diff --git a/projects/packages/forms/.phan/baseline.php b/projects/packages/forms/.phan/baseline.php
index 30a571dc80d2c..85a3c7929b81a 100644
--- a/projects/packages/forms/.phan/baseline.php
+++ b/projects/packages/forms/.phan/baseline.php
@@ -9,19 +9,18 @@
*/
return [
// # Issue statistics:
- // PhanTypeMismatchArgument : 50+ occurrences
- // PhanPluginDuplicateConditionalNullCoalescing : 30+ occurrences
- // PhanDeprecatedFunction : 8 occurrences
+ // PhanTypeMismatchArgument : 45+ occurrences
+ // PhanPluginDuplicateConditionalNullCoalescing : 25+ occurrences
// PhanTypeMismatchReturnProbablyReal : 8 occurrences
- // PhanTypeMismatchArgumentProbablyReal : 6 occurrences
+ // PhanUndeclaredFunction : 4 occurrences
+ // PhanDeprecatedFunction : 3 occurrences
// PhanPluginDuplicateAdjacentStatement : 3 occurrences
// PhanTypeConversionFromArray : 2 occurrences
- // PhanTypeMismatchReturn : 2 occurrences
+ // PhanTypeMismatchArgumentProbablyReal : 2 occurrences
// PhanDeprecatedClass : 1 occurrence
// PhanPluginMixedKeyNoKey : 1 occurrence
// PhanPossiblyNullTypeMismatchProperty : 1 occurrence
// PhanTypeMismatchReturnNullable : 1 occurrence
- // PhanUnreferencedUseNormal : 1 occurrence
// Currently, file_suppressions and directory_suppressions are the only supported suppressions
'file_suppressions' => [
@@ -30,7 +29,6 @@
'src/contact-form/class-contact-form-plugin.php' => ['PhanPluginDuplicateAdjacentStatement', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturnProbablyReal'],
'src/contact-form/class-contact-form-shortcode.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchReturnProbablyReal'],
'src/contact-form/class-contact-form.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchReturnNullable', 'PhanTypeMismatchReturnProbablyReal'],
- 'src/dashboard/class-dashboard-view-switch.php' => ['PhanDeprecatedFunction', 'PhanUnreferencedUseNormal'],
'src/service/class-google-drive.php' => ['PhanTypeMismatchReturnProbablyReal'],
'tests/php/contact-form/Contact_Form_Plugin_Test.php' => ['PhanPluginMixedKeyNoKey'],
'tests/php/dashboard/Dashboard_View_Switch_Test.php' => ['PhanDeprecatedClass', 'PhanDeprecatedFunction'],
diff --git a/projects/packages/forms/changelog/remove-jetpack-forms-dashboard-migration-cleanup b/projects/packages/forms/changelog/remove-jetpack-forms-dashboard-migration-cleanup
new file mode 100644
index 0000000000000..90b7485370461
--- /dev/null
+++ b/projects/packages/forms/changelog/remove-jetpack-forms-dashboard-migration-cleanup
@@ -0,0 +1,4 @@
+Significance: minor
+Type: removed
+
+Forms: clean up all dashboard migration code (filters, methods and wrapped up code)
diff --git a/projects/packages/forms/src/contact-form/class-contact-form-plugin.php b/projects/packages/forms/src/contact-form/class-contact-form-plugin.php
index c3ea859b1740b..10ee2d59b65e0 100644
--- a/projects/packages/forms/src/contact-form/class-contact-form-plugin.php
+++ b/projects/packages/forms/src/contact-form/class-contact-form-plugin.php
@@ -1394,7 +1394,9 @@ public static function gutenblock_render_field_image_select( $atts, $content, $b
public function admin_menu() {
$slug = 'feedback';
- if ( is_plugin_active( 'polldaddy/polldaddy.php' ) ) {
+ // Do we still need to create the Feedback menu item for polldaddy?
+ // WPCOM already handles this. Self hosted will depend on us until we produce a new release for polldaddy.
+ if ( is_plugin_active( 'polldaddy/polldaddy.php' ) || ! Jetpack_Forms::is_legacy_menu_item_retired() ) {
add_menu_page(
__( 'Feedback', 'jetpack-forms' ),
__( 'Feedback', 'jetpack-forms' ),
@@ -1485,22 +1487,6 @@ public function unread_count() {
}
return;
}
-
- if ( isset( $submenu['feedback'] ) && is_array( $submenu['feedback'] ) && ! empty( $submenu['feedback'] ) ) {
- foreach ( $submenu['feedback'] as $index => $menu_item ) {
- if ( 'edit.php?post_type=feedback' === $menu_item[2] ) {
- $unread = self::get_unread_count();
-
- if ( $unread > 0 ) {
- $unread_count = current_user_can( 'publish_pages' ) ? " " . number_format_i18n( $unread ) . '' : '';
-
- // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
- $submenu['feedback'][ $index ][0] .= $unread_count;
- }
- break;
- }
- }
- }
}
/**
@@ -2895,15 +2881,6 @@ public function get_feedback_entries_from_post() {
$args['s'] = sanitize_text_field( wp_unslash( $_POST['search'] ) );
}
- // TODO: We can remove this when the wp-admin UI is removed.
- if ( ! empty( $_POST['year'] ) && intval( $_POST['year'] ) > 0 ) {
- $args['date_query']['year'] = intval( $_POST['year'] );
- }
- // TODO: We can remove this when the wp-admin UI is removed.
- if ( ! empty( $_POST['month'] ) && intval( $_POST['month'] ) > 0 ) {
- $args['date_query']['month'] = intval( $_POST['month'] );
- }
-
if ( ! empty( $_POST['after'] ) && ! empty( $_POST['before'] ) ) {
$before = strtotime( sanitize_text_field( wp_unslash( $_POST['before'] ) ) );
$after = strtotime( sanitize_text_field( wp_unslash( $_POST['after'] ) ) );
diff --git a/projects/packages/forms/src/dashboard/class-dashboard-view-switch.php b/projects/packages/forms/src/dashboard/class-dashboard-view-switch.php
index 81b2a76ac4b52..52ab228322ba0 100644
--- a/projects/packages/forms/src/dashboard/class-dashboard-view-switch.php
+++ b/projects/packages/forms/src/dashboard/class-dashboard-view-switch.php
@@ -8,7 +8,6 @@
namespace Automattic\Jetpack\Forms\Dashboard;
use Automattic\Jetpack\Forms\Jetpack_Forms;
-use JETPACK__VERSION;
if ( ! defined( 'ABSPATH' ) ) {
exit( 0 );
@@ -21,326 +20,6 @@
*/
class Dashboard_View_Switch {
- /**
- * Identifier denoting that the classic WP Admin view should be used.
- *
- * @var string
- */
- const CLASSIC_VIEW = 'classic';
-
- /**
- * Identifier denoting that the modern view version should be used.
- *
- * @var string
- */
- const MODERN_VIEW = 'modern';
-
- /**
- * Initialize the switch.
- *
- * @deprecated 6.6.0 This class is no longer needed and has been removed from active use.
- */
- public function init() {
- _deprecated_function( __METHOD__, 'jetpack-6.6.0' );
- add_action( 'admin_print_styles', array( $this, 'print_styles' ) );
- add_filter( 'in_admin_header', array( $this, 'render_switch' ) );
- add_action( 'admin_footer', array( $this, 'add_scripts' ) );
- add_action( 'current_screen', array( $this, 'handle_preferred_view' ) );
- add_action( 'current_screen', array( $this, 'update_user_seen_announcement' ), 9 );
- }
-
- /**
- * Render the switch.
- */
- public function render_switch() {
- if ( ! $this->is_visible() ) {
- return;
- }
-
- $modern_view_url = $this->is_jetpack_forms_admin_page_available()
- ? 'admin.php?page=jetpack-forms-admin'
- : add_query_arg( 'dashboard-preferred-view', self::MODERN_VIEW, 'admin.php?page=jetpack-forms' );
- ?>
-
-
-
-
- is_visible() ) {
- return;
- }
-
- wp_register_style(
- 'jetpack-forms-dashboard-switch',
- false,
- array(),
- JETPACK__VERSION
- );
- wp_enqueue_style( 'jetpack-forms-dashboard-switch' );
-
- wp_add_inline_style(
- 'jetpack-forms-dashboard-switch',
- << #jetpack-forms__view-link-wrap {
- position: absolute;
- right: 32px;
- top: 0;
- z-index: 179;
- }
-
- body[class*="_page_jetpack-forms"] #jetpack-forms__view-link {
- background-color: #fff;
- border: 1px solid #c3c4c7;
- border-top: none;
- border-radius: 0 0 4px 4px;
- color: #646970;
- cursor: pointer;
- font-size: 13px;
- line-height: 1.7;
- padding: 3px 6px 3px 16px;
- }
-
- body[class*="_page_jetpack-forms"] #jetpack-forms__view-link::after {
- right: 0;
- content: "\\f140";
- font: normal 20px/1 dashicons;
- speak: never;
- display: inline-flex;
- padding: 0 5px 0 0;
- bottom: 2px;
- position: relative;
- vertical-align: bottom;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
- text-decoration: none;
- }
-
- .screen-options-tab__wrapper {
- position:relative
- }
-
- .screen-options-tab__dropdown {
- background-color: #fff;
- border: 1px solid var(--color-neutral-5);
- border-radius: 4px;
- box-shadow: 0 4px 10px #0000001a;
- padding: 3px;
- position: absolute;
- right: 20px;
- top: 37px;
- width:215px;
- z-index: 9999;
- }
-
- @media screen and (max-width: 782px) {
- .screen-options-tab__dropdown {
- right: 10px;
- top: 47px;
- }
- }
-
- @media screen and (max-width: 600px) {
- .screen-options-tab__dropdown {
- top: 93px;
- }
-
- .toplevel_page_jetpack-forms :not(#screen-meta-links) > #jetpack-forms__view-link-wrap {
- top: var(--wp-admin--admin-bar--height);
- }
- }
-
- .jp-forms__view-switcher:not(:hover) .jp-forms__view-switcher-button:nth-child(2) > strong {
- color:var(--wp-admin-theme-color)
- }
-
- .jp-forms__view-switcher-button, a.jp-forms__view-switcher-button {
- background: transparent;
- border: 1px solid #0000;
- border-radius: 4px;
- color: var(--color-text);
- cursor: pointer;
- display: inline-block;
- font-size: .75rem;
- line-height: normal;
- text-decoration: none;
- padding: 8px;
- text-align:left
- }
-
- a.jp-forms__view-switcher-button.is-active {
- border-color: var(--wp-admin-theme-color);
- margin-bottom:4px
- }
-
- .jp-forms__view-switcher-button:last-child, a.jp-forms__view-switcher-button:last-child {
- margin-bottom:0
- }
-
- .jp-forms__view-switcher-button strong, a.jp-forms__view-switcher-button strong {
- display: block;
- font-size: 13px;
- margin-bottom:4px
- }
-
- .jp-forms__view-switcher-button:focus > strong, .jp-forms__view-switcher-button:hover > strong, a.jp-forms__view-switcher-button:focus > strong, a.jp-forms__view-switcher-button:hover > strong {
- color:var(--wp-admin-theme-color)
- }
-CSS
- );
- }
-
- /**
- * Add scripts for the switch component.
- */
- public function add_scripts() {
- if ( ! $this->is_visible() ) {
- return;
- }
-
- wp_add_inline_script(
- 'common',
- "(function( $ ) {
- $( '#jetpack-forms__view-link-wrap' ).appendTo( '#screen-meta-links' );
-
- var viewLink = $( '#jetpack-forms__view-link' );
- var viewWrap = $( '#jetpack-forms__view-wrap' );
-
- viewLink.on( 'click', function() {
- viewWrap.toggle();
- viewLink.toggleClass( 'screen-meta-active' );
- } );
-
- $( document ).on( 'mouseup', function( event ) {
- if ( ! viewLink.is( event.target ) && ! viewWrap.is( event.target ) && viewWrap.has( event.target ).length === 0 ) {
- viewWrap.hide();
- viewLink.removeClass( 'screen-meta-active' );
- }
- });
- })( jQuery );"
- );
- }
-
- /**
- * Updates the prefeerred view setting for the user if a GET param is present.
- */
- public function handle_preferred_view() {
- // For simplicity, we only treat this as a valid operation
- // if it occurs on one of our screens.
- // phpcs:disable WordPress.Security.NonceVerification
- if ( ( ! $this->is_modern_view() && ! $this->is_classic_view() ) || ! isset( $_GET['dashboard-preferred-view'] ) ) {
- return;
- }
-
- // phpcs:disable WordPress.Security.NonceVerification
- $view = sanitize_key( $_GET['dashboard-preferred-view'] );
-
- if ( ! in_array( $view, array( self::CLASSIC_VIEW, self::MODERN_VIEW ), true ) ) {
- return;
- }
-
- update_user_option( get_current_user_id(), 'jetpack_forms_admin_preferred_view', $view );
- if ( ! Jetpack_Forms::is_legacy_menu_item_retired() ) {
- wp_safe_redirect( remove_query_arg( 'dashboard-preferred-view' ) );
- exit( 0 );
- }
- }
-
- /**
- * Update user seeing the announcement.
- */
- public function update_user_seen_announcement() {
- // phpcs:disable WordPress.Security.NonceVerification
- if ( $this->is_jetpack_forms_admin_page() && isset( $_GET['jetpack_forms_migration_announcement_seen'] ) ) {
- update_user_option( get_current_user_id(), 'jetpack_forms_migration_announcement_seen', true );
- wp_safe_redirect( remove_query_arg( 'jetpack_forms_migration_announcement_seen', $this->get_forms_admin_url() ) );
- exit;
- }
- }
-
- /**
- * Returns the preferred feedback view for the current user.
- *
- * @return string
- */
- public function get_preferred_view() {
- $preferred_view = get_user_option( 'jetpack_forms_admin_preferred_view' );
-
- return in_array( $preferred_view, array( self::CLASSIC_VIEW, self::MODERN_VIEW ), true ) ? $preferred_view : self::MODERN_VIEW;
- }
-
- /**
- * Returns true if the switch should be visible on the current page.
- *
- * @return boolean
- */
- public function is_visible() {
- return Jetpack_Forms::is_feedback_dashboard_enabled() && $this->is_classic_view_available() &&
- (
- $this->is_classic_view() ||
- ( $this->is_modern_view() && $this->is_jetpack_forms_view_switch_available() )
- );
- }
-
- /**
- * Returns true if the given screen features the classic view.
- *
- * @return boolean
- */
- public function is_classic_view() {
- if ( ! function_exists( 'get_current_screen' ) ) {
- return false;
- }
-
- $screen = get_current_screen();
-
- return $screen && $screen->id === 'edit-feedback';
- }
-
- /**
- * Returns true if the given screen features the modern view.
- *
- * @return boolean
- */
- public function is_modern_view() {
- if ( ! function_exists( 'get_current_screen' ) ) {
- return false;
- }
-
- // The menu slug might vary depending on language, but modern view is always a jetpack-forms page.
- // See: https://a8c.slack.com/archives/C03TY6J1A/p1747148941583849
- $page_hook_suffix = '_page_jetpack-forms';
- $screen = get_current_screen();
-
- // When classic view is set as preferred, jetpack-forms is registered under different
- // parents so it doesn't appear in the menu.
- // Because of this, we need to support these screens.
- return $screen && str_ends_with( $screen->id, $page_hook_suffix );
- }
-
/**
* Returns true if the current screen is the Jetpack Forms admin page.
*
@@ -350,6 +29,7 @@ public function is_modern_view() {
*/
public function is_jetpack_forms_admin_page() {
_deprecated_function( __METHOD__, 'jetpack-6.6.0', 'Dashboard::is_jetpack_forms_admin_page' );
+
if ( ! function_exists( 'get_current_screen' ) ) {
return false;
}
@@ -364,32 +44,25 @@ public function is_jetpack_forms_admin_page() {
* @deprecated 6.6.0 Use Dashboard::get_forms_admin_url() instead.
*
* @param string|null $tab Tab to open in the forms admin page.
- * @param boolean $force_inbox Whether to force the inbox view URL.
*
* @return string
*/
- public function get_forms_admin_url( $tab = null, $force_inbox = false ) {
+ public function get_forms_admin_url( $tab = null ) {
_deprecated_function( __METHOD__, 'jetpack-6.6.0', 'Dashboard::get_forms_admin_url' );
- $is_classic = $this->get_preferred_view() === self::CLASSIC_VIEW;
- $switch_is_available = $this->is_jetpack_forms_view_switch_available();
-
- $base_url = $is_classic && $switch_is_available && ! $force_inbox
- ? get_admin_url() . 'edit.php?post_type=feedback'
- : get_admin_url() . ( $this->is_jetpack_forms_admin_page_available() ? 'admin.php?page=jetpack-forms-admin' : 'admin.php?page=jetpack-forms' );
+ $base_url = get_admin_url() . 'admin.php?page=jetpack-forms-admin';
- return $this->append_tab_to_url( $base_url, $tab, $is_classic && $switch_is_available && ! $force_inbox );
+ return self::append_tab_to_url( $base_url, $tab );
}
/**
* Appends the appropriate tab parameter to the URL based on the view type.
*
- * @param string $url Base URL to append to.
- * @param string $tab Tab to open.
- * @param boolean $is_classic_view Whether we're using the classic view.
+ * @param string $url Base URL to append to.
+ * @param string $tab Tab to open.
*
* @return string
*/
- private function append_tab_to_url( $url, $tab, $is_classic_view ) {
+ private static function append_tab_to_url( $url, $tab ) {
if ( ! $tab ) {
return $url;
}
@@ -404,9 +77,7 @@ private function append_tab_to_url( $url, $tab, $is_classic_view ) {
return $url;
}
- return $is_classic_view
- ? add_query_arg( 'post_status', $status_map[ $tab ], $url )
- : $url . '#/responses?status=' . $status_map[ $tab ];
+ return $url . '#/responses?status=' . $status_map[ $tab ];
}
/**
diff --git a/projects/packages/forms/tests/php/dashboard/Dashboard_View_Switch_Test.php b/projects/packages/forms/tests/php/dashboard/Dashboard_View_Switch_Test.php
index 01bfffb336377..4c96723a22a2e 100644
--- a/projects/packages/forms/tests/php/dashboard/Dashboard_View_Switch_Test.php
+++ b/projects/packages/forms/tests/php/dashboard/Dashboard_View_Switch_Test.php
@@ -34,13 +34,11 @@ public function setUp(): void {
}
/**
- * Test that deprecated init method still works
+ * Test that deprecated init method has been removed
*/
- public function test_deprecated_init_method_still_works() {
- // Test that the method doesn't fatal error when called
- // Note: We can't test for deprecation warnings with WorDBless
- $this->dashboard_view_switch->init();
- $this->assertTrue( true ); // If we reach here, no fatal error occurred
+ public function test_deprecated_init_method_removed() {
+ // The init method has been removed as part of deprecation
+ $this->assertFalse( method_exists( $this->dashboard_view_switch, 'init' ) );
}
/**
@@ -92,11 +90,15 @@ public function test_deprecated_static_is_classic_view_available_still_works() {
}
/**
- * Test class constants are still accessible
+ * Test that class constants have been removed
*/
- public function test_class_constants() {
- $this->assertEquals( 'classic', Dashboard_View_Switch::CLASSIC_VIEW );
- $this->assertEquals( 'modern', Dashboard_View_Switch::MODERN_VIEW );
+ public function test_class_constants_removed() {
+ $reflection = new \ReflectionClass( Dashboard_View_Switch::class );
+ $constants = $reflection->getConstants();
+
+ // CLASSIC_VIEW and MODERN_VIEW constants should be removed
+ $this->assertArrayNotHasKey( 'CLASSIC_VIEW', $constants );
+ $this->assertArrayNotHasKey( 'MODERN_VIEW', $constants );
}
/**