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