Strong Testimonials - Version 3.0.0

Version Description

Download this release

Release Info

Developer giucu91
Plugin Icon 128x128 Strong Testimonials
Version 3.0.0
Comparing to
See all releases

Code changes from version 2.51.9 to 3.0.0

Files changed (51) hide show
  1. admin/about/class-strong-testimonials-welcome.php +137 -137
  2. admin/admin-notices.php +181 -181
  3. admin/admin.php +311 -311
  4. admin/challenge/modal.php +115 -0
  5. admin/class-strong-testimonials-addons.php +141 -141
  6. admin/class-strong-testimonials-admin-category-list.php +69 -69
  7. admin/class-strong-testimonials-admin-list.php +347 -347
  8. admin/class-strong-testimonials-admin-scripts.php +420 -420
  9. admin/class-strong-testimonials-defaults.php +874 -874
  10. admin/class-strong-testimonials-exporter.php +80 -80
  11. admin/class-strong-testimonials-help.php +226 -226
  12. admin/class-strong-testimonials-helper.php +2559 -2559
  13. admin/class-strong-testimonials-list-table.php +1212 -1212
  14. admin/class-strong-testimonials-lite-vs-pro-page.php +137 -138
  15. admin/class-strong-testimonials-page-shortcodes.php +417 -415
  16. admin/class-strong-testimonials-post-editor.php +401 -401
  17. admin/class-strong-testimonials-review.php +169 -169
  18. admin/class-strong-testimonials-updater.php +1387 -1387
  19. admin/class-strong-testimonials-upsell.php +892 -831
  20. admin/class-strong-testimonials-wpchill-upsells.php +499 -0
  21. admin/class-strong-views-list-table.php +276 -276
  22. admin/class-walker-strong-category-checklist.php +127 -127
  23. admin/class-walker-strong-form-category-checklist.php +127 -127
  24. admin/compat.php +116 -116
  25. admin/css/about.css +53 -53
  26. admin/css/admin-compat.css +178 -178
  27. admin/css/admin-form.css +138 -138
  28. admin/css/fields.css +317 -317
  29. admin/css/form-preview.css +135 -135
  30. admin/css/lite-vs-pro.css +174 -174
  31. admin/css/number-spinner.css +98 -98
  32. admin/css/order.css +129 -129
  33. admin/css/polylang.css +7 -7
  34. admin/css/post-editor.css +114 -114
  35. admin/css/selectize.default.css +408 -408
  36. admin/css/uninstall.css +113 -113
  37. admin/css/views.css +1031 -1031
  38. admin/css/wpml.css +31 -31
  39. admin/custom-fields-ajax.php +123 -123
  40. admin/custom-fields.php +529 -529
  41. admin/form-preview.php +51 -51
  42. admin/img/features/email.svg +21 -21
  43. admin/img/features/filter.svg +21 -21
  44. admin/img/features/infinitescroll.svg +15 -15
  45. admin/img/features/mailchimp.svg +34 -34
  46. admin/img/features/rolemanagement.svg +17 -17
  47. admin/img/logo-long.svg +91 -91
  48. admin/img/star.svg +12 -12
  49. admin/js/addon-licenses.js +163 -163
  50. admin/js/admin-compat.js +117 -117
  51. admin/js/admin-fields.js +379 -603
admin/about/class-strong-testimonials-welcome.php CHANGED
@@ -1,137 +1,137 @@
1
- <?php
2
-
3
- class Strong_Testimonials_Welcome {
4
-
5
- public function __construct() {
6
- add_action( 'admin_menu', array( $this, 'register' ) );
7
- add_action( 'admin_head', array( $this, 'hide_menu' ) );
8
- add_action( 'wpmtst_after_update_setup', array( $this, 'wpmtst_on_activation' ), 15 );
9
- }
10
-
11
- public function hide_menu() {
12
- remove_submenu_page( 'index.php', 'wpmtst-getting-started' );
13
- }
14
-
15
- /**
16
- * Add activation hook. Need to be this way so that the About page can be created and accessed
17
- *
18
- * @param $first_install
19
- * @since 2.51.9
20
- */
21
- public function wpmtst_on_activation( $first_install ) {
22
-
23
- if ( $first_install ) {
24
- add_action( 'activated_plugin', array( $this, 'redirect_on_activation' ) );
25
- }
26
- }
27
-
28
- /**
29
- * Redirect to About page when activated
30
- *
31
- * @param $plugin
32
- * @since 2.51.9
33
- */
34
- public function redirect_on_activation( $plugin ) {
35
-
36
- if ( WPMTST_PLUGIN === $plugin ) {
37
- wp_safe_redirect( admin_url( 'index.php?page=wpmtst-getting-started' ) );
38
- exit;
39
- }
40
- }
41
- public function register() {
42
-
43
- add_dashboard_page(
44
- esc_html__( 'Welcome to Strong Testimonials', 'strong-testimonials' ),
45
- esc_html__( 'Welcome to Strong Testimonials', 'strong-testimonials' ),
46
- 'manage_options',
47
- 'wpmtst-getting-started',
48
- array( $this, 'about_page' )
49
- );
50
- }
51
-
52
- /**
53
- * @since 2.51.9
54
- * Display About page
55
- */
56
- public function about_page() {
57
-
58
- // WPChill Welcome Class
59
- require_once WPMTST_DIR . 'includes/submodules/banner/class-wpchill-welcome.php';
60
- $welcome = WPChill_Welcome::get_instance();
61
- ?>
62
- <div id="wpchill-welcome">
63
-
64
- <div class="container">
65
-
66
- <div class="hero features">
67
-
68
- <div class="mascot">
69
- <img src="<?php echo esc_url( WPMTST_ADMIN_URL ); ?>/img/mascot-2.svg" alt="<?php esc_attr_e( 'Strong Testimonials Mascot', 'strong-testimonials' ); ?>">
70
- </div>
71
-
72
- <div class="block">
73
- <?php $welcome->display_heading( esc_html__( 'Thank you for installing Strong Testimonials', 'strong-testimonials' ) ); ?>
74
- <?php $welcome->display_subheading( esc_html__( 'You\'re just a few steps away from adding and displaying your first testimonial on your website with the easiest to use WordPress review and testimonial plugin on the market.', 'strong-testimonials' ) ); ?>
75
- </div>
76
-
77
- <div class="button-wrap-single">
78
- <?php $welcome->display_button( esc_html__( 'Read our step-by-step guide to get started', 'strong-testimonials' ), 'https://strongtestimonials.com/docs/add-testimonials-to-your-website/', true ); ?>
79
- </div>
80
-
81
- <?php $welcome->display_empty_space(); ?>
82
-
83
- <img src="<?php echo esc_url( WPMTST_ADMIN_URL ); ?>/img/banner.png" alt="<?php esc_attr_e( 'Watch how to', 'strong-testimonials' ); ?>" class="video-thumbnail">
84
-
85
- <?php $welcome->horizontal_delimiter(); ?>
86
-
87
- <div class="block">
88
- <?php $welcome->display_heading( esc_html__( 'Features&Add-ons', 'strong-testimonials' ) ); ?>
89
- <?php $welcome->layout_start( 2, 'feature-list clear' ); ?>
90
- <?php $welcome->display_extension( esc_html__( 'Multiple views', 'strong-testimonials' ), esc_html__( 'Take advantage of our three testimonial views - display, slider, and form, and use them to apply custom settings to multiple testimonials.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/multiple-views.png', true ); ?>
91
- <?php $welcome->display_extension( esc_html__( 'Predesigned templates', 'strong-testimonials' ), esc_html__( 'Choose a built-in template, layout, background, and font color to showcase your testimonials in a visually-appealing way.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/predesigned-templates.png', true ); ?>
92
- <?php $welcome->display_extension( esc_html__( 'Testimonial Importer', 'strong-testimonials' ), esc_html__( 'Keep all your testimonials in one single place by importing reviews from third-party websites/plugins, such as: Google, Facebook, Yelp, Zomato, Woocommerce.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/testimonial-importer.png', true ); ?>
93
- <?php $welcome->display_extension( esc_html__( 'Testimonial forms', 'strong-testimonials' ), esc_html__( 'Collect testimonials from customers via different types of forms along with their data - name, email, company name, company website, featured image, star rating.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/testimonial-forms.png', true ); ?>
94
- <?php $welcome->display_extension( esc_html__( 'User role management', 'strong-testimonials' ), esc_html__( 'As, an admin, easily decide which user roles are worthy of adding, editing, or removing testimonials.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/user-role-management.png', true ); ?>
95
- <?php $welcome->display_extension( esc_html__( 'Spam protection', 'strong-testimonials' ), esc_html__( 'Add spam control to your forms with our Captcha extension.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/spam-protection.png', true ); ?>
96
- <?php $welcome->display_extension( esc_html__( 'Email integration', 'strong-testimonials' ), esc_html__( 'Unlock more marketing and automation potential by sending users a targeted message or a coupon to thank them for leaving a good review and subscribing to a MailChimp email list', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/email-integration.png', true ); ?>
97
- <?php $welcome->display_extension( esc_html__( 'SEO-friendly markup', 'strong-testimonials' ), esc_html__( 'Include rating markup to encourage search engines to display rich snippets - whether or not you use a star rating field on your testimonials.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/seo-friendly-markup.png', true ); ?>
98
- <?php $welcome->display_extension( esc_html__( 'Pending testimonials', 'strong-testimonials' ), esc_html__( 'Manually verify and approve your incoming testimonials, or make use of the auto-approve feature to save time.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/pending-testimonials.png', true ); ?>
99
- <?php $welcome->display_extension( esc_html__( 'Testimonial assignment', 'strong-testimonials' ), esc_html__( 'Assign testimonials to certain custom post types.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/testimonial-assignment.png', true ); ?>
100
- <?php $welcome->display_extension( esc_html__( 'Testimonial category filters', 'strong-testimonials' ), esc_html__( 'Increase workflow and user experience by filtering testimonials by category, product/service, or star rating.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/testimonial-category-filters.png', true ); ?>
101
- <?php $welcome->display_extension( esc_html__( 'Properties ', 'strong-testimonials' ), esc_html__( 'Change properties of the testimonial post type: labels, permalink structure, admin options and post editor features.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/properties.png', true ); ?>
102
- <?php $welcome->layout_end(); ?>
103
- <div class="button-wrap-single clear">
104
- <div class="right">
105
- <?php $welcome->display_button( esc_html__( 'Upgrade Now', 'strong-testimonials' ), 'https://strongtestimonials.com/pricing/?utm_source=welcome_banner&utm_medium=upgradenow&utm_campaign=welcome_banner&utm_content=first_button', true, '#E76F51' ); ?>
106
- </div>
107
- </div>
108
- </div>
109
-
110
- <?php $welcome->horizontal_delimiter(); ?>
111
-
112
- <div class="block">
113
- <div class="testimonials">
114
- <div class="clear">
115
- <?php $welcome->display_heading( esc_html__( 'Happy users of Strong Testimonials', 'strong-testimonials' ) ); ?>
116
-
117
- <?php $welcome->display_testimonial( esc_html__( 'Strong Testimonials is my new, go-to resource for creating pages with multiple staff bios or testimonials. It\'s extremely easy to use, update, and customize, and that makes it an invaluable asset. Highly recommend!.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/testimonial-image-1.jpg', 'Ryan Haught', 'Digital Marketer at Heaven\'s Family' ); ?>
118
- <?php $welcome->display_testimonial( esc_html__( 'I have used various testimonials plugins. What I get here for free is just amazing. The support is great. And updates fresh. Looking at the ability to get reviews indexed by Google is more than enough reason to get an upgrade.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/testimonial-image-2.jpeg', 'Johan Horak', 'Marketing at CapeHolidays' ); ?>
119
- </div>
120
- </div><!-- testimonials -->
121
- <div class="button-wrap clear">
122
- <div class="left">
123
- <?php $welcome->display_button( esc_html__( 'Start Adding Testimonials', 'strong-testimonials' ), esc_url( admin_url( 'edit.php?post_type=wpm-testimonial' ) ), true ); ?>
124
- </div>
125
- <div class="right">
126
- <?php $welcome->display_button( esc_html__( 'Upgrade Now', 'strong-testimonials' ), 'https://strongtestimonials.com/pricing/?utm_source=welcome_banner&utm_medium=upgradenow&utm_campaign=welcome_banner&utm_content=second_button', true, '#E76F51' ); ?>
127
- </div>
128
- </div>
129
- </div>
130
- </div><!-- hero -->
131
- </div><!-- container -->
132
- </div><!-- wpchill welcome -->
133
- <?php
134
- }
135
- }
136
-
137
- new Strong_Testimonials_Welcome();
1
+ <?php
2
+
3
+ class Strong_Testimonials_Welcome {
4
+
5
+ public function __construct() {
6
+ add_action( 'admin_menu', array( $this, 'register' ) );
7
+ add_action( 'admin_head', array( $this, 'hide_menu' ) );
8
+ add_action( 'wpmtst_after_update_setup', array( $this, 'wpmtst_on_activation' ), 15 );
9
+ }
10
+
11
+ public function hide_menu() {
12
+ remove_submenu_page( 'index.php', 'wpmtst-getting-started' );
13
+ }
14
+
15
+ /**
16
+ * Add activation hook. Need to be this way so that the About page can be created and accessed
17
+ *
18
+ * @param $first_install
19
+ * @since 2.51.9
20
+ */
21
+ public function wpmtst_on_activation( $first_install ) {
22
+
23
+ if ( $first_install ) {
24
+ add_action( 'activated_plugin', array( $this, 'redirect_on_activation' ) );
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Redirect to About page when activated
30
+ *
31
+ * @param $plugin
32
+ * @since 2.51.9
33
+ */
34
+ public function redirect_on_activation( $plugin ) {
35
+
36
+ if ( WPMTST_PLUGIN === $plugin ) {
37
+ wp_safe_redirect( admin_url( 'index.php?page=wpmtst-getting-started' ) );
38
+ exit;
39
+ }
40
+ }
41
+ public function register() {
42
+
43
+ add_dashboard_page(
44
+ esc_html__( 'Welcome to Strong Testimonials', 'strong-testimonials' ),
45
+ esc_html__( 'Welcome to Strong Testimonials', 'strong-testimonials' ),
46
+ 'manage_options',
47
+ 'wpmtst-getting-started',
48
+ array( $this, 'about_page' )
49
+ );
50
+ }
51
+
52
+ /**
53
+ * @since 2.51.9
54
+ * Display About page
55
+ */
56
+ public function about_page() {
57
+
58
+ // WPChill Welcome Class
59
+ require_once WPMTST_DIR . 'includes/submodules/banner/class-wpchill-welcome.php';
60
+ $welcome = WPChill_Welcome::get_instance();
61
+ ?>
62
+ <div id="wpchill-welcome">
63
+
64
+ <div class="container">
65
+
66
+ <div class="hero features">
67
+
68
+ <div class="mascot">
69
+ <img src="<?php echo esc_url( WPMTST_ADMIN_URL ); ?>/img/mascot-2.svg" alt="<?php esc_attr_e( 'Strong Testimonials Mascot', 'strong-testimonials' ); ?>">
70
+ </div>
71
+
72
+ <div class="block">
73
+ <?php $welcome->display_heading( esc_html__( 'Thank you for installing Strong Testimonials', 'strong-testimonials' ) ); ?>
74
+ <?php $welcome->display_subheading( esc_html__( 'You\'re just a few steps away from adding and displaying your first testimonial on your website with the easiest to use WordPress review and testimonial plugin on the market.', 'strong-testimonials' ) ); ?>
75
+ </div>
76
+
77
+ <div class="button-wrap-single">
78
+ <?php $welcome->display_button( esc_html__( 'Read our step-by-step guide to get started', 'strong-testimonials' ), 'https://strongtestimonials.com/docs/add-testimonials-to-your-website/', true ); ?>
79
+ </div>
80
+
81
+ <?php $welcome->display_empty_space(); ?>
82
+
83
+ <img src="<?php echo esc_url( WPMTST_ADMIN_URL ); ?>/img/banner.png" alt="<?php esc_attr_e( 'Watch how to', 'strong-testimonials' ); ?>" class="video-thumbnail">
84
+
85
+ <?php $welcome->horizontal_delimiter(); ?>
86
+
87
+ <div class="block">
88
+ <?php $welcome->display_heading( esc_html__( 'Features&Add-ons', 'strong-testimonials' ) ); ?>
89
+ <?php $welcome->layout_start( 2, 'feature-list clear' ); ?>
90
+ <?php $welcome->display_extension( esc_html__( 'Multiple views', 'strong-testimonials' ), esc_html__( 'Take advantage of our three testimonial views - display, slider, and form, and use them to apply custom settings to multiple testimonials.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/multiple-views.png', true ); ?>
91
+ <?php $welcome->display_extension( esc_html__( 'Predesigned templates', 'strong-testimonials' ), esc_html__( 'Choose a built-in template, layout, background, and font color to showcase your testimonials in a visually-appealing way.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/predesigned-templates.png', true ); ?>
92
+ <?php $welcome->display_extension( esc_html__( 'Testimonial Importer', 'strong-testimonials' ), esc_html__( 'Keep all your testimonials in one single place by importing reviews from third-party websites/plugins, such as: Google, Facebook, Yelp, Zomato, Woocommerce.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/testimonial-importer.png', true ); ?>
93
+ <?php $welcome->display_extension( esc_html__( 'Testimonial forms', 'strong-testimonials' ), esc_html__( 'Collect testimonials from customers via different types of forms along with their data - name, email, company name, company website, featured image, star rating.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/testimonial-forms.png', true ); ?>
94
+ <?php $welcome->display_extension( esc_html__( 'User role management', 'strong-testimonials' ), esc_html__( 'As, an admin, easily decide which user roles are worthy of adding, editing, or removing testimonials.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/user-role-management.png', true ); ?>
95
+ <?php $welcome->display_extension( esc_html__( 'Spam protection', 'strong-testimonials' ), esc_html__( 'Add spam control to your forms with our Captcha extension.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/spam-protection.png', true ); ?>
96
+ <?php $welcome->display_extension( esc_html__( 'Email integration', 'strong-testimonials' ), esc_html__( 'Unlock more marketing and automation potential by sending users a targeted message or a coupon to thank them for leaving a good review and subscribing to a MailChimp email list', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/email-integration.png', true ); ?>
97
+ <?php $welcome->display_extension( esc_html__( 'SEO-friendly markup', 'strong-testimonials' ), esc_html__( 'Include rating markup to encourage search engines to display rich snippets - whether or not you use a star rating field on your testimonials.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/seo-friendly-markup.png', true ); ?>
98
+ <?php $welcome->display_extension( esc_html__( 'Pending testimonials', 'strong-testimonials' ), esc_html__( 'Manually verify and approve your incoming testimonials, or make use of the auto-approve feature to save time.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/pending-testimonials.png', true ); ?>
99
+ <?php $welcome->display_extension( esc_html__( 'Testimonial assignment', 'strong-testimonials' ), esc_html__( 'Assign testimonials to certain custom post types.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/testimonial-assignment.png', true ); ?>
100
+ <?php $welcome->display_extension( esc_html__( 'Testimonial category filters', 'strong-testimonials' ), esc_html__( 'Increase workflow and user experience by filtering testimonials by category, product/service, or star rating.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/testimonial-category-filters.png', true ); ?>
101
+ <?php $welcome->display_extension( esc_html__( 'Properties ', 'strong-testimonials' ), esc_html__( 'Change properties of the testimonial post type: labels, permalink structure, admin options and post editor features.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/features/properties.png', true ); ?>
102
+ <?php $welcome->layout_end(); ?>
103
+ <div class="button-wrap-single clear">
104
+ <div class="right">
105
+ <?php $welcome->display_button( esc_html__( 'Upgrade Now', 'strong-testimonials' ), 'https://strongtestimonials.com/pricing/?utm_source=welcome_banner&utm_medium=upgradenow&utm_campaign=welcome_banner&utm_content=first_button', true, '#E76F51' ); ?>
106
+ </div>
107
+ </div>
108
+ </div>
109
+
110
+ <?php $welcome->horizontal_delimiter(); ?>
111
+
112
+ <div class="block">
113
+ <div class="testimonials">
114
+ <div class="clear">
115
+ <?php $welcome->display_heading( esc_html__( 'Happy users of Strong Testimonials', 'strong-testimonials' ) ); ?>
116
+
117
+ <?php $welcome->display_testimonial( esc_html__( 'Strong Testimonials is my new, go-to resource for creating pages with multiple staff bios or testimonials. It\'s extremely easy to use, update, and customize, and that makes it an invaluable asset. Highly recommend!.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/testimonial-image-1.jpg', 'Ryan Haught', 'Digital Marketer at Heaven\'s Family' ); ?>
118
+ <?php $welcome->display_testimonial( esc_html__( 'I have used various testimonials plugins. What I get here for free is just amazing. The support is great. And updates fresh. Looking at the ability to get reviews indexed by Google is more than enough reason to get an upgrade.', 'strong-testimonials' ), esc_url( WPMTST_ADMIN_URL ) . '/img/testimonial-image-2.jpeg', 'Johan Horak', 'Marketing at CapeHolidays' ); ?>
119
+ </div>
120
+ </div><!-- testimonials -->
121
+ <div class="button-wrap clear">
122
+ <div class="left">
123
+ <?php $welcome->display_button( esc_html__( 'Start Adding Testimonials', 'strong-testimonials' ), esc_url( admin_url( 'edit.php?post_type=wpm-testimonial' ) ), true ); ?>
124
+ </div>
125
+ <div class="right">
126
+ <?php $welcome->display_button( esc_html__( 'Upgrade Now', 'strong-testimonials' ), 'https://strongtestimonials.com/pricing/?utm_source=welcome_banner&utm_medium=upgradenow&utm_campaign=welcome_banner&utm_content=second_button', true, '#E76F51' ); ?>
127
+ </div>
128
+ </div>
129
+ </div>
130
+ </div><!-- hero -->
131
+ </div><!-- container -->
132
+ </div><!-- wpchill welcome -->
133
+ <?php
134
+ }
135
+ }
136
+
137
+ new Strong_Testimonials_Welcome();
admin/admin-notices.php CHANGED
@@ -1,181 +1,181 @@
1
- <?php
2
- /**
3
- * Admin notices
4
- */
5
-
6
-
7
- /**
8
- * Dismiss persistent notices.
9
- *
10
- * @since 2.29.0
11
- */
12
- function wpmtst_dismiss_notice_ajax() {
13
- if ( ! isset( $_POST['key'] ) || ! $_POST['key'] ) {
14
- echo 0;
15
- wp_die();
16
- }
17
-
18
- check_ajax_referer( 'wpmtst-admin', 'nonce' );
19
- wpmtst_delete_admin_notice( $_POST['key'] );
20
- wp_die();
21
- }
22
-
23
- add_action( 'wp_ajax_wpmtst_dismiss_notice', 'wpmtst_dismiss_notice_ajax' );
24
-
25
- /**
26
- * Print admin notices.
27
- *
28
- * @since 2.24.0
29
- */
30
- function wpmtst_admin_notices() {
31
- $notices = get_option( 'wpmtst_admin_notices' );
32
- if ( ! $notices ) {
33
- return;
34
- }
35
-
36
- foreach ( $notices as $key => $notice ) {
37
- $message = apply_filters( 'wpmtst_admin_notice', '', $key );
38
- if ( $message ) {
39
- echo $message;
40
- }
41
- if ( ! $notice['persist'] ) {
42
- wpmtst_delete_admin_notice( $key );
43
- }
44
- }
45
- }
46
- add_action( 'admin_notices', 'wpmtst_admin_notices' );
47
-
48
-
49
- /**
50
- * Return specific admin notice text.
51
- *
52
- * @since 2.28.5
53
- * @param string $html
54
- * @param $key
55
- *
56
- * @return string
57
- */
58
- function wpmtst_admin_notice_text( $html, $key, $persist = false ) {
59
-
60
- switch ( $key ) {
61
- case 'defaults-restored' :
62
- ob_start();
63
- ?>
64
- <div class="wpmtst notice notice-success is-dismissible" data-key="<?php echo esc_attr( $key ); ?>">
65
- <p>
66
- <?php esc_html_e( 'Defaults restored.', 'strong-testimonials' ); ?>
67
- </p>
68
- </div>
69
- <?php
70
- $html = ob_get_clean();
71
- break;
72
-
73
- case 'fields-saved' :
74
- ob_start();
75
- ?>
76
- <div class="wpmtst notice notice-success is-dismissible" data-key="<?php echo esc_attr( $key ); ?>">
77
- <p>
78
- <?php esc_html_e( 'Fields saved.', 'strong-testimonials' ); ?>
79
- </p>
80
- </div>
81
- <?php
82
- $html = ob_get_clean();
83
- break;
84
-
85
- case 'changes-cancelled' :
86
- ob_start();
87
- ?>
88
- <div class="wpmtst notice notice-success is-dismissible" data-key="<?php echo esc_attr( $key ); ?>">
89
- <p>
90
- <?php esc_html_e( 'Changes cancelled.', 'strong-testimonials' ); ?>
91
- </p>
92
- </div>
93
- <?php
94
- $html = ob_get_clean();
95
- break;
96
-
97
- case 'captcha-options-changed' :
98
- $tags = array( 'a' => array( 'class' => array(), 'href' => array() ) );
99
- //$settings_url = admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-settings&tab=form#captcha-section' );
100
- $settings_url = admin_url( '?action=captcha-options-changed' );
101
- $settings_link = sprintf( wp_kses( __( 'Please check your <a href="%s">%s</a>.', 'strong-testimonials' ), $tags ), esc_url( $settings_url ), esc_html__( 'settings', 'strong-testimonials' ) );
102
-
103
- ob_start();
104
- ?>
105
- <div class="wpmtst notice notice-warning is-dismissible" data-key="<?php echo esc_attr( $key ); ?>">
106
- <p>
107
- <?php _e( 'Captcha options have changed in <strong>Strong Testimonials</strong>.', 'strong-testimonials' ); ?>
108
- <?php echo esc_url( $settings_link ); ?>
109
- </p>
110
- </div>
111
- <?php
112
- $html = ob_get_clean();
113
- break;
114
-
115
- default :
116
- $html = apply_filters( 'wpmtst_' . $key . '_notice', '' );
117
- // nothing
118
- }
119
-
120
- return $html;
121
- }
122
- add_filter( 'wpmtst_admin_notice', 'wpmtst_admin_notice_text', 10, 2 );
123
-
124
-
125
- /**
126
- * Add admin notice to queue.
127
- *
128
- * @since 2.24.0
129
- *
130
- * @param $key
131
- * @param $persist
132
- */
133
- function wpmtst_add_admin_notice( $key, $persist = false ) {
134
- $notices = get_option( 'wpmtst_admin_notices', array() );
135
- $notices[ $key ] = array( 'persist' => $persist );
136
- update_option( 'wpmtst_admin_notices', $notices, 'no' );
137
- }
138
-
139
-
140
- /**
141
- * Delete admin notice from queue.
142
- *
143
- * @since 2.24.0
144
- *
145
- * @param $key
146
- */
147
- function wpmtst_delete_admin_notice( $key ) {
148
- $notices = get_option( 'wpmtst_admin_notices', array() );
149
- if ( isset( $notices[ $key ] ) ) {
150
- unset( $notices[ $key ] );
151
- update_option( 'wpmtst_admin_notices', $notices, 'no' );
152
- }
153
- }
154
-
155
-
156
- /**
157
- * Automatically dismiss specific notices when settings are saved.
158
- *
159
- * @since 2.29.0
160
- * @param $option
161
- * @param $old_value
162
- * @param $value
163
- */
164
- function wpmtst_auto_dismiss_notices( $option, $old_value, $value ) {
165
- if ( ! function_exists( 'get_current_screen' ) ) {
166
- return;
167
- }
168
-
169
- $screen = get_current_screen();
170
- if ( $screen && 'options' == $screen->base ) {
171
- if ( 'wpmtst_form_options' == $option ) {
172
- $notices = get_option( 'wpmtst_admin_notices', array() );
173
- if ( isset( $notices['captcha-options-changed'] ) ) {
174
- unset( $notices['captcha-options-changed'] );
175
- update_option( 'wpmtst_admin_notices', $notices, 'no' );
176
- }
177
- }
178
- }
179
- }
180
- add_action( 'update_option', 'wpmtst_auto_dismiss_notices', 10, 3 );
181
-
1
+ <?php
2
+ /**
3
+ * Admin notices
4
+ */
5
+
6
+
7
+ /**
8
+ * Dismiss persistent notices.
9
+ *
10
+ * @since 2.29.0
11
+ */
12
+ function wpmtst_dismiss_notice_ajax() {
13
+ if ( ! isset( $_POST['key'] ) || ! $_POST['key'] ) {
14
+ echo 0;
15
+ wp_die();
16
+ }
17
+
18
+ check_ajax_referer( 'wpmtst-admin', 'nonce' );
19
+ wpmtst_delete_admin_notice( $_POST['key'] );
20
+ wp_die();
21
+ }
22
+
23
+ add_action( 'wp_ajax_wpmtst_dismiss_notice', 'wpmtst_dismiss_notice_ajax' );
24
+
25
+ /**
26
+ * Print admin notices.
27
+ *
28
+ * @since 2.24.0
29
+ */
30
+ function wpmtst_admin_notices() {
31
+ $notices = get_option( 'wpmtst_admin_notices' );
32
+ if ( ! $notices ) {
33
+ return;
34
+ }
35
+
36
+ foreach ( $notices as $key => $notice ) {
37
+ $message = apply_filters( 'wpmtst_admin_notice', '', $key );
38
+ if ( $message ) {
39
+ echo $message;
40
+ }
41
+ if ( ! $notice['persist'] ) {
42
+ wpmtst_delete_admin_notice( $key );
43
+ }
44
+ }
45
+ }
46
+ add_action( 'admin_notices', 'wpmtst_admin_notices' );
47
+
48
+
49
+ /**
50
+ * Return specific admin notice text.
51
+ *
52
+ * @since 2.28.5
53
+ * @param string $html
54
+ * @param $key
55
+ *
56
+ * @return string
57
+ */
58
+ function wpmtst_admin_notice_text( $html, $key, $persist = false ) {
59
+
60
+ switch ( $key ) {
61
+ case 'defaults-restored' :
62
+ ob_start();
63
+ ?>
64
+ <div class="wpmtst notice notice-success is-dismissible" data-key="<?php echo esc_attr( $key ); ?>">
65
+ <p>
66
+ <?php esc_html_e( 'Defaults restored.', 'strong-testimonials' ); ?>
67
+ </p>
68
+ </div>
69
+ <?php
70
+ $html = ob_get_clean();
71
+ break;
72
+
73
+ case 'fields-saved' :
74
+ ob_start();
75
+ ?>
76
+ <div class="wpmtst notice notice-success is-dismissible" data-key="<?php echo esc_attr( $key ); ?>">
77
+ <p>
78
+ <?php esc_html_e( 'Fields saved.', 'strong-testimonials' ); ?>
79
+ </p>
80
+ </div>
81
+ <?php
82
+ $html = ob_get_clean();
83
+ break;
84
+
85
+ case 'changes-cancelled' :
86
+ ob_start();
87
+ ?>
88
+ <div class="wpmtst notice notice-success is-dismissible" data-key="<?php echo esc_attr( $key ); ?>">
89
+ <p>
90
+ <?php esc_html_e( 'Changes cancelled.', 'strong-testimonials' ); ?>
91
+ </p>
92
+ </div>
93
+ <?php
94
+ $html = ob_get_clean();
95
+ break;
96
+
97
+ case 'captcha-options-changed' :
98
+ $tags = array( 'a' => array( 'class' => array(), 'href' => array() ) );
99
+ //$settings_url = admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-settings&tab=form#captcha-section' );
100
+ $settings_url = admin_url( '?action=captcha-options-changed' );
101
+ $settings_link = sprintf( wp_kses( __( 'Please check your <a href="%s">%s</a>.', 'strong-testimonials' ), $tags ), esc_url( $settings_url ), esc_html__( 'settings', 'strong-testimonials' ) );
102
+
103
+ ob_start();
104
+ ?>
105
+ <div class="wpmtst notice notice-warning is-dismissible" data-key="<?php echo esc_attr( $key ); ?>">
106
+ <p>
107
+ <?php _e( 'Captcha options have changed in <strong>Strong Testimonials</strong>.', 'strong-testimonials' ); ?>
108
+ <?php echo esc_url( $settings_link ); ?>
109
+ </p>
110
+ </div>
111
+ <?php
112
+ $html = ob_get_clean();
113
+ break;
114
+
115
+ default :
116
+ $html = apply_filters( 'wpmtst_' . $key . '_notice', '' );
117
+ // nothing
118
+ }
119
+
120
+ return $html;
121
+ }
122
+ add_filter( 'wpmtst_admin_notice', 'wpmtst_admin_notice_text', 10, 2 );
123
+
124
+
125
+ /**
126
+ * Add admin notice to queue.
127
+ *
128
+ * @since 2.24.0
129
+ *
130
+ * @param $key
131
+ * @param $persist
132
+ */
133
+ function wpmtst_add_admin_notice( $key, $persist = false ) {
134
+ $notices = get_option( 'wpmtst_admin_notices', array() );
135
+ $notices[ $key ] = array( 'persist' => $persist );
136
+ update_option( 'wpmtst_admin_notices', $notices, 'no' );
137
+ }
138
+
139
+
140
+ /**
141
+ * Delete admin notice from queue.
142
+ *
143
+ * @since 2.24.0
144
+ *
145
+ * @param $key
146
+ */
147
+ function wpmtst_delete_admin_notice( $key ) {
148
+ $notices = get_option( 'wpmtst_admin_notices', array() );
149
+ if ( isset( $notices[ $key ] ) ) {
150
+ unset( $notices[ $key ] );
151
+ update_option( 'wpmtst_admin_notices', $notices, 'no' );
152
+ }
153
+ }
154
+
155
+
156
+ /**
157
+ * Automatically dismiss specific notices when settings are saved.
158
+ *
159
+ * @since 2.29.0
160
+ * @param $option
161
+ * @param $old_value
162
+ * @param $value
163
+ */
164
+ function wpmtst_auto_dismiss_notices( $option, $old_value, $value ) {
165
+ if ( ! function_exists( 'get_current_screen' ) ) {
166
+ return;
167
+ }
168
+
169
+ $screen = get_current_screen();
170
+ if ( $screen && 'options' == $screen->base ) {
171
+ if ( 'wpmtst_form_options' == $option ) {
172
+ $notices = get_option( 'wpmtst_admin_notices', array() );
173
+ if ( isset( $notices['captcha-options-changed'] ) ) {
174
+ unset( $notices['captcha-options-changed'] );
175
+ update_option( 'wpmtst_admin_notices', $notices, 'no' );
176
+ }
177
+ }
178
+ }
179
+ }
180
+ add_action( 'update_option', 'wpmtst_auto_dismiss_notices', 10, 3 );
181
+
admin/admin.php CHANGED
@@ -1,312 +1,312 @@
1
- <?php
2
- /**
3
- * Strong Testimonials admin functions.
4
- *
5
- * 1. Check for required WordPress version.
6
- * 2. Check for plugin update.
7
- * 3. Initialize.
8
- */
9
-
10
- /**
11
- * Check for required WordPress version.
12
- */
13
- function wpmtst_version_check() {
14
- global $wp_version;
15
- $require_wp_version = "3.7";
16
-
17
- if ( version_compare( $wp_version, $require_wp_version ) == -1 ) {
18
- deactivate_plugins( WPMTST_PLUGIN );
19
- /* translators: %s is the name of the plugin. */
20
- $message = '<h2>' . sprintf( esc_html_x( 'Unable to load %s', 'installation', 'strong-testimonials' ), 'Strong Testimonials' ) . '</h2>';
21
- /* translators: %s is a WordPress version number. */
22
- $message .= '<p>' . sprintf( _x( 'This plugin requires <strong>WordPress %s</strong> or higher so it has been deactivated.', 'installation', 'strong-testimonials' ), $require_wp_version ) . '</p>';
23
- $message .= '<p>' . esc_html_x( 'Please upgrade WordPress and try again.', 'installation', 'strong-testimonials' ) . '</p>';
24
- $message .= '<p>' . sprintf( _x( 'Back to the WordPress <a href="%s">Plugins page</a>', 'installation', 'strong-testimonials' ), get_admin_url( null, 'plugins.php' ) ) . '</p>';
25
- wp_die( $message );
26
- }
27
- }
28
-
29
- add_action( 'admin_init', 'wpmtst_version_check', 1 );
30
-
31
- /**
32
- * Check for plugin update.
33
- *
34
- * @since 2.28.4 Before other admin_init actions.
35
- */
36
- function wpmtst_update_check() {
37
- $version = get_option( 'wpmtst_plugin_version', false );
38
- if ( $version == WPMTST_VERSION ) {
39
- return;
40
- }
41
-
42
- Strong_Testimonials_Updater::update();
43
- }
44
-
45
- add_action( 'admin_init', 'wpmtst_update_check', 5 );
46
-
47
- /**
48
- * Initialize.
49
- */
50
- function wpmtst_admin_init() {
51
-
52
- /**
53
- * Custom action hooks
54
- *
55
- * @since 1.18.4
56
- */
57
- if ( isset( $_REQUEST['action'] ) && '' != $_REQUEST['action'] ) {
58
- $action = sanitize_text_field( $_REQUEST['action'] );
59
- do_action( 'wpmtst_' . $action );
60
- }
61
- }
62
-
63
- add_action( 'admin_init', 'wpmtst_admin_init' );
64
-
65
- /**
66
- * Custom action link in admin notice.
67
- *
68
- * @since 2.29.0
69
- */
70
- function wpmtst_action_captcha_options_changed() {
71
- wpmtst_delete_admin_notice( 'captcha-options-changed' );
72
- wp_redirect( admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-settings&tab=form#captcha-section' ) );
73
- exit;
74
- }
75
-
76
- add_action( 'admin_action_captcha-options-changed', 'wpmtst_action_captcha_options_changed' );
77
-
78
- /**
79
- * Are we on a testimonial admin screen?
80
- *
81
- * Used by add-ons too!
82
- *
83
- * @return bool
84
- */
85
- function wpmtst_is_testimonial_screen() {
86
- $screen = get_current_screen();
87
- return ( $screen && 'wpm-testimonial' == $screen->post_type );
88
- }
89
-
90
- /**
91
- * Add pending numbers to post types on admin menu.
92
- * Thanks http://wordpress.stackexchange.com/a/105470/32076
93
- *
94
- * @param $menu
95
- *
96
- * @return mixed
97
- */
98
- function wpmtst_pending_indicator( $menu ) {
99
- if ( ! current_user_can( 'edit_posts' ) )
100
- return $menu;
101
-
102
- $options = get_option( 'wpmtst_options' );
103
- if ( ! isset( $options['pending_indicator'] ) || ! $options['pending_indicator'] )
104
- return $menu;
105
-
106
- $types = array( 'wpm-testimonial' );
107
- $status = 'pending';
108
- foreach ( $types as $type ) {
109
- $num_posts = wp_count_posts( $type, 'readable' );
110
- $pending_count = 0;
111
- if ( ! empty( $num_posts->$status ) )
112
- $pending_count = $num_posts->$status;
113
-
114
- if ( $type == 'post' )
115
- $menu_str = 'edit.php';
116
- else
117
- $menu_str = 'edit.php?post_type=' . $type;
118
-
119
- foreach ( $menu as $menu_key => $menu_data ) {
120
- if ( $menu_str != $menu_data[2] )
121
- continue;
122
- $menu[ $menu_key ][0] .= " <span class='update-plugins count-$pending_count'><span class='plugin-count'>" . number_format_i18n( $pending_count ) . '</span></span>';
123
- }
124
- }
125
-
126
- return $menu;
127
- }
128
- add_filter( 'add_menu_classes', 'wpmtst_pending_indicator' );
129
-
130
- /**
131
- * The [restore default] icon.
132
- *
133
- * @param $for
134
- *
135
- * @since 2.18.0
136
- */
137
- function wpmtst_restore_default_icon( $for ) {
138
- if ( !$for ) return;
139
- ?>
140
- <input type="button" class="button secondary restore-default"
141
- title="<?php esc_html_e( 'restore default', 'strong-testimonials' ); ?>"
142
- value="&#xf171"
143
- data-for="<?php echo esc_attr( $for ); ?>"/>
144
- <?php
145
- }
146
-
147
-
148
-
149
- /**
150
- * Check for configuration issues when options are updated.
151
- *
152
- * @since 2.24.0
153
- * @param $option
154
- * @param $old_value
155
- * @param $value
156
- */
157
- function wpmtst_updated_option( $option, $old_value, $value ) {
158
- if ( 'wpmtst_' == substr( $option, 0, 7 ) ) {
159
- do_action( 'wpmtst_check_config' );
160
- }
161
- }
162
- add_action( 'updated_option', 'wpmtst_updated_option', 10, 3 );
163
-
164
-
165
- /**
166
- * Store configuration error.
167
- *
168
- * @since 2.24.0
169
- * @param $key
170
- */
171
- function wpmtst_add_config_error( $key ) {
172
- $errors = get_option( 'wpmtst_config_errors', array() );
173
- $errors[] = $key;
174
- update_option( 'wpmtst_config_errors', array_unique( $errors ), 'no' );
175
-
176
- wpmtst_add_admin_notice( $key, true );
177
- }
178
-
179
-
180
- /**
181
- * Delete configuration error.
182
- *
183
- * @since 2.24.0
184
- * @param $key
185
- */
186
- function wpmtst_delete_config_error( $key ) {
187
- $errors = get_option( 'wpmtst_config_errors', array() );
188
- $errors = array_diff( $errors, array ( $key ) );
189
- update_option( 'wpmtst_config_errors', $errors, 'no' );
190
-
191
- wpmtst_delete_admin_notice( $key );
192
- }
193
-
194
-
195
- /**
196
- * Save a View.
197
- *
198
- * @param $view
199
- * @param string $action
200
- * @usedby Strong_Testimonials_Update:update_views
201
- *
202
- * @return bool|false|int
203
- */
204
- function wpmtst_save_view( $view, $action = 'edit' ) {
205
- global $wpdb;
206
-
207
- if ( ! $view ) return false;
208
-
209
- $table_name = $wpdb->prefix . 'strong_views';
210
- $serialized = serialize( $view['data'] );
211
-
212
- if ( 'add' == $action || 'duplicate' == $action ) {
213
- $sql = "INSERT INTO {$table_name} (name, value) VALUES (%s, %s)";
214
- $sql = $wpdb->prepare( $sql, $view['name'], $serialized );
215
- $wpdb->query( $sql );
216
- $view['id'] = $wpdb->insert_id;
217
- $return = $view['id'];
218
- }
219
- else {
220
- $sql = "UPDATE {$table_name} SET name = %s, value = %s WHERE id = %d";
221
- $sql = $wpdb->prepare( $sql, $view['name'], $serialized, intval( $view['id'] ) );
222
- $wpdb->query( $sql );
223
- $return = $wpdb->last_error ? 0 : 1;
224
- }
225
-
226
- do_action( 'wpmtst_view_saved', $view );
227
-
228
- return $return;
229
- }
230
-
231
-
232
- /**
233
- * @param $field
234
- *
235
- * @return mixed
236
- */
237
- function wpmtst_get_field_label( $field ) {
238
- if ( isset( $field['field'] ) ) {
239
- $custom_fields = wpmtst_get_custom_fields();
240
- if ( isset( $custom_fields[ $field['field'] ]['label'] ) ) {
241
- return $custom_fields[ $field['field'] ]['label'];
242
- }
243
- $builtin_fields = wpmtst_get_builtin_fields();
244
- if ( isset( $builtin_fields[ $field['field'] ]['label'] ) ) {
245
- return $builtin_fields[ $field['field'] ]['label'];
246
- }
247
- }
248
-
249
- return '';
250
- }
251
-
252
- function wpmtst_get_field_text( $field ) {
253
- if ( isset( $field['field'] ) ) {
254
- $custom_fields = wpmtst_get_custom_fields();
255
- if ( isset( $custom_fields[ $field['field'] ]['text'] ) ) {
256
- return $custom_fields[ $field['field'] ]['text'];
257
- }
258
- $builtin_fields = wpmtst_get_builtin_fields();
259
- if ( isset( $builtin_fields[ $field['field'] ]['text'] ) ) {
260
- return $builtin_fields[ $field['field'] ]['text'];
261
- }
262
- }
263
-
264
- return '';
265
- }
266
-
267
-
268
- /**
269
- * @param string $field_name
270
- *
271
- * @return mixed
272
- */
273
- function wpmtst_get_field_by_name( $field_name = '' ) {
274
- if ( $field_name ) {
275
- $custom_fields = wpmtst_get_custom_fields();
276
- if ( isset( $custom_fields[ $field_name ] ) ) {
277
- return $custom_fields[ $field_name ];
278
- }
279
- }
280
-
281
- return '';
282
- }
283
-
284
- /**
285
- * Returns true if at least one extension is installed
286
- */
287
- function wpmtst_extensions_installed() {
288
-
289
- if ( defined( 'WPMTST_CUSTOM_FIELDS_VERSION' ) ) {
290
- return true;
291
- }
292
- if ( defined( 'WPMTST_ASSIGNMENT_VERSION' ) ) {
293
- return true;
294
- }
295
- if ( defined( 'WPMTST_MULTIPLE_FORMS_VERSION' ) ) {
296
- return true;
297
- }
298
- if ( defined( 'WPMTST_PROPERTIES_VERSION' ) ) {
299
- return true;
300
- }
301
- if ( defined( 'WPMTST_COUNTRY_SELECTOR_VERSION' ) ) {
302
- return true;
303
- }
304
- if ( defined( 'WPMTST_REVIEW_MARKUP_VERSION' ) ) {
305
- return true;
306
- }
307
- if ( defined( 'WPMTST_ADVANCED_VIEWS_VERSION' ) ) {
308
- return true;
309
- }
310
-
311
- return false;
312
  }
1
+ <?php
2
+ /**
3
+ * Strong Testimonials admin functions.
4
+ *
5
+ * 1. Check for required WordPress version.
6
+ * 2. Check for plugin update.
7
+ * 3. Initialize.
8
+ */
9
+
10
+ /**
11
+ * Check for required WordPress version.
12
+ */
13
+ function wpmtst_version_check() {
14
+ global $wp_version;
15
+ $require_wp_version = "3.7";
16
+
17
+ if ( version_compare( $wp_version, $require_wp_version ) == -1 ) {
18
+ deactivate_plugins( WPMTST_PLUGIN );
19
+ /* translators: %s is the name of the plugin. */
20
+ $message = '<h2>' . sprintf( esc_html_x( 'Unable to load %s', 'installation', 'strong-testimonials' ), 'Strong Testimonials' ) . '</h2>';
21
+ /* translators: %s is a WordPress version number. */
22
+ $message .= '<p>' . sprintf( _x( 'This plugin requires <strong>WordPress %s</strong> or higher so it has been deactivated.', 'installation', 'strong-testimonials' ), $require_wp_version ) . '</p>';
23
+ $message .= '<p>' . esc_html_x( 'Please upgrade WordPress and try again.', 'installation', 'strong-testimonials' ) . '</p>';
24
+ $message .= '<p>' . sprintf( _x( 'Back to the WordPress <a href="%s">Plugins page</a>', 'installation', 'strong-testimonials' ), get_admin_url( null, 'plugins.php' ) ) . '</p>';
25
+ wp_die( $message );
26
+ }
27
+ }
28
+
29
+ add_action( 'admin_init', 'wpmtst_version_check', 1 );
30
+
31
+ /**
32
+ * Check for plugin update.
33
+ *
34
+ * @since 2.28.4 Before other admin_init actions.
35
+ */
36
+ function wpmtst_update_check() {
37
+ $version = get_option( 'wpmtst_plugin_version', false );
38
+ if ( $version == WPMTST_VERSION ) {
39
+ return;
40
+ }
41
+
42
+ Strong_Testimonials_Updater::update();
43
+ }
44
+
45
+ add_action( 'admin_init', 'wpmtst_update_check', 5 );
46
+
47
+ /**
48
+ * Initialize.
49
+ */
50
+ function wpmtst_admin_init() {
51
+
52
+ /**
53
+ * Custom action hooks
54
+ *
55
+ * @since 1.18.4
56
+ */
57
+ if ( isset( $_REQUEST['action'] ) && '' != $_REQUEST['action'] ) {
58
+ $action = sanitize_text_field( $_REQUEST['action'] );
59
+ do_action( 'wpmtst_' . $action );
60
+ }
61
+ }
62
+
63
+ add_action( 'admin_init', 'wpmtst_admin_init' );
64
+
65
+ /**
66
+ * Custom action link in admin notice.
67
+ *
68
+ * @since 2.29.0
69
+ */
70
+ function wpmtst_action_captcha_options_changed() {
71
+ wpmtst_delete_admin_notice( 'captcha-options-changed' );
72
+ wp_redirect( admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-settings&tab=form#captcha-section' ) );
73
+ exit;
74
+ }
75
+
76
+ add_action( 'admin_action_captcha-options-changed', 'wpmtst_action_captcha_options_changed' );
77
+
78
+ /**
79
+ * Are we on a testimonial admin screen?
80
+ *
81
+ * Used by add-ons too!
82
+ *
83
+ * @return bool
84
+ */
85
+ function wpmtst_is_testimonial_screen() {
86
+ $screen = get_current_screen();
87
+ return ( $screen && 'wpm-testimonial' == $screen->post_type );
88
+ }
89
+
90
+ /**
91
+ * Add pending numbers to post types on admin menu.
92
+ * Thanks http://wordpress.stackexchange.com/a/105470/32076
93
+ *
94
+ * @param $menu
95
+ *
96
+ * @return mixed
97
+ */
98
+ function wpmtst_pending_indicator( $menu ) {
99
+ if ( ! current_user_can( 'edit_posts' ) )
100
+ return $menu;
101
+
102
+ $options = get_option( 'wpmtst_options' );
103
+ if ( ! isset( $options['pending_indicator'] ) || ! $options['pending_indicator'] )
104
+ return $menu;
105
+
106
+ $types = array( 'wpm-testimonial' );
107
+ $status = 'pending';
108
+ foreach ( $types as $type ) {
109
+ $num_posts = wp_count_posts( $type, 'readable' );
110
+ $pending_count = 0;
111
+ if ( ! empty( $num_posts->$status ) )
112
+ $pending_count = $num_posts->$status;
113
+
114
+ if ( $type == 'post' )
115
+ $menu_str = 'edit.php';
116
+ else
117
+ $menu_str = 'edit.php?post_type=' . $type;
118
+
119
+ foreach ( $menu as $menu_key => $menu_data ) {
120
+ if ( $menu_str != $menu_data[2] )
121
+ continue;
122
+ $menu[ $menu_key ][0] .= " <span class='update-plugins count-$pending_count'><span class='plugin-count'>" . number_format_i18n( $pending_count ) . '</span></span>';
123
+ }
124
+ }
125
+
126
+ return $menu;
127
+ }
128
+ add_filter( 'add_menu_classes', 'wpmtst_pending_indicator' );
129
+
130
+ /**
131
+ * The [restore default] icon.
132
+ *
133
+ * @param $for
134
+ *
135
+ * @since 2.18.0
136
+ */
137
+ function wpmtst_restore_default_icon( $for ) {
138
+ if ( !$for ) return;
139
+ ?>
140
+ <input type="button" class="button secondary restore-default"
141
+ title="<?php esc_html_e( 'restore default', 'strong-testimonials' ); ?>"
142
+ value="&#xf171"
143
+ data-for="<?php echo esc_attr( $for ); ?>"/>
144
+ <?php
145
+ }
146
+
147
+
148
+
149
+ /**
150
+ * Check for configuration issues when options are updated.
151
+ *
152
+ * @since 2.24.0
153
+ * @param $option
154
+ * @param $old_value
155
+ * @param $value
156
+ */
157
+ function wpmtst_updated_option( $option, $old_value, $value ) {
158
+ if ( 'wpmtst_' == substr( $option, 0, 7 ) ) {
159
+ do_action( 'wpmtst_check_config' );
160
+ }
161
+ }
162
+ add_action( 'updated_option', 'wpmtst_updated_option', 10, 3 );
163
+
164
+
165
+ /**
166
+ * Store configuration error.
167
+ *
168
+ * @since 2.24.0
169
+ * @param $key
170
+ */
171
+ function wpmtst_add_config_error( $key ) {
172
+ $errors = get_option( 'wpmtst_config_errors', array() );
173
+ $errors[] = $key;
174
+ update_option( 'wpmtst_config_errors', array_unique( $errors ), 'no' );
175
+
176
+ wpmtst_add_admin_notice( $key, true );
177
+ }
178
+
179
+
180
+ /**
181
+ * Delete configuration error.
182
+ *
183
+ * @since 2.24.0
184
+ * @param $key
185
+ */
186
+ function wpmtst_delete_config_error( $key ) {
187
+ $errors = get_option( 'wpmtst_config_errors', array() );
188
+ $errors = array_diff( $errors, array ( $key ) );
189
+ update_option( 'wpmtst_config_errors', $errors, 'no' );
190
+
191
+ wpmtst_delete_admin_notice( $key );
192
+ }
193
+
194
+
195
+ /**
196
+ * Save a View.
197
+ *
198
+ * @param $view
199
+ * @param string $action
200
+ * @usedby Strong_Testimonials_Update:update_views
201
+ *
202
+ * @return bool|false|int
203
+ */
204
+ function wpmtst_save_view( $view, $action = 'edit' ) {
205
+ global $wpdb;
206
+
207
+ if ( ! $view ) return false;
208
+
209
+ $table_name = $wpdb->prefix . 'strong_views';
210
+ $serialized = serialize( $view['data'] );
211
+
212
+ if ( 'add' == $action || 'duplicate' == $action ) {
213
+ $sql = "INSERT INTO {$table_name} (name, value) VALUES (%s, %s)";
214
+ $sql = $wpdb->prepare( $sql, $view['name'], $serialized );
215
+ $wpdb->query( $sql );
216
+ $view['id'] = $wpdb->insert_id;
217
+ $return = $view['id'];
218
+ }
219
+ else {
220
+ $sql = "UPDATE {$table_name} SET name = %s, value = %s WHERE id = %d";
221
+ $sql = $wpdb->prepare( $sql, $view['name'], $serialized, intval( $view['id'] ) );
222
+ $wpdb->query( $sql );
223
+ $return = $wpdb->last_error ? 0 : 1;
224
+ }
225
+
226
+ do_action( 'wpmtst_view_saved', $view );
227
+
228
+ return $return;
229
+ }
230
+
231
+
232
+ /**
233
+ * @param $field
234
+ *
235
+ * @return mixed
236
+ */
237
+ function wpmtst_get_field_label( $field ) {
238
+ if ( isset( $field['field'] ) ) {
239
+ $custom_fields = wpmtst_get_custom_fields();
240
+ if ( isset( $custom_fields[ $field['field'] ]['label'] ) ) {
241
+ return $custom_fields[ $field['field'] ]['label'];
242
+ }
243
+ $builtin_fields = wpmtst_get_builtin_fields();
244
+ if ( isset( $builtin_fields[ $field['field'] ]['label'] ) ) {
245
+ return $builtin_fields[ $field['field'] ]['label'];
246
+ }
247
+ }
248
+
249
+ return '';
250
+ }
251
+
252
+ function wpmtst_get_field_text( $field ) {
253
+ if ( isset( $field['field'] ) ) {
254
+ $custom_fields = wpmtst_get_custom_fields();
255
+ if ( isset( $custom_fields[ $field['field'] ]['text'] ) ) {
256
+ return $custom_fields[ $field['field'] ]['text'];
257
+ }
258
+ $builtin_fields = wpmtst_get_builtin_fields();
259
+ if ( isset( $builtin_fields[ $field['field'] ]['text'] ) ) {
260
+ return $builtin_fields[ $field['field'] ]['text'];
261
+ }
262
+ }
263
+
264
+ return '';
265
+ }
266
+
267
+
268
+ /**
269
+ * @param string $field_name
270
+ *
271
+ * @return mixed
272
+ */
273
+ function wpmtst_get_field_by_name( $field_name = '' ) {
274
+ if ( $field_name ) {
275
+ $custom_fields = wpmtst_get_custom_fields();
276
+ if ( isset( $custom_fields[ $field_name ] ) ) {
277
+ return $custom_fields[ $field_name ];
278
+ }
279
+ }
280
+
281
+ return '';
282
+ }
283
+
284
+ /**
285
+ * Returns true if at least one extension is installed
286
+ */
287
+ function wpmtst_extensions_installed() {
288
+
289
+ if ( defined( 'WPMTST_CUSTOM_FIELDS_VERSION' ) ) {
290
+ return true;
291
+ }
292
+ if ( defined( 'WPMTST_ASSIGNMENT_VERSION' ) ) {
293
+ return true;
294
+ }
295
+ if ( defined( 'WPMTST_MULTIPLE_FORMS_VERSION' ) ) {
296
+ return true;
297
+ }
298
+ if ( defined( 'WPMTST_PROPERTIES_VERSION' ) ) {
299
+ return true;
300
+ }
301
+ if ( defined( 'WPMTST_COUNTRY_SELECTOR_VERSION' ) ) {
302
+ return true;
303
+ }
304
+ if ( defined( 'WPMTST_REVIEW_MARKUP_VERSION' ) ) {
305
+ return true;
306
+ }
307
+ if ( defined( 'WPMTST_ADVANCED_VIEWS_VERSION' ) ) {
308
+ return true;
309
+ }
310
+
311
+ return false;
312
  }
admin/challenge/modal.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Challenge main class
4
+ *
5
+ * @since 2.6.8
6
+ *
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+
14
+ class ST_Challenge_Modal{
15
+
16
+
17
+ public function __construct(){
18
+
19
+ if( is_admin() && $this->show_challenge() && 1 == get_option( 'wpmtst-challenge', 1 ) ){
20
+ add_action( 'admin_footer', array( $this, 'challenge_render' ), 99 );
21
+ add_action( 'admin_enqueue_scripts', array( $this, 'challenge_scripts' ) );
22
+ add_action( 'wp_ajax_wpmtst_challenge_hide', array( $this, 'wpmtst_challenge_hide' ) );
23
+ }
24
+
25
+ }
26
+
27
+ public function challenge_render(){
28
+
29
+ $new_gallery_url = add_query_arg(
30
+ array(
31
+ 'post_type' => 'wpm-testimonial',
32
+ ),
33
+ admin_url( 'post-new.php' )
34
+ );
35
+
36
+ ?>
37
+ <div class="wpmtst-challenge-wrap">
38
+ <div class="wpmtst-challenge-header">
39
+ <span id="wpmtst-challenge-close" class="dashicons dashicons-no-alt"></span>
40
+ <p><?php echo wp_kses_post( __( 'Start enjoying <strong>Strong Testimonials</strong> by adding your first testimonial.', 'strong-testimonials' ) ); ?></p>
41
+ </div>
42
+ <div class="wpmtst-challenge-list">
43
+ <p><span class="wpmtst-challenge-marker"></span> <?php esc_html_e( 'Primul lucru din lista', 'strong-testimonials' ); ?></p>
44
+ <p><span class="wpmtst-challenge-marker"></span> <?php esc_html_e( 'Al 2-lea lucru din lista', 'strong-testimonials' ); ?></p>
45
+ <p><span class="wpmtst-challenge-marker"></span> <?php esc_html_e( 'Al 3-lea lucru din lista', 'strong-testimonials' ); ?></p>
46
+ <p><span class="wpmtst-challenge-marker"></span> <?php esc_html_e( 'Al 4-lea lucru din lista', 'strong-testimonials' ); ?></p>
47
+ <p><span class="wpmtst-challenge-marker"></span> <?php esc_html_e( 'Al 5-lea lucru din lista', 'strong-testimonials' ); ?></p>
48
+ </div>
49
+ <div class="wpmtst-challenge-footer">
50
+ <img src="<?php echo esc_url( WPMTST_URL . 'admin/img/mascot.png' ); ?>" class="wpmtst-challenge-logo"/>
51
+ <div>
52
+ <h3>Strong Testimonials</h3>
53
+ <p><span class="wpmtst-challenge-time">5:00</span> remaining.</p>
54
+ </div>
55
+ </div>
56
+ <div class="wpmtst-challenge-footer-button">
57
+ <a id="wpmtst-challenge-button" href="<?php echo esc_url( $new_gallery_url ); ?>" class="wpmtst-btn wpmtst-challenge-btn"><?php esc_html_e( 'Create First Gallery', 'strong-testimonials' ); ?></a>
58
+ </div>
59
+
60
+ </div>
61
+ <?php
62
+ }
63
+
64
+ public function challenge_scripts( $hook ) {
65
+
66
+ wp_enqueue_style( 'wpmtst-challenge-style', WPMTST_URL . 'assets/css/challenge.css', array(), true );
67
+ wp_enqueue_script( 'wpmtst-challenge-script', WPMTST_URL . 'assets/js/challenge.js', array( 'jquery' ), '1.0.0', true );
68
+ $args = array(
69
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
70
+ 'nonce' => wp_create_nonce( 'wpmtst-challenge' ),
71
+ );
72
+ wp_localize_script( 'wpmtst-challenge-script', 'wpmtstChallenge', $args );
73
+
74
+ }
75
+
76
+ public function show_challenge(){
77
+ $args = array(
78
+ 'numberposts' => 1,
79
+ 'post_status' => 'any, trash',
80
+ 'post_type' => 'wpm-testimonial'
81
+ );
82
+
83
+ if( !isset( $_GET['post_type'] ) || 'wpm-testimonial' !== $_GET['post_type'] ){
84
+ return false;
85
+ }
86
+
87
+ if( empty( get_posts( $args ) ) ){
88
+ return true;
89
+ }
90
+
91
+ return false;
92
+
93
+ }
94
+ public function wpmtst_challenge_hide(){
95
+
96
+ $nonce = '';
97
+
98
+ if( isset( $_POST['nonce'] ) ){
99
+
100
+ $nonce = $_POST['nonce'];
101
+ }
102
+
103
+ if ( ! wp_verify_nonce( $nonce, 'wpmtst-challenge' ) ) {
104
+ wp_send_json_error();
105
+ die();
106
+ }
107
+
108
+ update_option( 'wpmtst-challenge', 0 );
109
+ wp_send_json_success();
110
+ wp_die();
111
+ }
112
+
113
+ }
114
+ new ST_Challenge_Modal();
115
+ ?>
admin/class-strong-testimonials-addons.php CHANGED
@@ -1,141 +1,141 @@
1
- <?php
2
- /**
3
- * Class Strong_Testimonials_Addons
4
- *
5
- * @since 2.38
6
- */
7
- class Strong_Testimonials_Addons {
8
-
9
- private $addons = array();
10
-
11
- public function __construct() {
12
- add_filter( 'wpmtst_submenu_pages', array( $this, 'add_submenu' ) );
13
-
14
- // Add ajax action to reload extensions
15
- add_action( 'wp_ajax_wpmtst_reload_extensions', array( $this, 'reload_extensions' ), 20 );
16
- }
17
-
18
- private function check_for_addons() {
19
-
20
- if ( false !== ( $data = get_transient( 'strong_testimonials_all_extensions' ) ) ) {
21
- return $data;
22
- }
23
-
24
- $addons = array();
25
-
26
- $url = apply_filters( 'strong_testimonials_addon_server_url', WPMTST_STORE_URL . '/wp-json/mt/v1/get-all-extensions' );
27
-
28
- // Get data from the remote URL.
29
- $response = wp_remote_get( $url );
30
-
31
- if ( ! is_wp_error( $response ) ) {
32
-
33
- // Decode the data that we got.
34
- $data = json_decode( wp_remote_retrieve_body( $response ), true );
35
-
36
- if ( ! empty( $data ) && is_array( $data ) ) {
37
- $addons = $data;
38
- // Store the data for a week.
39
- set_transient( 'strong_testimonials_all_extensions', $data, 7 * DAY_IN_SECONDS );
40
- }
41
- }
42
-
43
- return apply_filters( 'wpmtst_addons', $addons );
44
- }
45
-
46
- public function render_addons() {
47
-
48
- wp_enqueue_style( 'wpmtst-admin-style' );
49
- wp_enqueue_script( 'wpmtst-admin-script' );
50
-
51
- if ( ! empty( $this->addons ) ) {
52
- foreach ( $this->addons as $addon ) {
53
- $image = ( '' != $addon['image'] ) ? $addon['image'] : WPMTST_ASSETS_IMG . '/logo.png';
54
- echo '<div class="wpmtst-addon">';
55
- echo '<div class="wpmtst-addon-box">';
56
- echo '<img src="' . esc_attr( $image ) . '">';
57
- echo '<div class="wpmtst-addon-content">';
58
- echo '<h3>' . esc_html( $addon['name'] ) . '</h3>';
59
- echo '<div class="wpmtst-addon-description">' . wp_kses_post( $addon['description'] ) . '</div>';
60
- echo '</div>';
61
- echo '</div>';
62
- echo '<div class="wpmtst-addon-actions">';
63
- echo apply_filters( 'wpmtst_addon_button_action', '<a href="' . esc_url( WPMTST_STORE_UPGRADE_URL . '?utm_source=st-lite&utm_campaign=upsell&utm_medium=' . esc_attr( $addon['slug'] ) ) . '" target="_blank" class="button primary-button">' . esc_html__( 'Upgrade now', 'strong-testimonials' ) . '</a>', $addon );
64
- echo '</div>';
65
- echo '</div>';
66
- }
67
- }
68
-
69
- }
70
-
71
- /**
72
- * Add submenu page.
73
- *
74
- * @param $pages
75
- *
76
- * @return mixed
77
- */
78
- public function add_submenu( $pages ) {
79
- $pages[91] = $this->get_submenu();
80
- return $pages;
81
- }
82
-
83
- /**
84
- * Return submenu page parameters.
85
- *
86
- * @return array
87
- */
88
- public function get_submenu() {
89
- return array(
90
- 'page_title' => esc_html__( 'Extensions', 'strong-testimonials' ),
91
- 'menu_title' => esc_html__( 'Extensions', 'strong-testimonials' ),
92
- 'capability' => 'strong_testimonials_options',
93
- 'menu_slug' => 'strong-testimonials-addons',
94
- 'function' => array( $this, 'addons_page' ),
95
- );
96
- }
97
-
98
-
99
- /**
100
- * Print the Addons page.
101
- */
102
- public function addons_page() {
103
-
104
- $this->addons = $this->check_for_addons();
105
- ?>
106
-
107
- <div class="wrap">
108
- <h1 style="margin-bottom: 20px; display: inline-block;"><?php esc_html_e( 'Extensions', 'strong-testimonials' ); ?></h1>
109
-
110
- <a id="wpmtst-reload-extensions" class="button button-primary" style="margin: 10px 0 0 30px;" data-nonce="<?php echo esc_attr( wp_create_nonce( 'wpmtst-reload-extensions' ) ); ?>"><?php esc_html_e( 'Reload Extensions', 'strong-testimonials' ); ?></a>
111
-
112
- <div class="wpmtst-addons-container">
113
- <?php $this->render_addons(); ?>
114
- </div>
115
- </div>
116
- <?php
117
- }
118
-
119
- public function reload_extensions() {
120
- // Run a security check first.
121
- check_admin_referer( 'wpmtst-reload-extensions', 'nonce' );
122
-
123
- delete_transient( 'strong_testimonials_all_extensions' );
124
-
125
- die;
126
- }
127
-
128
- /**
129
- * Retrieves ST addons
130
- *
131
- * @return Array
132
- *
133
- * @since 2.51.7
134
- */
135
- public function get_addons() {
136
- return $this->check_for_addons();
137
- }
138
-
139
- }
140
-
141
- new Strong_Testimonials_Addons();
1
+ <?php
2
+ /**
3
+ * Class Strong_Testimonials_Addons
4
+ *
5
+ * @since 2.38
6
+ */
7
+ class Strong_Testimonials_Addons {
8
+
9
+ private $addons = array();
10
+
11
+ public function __construct() {
12
+ add_filter( 'wpmtst_submenu_pages', array( $this, 'add_submenu' ) );
13
+
14
+ // Add ajax action to reload extensions
15
+ add_action( 'wp_ajax_wpmtst_reload_extensions', array( $this, 'reload_extensions' ), 20 );
16
+ }
17
+
18
+ private function check_for_addons() {
19
+
20
+ if ( false !== ( $data = get_transient( 'strong_testimonials_all_extensions' ) ) ) {
21
+ return $data;
22
+ }
23
+
24
+ $addons = array();
25
+
26
+ $url = apply_filters( 'strong_testimonials_addon_server_url', WPMTST_STORE_URL . '/wp-json/mt/v1/get-all-extensions' );
27
+
28
+ // Get data from the remote URL.
29
+ $response = wp_remote_get( $url );
30
+
31
+ if ( ! is_wp_error( $response ) ) {
32
+
33
+ // Decode the data that we got.
34
+ $data = json_decode( wp_remote_retrieve_body( $response ), true );
35
+
36
+ if ( ! empty( $data ) && is_array( $data ) ) {
37
+ $addons = $data;
38
+ // Store the data for a week.
39
+ set_transient( 'strong_testimonials_all_extensions', $data, 7 * DAY_IN_SECONDS );
40
+ }
41
+ }
42
+
43
+ return apply_filters( 'wpmtst_addons', $addons );
44
+ }
45
+
46
+ public function render_addons() {
47
+
48
+ wp_enqueue_style( 'wpmtst-admin-style' );
49
+ wp_enqueue_script( 'wpmtst-admin-script' );
50
+
51
+ if ( ! empty( $this->addons ) ) {
52
+ foreach ( $this->addons as $addon ) {
53
+ $image = ( '' != $addon['image'] ) ? $addon['image'] : WPMTST_ASSETS_IMG . '/logo.png';
54
+ echo '<div class="wpmtst-addon">';
55
+ echo '<div class="wpmtst-addon-box">';
56
+ echo '<img src="' . esc_attr( $image ) . '">';
57
+ echo '<div class="wpmtst-addon-content">';
58
+ echo '<h3>' . esc_html( $addon['name'] ) . '</h3>';
59
+ echo '<div class="wpmtst-addon-description">' . wp_kses_post( $addon['description'] ) . '</div>';
60
+ echo '</div>';
61
+ echo '</div>';
62
+ echo '<div class="wpmtst-addon-actions">';
63
+ echo apply_filters( 'wpmtst_addon_button_action', '<a href="' . esc_url( WPMTST_STORE_UPGRADE_URL . '?utm_source=st-lite&utm_campaign=upsell&utm_medium=' . esc_attr( $addon['slug'] ) ) . '" target="_blank" class="button primary-button">' . esc_html__( 'Upgrade now', 'strong-testimonials' ) . '</a>', $addon );
64
+ echo '</div>';
65
+ echo '</div>';
66
+ }
67
+ }
68
+
69
+ }
70
+
71
+ /**
72
+ * Add submenu page.
73
+ *
74
+ * @param $pages
75
+ *
76
+ * @return mixed
77
+ */
78
+ public function add_submenu( $pages ) {
79
+ $pages[91] = $this->get_submenu();
80
+ return $pages;
81
+ }
82
+
83
+ /**
84
+ * Return submenu page parameters.
85
+ *
86
+ * @return array
87
+ */
88
+ public function get_submenu() {
89
+ return array(
90
+ 'page_title' => esc_html__( 'Extensions', 'strong-testimonials' ),
91
+ 'menu_title' => esc_html__( 'Extensions', 'strong-testimonials' ),
92
+ 'capability' => 'strong_testimonials_options',
93
+ 'menu_slug' => 'strong-testimonials-addons',
94
+ 'function' => array( $this, 'addons_page' ),
95
+ );
96
+ }
97
+
98
+
99
+ /**
100
+ * Print the Addons page.
101
+ */
102
+ public function addons_page() {
103
+
104
+ $this->addons = $this->check_for_addons();
105
+ ?>
106
+
107
+ <div class="wrap">
108
+ <h1 style="margin-bottom: 20px; display: inline-block;"><?php esc_html_e( 'Extensions', 'strong-testimonials' ); ?></h1>
109
+
110
+ <a id="wpmtst-reload-extensions" class="button button-primary" style="margin: 10px 0 0 30px;" data-nonce="<?php echo esc_attr( wp_create_nonce( 'wpmtst-reload-extensions' ) ); ?>"><?php esc_html_e( 'Reload Extensions', 'strong-testimonials' ); ?></a>
111
+
112
+ <div class="wpmtst-addons-container">
113
+ <?php $this->render_addons(); ?>
114
+ </div>
115
+ </div>
116
+ <?php
117
+ }
118
+
119
+ public function reload_extensions() {
120
+ // Run a security check first.
121
+ check_admin_referer( 'wpmtst-reload-extensions', 'nonce' );
122
+
123
+ delete_transient( 'strong_testimonials_all_extensions' );
124
+
125
+ die;
126
+ }
127
+
128
+ /**
129
+ * Retrieves ST addons
130
+ *
131
+ * @return Array
132
+ *
133
+ * @since 2.51.7
134
+ */
135
+ public function get_addons() {
136
+ return $this->check_for_addons();
137
+ }
138
+
139
+ }
140
+
141
+ new Strong_Testimonials_Addons();
admin/class-strong-testimonials-admin-category-list.php CHANGED
@@ -1,69 +1,69 @@
1
- <?php
2
- /**
3
- * Class Strong_Testimonials_Admin_Category_List
4
- *
5
- * @since 2.28.0
6
- */
7
- class Strong_Testimonials_Admin_Category_List {
8
-
9
- /**
10
- * Strong_Testimonials_Admin_list constructor.
11
- */
12
- public function __construct() {}
13
-
14
- /**
15
- * Initialize.
16
- */
17
- public static function init() {
18
- self::add_actions();
19
- }
20
-
21
- /**
22
- * Add actions and filters.
23
- */
24
- public static function add_actions() {
25
- add_filter( 'manage_edit-wpm-testimonial-category_columns', array( __CLASS__, 'manage_categories' ) );
26
- add_filter( 'manage_wpm-testimonial-category_custom_column', array( __CLASS__, 'manage_columns' ), 10, 3 );
27
- }
28
-
29
- /**
30
- * Add columns to the testimonials categories screen
31
- *
32
- * @param $columns
33
- *
34
- * @return array
35
- */
36
- public static function manage_categories( $columns ) {
37
- $new_columns = array(
38
- 'cb' => '<input type="checkbox">',
39
- 'ID' => esc_html__( 'ID', 'strong-testimonials' ),
40
- 'name' => esc_html__( 'Name', 'strong-testimonials' ),
41
- 'slug' => esc_html__( 'Slug', 'strong-testimonials' ),
42
- 'posts' => esc_html__( 'Posts', 'strong-testimonials' ),
43
- );
44
-
45
- return $new_columns;
46
- }
47
-
48
- /**
49
- * Show custom column
50
- *
51
- * @param $out
52
- * @param $column_name
53
- * @param $id
54
- *
55
- * @return string
56
- */
57
- public static function manage_columns( $out, $column_name, $id ) {
58
- if ( 'ID' == $column_name ) {
59
- $output = $id;
60
- } else {
61
- $output = '';
62
- }
63
-
64
- return $output;
65
- }
66
-
67
- }
68
-
69
- Strong_Testimonials_Admin_Category_List::init();
1
+ <?php
2
+ /**
3
+ * Class Strong_Testimonials_Admin_Category_List
4
+ *
5
+ * @since 2.28.0
6
+ */
7
+ class Strong_Testimonials_Admin_Category_List {
8
+
9
+ /**
10
+ * Strong_Testimonials_Admin_list constructor.
11
+ */
12
+ public function __construct() {}
13
+
14
+ /**
15
+ * Initialize.
16
+ */
17
+ public static function init() {
18
+ self::add_actions();
19
+ }
20
+
21
+ /**
22
+ * Add actions and filters.
23
+ */
24
+ public static function add_actions() {
25
+ add_filter( 'manage_edit-wpm-testimonial-category_columns', array( __CLASS__, 'manage_categories' ) );
26
+ add_filter( 'manage_wpm-testimonial-category_custom_column', array( __CLASS__, 'manage_columns' ), 10, 3 );
27
+ }
28
+
29
+ /**
30
+ * Add columns to the testimonials categories screen
31
+ *
32
+ * @param $columns
33
+ *
34
+ * @return array
35
+ */
36
+ public static function manage_categories( $columns ) {
37
+ $new_columns = array(
38
+ 'cb' => '<input type="checkbox">',
39
+ 'ID' => esc_html__( 'ID', 'strong-testimonials' ),
40
+ 'name' => esc_html__( 'Name', 'strong-testimonials' ),
41
+ 'slug' => esc_html__( 'Slug', 'strong-testimonials' ),
42
+ 'posts' => esc_html__( 'Posts', 'strong-testimonials' ),
43
+ );
44
+
45
+ return $new_columns;
46
+ }
47
+
48
+ /**
49
+ * Show custom column
50
+ *
51
+ * @param $out
52
+ * @param $column_name
53
+ * @param $id
54
+ *
55
+ * @return string
56
+ */
57
+ public static function manage_columns( $out, $column_name, $id ) {
58
+ if ( 'ID' == $column_name ) {
59
+ $output = $id;
60
+ } else {
61
+ $output = '';
62
+ }
63
+
64
+ return $output;
65
+ }
66
+
67
+ }
68
+
69
+ Strong_Testimonials_Admin_Category_List::init();
admin/class-strong-testimonials-admin-list.php CHANGED
@@ -1,347 +1,347 @@
1
- <?php
2
- /**
3
- * Class Strong_Testimonials_Admin_List
4
- *
5
- * @since 2.28.0
6
- */
7
- class Strong_Testimonials_Admin_List {
8
-
9
- /**
10
- * Strong_Testimonials_Admin_List constructor.
11
- */
12
- public function __construct() {}
13
-
14
- /**
15
- * Initialize.
16
- */
17
- public static function init() {
18
- self::add_actions();
19
- }
20
-
21
- /**
22
- * Add actions and filters.
23
- */
24
- public static function add_actions() {
25
- add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ) );
26
- add_filter( 'manage_wpm-testimonial_posts_columns', array( __CLASS__, 'add_thumbnail_column' ) );
27
- add_filter( 'manage_edit-wpm-testimonial_columns', array( __CLASS__, 'edit_columns' ) );
28
- add_action( 'restrict_manage_posts', array( __CLASS__, 'add_taxonomy_filters' ) );
29
- add_filter( 'manage_edit-wpm-testimonial_sortable_columns', array( __CLASS__, 'manage_sortable_columns' ) );
30
- add_action( 'manage_wpm-testimonial_posts_custom_column', array( __CLASS__, 'custom_columns' ) );
31
- add_filter( 'post_row_actions', array( __CLASS__, 'post_row_actions' ), 10, 2 );
32
- }
33
-
34
- /**
35
- * Add post ID to post row actions.
36
- *
37
- * @param $actions
38
- * @param $post
39
- * @since 2.32.2
40
- *
41
- * @return array
42
- */
43
- public static function post_row_actions( $actions, $post ) {
44
- if ( 'wpm-testimonial' == $post->post_type ) {
45
- $actions = array( 'id' => '<span>ID: ' . $post->ID . '</span>' ) + $actions;
46
- }
47
-
48
- return $actions;
49
- }
50
-
51
- /**
52
- * Add custom columns to the admin list.
53
- *
54
- * @param $columns
55
- *
56
- * @since 1.4.0
57
- * @since 2.5.1 Added comments column.
58
- *
59
- * @return array
60
- */
61
- public static function edit_columns( $columns ) {
62
- $fields = wpmtst_get_all_fields();
63
-
64
- $comments = isset( $columns['comments'] ) ? $columns['comments'] : '';
65
-
66
- /*
67
- INCOMING COLUMNS = Array (
68
- [cb] => <input type="checkbox" />
69
- [title] => Title
70
- [comments] => <span class="vers comment-grey-bubble" title="Comments"><span class="screen-reader-text">Comments</span></span>
71
- [date] => Date
72
- [search_exclude] => Search Exclude // other plugin
73
- [strong_thumbnail] => Thumbnail
74
- )
75
- */
76
-
77
- // 1. remove [thumbnail] (may be re-added in custom field loop) and [date]
78
- unset( $columns['strong_thumbnail'], $columns['date'] );
79
-
80
- if ( $comments ) {
81
- unset( $columns['comments'] );
82
- }
83
-
84
- // 2. insert [order] after [cb]
85
- if ( ! self::is_column_sorted() && ! self::is_viewing_trash() && class_exists( 'Strong_Testimonials_Order' ) ) {
86
- $columns = array_merge(
87
- array_slice( $columns, 0, 1 ),
88
- array( 'handle' => 'Order' ),
89
- array_slice( $columns, 1, null )
90
- );
91
- }
92
-
93
- // 3. insert [excerpt] after [title]
94
- $key = 'title';
95
- $offset = array_search( $key, array_keys( $columns ) ) + 1;
96
- $fields_to_add = array( 'post_excerpt' => esc_html__( 'Excerpt', 'strong-testimonials' ) );
97
-
98
- // 4. add custom fields
99
- foreach ( $fields as $key => $field ) {
100
-
101
- if ( $field['admin_table'] ) {
102
-
103
- if ( 'post_title' == $field['name'] ) {
104
- continue;
105
- } elseif ( 'featured_image' == $field['name'] ) {
106
- $fields_to_add['strong_thumbnail'] = esc_html__( 'Thumbnail', 'strong-testimonials' );
107
- } elseif ( 'rating' == $field['input_type'] ) {
108
- $fields_to_add[ $field['name'] ] = esc_html__( 'Rating', 'strong-testimonials' );
109
- } else {
110
- $fields_to_add[ $field['name'] ] = apply_filters( 'wpmtst_l10n', $field['label'], 'strong-testimonials-form-fields', $field['name'] . ' : label' );
111
- }
112
-
113
- }
114
-
115
- }
116
-
117
- // 5. add [category], [comments] and [date]
118
- // The slug "categories" slug is reserved by WordPress.
119
- if ( wpmtst_get_cat_count() ) {
120
- $fields_to_add['category'] = esc_html__( 'Categories', 'strong-testimonials' );
121
- }
122
-
123
- if ( $comments ) {
124
- $fields_to_add['comments'] = $comments;
125
- }
126
-
127
- $fields_to_add['date'] = esc_html__( 'Date', 'strong-testimonials' );
128
-
129
- $options = get_option( 'wpmtst_options' );
130
- if ( isset( $options['include_platform'] ) && $options['include_platform'] === true ) {
131
- $fields_to_add['platform'] = esc_html__( 'Platform', 'strong-testimonials' );
132
- }
133
-
134
- // Push other added columns like [search_exclude] to the end.
135
- $columns = array_merge(
136
- array_slice( $columns, 0, $offset ),
137
- $fields_to_add,
138
- array_slice( $columns, $offset, null )
139
- );
140
-
141
- return $columns;
142
- }
143
-
144
- /**
145
- * Show custom values
146
- *
147
- * @param $column
148
- */
149
- public static function custom_columns( $column ) {
150
- global $post;
151
-
152
- switch ( $column ) {
153
-
154
- case 'post_id' :
155
- echo absint( $post->ID );
156
- break;
157
-
158
- case 'post_content' :
159
- echo substr( $post->post_content, 0, 100 ) . '&hellip;';
160
- break;
161
-
162
- case 'post_excerpt' :
163
- echo $post->post_excerpt;
164
- break;
165
-
166
- case 'strong_thumbnail' :
167
- echo wpmtst_get_thumbnail( array( 60, 60 ) );
168
- break;
169
-
170
- case 'category' :
171
- $categories = get_the_terms( 0, 'wpm-testimonial-category' );
172
- if ( $categories && ! is_wp_error( $categories ) ) {
173
- $list = array();
174
- foreach ( $categories as $cat ) {
175
- $list[] = $cat->name;
176
- }
177
- echo implode( ", ", $list );
178
- }
179
- break;
180
-
181
- case 'handle' :
182
- if ( current_user_can( 'edit_post', $post->ID ) && ! self::is_column_sorted() && ! self::is_viewing_trash() ) {
183
- echo '<div class="handle"><div class="help"></div><div class="help-in-motion"></div></div>';
184
- }
185
- break;
186
-
187
- case 'platform':
188
- $platform = get_post_meta( $post->ID, 'platform', true );
189
-
190
- if ( $platform ) {
191
- ?>
192
- <img title="<?php echo esc_attr( __( 'posted on ', 'strong-testimonials' ) . $platform ); ?>" width="26" height="26" src="<?php esc_attr_e( WPMTST_ASSETS_IMG ); ?>/platform_icons/<?php esc_attr_e( $platform ); ?>.svg"/>
193
- <?php
194
- }
195
-
196
- break;
197
-
198
- default :
199
- // custom field?
200
- $custom = get_post_custom();
201
- $fields = wpmtst_get_custom_fields();
202
-
203
- if ( isset( $custom[ $column ] ) && $custom[ $column ][0] ) {
204
-
205
- if ( isset( $fields[ $column ] ) ) {
206
-
207
- switch ( $fields[ $column ]['input_type'] ) {
208
- case 'rating' :
209
- wpmtst_star_rating_display( $custom[ $column ][0], 'in-table-list' );
210
- break;
211
- case 'checkbox' :
212
- echo $custom[ $column ][0] ? 'yes' : 'no';
213
- break;
214
- default :
215
- echo $custom[ $column ][0];
216
- }
217
-
218
- }
219
-
220
- } else {
221
-
222
- if ( isset( $fields[ $column ] ) ) {
223
-
224
- if ( 'checkbox' == $fields[ $column ]['input_type'] ) {
225
- echo 'no';
226
- } else {
227
- // display nothing
228
- }
229
-
230
- }
231
- }
232
-
233
- }
234
- }
235
-
236
- /**
237
- * Add thumbnail column to admin list
238
- *
239
- * @param $columns
240
- *
241
- * @return array
242
- */
243
- public static function add_thumbnail_column( $columns ) {
244
- $columns['strong_thumbnail'] = esc_html__( 'Thumbnail', 'strong-testimonials' );
245
-
246
- return $columns;
247
- }
248
-
249
- /**
250
- * Make columns sortable.
251
- *
252
- * @param $columns
253
- *
254
- * @since 1.12.0
255
- * @since 2.2.0 category
256
- *
257
- * @return mixed
258
- */
259
- public static function manage_sortable_columns( $columns ) {
260
- $columns['client_name'] = 'client_name';
261
- $columns['category'] = 'categories';
262
- $columns['date'] = 'date';
263
-
264
- return $columns;
265
- }
266
-
267
- /**
268
- * Add category filter to testimonial list table.
269
- *
270
- * @since 2.2.0
271
- */
272
- public static function add_taxonomy_filters() {
273
- global $typenow;
274
-
275
- if ( $typenow != 'wpm-testimonial' ) {
276
- return;
277
- }
278
-
279
- $taxonomies = array( 'wpm-testimonial-category' );
280
-
281
- foreach ( $taxonomies as $tax ) {
282
- $tax_obj = get_taxonomy( $tax );
283
- $args = array(
284
- 'show_option_all' => $tax_obj->labels->all_items,
285
- 'show_option_none' => '',
286
- 'option_none_value' => '-1',
287
- 'orderby' => 'NAME',
288
- 'order' => 'ASC',
289
- 'show_count' => 1,
290
- 'hide_empty' => 1,
291
- 'child_of' => 0,
292
- 'exclude' => '',
293
- 'echo' => 1,
294
- 'selected' => isset( $_GET[ $tax ] ) ? sanitize_text_field( $_GET[ $tax ] ) : '',
295
- 'hierarchical' => 1,
296
- 'name' => $tax,
297
- 'id' => $tax,
298
- 'class' => 'postform',
299
- 'depth' => 0,
300
- 'tab_index' => 0,
301
- 'taxonomy' => $tax,
302
- 'hide_if_empty' => true,
303
- 'value_field' => 'slug',
304
- );
305
-
306
- wp_dropdown_categories( $args );
307
- }
308
- }
309
-
310
- /**
311
- * Sort columns.
312
- *
313
- * @since 1.12.0
314
- *
315
- * @param $query
316
- */
317
- public static function pre_get_posts( $query ) {
318
- // Only in main WP query AND if an orderby query variable is designated.
319
- if ( is_admin() && $query->is_main_query() && 'wpm-testimonial' == $query->get( 'post_type' ) ) {
320
- if ( 'client_name' == $query->get( 'orderby' ) ) {
321
- $query->set( 'meta_key', 'client_name' );
322
- $query->set( 'orderby', 'meta_value' );
323
- }
324
- }
325
- }
326
-
327
- /**
328
- * Check if we are viewing the Trash.
329
- *
330
- * @since 1.16.0
331
- */
332
- public static function is_viewing_trash() {
333
- return isset( $_GET['post_status'] ) && 'trash' == $_GET['post_status'];
334
- }
335
-
336
- /**
337
- * Check if a column in admin list table is sorted.
338
- *
339
- * @since 1.16.0
340
- */
341
- public static function is_column_sorted() {
342
- return isset( $_GET['orderby'] ) || strstr( $_SERVER['REQUEST_URI'], 'action=edit' ) || strstr( $_SERVER['REQUEST_URI'], 'wp-admin/post-new.php' );
343
- }
344
-
345
- }
346
-
347
- Strong_Testimonials_Admin_List::init();
1
+ <?php
2
+ /**
3
+ * Class Strong_Testimonials_Admin_List
4
+ *
5
+ * @since 2.28.0
6
+ */
7
+ class Strong_Testimonials_Admin_List {
8
+
9
+ /**
10
+ * Strong_Testimonials_Admin_List constructor.
11
+ */
12
+ public function __construct() {}
13
+
14
+ /**
15
+ * Initialize.
16
+ */
17
+ public static function init() {
18
+ self::add_actions();
19
+ }
20
+
21
+ /**
22
+ * Add actions and filters.
23
+ */
24
+ public static function add_actions() {
25
+ add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ) );
26
+ add_filter( 'manage_wpm-testimonial_posts_columns', array( __CLASS__, 'add_thumbnail_column' ) );
27
+ add_filter( 'manage_edit-wpm-testimonial_columns', array( __CLASS__, 'edit_columns' ) );
28
+ add_action( 'restrict_manage_posts', array( __CLASS__, 'add_taxonomy_filters' ) );
29
+ add_filter( 'manage_edit-wpm-testimonial_sortable_columns', array( __CLASS__, 'manage_sortable_columns' ) );
30
+ add_action( 'manage_wpm-testimonial_posts_custom_column', array( __CLASS__, 'custom_columns' ) );
31
+ add_filter( 'post_row_actions', array( __CLASS__, 'post_row_actions' ), 10, 2 );
32
+ }
33
+
34
+ /**
35
+ * Add post ID to post row actions.
36
+ *
37
+ * @param $actions
38
+ * @param $post
39
+ * @since 2.32.2
40
+ *
41
+ * @return array
42
+ */
43
+ public static function post_row_actions( $actions, $post ) {
44
+ if ( 'wpm-testimonial' == $post->post_type ) {
45
+ $actions = array( 'id' => '<span>ID: ' . $post->ID . '</span>' ) + $actions;
46
+ }
47
+
48
+ return $actions;
49
+ }
50
+
51
+ /**
52
+ * Add custom columns to the admin list.
53
+ *
54
+ * @param $columns
55
+ *
56
+ * @since 1.4.0
57
+ * @since 2.5.1 Added comments column.
58
+ *
59
+ * @return array
60
+ */
61
+ public static function edit_columns( $columns ) {
62
+ $fields = wpmtst_get_all_fields();
63
+
64
+ $comments = isset( $columns['comments'] ) ? $columns['comments'] : '';
65
+
66
+ /*
67
+ INCOMING COLUMNS = Array (
68
+ [cb] => <input type="checkbox" />
69
+ [title] => Title
70
+ [comments] => <span class="vers comment-grey-bubble" title="Comments"><span class="screen-reader-text">Comments</span></span>
71
+ [date] => Date
72
+ [search_exclude] => Search Exclude // other plugin
73
+ [strong_thumbnail] => Thumbnail
74
+ )
75
+ */
76
+
77
+ // 1. remove [thumbnail] (may be re-added in custom field loop) and [date]
78
+ unset( $columns['strong_thumbnail'], $columns['date'] );
79
+
80
+ if ( $comments ) {
81
+ unset( $columns['comments'] );
82
+ }
83
+
84
+ // 2. insert [order] after [cb]
85
+ if ( ! self::is_column_sorted() && ! self::is_viewing_trash() && class_exists( 'Strong_Testimonials_Order' ) ) {
86
+ $columns = array_merge(
87
+ array_slice( $columns, 0, 1 ),
88
+ array( 'handle' => 'Order' ),
89
+ array_slice( $columns, 1, null )
90
+ );
91
+ }
92
+
93
+ // 3. insert [excerpt] after [title]
94
+ $key = 'title';
95
+ $offset = array_search( $key, array_keys( $columns ) ) + 1;
96
+ $fields_to_add = array( 'post_excerpt' => esc_html__( 'Excerpt', 'strong-testimonials' ) );
97
+
98
+ // 4. add custom fields
99
+ foreach ( $fields as $key => $field ) {
100
+
101
+ if ( isset( $field['admin_table'] ) ) {
102
+
103
+ if ( 'post_title' == $field['name'] ) {
104
+ continue;
105
+ } elseif ( 'featured_image' == $field['name'] ) {
106
+ $fields_to_add['strong_thumbnail'] = esc_html__( 'Thumbnail', 'strong-testimonials' );
107
+ } elseif ( 'rating' == $field['input_type'] ) {
108
+ $fields_to_add[ $field['name'] ] = esc_html__( 'Rating', 'strong-testimonials' );
109
+ } else {
110
+ $fields_to_add[ $field['name'] ] = apply_filters( 'wpmtst_l10n', $field['label'], 'strong-testimonials-form-fields', $field['name'] . ' : label' );
111
+ }
112
+
113
+ }
114
+
115
+ }
116
+
117
+ // 5. add [category], [comments] and [date]
118
+ // The slug "categories" slug is reserved by WordPress.
119
+ if ( wpmtst_get_cat_count() ) {
120
+ $fields_to_add['category'] = esc_html__( 'Categories', 'strong-testimonials' );
121
+ }
122
+
123
+ if ( $comments ) {
124
+ $fields_to_add['comments'] = $comments;
125
+ }
126
+
127
+ $fields_to_add['date'] = esc_html__( 'Date', 'strong-testimonials' );
128
+
129
+ $options = get_option( 'wpmtst_options' );
130
+ if ( isset( $options['include_platform'] ) && $options['include_platform'] === true ) {
131
+ $fields_to_add['platform'] = esc_html__( 'Platform', 'strong-testimonials' );
132
+ }
133
+
134
+ // Push other added columns like [search_exclude] to the end.
135
+ $columns = array_merge(
136
+ array_slice( $columns, 0, $offset ),
137
+ $fields_to_add,
138
+ array_slice( $columns, $offset, null )
139
+ );
140
+
141
+ return $columns;
142
+ }
143
+
144
+ /**
145
+ * Show custom values
146
+ *
147
+ * @param $column
148
+ */
149
+ public static function custom_columns( $column ) {
150
+ global $post;
151
+
152
+ switch ( $column ) {
153
+
154
+ case 'post_id' :
155
+ echo absint( $post->ID );
156
+ break;
157
+
158
+ case 'post_content' :
159
+ echo substr( $post->post_content, 0, 100 ) . '&hellip;';
160
+ break;
161
+
162
+ case 'post_excerpt' :
163
+ echo $post->post_excerpt;
164
+ break;
165
+
166
+ case 'strong_thumbnail' :
167
+ echo wpmtst_get_thumbnail( array( 60, 60 ) );
168
+ break;
169
+
170
+ case 'category' :
171
+ $categories = get_the_terms( 0, 'wpm-testimonial-category' );
172
+ if ( $categories && ! is_wp_error( $categories ) ) {
173
+ $list = array();
174
+ foreach ( $categories as $cat ) {
175
+ $list[] = $cat->name;
176
+ }
177
+ echo implode( ", ", $list );
178
+ }
179
+ break;
180
+
181
+ case 'handle' :
182
+ if ( current_user_can( 'edit_post', $post->ID ) && ! self::is_column_sorted() && ! self::is_viewing_trash() ) {
183
+ echo '<div class="handle"><div class="help"></div><div class="help-in-motion"></div></div>';
184
+ }
185
+ break;
186
+
187
+ case 'platform':
188
+ $platform = get_post_meta( $post->ID, 'platform', true );
189
+
190
+ if ( $platform ) {
191
+ ?>
192
+ <img title="<?php echo esc_attr( __( 'posted on ', 'strong-testimonials' ) . $platform ); ?>" width="26" height="26" src="<?php esc_attr_e( WPMTST_ASSETS_IMG ); ?>/platform_icons/<?php esc_attr_e( $platform ); ?>.svg"/>
193
+ <?php
194
+ }
195
+
196
+ break;
197
+
198
+ default :
199
+ // custom field?
200
+ $custom = get_post_custom();
201
+ $fields = wpmtst_get_custom_fields();
202
+
203
+ if ( isset( $custom[ $column ] ) && $custom[ $column ][0] ) {
204
+
205
+ if ( isset( $fields[ $column ] ) ) {
206
+
207
+ switch ( $fields[ $column ]['input_type'] ) {
208
+ case 'rating' :
209
+ wpmtst_star_rating_display( $custom[ $column ][0], 'in-table-list' );
210
+ break;
211
+ case 'checkbox' :
212
+ echo $custom[ $column ][0] ? 'yes' : 'no';
213
+ break;
214
+ default :
215
+ echo $custom[ $column ][0];
216
+ }
217
+
218
+ }
219
+
220
+ } else {
221
+
222
+ if ( isset( $fields[ $column ] ) ) {
223
+
224
+ if ( 'checkbox' == $fields[ $column ]['input_type'] ) {
225
+ echo 'no';
226
+ } else {
227
+ // display nothing
228
+ }
229
+
230
+ }
231
+ }
232
+
233
+ }
234
+ }
235
+
236
+ /**
237
+ * Add thumbnail column to admin list
238
+ *
239
+ * @param $columns
240
+ *
241
+ * @return array
242
+ */
243
+ public static function add_thumbnail_column( $columns ) {
244
+ $columns['strong_thumbnail'] = esc_html__( 'Thumbnail', 'strong-testimonials' );
245
+
246
+ return $columns;
247
+ }
248
+
249
+ /**
250
+ * Make columns sortable.
251
+ *
252
+ * @param $columns
253
+ *
254
+ * @since 1.12.0
255
+ * @since 2.2.0 category
256
+ *
257
+ * @return mixed
258
+ */
259
+ public static function manage_sortable_columns( $columns ) {
260
+ $columns['client_name'] = 'client_name';
261
+ $columns['category'] = 'categories';
262
+ $columns['date'] = 'date';
263
+
264
+ return $columns;
265
+ }
266
+
267
+ /**
268
+ * Add category filter to testimonial list table.
269
+ *
270
+ * @since 2.2.0
271
+ */
272
+ public static function add_taxonomy_filters() {
273
+ global $typenow;
274
+
275
+ if ( $typenow != 'wpm-testimonial' ) {
276
+ return;
277
+ }
278
+
279
+ $taxonomies = array( 'wpm-testimonial-category' );
280
+
281
+ foreach ( $taxonomies as $tax ) {
282
+ $tax_obj = get_taxonomy( $tax );
283
+ $args = array(
284
+ 'show_option_all' => $tax_obj->labels->all_items,
285
+ 'show_option_none' => '',
286
+ 'option_none_value' => '-1',
287
+ 'orderby' => 'NAME',
288
+ 'order' => 'ASC',
289
+ 'show_count' => 1,
290
+ 'hide_empty' => 1,
291
+ 'child_of' => 0,
292
+ 'exclude' => '',
293
+ 'echo' => 1,
294
+ 'selected' => isset( $_GET[ $tax ] ) ? sanitize_text_field( $_GET[ $tax ] ) : '',
295
+ 'hierarchical' => 1,
296
+ 'name' => $tax,
297
+ 'id' => $tax,
298
+ 'class' => 'postform',
299
+ 'depth' => 0,
300
+ 'tab_index' => 0,
301
+ 'taxonomy' => $tax,
302
+ 'hide_if_empty' => true,
303
+ 'value_field' => 'slug',
304
+ );
305
+
306
+ wp_dropdown_categories( $args );
307
+ }
308
+ }
309
+
310
+ /**
311
+ * Sort columns.
312
+ *
313
+ * @since 1.12.0
314
+ *
315
+ * @param $query
316
+ */
317
+ public static function pre_get_posts( $query ) {
318
+ // Only in main WP query AND if an orderby query variable is designated.
319
+ if ( is_admin() && $query->is_main_query() && 'wpm-testimonial' == $query->get( 'post_type' ) ) {
320
+ if ( 'client_name' == $query->get( 'orderby' ) ) {
321
+ $query->set( 'meta_key', 'client_name' );
322
+ $query->set( 'orderby', 'meta_value' );
323
+ }
324
+ }
325
+ }
326
+
327
+ /**
328
+ * Check if we are viewing the Trash.
329
+ *
330
+ * @since 1.16.0
331
+ */
332
+ public static function is_viewing_trash() {
333
+ return isset( $_GET['post_status'] ) && 'trash' == $_GET['post_status'];
334
+ }
335
+
336
+ /**
337
+ * Check if a column in admin list table is sorted.
338
+ *
339
+ * @since 1.16.0
340
+ */
341
+ public static function is_column_sorted() {
342
+ return isset( $_GET['orderby'] ) || strstr( $_SERVER['REQUEST_URI'], 'action=edit' ) || strstr( $_SERVER['REQUEST_URI'], 'wp-admin/post-new.php' );
343
+ }
344
+
345
+ }
346
+
347
+ Strong_Testimonials_Admin_List::init();
admin/class-strong-testimonials-admin-scripts.php CHANGED
@@ -1,420 +1,420 @@
1
- <?php
2
- /**
3
- * Class Strong_Testimonials_Admin_Scripts
4
- */
5
- class Strong_Testimonials_Admin_Scripts {
6
-
7
- /**
8
- * Strong_Testimonials_Admin_Scripts constructor.
9
- */
10
- public function __construct() {}
11
-
12
- /**
13
- * Initialize.
14
- */
15
- public static function init() {
16
- self::add_actions();
17
- }
18
-
19
- /**
20
- * Add actions and filters.
21
- */
22
- public static function add_actions() {
23
- add_action( 'admin_init', array( __CLASS__, 'admin_register' ) );
24
- add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_dequeue_scripts' ), 500 );
25
- add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_enqueue_scripts' ) );
26
-
27
- add_action( 'admin_print_styles-wpm-testimonial_page_testimonial-views', array( __CLASS__, 'admin_views' ) );
28
- add_action( 'admin_print_styles-wpm-testimonial_page_testimonial-fields', array( __CLASS__, 'admin_fields' ) );
29
- add_action( 'admin_print_styles-wpm-testimonial_page_testimonial-settings', array( __CLASS__, 'admin_settings' ) );
30
- add_action( 'admin_print_styles-wpm-testimonial_page_about-strong-testimonials', array( __CLASS__, 'admin_about' ) );
31
- add_action( 'admin_print_styles-wpm-testimonial_page_testimonial-shortcodes', array( __CLASS__, 'admin_shortcodes' ) );
32
-
33
- add_action( 'load-edit.php', array( __CLASS__, 'admin_load_edit' ) );
34
- add_action( 'load-post.php', array( __CLASS__, 'admin_load_post' ) );
35
- add_action( 'load-post-new.php', array( __CLASS__, 'admin_load_post' ) );
36
- add_action( 'load-edit-tags.php', array( __CLASS__, 'admin_load_edit_tags' ) );
37
- }
38
-
39
- /**
40
- * Register admin scripts.
41
- */
42
- public static function admin_register() {
43
-
44
- $plugin_version = get_option( 'wpmtst_plugin_version' );
45
-
46
- $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
47
-
48
- wp_register_script( 'wpmtst-help',
49
- WPMTST_ADMIN_URL . 'js/help.js',
50
- array( 'jquery' ),
51
- $plugin_version,
52
- true );
53
-
54
-
55
- wp_register_script(
56
- 'wpmtst-admin-script',
57
- WPMTST_ASSETS_JS . 'admin-js.js',
58
- array( 'jquery', 'underscore' ),
59
- $plugin_version,
60
- true );
61
-
62
- wp_register_style(
63
- 'wpmtst-admin-global-style',
64
- WPMTST_ASSETS_CSS . 'admin-global.css',
65
- array(),
66
- $plugin_version );
67
-
68
- wp_register_style(
69
- 'wpmtst-admin-style',
70
- WPMTST_ASSETS_CSS . 'admin.css',
71
- array( ),
72
- $plugin_version );
73
-
74
- wp_register_style( 'wpmtst-post-editor',
75
- WPMTST_ADMIN_URL . 'css/post-editor.css',
76
- array( ),
77
- $plugin_version );
78
-
79
- wp_register_style( 'wpmtst-lite-vs-pro',
80
- WPMTST_ADMIN_URL . 'css/lite-vs-pro.css',
81
- array( ),
82
- $plugin_version );
83
-
84
- wp_register_script( 'wpmtst-custom-spinner',
85
- WPMTST_ADMIN_URL . 'js/custom-spinner.js',
86
- array( 'jquery' ),
87
- $plugin_version,
88
- true );
89
-
90
- wp_register_script( 'autosize',
91
- WPMTST_ADMIN_URL . 'js/lib/autosize/autosize.min.js',
92
- array(),
93
- '4.0.1',
94
- true );
95
-
96
- /**
97
- * Form tab
98
- */
99
- wp_register_style( 'wpmtst-admin-form-style',
100
- WPMTST_ADMIN_URL . 'css/admin-form.css',
101
- array( 'wpmtst-admin-style' ),
102
- $plugin_version );
103
-
104
- wp_register_script( 'wpmtst-admin-form-script',
105
- WPMTST_ADMIN_URL . 'js/admin-form.js',
106
- array( 'wpmtst-admin-script', 'autosize' ),
107
- $plugin_version,
108
- true );
109
-
110
- /**
111
- * Compatibility tab
112
- */
113
- wp_register_style( 'wpmtst-admin-compat-style',
114
- WPMTST_ADMIN_URL . 'css/admin-compat.css',
115
- array(),
116
- $plugin_version );
117
-
118
- wp_register_script( 'wpmtst-admin-compat-script',
119
- WPMTST_ADMIN_URL . 'js/admin-compat.js',
120
- array( 'jquery', 'wpmtst-custom-spinner', 'wpmtst-help' ),
121
- $plugin_version,
122
- true );
123
-
124
- /**
125
- * Fields
126
- */
127
- wp_register_style( 'wpmtst-admin-fields-style',
128
- WPMTST_ADMIN_URL . 'css/fields.css',
129
- array(),
130
- $plugin_version );
131
-
132
- wp_register_style( 'wpmtst-admin-form-preview',
133
- WPMTST_ADMIN_URL . 'css/form-preview.css',
134
- array(),
135
- $plugin_version );
136
-
137
- wp_register_script( 'wpmtst-admin-fields-script',
138
- WPMTST_ADMIN_URL . 'js/admin-fields.js',
139
- array( 'jquery', 'jquery-ui-sortable', 'wpmtst-help' ),
140
- $plugin_version,
141
- true );
142
-
143
- $params = array(
144
- 'ajax_nonce' => wp_create_nonce( 'wpmtst-admin' ),
145
- 'newField' => esc_html_x( 'New Field', 'Field editor: The default label for new fields', 'strong-testimonials' ),
146
- 'inUse' => esc_html_x( '(in use)', 'Fields editor: To indicate when a field type can only be used once.', 'strong-testimonials' ),
147
- 'noneFound' => esc_html_x( '(none found)', 'Fields editor: To indicate when no categories have been found.', 'strong-testimonials' ),
148
- );
149
- wp_localize_script( 'wpmtst-admin-fields-script', 'wpmtstAdmin', $params );
150
-
151
- /**
152
- * Ratings
153
- */
154
- wp_register_style( 'wpmtst-rating-display',
155
- WPMTST_PUBLIC_URL . 'css/rating-display.css',
156
- array( ),
157
- $plugin_version );
158
-
159
- wp_register_style( 'wpmtst-rating-form',
160
- WPMTST_PUBLIC_URL . 'css/rating-form.css',
161
- array( ),
162
- $plugin_version );
163
-
164
- wp_register_script( 'wpmtst-rating-script',
165
- WPMTST_ADMIN_URL . 'js/rating-edit.js',
166
- array( 'jquery' ),
167
- $plugin_version,
168
- true );
169
-
170
- /**
171
- * Views
172
- */
173
- wp_register_style( 'wpmtst-admin-views-style',
174
- WPMTST_ADMIN_URL . 'css/views.css',
175
- array(),
176
- $plugin_version );
177
-
178
- wp_register_script( 'wpmtst-admin-views-script',
179
- WPMTST_ADMIN_URL . 'js/views.js',
180
- array( 'jquery', 'jquery-ui-sortable', 'wp-color-picker', 'jquery-masonry', 'wpmtst-help' ),
181
- $plugin_version,
182
- true );
183
-
184
- /**
185
- * Category filter in View editor.
186
- *
187
- * JavaScript adapted under GPL-2.0+ license
188
- * from Post Category Filter plugin by Javier Villanueva (http://www.jahvi.com)
189
- *
190
- * @since 2.2.0
191
- */
192
- wp_register_script( 'wpmtst-view-category-filter-script',
193
- WPMTST_ADMIN_URL . 'js/view-category-filter.js',
194
- array( 'jquery' ),
195
- $plugin_version,
196
- true );
197
-