Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making a theme plugin work, invalid function name
#1
Exclamation 
I like how you're using MyBB for forums, good choice!
Okay so I'm trying to make a plugin and I'm coming up against some problems, the latest being:
Quote:Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'foundation_show' not found or invalid function name in C:\xampp\htdocs\GetSimple\admin\load.php on line 38

I'll paste both my template and my plugin and lang file here:
template.php
PHP Code:
function Foundation_Parent_Link($name) {
    
$file GSDATAPAGESPATH $name .'.xml';
    if (
file_exists($file)) {
        
$p getXML($file);
        
$title $p->title;
        
$parent $p->parent;
        
$slug $p->slug;
        echo 
'<a href="'find_url($name,'') .'">'$title .'</a> &nbsp;&nbsp;•&nbsp;&nbsp; ';
    }
};
function 
Foundation_Settings() {
    
$file GSDATAOTHERPATH 'FoundationSettings.xml';
    if (
file_exists($file)) {
        
$p getXML($file);
        if (
$p->facebook != '' define('FACEBOOK'$p->facebook);
        if (
$p->twitter != '' define('TWITTER'$p->twitter);
        if (
$p->linkedin != '' define('LINKEDIN'$p->linkedin);
        if (
$p->linkedin != '' define('TUMBLR'$p->tumblr);
        if (
$p->linkedin != '' define('INSTAGRAM'$p->instagram);
        if (
$p->youtube != '' define('YOUTUBE'$p->youtube);
        if (
$p->vimeo != '' define('VIMEO'$p->vimeo);
        if (
$p->github != '' define('GITHUB'$p->github);
        if (
$p->webfont != '' define('WEBFONT'$p->webfont);
        return 
true;
    } else {
        return 
false;
    }
};
?>
<!DOCTYPE html>
**my template formatting**
<?php if (defined('FACEBOOK')) { ?>
    <a href="<?php echo FACEBOOK?>"><img src="<?php get_theme_url(); ?>/images/facebook.png" /></a>
    <?php ?>
    <?php if (defined('TWITTER')) { ?>
    <a href="<?php echo TWITTER?>"><img src="<?php get_theme_url(); ?>/images/twitter.png" /></a>
    <?php ?>
    <?php if (defined('LINKEDIN')) { ?>
    <a href="<?php echo LINKEDIN?>"><img src="<?php get_theme_url(); ?>/images/linkedin.png" /></a>
    <?php ?>
    <?php if (defined('TUMBLR')) { ?>
    <a href="<?php echo TUMBLR?>"><img src="<?php get_theme_url(); ?>/images/tumblr.png" /></a>
    <?php ?>
    <?php if (defined('INSTAGRAM')) { ?>
    <a href="<?php echo INSTAGRAM?>"><img src="<?php get_theme_url(); ?>/images/instagram.png" /></a>
    <?php ?>
    <?php if (defined('YOUTUBE')) { ?>
    <a href="<?php echo YOUTUBE?>"><img src="<?php get_theme_url(); ?>/images/youtube.png" /></a>
    <?php ?>
    <?php if (defined('VIMEO')) { ?>
    <a href="<?php echo VIMEO?>"><img src="<?php get_theme_url(); ?>/images/vimeo.png" /></a>
    <?php ?>
    <?php if (defined('GITHUB')) { ?>
    <a href="<?php echo GITHUB?>"><img src="<?php get_theme_url(); ?>/images/github.png" /></a>
    <?php ?>
    </div><!-- end Social
**rest of template formatting** 

the plugin file FoundationPlugin:
PHP Code:
# get correct id for plugin
$thisfile_found=basename(__FILE__".php");
$foundation_file=GSDATAOTHERPATH .'FoundationSettings.xml';

# add in this plugin's language file
i18n_merge($thisfile_found) || i18n_merge($thisfile_found'en_US');

# register plugin
register_plugin(
    
$thisfile_found,                                                     # ID of plugin, should be filename minus php
    
i18n_r($thisfile_found.'/FOUNDATION_TITLE'),                 # Title of plugin
    
'1.0',                                                             # Version of plugin
    
'Levy Image',                                            # Author of plugin
    
'http://webdevandphoto.com',             # Author URL
    
i18n_r($thisfile_found.'/FOUNDATION_DESC'),                     # Plugin Description
    
'theme',                                                         # Page type of plugin
    
'foundation_show'                                      # Function that displays content
);



# hooks
add_action('theme-sidebar','createSideMenu',array($thisfile_foundi18n_r($thisfile_found.'/FOUNDATION_TITLE'))); 

# get XML data
if (file_exists($foundation_file)) {
    
$x getXML($foundation_file);
    
$facebook $x->facebook;
    
$twitter $x->twitter;
    
$linkedin $x->linkedin;
    
$tumblr $x->tumblr;
    
$instagram $x->instagram;
    
$youtube $x->youtube;
    
$vimeo $x->vimeo;
    
$github $x->github;
} else {
    
$facebook '';
    
$twitter '';
    
$linkedin '';
    
$tumblr '';
    
$instagram '';
    
$youtube '';
    
$vimeo '';
    
$github '';
}


function 
innovation_show() {
    global 
$innovation_file$facebook$twitter$linkedin$tumblr$instagram$youtube$vimeo$github$thisfile_found;
    
$success=null;$error=null;
    
    
// submitted form
    
if (isset($_POST['submit'])) {
        
$facebook=null;    $twitter=null$linkedin=null$tumblr=null$instagram=null$youtube=null$vimeo=null$github=null;
        
        
# check to see if the URLs provided are valid
        
if ($_POST['facebook'] != '') {
            if (
validate_url($_POST['facebook'])) {
                
$facebook $_POST['facebook'];
            } else {
                
$error .= i18n_r($thisfile_found.'/FACEBOOK_ERROR').' ';
            }
        }
        
        if (
$_POST['twitter'] != '') {
            if (
validate_url($_POST['twitter'])) {
                
$twitter $_POST['twitter'];
            } else {
                
$error .= i18n_r($thisfile_found.'/TWITTER_ERROR').' ';
            }
        }
        
        if (
$_POST['linkedin'] != '') {
            if (
validate_url($_POST['linkedin'])) {
                
$linkedin $_POST['linkedin'];
            } else {
                
$error .= i18n_r($thisfile_found.'/LINKEDIN_ERROR').' ';
            }
        }
        if (
$_POST['tumblr'] != '') {
            if (
validate_url($_POST['tumblr'])) {
                
$tumblr $_POST['tumblr'];
            } else {
                
$error .= i18n_r($thisfile_found.'/TUMBLR_ERROR').' ';
            }
        }
        if (
$_POST['instagram'] != '') {
            if (
validate_url($_POST['instagram'])) {
                
$instagram $_POST['instagram'];
            } else {
                
$error .= i18n_r($thisfile_found.'/INSTAGRAM_ERROR').' ';
            }
        }
        if (
$_POST['youtube'] != '') {
            if (
validate_url($_POST['youtube'])) {
                
$youtube $_POST['youtube'];
            } else {
                
$error .= i18n_r($thisfile_found.'/YOUTUBE_ERROR').' ';
            }
        }
        if (
$_POST['vimeo'] != '') {
            if (
validate_url($_POST['vimeo'])) {
                
$vimeo $_POST['vimeo'];
            } else {
                
$error .= i18n_r($thisfile_found.'/VIMEO_ERROR').' ';
            }
        }
        if (
$_POST['github'] != '') {
            if (
validate_url($_POST['github'])) {
                
$github $_POST['github'];
            } else {
                
$error .= i18n_r($fthisfile_innov.'/GITHUB_ERROR').' ';
            }
        }
        
        
# if there are no errors, dave data
        
if (!$error) {
            
$xml = @new SimpleXMLElement('<item></item>');
            
$xml->addChild('facebook'$facebook);
            
$xml->addChild('twitter'$twitter);
            
$xml->addChild('linkedin'$linkedin);
            
$xml->addChild('tumblr'$tumblr);
            
$xml->addChild('instagram'$instagram);
            
$xml->addChild('youtube'$youtube);
            
$xml->addChild('vimeo'$vimeo);
            
$xml->addChild('github'$github);
            
            if (! 
$xml->asXML($foundation_file)) {
                
$error i18n_r('CHMOD_ERROR');
            } else {
                
$x getXML($foundation_file);
                
$facebook $x->facebook;
                
$twitter $x->twitter;
                
$linkedin $x->linkedin;
                
$tumblr $x->tumblr;
                
$instagram $x->instagram;
                
$youtube $x->youtube;
                
$vimeo $x->vimeo;
                
$github $x->github;
                
$success i18n_r('SETTINGS_UPDATED');
            }
        }
    }
    
    
?>
    <h3><?php i18n($thisfile_found.'/FOUNDATION_TITLE'); ?></h3>
    
    <?php 
    
if($success) { 
        echo 
'<p style="color:#5da423;"><b>'$success .'</b></p>';
    } 
    if(
$error) { 
        echo 
'<p style="color:#c60f13;"><b>'$error .'</b></p>';
    }
    
?>
    
    <form method="post" action="<?php    echo $_SERVER ['REQUEST_URI']?>">
        
        <p><label for="inn_facebook" ><?php i18n($thisfile_found.'/FACEBOOK_URL'); ?></label><input id="inn_facebook" name="facebook" class="text" value="<?php echo $facebook?>" type="url" /></p>
        <p><label for="inn_twitter" ><?php i18n($thisfile_found.'/TWITTER_URL'); ?></label><input id="inn_twitter" name="twitter" class="text" value="<?php echo $twitter?>" type="url" /></p>
        <p><label for="inn_linkedin" ><?php i18n($thisfile_found.'/LINKEDIN_URL'); ?></label><input id="inn_linkedin" name="linkedin" class="text" value="<?php echo $linkedin?>" type="url" /></p>
        <p><label for="inn_tumblr" ><?php i18n($thisfile_found.'/TUMBLR_URL'); ?></label><input id="inn_tumblr" name="tumblr" class="text" value="<?php echo $tumblr?>" type="url" /></p>
        <p><label for="inn_instagram" ><?php i18n($thisfile_found.'/INSTAGRAM_URL'); ?></label><input id="inn_instagram" name="instagram" class="text" value="<?php echo $instagram?>" type="url" /></p>
        <p><label for="inn_youtube" ><?php i18n($thisfile_found.'/YOUTUBE_URL'); ?></label><input id="inn_youtube" name="youtube" class="text" value="<?php echo $youtube?>" type="url" /></p>
        <p><label for="inn_vimeo" ><?php i18n($thisfile_found.'/VIMEO_URL'); ?></label><input id="inn_vimeo" name="vimeo" class="text" value="<?php echo $vimeo?>" type="url" /></p>
        <p><label for="inn_github" ><?php i18n($thisfile_found.'/GITHUB_URL'); ?></label><input id="inn_github" name="github" class="text" value="<?php echo $github?>" type="url" /></p>
        
        <p><input type="submit" id="submit" class="submit" value="<?php i18n('BTN_SAVESETTINGS'); ?>" name="submit" /></p>
    </form>
    
    <?php


and the language file for the plugin:
PHP Code:
$i18n = array (
    
    
"FOUNDATION_TITLE"=>  "FoundationNation Theme Settings",
    
"FOUNDATION_DESC" =>  "Settings for the default GetSimple theme: FoundationNation",
    
"FACEBOOK_ERROR"    =>    "Facebook URL is not valid.",
    
"TWITTER_ERROR"        =>    "Twitter URL is not valid.",
    
"LINKEDIN_ERROR"    =>    "LinkedIn URL is not valid.",
    
"TUMBLR_ERROR"    =>    "Tumblr URL is not valid.",
    
"INSTAGRAM_ERROR"    =>    "Instagram URL is not valid.",
    
"YOUTUBE_ERROR"    =>    "Youtube URL is not valid.",
    
"VIMEO_ERROR"    =>    "Vimeo URL is not valid.",
    
"GITHUB_ERROR"    =>    "Github URL is not valid.",
    
"FACEBOOK_URL"        =>    "Facebook URL",
    
"TWITTER_URL"        =>    "Twitter URL",
    
"LINKEDIN_URL"        =>    "LinkedIn URL",
    
"TUMBLR_URL"        =>    "Tumblr URL",
    
"INSTAGRAM_URL"        =>    "Instagram URL",
    
"YOUTUBE_URL"        =>    "Youtube URL",
    
"VIMEO_URL"        =>    "Vimeo URL",
    
"GITHUB_URL"        =>    "Github URL"
); 

I am testing via localhost with XAMPP on Windows 7 x64, all dependencies are good.

Any help with this plugin so I can move on to finishing this theme would be much appreciated! Thank you.

The theme will incorporate Foundation 3 CSS framework and a plethora of great jQuery functions.

If you're a fellow MyBB developer you can find my MyBB account here:
http://community.mybb.com/user-63717.html

attachment is just for adding a image to my sig on this forum.
   
Reply
#2
function 'foundation_show' not found
pretty simple
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#3
change your function name from innovation_show() to foundation_show()
My Github Repos: Github
Website: DigiMute
Reply
#4
(2013-02-13, 10:44:19)n00dles101 Wrote: change your function name from innovation_show() to foundation_show()

OH SOB! I failed at being captain obvious there... lol Thank you guys!
No errors now, XML file is generated, and images are parsing fine Big Grin
Reply




Users browsing this thread: 1 Guest(s)