Completed
Push — master ( 209b6d...6da443 )
by Askupa
01:29
created
Manager.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public static function get_instance()
25 25
     {
26
-        if( null === static::$instance ) 
26
+        if (null === static::$instance) 
27 27
         {
28 28
             static::$instance = new static();
29 29
         }
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
      * @param [array] $args
37 37
      * @return void
38 38
      */
39
-    public function register_shortcode( $args )
39
+    public function register_shortcode($args)
40 40
     {
41 41
         $config = $this->prepare_config($args);
42 42
 
43
-        if($this->shortcode_exists($args['id']))
43
+        if ($this->shortcode_exists($args['id']))
44 44
         {
45 45
             throw new \RuntimeException("A shortcode with id '{$args['id']}' has already been registered");
46 46
         }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public function enqueue_popup_style()
76 76
     {
77
-        \wp_enqueue_style('amarkal-shortcode',\Amarkal\Core\Utility::path_to_url(__DIR__.'/assets/css/dist/amarkal-shortcode-popup.min.css'));
77
+        \wp_enqueue_style('amarkal-shortcode', \Amarkal\Core\Utility::path_to_url(__DIR__.'/assets/css/dist/amarkal-shortcode-popup.min.css'));
78 78
     }
79 79
 
80 80
     /**
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     private function prepare_json_object()
95 95
     {
96 96
         $json = array();
97
-        foreach($this->shortcodes as $id => $shortcode)
97
+        foreach ($this->shortcodes as $id => $shortcode)
98 98
         {
99 99
             $popup = new Popup($shortcode['fields']);
100 100
             $json[$id] = $shortcode;
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     /**
127 127
      * Check if a shortcode with the given ID has already been registered
128 128
      */
129
-    private function shortcode_exists( $id )
129
+    private function shortcode_exists($id)
130 130
     {
131 131
         return array_key_exists($id, $this->shortcodes);
132 132
     }
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
      * Validate that the provided arguments have the required arguments as
136 136
      * specified in self::required_args()
137 137
      */
138
-    private function validate_args( $args )
138
+    private function validate_args($args)
139 139
     {
140
-        foreach($this->required_args() as $arg)
140
+        foreach ($this->required_args() as $arg)
141 141
         {
142
-            if(!array_key_exists($arg, $args))
142
+            if (!array_key_exists($arg, $args))
143 143
             {
144 144
                 throw new \RuntimeException("Missing required argument '$arg'");
145 145
             }
@@ -152,14 +152,14 @@  discard block
 block discarded – undo
152 152
      * @param [array] $args
153 153
      * @return array
154 154
      */
155
-    private function prepare_config( $args )
155
+    private function prepare_config($args)
156 156
     {
157 157
         $this->validate_args($args);
158 158
         $config = array_merge($this->default_args(), $args);
159 159
 
160
-        if($config['template'] === null)
160
+        if ($config['template'] === null)
161 161
         {
162
-            $config['template'] = $this->generate_template($config['id'],$config['fields']);
162
+            $config['template'] = $this->generate_template($config['id'], $config['fields']);
163 163
         }
164 164
 
165 165
         return $config;
@@ -178,17 +178,17 @@  discard block
 block discarded – undo
178 178
         $template = "[$tag";
179 179
         $self_enclosing = true;
180 180
 
181
-        foreach($fields as $field)
181
+        foreach ($fields as $field)
182 182
         {
183 183
             $name = $field['name'];
184
-            if('content' !== $name)
184
+            if ('content' !== $name)
185 185
             {
186 186
                 $template .= " $name=\"{{{$name}}}\"";
187 187
             }
188 188
             else $self_enclosing = false;
189 189
         }
190 190
 
191
-        if($self_enclosing)
191
+        if ($self_enclosing)
192 192
         {
193 193
             $template .= "/]";
194 194
         }
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
      */
205 205
     private function required_args()
206 206
     {
207
-        return array('id','title','fields');
207
+        return array('id', 'title', 'fields');
208 208
     }
209 209
 
210 210
     /**
@@ -212,9 +212,9 @@  discard block
 block discarded – undo
212 212
      */
213 213
     private function __construct() 
214 214
     {
215
-        \add_filter('mce_external_plugins',array($this,'enqueue_script'));
216
-        \add_action('admin_init', array($this,'enqueue_editor_style'));
217
-        \add_action('admin_enqueue_scripts', array($this,'enqueue_popup_style'));
218
-        \add_action('wp_enqueue_scripts', array($this,'enqueue_popup_style'));
215
+        \add_filter('mce_external_plugins', array($this, 'enqueue_script'));
216
+        \add_action('admin_init', array($this, 'enqueue_editor_style'));
217
+        \add_action('admin_enqueue_scripts', array($this, 'enqueue_popup_style'));
218
+        \add_action('wp_enqueue_scripts', array($this, 'enqueue_popup_style'));
219 219
     }
220 220
 }
221 221
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -184,15 +184,15 @@
 block discarded – undo
184 184
             if('content' !== $name)
185 185
             {
186 186
                 $template .= " $name=\"{{{$name}}}\"";
187
+            } else {
188
+                $self_enclosing = false;
187 189
             }
188
-            else $self_enclosing = false;
189 190
         }
190 191
 
191 192
         if($self_enclosing)
192 193
         {
193 194
             $template .= "/]";
194
-        }
195
-        else {
195
+        } else {
196 196
             $template .= "]{{content}}[/$tag]";
197 197
         }
198 198
         
Please login to merge, or discard this patch.