@@ -56,7 +56,6 @@ |
||
56 | 56 | /** |
57 | 57 | * Get the value of the given settings |
58 | 58 | * |
59 | - * @param [array] $args |
|
60 | 59 | * @return void |
61 | 60 | */ |
62 | 61 | function amarkal_get_settings_value( $field_name ) |
@@ -13,15 +13,15 @@ discard block |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | // Prevent direct file access |
16 | -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
|
16 | +defined('ABSPATH') or die('No script kiddies please!'); |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Prevent loading the library more than once |
20 | 20 | */ |
21 | -if( defined( 'AMARKAL_SETTINGS' ) ) return false; |
|
22 | -define( 'AMARKAL_SETTINGS', true ); |
|
21 | +if (defined('AMARKAL_SETTINGS')) return false; |
|
22 | +define('AMARKAL_SETTINGS', true); |
|
23 | 23 | |
24 | -if(!function_exists('amarkal_add_settings_page')) |
|
24 | +if (!function_exists('amarkal_add_settings_page')) |
|
25 | 25 | { |
26 | 26 | /** |
27 | 27 | * Add a new top-level settings page |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | * @param [array] $args |
30 | 30 | * @return void |
31 | 31 | */ |
32 | - function amarkal_add_settings_page( $args ) |
|
32 | + function amarkal_add_settings_page($args) |
|
33 | 33 | { |
34 | 34 | $manager = Amarkal\Settings\Manager::get_instance(); |
35 | 35 | $manager->add_page($args); |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | -if(!function_exists('amarkal_add_settings_child_page')) |
|
39 | +if (!function_exists('amarkal_add_settings_child_page')) |
|
40 | 40 | { |
41 | 41 | /** |
42 | 42 | * Add a child page to an existing top-level settings page |
@@ -44,14 +44,14 @@ discard block |
||
44 | 44 | * @param [array] $args |
45 | 45 | * @return void |
46 | 46 | */ |
47 | - function amarkal_add_settings_child_page( $args ) |
|
47 | + function amarkal_add_settings_child_page($args) |
|
48 | 48 | { |
49 | 49 | $manager = Amarkal\Settings\Manager::get_instance(); |
50 | 50 | $manager->add_child_page($args); |
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | -if(!function_exists('amarkal_get_settings_value')) |
|
54 | +if (!function_exists('amarkal_get_settings_value')) |
|
55 | 55 | { |
56 | 56 | /** |
57 | 57 | * Get the value of the given settings |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param [array] $args |
60 | 60 | * @return void |
61 | 61 | */ |
62 | - function amarkal_get_settings_value( $field_name ) |
|
62 | + function amarkal_get_settings_value($field_name) |
|
63 | 63 | { |
64 | 64 | $manager = Amarkal\Settings\Manager::get_instance(); |
65 | 65 | return $manager->get_field_value($field_name); |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public static function get_instance() |
22 | 22 | { |
23 | - if( null === static::$instance ) |
|
23 | + if (null === static::$instance) |
|
24 | 24 | { |
25 | 25 | static::$instance = new static(); |
26 | 26 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public function add_page($args) |
37 | 37 | { |
38 | 38 | $slug = $args['slug']; |
39 | - if(array_key_exists($slug,$this->pages)) |
|
39 | + if (array_key_exists($slug, $this->pages)) |
|
40 | 40 | { |
41 | 41 | throw new \RuntimeException("A page with slug '$slug' has already been registered"); |
42 | 42 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function get_page($slug) |
54 | 54 | { |
55 | - if(!array_key_exists($slug,$this->pages)) |
|
55 | + if (!array_key_exists($slug, $this->pages)) |
|
56 | 56 | { |
57 | 57 | throw new \RuntimeException("The page '$slug' does not exist"); |
58 | 58 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | public function add_child_page($args) |
68 | 68 | { |
69 | 69 | $parent_slug = $args['parent_slug']; |
70 | - if(!array_key_exists($parent_slug, $this->child_pages)) |
|
70 | + if (!array_key_exists($parent_slug, $this->child_pages)) |
|
71 | 71 | { |
72 | 72 | $this->child_pages[$parent_slug] = array(); |
73 | 73 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function get_child_page($slug, $parent_slug) |
86 | 86 | { |
87 | - if(!array_key_exists($parent_slug, $this->child_pages) || |
|
87 | + if (!array_key_exists($parent_slug, $this->child_pages) || |
|
88 | 88 | !array_key_exists($slug, $this->child_pages[$parent_slug])) |
89 | 89 | { |
90 | 90 | throw new \RuntimeException("The child page '$slug' does not exist for the parent '$parent_slug'"); |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function get_field_value($field_name) |
102 | 102 | { |
103 | - foreach($this->child_pages as $parent_slug => $child_pages) |
|
103 | + foreach ($this->child_pages as $parent_slug => $child_pages) |
|
104 | 104 | { |
105 | 105 | try |
106 | 106 | { |
107 | 107 | return $this->get_field_value_for_parent($parent_slug, $field_name); |
108 | 108 | } |
109 | - catch(\RuntimeException $e) |
|
109 | + catch (\RuntimeException $e) |
|
110 | 110 | { |
111 | 111 | continue; |
112 | 112 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function get_field_value_for_parent($parent_slug, $field_name) |
127 | 127 | { |
128 | - foreach($this->child_pages[$parent_slug] as $cp) |
|
128 | + foreach ($this->child_pages[$parent_slug] as $cp) |
|
129 | 129 | { |
130 | 130 | try |
131 | 131 | { |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $value = \get_option($field_name, $component->default); |
134 | 134 | return $value; |
135 | 135 | } |
136 | - catch(\RuntimeException $e) |
|
136 | + catch (\RuntimeException $e) |
|
137 | 137 | { |
138 | 138 | continue; |
139 | 139 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | public function register_scripts() |
148 | 148 | { |
149 | 149 | \wp_register_style('amarkal-settings', \Amarkal\Core\Utility::path_to_url(__DIR__.'/assets/css/dist/amarkal-settings.min.css')); |
150 | - \wp_register_script('amarkal-settings',\Amarkal\Core\Utility::path_to_url(__DIR__.'/assets/js/dist/amarkal-settings.min.js'),array('amarkal-ui')); |
|
150 | + \wp_register_script('amarkal-settings', \Amarkal\Core\Utility::path_to_url(__DIR__.'/assets/js/dist/amarkal-settings.min.js'), array('amarkal-ui')); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | */ |
164 | 164 | private function init() |
165 | 165 | { |
166 | - \add_action('admin_init',array($this,'register_scripts')); |
|
166 | + \add_action('admin_init', array($this, 'register_scripts')); |
|
167 | 167 | |
168 | 168 | $rh = RequestHandler::get_instance(); |
169 | 169 | $rh->init(); |
@@ -105,8 +105,7 @@ discard block |
||
105 | 105 | try |
106 | 106 | { |
107 | 107 | return $this->get_field_value_for_parent($parent_slug, $field_name); |
108 | - } |
|
109 | - catch(\RuntimeException $e) |
|
108 | + } catch(\RuntimeException $e) |
|
110 | 109 | { |
111 | 110 | continue; |
112 | 111 | } |
@@ -132,8 +131,7 @@ discard block |
||
132 | 131 | $component = $cp->get_component($field_name); |
133 | 132 | $value = \get_option($field_name, $component->default); |
134 | 133 | return $value; |
135 | - } |
|
136 | - catch(\RuntimeException $e) |
|
134 | + } catch(\RuntimeException $e) |
|
137 | 135 | { |
138 | 136 | continue; |
139 | 137 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public static function get_instance() |
22 | 22 | { |
23 | - if( null === static::$instance ) |
|
23 | + if (null === static::$instance) |
|
24 | 24 | { |
25 | 25 | static::$instance = new static(); |
26 | 26 | } |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | |
30 | 30 | public function init() |
31 | 31 | { |
32 | - \add_action('wp_ajax_amarkal_settings_save', array( $this, 'save_settings')); |
|
33 | - \add_action('wp_ajax_amarkal_settings_reset', array( $this, 'reset_settings')); |
|
32 | + \add_action('wp_ajax_amarkal_settings_save', array($this, 'save_settings')); |
|
33 | + \add_action('wp_ajax_amarkal_settings_reset', array($this, 'reset_settings')); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | public function save_settings() |
37 | 37 | { |
38 | 38 | $this->set_request_data(); |
39 | - $child_page = $this->get_request_child_page(); |
|
39 | + $child_page = $this->get_request_child_page(); |
|
40 | 40 | |
41 | 41 | \wp_send_json($child_page->update($this->request_data)); |
42 | 42 | } |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | |
61 | 61 | private function set_request_data() |
62 | 62 | { |
63 | - $this->request_data = filter_input(INPUT_POST,'data',FILTER_DEFAULT,FILTER_REQUIRE_ARRAY); |
|
63 | + $this->request_data = filter_input(INPUT_POST, 'data', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
64 | 64 | $nonce = $this->request_data['_amarkal_settings_nonce']; |
65 | 65 | |
66 | - if( !isset( $nonce ) || |
|
67 | - !\wp_verify_nonce($nonce, self::NONCE_ACTION) ) |
|
66 | + if (!isset($nonce) || |
|
67 | + !\wp_verify_nonce($nonce, self::NONCE_ACTION)) |
|
68 | 68 | { |
69 | 69 | \wp_send_json(array( |
70 | 70 | 'values' => array(), |