Changeset 4923
- Timestamp:
- 02/18/2017 11:39:32 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/inc/class-plugin.php
r4325 r4923 45 45 add_filter( 'wporg_translate_language_pack_theme_args', array( $this, 'set_version_for_twentyseventeen_language_pack' ), 10, 2 ); 46 46 47 // Toolbar. 48 add_action( 'admin_bar_menu', array( $this, 'add_profile_settings_to_admin_bar' ) ); 49 add_action( 'admin_bar_init', array( $this, 'show_admin_bar' ) ); 50 add_action( 'add_admin_bar_menus', array( $this, 'remove_admin_bar_menus' ) ); 51 52 add_action( 'template_redirect', array( $this, 'jetpack_stats' ), 1 ); 53 47 54 // Load the API endpoints. 48 55 add_action( 'rest_api_init', array( __NAMESPACE__ . '\REST_API\Base', 'load_endpoints' ) ); … … 51 58 $this->register_cli_commands(); 52 59 } 60 } 61 62 /** 63 * Adds support for Jetpack Stats. 64 */ 65 public function jetpack_stats() { 66 if ( ! function_exists( 'stats_hide_smile_css' ) ) { 67 return; 68 } 69 70 add_action( 'gp_head', 'stats_hide_smile_css' ); 71 add_action( 'gp_head', 'stats_admin_bar_head', 100 ); 72 add_action( 'gp_footer', 'stats_footer', 101 ); 73 } 74 75 /** 76 * Renders the toolbar. 77 */ 78 public function show_admin_bar() { 79 add_action( 'gp_head', 'wp_admin_bar_header' ); 80 add_action( 'gp_head', '_admin_bar_bump_cb' ); 81 82 gp_enqueue_script( 'admin-bar' ); 83 gp_enqueue_style( 'admin-bar' ); 84 85 add_action( 'gp_footer', 'wp_admin_bar_render', 1000 ); 86 } 87 88 /** 89 * Adds the linkt to profile settings to the user actions toolbar menu. 90 * 91 * @param \WP_Admin_Bar $wp_admin_bar 92 */ 93 public function add_profile_settings_to_admin_bar( $wp_admin_bar ) { 94 $logout_node = $wp_admin_bar->get_node( 'logout' ); 95 $wp_admin_bar->remove_node( 'logout' ); 96 97 $wp_admin_bar->add_node( [ 98 'parent' => 'user-actions', 99 'id' => 'gp-profile-settings', 100 'title' => 'Translate Settings', 101 'href' => gp_url( '/settings' ), 102 ] ); 103 104 if ( $logout_node ) { 105 $wp_admin_bar->add_node( $logout_node ); // Ensures that logout is the last action. 106 } 107 } 108 109 /** 110 * Removes default toolbar menus which are not needed. 111 */ 112 public function remove_admin_bar_menus() { 113 remove_action( 'admin_bar_menu', 'wp_admin_bar_search_menu', 4 ); 114 remove_action( 'admin_bar_menu', 'wp_admin_bar_comments_menu', 60 ); 115 remove_action( 'admin_bar_menu', 'wp_admin_bar_new_content_menu', 70 ); 116 remove_action( 'admin_bar_menu', 'wp_admin_bar_edit_menu', 80 ); 53 117 } 54 118
Note: See TracChangeset
for help on using the changeset viewer.