I have a plugin I'm developing. It works fine on a single site version of WordPress. It installs on a multisite version of WordPress, it appears to work on the admin pages, but when the plugin attempts to add javascript and css, it's not added.
The display portion of the code is as follows...
add_action('init', array(&$this, 'init'));
function init() {
// Gather gallery and template variables
$url = explode('?', 'http://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
$ID = url_to_postid($url[0]);
load_plugin_textdomain('ngTemplateCreator', ngTemplateCreator_DIR . '/lang', basename(dirname(__FILE__)) . '/lang');
$t = get_post($ID);
$c = 0;
$regex_pattern = get_shortcode_regex();
preg_match_all('/' . $regex_pattern . '/s', $t->post_content, $regex_matches);
// loop thru shortcode
foreach ($regex_matches[3] as $key => $value) {
if ($regex_matches[2][$key] == 'nggtc') {
$c = $c + 1;
// Found a NextGEN gallery find out what ID
// Turn the attributes into a URL parm string
$attribureStr = str_replace(" ", "&", trim($value));
$attribureStr = str_replace('"', '', $attribureStr);
// Parse the attributes
$defaults = array(
'id' => 0,
'template' => ''
);
$attributes = wp_parse_args($attribureStr, $defaults);
if (isset($attributes["id"])) {
$this->gid = $attributes["id"];
}
if (isset($attributes["template"])) {
$this->tcname = $attributes["template"];
}
$wrapper = "nggtc_gallery_" . $this->gid . "_" . $c;
if (!empty($this->gid) && !empty($this->tcname)) {
$images = get_ngg_gallery($this->gid);
$templates = get_custom_template($this->tcname);
if ($templates && $images) {
foreach ($templates as $template) {
if ($template->bottom_javascript) {
$this->bottom_javascript = $this->bottom_javascript . process_script_shortcode($template->bottom_javascript, $wrapper, $panelid, $panelcss, $filmstripid, $filmstripcss) . "\r\n\r\n";
}
}
}
}
}
}
$this->count = $c;
if ($this->bottom_javascript) {
add_action('wp_footer', array(&$this, 'footerScripts'), 200);
}
wp_reset_query();
}
function process_script_shortcode($script, $wrapper, $panelid, $panelcss, $filmstripid, $filmstripcss) {
$out = remove_php($script);
// Swap shortcode
if($out) {
// strip html from filmstrip variables
$filmstripi = str_replace(" id=\"", "", $filmstripid);
$filmstrip = str_replace("\"", "", $filmstripi);
$filmstripcs = str_replace(" class=\"", "", $filmstripcss);
$filmstripc = str_replace("\"", "", $filmstripcs);
$out = str_replace("[wrapper]", $wrapper, $out);
$out = str_replace("[panel_id]", $panelid, $out);
$out = str_replace("[panel_css]", $panelcss, $out);
$out = str_replace("[filmstrip_id]", $filmstrip, $out);
$out = str_replace("[filmstrip_css]", $filmstripc, $out);
}
return $out;
}
function footerScripts() {
if (wp_script_is('jquery', 'done')) {
echo "<script type=\"text/javascript\" defer=\"defer\">" . $this->bottom_javascript . "</script>";
}
}
I'm only showing the function for my footer scripts, but none of the scripts and css are being shown, so I'm fairly certain the source of the error is the same.
Can anyone tell me where I'm going wrong here?
is_single()
might also be needed depending on what you're trying to do.