Completed
Push — master ( 11fa70...bdfca8 )
by Askupa
01:16
created
Manager.php 1 patch
Spacing   +26 added lines, -26 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,20 +36,20 @@  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
         }
47 47
 
48 48
         $this->shortcodes[$args['id']] = $config;
49 49
 
50
-        if($config['is_shortcode'])
50
+        if ($config['is_shortcode'])
51 51
         {
52
-            \add_shortcode( $args['id'], function($atts, $content = null) use ($args) {
52
+            \add_shortcode($args['id'], function($atts, $content = null) use ($args) {
53 53
                 // TODO: merge $atts with defaults using shortcode_atts()
54 54
                 $atts['content'] = $content;
55 55
                 return call_user_func_array($args['render'], array($this->decode_atts($atts)));
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public function enqueue_popup_style()
85 85
     {
86
-        \wp_enqueue_style('amarkal-shortcode',\Amarkal\Core\Utility::path_to_url(__DIR__.'/assets/css/dist/amarkal-shortcode-popup.min.css'));
86
+        \wp_enqueue_style('amarkal-shortcode', \Amarkal\Core\Utility::path_to_url(__DIR__.'/assets/css/dist/amarkal-shortcode-popup.min.css'));
87 87
     }
88 88
 
89 89
     /**
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         
103 103
         // Attributes are JSON encoded and then URL encoded in the shortcode editor, so
104 104
         // we need to reverse that
105
-        foreach($atts as $name => $value)
105
+        foreach ($atts as $name => $value)
106 106
         {
107 107
             $decoded_atts[$name] = $this->decode_att($value);
108 108
         }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         
116 116
         // If the value is null, it is most likely because the attribute is not JSON encoded.
117 117
         // We return the uncoded value for backward compatibility, where attributes are not JSON encoded.
118
-        if(null === $decoded) {
118
+        if (null === $decoded) {
119 119
             $decoded = $this->decode_non_json_encodede_att($value);
120 120
         }
121 121
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 
125 125
     private function decode_non_json_encodede_att($value)
126 126
     {
127
-        if(false !== \strpos($value, ',')) {
127
+        if (false !== \strpos($value, ',')) {
128 128
             return \explode(',', $value);
129 129
         }
130 130
         return $value;
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     private function prepare_json_object()
138 138
     {
139 139
         $json = array();
140
-        foreach($this->shortcodes as $id => $shortcode)
140
+        foreach ($this->shortcodes as $id => $shortcode)
141 141
         {
142 142
             $popup = new Popup($shortcode);
143 143
             $json[$id] = $shortcode;
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             'cmd'               => '',
159 159
             'width'             => 550,
160 160
             'height'            => 450,
161
-            'render'            => function(){},
161
+            'render'            => function() {},
162 162
             'fields'            => array(),
163 163
             'is_shortcode'      => true,
164 164
             'show_placeholder'  => true,
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
     /**
172 172
      * Check if a shortcode with the given ID has already been registered
173 173
      */
174
-    private function shortcode_exists( $id )
174
+    private function shortcode_exists($id)
175 175
     {
176 176
         return array_key_exists($id, $this->shortcodes);
177 177
     }
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
      * Validate that the provided arguments have the required arguments as
181 181
      * specified in self::required_args()
182 182
      */
183
-    private function validate_args( $args )
183
+    private function validate_args($args)
184 184
     {
185
-        foreach($this->required_args() as $arg)
185
+        foreach ($this->required_args() as $arg)
186 186
         {
187
-            if(!array_key_exists($arg, $args))
187
+            if (!array_key_exists($arg, $args))
188 188
             {
189 189
                 throw new \RuntimeException("Missing required argument '$arg'");
190 190
             }
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
      * @param [array] $args
198 198
      * @return array
199 199
      */
200
-    private function prepare_config( $args )
200
+    private function prepare_config($args)
201 201
     {
202 202
         $this->validate_args($args);
203 203
         $config = array_merge($this->default_args(), $args);
204 204
 
205
-        if($config['template'] === null)
205
+        if ($config['template'] === null)
206 206
         {
207
-            $config['template'] = $this->generate_template($config['id'],$config['fields']);
207
+            $config['template'] = $this->generate_template($config['id'], $config['fields']);
208 208
         }
209 209
 
210 210
         return $config;
@@ -223,17 +223,17 @@  discard block
 block discarded – undo
223 223
         $template = "[$tag";
224 224
         $self_enclosing = true;
225 225
 
226
-        foreach($fields as $field)
226
+        foreach ($fields as $field)
227 227
         {
228 228
             $name = $field['name'];
229
-            if('content' !== $name)
229
+            if ('content' !== $name)
230 230
             {
231 231
                 $template .= " $name=\"{{{$name}}}\"";
232 232
             }
233 233
             else $self_enclosing = false;
234 234
         }
235 235
 
236
-        if($self_enclosing)
236
+        if ($self_enclosing)
237 237
         {
238 238
             $template .= "/]";
239 239
         }
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
      */
250 250
     private function required_args()
251 251
     {
252
-        return array('id','title','fields');
252
+        return array('id', 'title', 'fields');
253 253
     }
254 254
 
255 255
     /**
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
      */
258 258
     private function __construct() 
259 259
     {
260
-        \add_filter('mce_external_plugins',array($this,'enqueue_script'));
261
-        \add_action('admin_init', array($this,'enqueue_editor_style'));
262
-        \add_action('admin_enqueue_scripts', array($this,'enqueue_popup_style'));
263
-        \add_action('wp_enqueue_scripts', array($this,'enqueue_popup_style'));
260
+        \add_filter('mce_external_plugins', array($this, 'enqueue_script'));
261
+        \add_action('admin_init', array($this, 'enqueue_editor_style'));
262
+        \add_action('admin_enqueue_scripts', array($this, 'enqueue_popup_style'));
263
+        \add_action('wp_enqueue_scripts', array($this, 'enqueue_popup_style'));
264 264
     }
265 265
 }
266 266
\ No newline at end of file
Please login to merge, or discard this patch.