Completed
Push — master ( 24cf5e...bc1ad9 )
by Askupa
02:11
created
composer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
  */
7 7
 
8 8
 // Prevent direct file access
9
-defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
9
+defined('ABSPATH') or die('No script kiddies please!');
10 10
 
11 11
 // Load module functions
12 12
 require_once 'functions.php';
Please login to merge, or discard this patch.
Page.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@
 block discarded – undo
6 6
 {   
7 7
     private $config;
8 8
     
9
-    public function __construct( array $args = array() ) 
9
+    public function __construct(array $args = array()) 
10 10
     {
11 11
         $this->config = array_merge($this->default_args(), $args);
12 12
         
13
-        \add_action('admin_menu', array($this,'add_menu_page'));
13
+        \add_action('admin_menu', array($this, 'add_menu_page'));
14 14
     }
15 15
     
16 16
     public function add_menu_page()
Please login to merge, or discard this patch.
bootstrap.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@
 block discarded – undo
6 6
  */
7 7
 
8 8
 // Prevent direct file access
9
-defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
9
+defined('ABSPATH') or die('No script kiddies please!');
10 10
 
11 11
 /**
12 12
  * Load module functions. If this amarkal module has not been loaded, 
13 13
  * functions.php will not return false.
14 14
  */
15
-if(false !== (require_once 'functions.php'))
15
+if (false !== (require_once 'functions.php'))
16 16
 {
17 17
     // Load required classes if not using composer
18 18
     require_once 'RequestHandler.php';
Please login to merge, or discard this patch.
functions.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,6 @@
 block discarded – undo
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 )
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
Manager.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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();
Please login to merge, or discard this patch.
RequestHandler.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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(),
Please login to merge, or discard this patch.
ChildPage.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -28,15 +28,15 @@  discard block
 block discarded – undo
28 28
      * 
29 29
      * @param array $config
30 30
      */
31
-    public function __construct( array $config = array() ) 
31
+    public function __construct(array $config = array()) 
32 32
     {
33 33
         $this->config = array_merge($this->default_args(), $config);
34 34
         $this->form   = new \Amarkal\UI\Form(
35 35
             new \Amarkal\UI\ComponentList($this->config['fields'])
36 36
         );
37 37
         
38
-        \add_action('admin_menu', array($this,'add_submenu_page'));
39
-        \add_action('admin_enqueue_scripts', array($this,'enqueue_scripts'));
38
+        \add_action('admin_menu', array($this, 'add_submenu_page'));
39
+        \add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));
40 40
     }
41 41
     
42 42
     /**
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     public function enqueue_scripts()
62 62
     {
63 63
         // Only enqueue styles & scripts if this is a settings page
64
-        if($this->config['slug'] === filter_input(INPUT_GET, 'page'))
64
+        if ($this->config['slug'] === filter_input(INPUT_GET, 'page'))
65 65
         {
66 66
             \wp_enqueue_style('amarkal-settings');
67 67
             \wp_enqueue_script('amarkal-settings');
@@ -85,15 +85,15 @@  discard block
 block discarded – undo
85 85
      * @param array $new_instance
86 86
      * @return array
87 87
      */
88
-    public function update( $new_instance )
88
+    public function update($new_instance)
89 89
     {
90
-        if($this->can_update())
90
+        if ($this->can_update())
91 91
         {
92 92
             $old_instance = $this->get_old_instance();
93 93
             $final_instance = $this->form->update($new_instance, $old_instance);
94
-            foreach($final_instance as $name => $value)
94
+            foreach ($final_instance as $name => $value)
95 95
             {
96
-                \update_option($name,$value);
96
+                \update_option($name, $value);
97 97
             }
98 98
             return $this->results_array(
99 99
                 $this->get_errors(),
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function reset()
115 115
     {
116
-        if($this->can_update())
116
+        if ($this->can_update())
117 117
         {
118
-            foreach($this->config['fields'] as $field)
118
+            foreach ($this->config['fields'] as $field)
119 119
             {
120 120
                 \delete_option($field['name']);
121 121
             }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     private function get_errors()
158 158
     {
159 159
         $errors = array();
160
-        foreach($this->form->get_errors() as $name => $error)
160
+        foreach ($this->form->get_errors() as $name => $error)
161 161
         {
162 162
             $errors[$name] = $error;
163 163
         }
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
      * @param array $values The list of values
172 172
      * @return array
173 173
      */
174
-    private function results_array( $errors = array(), $values = '' )
174
+    private function results_array($errors = array(), $values = '')
175 175
     {
176 176
         return array(
177 177
             'values' => $values,
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
     private function get_old_instance()
199 199
     {
200 200
         $old_instance = array();
201
-        foreach($this->form->get_component_list()->get_value_components() as $component)
201
+        foreach ($this->form->get_component_list()->get_value_components() as $component)
202 202
         {
203 203
             $old_instance[$component->name] = \get_option($component->name, $component->default);
204 204
         }
Please login to merge, or discard this patch.