Skip to content

Instantly share code, notes, and snippets.

@samuelaguilera
Forked from norcross/yoast-ga-menu-move.php
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuelaguilera/ebc88abbfa7048486523 to your computer and use it in GitHub Desktop.
Save samuelaguilera/ebc88abbfa7048486523 to your computer and use it in GitHub Desktop.
<?php
/**
* move the main settings page for Yoast Google Analytics
* from it's own parent menu into a submenu page in either
* the Yoast SEO menu or in the general settings
*
* @return null
*/
function rkv_yoast_ga_menu() {
// check for the defined path in the event that the plugin
// has been removed
if ( ! defined( 'GAWP_PATH' ) ) {
return;
}
// first remove the top level menu item
remove_menu_page( 'yst_ga_dashboard' );
// check for Yoast SEO plugin first
// and if present, add the item there
if ( function_exists( 'wpseo_auto_load' ) ) {
add_submenu_page( 'wpseo_dashboard', __( 'Google Analytics', 'google-analytics-for-wordpress' ), __( 'Google Analytics', 'google-analytics-for-wordpress' ), 'manage_options', 'yst_ga_settings', 'rkv_yoast_ga_page' );
} else {
// Yoast SEO not installed, just put it into main settings
add_options_page( __( 'Yoast Google Analytics', 'google-analytics-for-wordpress' ), __( 'Yoast Google Analytics', 'google-analytics-for-wordpress' ), 'manage_options', 'admin.php?page=yst_ga_settings', 'rkv_yoast_ga_page' );
}
}
add_action( 'admin_menu', 'rkv_yoast_ga_menu', 999 );
/**
* call the files required for the Yoast GA page to
* render properly
* @return [type] [description]
*/
function rkv_yoast_ga_page() {
// check for the defined path in the event that the plugin
// has been removed
if ( ! defined( 'GAWP_PATH' ) ) {
return;
}
// load our two files
require_once( GAWP_PATH . 'admin/class-admin-ga-js.php' );
require_once( GAWP_PATH . 'admin/pages/settings.php' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment