コード例 #1
0
ファイル: loco-admin.php プロジェクト: the-xenon/someshops
/**
 * Admin menu registration callback
 */
function _loco_hook__admin_menu()
{
    $cap = Loco::admin_capablity();
    if (current_user_can($cap)) {
        // hook in legacy wordpress styles as menu will display
        $wp_38 = version_compare($GLOBALS['wp_version'], '3.8', '>=') or Loco::enqueue_styles('loco-legacy');
        $page_title = Loco::__('Loco, Translation Management');
        $tool_title = Loco::__('Manage translations');
        $opts_title = Loco::__('Translation options');
        // Loco main menu item
        $slug = Loco::NS;
        $title = $page_title . ' - ' . $tool_title;
        $page = array('LocoAdmin', 'render_page_tools');
        // Dashicons were introduced in WP 3.8
        $icon = $wp_38 ? 'dashicons-translation' : 'none';
        add_menu_page($title, Loco::__('Loco Translate'), $cap, $slug, $page, $icon);
        // add main link under self with different name
        add_submenu_page($slug, $title, $tool_title, $cap, $slug, $page);
        // also add under Tools menu (legacy)
        add_management_page($title, $tool_title, $cap, $slug . '-legacy', $page);
        // Settings page
        $slug = Loco::NS . '-settings';
        $title = $page_title . ' - ' . $opts_title;
        $page = array('LocoAdmin', 'render_page_options');
        add_submenu_page(Loco::NS, $title, $opts_title, $cap, $slug, $page);
        // also add under Settings menu (legacy)
        add_options_page($title, $opts_title, $cap, $slug . '-legacy', $page);
        /*/ Diagnostics page - enabled in debug mode only
          if( WP_DEBUG ){
             $diag_title = Loco::__('Diagnostics');
              $page = array( 'LocoAdmin', 'render_page_diagnostics' );
              add_submenu_page( Loco::NS, $page_title.' - '.$diag_title, $diag_title, $cap, Loco::NS.'-diagnostics', $page );
          }*/
        // Hook in page stuff as soon as screen is avaiable
        add_action('current_screen', '_loco_hook__current_screen');
    }
}