@@ -165,6 +165,12 @@ public function enqueue_styles() {
165
165
'clearLogButton ' => __ ( 'Clear Log ' , 'feedzy-rss-feeds ' ),
166
166
'okButton ' => __ ( 'Ok ' , 'feedzy-rss-feeds ' ),
167
167
'removeErrorLogsMsg ' => __ ( 'Removed all error logs. ' , 'feedzy-rss-feeds ' ),
168
+ 'importButton ' => sprintf (
169
+ '<a href="#" id="mpg_import" class="page-title-action fz-export-import-btn%1$s"><span class="dashicons %2$s"></span>%3$s</a> ' ,
170
+ ! feedzy_is_pro () ? ' only-pro ' : '' ,
171
+ feedzy_is_pro () ? 'dashicons-upload ' : 'dashicons-lock ' ,
172
+ esc_html__ ( 'Import Job ' , 'feedzy-rss-feeds ' )
173
+ ),
168
174
),
169
175
)
170
176
);
@@ -2471,6 +2477,11 @@ public function admin_notices() {
2471
2477
if ( false === Feedzy_Rss_Feeds_Util_Scheduler::is_scheduled ( 'feedzy_cron ' ) ) {
2472
2478
echo wp_kses_post ( '<div class="notice notice-error"><p> ' . __ ( 'Unable to register cron job. Your feeds might not get updated ' , 'feedzy-rss-feeds ' ) . '</p></div> ' );
2473
2479
}
2480
+
2481
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended
2482
+ if ( ! empty ( $ _GET ['imported ' ] ) ) {
2483
+ echo wp_kses_post ( '<div class="notice notice-success is-dismissible"><p> ' . __ ( 'Successfully imported. ' , 'feedzy-rss-feeds ' ) . '</p></div> ' );
2484
+ }
2474
2485
}
2475
2486
2476
2487
/**
@@ -2838,12 +2849,12 @@ public function add_import_actions( $actions, $post ) {
2838
2849
unset( $ actions ['inline hide-if-no-js ' ] );
2839
2850
2840
2851
$ actions ['feedzy_purge ' ] = sprintf (
2841
- '<a href="#" class="feedzy-purge" data-id="%d">%2$s</a><span class="feedzy-spinner spinner"></span> ' ,
2852
+ '<a href="#" class="feedzy-purge" data-id="%d">%2$s</a> ' ,
2842
2853
$ post ->ID ,
2843
2854
esc_html ( __ ( 'Purge & Reset ' , 'feedzy-rss-feeds ' ) )
2844
2855
);
2845
- if ( feedzy_is_pro () ) {
2846
2856
2857
+ if ( feedzy_is_pro () ) {
2847
2858
$ actions ['feedzy_clone ' ] =
2848
2859
sprintf (
2849
2860
'<a href="%1$s" class="feedzy-clone" >%2$s</a> ' ,
@@ -2877,6 +2888,25 @@ public function add_import_actions( $actions, $post ) {
2877
2888
$ is_not_first = true ;
2878
2889
}
2879
2890
}
2891
+ // Export action.
2892
+ $ export_action = sprintf (
2893
+ '<a href="%s" class="%s"style="%s">%s</a> ' ,
2894
+ feedzy_is_pro () ? esc_url (
2895
+ add_query_arg (
2896
+ array (
2897
+ 'action ' => 'fz_export_job ' ,
2898
+ '_wpnonce ' => wp_create_nonce ( 'fz_export_job ' ),
2899
+ 'id ' => $ post ->ID ,
2900
+ ),
2901
+ admin_url ( 'admin.php ' )
2902
+ )
2903
+ ) : '# ' ,
2904
+ feedzy_is_pro () ? 'fz-export-btn ' : 'fz-export-btn-pro ' ,
2905
+ ! feedzy_is_pro () ? 'opacity:0.5; ' : '' ,
2906
+ ( ! feedzy_is_pro () ? '<span style="font-size: 13px;line-height: 1.5em;width: 13px;height: 13px;" class="dashicons dashicons-lock"></span> ' : '' ) . esc_html__ ( 'Export ' , 'feedzy-rss-feeds ' )
2907
+ );
2908
+
2909
+ $ actions ['export ' ] = $ export_action ;
2880
2910
} elseif ( 1 === intval ( get_post_meta ( $ post ->ID , 'feedzy ' , true ) ) ) {
2881
2911
// show an unclickable action that mentions that it is imported by us
2882
2912
// so that users are aware
@@ -3342,4 +3372,51 @@ private function clear_error_logs() {
3342
3372
)
3343
3373
);
3344
3374
}
3375
+
3376
+ /**
3377
+ * Load edit screen.
3378
+ */
3379
+ public function load_edit_screen () {
3380
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended
3381
+ if ( empty ( $ _GET ['post_type ' ] ) || 'feedzy_imports ' !== $ _GET ['post_type ' ] ) {
3382
+ return ;
3383
+ }
3384
+ add_action ( 'admin_footer ' , array ( $ this , 'add_import_export_section ' ) );
3385
+ }
3386
+
3387
+ /**
3388
+ * Add import export section.
3389
+ */
3390
+ public function add_import_export_section () {
3391
+ if ( ! feedzy_is_pro () ) :
3392
+ ?>
3393
+ <div id="fz_import_export_upsell" class="hidden" style="max-width:450px">
3394
+ <div class="modal-content">
3395
+ <span class="notice-dismiss close-modal">
3396
+ <span class="screen-reader-text"><?php esc_html_e ( 'Dismiss this dialog ' , 'feedzy-rss-feeds ' ); ?> </span>
3397
+ </span>
3398
+ <div class="modal-header">
3399
+ <h2><span class="dashicons dashicons-lock"></span> <?php esc_html_e ( 'Import/Export is a PRO feature ' , 'feedzy-rss-feeds ' ); ?> </h2>
3400
+ </div>
3401
+ <div class="modal-body">
3402
+ <p><?php esc_html_e ( 'We \'re sorry, import/export is not available on your plan. Please upgrade to the Pro plan to unlock all these features. ' , 'feedzy-rss-feeds ' ); ?> </p>
3403
+ </div>
3404
+ <div class="modal-footer">
3405
+ <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 ' ); ?> <span aria-hidden="true" class="dashicons dashicons-external"></span></a></div>
3406
+ </div>
3407
+ </div>
3408
+ </div>
3409
+ <?php endif ; ?>
3410
+ <script type="template/text" id="fz_import_field_section">
3411
+ <div class="fz-import-field hidden">
3412
+ <form method="post" enctype="multipart/form-data" action="<?php echo esc_url ( add_query_arg ( array ( 'action ' => 'fz_import_job ' ), admin_url ( 'admin.php ' ) ) ); ?> ">
3413
+ <h4> <?php esc_html_e ( 'Choose the inport job .json file to import. ' , 'feedzy-rss-feeds ' ); ?> </h4>
3414
+ <?php wp_nonce_field ( 'fz_import_job ' ); ?>
3415
+ <input type="file" accept=".json" name="fz_import" required>
3416
+ <button type="submit" class="button button-primary"><?php esc_html_e ( 'Import ' , 'feedzy-rss-feeds ' ); ?> </button>
3417
+ </form>
3418
+ </div>
3419
+ </script>
3420
+ <?php
3421
+ }
3345
3422
}
0 commit comments