@@ -98,6 +98,13 @@ class Promotions extends Abstract_Module {
9898 */
9999 private $ option_wp_full_pay = 'themeisle_sdk_promotions_wp_full_pay_installed ' ;
100100
101+ /**
102+ * Option key for Feedzy.
103+ *
104+ * @var string
105+ */
106+ private $ option_feedzy = 'themeisle_sdk_promotions_feedzy_installed ' ;
107+
101108 /**
102109 * Loaded promotion.
103110 *
@@ -134,16 +141,21 @@ public function can_load( $product ) {
134141 return false ;
135142 }
136143
137- $ this ->debug = apply_filters ( 'themeisle_sdk_promo_debug ' , $ this ->debug );
138- $ promotions_to_load = apply_filters ( $ product ->get_key () . '_load_promotions ' , array () );
144+ $ this ->debug = apply_filters ( 'themeisle_sdk_promo_debug ' , $ this ->debug );
145+ $ promotions_to_load = apply_filters ( $ product ->get_key () . '_load_promotions ' , array () );
146+
139147 $ promotions_to_load [] = 'optimole ' ;
140148 $ promotions_to_load [] = 'rop ' ;
141149 $ promotions_to_load [] = 'woo_plugins ' ;
142150 $ promotions_to_load [] = 'neve ' ;
143151 $ promotions_to_load [] = 'redirection-cf7 ' ;
144152 $ promotions_to_load [] = 'hyve ' ;
145153 $ promotions_to_load [] = 'wp_full_pay ' ;
154+ $ promotions_to_load [] = 'feedzy_import ' ;
146155
156+ if ( defined ( 'NEVE_VERSION ' ) || defined ( 'WPMM_PATH ' ) || defined ( 'OTTER_BLOCKS_VERSION ' ) || defined ( 'OBFX_URL ' ) ) {
157+ $ promotions_to_load [] = 'feedzy_embed ' ;
158+ }
147159 $ promotions_to_load = array_unique ( $ promotions_to_load );
148160
149161 $ this ->promotions = $ this ->get_promotions ();
@@ -155,7 +167,6 @@ public function can_load( $product ) {
155167 unset( $ this ->promotions [ $ slug ] );
156168 }
157169 }
158-
159170 add_action ( 'init ' , array ( $ this , 'register_settings ' ), 99 );
160171 add_action ( 'admin_init ' , array ( $ this , 'register_reference ' ), 99 );
161172
@@ -246,6 +257,10 @@ public function register_reference() {
246257 if ( isset ( $ _GET ['wp_full_pay_reference_key ' ] ) ) {
247258 update_option ( 'wp_full_pay_reference_key ' , sanitize_key ( $ _GET ['wp_full_pay_reference_key ' ] ) );
248259 }
260+ if ( isset ( $ _GET ['feedzy_reference_key ' ] ) || ( isset ( $ _GET ['from ' ], $ _GET ['plugin ' ] ) && $ _GET ['from ' ] === 'import ' && str_starts_with ( sanitize_key ( $ _GET ['plugin ' ] ), 'feedzy ' ) ) ) {
261+ update_option ( 'feedzy_reference_key ' , sanitize_key ( $ _GET ['feedzy_reference_key ' ] ?? 'i- ' . $ this ->product ->get_key () ) );
262+ update_option ( $ this ->option_feedzy , 1 );
263+ }
249264 }
250265
251266 /**
@@ -402,6 +417,9 @@ private function get_promotions() {
402417 $ has_enough_old_posts = $ this ->has_old_posts ();
403418 $ is_min_php_8_1 = version_compare ( PHP_VERSION , '8.1 ' , '>= ' );
404419
420+ $ has_feedzy = defined ( 'FEEDZY_BASEFILE ' ) || $ this ->is_plugin_installed ( 'feedzy-rss-feedss ' );
421+ $ had_feedzy_from_promo = get_option ( $ this ->option_feedzy , false );
422+
405423 $ all = [
406424 'optimole ' => [
407425 'om-editor ' => [
@@ -428,6 +446,19 @@ private function get_promotions() {
428446 'delayed ' => true ,
429447 ],
430448 ],
449+ 'feedzy_import ' => [
450+ 'feedzy-import ' => [
451+ 'env ' => true ,
452+ 'screen ' => 'import ' ,
453+ 'always ' => true ,
454+ ],
455+ ],
456+ 'feedzy_embed ' => [
457+ 'feedzy-editor ' => [
458+ 'env ' => ! $ has_feedzy && is_main_site () && ! $ had_feedzy_from_promo ,
459+ 'screen ' => 'editor ' ,
460+ ],
461+ ],
431462 'otter ' => [
432463 'blocks-css ' => [
433464 'env ' => ! $ has_otter && $ is_min_req_v && ! $ had_otter_from_promo ,
@@ -514,7 +545,6 @@ private function get_promotions() {
514545 unset( $ all [ $ slug ] );
515546 }
516547 }
517-
518548 return $ all ;
519549 }
520550
@@ -564,31 +594,36 @@ private function filter_by_screen_and_merge() {
564594 $ is_theme_install = isset ( $ current_screen ->id ) && ( $ current_screen ->id === 'theme-install ' );
565595 $ is_plugin_install = isset ( $ current_screen ->id ) && ( $ current_screen ->id === 'plugin-install ' );
566596 $ is_product = isset ( $ current_screen ->id ) && $ current_screen ->id === 'product ' ;
597+ $ is_import = isset ( $ current_screen ->id ) && $ current_screen ->id === 'import ' ;
567598 $ is_cf7_install = isset ( $ current_screen ->id ) && function_exists ( 'str_contains ' ) ? str_contains ( $ current_screen ->id , 'page_wpcf7 ' ) : false ;
568599
569- $ return = [];
570-
600+ $ return = [];
571601 $ product_install_time = (int ) $ this ->product ->get_install_time ();
572602 $ is_older = time () > ( $ product_install_time + ( 3 * DAY_IN_SECONDS ) );
573603 $ is_newer = time () < ( $ product_install_time + ( 6 * HOUR_IN_SECONDS ) );
574-
575604 foreach ( $ this ->promotions as $ slug => $ promos ) {
576605 foreach ( $ promos as $ key => $ data ) {
577606
578- $ data = wp_parse_args ( $ data , [ 'delayed ' => false ] );
607+ $ data = wp_parse_args (
608+ $ data ,
609+ [
610+ 'delayed ' => false ,
611+ 'always ' => false ,
612+ ]
613+ );
579614
580615 if (
581- ! $ this ->debug &&
616+ ! $ this ->debug &&
582617 (
583618 ( $ data ['delayed ' ] === true && ! $ is_older ) || // Skip promotions that are delayed for 3 days.
584619 $ is_newer // Skip promotions for the first 6 hours after install.
585620 )
621+ && ! $ data ['always ' ]
586622 ) {
587623 unset( $ this ->promotions [ $ slug ][ $ key ] );
588624
589625 continue ;
590626 }
591-
592627 switch ( $ data ['screen ' ] ) {
593628 case 'media-editor ' :
594629 if ( ! $ is_media && ! $ is_editor ) {
@@ -605,6 +640,11 @@ private function filter_by_screen_and_merge() {
605640 unset( $ this ->promotions [ $ slug ][ $ key ] );
606641 }
607642 break ;
643+ case 'import ' :
644+ if ( ! $ is_import ) {
645+ unset( $ this ->promotions [ $ slug ][ $ key ] );
646+ }
647+ break ;
608648 case 'elementor ' :
609649 if ( ! $ is_elementor ) {
610650 unset( $ this ->promotions [ $ slug ][ $ key ] );
@@ -683,11 +723,11 @@ private function load_promotion( $slug ) {
683723 add_action ( 'admin_notices ' , [ $ this , 'render_wp_full_pay_notice ' ] );
684724 }
685725
726+ add_action ( 'load-import.php ' , [ $ this , 'add_import ' ] );
686727 $ this ->load_woo_promos ();
687728
688729 return ;
689730 }
690-
691731 switch ( $ slug ) {
692732 case 'om-editor ' :
693733 case 'om-image-block ' :
@@ -707,6 +747,13 @@ private function load_promotion( $slug ) {
707747 add_action ( 'admin_enqueue_scripts ' , [ $ this , 'enqueue ' ] );
708748 add_action ( 'admin_notices ' , [ $ this , 'render_rop_dash_notice ' ] );
709749 break ;
750+ case 'feedzy-import ' :
751+ add_action ( 'load-import.php ' , [ $ this , 'add_import ' ] );
752+
753+ break ;
754+ case 'feedzy-editor ' :
755+ add_action ( 'enqueue_block_editor_assets ' , [ $ this , 'enqueue ' ] );
756+ break ;
710757 case 'ppom ' :
711758 case 'sparks-wishlist ' :
712759 case 'sparks-announcement ' :
@@ -744,6 +791,25 @@ private function load_promotion( $slug ) {
744791 }
745792 }
746793
794+ /**
795+ * Add import row.
796+ *
797+ * @return void
798+ */
799+ public function add_import () {
800+ global $ wp_importers ;
801+ if ( isset ( $ wp_importers ['feedzy-rss-feeds ' ] ) ) {
802+ return ;
803+ }
804+ $ wp_importers ['feedzy-rss-feeds ' ] = array ( // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
805+ 'Feedzy ' ,
806+ sprintf ( Loader::$ labels ['promotions ' ]['feedzy ' ]['import_desc ' ], '<span style="float: left; font-style: italic;margin-top:0.4em;"> ' , $ this ->product ->get_friendly_name (), '</span> ' ),
807+ 'install ' => 'feedzy-rss-feeds ' ,
808+ );
809+ if ( defined ( 'FEEDZY_BASEFILE ' ) ) {
810+ unset( $ wp_importers ['feedzy-rss-feeds ' ]['install ' ] );
811+ }
812+ }
747813 /**
748814 * Render dashboard notice.
749815 */
@@ -769,16 +835,30 @@ public function enqueue() {
769835 $ asset_file = require $ themeisle_sdk_max_path . '/assets/js/build/promos/index.asset.php ' ;
770836 $ deps = array_merge ( $ asset_file ['dependencies ' ], [ 'updates ' ] );
771837
772- $ themes = wp_get_themes ();
773- $ neve_action = isset ( $ themes ['neve ' ] ) ? 'activate ' : 'install ' ;
774-
838+ $ themes = wp_get_themes ();
839+ $ neve_action = isset ( $ themes ['neve ' ] ) ? 'activate ' : 'install ' ;
840+ $ labels = Loader::$ labels ['promotions ' ];
841+ $ labels ['feedzy ' ]['editor_recommends ' ] = sprintf (
842+ $ labels ['feedzy ' ]['editor_recommends ' ],
843+ $ this ->product ->get_friendly_name (),
844+ '<a target="_blank" href=" ' . add_query_arg (
845+ array (
846+ 'tab ' => 'plugin-information ' ,
847+ 'plugin ' => 'feedzy-rss-feeds ' ,
848+ '_wpnonce ' => wp_create_nonce ( 'activate-plugin_feedzy-rss-feeds ' ),
849+ 'feedzy_reference_key ' => 'e- ' . $ this ->product ->get_key (),
850+ ),
851+ network_admin_url ( 'plugin-install.php ' )
852+ ) . '"> ' ,
853+ '</a> '
854+ );
775855 wp_register_script ( $ handle , $ themeisle_sdk_src . 'assets/js/build/promos/index.js ' , $ deps , $ asset_file ['version ' ], true );
776856 wp_localize_script (
777857 $ handle ,
778858 'themeisleSDKPromotions ' ,
779859 [
780860 'debug ' => $ this ->debug ,
781- 'labels ' => Loader:: $ labels[ ' promotions ' ] ,
861+ 'labels ' => $ labels ,
782862 'email ' => $ user ->user_email ,
783863 'showPromotion ' => $ this ->loaded_promo ,
784864 'optionKey ' => $ this ->option_main ,
@@ -810,7 +890,7 @@ public function enqueue() {
810890 'stylesheet ' => 'neve ' ,
811891 '_wpnonce ' => wp_create_nonce ( 'switch-theme_neve ' ),
812892 ],
813- admin_url ( 'themes.php ' )
893+ admin_url ( 'themes.php ' )
814894 )
815895 ),
816896 ]
0 commit comments