Completed
Push — master ( 1fbea9...3bd219 )
by Askupa
01:22
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.
functions.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,9 @@
 block discarded – undo
18 18
 /**
19 19
  * Prevent loading the library more than once
20 20
  */
21
-if( defined( 'AMARKAL_SETTINGS' ) ) return false;
21
+if( defined( 'AMARKAL_SETTINGS' ) ) {
22
+    return false;
23
+}
22 24
 define( 'AMARKAL_SETTINGS', true );
23 25
 
24 26
 if(!function_exists('amarkal_add_settings_page'))
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,26 +13,26 @@
 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
-    function amarkal_add_settings_page( $args )
26
+    function amarkal_add_settings_page($args)
27 27
     {
28 28
         $manager = Amarkal\Settings\Manager::get_instance();
29 29
         $manager->add_page($args);
30 30
     }
31 31
 }
32 32
 
33
-if(!function_exists('amarkal_add_settings_child_page'))
33
+if (!function_exists('amarkal_add_settings_child_page'))
34 34
 {
35
-    function amarkal_add_settings_child_page( $args )
35
+    function amarkal_add_settings_child_page($args)
36 36
     {
37 37
         $manager = Amarkal\Settings\Manager::get_instance();
38 38
         $manager->add_child_page($args);
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
-        \parse_str(filter_input(INPUT_POST,'data'),$this->request_data);
63
+        \parse_str(filter_input(INPUT_POST, 'data'), $this->request_data);
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.
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.
ChildPage.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -24,13 +24,13 @@  discard block
 block discarded – undo
24 24
      * 
25 25
      * @param array $config
26 26
      */
27
-    public function __construct( array $config = array() ) 
27
+    public function __construct(array $config = array()) 
28 28
     {
29 29
         $this->config = array_merge($this->default_args(), $config);
30 30
         $this->form = new \Amarkal\UI\Form($this->config['fields']);
31 31
         
32
-        \add_action('admin_menu', array($this,'add_submenu_page'));
33
-        \add_action('admin_enqueue_scripts', array($this,'enqueue_scripts'));
32
+        \add_action('admin_menu', array($this, 'add_submenu_page'));
33
+        \add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));
34 34
     }
35 35
     
36 36
     /**
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     public function enqueue_scripts()
56 56
     {
57 57
         // Only enqueue styles & scripts if this is a settings page
58
-        if($this->config['slug'] === filter_input(INPUT_GET, 'page'))
58
+        if ($this->config['slug'] === filter_input(INPUT_GET, 'page'))
59 59
         {
60 60
             \wp_enqueue_style('amarkal-settings');
61 61
             \wp_enqueue_script('amarkal-settings');
@@ -79,15 +79,15 @@  discard block
 block discarded – undo
79 79
      * @param array $new_instance
80 80
      * @return array
81 81
      */
82
-    public function update( $new_instance )
82
+    public function update($new_instance)
83 83
     {
84
-        if($this->can_update())
84
+        if ($this->can_update())
85 85
         {
86 86
             $old_instance = $this->get_old_instance();
87 87
             $final_instance = $this->form->update($new_instance, $old_instance);
88
-            foreach($final_instance as $name => $value)
88
+            foreach ($final_instance as $name => $value)
89 89
             {
90
-                \update_option($name,$value);
90
+                \update_option($name, $value);
91 91
             }
92 92
             return $this->results_array(
93 93
                 $this->get_errors(),
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
      */
108 108
     public function reset()
109 109
     {
110
-        if($this->can_update())
110
+        if ($this->can_update())
111 111
         {
112
-            foreach($this->config['fields'] as $field)
112
+            foreach ($this->config['fields'] as $field)
113 113
             {
114 114
                 \delete_option($field['name']);
115 115
             }
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     private function get_errors()
140 140
     {
141 141
         $errors = array();
142
-        foreach($this->form->get_errors() as $name => $error)
142
+        foreach ($this->form->get_errors() as $name => $error)
143 143
         {
144 144
             $errors[$name] = $error;
145 145
         }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
      * @param array $values The list of values
154 154
      * @return array
155 155
      */
156
-    private function results_array( $errors = array(), $values = '' )
156
+    private function results_array($errors = array(), $values = '')
157 157
     {
158 158
         return array(
159 159
             'values' => $values,
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
     private function get_old_instance()
181 181
     {
182 182
         $old_instance = array();
183
-        foreach($this->form->get_components() as $component)
183
+        foreach ($this->form->get_components() as $component)
184 184
         {
185 185
             $old_instance[$component->name] = \get_option($component->name, $component->default);
186 186
         }
Please login to merge, or discard this patch.
Manager.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
         }
@@ -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'");
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     public function register_scripts()
99 99
     {
100 100
         \wp_register_style('amarkal-settings', \Amarkal\Core\Utility::path_to_url(__DIR__.'/assets/css/dist/amarkal-settings.min.css'));
101
-        \wp_register_script('amarkal-settings',\Amarkal\Core\Utility::path_to_url(__DIR__.'/assets/js/dist/amarkal-settings.min.js'),array('amarkal-ui'));
101
+        \wp_register_script('amarkal-settings', \Amarkal\Core\Utility::path_to_url(__DIR__.'/assets/js/dist/amarkal-settings.min.js'), array('amarkal-ui'));
102 102
     }
103 103
     
104 104
     /**
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      */
115 115
     private function init()
116 116
     {
117
-        \add_action('admin_init',array($this,'register_scripts'));
117
+        \add_action('admin_init', array($this, 'register_scripts'));
118 118
         
119 119
         $rh = RequestHandler::get_instance();
120 120
         $rh->init();
Please login to merge, or discard this patch.