Skip to content

Commit

Permalink
Add/my jetpack link to all jetpack plugins on plugins page (#35523)
Browse files Browse the repository at this point in the history
* Launchpad: Make the 'Install the mobile app' task visible to Simple and Atomic sites (#35465)

* Make the Install the mobile app task visible

* changelog

* Bump version

---------

Co-authored-by: Valter Lorran <[email protected]>

* changelog

* Add comments

* update project version

* fix test

* fix test

* Try to fix tests again

* Add My Jetpack back to tests

* Add multisite condition to test

* Shorten multisite check

* Show My Jetpack link even if site is not connected

* changelog

* Add search

---------

Co-authored-by: valterlorran <[email protected]>
Co-authored-by: Valter Lorran <[email protected]>
  • Loading branch information
3 people authored Feb 9, 2024
1 parent c6008e4 commit e0462a5
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: added

Add My Jetpack link to standalone plugins missing it
2 changes: 1 addition & 1 deletion projects/packages/my-jetpack/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-my-jetpack",
"version": "4.9.0",
"version": "4.9.1-alpha",
"description": "WP Admin page with information and configuration shared among all Jetpack stand-alone plugins",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/my-jetpack/#readme",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/my-jetpack/src/class-initializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Initializer {
*
* @var string
*/
const PACKAGE_VERSION = '4.9.0';
const PACKAGE_VERSION = '4.9.1-alpha';

/**
* HTML container ID for the IDC screen on My Jetpack page.
Expand Down
11 changes: 10 additions & 1 deletion projects/packages/my-jetpack/src/class-products.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,17 @@ public static function extend_plugins_action_links() {
'backup',
'boost',
'crm',
'videopress', // we use videopress here to add the plugin action to the Jetpack plugin itself
'videopress',
'social',
'protect',
'crm',
'search',
);

// Add plugin action links for the core Jetpack plugin.
Product::extend_core_plugin_action_links();

// Add plugin action links to standalone products.
foreach ( $products as $product ) {
$class_name = self::get_product_class( $product );
$class_name::extend_plugin_action_links();
Expand Down
5 changes: 4 additions & 1 deletion projects/packages/my-jetpack/src/products/class-crm.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ class Crm extends Product {
*
* @var string
*/
public static $plugin_filename = 'zero-bs-crm/ZeroBSCRM.php';
public static $plugin_filename = array(
'zero-bs-crm/ZeroBSCRM.php',
'crm/ZeroBSCRM.php',
);

/**
* The slug of the plugin associated with this product. If not defined, it will default to the Jetpack plugin
Expand Down
35 changes: 26 additions & 9 deletions projects/packages/my-jetpack/src/products/class-product.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ abstract class Product {
/**
* The Jetpack plugin filename
*
* @var string
* @var array
*/
const JETPACK_PLUGIN_FILENAME = array(
'jetpack/jetpack.php',
Expand Down Expand Up @@ -537,15 +537,11 @@ public static function get_plugin_actions_links( $actions ) {
}

/**
* Extend the plugin action links.
* Filter the action links for the plugins specified.
*
* @param string|string[] $filenames The plugin filename(s) to filter the action links for.
*/
public static function extend_plugin_action_links() {

$filenames = static::get_plugin_filename();
if ( ! is_array( $filenames ) ) {
$filenames = array( $filenames );
}

private static function filter_action_links( $filenames ) {
foreach ( $filenames as $filename ) {
$hook = 'plugin_action_links_' . $filename;
$callback = array( static::class, 'get_plugin_actions_links' );
Expand All @@ -554,4 +550,25 @@ public static function extend_plugin_action_links() {
}
}
}

/**
* Extend the plugin action links.
*/
public static function extend_plugin_action_links() {
$filenames = static::get_plugin_filename();
if ( ! is_array( $filenames ) ) {
$filenames = array( $filenames );
}

self::filter_action_links( $filenames );
}

/**
* Extend the Jetpack plugin action links.
*/
public static function extend_core_plugin_action_links() {
$filenames = self::JETPACK_PLUGIN_FILENAME;

self::filter_action_links( $filenames );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: enhancement

Remove Support link from Jetpack on plugins page
3 changes: 0 additions & 3 deletions projects/plugins/jetpack/class.jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -3772,12 +3772,9 @@ public function admin_menu_css() {
* @return array
*/
public function plugin_action_links( $actions ) {
$support_link = ( new Host() )->is_woa_site() ? 'https://wordpress.com/help/contact/' : self::admin_url( 'page=jetpack-debugger' );

if ( current_user_can( 'jetpack_manage_modules' ) && ( self::is_connection_ready() || ( new Status() )->is_offline_mode() ) ) {
return array_merge(
array( 'settings' => sprintf( '<a href="%s">%s</a>', esc_url( self::admin_url( 'page=jetpack#/settings' ) ), __( 'Settings', 'jetpack' ) ) ),
array( 'support' => sprintf( '<a href="%s">%s</a>', esc_url( $support_link ), __( 'Support', 'jetpack' ) ) ),
$actions
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,10 @@ public function test_plugin_action_links_get_synced() {
),
);

if ( ! is_multisite() ) {
$expected_array['jetpack/jetpack.php']['My Jetpack'] = admin_url( 'admin.php?page=my-jetpack' );
}

$this->assertEquals( $expected_array, $this->extract_plugins_we_are_testing( $plugins_action_links ) );

$helper_all->array_override = array( '<a href="not-fun.php">not fun</a>' );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Showing My Jetpack link on plugins page even if the plugin is not installed
2 changes: 1 addition & 1 deletion projects/plugins/search/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
"config": {
"sort-packages": true,
"autoloader-suffix": "b462338fb66be23595d68a93345c9e3d_jetpack_searchⓥ2_0_0",
"autoloader-suffix": "b462338fb66be23595d68a93345c9e3d_jetpack_searchⓥ2_0_1_alpha",
"allow-plugins": {
"automattic/jetpack-autoloader": true,
"automattic/jetpack-composer-plugin": true,
Expand Down
4 changes: 2 additions & 2 deletions projects/plugins/search/jetpack-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: Jetpack Search
* Plugin URI: https://jetpack.com/search/
* Description: Easily add cloud-powered instant search and filters to your website or WooCommerce store with advanced algorithms that boost your search results based on traffic to your site.
* Version: 2.0.0
* Version: 2.0.1-alpha
* Author: Automattic - Jetpack Search team
* Author URI: https://jetpack.com/
* License: GPLv2 or later
Expand All @@ -26,7 +26,7 @@
define( 'JETPACK_SEARCH_PLUGIN__FILE', __FILE__ );
define( 'JETPACK_SEARCH_PLUGIN__FILE_RELATIVE_PATH', plugin_basename( __FILE__ ) );
define( 'JETPACK_SEARCH_PLUGIN__SLUG', 'jetpack-search' );
define( 'JETPACK_SEARCH_PLUGIN__VERSION', '2.0.0' );
define( 'JETPACK_SEARCH_PLUGIN__VERSION', '2.0.1-alpha' );

defined( 'JETPACK_CLIENT__AUTH_LOCATION' ) || define( 'JETPACK_CLIENT__AUTH_LOCATION', 'header' );

Expand Down
6 changes: 0 additions & 6 deletions projects/plugins/search/src/class-jetpack-search-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ public static function plugin_page_add_links( $links ) {
$settings_link = '<a href="' . admin_url( 'admin.php?page=jetpack-search' ) . '">' . esc_html__( 'Settings', 'jetpack-search' ) . '</a>';
array_unshift( $links, $settings_link );

// Add the My Jetpack link only if Jetpack is connected
if ( ( new Connection_Manager() )->is_connected() ) {
$my_jetpack_link = '<a href="' . admin_url( 'admin.php?page=my-jetpack' ) . '">' . esc_html__( 'My Jetpack', 'jetpack-search' ) . '</a>';
array_unshift( $links, $my_jetpack_link );
}

return $links;
}

Expand Down

0 comments on commit e0462a5

Please sign in to comment.