Skip to content

Commit

Permalink
IDC: old code cleanup (#35048)
Browse files Browse the repository at this point in the history
  • Loading branch information
bindlegirl authored Feb 6, 2024
1 parent a08a117 commit 9c08613
Show file tree
Hide file tree
Showing 24 changed files with 70 additions and 310 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: deprecated

Removing old and previously deprecated code.
2 changes: 1 addition & 1 deletion projects/packages/identity-crisis/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"link-template": "https://github.com/Automattic/jetpack-identity-crisis/compare/v${old}...v${new}"
},
"branch-alias": {
"dev-trunk": "0.15.x-dev"
"dev-trunk": "0.16.x-dev"
}
},
"config": {
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/identity-crisis/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jetpack-identity-crisis",
"version": "0.15.1",
"version": "0.16.0-alpha",
"description": "Jetpack Identity Crisis",
"main": "_inc/admin.jsx",
"repository": {
Expand Down
240 changes: 1 addition & 239 deletions projects/packages/identity-crisis/src/class-identity-crisis.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace Automattic\Jetpack;

use Automattic\Jetpack\Assets\Logo as Jetpack_Logo;
use Automattic\Jetpack\Connection\Manager as Connection_Manager;
use Automattic\Jetpack\Connection\Urls;
use Automattic\Jetpack\IdentityCrisis\Exception;
Expand All @@ -27,7 +26,7 @@ class Identity_Crisis {
/**
* Package Version
*/
const PACKAGE_VERSION = '0.15.1';
const PACKAGE_VERSION = '0.16.0-alpha';

/**
* Persistent WPCOM blog ID that stays in the options after disconnect.
Expand Down Expand Up @@ -239,25 +238,6 @@ public function add_idc_query_args_to_url( $url ) {
return add_query_arg( $query_args, $url );
}

/**
* Non-admins current screen check.
*
* @param object $current_screen Current screen.
*
* @return null
* @deprecated 0.5.0 Use `@automattic/jetpack-idc` instead.
*/
public function non_admins_current_screen_check( $current_screen ) {
_deprecated_function( __METHOD__, '0.5.0' );

self::$current_screen = $current_screen;
if ( isset( $current_screen->id ) && 'toplevel_page_jetpack' === $current_screen->id ) {
return null;
}

return null;
}

/**
* Renders the admin bar button.
*
Expand Down Expand Up @@ -558,21 +538,6 @@ public static function get_sync_error_idc_option( $response = array() ) {
return $returned_values;
}

/**
* Returns the value of the jetpack_sync_idc_optin filter, or constant.
* If set to true, the site will be put into staging mode.
*
* @return bool
* @since 0.2.0
* @since-jetpack 4.3.2
* @deprecated 0.2.6 Use should_handle_idc()
* @see Automattic\Jetpack\Identity_Crisis::should_handle_idc
*/
public static function sync_idc_optin() {
_deprecated_function( __METHOD__, '0.2.6', 'Automattic\\Jetpack\\Identity_Crisis::should_handle_idc' );
return self::should_handle_idc();
}

/**
* Returns the value of the jetpack_should_handle_idc filter or constant.
* If set to true, the site will be put into staging mode.
Expand All @@ -594,9 +559,6 @@ public static function should_handle_idc() {
$default = ! Constants::is_defined( 'SUNRISE' ) && ! is_multisite();
}

// Add a callback which uses the legacy filter 'jetpack_sync_idc_optin'.
add_filter( 'jetpack_should_handle_idc', array( __CLASS__, 'legacy_jetpack_sync_idc_optin_filter' ) );

/**
* Allows sites to opt in for IDC mitigation which blocks the site from syncing to WordPress.com when the home
* URL or site URL do not match what WordPress.com expects. The default value is either true, or the value of
Expand All @@ -609,155 +571,6 @@ public static function should_handle_idc() {
return (bool) apply_filters( 'jetpack_should_handle_idc', $default );
}

/**
* Returns the value for the deprecated filter, 'jetpack_sync_idc_optin'. That filter has been replaced with the
* 'jetpack_should_handle_idc' filter.
*
* @since 0.2.6
*
* @param bool $default Whether the site is opted in to IDC mitigation.
*/
public static function legacy_jetpack_sync_idc_optin_filter( $default ) {
/**
* Allows sites to opt in for IDC mitigation which blocks the site from syncing to WordPress.com when the home
* URL or site URL do not match what WordPress.com expects. The default value is either true, or the value of
* JETPACK_SYNC_IDC_OPTIN constant if set.
*
* @param bool $default Whether the site is opted in to IDC mitigation.
*
* @since 0.2.0
* @since-jetpack 4.3.2
* @deprecated 0.2.6 Use jetpack_should_handle_idc
*/
return (bool) apply_filters_deprecated( 'jetpack_sync_idc_optin', array( $default ), '0.2.6', 'jetpack_should_handle_idc' );
}

/**
* Does the current admin page have help tabs?
*
* @return bool
* @deprecated 0.5.0 Use `@automattic/jetpack-idc` instead.
*/
public function admin_page_has_help_tabs() {
_deprecated_function( __METHOD__, '0.5.0' );

if ( ! function_exists( 'get_current_screen' ) ) {
return false;
}

$current_screen = get_current_screen();
$tabs = $current_screen->get_help_tabs();

return ! empty( $tabs );
}

/**
* Renders the non-admin IDC notice.
*
* @return void
* @deprecated 0.5.0 Use `@automattic/jetpack-idc` instead.
*/
public function display_non_admin_idc_notice() {
_deprecated_function( __METHOD__, '0.5.0' );

$classes = 'jp-idc-notice inline is-non-admin notice notice-warning';
if ( isset( self::$current_screen ) && 'toplevel_page_jetpack' !== self::$current_screen->id ) {
$classes .= ' is-dismissible';
}

if ( $this->admin_page_has_help_tabs() ) {
$classes .= ' has-help-tabs';
}
?>

<div class="<?php echo esc_attr( $classes ); ?>">
<?php $this->render_notice_header(); ?>
<div class="jp-idc-notice__content-header">
<h3 class="jp-idc-notice__content-header__lead">
<?php echo $this->get_non_admin_notice_text(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</h3>

<p class="jp-idc-notice__content-header__explanation">
<?php echo $this->get_non_admin_contact_admin_text(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</p>
</div>
</div>
<?php
}

/**
* First "step" of the IDC mitigation. Will provide some messaging and two options/buttons.
* "Confirm Staging" - Dismiss the notice and continue on with our lives in staging mode.
* "Fix Jetpack Connection" - Will disconnect the site and start the mitigation...
*
* @return void
* @deprecated 0.5.0 Use `@automattic/jetpack-idc` instead.
*/
public function display_idc_notice() {
_deprecated_function( __METHOD__, '0.5.0' );

$classes = 'jp-idc-notice inline notice notice-warning';
if ( $this->admin_page_has_help_tabs() ) {
$classes .= ' has-help-tabs';
}
?>
<div class="<?php echo esc_attr( $classes ); ?>">
<?php $this->render_notice_header(); ?>
<?php $this->render_notice_first_step(); ?>
<?php $this->render_notice_second_step(); ?>
</div>
<?php
}

/**
* Enqueue CSS for the admin bar.
*
* @return void
* @deprecated 0.5.0 Use `@automattic/jetpack-idc` instead.
*/
public function enqueue_admin_bar_css() {
_deprecated_function( __METHOD__, '0.5.0' );
}

/**
* Enqueue scripts for the notice.
*
* @return void
* @deprecated 0.5.0 Use `@automattic/jetpack-idc` instead.
*/
public function enqueue_idc_notice_files() {
_deprecated_function( __METHOD__, '0.5.0' );

// Register and Enqueue jp-tracks-functions.
Tracking::register_tracks_functions_scripts( true );
}

/**
* Renders the notice header.
*
* @return void
* @deprecated 0.5.0 Use `@automattic/jetpack-idc` instead.
*/
public function render_notice_header() {
_deprecated_function( __METHOD__, '0.5.0' );

?>
<div class="jp-idc-notice__header">
<div class="jp-idc-notice__header__emblem">
<?php
$jetpack_logo = new Jetpack_Logo();
echo $jetpack_logo->get_jp_emblem(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>
</div>
<p class="jp-idc-notice__header__text">
<?php esc_html_e( 'Jetpack Safe Mode', 'jetpack-idc' ); ?>
</p>
</div>

<div class="jp-idc-notice__separator"></div>
<?php
}

/**
* Is a container for the error notices.
* Will be shown/controlled by jQuery in idc-notice.js.
Expand Down Expand Up @@ -1166,57 +979,6 @@ public function get_unsure_prompt() {
return apply_filters( 'jetpack_idc_unsure_prompt', $html );
}

/**
* Returns the non-admin notice text.
*
* @return string
* @deprecated 0.5.0 Use `@automattic/jetpack-idc` instead.
*/
public function get_non_admin_notice_text() {
_deprecated_function( __METHOD__, '0.5.0' );

$html = wp_kses(
sprintf(
/* translators: %s: Safe mode docs URL. */
__( 'Jetpack has been placed into Safe Mode. Learn more about <a href="%1$s">Safe Mode</a>.', 'jetpack-idc' ),
esc_url( self::get_safe_mod_doc_url() )
),
array( 'a' => array( 'href' => array() ) )
);

/**
* Allows overriding of the default text that is displayed to non-admin on the Jetpack admin page.
*
* @param string $html The HTML to be displayed.
*
* @since 0.2.0
* @since-jetpack 4.4.0
*/
return apply_filters( 'jetpack_idc_non_admin_notice_text', $html );
}

/**
* Returns the non-admin contact admin text.
*
* @return string
* @deprecated 0.5.0 Use `@automattic/jetpack-idc` instead.
*/
public function get_non_admin_contact_admin_text() {
_deprecated_function( __METHOD__, '0.5.0' );

$string = esc_html__( 'An administrator of this site can take Jetpack out of Safe Mode.', 'jetpack-idc' );

/**
* Allows overriding of the default text that is displayed to non-admins prompting them to contact an admin.
*
* @param string $string The string to be displayed.
*
* @since 0.2.0
* @since-jetpack 4.4.0
*/
return apply_filters( 'jetpack_idc_non_admin_contact_admin_text', $string );
}

/**
* Whether the site is undergoing identity crisis.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,6 @@ public function test_should_handle_idc_false_when_legacy_constant_false() {
$this->assertFalse( Identity_Crisis::should_handle_idc() );
}

/**
* Test that the legacy jetpack_sync_idc_optin filter is used by should_handle_idc.
*/
public function test_should_handle_idc_uses_legacy_filter() {
add_filter( 'jetpack_sync_idc_optin', '__return_false' );
$result = Identity_Crisis::should_handle_idc();
remove_filter( 'jetpack_sync_idc_optin', '__return_false' );

$this->assertFalse( $result );
}

/**
* Test that current JETPACK_SHOULD_HANDLE_IDC constant overrides the legacy JETPACK_SYNC_IDC_OPTIN constant.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/backup/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/boost/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: other
Comment: Updated composer.lock.


Loading

0 comments on commit 9c08613

Please sign in to comment.