Support » Plugin: Maintainn Tools » Maintainn_Tools_Dashboard::options_page isn’t defined on multisite network

  • Resolved Morgan Estes

    (@morganestes)


    In a subfolder multisite install, when I network activate the plugin it throws a notice:

    ( ! ) Notice: Undefined property: Maintainn_Tools_Dashboard::$options_page in /app/public/wp-content/plugins/maintainn-tools/includes/dashboard.php on line 110

    This is on http://example.dev/wp-admin/network/plugins.php?plugin_status=all&paged=1&s immediately following network activation, when the plugin’s add_network_options_page() is called and the action "admin_print_styles-{$this->options_page}" is called.

Viewing 6 replies - 1 through 6 (of 6 total)
  • I have a small patch that will set $options_page so the dynamic hook fires at the right time and loads the stylesheet. It sets Maintainn_Tools_Dashboard::options_page from the hook_suffix returned by add_menu_page() so it can be added to the right action for the network page.

    
    class Maintainn_Tools_Dashboard {
    
    	/**
    	 * The hook suffix for the options page.
    	 *
    	 * @var string
    	 * @since x.x.x
    	 */
    	protected $options_page = '';
    
    	public function add_network_options_page() {
    		$this->options_page = add_menu_page(
    			$this->title,
    			$this->title,
    			'manage_options',
    			$this->key,
    			array( $this, 'render_page' )
    		);
    
    		// Include CMB CSS in the head to avoid FOUC.
    		add_action( "admin_print_styles-{$this->options_page}", array( 'CMB2_hookup', 'enqueue_cmb_css' ) );
    	}
    }
    
    • This reply was modified 4 months, 2 weeks ago by  Jose Castaneda. Reason: fixed code

    Sorry for the formatting, here it is again:

    class Maintainn_Tools_Dashboard {
    
    	/**
    	 * The hook suffix for the options page.
    	 *
    	 * @var string
    	 * @since x.x.x
    	 */
    	protected $options_page = '';
    
    	public function add_network_options_page() {
    		$this->options_page = add_menu_page(
    			$this->title,
    			$this->title,
    			'manage_options',
    			$this->key,
    			array( $this, 'render_page' )
    		);
    
    		// Include CMB CSS in the head to avoid FOUC.
    		add_action( "admin_print_styles-{$this->options_page}", array( 'CMB2_hookup', 'enqueue_cmb_css' ) );
    	}
    }
    Plugin Author Michael Beckwith

    (@tw2113)

    Thanks Morgan, will get this taken care of.

    Plugin Author Michael Beckwith

    (@tw2113)

    And committed. Thanks again.

    I noticed after some more testing that my change only loads the CMB2 stylesheet on the main options page but not any of the tabs. If it needs to load on the tabs pages, that’s a different hook that fires (because if course it is :/).

    I’m happy to share another patch to load those styles if they’re needed in the tabs.

    Plugin Author Michael Beckwith

    (@tw2113)

    As is, it looks like it’s fine. We don’t rely too heavily on CMB2 styles. Mostly the fields themselves and the saving process.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.