PluginProbe ʕ •ᴥ•ʔ
YITH WooCommerce Wishlist / 4.0.1
YITH WooCommerce Wishlist v4.0.1
trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.17 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.18 3.0.19 3.0.2 3.0.20 3.0.21 3.0.22 3.0.23 3.0.25 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.10.0 3.11.0 3.12.0 3.13.0 3.14.0 3.15.0 3.16.0 3.17.0 3.18.0 3.19.0 3.2.0 3.20.0 3.21.0 3.22.0 3.23.0 3.24.0 3.25.0 3.26.0 3.27.0 3.28.0 3.29.0 3.3.0 3.30.0 3.31.0 3.32.0 3.33.0 3.34.0 3.35.0 3.36.0 3.37.0 3.38.0 3.4.0 3.5.0 3.6.0 3.7.0 3.8.0 3.9.0 4.0.0 4.0.1 4.1.0 4.10.0 4.10.1 4.10.2 4.11.0 4.12.0 4.13.0 4.14.0 4.15.0 4.2.0 4.3.0 4.4.0 4.5.0 4.6.0 4.7.0 4.8.0 4.9.0
yith-woocommerce-wishlist / includes / admin / class-yith-wcwl-rendering-method-admin-handler.php
yith-woocommerce-wishlist / includes / admin Last commit date
class-yith-wcwl-admin-panel.php 1 year ago class-yith-wcwl-admin.php 1 year ago class-yith-wcwl-rendering-method-admin-handler.php 1 year ago
class-yith-wcwl-rendering-method-admin-handler.php
131 lines
1 <?php
2 /**
3 * Class that manage the admin handling rendering methods
4 *
5 * @since 4.0.0
6 * @package YITH\Wishlist\Admin\
7 * @author YITH <plugins@yithemes.com>
8 */
9
10 defined( 'YITH_WCWL' ) || exit;
11
12 if ( ! class_exists( 'YITH_WCWL_Rendering_Method_Admin_Handler' ) ) {
13 /**
14 * Class that manage the admin handling rendering methods
15 */
16 class YITH_WCWL_Rendering_Method_Admin_Handler {
17 use YITH_WCWL_Singleton_Trait;
18 use YITH_WCWL_Rendering_Method_Access_Trait;
19
20 /**
21 * Class constructor
22 */
23 protected function __construct() {
24 $this->maybe_update_rendering_method();
25 add_action( 'admin_notices', array( $this, 'add_notices' ) );
26 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
27 }
28
29 protected function maybe_update_rendering_method() {
30 if ( ! empty( $_REQUEST[ self::$exit_from_preview_mode_param ] ) ) {
31 self::update_preview_options( false );
32 }
33 if ( ! empty( $_REQUEST[ self::$convert_to_react_rendering_param ] ) ) {
34 self::update_preview_options( false );
35 self::$updated_rendering_method = self::update_rendering_method( 'react-components' );
36 }
37 }
38
39 /**
40 * Add notices used to update the rendering method
41 */
42 public function add_notices() {
43 $rendering_method = self::get_rendering_method_option();
44 $args = array();
45
46 if ( 'php-templates' === $rendering_method && YITH_WCWL_Admin_Panel::get_instance()->is_panel() ) {
47 $args[ 'message' ] = sprintf(
48 // translators: %1$s is the opening tag to hyperlink the text; %2$s id the closing tag to hyperlink the text;
49 __( 'YITH Wishlist 4.0 includes the new React Components. %1$s Read how to convert to them to improve the plugin performance %2$s', 'yith-woocommerce-wishlist' ),
50 '<a id="yith-wcwl-open-rendering-methods-modal" href="#">',
51 '</a>'
52 );
53 }
54
55 if ( 'react-components' === $rendering_method && self::$updated_rendering_method ) {
56 $args[ 'message' ] = sprintf(
57 __( 'Successfully switched to the new React Components management!', 'yith-woocommerce-wishlist' ),
58 '<a id="yith-wcwl-open-rendering-methods-modal" href="#">',
59 '</a>'
60 );
61 $args[ 'notice_type' ] = 'success';
62 }
63
64 if ( ! empty( $args[ 'message' ] ) ) {
65 $args = wp_parse_args(
66 $args,
67 array(
68 'type' => 'notice',
69 'notice_type' => 'warning',
70 )
71 );
72
73 echo yith_plugin_fw_get_component( $args );
74 }
75 }
76
77 /**
78 * Enqueue scripts
79 */
80 public function enqueue_scripts() {
81 if ( 'react-components' === self::get_rendering_method_option() ) {
82 return;
83 }
84
85 $prefix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'unminified/' : '';
86 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
87
88 wp_register_script( 'yith-wcwl-rendering-methods', YITH_WCWL_ASSETS_JS_URL . $prefix . 'admin/rendering-methods' . $suffix . '.js', array( 'jquery' ), YITH_WCWL_VERSION );
89 wp_register_style( 'yith-wcwl-rendering-methods', YITH_WCWL_ASSETS_CSS_URL . 'admin/rendering-methods.css', array(), YITH_WCWL_VERSION );
90
91 $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'REQUEST_URI' ];
92
93 wp_localize_script(
94 'yith-wcwl-rendering-methods',
95 'yithWcwlRenderingMethods',
96 array(
97 'i18n' => array(
98 'reactOnlyOptionModalTitle' => __( 'This option is available only in the new React templates. Convert now to unlock all the new features!', 'yith-woocommerce-wishlist' ),
99 ),
100 'modals' => array(
101 'updateRenderingMethod' => array(
102 'title' => __( 'YITH Wishlist 4.0 includes new React Components. Convert now to improve the plugin performance!', 'yith-woocommerce-wishlist' ),
103 'content' => __( "In this update, we converted our frontend templates using React to improve code readability and plugin performance.<br><br><b>Our PHP templates will be deprecated soon</b> (in the next major update) so we suggest you convert them now to enjoy the new system and check if everything works properly.<br><br>Any doubts? Don't worry! You can click on the button below to see a preview of the new system on your site before you apply the changes!", 'yith-woocommerce-wishlist' ),
104 'footer' => yith_wcwl_get_view(
105 'rendering-methods/modal/footer.php',
106 array(
107 'preview_url' => add_query_arg(
108 array(
109 self::$react_preview_key => true,
110 ),
111 wc_get_page_permalink( 'shop' )
112 ),
113 'convert_to_react_url' => add_query_arg( array( self::$convert_to_react_rendering_param => true ), $current_url ),
114 ),
115 true ),
116 ),
117 ),
118 'templates' => array(
119 'reactOnlyOptionNotice' => yith_wcwl_get_view( 'rendering-methods/react-only-option-notice.php', array(), true ),
120 ),
121 )
122 );
123
124 if ( YITH_WCWL_Admin_Panel::get_instance()->is_panel() ) {
125 wp_enqueue_script( 'yith-wcwl-rendering-methods' );
126 wp_enqueue_style( 'yith-wcwl-rendering-methods' );
127 }
128 }
129 }
130 }
131