Changeset 7730 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-o2-posting-access/wporg-o2-posting-access.php
- Timestamp:
- 10/15/2018 10:04:36 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-o2-posting-access/wporg-o2-posting-access.php
r4107 r7730 25 25 26 26 if ( apply_filters( 'wporg_o2_enable_pending_for_unknown_users', true ) ) { 27 if ( ! is_network_admin() && ! is_user_admin() ) { 28 add_action( 'admin_bar_menu', [ $this, 'add_pending_posts_count_to_admin_bar' ], 55 ); 29 add_action( 'wp_enqueue_scripts', [ $this, 'add_pending_posts_icon_to_admin_bar' ] ); 30 add_action( 'admin_enqueue_scripts', [ $this, 'add_pending_posts_icon_to_admin_bar' ] ); 31 } 32 27 33 add_filter( 'gettext_with_context', [ $this, 'replace_post_button_label' ], 10, 4 ); 28 34 add_filter( 'o2_create_post', [ $this, 'save_new_post_as_pending' ] ); … … 86 92 $wp_admin_bar->remove_node( 'comments' ); 87 93 $wp_admin_bar->remove_node( 'edit' ); 94 } 95 96 /** 97 * Adds pending posts count before pending comments count. 98 * 99 * @param \WP_Admin_Bar $wp_admin_bar The admin bar instance. 100 */ 101 public function add_pending_posts_count_to_admin_bar( $wp_admin_bar ) { 102 if ( ! current_user_can( 'edit_posts' ) ) { 103 return; 104 } 105 106 $awaiting_review = wp_count_posts(); 107 $awaiting_review = $awaiting_review->pending; 108 $awaiting_text = sprintf( _n( '%s post awaiting review', '%s posts awaiting review', $awaiting_review, 'o2' ), number_format_i18n( $awaiting_review ) ); 109 110 $icon = '<span class="ab-icon"></span>'; 111 $title = '<span class="ab-label count-' . $awaiting_review . '" aria-hidden="true">' . number_format_i18n( $awaiting_review ) . '</span>'; 112 $title .= '<span class="screen-reader-text">' . $awaiting_text . '</span>'; 113 114 $wp_admin_bar->add_menu( 115 array( 116 'id' => 'pending-posts', 117 'title' => $icon . $title, 118 'href' => admin_url( 'edit.php' ), 119 ) 120 ); 121 } 122 123 /** 124 * Adds icon for the pending posts count. 125 */ 126 public function add_pending_posts_icon_to_admin_bar() { 127 if ( ! current_user_can( 'edit_posts' ) ) { 128 return; 129 } 130 131 wp_add_inline_style( 'admin-bar', ' 132 #wpadminbar #wp-admin-bar-pending-posts .ab-icon:before { 133 content: "\f109"; 134 top: 3px; 135 } 136 ' ); 88 137 } 89 138 … … 129 178 130 179 /** 131 * Whether a user can publish a post with post status 'publish' 132 * .180 * Whether a user can publish a post with post status 'publish'. 181 * 133 182 * @param int $user_id Optional. The user ID. 134 183 * @return bool True when user can, false if not.
Note: See TracChangeset
for help on using the changeset viewer.