|
9 | 9 |
|
10 | 10 | namespace WebberZone\Knowledge_Base; |
11 | 11 |
|
12 | | -use WebberZone\Knowledge_Base\Util\Hook_Registry; |
13 | | - |
14 | 12 | if ( ! defined( 'WPINC' ) ) { |
15 | 13 | die; |
16 | 14 | } |
@@ -46,22 +44,13 @@ class Options_API { |
46 | 44 | */ |
47 | 45 | private static $settings; |
48 | 46 |
|
49 | | - /** |
50 | | - * Initialize hooks for AJAX functionality. |
51 | | - * |
52 | | - * @since 3.0.0 |
53 | | - */ |
54 | | - public static function init() { |
55 | | - Hook_Registry::add_action( 'wp_ajax_' . self::FILTER_PREFIX . '_tags_search', array( __CLASS__, 'tags_search' ) ); |
56 | | - } |
57 | | - |
58 | 47 | /** |
59 | 48 | * Get Settings. |
60 | 49 | * |
61 | 50 | * Retrieves all plugin settings |
62 | 51 | * |
63 | 52 | * @since 3.0.0 |
64 | | - * @return array Glue Link settings |
| 53 | + * @return array Settings array |
65 | 54 | */ |
66 | 55 | public static function get_settings() { |
67 | 56 | $settings = get_option( self::SETTINGS_OPTION ); |
@@ -188,7 +177,7 @@ public static function update_settings( array $settings, bool $merge = true, boo |
188 | 177 | /** |
189 | 178 | * Remove an option |
190 | 179 | * |
191 | | - * Removes a Glue Link setting value in both the db and the static variable. |
| 180 | + * Removes a setting value in both the db and the static variable. |
192 | 181 | * |
193 | 182 | * @since 3.0.0 |
194 | 183 | * |
@@ -265,68 +254,4 @@ public static function reset_settings(): bool { |
265 | 254 |
|
266 | 255 | return $did_update; |
267 | 256 | } |
268 | | - |
269 | | - /** |
270 | | - * Function to add an action to search for tags using Ajax. |
271 | | - * |
272 | | - * @since 3.0.0 |
273 | | - * |
274 | | - * @return void |
275 | | - */ |
276 | | - public static function tags_search() { |
277 | | - if ( ! isset( $_REQUEST['tax'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
278 | | - wp_die(); |
279 | | - } |
280 | | - |
281 | | - $taxonomy = sanitize_key( $_REQUEST['tax'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
282 | | - $tax = get_taxonomy( $taxonomy ); |
283 | | - if ( ! empty( $taxonomy ) ) { |
284 | | - $tax = get_taxonomy( $taxonomy ); |
285 | | - if ( ! $tax ) { |
286 | | - wp_die(); |
287 | | - } |
288 | | - |
289 | | - if ( ! current_user_can( $tax->cap->assign_terms ) ) { |
290 | | - wp_die(); |
291 | | - } |
292 | | - } |
293 | | - |
294 | | - $s = isset( $_REQUEST['q'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['q'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
295 | | - |
296 | | - $comma = _x( ',', 'tag delimiter', 'knowledgebase' ); |
297 | | - if ( ',' !== $comma ) { |
298 | | - $s = str_replace( $comma, ',', $s ); |
299 | | - } |
300 | | - if ( false !== strpos( $s, ',' ) ) { |
301 | | - $s = explode( ',', $s ); |
302 | | - $s = $s[ count( $s ) - 1 ]; |
303 | | - } |
304 | | - $s = trim( $s ); |
305 | | - |
306 | | - /** This filter has been defined in /wp-admin/includes/ajax-actions.php */ |
307 | | - $term_search_min_chars = (int) apply_filters( 'term_search_min_chars', 2, $tax, $s ); |
308 | | - |
309 | | - /* |
310 | | - * Require $term_search_min_chars chars for matching (default: 2) |
311 | | - * ensure it's a non-negative, non-zero integer. |
312 | | - */ |
313 | | - if ( ( 0 === $term_search_min_chars ) || ( strlen( $s ) < $term_search_min_chars ) ) { |
314 | | - wp_die(); |
315 | | - } |
316 | | - |
317 | | - $results = get_terms( |
318 | | - array( |
319 | | - 'taxonomy' => $taxonomy, |
320 | | - 'name__like' => $s, |
321 | | - 'fields' => 'names', |
322 | | - 'hide_empty' => false, |
323 | | - ) |
324 | | - ); |
325 | | - |
326 | | - echo wp_json_encode( $results ); |
327 | | - wp_die(); |
328 | | - } |
329 | 257 | } |
330 | | - |
331 | | -// Initialize hooks. |
332 | | -Options_API::init(); |
0 commit comments