Skip to content

Commit 542edf1

Browse files
committed
rebase
1 parent af6df21 commit 542edf1

File tree

4 files changed

+134
-0
lines changed

4 files changed

+134
-0
lines changed

includes/admin/feedzy-rss-feeds-admin.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ public function enqueue_styles_admin() {
247247
wp_set_script_translations( $this->plugin_name . '_feedback', 'feedzy-rss-feeds' );
248248
}
249249

250+
if ( 'feedzy_imports' === $screen->post_type && 'edit' === $screen->base && feedzy_show_review_notice() ) {
251+
$asset_file = include FEEDZY_ABSPATH . '/js/build/review.asset.php';
252+
wp_enqueue_script( $this->plugin_name . '_review', FEEDZY_ABSURL . 'js/build/review.js', $asset_file['dependencies'], $asset_file['version'], true );
253+
}
254+
250255
wp_enqueue_style( $this->plugin_name . '-settings', FEEDZY_ABSURL . 'css/settings.css', array(), $this->version );
251256
wp_enqueue_style( $this->plugin_name . '-metabox', FEEDZY_ABSURL . 'css/metabox-settings.css', array( $this->plugin_name . '-settings' ), $this->version );
252257
}
@@ -1968,4 +1973,19 @@ public function get_lang_list() {
19681973

19691974
return $target_lang;
19701975
}
1976+
1977+
/**
1978+
* Register settings.
1979+
*/
1980+
public function register_settings() {
1981+
register_setting(
1982+
'feedzy',
1983+
'feedzy_review_notice',
1984+
array(
1985+
'type' => 'string',
1986+
'default' => 'no',
1987+
'show_in_rest' => true
1988+
)
1989+
);
1990+
}
19711991
}

includes/feedzy-rss-feeds-feed-tweaks.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,3 +567,41 @@ function feedzy_show_import_tour() {
567567
}
568568
return false;
569569
}
570+
571+
/**
572+
* Show review notice.
573+
*
574+
* @return bool
575+
*/
576+
function feedzy_show_review_notice() {
577+
$has_dismissed = get_option( 'feedzy_review_notice', 'no' );
578+
579+
if ( 'yes' === $has_dismissed ) {
580+
return false;
581+
}
582+
583+
$install_date = get_option( 'feedzy_rss_feeds_install', 0 );
584+
$days_since = ( time() - $install_date ) / DAY_IN_SECONDS;
585+
586+
if ( $days_since < 7 ) {
587+
return false;
588+
}
589+
590+
$args = array(
591+
'post_type' => 'feedzy_imports',
592+
'post_status' => 'publish',
593+
'posts_per_page' => 1,
594+
'meta_query' => array(
595+
array(
596+
'key' => 'imported_items_count',
597+
'value' => 100,
598+
'type' => 'numeric',
599+
'compare' => '>='
600+
)
601+
)
602+
);
603+
604+
$imported_posts = new WP_Query( $args );
605+
606+
return $imported_posts->have_posts();
607+
}

includes/feedzy-rss-feeds.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ private function define_admin_hooks() {
200200
self::$instance->loader->add_filter( 'feedzy_get_source_validity_error', self::$instance->admin, 'get_source_validity_error', 10, 3 );
201201
self::$instance->loader->add_filter( 'post_row_actions', self::$instance->admin, 'add_feedzy_category_actions', 10, 2 );
202202
self::$instance->loader->add_filter( 'admin_footer', self::$instance->admin, 'handle_upgrade_submenu' );
203+
self::$instance->loader->add_action( 'init', self::$instance->admin, 'register_settings' );
203204

204205
// do not load this with the loader as this will need a corresponding remove_filter also.
205206
add_filter( 'update_post_metadata', array( self::$instance->admin, 'validate_category_feeds' ), 10, 5 );

js/Review/index.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* WordPress dependencies.
3+
*/
4+
import { __ } from '@wordpress/i18n';
5+
6+
import apiFetch from '@wordpress/api-fetch';
7+
8+
import domReady from '@wordpress/dom-ready';
9+
10+
import {
11+
Button,
12+
Modal
13+
} from '@wordpress/components';
14+
15+
import {
16+
createRoot,
17+
useState
18+
} from '@wordpress/element';
19+
20+
const App = () => {
21+
const [ isOpen, setOpen ] = useState( true );
22+
23+
const closeModal = async () => {
24+
console.log( 'closeModal' );
25+
try {
26+
await apiFetch({
27+
path: '/wp/v2/settings',
28+
method: 'POST',
29+
data: {
30+
feedzy_review_notice: 'yes',
31+
},
32+
});
33+
} catch ( error ) {
34+
console.error( __( 'Error updating setting:', 'feedzy-rss-feeds' ), error );
35+
} finally {
36+
setOpen( false );
37+
}
38+
};
39+
40+
if ( ! isOpen ) {
41+
return null;
42+
}
43+
44+
return (
45+
<Modal
46+
title={ __( 'Congrats, You\'ve Reached an Impressive Milestone! 🎉', 'feedzy-rss-feeds' ) }
47+
size="medium"
48+
shouldCloseOnClickOutside={ false }
49+
onRequestClose={ closeModal }
50+
>
51+
<p>{ __( 'You\'ve successfully imported', 'feedzy-rss-feeds' ) }<strong>{ __( ' more than 100 posts', 'feedzy-rss-feeds' ) }</strong>{ __( ' using Feedzy!', 'feedzy-rss-feeds' ) }</p>
52+
<p>{ __( 'If you\'re enjoying Feedzy, we\'d be thrilled if you could leave us a', 'feedzy-rss-feeds' ) } <strong>{ __( '5-star review', 'feedzy-rss-feeds' ) }</strong> (<span style={{ color: 'gold' }}>★★★★★</span>) { __( 'on WordPress.org. Your support helps us grow and deliver even better features.', 'feedzy-rss-feeds' ) }</p>
53+
54+
<div className="buttons-wrap" style={{ display: 'flex', gap: '10px', marginTop: '20px' }}>
55+
<Button
56+
href="https://wordpress.org/support/plugin/feedzy-rss-feeds/reviews/#new-post"
57+
target="_blank"
58+
variant="primary"
59+
className="fz-feedback-button"
60+
style={{ borderRadius: '5px' }}
61+
>
62+
{ __( 'Rate Feedzy on WordPress.org', 'feedzy-rss-feeds' ) }
63+
</Button>
64+
</div>
65+
</Modal>
66+
);
67+
};
68+
69+
domReady( () => {
70+
const modalContainer = document.createElement( 'div' );
71+
modalContainer.id = 'fz-review-modal';
72+
document.body.appendChild( modalContainer );
73+
const root = createRoot( document.getElementById( 'fz-review-modal' ) );
74+
root.render( <App /> );
75+
});

0 commit comments

Comments
 (0)