1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107:
<?php
class Inbound_Menus_Admin {
public function __construct() {
self::load_hooks();
}
public static function load_hooks() {
add_action('admin_menu', array( __CLASS__ , 'add_menu_items' ) , 1 );
add_filter( 'inbound_menu_debug' , array (__CLASS__ , 'load_debug_links') , 10 , 2);
}
public static function add_menu_items() {
if( !current_user_can('activate_plugins') ) {
return;
}
if (!defined('INBOUND_PRO_MENU_LABEL')) {
define('INBOUND_PRO_MENU_LABEL' , __( 'Inbound Pro' , 'inbound-pro' ) );
}
add_menu_page(
INBOUND_PRO_MENU_LABEL ,
INBOUND_PRO_MENU_LABEL ,
'edit_posts',
'inbound-pro',
array( 'Inbound_Pro_Settings' , 'display' ),
INBOUND_PRO_URLPATH . 'core/shared/assets/images/global/inbound-icon.png',
30
);
add_submenu_page('inbound-pro', __( 'Settings' , 'inbound-pro' ) , __( 'Settings' , 'inbound-pro' ) , 'manage_options', 'inbound-pro', array( 'Inbound_Pro_Settings' , 'display' ) );
add_submenu_page('inbound-pro', __( 'Templates' , 'inbound-pro' ) , __( 'Templates' , 'inbound-pro' ) , 'edit_posts', 'inbound-manage-templates', array( 'Inbound_Pro_Downloads' , 'display_ui' ) );
add_submenu_page('inbound-pro', __( 'Extensions' , 'inbound-pro' ) , __( 'Extensions' , 'inbound-pro' ) , 'edit_posts', 'inbound-manage-extensions', array( 'Inbound_Pro_Downloads' , 'display_ui' ) );
}
public static function load_debug_links( $secondary_menu_items , $debug_key ) {
$actual_link = "//$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$reset_templates_link = add_query_arg( array('inbound_reset_downloads_data' => true ) , admin_url('admin.php?page=inbound-manage-templates'));
$reset_extensions_link = add_query_arg( array('inbound_reset_downloads_data' => true ) , admin_url('admin.php?page=inbound-manage-extensions'));
$disable_inbound_pro_link = add_query_arg( array('inbound_off' => true ) , $actual_link);
$secondary_menu_items['inbound-pro-reset-templates'] = array(
'parent' => $debug_key,
'title' => __( 'Templates::Refresh Available Templates', 'inbound-pro' ),
'href' => $reset_templates_link,
'meta' => array( 'title' => __( 'Refresh available template data from Inbound Now.', 'inbound-pro' ) )
);
$secondary_menu_items['inbound-pro-reset-extensiond'] = array(
'parent' => $debug_key,
'title' => __( 'Extensions::Refresh Available Extensions', 'inbound-pro' ),
'href' => $reset_extensions_link,
'meta' => array( 'title' => __( 'Refresh available template data from Inbound Now.', 'inbound-pro' ) )
);
$secondary_menu_items['inbound-pro-disable'] = array(
'parent' => $debug_key,
'title' => __( 'Turn Inbound Pro Off For This Page', 'inbound-pro' ),
'href' => $disable_inbound_pro_link,
'meta' => array( 'title' => __( 'Tell WordPress not to load Inbound Pro on this page.', 'inbound-pro' ) )
);
return $secondary_menu_items;
}
}
$Inbound_Menus_Admin = new Inbound_Menus_Admin();