Completed
Push — master ( 79e699...9f4abe )
by Askupa
05:35
created
Manager.php 1 patch
Spacing   +24 added lines, -24 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
             $decoded_atts[$name] = \json_decode(\urldecode($value));
107 107
         }
108 108
         return $decoded_atts;
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     private function prepare_json_object()
116 116
     {
117 117
         $json = array();
118
-        foreach($this->shortcodes as $id => $shortcode)
118
+        foreach ($this->shortcodes as $id => $shortcode)
119 119
         {
120 120
             $popup = new Popup($shortcode);
121 121
             $json[$id] = $shortcode;
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
             'cmd'               => '',
137 137
             'width'             => 550,
138 138
             'height'            => 450,
139
-            'render'            => function(){},
139
+            'render'            => function() {},
140 140
             'fields'            => array(),
141 141
             'is_shortcode'      => true,
142 142
             'show_placeholder'  => true,
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     /**
150 150
      * Check if a shortcode with the given ID has already been registered
151 151
      */
152
-    private function shortcode_exists( $id )
152
+    private function shortcode_exists($id)
153 153
     {
154 154
         return array_key_exists($id, $this->shortcodes);
155 155
     }
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
      * Validate that the provided arguments have the required arguments as
159 159
      * specified in self::required_args()
160 160
      */
161
-    private function validate_args( $args )
161
+    private function validate_args($args)
162 162
     {
163
-        foreach($this->required_args() as $arg)
163
+        foreach ($this->required_args() as $arg)
164 164
         {
165
-            if(!array_key_exists($arg, $args))
165
+            if (!array_key_exists($arg, $args))
166 166
             {
167 167
                 throw new \RuntimeException("Missing required argument '$arg'");
168 168
             }
@@ -175,14 +175,14 @@  discard block
 block discarded – undo
175 175
      * @param [array] $args
176 176
      * @return array
177 177
      */
178
-    private function prepare_config( $args )
178
+    private function prepare_config($args)
179 179
     {
180 180
         $this->validate_args($args);
181 181
         $config = array_merge($this->default_args(), $args);
182 182
 
183
-        if($config['template'] === null)
183
+        if ($config['template'] === null)
184 184
         {
185
-            $config['template'] = $this->generate_template($config['id'],$config['fields']);
185
+            $config['template'] = $this->generate_template($config['id'], $config['fields']);
186 186
         }
187 187
 
188 188
         return $config;
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
         $template = "[$tag";
202 202
         $self_enclosing = true;
203 203
 
204
-        foreach($fields as $field)
204
+        foreach ($fields as $field)
205 205
         {
206 206
             $name = $field['name'];
207
-            if('content' !== $name)
207
+            if ('content' !== $name)
208 208
             {
209 209
                 $template .= " $name=\"{{{$name}}}\"";
210 210
             }
211 211
             else $self_enclosing = false;
212 212
         }
213 213
 
214
-        if($self_enclosing)
214
+        if ($self_enclosing)
215 215
         {
216 216
             $template .= "/]";
217 217
         }
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
      */
228 228
     private function required_args()
229 229
     {
230
-        return array('id','title','fields');
230
+        return array('id', 'title', 'fields');
231 231
     }
232 232
 
233 233
     /**
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
      */
236 236
     private function __construct() 
237 237
     {
238
-        \add_filter('mce_external_plugins',array($this,'enqueue_script'));
239
-        \add_action('admin_init', array($this,'enqueue_editor_style'));
240
-        \add_action('admin_enqueue_scripts', array($this,'enqueue_popup_style'));
241
-        \add_action('wp_enqueue_scripts', array($this,'enqueue_popup_style'));
238
+        \add_filter('mce_external_plugins', array($this, 'enqueue_script'));
239
+        \add_action('admin_init', array($this, 'enqueue_editor_style'));
240
+        \add_action('admin_enqueue_scripts', array($this, 'enqueue_popup_style'));
241
+        \add_action('wp_enqueue_scripts', array($this, 'enqueue_popup_style'));
242 242
     }
243 243
 }
244 244
\ No newline at end of file
Please login to merge, or discard this patch.