summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/calypsoify/class.jetpack-calypsoify.php')
-rw-r--r--plugins/jetpack/modules/calypsoify/class.jetpack-calypsoify.php77
1 files changed, 61 insertions, 16 deletions
diff --git a/plugins/jetpack/modules/calypsoify/class.jetpack-calypsoify.php b/plugins/jetpack/modules/calypsoify/class.jetpack-calypsoify.php
index 49c44f42..eb0874da 100644
--- a/plugins/jetpack/modules/calypsoify/class.jetpack-calypsoify.php
+++ b/plugins/jetpack/modules/calypsoify/class.jetpack-calypsoify.php
@@ -37,6 +37,8 @@ class Jetpack_Calypsoify {
if ( $this->is_calypsoify_enabled ) {
add_action( 'admin_init', array( $this, 'setup_admin' ), 6 );
+ add_action( 'admin_menu', array( $this, 'remove_core_menus' ), 100 );
+ add_action( 'admin_menu', array( $this, 'add_custom_menus' ), 101 );
}
// Make this always available -- in case calypsoify gets toggled off.
@@ -56,8 +58,6 @@ class Jetpack_Calypsoify {
}
add_action( 'admin_init', array( $this, 'check_page' ) );
- add_action( 'admin_menu', array( $this, 'remove_core_menus' ), 100 );
- add_action( 'admin_menu', array( $this, 'add_plugin_menus' ), 101 );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ), 100 );
add_action( 'in_admin_header', array( $this, 'insert_sidebar_html' ) );
add_action( 'wp_before_admin_bar_render', array( $this, 'modify_masterbar' ), 100000 );
@@ -68,6 +68,8 @@ class Jetpack_Calypsoify {
add_action( 'manage_plugins_custom_column', array( $this, 'manage_plugins_custom_column' ), 10, 2 );
add_filter( 'bulk_actions-plugins', array( $this, 'bulk_actions_plugins' ) );
+ add_action( 'current_screen', array( $this, 'attach_views_filter' ) );
+
if ( 'plugins.php' === basename( $_SERVER['PHP_SELF'] ) ) {
add_action( 'admin_notices', array( $this, 'plugins_admin_notices' ) );
}
@@ -202,10 +204,10 @@ class Jetpack_Calypsoify {
}
public function remove_core_menus() {
+ remove_menu_page( 'edit.php?post_type=feedback' );
remove_menu_page( 'index.php' );
remove_menu_page( 'jetpack' );
remove_menu_page( 'edit.php' );
- remove_menu_page( 'edit.php?post_type=feedback' );
remove_menu_page( 'upload.php' );
remove_menu_page( 'edit.php?post_type=page' );
remove_menu_page( 'edit-comments.php' );
@@ -226,21 +228,27 @@ class Jetpack_Calypsoify {
remove_submenu_page( 'options-general.php', 'sharing' );
}
- public function add_plugin_menus() {
+ public function add_custom_menus() {
global $menu, $submenu;
- add_menu_page( __( 'Manage Plugins', 'jetpack' ), __( 'Manage Plugins', 'jetpack' ), 'activate_plugins', 'plugins.php', '', $this->installed_plugins_icon(), 1 );
-
- // // Count the settings page submenus, if it's zero then don't show this.
- if ( empty( $submenu['options-general.php'] ) ) {
+ if ( isset( $_GET['post_type'] ) && 'feedback' === $_GET['post_type'] ) {
+ // there is currently no gridicon for feedback, so using dashicon.
+ add_menu_page( __( 'Feedback', 'jetpack' ), __( 'Feedback', 'jetpack' ), 'edit_pages', 'edit.php?post_type=feedback', '', 'dashicons-feedback', 1 );
remove_menu_page( 'options-general.php' );
+ remove_submenu_page( 'edit.php?post_type=feedback', 'feedback-export' );
} else {
- // Rename and make sure the plugin settings menu is always last.
- // Sneaky plugins seem to override this otherwise.
- // Settings is always key 80.
- $menu[80][0] = __( 'Plugin Settings', 'jetpack' );
- $menu[ max( array_keys( $menu ) ) + 1 ] = $menu[80];
- unset( $menu[80] );
+ add_menu_page( __( 'Manage Plugins', 'jetpack' ), __( 'Manage Plugins', 'jetpack' ), 'activate_plugins', 'plugins.php', '', $this->installed_plugins_icon(), 1 );
+ // Count the settings page submenus, if it's zero then don't show this.
+ if ( empty( $submenu['options-general.php'] ) ) {
+ remove_menu_page( 'options-general.php' );
+ } else {
+ // Rename and make sure the plugin settings menu is always last.
+ // Sneaky plugins seem to override this otherwise.
+ // Settings is always key 80.
+ $menu[80][0] = __( 'Plugin Settings', 'jetpack' );
+ $menu[ max( array_keys( $menu ) ) + 1 ] = $menu[80];
+ unset( $menu[80] );
+ }
}
}
@@ -269,17 +277,20 @@ class Jetpack_Calypsoify {
'calypsoifyGutenberg',
array(
'closeUrl' => $this->get_close_gutenberg_url(),
+ 'manageReusableBlocksUrl' => $this->get_calypso_origin() . '/types/wp_block' . $this->get_site_suffix(),
)
);
}
- public function insert_sidebar_html() { ?>
+ public function insert_sidebar_html() {
+ $heading = ( isset( $_GET['post_type'] ) && 'feedback' === $_GET['post_type'] ) ? __( 'Feedback', 'jetpack' ) : __( 'Plugins', 'jetpack' );
+ ?>
<a href="<?php echo esc_url( 'https://wordpress.com/stats/day/' . Jetpack::build_raw_urls( home_url() ) ); ?>" id="calypso-sidebar-header">
<svg class="gridicon gridicons-chevron-left" height="24" width="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><g><path d="M14 20l-8-8 8-8 1.414 1.414L8.828 12l6.586 6.586"></path></g></svg>
<ul>
<li id="calypso-sitename"><?php bloginfo( 'name' ); ?></li>
- <li id="calypso-plugins"><?php esc_html_e( 'Plugins' ); ?></li>
+ <li id="calypso-plugins"><?php echo esc_html( $heading ); ?></li>
</ul>
</a>
<?php
@@ -323,6 +334,19 @@ class Jetpack_Calypsoify {
'https://wordpress.com',
);
return in_array( $origin, $whitelist ) ? $origin : 'https://wordpress.com';
+
+ function get_site_suffix() {
+ if ( class_exists( 'Jetpack' ) && method_exists( 'Jetpack', 'build_raw_urls' ) ) {
+ $site_suffix = Jetpack::build_raw_urls( home_url() );
+ } elseif ( class_exists( 'WPCOM_Masterbar' ) && method_exists( 'WPCOM_Masterbar', 'get_calypso_site_slug' ) ) {
+ $site_suffix = WPCOM_Masterbar::get_calypso_site_slug( get_current_blog_id() );
+ }
+
+ if ( $site_suffix ) {
+ return "/${site_suffix}";
+ }
+ return '';
+ }
}
/**
@@ -457,6 +481,27 @@ class Jetpack_Calypsoify {
return false;
}
+
+ /**
+ * Attach a WP_List_Table views filter to all screens.
+ */
+ public function attach_views_filter( $current_screen ) {
+ add_filter( "views_{$current_screen->id}", array( $this, 'filter_views' ) );
+ }
+
+ /**
+ * Remove the parentheses from list table view counts when Calypsofied.
+ *
+ * @param array $views Array of views. See: WP_List_Table::get_views().
+ * @return array Filtered views.
+ */
+ public function filter_views( $views ) {
+ foreach ( $views as $id => $view ) {
+ $views[ $id ] = preg_replace( '/<span class="count">\((\d+)\)<\/span>/', '<span class="count">$1</span>', $view );
+ }
+
+ return $views;
+ }
}
$Jetpack_Calypsoify = Jetpack_Calypsoify::getInstance();