diff --git a/assets/apps/customizer-controls/src/builder-instructions/HFGMigrationNotice.tsx b/assets/apps/customizer-controls/src/builder-instructions/HFGMigrationNotice.tsx deleted file mode 100644 index 7c1ccf9d79..0000000000 --- a/assets/apps/customizer-controls/src/builder-instructions/HFGMigrationNotice.tsx +++ /dev/null @@ -1,211 +0,0 @@ -import React from 'react'; -import { __ } from '@wordpress/i18n'; -import apiFetch from '@wordpress/api-fetch'; -import { - cancelCircleFilled, - rotateRight, - starFilled, - undo, -} from '@wordpress/icons'; -import { Button } from '@wordpress/components'; -import { useState, useEffect } from '@wordpress/element'; -import { StringObjectKeys } from '../@types/utils'; - -interface MigrationResponse { - success: boolean; -} - -type Props = { - alreadyMigrated: boolean; - hadOldBuilder: boolean; -}; - -export const HFGMigrationNotice: React.FC = ({ - alreadyMigrated, - hadOldBuilder, -}) => { - const [error, setError] = useState(false); - const [isCustomizerSaved, setCustomizerSaved] = useState(true); - - useEffect(() => { - if (alreadyMigrated && !hadOldBuilder) { - return; - } - window.wp.customize.bind('ready', () => { - window.wp.customize.state('saved').bind((status: boolean) => { - setCustomizerSaved(status); - }); - }); - }, []); - - if (typeof window.NeveProReactCustomize !== 'undefined') { - const { whiteLabel } = window.NeveProReactCustomize; - - if (whiteLabel) { - return null; - } - } - - if (!hadOldBuilder) { - return null; - } - - const { nonce } = window.NeveReactCustomize; - - const getReloadUrl = () => { - const location = window.location.href; - const currentPanel = window.wp.customize.state('expandedPanel').get(); - - if (!currentPanel) return location; - - const panelId = currentPanel.id; - - if (!panelId) return location; - - const url = new URL(location); - - url.searchParams.set('autofocus[panel]', panelId); - - return url.href; - }; - - const runMigration = (rollback = false, dismiss = false) => { - let message = __('Migrating builder data', 'neve'); - - if (rollback) { - message = __('Rolling back builder', 'neve'); - } - - if (dismiss) { - message = __('Removing old data', 'neve'); - } - - window.wp.customize.notifications.add( - new window.wp.customize.OverlayNotification( - 'neve_migrating_builders', - { - message: message + '...', - type: 'success', - loading: true, - } - ) - ); - - const headers: StringObjectKeys = { 'X-WP-Nonce': nonce }; - if (rollback) { - headers.rollback = 'yes'; - } - - if (dismiss) { - headers.dismiss = 'yes'; - } - - apiFetch({ - path: '/nv/migration/new_header_builder', - method: 'GET', - headers, - }).then((response: unknown) => { - if (!(response as MigrationResponse).success) { - window.wp.customize.notifications.remove( - 'neve_migrating_builders' - ); - setError(true); - return false; - } - reloadPage(); - }); - }; - - const reloadPage = () => { - const url = getReloadUrl(); - if (window.location.href === url) { - window.location.reload(); - return false; - } - window.location.href = url; - }; - - const renderErrors = () => { - return ( - <> - {!isCustomizerSaved && !error && ( -

- {__( - 'You must save the current customizer values before running the migration.', - 'neve' - )} -

- )} - - {error && ( -

- {__( - 'Something went wrong. Please reload the page and try again.', - 'neve' - )} -

- )} - - ); - }; - - if (alreadyMigrated && hadOldBuilder) { - return ( - <> -
-

{__('Want to roll back to the old builder?', 'neve')}

- - - {renderErrors()} - - ); - } - - return ( - <> -
-

- {__( - "We've created a new Header/Footer Builder experience! You can always roll back to the old builder from right here.", - 'neve' - )} -

-

- - {__('Some manual adjustments may be required.', 'neve')} - -

- - {renderErrors()} - - ); -}; diff --git a/assets/apps/customizer-controls/src/builder-instructions/Instructions.tsx b/assets/apps/customizer-controls/src/builder-instructions/Instructions.tsx index 2202a19259..d52f3524c6 100644 --- a/assets/apps/customizer-controls/src/builder-instructions/Instructions.tsx +++ b/assets/apps/customizer-controls/src/builder-instructions/Instructions.tsx @@ -2,7 +2,6 @@ import React from 'react'; import { __ } from '@wordpress/i18n'; import { Button } from '@wordpress/components'; import { WPCustomizeControl } from '../@types/customizer-control'; -import { HFGMigrationNotice } from './HFGMigrationNotice'; type Props = { control: WPCustomizeControl; @@ -72,12 +71,6 @@ const Instructions: React.FC = ({ control }) => { ); })} - {id === 'hfg_header_layout_section_quick_links' && ( - - )} )} diff --git a/assets/apps/customizer-controls/src/controls.js b/assets/apps/customizer-controls/src/controls.js index 7f06cc3655..19632184f0 100644 --- a/assets/apps/customizer-controls/src/controls.js +++ b/assets/apps/customizer-controls/src/controls.js @@ -29,7 +29,6 @@ import { BuilderColumns } from './builder-columns/Control'; import { TextareaControl } from './textarea/Control'; import { InstructionsControl } from './builder-instructions/Control'; import { HeadingControl } from './heading/Control'; -import { SkinSwitcherControl } from './skin-switcher/Control'; import { LogoPaletteControl } from './logo-palette/Control'; import { RepeaterControl } from './repeater/Control'; import { RichTextControl } from './rich-text/Control'; @@ -77,7 +76,6 @@ controlConstructor.neve_builder_columns = BuilderColumns; controlConstructor.neve_textarea = TextareaControl; controlConstructor.hfg_instructions = InstructionsControl; controlConstructor.neve_customizer_heading = HeadingControl; -controlConstructor.neve_skin_switcher = SkinSwitcherControl; controlConstructor.neve_logo_palette_control = LogoPaletteControl; controlConstructor.neve_repeater_control = RepeaterControl; controlConstructor.neve_rich_text = RichTextControl; diff --git a/assets/apps/customizer-controls/src/skin-switcher/Control.js b/assets/apps/customizer-controls/src/skin-switcher/Control.js deleted file mode 100644 index a176277f15..0000000000 --- a/assets/apps/customizer-controls/src/skin-switcher/Control.js +++ /dev/null @@ -1,8 +0,0 @@ -import SkinSwitcher from './SkinSwitcher.tsx'; -import { render } from '@wordpress/element'; - -export const SkinSwitcherControl = wp.customize.Control.extend({ - renderContent: function renderContent() { - render(, this.container[0]); - }, -}); diff --git a/assets/apps/customizer-controls/src/skin-switcher/SkinSwitcher.tsx b/assets/apps/customizer-controls/src/skin-switcher/SkinSwitcher.tsx deleted file mode 100644 index 4452fd6928..0000000000 --- a/assets/apps/customizer-controls/src/skin-switcher/SkinSwitcher.tsx +++ /dev/null @@ -1,101 +0,0 @@ -import React from 'react'; -import { WPCustomizeControl } from '../@types/customizer-control'; -import { __ } from '@wordpress/i18n'; -import { useEffect, useState } from '@wordpress/element'; - -// @ts-ignore -import { InlineSelect } from '@neve-wp/components'; -import { Button } from '@wordpress/components'; - -type Props = { - control: WPCustomizeControl; -}; - -const SkinSwitcher: React.FC = ({ control }) => { - const [value, setValue] = useState(control.setting.get()); - const [changed, setChanged] = useState(false); - const [switching, setSwitching] = useState(false); - const [customizerSaved, setCustomizerSaved] = useState(true); - - useEffect(() => { - window.wp.customize.bind('ready', () => { - setCustomizerSaved(window.wp.customize.state('saved').get()); - - window.wp.customize.state('saved').bind((status: boolean) => { - setCustomizerSaved(status); - }); - }); - }, []); - - const options = [ - { - value: 'old', - label: __('Legacy Skin', 'neve'), - }, - { - value: 'new', - label: __('Neve 3.0', 'neve'), - }, - ]; - - const handleChange = (newVal: string) => { - setValue(newVal); - setChanged(true); - }; - - const handleSwitch = () => { - setSwitching(true); - - setVal(control, value).then(() => { - window.wp.customize.previewer.save().then(() => { - window.wp.customize.notifications.add( - new window.wp.customize.OverlayNotification( - 'neve_switching_skin', - { - message: __('Switching skin', 'neve') + '...', - type: 'success', - loading: true, - } - ) - ); - window.location.reload(); - }); - }); - }; - - return ( -
- - - {!customizerSaved && !switching && ( -

- {__( - 'Please save the current customizer settings before switching skins.' - )} -

- )} -
- ); -}; - -const setVal = async (control: WPCustomizeControl, newVal: string) => { - await control.setting.set(newVal); -}; - -export default SkinSwitcher; diff --git a/header-footer-grid/Core/Builder/Header.php b/header-footer-grid/Core/Builder/Header.php index a68e93cbbd..fb26e2834c 100644 --- a/header-footer-grid/Core/Builder/Header.php +++ b/header-footer-grid/Core/Builder/Header.php @@ -94,7 +94,6 @@ public function init() { ), ), 'builderMigrated' => $migrated_hfg, - 'hadOldBuilder' => neve_had_old_hfb() && ( ! neve_is_new_skin() || neve_was_auto_migrated_to_new() ), ) ); diff --git a/inc/core/admin.php b/inc/core/admin.php index 327cade76d..a8bf8cde2f 100644 --- a/inc/core/admin.php +++ b/inc/core/admin.php @@ -276,18 +276,6 @@ public function adapt_conditional_headers( $array ) { * Register Rest Routes. */ public function register_rest_routes() { - register_rest_route( - 'nv/migration', - '/new_header_builder', - array( - 'methods' => \WP_REST_Server::READABLE, - 'callback' => [ $this, 'migrate_builders_data' ], - 'permission_callback' => function () { - return current_user_can( 'manage_options' ); - }, - ) - ); - register_rest_route( 'nv/v1/dashboard', '/plugin-state/(?P[a-z0-9-]+)', @@ -306,42 +294,6 @@ public function register_rest_routes() { ); } - /** - * Migration routine request. - * - * @param \WP_REST_Request $request the received request. - * - * @return \WP_REST_Response - * - * @since 3.0.0 - */ - public function migrate_builders_data( \WP_REST_Request $request ) { - $is_rollback = $request->get_header( 'rollback' ); - $is_dismiss = $request->get_header( 'dismiss' ); - - if ( $is_dismiss === 'yes' ) { - remove_theme_mod( 'hfg_header_layout' ); - remove_theme_mod( 'hfg_footer_layout' ); - - return new \WP_REST_Response( [ 'success' => true ], 200 ); - } - - if ( $is_rollback === 'yes' ) { - set_theme_mod( 'neve_migrated_builders', false ); - - return new \WP_REST_Response( [ 'success' => true ], 200 ); - } - - $migrator = new Builder_Migrator(); - $response = $migrator->run(); - - if ( $response === true ) { - set_theme_mod( 'neve_migrated_builders', true ); - } - - return new \WP_REST_Response( [ 'success' => $response ], 200 ); - } - /** * Get any plugin's state. * diff --git a/inc/core/front_end.php b/inc/core/front_end.php index d6a9fe00c2..7329e49bfd 100644 --- a/inc/core/front_end.php +++ b/inc/core/front_end.php @@ -510,27 +510,43 @@ public function register_sidebars() { */ public function get_strings() { return [ - 'add_item' => __( 'Add item', 'neve' ), - 'add_items' => __( 'Add items by clicking the ones below.', 'neve' ), - 'all_selected' => __( 'All items are already selected.', 'neve' ), - 'page_layout' => __( 'Page Layout', 'neve' ), - 'page_title' => __( 'Page Title', 'neve' ), - 'upsell_components' => __( 'Upgrade to Neve Pro and unlock all components, including Wish List, Breadcrumbs, Custom Layouts and many more.', 'neve' ), - 'header_booster' => esc_html__( 'Header Booster', 'neve' ), - 'blog_booster' => esc_html__( 'Blog Booster', 'neve' ), - 'woo_booster' => esc_html__( 'WooCommerce Booster', 'neve' ), - 'custom_layouts' => esc_html__( 'Custom Layouts', 'neve' ), - 'white_label' => esc_html__( 'White Label module', 'neve' ), - 'scroll_to_top' => esc_html__( 'Scroll to Top module', 'neve' ), - 'elementor_booster' => esc_html__( 'Elementor Booster', 'neve' ), - 'ext_h_description' => esc_html__( 'Extend your header with more components and settings, build sticky/transparent headers or display them conditionally.', 'neve' ), - 'ctm_h_description' => esc_html__( 'Easily create custom headers and footers as well as adding your own custom code or content in any of the hooks locations.', 'neve' ), - 'elem_description' => esc_html__( 'Leverage the true flexibility of Elementor with powerful addons and templates that you can import with just one click.', 'neve' ), - 'get_pro_cta' => esc_html__( 'Get the PRO version!', 'neve' ), - 'opens_new_tab_des' => esc_html__( '(opens in a new tab)', 'neve' ), - 'filter' => __( 'Filter', 'neve' ), + 'add_item' => __( 'Add item', 'neve' ), + 'add_items' => __( 'Add items by clicking the ones below.', 'neve' ), + 'all_selected' => __( 'All items are already selected.', 'neve' ), + 'page_layout' => __( 'Page Layout', 'neve' ), + 'page_title' => __( 'Page Title', 'neve' ), + 'upsell_components' => __( 'Upgrade to Neve Pro and unlock all components, including Wish List, Breadcrumbs, Custom Layouts and many more.', 'neve' ), + 'header_booster' => esc_html__( 'Header Booster', 'neve' ), + 'blog_booster' => esc_html__( 'Blog Booster', 'neve' ), + 'woo_booster' => esc_html__( 'WooCommerce Booster', 'neve' ), + 'custom_layouts' => esc_html__( 'Custom Layouts', 'neve' ), + 'white_label' => esc_html__( 'White Label module', 'neve' ), + 'scroll_to_top' => esc_html__( 'Scroll to Top module', 'neve' ), + 'elementor_booster' => esc_html__( 'Elementor Booster', 'neve' ), + 'ext_h_description' => esc_html__( 'Extend your header with more components and settings, build sticky/transparent headers or display them conditionally.', 'neve' ), + 'ctm_h_description' => esc_html__( 'Easily create custom headers and footers as well as adding your own custom code or content in any of the hooks locations.', 'neve' ), + 'elem_description' => esc_html__( 'Leverage the true flexibility of Elementor with powerful addons and templates that you can import with just one click.', 'neve' ), + 'get_pro_cta' => esc_html__( 'Get the PRO version!', 'neve' ), + 'opens_new_tab_des' => esc_html__( '(opens in a new tab)', 'neve' ), + 'filter' => __( 'Filter', 'neve' ), /* translators: %s - Theme name */ - 'neve_options' => __( '%s Options', 'neve' ), + 'neve_options' => __( '%s Options', 'neve' ), + 'migrate_builder_d' => __( 'Migrating builder data', 'neve' ), + 'rollback_builder' => __( 'Rolling back builder', 'neve' ), + 'remove_old_data' => __( 'Removing old data', 'neve' ), + 'customizer_values_notice' => __( 'You must save the current customizer values before running the migration.', 'neve' ), + 'wrong_reload_notice' => __( 'Something went wrong. Please reload the page and try again.', 'neve' ), + 'rollback_to_old' => __( 'Want to roll back to the old builder?', 'neve' ), + 'new_hfg_experience' => __( "We've created a new Header/Footer Builder experience! You can always roll back to the old builder from right here.", 'neve' ), + 'manual_adjust' => __( 'Some manual adjustments may be required.', 'neve' ), + 'reload' => __( 'Reload', 'neve' ), + 'migrate' => __( 'Migrate Builders Data', 'neve' ), + 'legacy_skin' => __( 'Legacy Skin', 'neve' ), + 'neve_30' => __( 'Neve 3.0', 'neve' ), + 'switching_skin' => __( 'Switching skin', 'neve' ), + 'switch_skin' => __( 'Switch Skin', 'neve' ), + 'dismiss' => __( 'Dismiss', 'neve' ), + 'rollback' => __( 'Roll Back', 'neve' ), ]; } diff --git a/inc/customizer/controls/react/instructions_section.php b/inc/customizer/controls/react/instructions_section.php index 04fc730488..81e1dd0099 100644 --- a/inc/customizer/controls/react/instructions_section.php +++ b/inc/customizer/controls/react/instructions_section.php @@ -31,7 +31,6 @@ class Instructions_Section extends \WP_Customize_Section { 'description' => '', 'image' => '', 'quickLinks' => [], - 'hadOldBuilder' => false, 'builderMigrated' => false, ]; /** diff --git a/inc/customizer/options/main.php b/inc/customizer/options/main.php index 2eb94b6e5f..4be557f39c 100644 --- a/inc/customizer/options/main.php +++ b/inc/customizer/options/main.php @@ -30,7 +30,6 @@ public function add_controls() { $this->register_types(); $this->add_main_panels(); $this->change_controls(); - $this->add_skin_switcher(); } /** @@ -125,56 +124,4 @@ protected function change_controls() { // Change default for shop columns WooCommerce option. $this->change_customizer_object( 'setting', 'woocommerce_catalog_columns', 'default', 3 ); } - - /** - * Add the skin switcher. - * - * @return void - * @since 3.0.0 - */ - private function add_skin_switcher() { - // If we started with the new skin this shouldn't show up at all. - if ( get_theme_mod( 'neve_had_old_skin' ) === false ) { - return; - } - - // If we're not using the new builder. We don't show the switch & section. - if ( ! neve_is_new_builder() ) { - return; - } - - // If the pro version exists but it's incompatible, we don't show the switch. - if ( defined( 'NEVE_PRO_VERSION' ) ) { - if ( ! neve_pro_has_support( 'skinv2' ) ) { - return; - } - } - - $section = 'neve_style_section'; - - $this->add_section( - new Section( - $section, - [ - 'priority' => 201, - 'title' => esc_html__( 'Style', 'neve' ), - ] - ) - ); - - $this->add_control( - new Control( - 'neve_new_skin', - [ - 'transport' => 'postMessage', - 'sanitize_callback' => 'sanitize_text_field', - 'default' => 'new', - ], - [ - 'type' => 'neve_skin_switcher', - 'section' => $section, - ] - ) - ); - } }