PluginProbe ʕ •ᴥ•ʔ
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF / trunk
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF vtrunk
2.0.5 trunk 1.3.7 1.4.0 1.4.1 1.4.2 1.4.6 1.5.0 1.5.3 1.5.6 1.5.8 1.6.5 1.6.6 1.6.9 1.7.0 1.7.4 1.8.1 1.8.2 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4
robin-image-optimizer / libs / factory / templates / includes / class-search-options.php
robin-image-optimizer / libs / factory / templates / includes Last commit date
ajax-handlers.php 5 months ago class-configurate.php 5 months ago class-helpers.php 5 months ago class-search-options.php 5 months ago index.php 6 months ago
class-search-options.php
85 lines
1 <?php
2
3 namespace WBCR\Factory_Templates_759;
4
5 /**
6 * Class Search options
7 *
8 * Allows you to collect all the options from the plugin pages, is a registry of options.
9 *
10 * @since 2.2.0
11 */
12 class Search_Options {
13
14 private static $_all_options;
15
16 /**
17 * Registers page options in the options registry
18 *
19 * This will allow the user to search all the plugin options.
20 *
21 * @param array $options
22 * @param string $page_url
23 * @param string $page_id
24 * @since 2.2.0
25 */
26 public static function register_options( $options, $page_url, $page_id ) {
27 if ( empty( $options ) || ! is_array( $options ) ) {
28 return;
29 }
30
31 $extracted_options = static::recursive_extraxt_options( $options );
32
33 if ( ! empty( $extracted_options ) ) {
34 foreach ( (array) $extracted_options as $option ) {
35 if ( 'div' === $option['type'] || 'html' === $option['type'] || ! isset( $option['title'] ) ) {
36 continue;
37 }
38
39 $formated_option['title'] = $option['title'];
40
41 /*
42 if( isset($option['hint']) ) {
43 $formated_option['hint'] = $option['hint'];
44 }*/
45
46 $formated_option['page_url'] = $page_url . '#factory-control-' . $option['name'];
47 $formated_option['page_id'] = $page_id;
48
49 static::$_all_options[] = $formated_option;
50 }
51 }
52 }
53
54 /**
55 * Extracted options from a nested array
56 *
57 * @param array $options
58 * @return array
59 * @since 2.2.0
60 */
61 protected static function recursive_extraxt_options( $options ) {
62 $extracted_options = [];
63
64 foreach ( $options as $option ) {
65 if ( isset( $option['items'] ) ) {
66 $extracted_options = array_merge( $extracted_options, static::recursive_extraxt_options( $option['items'] ) );
67 } else {
68 $extracted_options[] = $option;
69 }
70 }
71
72 return $extracted_options;
73 }
74
75 /**
76 * Get all plugin options
77 *
78 * @return mixed
79 * @since 2.2.0
80 */
81 public static function get_all_options() {
82 return static::$_all_options;
83 }
84 }
85