PluginProbe ʕ •ᴥ•ʔ
Strong Testimonials / 3.2.7
Strong Testimonials v3.2.7
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 wpchill 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
276 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 * Are we on a testimonial admin screen?
68 *
69 * Used by add-ons too!
70 *
71 * @return bool
72 */
73 function wpmtst_is_testimonial_screen() {
74 $screen = get_current_screen();
75 return ( $screen && 'wpm-testimonial' === $screen->post_type );
76 }
77
78 /**
79 * Add pending numbers to post types on admin menu.
80 * Thanks http://wordpress.stackexchange.com/a/105470/32076
81 *
82 * @param $menu
83 *
84 * @return mixed
85 */
86 function wpmtst_pending_indicator( $menu ) {
87 if ( ! current_user_can( 'edit_posts' ) ) {
88 return $menu;
89 }
90
91 $options = get_option( 'wpmtst_options' );
92 if ( ! isset( $options['pending_indicator'] ) || ! $options['pending_indicator'] ) {
93 return $menu;
94 }
95
96 $types = array( 'wpm-testimonial' );
97 $status = 'pending';
98 foreach ( $types as $type ) {
99 $num_posts = wp_count_posts( $type, 'readable' );
100 $pending_count = 0;
101 if ( ! empty( $num_posts->$status ) ) {
102 $pending_count = $num_posts->$status;
103 }
104
105 if ( 'post' === $type ) {
106 $menu_str = 'edit.php';
107 } else {
108 $menu_str = 'edit.php?post_type=' . $type;
109 }
110 foreach ( $menu as $menu_key => $menu_data ) {
111 if ( $menu_str !== $menu_data[2] ) {
112 continue;
113 }
114
115 $menu[ $menu_key ][0] .= " <span class='update-plugins count-$pending_count'><span class='plugin-count'>" . number_format_i18n( $pending_count ) . '</span></span>';
116 }
117 }
118
119 return $menu;
120 }
121 add_filter( 'add_menu_classes', 'wpmtst_pending_indicator' );
122
123 /**
124 * The [restore default] icon.
125 *
126 * @param $for
127 *
128 * @since 2.18.0
129 */
130 function wpmtst_restore_default_icon( $input_for ) {
131 if ( ! $input_for ) {
132 return;
133 }
134 ?>
135 <input type="button" class="button secondary restore-default"
136 title="<?php esc_html_e( 'restore default', 'strong-testimonials' ); ?>"
137 value="&#xf171"
138 data-for="<?php echo esc_attr( $input_for ); ?>"/>
139 <?php
140 }
141
142
143
144 /**
145 * Check for configuration issues when options are updated.
146 *
147 * @since 2.24.0
148 * @param $option
149 * @param $old_value
150 * @param $value
151 */
152 function wpmtst_updated_option( $option, $old_value, $value ) {
153 if ( 'wpmtst_' === substr( $option, 0, 7 ) ) {
154 do_action( 'wpmtst_check_config' );
155 }
156 }
157 add_action( 'updated_option', 'wpmtst_updated_option', 10, 3 );
158
159 /**
160 * Save a View.
161 *
162 * @param $view
163 * @param string $action
164 * @usedby Strong_Testimonials_Update:update_views
165 *
166 * @return bool|false|int
167 */
168 function wpmtst_save_view( $view, $action = 'edit' ) {
169 global $wpdb;
170
171 if ( ! $view ) {
172 return false;
173 }
174
175 $table_name = $wpdb->prefix . 'strong_views';
176 $serialized = serialize( $view['data'] );
177
178 if ( 'add' === $action || 'duplicate' === $action ) {
179 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
180 $wpdb->query( $wpdb->prepare( "INSERT INTO {$table_name} (name, value) VALUES (%s, %s)", $view['name'], $serialized ) );
181 $view['id'] = $wpdb->insert_id;
182 $return = $view['id'];
183 } else {
184 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
185 $wpdb->query( $wpdb->prepare( "UPDATE {$table_name} SET name = %s, value = %s WHERE id = %d", $view['name'], $serialized, intval( $view['id'] ) ) );
186 $return = $wpdb->last_error ? 0 : 1;
187 }
188
189 do_action( 'wpmtst_view_saved', $view );
190
191 return $return;
192 }
193
194
195 /**
196 * @param $field
197 *
198 * @return mixed
199 */
200 function wpmtst_get_field_label( $field ) {
201 if ( isset( $field['field'] ) ) {
202 $custom_fields = wpmtst_get_custom_fields();
203 if ( isset( $custom_fields[ $field['field'] ]['label'] ) ) {
204 return $custom_fields[ $field['field'] ]['label'];
205 }
206 $builtin_fields = wpmtst_get_builtin_fields();
207 if ( isset( $builtin_fields[ $field['field'] ]['label'] ) ) {
208 return $builtin_fields[ $field['field'] ]['label'];
209 }
210 }
211
212 return '';
213 }
214
215 function wpmtst_get_field_text( $field ) {
216 if ( isset( $field['field'] ) ) {
217 $custom_fields = wpmtst_get_custom_fields();
218 if ( isset( $custom_fields[ $field['field'] ]['text'] ) ) {
219 return $custom_fields[ $field['field'] ]['text'];
220 }
221 $builtin_fields = wpmtst_get_builtin_fields();
222 if ( isset( $builtin_fields[ $field['field'] ]['text'] ) ) {
223 return $builtin_fields[ $field['field'] ]['text'];
224 }
225 }
226
227 return '';
228 }
229
230
231 /**
232 * @param string $field_name
233 *
234 * @return mixed
235 */
236 function wpmtst_get_field_by_name( $field_name = '' ) {
237 if ( $field_name ) {
238 $custom_fields = wpmtst_get_custom_fields();
239 if ( isset( $custom_fields[ $field_name ] ) ) {
240 return $custom_fields[ $field_name ];
241 }
242 }
243
244 return '';
245 }
246
247 /**
248 * Returns true if at least one extension is installed
249 */
250 function wpmtst_extensions_installed() {
251
252 if ( defined( 'WPMTST_CUSTOM_FIELDS_VERSION' ) ) {
253 return true;
254 }
255 if ( defined( 'WPMTST_ASSIGNMENT_VERSION' ) ) {
256 return true;
257 }
258 if ( defined( 'WPMTST_MULTIPLE_FORMS_VERSION' ) ) {
259 return true;
260 }
261 if ( defined( 'WPMTST_PROPERTIES_VERSION' ) ) {
262 return true;
263 }
264 if ( defined( 'WPMTST_COUNTRY_SELECTOR_VERSION' ) ) {
265 return true;
266 }
267 if ( defined( 'WPMTST_REVIEW_MARKUP_VERSION' ) ) {
268 return true;
269 }
270 if ( defined( 'WPMTST_ADVANCED_VIEWS_VERSION' ) ) {
271 return true;
272 }
273
274 return false;
275 }
276