Skip to content

Commit ce31a8e

Browse files
authored
release: fixes
Adds feadzy features.
2 parents f98e239 + 7da7b60 commit ce31a8e

File tree

8 files changed

+199
-20
lines changed

8 files changed

+199
-20
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-plugins'), 'version' => 'c57846e72deaa82a7a04');
1+
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-plugins'), 'version' => '3997ba6be36742082cb2');

assets/js/build/promos/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/src/feedzy.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import { InspectorControls } from '@wordpress/block-editor';
2+
import { PanelBody } from '@wordpress/components';
3+
import { createHigherOrderComponent } from '@wordpress/compose';
4+
import { addFilter } from '@wordpress/hooks';
5+
import { useEffect, useState} from '@wordpress/element';
6+
7+
import useSettings from './common/useSettings.js';
8+
const withFeedzyNotice = createHigherOrderComponent((BlockEdit) => {
9+
return (props) => {
10+
11+
if (props.name !== 'core/rss' || ! Boolean(window.themeisleSDKPromotions.showPromotion)) {
12+
return <BlockEdit {...props} />;
13+
}
14+
if ('feedzy-editor' !== window.themeisleSDKPromotions.showPromotion) {
15+
return <BlockEdit {...props} />;
16+
}
17+
const [getOption, updateOption, status] = useSettings();
18+
const [hasSkipped, setHasSkipped] = useState(false);
19+
20+
const onSkip = () => {
21+
const option = {...window.themeisleSDKPromotions.option};
22+
option[window.themeisleSDKPromotions.showPromotion] = new Date().getTime() / 1000 | 0;
23+
updateOption('themeisle_sdk_promotions', JSON.stringify(option));
24+
window.themeisleSDKPromotions.showPromotion = false;
25+
};
26+
useEffect(() => {
27+
if (hasSkipped) {
28+
onSkip();
29+
}
30+
}, [hasSkipped]);
31+
32+
33+
if (hasSkipped) {
34+
return <BlockEdit {...props} />;
35+
}
36+
return (
37+
<>
38+
<BlockEdit {...props} />
39+
<InspectorControls>
40+
<PanelBody>
41+
<div
42+
style={{
43+
padding: '16px 10px',
44+
backgroundColor: '#f0f6fc',
45+
borderLeft: '4px solid #72aee6',
46+
margin: '5px 0',
47+
fontSize: '13px',
48+
color: '#1e1e1e',
49+
position: 'relative'
50+
}}
51+
>
52+
<div dangerouslySetInnerHTML={{ __html: window.themeisleSDKPromotions.labels.feedzy.editor_recommends }} />
53+
<button
54+
onClick={() => setHasSkipped(true)}
55+
style={{
56+
position: 'absolute',
57+
top: '-2px',
58+
right: '3px',
59+
cursor: 'pointer',
60+
background: 'none',
61+
border: 'none',
62+
padding: '2px',
63+
color: '#757575',
64+
fontSize: '16px'
65+
}}
66+
>
67+
×
68+
</button>
69+
</div>
70+
</PanelBody>
71+
</InspectorControls>
72+
</>
73+
);
74+
};
75+
}, 'withFeedzyNotice');
76+
77+
addFilter(
78+
'editor.BlockEdit',
79+
'feedzy/with-notice',
80+
withFeedzyNotice
81+
);

assets/js/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ import './rop.js';
44
import './neve.js';
55
import './redirection-for-cf7.js';
66
import './hyve.js';
7+
import './feedzy.js';
78
import './wp-full-pay.js';

src/Loader.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ final class Loader {
138138
'spark_desc2' => 'Add a top notification bar on your website to highlight the latest products, offers, or upcoming events.',
139139
'spark_desc3' => 'Enable an advanced review section, enlarging the basic review options with lots of capabilities.',
140140
],
141+
142+
'feedzy' => [
143+
'import_desc' => 'Schedule automatic content imports from any RSS feed directly to your site. %sBuilt by %s%s',
144+
'install_now' => 'Install Now',
145+
'by' => 'by %s',
146+
'editor_recommends' => '%s recommends %sFeedzy%s to display entries from any RSS feed with more advanced styling and filtering options.',
147+
],
141148
'optimole' => [
142149
'installOptimole' => 'Install Optimole',
143150
'gotodash' => 'Go to Optimole dashboard',

src/Modules/About_us.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ private function get_other_products_data() {
379379
'name' => 'Hyve Lite',
380380
],
381381
'wp-full-stripe-free' => [
382-
'name' => 'Stripe Payment forms for WordPress Plugin – WP Full Pay',
382+
'name' => 'WP Full Pay',
383383
],
384384
];
385385

src/Modules/Promotions.php

Lines changed: 96 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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
]

src/Product.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,17 @@ public function is_wordpress_available() {
346346
* @return string Friendly name.
347347
*/
348348
public function get_friendly_name() {
349-
$name = apply_filters( $this->get_key() . '_friendly_name', trim( str_replace( 'Lite', '', $this->get_name() ) ) );
349+
$name = trim( str_replace( 'Lite', '', $this->get_name() ) );
350+
if ( defined( 'OTTER_BLOCKS_BASEFILE' ) && OTTER_BLOCKS_BASEFILE === $this->basefile ) {
351+
$name = 'Otter Blocks';
352+
}
353+
if ( defined( 'OPTML_BASEFILE' ) && OPTML_BASEFILE === $this->basefile ) {
354+
$name = 'Optimole';
355+
}
356+
if ( defined( 'WPMM_FILE' ) && WPMM_FILE === $this->basefile ) {
357+
$name = 'LightStart';
358+
}
359+
$name = apply_filters( $this->get_key() . '_friendly_name', $name );
350360
$name = rtrim( $name, '- ()' );
351361

352362
return $name;

0 commit comments

Comments
 (0)