From c6f0eee6a712d92ae040c920301d33d08c392435 Mon Sep 17 00:00:00 2001 From: prcdevgitbot Date: Mon, 4 Mar 2024 16:57:48 +0000 Subject: [PATCH] See https://github.com/pewresearch/pewresearch-org/commit/23cd9c16da9ec90954ff091be97f2cc3e57181cc from refs/heads/release/5.0 --- includes/decoded/class-decoded.php | 4 +- includes/gutenberg/class-gutenberg.php | 9 ++-- includes/homepages/class-homepages.php | 4 +- includes/wp-admin/class-wp-admin.php | 65 ++++++++++++++++++++++++-- 4 files changed, 68 insertions(+), 14 deletions(-) diff --git a/includes/decoded/class-decoded.php b/includes/decoded/class-decoded.php index 82b07a38..d32479d6 100644 --- a/includes/decoded/class-decoded.php +++ b/includes/decoded/class-decoded.php @@ -80,8 +80,8 @@ public function register_type() { 'label' => __( 'Decoded', 'text_domain' ), 'description' => __( 'A post type for Decoded blog posts.', 'text_domain' ), 'labels' => $labels, - 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'revisions' ), - 'taxonomies' => array( 'formats' ), + 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'revisions', 'custom-fields' ), + 'taxonomies' => array( 'category', 'research-teams', 'collection', 'languages', 'formats' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, diff --git a/includes/gutenberg/class-gutenberg.php b/includes/gutenberg/class-gutenberg.php index 7be867f0..b5a716ee 100644 --- a/includes/gutenberg/class-gutenberg.php +++ b/includes/gutenberg/class-gutenberg.php @@ -76,6 +76,7 @@ public function load_gutenberg( $use_block_editor, $post ) { /** * Enable revisions for reusable blocks. * @hook init + * @TODO: Look into this, I'm pretty sure a recent Gutenberg release defaulted to this. */ public function add_revisions_to_reusable_blocks() { add_post_type_support( 'wp_block', 'revisions' ); @@ -91,12 +92,8 @@ public function group_admin_menus_together( $menu_order ) { $new_menu_order = array(); $reorder = array( - 'edit.php?post_type=topic-page', // Legacy - 'edit.php?post_type=template-block', // Legacy - 'edit.php?post_type=block_module', // New - 'edit.php?post_type=wp_block', // Core Patterns - 'edit.php?post_type=blockmeister_pattern', // Block Meister Patterns - 'admin.php?page=blockmeister', // Block Meister Settings + 'edit.php?post_type=block_module', + 'edit.php?post_type=wp_block', ); foreach ( $menu_order as $index => $item ) { diff --git a/includes/homepages/class-homepages.php b/includes/homepages/class-homepages.php index 35acdd15..8eb3d7c6 100644 --- a/includes/homepages/class-homepages.php +++ b/includes/homepages/class-homepages.php @@ -205,8 +205,8 @@ public function add_front_page_quick_edit( $admin_bar ) { $admin_bar->remove_menu( 'edit' ); $admin_bar->add_menu( array( - 'id' => 'edit-homepage', - 'title' => '' . _( 'Edit Homepage' ), + 'id' => 'edit', + 'title' => __( 'Edit Homepage' ), 'href' => $link, 'meta' => array( 'title' => __( 'Edit Homepage' ), diff --git a/includes/wp-admin/class-wp-admin.php b/includes/wp-admin/class-wp-admin.php index 83ad1a5d..20d5f61f 100644 --- a/includes/wp-admin/class-wp-admin.php +++ b/includes/wp-admin/class-wp-admin.php @@ -41,7 +41,7 @@ public function init($loader = null) { $loader->add_action( 'admin_enqueue_scripts', $this, 'enqueue_assets' ); $loader->add_action( 'login_enqueue_scripts', $this, 'login_logo' ); - $loader->add_action( 'wp_before_admin_bar_render', $this, 'admin_bar_tweaks' ); + $loader->add_action( 'wp_before_admin_bar_render', $this, 'admin_bar_tweaks', 100 ); $loader->add_filter( 'get_user_option_admin_color', $this, 'default_admin_color_scheme' ); $loader->add_action( 'admin_print_footer_scripts', $this, 'admin_footer' ); $loader->add_filter( 'disabled_cookiepro', $this, 'disable_cookie_banner_conditions', 10, 1 ); @@ -90,7 +90,8 @@ public function login_logo() { public function admin_bar_tweaks() { global $wp_admin_bar; - $tools_id = 'prc-tools'; + $tools_id = 'tools'; + $edit_id = 'edit'; $vip_cache_tool = $wp_admin_bar->get_node('vip-purge-page'); if ( $vip_cache_tool ) { @@ -115,6 +116,43 @@ public function admin_bar_tweaks() { $wp_admin_bar->remove_node('parsely-stats'); } + $yoast_redirect_tool = $wp_admin_bar->get_node('wpseo-premium-create-redirect'); + if ( $yoast_redirect_tool ) { + $yoast_redirect_tool->parent = $tools_id; + $yoast_redirect_tool = (array) $yoast_redirect_tool; + $wp_admin_bar->remove_node('wpseo-premium-create-redirect'); + } + + $my_account = $wp_admin_bar->get_node('my-account'); + if ( $my_account ) { + // I actualy just want to remove the "Howdy" part of the greeting, make it just the username. + $my_account->title = str_replace('Howdy, ', '', $my_account->title); + // now remove the existing node and then add it back again with the updated title + $wp_admin_bar->remove_node('my-account'); + $wp_admin_bar->add_node($my_account); + } + + $site_editor = $wp_admin_bar->get_node('site-editor'); + if ( $site_editor ) { + $site_editor->title = 'Edit Template'; + // now remove the existing node and then add it back again with the updated title + $site_editor->parent = $edit_id; + $wp_admin_bar->remove_node('site-editor'); + $wp_admin_bar->add_node($site_editor); + } + + $search = $wp_admin_bar->get_node('search'); + if ( $search ) { + $wp_admin_bar->remove_node('search'); + } + + $duplicate_post = $wp_admin_bar->get_node('duplicate-post'); + if ( $duplicate_post ) { + $duplicate_post->parent = $tools_id; + $duplicate_post = (array) $duplicate_post; + $wp_admin_bar->remove_node('duplicate-post'); + } + // create a new wp_admin bar node for my Attachments Report tool $attachments_tool = array( 'id' => 'attachments-report', @@ -126,7 +164,7 @@ public function admin_bar_tweaks() { ), ); - if ( $vip_cache_tool || $bitly_tool || $parsely_tool || $attachments_tool ) { + if ( $vip_cache_tool || $bitly_tool || $parsely_tool || $attachments_tool || $yoast_redirect_tool || $duplicate_post) { $wp_admin_bar->add_menu( array( 'id' => $tools_id, @@ -147,6 +185,25 @@ public function admin_bar_tweaks() { if ( $attachments_tool ) { $wp_admin_bar->add_node( $attachments_tool ); } + if ( $yoast_redirect_tool ) { + $wp_admin_bar->add_node( $yoast_redirect_tool ); + } + if ( $duplicate_post ) { + $wp_admin_bar->add_node( $duplicate_post ); + } + } + + // Organize an "Edit" menu + + $edit = $wp_admin_bar->get_node('edit'); + if ( !$edit ) { + $wp_admin_bar->add_menu( + array( + 'id' => $edit_id, + 'title' => 'Edit', + 'href' => '#', + ) + ); } // Remove fwp cache, comments @@ -208,7 +265,7 @@ public function admin_footer() { global $post_type; if ( isset( $post_type ) && is_string( $post_type ) ) { // add the post type to the javascript global object window.prcEditorPostType - echo ''; + echo wp_sprintf( '', esc_js($post_type) ); } }