WordPress.org

Forums

Bannerspace Slideshow
[resolved] Static Methods need updating (8 posts)

  1. Andi Lee Davis
    Member
    Posted 11 months ago #

    I'm getting the warning below because my dev server error reporting is set to E_ALL, but this sometimes helps with feedback to the developers of the plugins I use.

    Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method bannerspace_plugin_options::update() should not be called statically in /media/DriveD/sdb1/www/www.website.dev/wp-includes/plugin.php on line 470

    Strict Standards: Non-static method bannerspace_plugin_options::BS_getOptions() should not be called statically in /media/DriveD/sdb1/www/www.website.dev/wp-content/plugins/bannerspace/bannerspace.php on line 124

    You may need to update the function call from the class.

    I.E.

    class myClass {
         public function helloWorld() {
            echo "Hello, World!";
        }
    }
    $example = new myClass();
    call_user_func(array($example, 'helloWorld'));

    Not sure, I believe the issue may actually occur on line 315

    // register functions
    add_action('admin_menu', array('bannerspace_plugin_options', 'update'));

    You are calling the function directly in the add action without creating the class? But then the add_action should be also declared in the construct method of the class:

    Please see here about this:
    http://codex.wordpress.org/Function_Reference/add_action

    public function __construct() {
             //add your actions to the constructor!
             add_action( 'admin_menu', array( $this, 'update' ) );
        }

    As I say this is not a problem on as is a warning but you may want to consider fixing it.

    thanks

    Andi

    https://wordpress.org/plugins/bannerspace/

  2. Andi Lee Davis
    Member
    Posted 11 months ago #

    ok Here is the solution:

    on line 35 in bannerspace.php put in the constructor to add the action

    public function __construct() {
             //add your actions to the constructor!
             add_action( 'admin_menu', array( $this, 'update' ) );
        }

    on Line 324 rplace

    add_action('admin_menu', array('bannerspace_plugin_options','construct'));

    with this

    $banner_space = new bannerspace_plugin_options;

    That calls the class and the constructor adds the action.

    Thanks

    Andi

  3. Andi Lee Davis
    Member
    Posted 11 months ago #

    however... there are other errors on other lines now with the same message. If you do this you will have to re-write several lines.

  4. Andi Lee Davis
    Member
    Posted 11 months ago #

    using this within the class to get the instance may help:
    Not sure will have a look into it further at some other point

    private static $__instance = NULL;
    	public function __construct() {
             //add your actions to the constructor!
    		 add_action( 'admin_menu', array( $this, 'update' ) );
        }
    	private function __clone(){}
       	static public function getInstance(){
            if(self::$__instance == NULL) self::$__instance = new bannerspace_plugin_options;
            return self::$__instance;
        }

    when calling the from inside the methods we can use

    $banner_space = bannerspace_plugin_options::getInstance();
    		$options = $banner_space->BS_getOptions();
  5. Andi Lee Davis
    Member
    Posted 11 months ago #

    ok fixed all these errors now.

    line 35 within the class add this construct

    public function __construct() {
             //add your actions to the constructor!
    		 add_action( 'admin_menu', array( $this, 'update' ) );
        }

    line 132 call the class object by $this keyword instead...
    See here... http://codex.wordpress.org/Function_Reference/add_submenu_page

    /// replace - add_submenu_page( 'options-general.php', 'Bannerspace Options', 'Bannerspace Options', 'edit_theme_options', basename(__FILE__), array('bannerspace_plugin_options', 'display'));
    
    add_submenu_page( 'options-general.php', 'Bannerspace Options', 'Bannerspace Options', 'edit_theme_options', basename(__FILE__), array($this, 'display'));

    around line 319 call the class instead.

    // register functions
    // - replaced add_action('admin_menu', array('bannerspace_plugin_options','construct'));
    
    $banner_space = new bannerspace_plugin_options;

    Hope this helps.

    thanks

    Andi

  6. Andi Lee Davis
    Member
    Posted 11 months ago #

    Also you should consider changing these bool checks as result in undefined variable errors
    around line 95
    if ($_POST['hide_content'])

    this will work better instead
    if (isset($_POST['hide_content']) && $_POST['hide_content'])

    thanks

    Andi

  7. Andi Lee Davis
    Member
    Posted 11 months ago #

    Same with these...

    if (isset($_POST['show_arrows']) && $_POST['show_arrows'])
    				$options['show_arrows'] = (bool)true;
    			else
    				$options['show_arrows'] = (bool)false;
    
    			if (isset($_POST['show_paging']) && $_POST['show_paging'])
    				$options['show_paging'] = (bool)true;
    			else
    				$options['show_paging'] = (bool)false;

    If the developer of this plugin contacts me I can send an updated zipped file with all the fixes to this plugin.

  8. THRIVE - Web Design Gold Coast
    Member
    Plugin Author

    Posted 10 months ago #

    Hi Andi. Thanks for this. Feel free to email me at contact@thriveweb.com.au. I'll include it in the next update :)

Reply

You must log in to post.

About this Plugin

  • Bannerspace Slideshow
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic