WordPress custom filter giving errors in debug

I’m just learning how to use wordpress filters to make my custom plugin extensible. To my main plugin I have the following function, and filter:

static function get_pages( $page_slug = '' ) {

    $pages = array();
    // Default page properties
    $default_args = array(
        'menu-title' => '',
        'tab-title' => '',
        'parent' => 'admin.php',
        'in-menu' => false,
        'has-tab' => true,
        'tab-side' => false,
        'top-level' => false,
    );

    $pages['sat-options-general'] = array_merge(
        $default_args,
        array(
            'slug' => 'sat-options-general',
            'menu-title' => _x( 'Admin Theme', 'Page title in the menu', 'skizzar_admin_theme' ),
            'tab-title' => _x( 'Admin Theme Options', 'Option tab title', 'skizzar_admin_theme' ),
            'title' => _x( 'Admin Theme Options', 'Option page title', 'skizzar_admin_theme' ),
            'callback' => array( __CLASS__, 'display_general_options_page' ),
            'in-menu' => true,
            'top-level' => true,
        )
    );

    $pages['sat-addons'] = array_merge(
        $default_args,
        array(
            'slug' => 'sat-addons',
            'menu-title' => _x( 'Addons', 'Page title in the menu', 'skizzar_admin_theme' ),
            'tab-title' => _x( 'Addons', 'Option tab title', 'skizzar_admin_theme' ),
            'title' => _x( 'Browse Addons', 'Option page title', 'skizzar_admin_theme' ),
            'callback' => array( __CLASS__, 'display_addons_page' ),
            'in-menu' => true,
        )
    );

    // Return
    if ( $page_slug ) {
        if ( ! isset( $pages[ $page_slug ] ) ) {
            return null;
        }
        return $pages[ $page_slug ];
    }

    return apply_filters( 'skizzar_admin_theme_tab', $pages, $default_args, $page_slug );
}

This function allows me to define attributes for creating plugin pages and adding tabs to the top of the plugin page, along with other uses.

Read More

I have created an addon plugin to extend this, in this plugin I have the following function:

add_filter( 'skizzar_admin_theme_tab', array(&$this, 'add_google_analytics_tab'), 1, 3 );

function add_google_analytics_tab( $pages, $default_args, $page_slug ) {

    if(is_multisite()) {
        $is_multisite = '_network';
    } else {
        $is_multisite = '_site';
    }

    $pages['sat-google-analytics'] = array_merge(
            $default_args,
            array(
                'slug' => 'sat-google-analytics',
                'menu-title' => _x( 'Google Analytics', 'Page title in the menu', 'skizzar_admin_theme' ),
                'tab-title' => _x( 'Google Analytics', 'Option tab title', 'skizzar_admin_theme' ),
                'title' => _x( 'Google Analytics Settings', 'Option page title', 'skizzar_admin_theme' ),
                'callback' => array( &$this, 'output'.$is_multisite.'_settings_page' ), // callback changes on multisite
                'in-menu' => true,
            )
        );

        // Return
        if ( $page_slug ) {
            if ( ! isset( $pages[ $page_slug ] ) ) {
                return null;
            }
            return $pages[ $page_slug ];
        }    

        return $pages;
}

This works, in that it adds the page and tab (although the link in the tab is incorrect). However, it throws up the following erros in my debug file, which I’m not sure how to fix:

[21-Mar-2016 10:22:19 UTC] PHP Warning:  Missing argument 2 for Google_Analytics_Async::add_google_analytics_tab(), called in /usr/share/nginx/skizzar/wp-content/plugins/skizzar-google-analytics/skizzar-google-analytics.php on line 286 and defined in /usr/share/nginx/skizzar/wp-content/plugins/skizzar-google-analytics/skizzar-google-analytics.php on line 238
[21-Mar-2016 10:22:19 UTC] PHP Warning:  Missing argument 3 for Google_Analytics_Async::add_google_analytics_tab(), called in /usr/share/nginx/skizzar/wp-content/plugins/skizzar-google-analytics/skizzar-google-analytics.php on line 286 and defined in /usr/share/nginx/skizzar/wp-content/plugins/skizzar-google-analytics/skizzar-google-analytics.php on line 238
[21-Mar-2016 10:22:19 UTC] PHP Notice:  Undefined variable: default_args in /usr/share/nginx/skizzar/wp-content/plugins/skizzar-google-analytics/skizzar-google-analytics.php on line 247
[21-Mar-2016 10:22:19 UTC] PHP Warning:  array_merge(): Argument #1 is not an array in /usr/share/nginx/skizzar/wp-content/plugins/skizzar-google-analytics/skizzar-google-analytics.php on line 256
[21-Mar-2016 10:22:19 UTC] PHP Warning:  Illegal string offset 'sat-google-analytics' in /usr/share/nginx/skizzar/wp-content/plugins/skizzar-google-analytics/skizzar-google-analytics.php on line 246
[21-Mar-2016 10:22:19 UTC] PHP Notice:  Undefined variable: page_slug in /usr/share/nginx/skizzar/wp-content/plugins/skizzar-google-analytics/skizzar-google-analytics.php on line 259

Related posts