PluginProbe ʕ •ᴥ•ʔ
Strong Testimonials / 3.2.2
Strong Testimonials v3.2.2
3.3.3 3.3.2 3.3.1 trunk 1.0.1 2.30.9 2.31.10 2.32 2.32.1 2.32.2 2.32.3 2.32.4 2.33 2.34 2.35 2.36 2.37 2.38 2.38.1 2.39 2.39.1 2.39.2 2.39.3 2.40.0 2.40.1 2.40.2 2.40.3 2.40.4 2.40.5 2.40.6 2.40.7 2.41.0 2.41.1 2.50.0 2.50.1 2.50.2 2.50.3 2.50.4 2.51.0 2.51.1 2.51.2 2.51.3 2.51.4 2.51.5 2.51.6 2.51.7 2.51.8 2.51.9 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.17 3.2.18 3.2.19 3.2.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0
strong-testimonials / admin / admin.php
strong-testimonials / admin Last commit date
challenge 1 year ago css 1 year ago img 1 year ago js 1 year ago menu 1 year ago partials 1 year ago scss 1 year ago settings 1 year ago uninstall 1 year ago admin-notices.php 1 year ago admin.php 1 year ago class-strong-testimonials-addons.php 1 year ago class-strong-testimonials-admin-category-list.php 1 year ago class-strong-testimonials-admin-list.php 1 year ago class-strong-testimonials-admin-scripts.php 1 year ago class-strong-testimonials-debug.php 1 year ago class-strong-testimonials-defaults.php 1 year ago class-strong-testimonials-exporter.php 1 year ago class-strong-testimonials-help.php 1 year ago class-strong-testimonials-helper.php 1 year ago class-strong-testimonials-list-table.php 1 year ago class-strong-testimonials-lite-vs-pro-page.php 1 year ago class-strong-testimonials-page-shortcodes.php 1 year ago class-strong-testimonials-post-editor.php 1 year ago class-strong-testimonials-review.php 1 year ago class-strong-testimonials-updater.php 1 year ago class-strong-testimonials-upsell.php 1 year ago class-strong-testimonials-wpchill-upsells.php 1 year ago class-strong-views-list-table.php 1 year ago class-walker-strong-category-checklist.php 1 year ago class-walker-strong-form-category-checklist.php 1 year ago class-wpmtst-admin-helpers.php 1 year ago class-wpmtst-onboarding.php 1 year ago compat.php 1 year ago custom-fields-ajax.php 1 year ago custom-fields.php 1 year ago form-preview.php 1 year ago view-list-order.php 1 year ago views-ajax.php 1 year ago views-validate.php 1 year ago views.php 1 year ago
admin.php
320 lines
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( wp_kses_post( _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 /* translators: %s is the URL to the "Plugins" page in WordPress. */
25 $message .= '<p>' . sprintf( wp_kses_post( _x( 'Back to the WordPress <a href="%s">Plugins page</a>', 'installation', 'strong-testimonials' ) ), esc_url( get_admin_url( null, 'plugins.php' ) ) ) . '</p>';
26 wp_die( $message );
27 }
28 }
29
30 add_action( 'admin_init', 'wpmtst_version_check', 1 );
31
32 /**
33 * Check for plugin update.
34 *
35 * @since 2.28.4 Before other admin_init actions.
36 */
37 function wpmtst_update_check() {
38 $version = get_option( 'wpmtst_plugin_version', false );
39 if ( WPMTST_VERSION === $version ) {
40 return;
41 }
42
43 Strong_Testimonials_Updater::update();
44 }
45
46 add_action( 'admin_init', 'wpmtst_update_check', 5 );
47
48 /**
49 * Initialize.
50 */
51 function wpmtst_admin_init() {
52
53 /**
54 * Custom action hooks
55 *
56 * @since 1.18.4
57 */
58 if ( isset( $_REQUEST['action'] ) && '' !== $_REQUEST['action'] ) {
59 $action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) );
60 do_action( 'wpmtst_' . $action );
61 }
62 }
63
64 add_action( 'admin_init', 'wpmtst_admin_init' );
65
66 /**
67 * Custom action link in admin notice.
68 *
69 * @since 2.29.0
70 */
71 function wpmtst_action_captcha_options_changed() {
72 wpmtst_delete_admin_notice( 'captcha-options-changed' );
73 wp_redirect( admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-settings&tab=form#captcha-section' ) );
74 exit;
75 }
76
77 add_action( 'admin_action_captcha-options-changed', 'wpmtst_action_captcha_options_changed' );
78
79 /**
80 * Are we on a testimonial admin screen?
81 *
82 * Used by add-ons too!
83 *
84 * @return bool
85 */
86 function wpmtst_is_testimonial_screen() {
87 $screen = get_current_screen();
88 return ( $screen && 'wpm-testimonial' === $screen->post_type );
89 }
90
91 /**
92 * Add pending numbers to post types on admin menu.
93 * Thanks http://wordpress.stackexchange.com/a/105470/32076
94 *
95 * @param $menu
96 *
97 * @return mixed
98 */
99 function wpmtst_pending_indicator( $menu ) {
100 if ( ! current_user_can( 'edit_posts' ) ) {
101 return $menu;
102 }
103
104 $options = get_option( 'wpmtst_options' );
105 if ( ! isset( $options['pending_indicator'] ) || ! $options['pending_indicator'] ) {
106 return $menu;
107 }
108
109 $types = array( 'wpm-testimonial' );
110 $status = 'pending';
111 foreach ( $types as $type ) {
112 $num_posts = wp_count_posts( $type, 'readable' );
113 $pending_count = 0;
114 if ( ! empty( $num_posts->$status ) ) {
115 $pending_count = $num_posts->$status;
116 }
117
118 if ( 'post' === $type ) {
119 $menu_str = 'edit.php';
120 } else {
121 $menu_str = 'edit.php?post_type=' . $type;
122 }
123 foreach ( $menu as $menu_key => $menu_data ) {
124 if ( $menu_str !== $menu_data[2] ) {
125 continue;
126 }
127
128 $menu[ $menu_key ][0] .= " <span class='update-plugins count-$pending_count'><span class='plugin-count'>" . number_format_i18n( $pending_count ) . '</span></span>';
129 }
130 }
131
132 return $menu;
133 }
134 add_filter( 'add_menu_classes', 'wpmtst_pending_indicator' );
135
136 /**
137 * The [restore default] icon.
138 *
139 * @param $for
140 *
141 * @since 2.18.0
142 */
143 function wpmtst_restore_default_icon( $input_for ) {
144 if ( ! $input_for ) {
145 return;
146 }
147 ?>
148 <input type="button" class="button secondary restore-default"
149 title="<?php esc_html_e( 'restore default', 'strong-testimonials' ); ?>"
150 value="&#xf171"
151 data-for="<?php echo esc_attr( $input_for ); ?>"/>
152 <?php
153 }
154
155
156
157 /**
158 * Check for configuration issues when options are updated.
159 *
160 * @since 2.24.0
161 * @param $option
162 * @param $old_value
163 * @param $value
164 */
165 function wpmtst_updated_option( $option, $old_value, $value ) {
166 if ( 'wpmtst_' === substr( $option, 0, 7 ) ) {
167 do_action( 'wpmtst_check_config' );
168 }
169 }
170 add_action( 'updated_option', 'wpmtst_updated_option', 10, 3 );
171
172
173 /**
174 * Store configuration error.
175 *
176 * @since 2.24.0
177 * @param $key
178 */
179 function wpmtst_add_config_error( $key ) {
180 $errors = get_option( 'wpmtst_config_errors', array() );
181 $errors[] = $key;
182 update_option( 'wpmtst_config_errors', array_unique( $errors ), 'no' );
183
184 wpmtst_add_admin_notice( $key, true );
185 }
186
187
188 /**
189 * Delete configuration error.
190 *
191 * @since 2.24.0
192 * @param $key
193 */
194 function wpmtst_delete_config_error( $key ) {
195 $errors = get_option( 'wpmtst_config_errors', array() );
196 $errors = array_diff( $errors, array( $key ) );
197 update_option( 'wpmtst_config_errors', $errors, 'no' );
198
199 wpmtst_delete_admin_notice( $key );
200 }
201
202
203 /**
204 * Save a View.
205 *
206 * @param $view
207 * @param string $action
208 * @usedby Strong_Testimonials_Update:update_views
209 *
210 * @return bool|false|int
211 */
212 function wpmtst_save_view( $view, $action = 'edit' ) {
213 global $wpdb;
214
215 if ( ! $view ) {
216 return false;
217 }
218
219 $table_name = $wpdb->prefix . 'strong_views';
220 $serialized = serialize( $view['data'] );
221
222 if ( 'add' === $action || 'duplicate' === $action ) {
223 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
224 $wpdb->query( $wpdb->prepare( "INSERT INTO {$table_name} (name, value) VALUES (%s, %s)", $view['name'], $serialized ) );
225 $view['id'] = $wpdb->insert_id;
226 $return = $view['id'];
227 } else {
228 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
229 $wpdb->query( $wpdb->prepare( "UPDATE {$table_name} SET name = %s, value = %s WHERE id = %d", $view['name'], $serialized, intval( $view['id'] ) ) );
230 $return = $wpdb->last_error ? 0 : 1;
231 }
232
233 do_action( 'wpmtst_view_saved', $view );
234
235 return $return;
236 }
237
238
239 /**
240 * @param $field
241 *
242 * @return mixed
243 */
244 function wpmtst_get_field_label( $field ) {
245 if ( isset( $field['field'] ) ) {
246 $custom_fields = wpmtst_get_custom_fields();
247 if ( isset( $custom_fields[ $field['field'] ]['label'] ) ) {
248 return $custom_fields[ $field['field'] ]['label'];
249 }
250 $builtin_fields = wpmtst_get_builtin_fields();
251 if ( isset( $builtin_fields[ $field['field'] ]['label'] ) ) {
252 return $builtin_fields[ $field['field'] ]['label'];
253 }
254 }
255
256 return '';
257 }
258
259 function wpmtst_get_field_text( $field ) {
260 if ( isset( $field['field'] ) ) {
261 $custom_fields = wpmtst_get_custom_fields();
262 if ( isset( $custom_fields[ $field['field'] ]['text'] ) ) {
263 return $custom_fields[ $field['field'] ]['text'];
264 }
265 $builtin_fields = wpmtst_get_builtin_fields();
266 if ( isset( $builtin_fields[ $field['field'] ]['text'] ) ) {
267 return $builtin_fields[ $field['field'] ]['text'];
268 }
269 }
270
271 return '';
272 }
273
274
275 /**
276 * @param string $field_name
277 *
278 * @return mixed
279 */
280 function wpmtst_get_field_by_name( $field_name = '' ) {
281 if ( $field_name ) {
282 $custom_fields = wpmtst_get_custom_fields();
283 if ( isset( $custom_fields[ $field_name ] ) ) {
284 return $custom_fields[ $field_name ];
285 }
286 }
287
288 return '';
289 }
290
291 /**
292 * Returns true if at least one extension is installed
293 */
294 function wpmtst_extensions_installed() {
295
296 if ( defined( 'WPMTST_CUSTOM_FIELDS_VERSION' ) ) {
297 return true;
298 }
299 if ( defined( 'WPMTST_ASSIGNMENT_VERSION' ) ) {
300 return true;
301 }
302 if ( defined( 'WPMTST_MULTIPLE_FORMS_VERSION' ) ) {
303 return true;
304 }
305 if ( defined( 'WPMTST_PROPERTIES_VERSION' ) ) {
306 return true;
307 }
308 if ( defined( 'WPMTST_COUNTRY_SELECTOR_VERSION' ) ) {
309 return true;
310 }
311 if ( defined( 'WPMTST_REVIEW_MARKUP_VERSION' ) ) {
312 return true;
313 }
314 if ( defined( 'WPMTST_ADVANCED_VIEWS_VERSION' ) ) {
315 return true;
316 }
317
318 return false;
319 }
320