-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathfeedzy-rss-feeds-admin.php
More file actions
3226 lines (2952 loc) · 109 KB
/
feedzy-rss-feeds-admin.php
File metadata and controls
3226 lines (2952 loc) · 109 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* The admin-specific functionality of the plugin.
*
* @link https://themeisle.com
* @since 3.0.0
*
* @package feedzy-rss-feeds
* @subpackage feedzy-rss-feeds/includes/admin
*/
/**
* The admin-specific functionality of the plugin.
*
* Defines the plugin name, version, and two examples hooks for how to
* enqueue the admin-specific stylesheet and JavaScript.
*
* @package feedzy-rss-feeds
* @subpackage feedzy-rss-feeds/includes/admin
* @author Themeisle <friends@themeisle.com>
*/
/**
* Class Feedzy_Rss_Feeds_Admin
*/
class Feedzy_Rss_Feeds_Admin extends Feedzy_Rss_Feeds_Admin_Abstract {
/**
* Any notice we want to show in the settings screen.
*
* @access public
* @var string $notice The notice.
*/
public $notice;
/**
* Any error we want to show in the settings screen.
*
* @access public
* @var string $error The error.
*/
public $error;
/**
* The version of this plugin.
*
* @since 3.0.0
* @access protected
* @var string $version The current version of this plugin.
*/
protected $version;
/**
* Initialize the class and set its properties.
*
* @since 3.0.0
* @access public
*
* @param string $plugin_name The name of this plugin.
* @param string $version The version of this plugin.
*/
public function __construct( $plugin_name, $version ) {
$this->plugin_name = $plugin_name;
$this->version = $version;
if ( ! defined( 'E2E_TESTING' ) ) {
add_filter(
'themeisle-sdk/survey/' . $this->plugin_name,
function ( $data, $page_slug ) {
// Show survey only on `Help us improve` tab on Support page.
if ( false !== strpos( $page_slug, 'support' ) && 'support-improve' !== $page_slug ) {
return $data;
}
return $this->get_survey_data();
},
10,
2
);
}
add_filter( 'themeisle_sdk_blackfriday_data', array( $this, 'add_black_friday_data' ) );
/**
* Load SDK dependencies.
*/
add_action(
'themeisle_internal_page',
function ( $product_name, $page_slug ) {
if ( $product_name !== $this->plugin_name ) {
return;
}
if ( in_array( $page_slug, array( 'imports', 'categories' ), true ) ) {
$this->add_banner_anchor();
}
if (
in_array( $page_slug, array( 'imports', 'new-category', 'settings' ), true )
&& 'yes' === get_option( 'feedzy_rss_feeds_logger_flag', false )
) {
$this->enable_telemetry();
}
},
10,
2
);
}
/**
* Register the stylesheets for the admin area.
*
* @since 3.0.0
* @access public
*/
public function enqueue_styles() {
/**
* This function is provided for demonstration purposes only.
*
* An instance of this class should be passed to the run() function
* defined in Feedzy_Rss_Feeds_Loader as all of the hooks are defined
* in that particular class.
*
* The Feedzy_Rss_Feeds_Loader will then create the relationship
* between the defined hooks and the functions defined in this
* class.
*/
if ( is_admin() ) {
return;
}
wp_register_style( $this->plugin_name, FEEDZY_ABSURL . 'css/feedzy-rss-feeds.css', array(), $this->version, 'all' );
}
/**
* Helper function to enqueue the license script with localization
*
* @access public
* @return void
*/
private function enqueue_license_script() {
wp_enqueue_script(
$this->plugin_name . '_license',
FEEDZY_ABSURL . 'js/feedzy-license.js',
array( 'jquery' ),
$this->version,
true
);
wp_localize_script(
$this->plugin_name . '_license',
'feedzyLicense',
array(
'l10n' => array(
'licenseKey' => __( 'License Key', 'feedzy-rss-feeds' ),
'checkBtn' => __( 'Check License', 'feedzy-rss-feeds' ),
'errorMsg' => __( 'An error occurred while checking the license. Please try again.', 'feedzy-rss-feeds' ),
),
)
);
}
/**
* Register the stylesheets for the admin area.
*
* @since 3.3.6
* @access public
*/
public function enqueue_styles_admin() {
/**
* This function is provided for demonstration purposes only.
*
* An instance of this class should be passed to the run() function
* defined in Feedzy_Rss_Feeds_Loader as all of the hooks are defined
* in that particular class.
*
* The Feedzy_Rss_Feeds_Loader will then create the relationship
* between the defined hooks and the functions defined in this
* class.
*/
if ( ! is_admin() ) {
return;
}
$screen = get_current_screen();
if ( empty( $screen ) ) {
return;
}
if ( ! isset( $screen->base ) ) {
return;
}
if ( 'feedzy_imports' === $screen->post_type && 'edit' === $screen->base ) {
$this->do_internal_page( 'imports' );
}
if ( 'feedzy_categories' === $screen->post_type ) {
wp_enqueue_script(
$this->plugin_name . '_categories',
FEEDZY_ABSURL . 'js/categories.js',
array(
'jquery',
),
$this->version,
true
);
wp_localize_script(
$this->plugin_name . '_categories',
'feedzy',
array(
'ajax' => array(
'security' => wp_create_nonce( FEEDZY_NAME ),
),
'l10n' => array(
'validate' => __( 'Validate & Clean', 'feedzy-rss-feeds' ),
'validating' => __( 'Validating', 'feedzy-rss-feeds' ) . '...',
'validated' => __( 'Removed # URL(s)!', 'feedzy-rss-feeds' ),
),
)
);
}
if ( 'feedzy_page_feedzy-settings' === $screen->base || 'feedzy_page_feedzy-integration' === $screen->base ) {
if ( ! did_action( 'wp_enqueue_media' ) && 'feedzy_page_feedzy-settings' === $screen->base ) {
wp_enqueue_media();
}
wp_enqueue_script( $this->plugin_name . '_setting', FEEDZY_ABSURL . 'js/feedzy-setting.js', array( 'jquery' ), $this->version, true );
wp_localize_script(
$this->plugin_name . '_setting',
'feedzy_setting',
array(
'l10n' => array(
'media_iframe_title' => __( 'Select image', 'feedzy-rss-feeds' ),
'media_iframe_button' => __( 'Set default image', 'feedzy-rss-feeds' ),
'action_btn_text_1' => __( 'Choose image', 'feedzy-rss-feeds' ),
'action_btn_text_2' => __( 'Replace image', 'feedzy-rss-feeds' ),
'delete_btn_label' => __( 'Delete', 'feedzy-rss-feeds' ),
),
)
);
$this->enqueue_license_script();
}
$upsell_screens = array( 'feedzy-rss_page_feedzy-settings', 'feedzy-rss_page_feedzy-admin-menu-pro-upsell' );
if ( 'feedzy_imports' === $screen->post_type && 'edit' !== $screen->base ) {
$asset_file = include FEEDZY_ABSPATH . '/build/action-popup/index.asset.php';
wp_enqueue_script( $this->plugin_name . '_action_popup', FEEDZY_ABSURL . 'build/action-popup/index.js', array_merge( $asset_file['dependencies'], array( 'wp-editor', 'wp-api' ) ), $asset_file['version'], true );
$openai_model = '';
$open_router_model = '';
$integration_settings = get_option( 'feedzy-rss-feeds-settings', array() );
$all_open_ai_models = apply_filters( 'feedzy_openai_models', array() );
$deprecated_open_ai_models = apply_filters( 'feedzy_openai_deprecated_models', array() );
$active_open_ai_models = array_values( array_diff( $all_open_ai_models, $deprecated_open_ai_models ) );
if ( ! empty( $integration_settings['openai_api_model'] ) ) {
$openai_model = $integration_settings['openai_api_model'];
}
if ( ! empty( $integration_settings['openrouter_api_model'] ) ) {
$open_router_model = $integration_settings['openrouter_api_model'];
}
wp_localize_script(
$this->plugin_name . '_action_popup',
'feedzyData',
array(
'isPro' => feedzy_is_pro(),
'isBusinessPlan' => apply_filters( 'feedzy_is_license_of_type', false, 'business' ),
'isAgencyPlan' => apply_filters( 'feedzy_is_license_of_type', false, 'agency' ),
'apiLicenseStatus' => $this->api_license_status(),
'isHighPrivileges' => current_user_can( 'manage_options' ),
'languageList' => $this->get_lang_list(),
'integrationSettings' => get_option( 'feedzy-rss-feeds-settings' ),
'integrations' => array(
'openAIModel' => $openai_model,
'openRouterModel' => $open_router_model,
),
'activeOpenAIModels' => $active_open_ai_models,
'deprecatedOpenAIModels' => $deprecated_open_ai_models,
)
);
wp_set_script_translations( $this->plugin_name . '_action_popup', 'feedzy-rss-feeds' );
$asset_file = include FEEDZY_ABSPATH . '/build/conditions/index.asset.php';
wp_enqueue_script( $this->plugin_name . '_conditions', FEEDZY_ABSURL . 'build/conditions/index.js', array_merge( $asset_file['dependencies'], array( 'wp-editor', 'wp-api' ) ), $asset_file['version'], true );
// Add wp_localize_script to pass variables to the JS file with a filter over the data.
wp_localize_script(
$this->plugin_name . '_conditions',
'feedzyConditionsData',
apply_filters(
'feedzy_conditions_data',
array(
'isPro' => feedzy_is_pro(),
'isBusinessPlan' => apply_filters( 'feedzy_is_license_of_type', false, 'business' ),
'isAgencyPlan' => apply_filters( 'feedzy_is_license_of_type', false, 'agency' ),
'apiLicenseStatus' => $this->api_license_status(),
'isHighPrivileges' => current_user_can( 'manage_options' ),
'operators' => Feedzy_Rss_Feeds_Conditions::get_operators(),
)
)
);
wp_enqueue_style( 'wp-block-editor' );
wp_set_script_translations( $this->plugin_name . '_conditions', 'feedzy-rss-feeds' );
$this->enable_telemetry();
}
if ( ! defined( 'TI_CYPRESS_TESTING' ) && ( 'edit' !== $screen->base && 'feedzy_imports' === $screen->post_type && feedzy_show_import_tour() ) ) {
$asset_file = include FEEDZY_ABSPATH . '/build/onboarding/index.asset.php';
wp_enqueue_script( $this->plugin_name . '_on_boarding', FEEDZY_ABSURL . 'build/onboarding/index.js', array_merge( $asset_file['dependencies'], array( 'wp-editor', 'wp-api' ) ), $asset_file['version'], true );
wp_set_script_translations( $this->plugin_name . '_on_boarding', 'feedzy-rss-feeds' );
$this->enable_telemetry();
}
if ( 'feedzy_page_feedzy-settings' === $screen->base ) {
$this->do_internal_page( 'settings' );
}
if ( 'feedzy_page_feedzy-integration' === $screen->base ) {
$this->do_internal_page( 'integrations' );
}
if ( 'feedzy_categories' === $screen->post_type ) {
$this->do_internal_page( 'add' === $screen->action ? 'new-category' : 'categories' );
}
if ( ! in_array( $screen->base, $upsell_screens, true ) && false === strpos( $screen->id, 'feedzy' ) ) {
return;
}
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : '';
if ( 'feedzy_page_feedzy-support' === $screen->base &&
(
( 'improve' === $tab )
|| ( 'edit' !== $screen->base && 'feedzy_imports' === $screen->post_type )
|| ( 'license' === $tab )
)
) {
$asset_file = include FEEDZY_ABSPATH . '/build/feedback/index.asset.php';
wp_enqueue_script( $this->plugin_name . '_feedback', FEEDZY_ABSURL . 'build/feedback/index.js', array_merge( $asset_file['dependencies'], array( 'wp-editor', 'wp-api', 'lodash' ) ), $asset_file['version'], true );
wp_enqueue_style( 'wp-block-editor' );
wp_localize_script(
$this->plugin_name . '_feedback',
'feedzyObj',
array(
'assetsUrl' => FEEDZY_ABSURL,
'pluginVersion' => $this->version,
)
);
$this->enqueue_license_script();
wp_set_script_translations( $this->plugin_name . '_feedback', 'feedzy-rss-feeds' );
}
if ( 'feedzy_page_feedzy-support' === $screen->base ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : '';
$suffix = ! empty( $tab ) ? '-' . $tab : '';
$this->do_internal_page( 'support' . $suffix );
}
if ( ( 'edit' !== $screen->base && 'feedzy_imports' === $screen->post_type ) ) {
$this->do_internal_page( 'new-import' );
}
if ( 'feedzy_imports' === $screen->post_type && 'edit' === $screen->base && feedzy_show_review_notice() ) {
$asset_file = include FEEDZY_ABSPATH . '/build/review/index.asset.php';
wp_enqueue_script( $this->plugin_name . '_review', FEEDZY_ABSURL . 'build/review/index.js', $asset_file['dependencies'], $asset_file['version'], true );
wp_set_script_translations( $this->plugin_name . '_review', 'feedzy-rss-feeds' );
}
wp_enqueue_style( $this->plugin_name . '-settings', FEEDZY_ABSURL . 'css/settings.css', array(), $this->version );
wp_enqueue_style( $this->plugin_name . '-metabox', FEEDZY_ABSURL . 'css/metabox-settings.css', array( $this->plugin_name . '-settings' ), $this->version );
}
/**
* Add action links on plugin listing screen.
*
* @param array $actions Actions array.
* @param string $plugin_file Plugin file.
*
* @return mixed
*/
public function plugin_actions( $actions, $plugin_file ) {
$actions['settings'] = '<a href="' . admin_url( 'admin.php?page=feedzy-settings' ) . '">' . __( 'Settings', 'feedzy-rss-feeds' ) . '</a>';
return $actions;
}
/**
* Get number of imports.
*
* @return int
*/
public static function get_no_of_imports() {
$args = array(
'post_type' => 'feedzy_imports',
'posts_per_page' => 100,
'post_status' => array( 'any', 'trash' ),
'fields' => 'ids',
);
$query = new WP_Query( $args );
return $query->found_posts;
}
/**
* Handle legacy logic.
*
* @return void
*/
public function handle_legacy() {
// We can increment this when we reach a new legacy milestone.
$current_legacy_version = (int) get_option( 'feedzy_legacyv5', 0 );
if ( 0 === $current_legacy_version ) {
$current_legacy_version = self::get_no_of_imports() > 0 ? 1 : -1;
update_option( 'feedzy_legacyv5', $current_legacy_version );
}
if ( function_exists( 'get_current_screen' ) && 'feedzy_imports' === get_current_screen()->post_type && 'add' === get_current_screen()->action && ! feedzy_is_pro() && -1 === $current_legacy_version && self::get_no_of_imports() >= 1 ) {
wp_safe_redirect( 'edit.php?post_type=feedzy_imports' );
exit;
}
if ( -1 === $current_legacy_version && ! feedzy_is_pro() && self::get_no_of_imports() >= 1 ) {
add_action(
'admin_head',
function () {
?>
<script type="text/javascript">
jQuery(function () {
jQuery('a[href*="post-new.php?post_type=feedzy_imports"]').addClass('feedzy-import-limit').prepend('<span class="dashicons dashicons-lock"></span> ');
});
</script>
<?php
}
);
}
}
/**
* Add modals for the plugin.
*/
public function add_modals() {
?>
<script type="text/javascript">
jQuery(function () {
jQuery('a.feedzy-clone-disabled').on('click', function (event) {
openModal('#feedzy-clone-modal');
event.preventDefault();
});
jQuery('a.feedzy-edit-disabled').on('click', function (event) {
openModal('#feedzy-renew-edit');
event.preventDefault();
});
jQuery('a.feedzy-import-limit').on('click', function (event) {
openModal('#feedzy-add-new-import');
event.preventDefault();
});
// Function to open the modal
function openModal(modal) {
jQuery(modal).show();
}
// Function to close the modal
function closeModal(e) {
jQuery('.feedzy-modal')
.hide();
}
// Close modal when close button or overlay is clicked
jQuery('.close-modal').on('click', function () {
closeModal();
});
// Close modal when Esc key is pressed
jQuery(document).on('keyup', function (e) {
if (e.key === "Escape") closeModal();
});
});
</script>
<div id="feedzy-add-new-import" class="wp-core-ui feedzy-modal" style="display:none;">
<div class="modal-content">
<button type="button" class="fz-notice close-modal">
<span class="dashicons dashicons-no-alt"></span>
<span class="screen-reader-text">
<?php esc_html_e( 'Dismiss this dialog', 'feedzy-rss-feeds' ); ?>
</span>
</button>
<div class="modal-header">
<h2>
<?php esc_html_e( 'Upgrade to Use Unlimited Imports', 'feedzy-rss-feeds' ); ?>
</h2>
<p style="color: red;">
<?php esc_html_e( 'Import limit reached', 'feedzy-rss-feeds' ); ?>
<span>
<?php
// translators: %1$s is the number of imports used, %2$s is the total number of imports allowed.
echo esc_html( '(' . sprintf( __( '%1$s/%2$s used', 'feedzy-rss-feeds' ), '1', '1' ) . ')' );
?>
</span>
</p>
</div>
<div class="modal-body">
<p>
<?php esc_html_e( 'Your current plan supports only one import setup. Upgrade to unlock unlimited import configurations and make the most of Feedzy\'s powerful features!', 'feedzy-rss-feeds' ); ?>
</p>
</div>
<div class="modal-footer">
<div class="button-container">
<a
href="<?php echo esc_url( tsdk_utmify( tsdk_translate_link( FEEDZY_UPSELL_LINK ), 'add-new-import' ) ); ?>"
target="_blank" rel="noopener "
class="button button-primary button-large"
>
<?php esc_html_e( 'Upgrade to PRO', 'feedzy-rss-feeds' ); ?>
</a>
</div>
<span>
<?php
esc_html_e( '30-day money-back guarantee. No questions asked.', 'feedzy-rss-feeds' );
?>
</span>
</div>
</div>
</div>
<?php
$license_key = apply_filters( 'product_feedzy_license_key', '' );
$renew_license_url = tsdk_utmify( tsdk_translate_link( FEEDZY_UPSELL_LINK ), 'renew' );
if ( ! empty( $license_key ) ) {
$renew_license_url = tsdk_utmify( 'https://store.themeisle.com/?edd_license_key=' . $license_key . '&download_id=6306666', 'feedzy_renew_link' );
}
?>
<div id="feedzy-renew-edit" class="wp-core-ui feedzy-modal" style="display:none;">
<div class="modal-content">
<button type="button" class="fz-notice close-modal">
<span class="dashicons dashicons-no-alt"></span>
<span class="screen-reader-text"><?php esc_html_e( 'Dismiss this dialog', 'feedzy-rss-feeds' ); ?></span>
</button>
<div class="modal-header">
<h2>
<?php esc_html_e( 'Alert!', 'feedzy-rss-feeds' ); ?>
</h2>
</div>
<div class="modal-body">
<p>
<?php esc_html_e( 'In order to edit premium import setups, benefit from updates and support for Feedzy Premium plugin, please renew your license code or activate it.', 'feedzy-rss-feeds' ); ?>
</p>
</div>
<div class="modal-footer">
<div class="button-container">
<a
href="<?php echo esc_url( $renew_license_url ); ?>"
target="_blank"
rel="noopener "
class="button button-primary button-large"
>
<?php esc_html_e( 'Renew License', 'feedzy-rss-feeds' ); ?><span aria-hidden="true" class="dashicons dashicons-external"></span>
</a>
<a
href="<?php echo esc_url( admin_url( 'options-general.php#feedzy_rss_feeds_pro_license' ) ); ?>"
target="_blank"
rel="noopener "
class="button button-secondary button-large"
>
<?php esc_html_e( 'Activate License', 'feedzy-rss-feeds' ); ?>
</a>
</div>
</div>
</div>
</div>
<div id="feedzy-clone-modal" class="wp-core-ui feedzy-modal" style="display:none;">
<div class="modal-content">
<button type="button" class="fz-notice close-modal">
<span class="dashicons dashicons-no-alt"></span>
<span class="screen-reader-text"><?php esc_html_e( 'Dismiss this dialog', 'feedzy-rss-feeds' ); ?></span>
</button>
<div class="modal-header">
<h2>
<?php esc_html_e( 'Unlock Cloning with Feedzy PRO', 'feedzy-rss-feeds' ); ?>
</h2>
<p>
<?php esc_html_e( 'Duplicate your imports with one click', 'feedzy-rss-feeds' ); ?>
</p>
</div>
<div class="modal-body">
<p>
<?php esc_html_e( 'Cloning import setups are not available on your plan. Upgrade to the Pro plan to unlock this feature and streamline your import setup process.', 'feedzy-rss-feeds' ); ?>
</p>
</div>
<div class="modal-footer">
<div class="button-container">
<a
href="<?php echo esc_url( tsdk_utmify( tsdk_translate_link( FEEDZY_UPSELL_LINK ), 'clone' ) ); ?>"
target="_blank" rel="noopener "
class="button button-primary button-large"
>
<?php esc_html_e( 'Upgrade to PRO', 'feedzy-rss-feeds' ); ?>
</a>
</div>
<span>
<?php
esc_html_e( '30-day money-back guarantee. No questions asked.', 'feedzy-rss-feeds' );
?>
</span>
</div>
</div>
</div>
<div id="fz_import_export_upsell" class="wp-core-ui feedzy-modal" style="display:none;">
<div class="modal-content">
<span class="fz-notice close-modal">
<span class="dashicons dashicons-no-alt"></span>
<span class="screen-reader-text">
<?php esc_html_e( 'Dismiss this dialog', 'feedzy-rss-feeds' ); ?>
</span>
</span>
<div class="modal-header">
<h2>
<?php esc_html_e( 'Unlock Upload & Export with Feedzy PRO', 'feedzy-rss-feeds' ); ?>
</h2>
<p>
<?php esc_html_e( 'Save time by reusing your import setups', 'feedzy-rss-feeds' ); ?>
</p>
</div>
<div class="modal-body">
<p>
<?php esc_html_e( 'Upload/export of import configuration is not available on your plan. Please upgrade to the Pro plan to unlock all these features.', 'feedzy-rss-feeds' ); ?>
</p>
</div>
<div class="modal-footer">
<div class="button-container">
<a
href="<?php echo esc_url( tsdk_translate_link( tsdk_utmify( FEEDZY_UPSELL_LINK, 'importExport' ) ) ); ?>"
target="_blank" rel="noopener "
class="button button-primary button-large"
>
<?php esc_html_e( 'Upgrade to PRO', 'feedzy-rss-feeds' ); ?>
</a>
</div>
<span>
<?php
esc_html_e( '30-day money-back guarantee. No questions asked.', 'feedzy-rss-feeds' );
?>
</span>
</div>
</div>
</div>
<style>
.feedzy-import-limit, .page-title-action.only-pro{
opacity:0.7;
}
.feedzy-quick-link{
opacity:0.7;
}
.feedzy-quick-link .dashicons{
font-size: 13px;
width: 13px;
height: 15px;
vertical-align: middle;
}
.feedzy-modal {
position: fixed;
z-index: 100000;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow-x: hidden;
overflow-y: auto;
background: rgba(0, 0, 0, 0.7);
}
.feedzy-modal .modal-content {
position: relative;
background: #fff;
padding: 0;
border-radius: 8px;
max-width: 500px;
width: auto;
margin: 6.75rem auto;
}
.feedzy-modal .modal-body {
padding: 0 25px;
padding-top: 25px;
}
.feedzy-modal .modal-body p {
margin: 0;
font-size: 16px;
line-height: 1.2;
}
.feedzy-modal .modal-header {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 0.5rem;
position: relative;
background-color: rgb(248, 250, 252);
padding: 20px 25px;
border-radius: 8px;
}
.feedzy-modal .modal-header .dashicons {
font-size: 1.3em;
line-height: inherit;
}
.feedzy-modal .modal-header :is(h2,p) {
margin: 0;
font-weight: 500;
}
:is( .feedzy-modal, #poststuff ) .modal-header h2 {
font-size: 20px;
margin: 0;
padding: 0;
}
.feedzy-modal .close-modal {
position: absolute;
top: 0;
right: 0;
z-index: 10;
background: transparent;
border: none;
cursor: pointer;
padding: 10px;
}
.feedzy-modal .modal-footer .dashicons {
vertical-align: middle;
font-size: initial;
}
.feedzy-modal .modal-footer {
padding: 25px;
text-align: center;
flex-direction: column;
display: flex;
gap: 1rem;
}
.feedzy-modal .modal-footer a {
display: flex;
align-items: center;
justify-content: center;
background-color: rgb(89, 127, 230);
padding: 10px;
border-radius: 6px;
font-size: medium;
}
#toplevel_page_feedzy-admin-menu span.tsdk-upg-menu-item{
color:#fff;
}
#toplevel_page_feedzy-admin-menu a:has(span.tsdk-upg-menu-item){
background-color:#00A32A!important;
margin-bottom:-7px;
color:#fff!important;
}
</style>
<?php
}
/**
* Register the JavaScript for the admin area.
*
* @since 3.0.0
* @access public
*/
public function enqueue_scripts() {
/**
* This function is provided for demonstration purposes only.
*
* An instance of this class should be passed to the run() function
* defined in Feedzy_Rss_Feeds_Loader as all of the hooks are defined
* in that particular class.
*
* The Feedzy_Rss_Feeds_Loader will then create the relationship
* between the defined hooks and the functions defined in this
* class.
*/
}
/**
* Method to register custom post type for
* Feedzy RSS Feeds Categories.
*
* @since 3.0.12
* @access public
*/
public function register_post_type() {
$labels = array(
'name' => __( 'Feed Groups', 'feedzy-rss-feeds' ),
'singular_name' => __( 'Feed Group', 'feedzy-rss-feeds' ),
'add_new' => __( 'Add Group', 'feedzy-rss-feeds' ),
'add_new_item' => __( 'Add Group', 'feedzy-rss-feeds' ),
'edit_item' => __( 'Edit Group', 'feedzy-rss-feeds' ),
'new_item' => __( 'New Feed Group', 'feedzy-rss-feeds' ),
'view_item' => __( 'View Group', 'feedzy-rss-feeds' ),
'search_items' => __( 'Search Group', 'feedzy-rss-feeds' ),
'not_found' => __( 'No groups found', 'feedzy-rss-feeds' ),
'not_found_in_trash' => __( 'No groups in the trash', 'feedzy-rss-feeds' ),
);
$supports = array(
'title',
);
$args = array(
'labels' => $labels,
'supports' => $supports,
'public' => true,
'exclude_from_search' => true,
'publicly_queryable' => false,
'show_in_nav_menus' => false,
'capability_type' => 'post',
'rewrite' => array( 'slug' => 'feedzy-category' ),
'show_in_menu' => 'feedzy-admin-menu',
'register_meta_box_cb' => array( $this, 'add_feedzy_post_type_metaboxes' ),
'show_in_rest' => true,
'rest_base' => 'feedzy_categories',
'rest_controller_class' => 'WP_REST_Posts_Controller',
'map_meta_cap' => true,
'capabilities' => array(
'edit_post' => 'edit_feedzy_category',
'read_post' => 'read_feedzy_category',
'delete_post' => 'delete_feedzy_category',
'edit_posts' => 'edit_feedzy_categories',
'edit_others_posts' => 'edit_others_feedzy_categories',
'publish_posts' => 'publish_feedzy_categories',
'read_private_posts' => 'read_private_feedzy_categories',
),
);
$args = apply_filters( 'feedzy_post_type_args', $args );
register_post_type( 'feedzy_categories', $args );
}
/**
* Only allow admin to modify or delete categories.
*
* @return void
*/
public function register_admin_capabilities() {
$admin_role = get_role( 'administrator' );
$admin_role->add_cap( 'edit_feedzy_category' );
$admin_role->add_cap( 'read_feedzy_category' );
$admin_role->add_cap( 'delete_feedzy_category' );
$admin_role->add_cap( 'edit_feedzy_categories' );
$admin_role->add_cap( 'edit_others_feedzy_categories' );
$admin_role->add_cap( 'publish_feedzy_categories' );
$admin_role->add_cap( 'read_private_feedzy_categories' );
}
/**
* Method to add a meta box to `feedzy_categories`
* custom post type.
*
* @since 3.0.12
* @access public
*/
public function add_feedzy_post_type_metaboxes() {
add_meta_box(
'feedzy_category_feeds',
__( 'Group Feeds', 'feedzy-rss-feeds' ),
array(
$this,
'feedzy_category_feed',
),
'feedzy_categories',
'normal',
'high'
);
if ( ! feedzy_is_pro() ) {
add_meta_box(
'feedzy_category_feeds_rn',
__( 'Extend Feedzy', 'feedzy-rss-feeds' ),
array(
$this,
'render_upsell_rn',
),
'feedzy_categories',
'side',
'low'
);
}
if ( 'publish' === get_post_status() ) {
add_meta_box(
'feedzy_category_feeds_preview',
__( 'Feed Preview', 'feedzy-rss-feeds' ),
array(
$this,
'render_feed_preview',
),
'feedzy_categories',
'side'
);
}
}
/**
* Render RN upsell metabox.
*/
public function render_upsell_rn() {
echo '<strong>' . esc_html__( 'Get access to more features.', 'feedzy-rss-feeds' ) . '</strong>';
echo '<ul>
<li>- ' . esc_html__( 'Auto add referral parameters to links', 'feedzy-rss-feeds' ) . '</li>
<li>- ' . esc_html__( 'Full Text Import', 'feedzy-rss-feeds' ) . '</li>
<li>- ' . esc_html__( 'Paraphrase content', 'feedzy-rss-feeds' ) . '</li>
<li>- ' . esc_html__( 'Translate content', 'feedzy-rss-feeds' ) . '</li>
<li>- ' . esc_html__( 'Elementor Templates support', 'feedzy-rss-feeds' ) . '</li>
</ul>';
echo '<a class="button button-primary " href="' . esc_url( tsdk_translate_link( tsdk_utmify( FEEDZY_UPSELL_LINK, 'metabox', 'new-category' ) ) ) . '" target="_blank">' . esc_html__( 'View more details', 'feedzy-rss-feeds' ) . '</a>';
}
/**
* Meta box callback function to display a textarea
* inside the custom post edit page.
*
* @since 3.0.12
* @access public
* @return mixed
*/
public function feedzy_category_feed() {
global $post;
$nonce = wp_create_nonce( FEEDZY_BASEFILE );
$feed = get_post_meta( $post->ID, 'feedzy_category_feed', true );
$invalid = $this->get_source_validity_error( '', $post );
$output = '
<input type="hidden" name="feedzy_category_meta_noncename" id="feedzy_category_meta_noncename" value="' . $nonce . '" />
<strong>' .
sprintf(
// translators: %1$s and %2$s are placeholders for HTML anchor tags.
__( 'Please be aware that multiple feeds, when mashed together, may sometimes not work as expected as explained %1$s here %2$s.', 'feedzy-rss-feeds' ),
'<a href="' . esc_url( 'https://simplepie.org/wiki/faq/typical_multifeed_gotchas' ) . '" target="_blank">',
'</a>'
)
. '</strong><br/><br/>'
. $invalid
. '<textarea name="feedzy_category_feed" rows="10" class="widefat" placeholder="themeisle.com/blog/feed/, https://wptavern.com/feed/, https://www.wpbeginner.com/feed/, https://wpshout.com/feed/, https://planet.wordpress.org/feed/" >' . $feed . '</textarea>
<div class="validate-feeds-actions">
<span class="spinner"></span>
<button class="button validate-feeds" ' . esc_attr( empty( $feed ) ? 'disabled' : '' ) . '>' . __( 'Validate & Remove Invalid Feeds', 'feedzy-rss-feeds' ) . '</button>
</div>
';
echo wp_kses( $output, apply_filters( 'feedzy_wp_kses_allowed_html', array() ) );
}
/**
* Render the feed preview metabox.
*
* @return void
*/
public function render_feed_preview() {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( isset( $_GET['action'] ) && 'edit' !== $_GET['action'] ) {
return;
}
$feeds = get_post_meta( get_the_ID(), 'feedzy_category_feed', true );
$feed_urls = $this->normalize_urls( $feeds );
if ( empty( $feed_urls ) ) {
echo '<p>' . esc_html__( 'No feeds available for preview.', 'feedzy-rss-feeds' ) . '</p>';
return;
}
$shortcode = array(
'sort' => 'date_desc',
'thumb' => 'no',
'max' => 0,
);
$atts = $this->get_short_code_attributes( $shortcode );
$atts = $this->sanitize_attr( $atts, $feed_urls );
$sizes = array(
'width' => 0,
'height' => 0,
);
$feed = $this->fetch_feed( $feed_urls, $atts['refresh'], $atts );
$feed_items = apply_filters( 'feedzy_get_feed_array', array(), $atts, $feed, $feed_urls, $sizes );
$total_items = count( $feed_items );
$max_items_preview_count = 5;
$preview_feed_items = array_slice( $feed_items, 0, $max_items_preview_count );