Skip to content

Commit

Permalink
See pewresearch/pewresearch-org@c92ddfb from refs/heads/release/5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
prcdevgitbot committed Mar 5, 2024
1 parent a5435f0 commit f618805
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 18 deletions.
4 changes: 2 additions & 2 deletions includes/decoded/class-decoded.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 3 additions & 6 deletions includes/gutenberg/class-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand All @@ -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 ) {
Expand Down
4 changes: 2 additions & 2 deletions includes/homepages/class-homepages.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '<span class="ab-icon dashicons dashicons-admin-home"></span>' . _( 'Edit Homepage' ),
'id' => 'edit',
'title' => __( 'Edit Homepage' ),
'href' => $link,
'meta' => array(
'title' => __( 'Edit Homepage' ),
Expand Down
140 changes: 132 additions & 8 deletions includes/wp-admin/class-wp-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ 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, 'manage_admin_bar', 100 );
$loader->add_action( 'wp_before_admin_bar_render', $this, 'manage_tools_menu', 101 );
$loader->add_action( 'wp_before_admin_bar_render', $this, 'manage_edit_menu', 102 );
$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 );
Expand Down Expand Up @@ -87,11 +89,15 @@ public function login_logo() {
<?php
}

public function admin_bar_tweaks() {
public function manage_tools_menu() {
global $wp_admin_bar;

$tools_id = 'prc-tools';
$tools_id = 'tools';
$edit_id = 'edit';

/**
* Tools Menu
*/
$vip_cache_tool = $wp_admin_bar->get_node('vip-purge-page');
if ( $vip_cache_tool ) {
$vip_cache_tool->parent = $tools_id;
Expand All @@ -105,7 +111,6 @@ public function admin_bar_tweaks() {
$bitly_tool->parent = $tools_id;
$bitly_tool = (array) $bitly_tool;
$wp_admin_bar->remove_node('reset-bitly-link');

}

$parsely_tool = $wp_admin_bar->get_node('parsely-stats');
Expand All @@ -115,7 +120,21 @@ public function admin_bar_tweaks() {
$wp_admin_bar->remove_node('parsely-stats');
}

// create a new wp_admin bar node for my Attachments Report tool
$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');
}

$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 the new Attachment Report tool
$attachments_tool = array(
'id' => 'attachments-report',
'title' => 'Attachments Report',
Expand All @@ -126,15 +145,14 @@ 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,
'title' => 'Tools',
'href' => '#',
)
);

if ( $vip_cache_tool ) {
$wp_admin_bar->add_node( $vip_cache_tool );
}
Expand All @@ -147,6 +165,54 @@ 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 );
}
}

/**
* Edit Menu
*/
$edit = $wp_admin_bar->get_node('edit');
if ( !$edit && is_user_logged_in() ) {
$wp_admin_bar->add_menu(
array(
'id' => $edit_id,
'title' => 'Edit',
'href' => '#',
)
);
}
$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);
}

/**
* Other/Misc
*/

// Get rid of the "Howdy" in the Profile link
$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);
}

// Remove Search
$search = $wp_admin_bar->get_node('search');
if ( $search ) {
$wp_admin_bar->remove_node('search');
}

// Remove fwp cache, comments
Expand All @@ -161,6 +227,64 @@ public function admin_bar_tweaks() {
}
}

public function manage_edit_menu() {
global $wp_admin_bar;
$edit_id = 'edit';

/**
* Edit Menu
*/
$edit = $wp_admin_bar->get_node('edit');
if ( !$edit && is_user_logged_in() ) {
$wp_admin_bar->add_menu(
array(
'id' => $edit_id,
'title' => 'Edit',
'href' => '#',
)
);
}
$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);
}
}

public function manage_admin_bar() {
global $wp_admin_bar;
/**
* Other/Misc
*/

// Get rid of the "Howdy" in the Profile link
$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);
}

// Remove Search
$search = $wp_admin_bar->get_node('search');
if ( $search ) {
$wp_admin_bar->remove_node('search');
}

// Remove fwp cache, comments
$wp_admin_bar->remove_menu( 'fwp-cache' );
$wp_admin_bar->remove_menu( 'comments' );
$wp_admin_bar->remove_menu( 'notes' );
if ( ! is_search() ) {
$wp_admin_bar->remove_menu( 'vip-search-dev-tools' );
}
}

public function register_assets() {
$asset_file = include( plugin_dir_path( __FILE__ ) . 'build/index.asset.php' );
$asset_slug = self::$handle;
Expand Down Expand Up @@ -208,7 +332,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 '<script>window.prcEditorPostType = "' . $post_type . '";</script>';
echo wp_sprintf( '<script>window.prcEditorPostType = "%s";</script>', esc_js($post_type) );
}
}

Expand Down

0 comments on commit f618805

Please sign in to comment.