@@ -40,6 +40,14 @@ class Visualizer_Module_Admin extends Visualizer_Module {
40
40
*/
41
41
private $ _libraryPage ;
42
42
43
+ /**
44
+ * Support page suffix.
45
+ *
46
+ * @access private
47
+ * @var string
48
+ */
49
+ private $ _supportPage ;
50
+
43
51
/**
44
52
* Constructor.
45
53
*
@@ -56,12 +64,14 @@ public function __construct( Visualizer_Plugin $plugin ) {
56
64
$ this ->_addAction ( 'enqueue_block_editor_assets ' , 'enqueueMediaScripts ' );
57
65
$ this ->_addAction ( 'admin_footer ' , 'renderTemplates ' );
58
66
$ this ->_addAction ( 'admin_enqueue_scripts ' , 'enqueueLibraryScripts ' , null , 0 );
67
+ $ this ->_addAction ( 'admin_enqueue_scripts ' , 'enqueue_support_page ' );
59
68
$ this ->_addAction ( 'admin_menu ' , 'registerAdminMenu ' );
60
69
$ this ->_addFilter ( 'media_view_strings ' , 'setupMediaViewStrings ' );
61
70
$ this ->_addFilter ( 'plugin_action_links ' , 'getPluginActionLinks ' , 10 , 2 );
62
71
$ this ->_addFilter ( 'plugin_row_meta ' , 'getPluginMetaLinks ' , 10 , 2 );
63
72
$ this ->_addFilter ( 'visualizer_logger_data ' , 'getLoggerData ' );
64
73
$ this ->_addFilter ( 'visualizer_feedback_review_trigger ' , 'feedbackReviewTrigger ' );
74
+ $ this ->_addFilter ( 'themeisle_sdk_blackfriday_data ' , 'add_black_friday_data ' );
65
75
66
76
// screen pagination
67
77
$ this ->_addFilter ( 'set-screen-option ' , 'setScreenOptions ' , 10 , 3 );
@@ -639,40 +649,56 @@ public function renderTemplates() {
639
649
* @param string $suffix The current page suffix.
640
650
*/
641
651
public function enqueueLibraryScripts ( $ suffix ) {
642
- if ( $ suffix === $ this ->_libraryPage ) {
643
- wp_enqueue_style ( 'visualizer-library ' , VISUALIZER_ABSURL . 'css/library.css ' , array (), Visualizer_Plugin::VERSION );
644
- $ this ->_addFilter ( 'media_upload_tabs ' , 'setupVisualizerTab ' );
645
- wp_enqueue_media ();
652
+ if ( $ suffix !== $ this ->_libraryPage ) {
653
+ return ;
654
+ }
655
+
656
+ wp_enqueue_style ( 'visualizer-library ' , VISUALIZER_ABSURL . 'css/library.css ' , array (), Visualizer_Plugin::VERSION );
657
+ $ this ->_addFilter ( 'media_upload_tabs ' , 'setupVisualizerTab ' );
658
+ wp_enqueue_media ();
659
+ wp_enqueue_script (
660
+ 'visualizer-library ' ,
661
+ VISUALIZER_ABSURL . 'js/library.js ' ,
662
+ array (
663
+ 'jquery ' ,
664
+ 'media-views ' ,
665
+ 'clipboard ' ,
666
+ ),
667
+ Visualizer_Plugin::VERSION ,
668
+ true
669
+ );
670
+
671
+ wp_enqueue_script ( 'visualizer-customization ' , $ this ->get_user_customization_js (), array (), null , true );
672
+
673
+ $ query = $ this ->getQuery ();
674
+ while ( $ query ->have_posts () ) {
675
+ $ chart = $ query ->next_post ();
676
+ $ library = $ this ->load_chart_type ( $ chart ->ID );
677
+ if ( is_null ( $ library ) ) {
678
+ continue ;
679
+ }
646
680
wp_enqueue_script (
647
- 'visualizer-library ' ,
648
- VISUALIZER_ABSURL . 'js/library.js ' ,
649
- array (
650
- 'jquery ' ,
651
- 'media-views ' ,
652
- 'clipboard ' ,
653
- ),
681
+ "visualizer-render- $ library " ,
682
+ VISUALIZER_ABSURL . 'js/render-facade.js ' ,
683
+ apply_filters ( 'visualizer_assets_render ' , array ( 'visualizer-library ' , 'visualizer-customization ' ), true ),
654
684
Visualizer_Plugin::VERSION ,
655
685
true
656
686
);
687
+ }
657
688
658
- wp_enqueue_script ( 'visualizer-customization ' , $ this ->get_user_customization_js (), array (), null , true );
689
+ do_action ( 'themeisle_internal_page ' , VISUALIZER_DIRNAME , 'library ' );
690
+ }
659
691
660
- $ query = $ this ->getQuery ();
661
- while ( $ query ->have_posts () ) {
662
- $ chart = $ query ->next_post ();
663
- $ library = $ this ->load_chart_type ( $ chart ->ID );
664
- if ( is_null ( $ library ) ) {
665
- continue ;
666
- }
667
- wp_enqueue_script (
668
- "visualizer-render- $ library " ,
669
- VISUALIZER_ABSURL . 'js/render-facade.js ' ,
670
- apply_filters ( 'visualizer_assets_render ' , array ( 'visualizer-library ' , 'visualizer-customization ' ), true ),
671
- Visualizer_Plugin::VERSION ,
672
- true
673
- );
674
- }
692
+ /**
693
+ * Enqueue script for support page.
694
+ *
695
+ * @param string $hook_suffix Current hook.
696
+ */
697
+ public function enqueue_support_page ( $ hook_suffix ) {
698
+ if ( $ this ->_supportPage !== $ hook_suffix ) {
699
+ return ;
675
700
}
701
+ do_action ( 'themeisle_internal_page ' , VISUALIZER_DIRNAME , 'support ' );
676
702
}
677
703
678
704
/**
@@ -718,7 +744,8 @@ public function registerAdminMenu() {
718
744
'edit_posts ' ,
719
745
'admin.php?page= ' . Visualizer_Plugin::NAME . '&vaction=addnew '
720
746
);
721
- add_submenu_page (
747
+
748
+ $ this ->_supportPage = add_submenu_page (
722
749
Visualizer_Plugin::NAME ,
723
750
__ ( 'Support ' , 'visualizer ' ),
724
751
__ ( 'Support ' , 'visualizer ' ) . '<span class="dashicons dashicons-editor-help more-features-icon" style="width: 17px; height: 17px; margin-left: 4px; color: #ffca54; font-size: 17px; vertical-align: -3px;"></span> ' ,
@@ -938,7 +965,6 @@ private function getQuery() {
938
965
*/
939
966
public function renderSupportPage () {
940
967
wp_enqueue_style ( 'visualizer-upsell ' , VISUALIZER_ABSURL . 'css/upsell.css ' , array (), Visualizer_Plugin::VERSION );
941
- do_action ( 'themeisle_internal_page ' , VISUALIZER_DIRNAME , 'support ' );
942
968
include_once VISUALIZER_ABSPATH . '/templates/support.php ' ;
943
969
}
944
970
@@ -1095,12 +1121,6 @@ public function renderLibraryPage() {
1095
1121
)
1096
1122
);
1097
1123
1098
- do_action ( 'themeisle_internal_page ' , VISUALIZER_DIRNAME , 'library ' );
1099
-
1100
- if ( ! apply_filters ( 'visualizer_is_business ' , false ) ) {
1101
- do_action ( 'themeisle_sdk_load_banner ' , 'visualizer ' );
1102
- }
1103
-
1104
1124
$ render ->render ();
1105
1125
}
1106
1126
@@ -1304,4 +1324,46 @@ public function count_charts( $limit = -1 ) {
1304
1324
$ query = new WP_Query ( $ args );
1305
1325
return $ query ->post_count ;
1306
1326
}
1327
+
1328
+ /**
1329
+ * Set the black friday data.
1330
+ *
1331
+ * @param array $configs The configuration array for the loaded products.
1332
+ * @return array
1333
+ */
1334
+ public function add_black_friday_data ( $ configs ) {
1335
+ $ config = $ configs ['default ' ];
1336
+
1337
+ // translators: %1$s - HTML tag, %2$s - discount, %3$s - HTML tag, %4$s - product name.
1338
+ $ message_template = __ ( 'Our biggest sale of the year: %1$sup to %2$s OFF%3$s on %4$s. Don \'t miss this limited-time offer. ' , 'wp-cloudflare-page-cache ' );
1339
+ $ product_label = 'Visualizer ' ;
1340
+ $ discount = '70% ' ;
1341
+
1342
+ $ plan = apply_filters ( 'product_visualizer_license_plan ' , 0 );
1343
+ $ license = apply_filters ( 'product_visualizer_license_key ' , false );
1344
+ $ is_pro = 0 < $ plan ;
1345
+
1346
+ if ( $ is_pro ) {
1347
+ // translators: %1$s - HTML tag, %2$s - discount, %3$s - HTML tag, %4$s - product name.
1348
+ $ message_template = __ ( 'Get %1$sup to %2$s off%3$s when you upgrade your %4$s plan or renew early. ' , 'wp-cloudflare-page-cache ' );
1349
+ $ product_label = 'Visualizer Pro ' ;
1350
+ $ discount = '30% ' ;
1351
+ }
1352
+
1353
+ $ product_label = sprintf ( '<strong>%s</strong> ' , $ product_label );
1354
+ $ url_params = array (
1355
+ 'utm_term ' => $ is_pro ? 'plan- ' . $ plan : 'free ' ,
1356
+ 'lkey ' => ! empty ( $ license ) ? $ license : false ,
1357
+ );
1358
+
1359
+ $ config ['message ' ] = sprintf ( $ message_template , '<strong> ' , $ discount , '</strong> ' , $ product_label );
1360
+ $ config ['sale_url ' ] = add_query_arg (
1361
+ $ url_params ,
1362
+ tsdk_translate_link ( tsdk_utmify ( 'https://themeisle.link/vizualizer-bf ' , 'bfcm ' , 'visualizer ' ) )
1363
+ );
1364
+
1365
+ $ configs [ VISUALIZER_DIRNAME ] = $ config ;
1366
+
1367
+ return $ configs ;
1368
+ }
1307
1369
}
0 commit comments