Completed
Push — master ( ebd957...370ac4 )
by CodexShaper
12:32
created
includes/class-wpb.php 2 patches
Indentation   +338 added lines, -338 removed lines patch added patch discarded remove patch
@@ -28,342 +28,342 @@
 block discarded – undo
28 28
  */
29 29
 class WPB {
30 30
 
31
-	/**
32
-	 * The loader that's responsible for maintaining and registering all hooks that power
33
-	 * the plugin.
34
-	 *
35
-	 * @since    1.0.0
36
-	 * @access   protected
37
-	 * @var      WPB_Loader    $loader    Maintains and registers all hooks for the plugin.
38
-	 */
39
-	protected $loader;
40
-
41
-	/**
42
-	 * The unique identifier of this plugin.
43
-	 *
44
-	 * @since    1.0.0
45
-	 * @access   protected
46
-	 * @var      string    $plugin_name    The string used to uniquely identify this plugin.
47
-	 */
48
-	protected $plugin_name;
49
-
50
-	/**
51
-	 * The current version of the plugin.
52
-	 *
53
-	 * @since    1.0.0
54
-	 * @access   protected
55
-	 * @var      string    $version    The current version of the plugin.
56
-	 */
57
-	protected $version;
58
-
59
-	/**
60
-	 * Define the core functionality of the plugin.
61
-	 *
62
-	 * Set the plugin name and the plugin version that can be used throughout the plugin.
63
-	 * Load the dependencies, define the locale, and set the hooks for the admin area and
64
-	 * the public-facing side of the site.
65
-	 *
66
-	 * @since    1.0.0
67
-	 */
68
-	public function __construct() {
69
-
70
-		$this->define_constants();
71
-
72
-		if ( defined( 'WPB_VERSION' ) ) {
73
-			$this->version = WPB_VERSION;
74
-		} else {
75
-			$this->version = '1.0.0';
76
-		}
77
-		$this->plugin_name = 'wpb';
78
-		$this->load_dependencies();
79
-		$this->set_locale();
80
-		$this->define_admin_hooks();
81
-		$this->define_public_hooks();
82
-		$this->register_assets();
83
-
84
-		$menu             = new WPB_Admin_Menu( $this->plugin_name );
85
-		$menu->page_title = 'WPB';
86
-		$menu->menu_title = 'WPB';
87
-		$menu->capability = 'manage_options';
88
-		$menu->slug       = 'wpb';
89
-		$menu->callback   = function() {
90
-				echo '<div class="wrap"><div id="wpb-admin" base-url="' . esc_attr( get_site_url() ) . '" csrf-token="' . esc_attr( wpb_csrf_token() ) . '"></div></div>';
91
-		};
92
-		$menu->icon       = 'dashicons-text';
93
-		$menu->save();
94
-
95
-		$submenu              = new WPB_Admin_SubMenu( $this->plugin_name );
96
-		$submenu->parent_slug = $menu->slug;
97
-		$submenu->page_title  = 'Settings';
98
-		$submenu->menu_title  = 'Settings';
99
-		$submenu->capability  = 'manage_options';
100
-		$submenu->slug        = 'admin.php?page=' . $menu->slug . '#/settings';
101
-		$submenu->save();
102
-	}
103
-
104
-	/**
105
-	 * Load the required dependencies for this plugin.
106
-	 *
107
-	 * Include the following files that make up the plugin:
108
-	 *
109
-	 * - WPB_Loader. Orchestrates the hooks of the plugin.
110
-	 * - WPB_i18n. Defines internationalization functionality.
111
-	 * - WPB_Admin. Defines all hooks for the admin area.
112
-	 * - WPB_Public. Defines all hooks for the public side of the site.
113
-	 *
114
-	 * Create an instance of the loader which will be used to register the hooks
115
-	 * with WordPress.
116
-	 *
117
-	 * @since    1.0.0
118
-	 * @access   private
119
-	 */
120
-	private function load_dependencies() {
121
-
122
-		/**
123
-		 * The class responsible for orchestrating the actions and filters of the
124
-		 * core plugin.
125
-		 */
126
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpb-loader.php';
127
-
128
-		/**
129
-		 * The class responsible for defining internationalization functionality
130
-		 * of the plugin.
131
-		 */
132
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpb-i18n.php';
133
-
134
-		/**
135
-		 * The class responsible for defining all actions that occur in the admin area.
136
-		 */
137
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wpb-admin.php';
138
-
139
-		/**
140
-		 * The class responsible for defining all menu actions that occur in the admin area.
141
-		 */
142
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wpb-admin-menu.php';
143
-
144
-		/**
145
-		 * The class responsible for defining all submenu actions that occur in the admin area.
146
-		 */
147
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wpb-admin-submenu.php';
148
-
149
-		/**
150
-		 * The class responsible for defining all actions that occur in the public-facing
151
-		 * side of the site.
152
-		 */
153
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wpb-public.php';
154
-
155
-		$this->loader = new WPB_Loader();
156
-
157
-	}
158
-
159
-	/**
160
-	 * Define the locale for this plugin for internationalization.
161
-	 *
162
-	 * Uses the WPB_i18n class in order to set the domain and to register the hook
163
-	 * with WordPress.
164
-	 *
165
-	 * @since    1.0.0
166
-	 * @access   private
167
-	 */
168
-	private function set_locale() {
169
-
170
-		$plugin_i18n = new WPB_I18n();
171
-
172
-		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
173
-
174
-	}
175
-
176
-	/**
177
-	 * Register all of the hooks related to the admin area functionality
178
-	 * of the plugin.
179
-	 *
180
-	 * @since    1.0.0
181
-	 * @access   private
182
-	 */
183
-	private function define_admin_hooks() {
184
-
185
-		$plugin_admin = new WPB_Admin( $this->get_plugin_name(), $this->get_version() );
186
-
187
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
188
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
189
-
190
-	}
191
-
192
-	/**
193
-	 * Register all of the hooks related to the public-facing functionality
194
-	 * of the plugin.
195
-	 *
196
-	 * @since    1.0.0
197
-	 * @access   private
198
-	 */
199
-	private function define_public_hooks() {
200
-
201
-		$plugin_public = new WPB_Public( $this->get_plugin_name(), $this->get_version() );
202
-
203
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
204
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
205
-
206
-	}
207
-
208
-	/**
209
-	 * Run the loader to execute all of the hooks with WordPress.
210
-	 *
211
-	 * @since    1.0.0
212
-	 */
213
-	public function run() {
214
-		$this->loader->run();
215
-	}
216
-
217
-	/**
218
-	 * The name of the plugin used to uniquely identify it within the context of
219
-	 * WordPress and to define internationalization functionality.
220
-	 *
221
-	 * @since     1.0.0
222
-	 * @return    string    The name of the plugin.
223
-	 */
224
-	public function get_plugin_name() {
225
-		return $this->plugin_name;
226
-	}
227
-
228
-	/**
229
-	 * The reference to the class that orchestrates the hooks with the plugin.
230
-	 *
231
-	 * @since     1.0.0
232
-	 * @return    WPB_Loader    Orchestrates the hooks of the plugin.
233
-	 */
234
-	public function get_loader() {
235
-		return $this->loader;
236
-	}
237
-
238
-	/**
239
-	 * Retrieve the version number of the plugin.
240
-	 *
241
-	 * @since     1.0.0
242
-	 * @return    string    The version number of the plugin.
243
-	 */
244
-	public function get_version() {
245
-		return $this->version;
246
-	}
247
-
248
-	/**
249
-	 * Define the constants.
250
-	 *
251
-	 * @return void
252
-	 */
253
-	public function define_constants() {
254
-		define( 'WPB_VERSION', $this->version );
255
-	}
256
-
257
-	/**
258
-	 * Register our app scripts and styles.
259
-	 *
260
-	 * @return void
261
-	 */
262
-	public function register_assets() {
263
-		$this->register_scripts( $this->get_scripts() );
264
-		$this->register_styles( $this->get_styles() );
265
-	}
266
-
267
-	/**
268
-	 * Register scripts.
269
-	 *
270
-	 * @param  array $scripts All Scripts as an array.
271
-	 *
272
-	 * @return void
273
-	 */
274
-	private function register_scripts( $scripts ) {
275
-		foreach ( $scripts as $handle => $script ) {
276
-			$deps      = isset( $script['deps'] ) ? $script['deps'] : false;
277
-			$in_footer = isset( $script['in_footer'] ) ? $script['in_footer'] : false;
278
-			$version   = isset( $script['version'] ) ? $script['version'] : WPB_VERSION;
279
-
280
-			wp_register_script( $handle, $script['src'], $deps, $version, $in_footer );
281
-		}
282
-	}
283
-
284
-	/**
285
-	 * Register styles.
286
-	 *
287
-	 * @param  array $styles All styles as an array.
288
-	 *
289
-	 * @return void
290
-	 */
291
-	public function register_styles( $styles ) {
292
-		foreach ( $styles as $handle => $style ) {
293
-			$deps = isset( $style['deps'] ) ? $style['deps'] : false;
294
-
295
-			wp_register_style( $handle, $style['src'], $deps, WPB_VERSION );
296
-		}
297
-	}
298
-
299
-	/**
300
-	 * Get all registered scripts.
301
-	 *
302
-	 * @return array
303
-	 */
304
-	public function get_scripts() {
305
-
306
-		$prefix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.min' : '';
307
-
308
-		$scripts = array(
309
-			'wpb-runtime'  => array(
310
-				'src'       => WPB_ASSETS . '/js/runtime.js',
311
-				'version'   => filemtime( WPB_PATH . '/public/js/runtime.js' ),
312
-				'in_footer' => true,
313
-			),
314
-			'wpb-vendor'   => array(
315
-				'src'       => WPB_ASSETS . '/js/vendors.js',
316
-				'version'   => filemtime( WPB_PATH . '/public/js/vendors.js' ),
317
-				'in_footer' => true,
318
-			),
319
-			'wpb-frontend' => array(
320
-				'src'       => WPB_ASSETS . '/js/frontend.js',
321
-				'deps'      => array( 'jquery', 'wpb-vendor', 'wpb-runtime' ),
322
-				'version'   => filemtime( WPB_PATH . '/public/js/frontend.js' ),
323
-				'in_footer' => true,
324
-			),
325
-			'wpb-admin'    => array(
326
-				'src'       => WPB_ASSETS . '/js/admin.js',
327
-				'deps'      => array( 'jquery', 'wpb-vendor', 'wpb-runtime' ),
328
-				'version'   => filemtime( WPB_PATH . '/public/js/admin.js' ),
329
-				'in_footer' => true,
330
-			),
331
-			'wpb-spa'      => array(
332
-				'src'       => WPB_ASSETS . '/js/spa.js',
333
-				'deps'      => array( 'jquery', 'wpb-vendor', 'wpb-runtime' ),
334
-				'version'   => filemtime( WPB_PATH . '/public/js/spa.js' ),
335
-				'in_footer' => true,
336
-			),
337
-		);
338
-
339
-		return $scripts;
340
-	}
341
-
342
-	/**
343
-	 * Get registered styles.
344
-	 *
345
-	 * @return array
346
-	 */
347
-	public function get_styles() {
348
-
349
-		$styles = array(
350
-			'wpb-style'    => array(
351
-				'src' => WPB_ASSETS . '/css/style.css',
352
-			),
353
-			'wpb-frontend' => array(
354
-				'src' => WPB_ASSETS . '/css/frontend.css',
355
-			),
356
-			'wpb-admin'    => array(
357
-				'src' => WPB_ASSETS . '/css/admin.css',
358
-			),
359
-			'wpb-spa'      => array(
360
-				'src' => WPB_ASSETS . '/css/spa.css',
361
-			),
362
-			'wpb-vendors'  => array(
363
-				'src' => WPB_ASSETS . '/css/vendors.css',
364
-			),
365
-		);
366
-
367
-		return $styles;
368
-	}
31
+    /**
32
+     * The loader that's responsible for maintaining and registering all hooks that power
33
+     * the plugin.
34
+     *
35
+     * @since    1.0.0
36
+     * @access   protected
37
+     * @var      WPB_Loader    $loader    Maintains and registers all hooks for the plugin.
38
+     */
39
+    protected $loader;
40
+
41
+    /**
42
+     * The unique identifier of this plugin.
43
+     *
44
+     * @since    1.0.0
45
+     * @access   protected
46
+     * @var      string    $plugin_name    The string used to uniquely identify this plugin.
47
+     */
48
+    protected $plugin_name;
49
+
50
+    /**
51
+     * The current version of the plugin.
52
+     *
53
+     * @since    1.0.0
54
+     * @access   protected
55
+     * @var      string    $version    The current version of the plugin.
56
+     */
57
+    protected $version;
58
+
59
+    /**
60
+     * Define the core functionality of the plugin.
61
+     *
62
+     * Set the plugin name and the plugin version that can be used throughout the plugin.
63
+     * Load the dependencies, define the locale, and set the hooks for the admin area and
64
+     * the public-facing side of the site.
65
+     *
66
+     * @since    1.0.0
67
+     */
68
+    public function __construct() {
69
+
70
+        $this->define_constants();
71
+
72
+        if ( defined( 'WPB_VERSION' ) ) {
73
+            $this->version = WPB_VERSION;
74
+        } else {
75
+            $this->version = '1.0.0';
76
+        }
77
+        $this->plugin_name = 'wpb';
78
+        $this->load_dependencies();
79
+        $this->set_locale();
80
+        $this->define_admin_hooks();
81
+        $this->define_public_hooks();
82
+        $this->register_assets();
83
+
84
+        $menu             = new WPB_Admin_Menu( $this->plugin_name );
85
+        $menu->page_title = 'WPB';
86
+        $menu->menu_title = 'WPB';
87
+        $menu->capability = 'manage_options';
88
+        $menu->slug       = 'wpb';
89
+        $menu->callback   = function() {
90
+                echo '<div class="wrap"><div id="wpb-admin" base-url="' . esc_attr( get_site_url() ) . '" csrf-token="' . esc_attr( wpb_csrf_token() ) . '"></div></div>';
91
+        };
92
+        $menu->icon       = 'dashicons-text';
93
+        $menu->save();
94
+
95
+        $submenu              = new WPB_Admin_SubMenu( $this->plugin_name );
96
+        $submenu->parent_slug = $menu->slug;
97
+        $submenu->page_title  = 'Settings';
98
+        $submenu->menu_title  = 'Settings';
99
+        $submenu->capability  = 'manage_options';
100
+        $submenu->slug        = 'admin.php?page=' . $menu->slug . '#/settings';
101
+        $submenu->save();
102
+    }
103
+
104
+    /**
105
+     * Load the required dependencies for this plugin.
106
+     *
107
+     * Include the following files that make up the plugin:
108
+     *
109
+     * - WPB_Loader. Orchestrates the hooks of the plugin.
110
+     * - WPB_i18n. Defines internationalization functionality.
111
+     * - WPB_Admin. Defines all hooks for the admin area.
112
+     * - WPB_Public. Defines all hooks for the public side of the site.
113
+     *
114
+     * Create an instance of the loader which will be used to register the hooks
115
+     * with WordPress.
116
+     *
117
+     * @since    1.0.0
118
+     * @access   private
119
+     */
120
+    private function load_dependencies() {
121
+
122
+        /**
123
+         * The class responsible for orchestrating the actions and filters of the
124
+         * core plugin.
125
+         */
126
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpb-loader.php';
127
+
128
+        /**
129
+         * The class responsible for defining internationalization functionality
130
+         * of the plugin.
131
+         */
132
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpb-i18n.php';
133
+
134
+        /**
135
+         * The class responsible for defining all actions that occur in the admin area.
136
+         */
137
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wpb-admin.php';
138
+
139
+        /**
140
+         * The class responsible for defining all menu actions that occur in the admin area.
141
+         */
142
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wpb-admin-menu.php';
143
+
144
+        /**
145
+         * The class responsible for defining all submenu actions that occur in the admin area.
146
+         */
147
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wpb-admin-submenu.php';
148
+
149
+        /**
150
+         * The class responsible for defining all actions that occur in the public-facing
151
+         * side of the site.
152
+         */
153
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wpb-public.php';
154
+
155
+        $this->loader = new WPB_Loader();
156
+
157
+    }
158
+
159
+    /**
160
+     * Define the locale for this plugin for internationalization.
161
+     *
162
+     * Uses the WPB_i18n class in order to set the domain and to register the hook
163
+     * with WordPress.
164
+     *
165
+     * @since    1.0.0
166
+     * @access   private
167
+     */
168
+    private function set_locale() {
169
+
170
+        $plugin_i18n = new WPB_I18n();
171
+
172
+        $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
173
+
174
+    }
175
+
176
+    /**
177
+     * Register all of the hooks related to the admin area functionality
178
+     * of the plugin.
179
+     *
180
+     * @since    1.0.0
181
+     * @access   private
182
+     */
183
+    private function define_admin_hooks() {
184
+
185
+        $plugin_admin = new WPB_Admin( $this->get_plugin_name(), $this->get_version() );
186
+
187
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
188
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
189
+
190
+    }
191
+
192
+    /**
193
+     * Register all of the hooks related to the public-facing functionality
194
+     * of the plugin.
195
+     *
196
+     * @since    1.0.0
197
+     * @access   private
198
+     */
199
+    private function define_public_hooks() {
200
+
201
+        $plugin_public = new WPB_Public( $this->get_plugin_name(), $this->get_version() );
202
+
203
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
204
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
205
+
206
+    }
207
+
208
+    /**
209
+     * Run the loader to execute all of the hooks with WordPress.
210
+     *
211
+     * @since    1.0.0
212
+     */
213
+    public function run() {
214
+        $this->loader->run();
215
+    }
216
+
217
+    /**
218
+     * The name of the plugin used to uniquely identify it within the context of
219
+     * WordPress and to define internationalization functionality.
220
+     *
221
+     * @since     1.0.0
222
+     * @return    string    The name of the plugin.
223
+     */
224
+    public function get_plugin_name() {
225
+        return $this->plugin_name;
226
+    }
227
+
228
+    /**
229
+     * The reference to the class that orchestrates the hooks with the plugin.
230
+     *
231
+     * @since     1.0.0
232
+     * @return    WPB_Loader    Orchestrates the hooks of the plugin.
233
+     */
234
+    public function get_loader() {
235
+        return $this->loader;
236
+    }
237
+
238
+    /**
239
+     * Retrieve the version number of the plugin.
240
+     *
241
+     * @since     1.0.0
242
+     * @return    string    The version number of the plugin.
243
+     */
244
+    public function get_version() {
245
+        return $this->version;
246
+    }
247
+
248
+    /**
249
+     * Define the constants.
250
+     *
251
+     * @return void
252
+     */
253
+    public function define_constants() {
254
+        define( 'WPB_VERSION', $this->version );
255
+    }
256
+
257
+    /**
258
+     * Register our app scripts and styles.
259
+     *
260
+     * @return void
261
+     */
262
+    public function register_assets() {
263
+        $this->register_scripts( $this->get_scripts() );
264
+        $this->register_styles( $this->get_styles() );
265
+    }
266
+
267
+    /**
268
+     * Register scripts.
269
+     *
270
+     * @param  array $scripts All Scripts as an array.
271
+     *
272
+     * @return void
273
+     */
274
+    private function register_scripts( $scripts ) {
275
+        foreach ( $scripts as $handle => $script ) {
276
+            $deps      = isset( $script['deps'] ) ? $script['deps'] : false;
277
+            $in_footer = isset( $script['in_footer'] ) ? $script['in_footer'] : false;
278
+            $version   = isset( $script['version'] ) ? $script['version'] : WPB_VERSION;
279
+
280
+            wp_register_script( $handle, $script['src'], $deps, $version, $in_footer );
281
+        }
282
+    }
283
+
284
+    /**
285
+     * Register styles.
286
+     *
287
+     * @param  array $styles All styles as an array.
288
+     *
289
+     * @return void
290
+     */
291
+    public function register_styles( $styles ) {
292
+        foreach ( $styles as $handle => $style ) {
293
+            $deps = isset( $style['deps'] ) ? $style['deps'] : false;
294
+
295
+            wp_register_style( $handle, $style['src'], $deps, WPB_VERSION );
296
+        }
297
+    }
298
+
299
+    /**
300
+     * Get all registered scripts.
301
+     *
302
+     * @return array
303
+     */
304
+    public function get_scripts() {
305
+
306
+        $prefix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.min' : '';
307
+
308
+        $scripts = array(
309
+            'wpb-runtime'  => array(
310
+                'src'       => WPB_ASSETS . '/js/runtime.js',
311
+                'version'   => filemtime( WPB_PATH . '/public/js/runtime.js' ),
312
+                'in_footer' => true,
313
+            ),
314
+            'wpb-vendor'   => array(
315
+                'src'       => WPB_ASSETS . '/js/vendors.js',
316
+                'version'   => filemtime( WPB_PATH . '/public/js/vendors.js' ),
317
+                'in_footer' => true,
318
+            ),
319
+            'wpb-frontend' => array(
320
+                'src'       => WPB_ASSETS . '/js/frontend.js',
321
+                'deps'      => array( 'jquery', 'wpb-vendor', 'wpb-runtime' ),
322
+                'version'   => filemtime( WPB_PATH . '/public/js/frontend.js' ),
323
+                'in_footer' => true,
324
+            ),
325
+            'wpb-admin'    => array(
326
+                'src'       => WPB_ASSETS . '/js/admin.js',
327
+                'deps'      => array( 'jquery', 'wpb-vendor', 'wpb-runtime' ),
328
+                'version'   => filemtime( WPB_PATH . '/public/js/admin.js' ),
329
+                'in_footer' => true,
330
+            ),
331
+            'wpb-spa'      => array(
332
+                'src'       => WPB_ASSETS . '/js/spa.js',
333
+                'deps'      => array( 'jquery', 'wpb-vendor', 'wpb-runtime' ),
334
+                'version'   => filemtime( WPB_PATH . '/public/js/spa.js' ),
335
+                'in_footer' => true,
336
+            ),
337
+        );
338
+
339
+        return $scripts;
340
+    }
341
+
342
+    /**
343
+     * Get registered styles.
344
+     *
345
+     * @return array
346
+     */
347
+    public function get_styles() {
348
+
349
+        $styles = array(
350
+            'wpb-style'    => array(
351
+                'src' => WPB_ASSETS . '/css/style.css',
352
+            ),
353
+            'wpb-frontend' => array(
354
+                'src' => WPB_ASSETS . '/css/frontend.css',
355
+            ),
356
+            'wpb-admin'    => array(
357
+                'src' => WPB_ASSETS . '/css/admin.css',
358
+            ),
359
+            'wpb-spa'      => array(
360
+                'src' => WPB_ASSETS . '/css/spa.css',
361
+            ),
362
+            'wpb-vendors'  => array(
363
+                'src' => WPB_ASSETS . '/css/vendors.css',
364
+            ),
365
+        );
366
+
367
+        return $styles;
368
+    }
369 369
 }
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
 		$this->define_constants();
71 71
 
72
-		if ( defined( 'WPB_VERSION' ) ) {
72
+		if (defined('WPB_VERSION')) {
73 73
 			$this->version = WPB_VERSION;
74 74
 		} else {
75 75
 			$this->version = '1.0.0';
@@ -81,23 +81,23 @@  discard block
 block discarded – undo
81 81
 		$this->define_public_hooks();
82 82
 		$this->register_assets();
83 83
 
84
-		$menu             = new WPB_Admin_Menu( $this->plugin_name );
84
+		$menu             = new WPB_Admin_Menu($this->plugin_name);
85 85
 		$menu->page_title = 'WPB';
86 86
 		$menu->menu_title = 'WPB';
87 87
 		$menu->capability = 'manage_options';
88 88
 		$menu->slug       = 'wpb';
89 89
 		$menu->callback   = function() {
90
-				echo '<div class="wrap"><div id="wpb-admin" base-url="' . esc_attr( get_site_url() ) . '" csrf-token="' . esc_attr( wpb_csrf_token() ) . '"></div></div>';
90
+				echo '<div class="wrap"><div id="wpb-admin" base-url="'.esc_attr(get_site_url()).'" csrf-token="'.esc_attr(wpb_csrf_token()).'"></div></div>';
91 91
 		};
92 92
 		$menu->icon       = 'dashicons-text';
93 93
 		$menu->save();
94 94
 
95
-		$submenu              = new WPB_Admin_SubMenu( $this->plugin_name );
95
+		$submenu              = new WPB_Admin_SubMenu($this->plugin_name);
96 96
 		$submenu->parent_slug = $menu->slug;
97 97
 		$submenu->page_title  = 'Settings';
98 98
 		$submenu->menu_title  = 'Settings';
99 99
 		$submenu->capability  = 'manage_options';
100
-		$submenu->slug        = 'admin.php?page=' . $menu->slug . '#/settings';
100
+		$submenu->slug        = 'admin.php?page='.$menu->slug.'#/settings';
101 101
 		$submenu->save();
102 102
 	}
103 103
 
@@ -123,34 +123,34 @@  discard block
 block discarded – undo
123 123
 		 * The class responsible for orchestrating the actions and filters of the
124 124
 		 * core plugin.
125 125
 		 */
126
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpb-loader.php';
126
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wpb-loader.php';
127 127
 
128 128
 		/**
129 129
 		 * The class responsible for defining internationalization functionality
130 130
 		 * of the plugin.
131 131
 		 */
132
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpb-i18n.php';
132
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wpb-i18n.php';
133 133
 
134 134
 		/**
135 135
 		 * The class responsible for defining all actions that occur in the admin area.
136 136
 		 */
137
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wpb-admin.php';
137
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wpb-admin.php';
138 138
 
139 139
 		/**
140 140
 		 * The class responsible for defining all menu actions that occur in the admin area.
141 141
 		 */
142
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wpb-admin-menu.php';
142
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wpb-admin-menu.php';
143 143
 
144 144
 		/**
145 145
 		 * The class responsible for defining all submenu actions that occur in the admin area.
146 146
 		 */
147
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wpb-admin-submenu.php';
147
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wpb-admin-submenu.php';
148 148
 
149 149
 		/**
150 150
 		 * The class responsible for defining all actions that occur in the public-facing
151 151
 		 * side of the site.
152 152
 		 */
153
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wpb-public.php';
153
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wpb-public.php';
154 154
 
155 155
 		$this->loader = new WPB_Loader();
156 156
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
 		$plugin_i18n = new WPB_I18n();
171 171
 
172
-		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
172
+		$this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
173 173
 
174 174
 	}
175 175
 
@@ -182,10 +182,10 @@  discard block
 block discarded – undo
182 182
 	 */
183 183
 	private function define_admin_hooks() {
184 184
 
185
-		$plugin_admin = new WPB_Admin( $this->get_plugin_name(), $this->get_version() );
185
+		$plugin_admin = new WPB_Admin($this->get_plugin_name(), $this->get_version());
186 186
 
187
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
188
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
187
+		$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
188
+		$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
189 189
 
190 190
 	}
191 191
 
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
 	 */
199 199
 	private function define_public_hooks() {
200 200
 
201
-		$plugin_public = new WPB_Public( $this->get_plugin_name(), $this->get_version() );
201
+		$plugin_public = new WPB_Public($this->get_plugin_name(), $this->get_version());
202 202
 
203
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
204
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
203
+		$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
204
+		$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
205 205
 
206 206
 	}
207 207
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 * @return void
252 252
 	 */
253 253
 	public function define_constants() {
254
-		define( 'WPB_VERSION', $this->version );
254
+		define('WPB_VERSION', $this->version);
255 255
 	}
256 256
 
257 257
 	/**
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 	 * @return void
261 261
 	 */
262 262
 	public function register_assets() {
263
-		$this->register_scripts( $this->get_scripts() );
264
-		$this->register_styles( $this->get_styles() );
263
+		$this->register_scripts($this->get_scripts());
264
+		$this->register_styles($this->get_styles());
265 265
 	}
266 266
 
267 267
 	/**
@@ -271,13 +271,13 @@  discard block
 block discarded – undo
271 271
 	 *
272 272
 	 * @return void
273 273
 	 */
274
-	private function register_scripts( $scripts ) {
275
-		foreach ( $scripts as $handle => $script ) {
276
-			$deps      = isset( $script['deps'] ) ? $script['deps'] : false;
277
-			$in_footer = isset( $script['in_footer'] ) ? $script['in_footer'] : false;
278
-			$version   = isset( $script['version'] ) ? $script['version'] : WPB_VERSION;
274
+	private function register_scripts($scripts) {
275
+		foreach ($scripts as $handle => $script) {
276
+			$deps      = isset($script['deps']) ? $script['deps'] : false;
277
+			$in_footer = isset($script['in_footer']) ? $script['in_footer'] : false;
278
+			$version   = isset($script['version']) ? $script['version'] : WPB_VERSION;
279 279
 
280
-			wp_register_script( $handle, $script['src'], $deps, $version, $in_footer );
280
+			wp_register_script($handle, $script['src'], $deps, $version, $in_footer);
281 281
 		}
282 282
 	}
283 283
 
@@ -288,11 +288,11 @@  discard block
 block discarded – undo
288 288
 	 *
289 289
 	 * @return void
290 290
 	 */
291
-	public function register_styles( $styles ) {
292
-		foreach ( $styles as $handle => $style ) {
293
-			$deps = isset( $style['deps'] ) ? $style['deps'] : false;
291
+	public function register_styles($styles) {
292
+		foreach ($styles as $handle => $style) {
293
+			$deps = isset($style['deps']) ? $style['deps'] : false;
294 294
 
295
-			wp_register_style( $handle, $style['src'], $deps, WPB_VERSION );
295
+			wp_register_style($handle, $style['src'], $deps, WPB_VERSION);
296 296
 		}
297 297
 	}
298 298
 
@@ -303,35 +303,35 @@  discard block
 block discarded – undo
303 303
 	 */
304 304
 	public function get_scripts() {
305 305
 
306
-		$prefix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.min' : '';
306
+		$prefix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.min' : '';
307 307
 
308 308
 		$scripts = array(
309 309
 			'wpb-runtime'  => array(
310
-				'src'       => WPB_ASSETS . '/js/runtime.js',
311
-				'version'   => filemtime( WPB_PATH . '/public/js/runtime.js' ),
310
+				'src'       => WPB_ASSETS.'/js/runtime.js',
311
+				'version'   => filemtime(WPB_PATH.'/public/js/runtime.js'),
312 312
 				'in_footer' => true,
313 313
 			),
314 314
 			'wpb-vendor'   => array(
315
-				'src'       => WPB_ASSETS . '/js/vendors.js',
316
-				'version'   => filemtime( WPB_PATH . '/public/js/vendors.js' ),
315
+				'src'       => WPB_ASSETS.'/js/vendors.js',
316
+				'version'   => filemtime(WPB_PATH.'/public/js/vendors.js'),
317 317
 				'in_footer' => true,
318 318
 			),
319 319
 			'wpb-frontend' => array(
320
-				'src'       => WPB_ASSETS . '/js/frontend.js',
321
-				'deps'      => array( 'jquery', 'wpb-vendor', 'wpb-runtime' ),
322
-				'version'   => filemtime( WPB_PATH . '/public/js/frontend.js' ),
320
+				'src'       => WPB_ASSETS.'/js/frontend.js',
321
+				'deps'      => array('jquery', 'wpb-vendor', 'wpb-runtime'),
322
+				'version'   => filemtime(WPB_PATH.'/public/js/frontend.js'),
323 323
 				'in_footer' => true,
324 324
 			),
325 325
 			'wpb-admin'    => array(
326
-				'src'       => WPB_ASSETS . '/js/admin.js',
327
-				'deps'      => array( 'jquery', 'wpb-vendor', 'wpb-runtime' ),
328
-				'version'   => filemtime( WPB_PATH . '/public/js/admin.js' ),
326
+				'src'       => WPB_ASSETS.'/js/admin.js',
327
+				'deps'      => array('jquery', 'wpb-vendor', 'wpb-runtime'),
328
+				'version'   => filemtime(WPB_PATH.'/public/js/admin.js'),
329 329
 				'in_footer' => true,
330 330
 			),
331 331
 			'wpb-spa'      => array(
332
-				'src'       => WPB_ASSETS . '/js/spa.js',
333
-				'deps'      => array( 'jquery', 'wpb-vendor', 'wpb-runtime' ),
334
-				'version'   => filemtime( WPB_PATH . '/public/js/spa.js' ),
332
+				'src'       => WPB_ASSETS.'/js/spa.js',
333
+				'deps'      => array('jquery', 'wpb-vendor', 'wpb-runtime'),
334
+				'version'   => filemtime(WPB_PATH.'/public/js/spa.js'),
335 335
 				'in_footer' => true,
336 336
 			),
337 337
 		);
@@ -348,19 +348,19 @@  discard block
 block discarded – undo
348 348
 
349 349
 		$styles = array(
350 350
 			'wpb-style'    => array(
351
-				'src' => WPB_ASSETS . '/css/style.css',
351
+				'src' => WPB_ASSETS.'/css/style.css',
352 352
 			),
353 353
 			'wpb-frontend' => array(
354
-				'src' => WPB_ASSETS . '/css/frontend.css',
354
+				'src' => WPB_ASSETS.'/css/frontend.css',
355 355
 			),
356 356
 			'wpb-admin'    => array(
357
-				'src' => WPB_ASSETS . '/css/admin.css',
357
+				'src' => WPB_ASSETS.'/css/admin.css',
358 358
 			),
359 359
 			'wpb-spa'      => array(
360
-				'src' => WPB_ASSETS . '/css/spa.css',
360
+				'src' => WPB_ASSETS.'/css/spa.css',
361 361
 			),
362 362
 			'wpb-vendors'  => array(
363
-				'src' => WPB_ASSETS . '/css/vendors.css',
363
+				'src' => WPB_ASSETS.'/css/vendors.css',
364 364
 			),
365 365
 		);
366 366
 
Please login to merge, or discard this patch.
admin/class-wpb-admin-menu.php 2 patches
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -21,150 +21,150 @@
 block discarded – undo
21 21
  */
22 22
 class WPB_Admin_Menu {
23 23
 
24
-	/**
25
-	 * The menu page title.
26
-	 *
27
-	 * @since    1.0.0
28
-	 * @access   public
29
-	 * @var      string    $page_title    The string used to set menu page title.
30
-	 */
31
-	public $page_title;
32
-
33
-	/**
34
-	 * The menu title.
35
-	 *
36
-	 * @since    1.0.0
37
-	 * @access   public
38
-	 * @var      string    $menu_title    The string used to set menu title.
39
-	 */
40
-	public $menu_title;
41
-
42
-	/**
43
-	 * The menu capability.
44
-	 *
45
-	 * @since    1.0.0
46
-	 * @access   public
47
-	 * @var      string    $capability    The string used to set menu capability.
48
-	 */
49
-	public $capability;
50
-
51
-	/**
52
-	 * The menu slug.
53
-	 *
54
-	 * @since    1.0.0
55
-	 * @access   public
56
-	 * @var      string    $slug    The string used to set menu slug.
57
-	 */
58
-	public $slug;
59
-
60
-	/**
61
-	 * The callback to render content.
62
-	 *
63
-	 * @since    1.0.0
64
-	 * @access   public
65
-	 * @var      callback    $callback    The callback used to render content.
66
-	 */
67
-	public $callback;
68
-
69
-	/**
70
-	 * The menu icon.
71
-	 *
72
-	 * @since    1.0.0
73
-	 * @access   public
74
-	 * @var      string    $icon    The string used to set menu icon.
75
-	 */
76
-	public $icon;
77
-
78
-	/**
79
-	 * The menu position.
80
-	 *
81
-	 * @since    1.0.0
82
-	 * @access   public
83
-	 * @var      int    $position    The string used to set menu position.
84
-	 */
85
-	public $position;
86
-
87
-	/**
88
-	 * The menu plugin name.
89
-	 *
90
-	 * @since    1.0.0
91
-	 * @access   private
92
-	 * @var      string    $plugin_name    The string used to uniquely identify this plugin.
93
-	 */
94
-	private $plugin_name;
95
-
96
-	/**
97
-	 * Boot Menu.
98
-	 *
99
-	 * @param  string $plugin_name The string used to uniquely identify this plugin.
100
-	 * @since    1.0.0
101
-	 * @access   public
102
-	 */
103
-	public function __construct( $plugin_name ) {
104
-		$this->plugin_name = $plugin_name;
105
-	}
106
-
107
-	/**
108
-	 * Create a new menu page.
109
-	 *
110
-	 * @since    1.0.0
111
-	 * @access   public
112
-	 */
113
-	public function save() {
114
-		add_action( 'admin_menu', array( $this, 'create_menu' ) );
115
-	}
116
-
117
-	/**
118
-	 * Create a new menu page.
119
-	 *
120
-	 * @since    1.0.0
121
-	 * @param    array $options Pass proprties as an array.
122
-	 * @access   public
123
-	 */
124
-	public function make( $options = array() ) {
125
-		foreach ( $options as $property => $value ) {
126
-			if ( property_exists( get_called_class(), $property ) ) {
127
-				$this->{$property} = $value;
128
-			}
129
-		}
130
-		add_action( 'admin_menu', array( $this, 'create_menu' ) );
131
-	}
132
-
133
-	/**
134
-	 * Register new menu page.
135
-	 *
136
-	 * @return void
137
-	 */
138
-	public function create_menu() {
139
-		$hook = add_menu_page(
140
-			$this->page_title,
141
-			$this->menu_title,
142
-			$this->capability,
143
-			$this->slug,
144
-			$this->callback,
145
-			$this->icon
146
-		);
147
-
148
-		add_action( 'load-' . $hook, array( $this, 'init_hooks' ) );
149
-	}
150
-
151
-	/**
152
-	 * Initialize hooks for the admin page.
153
-	 *
154
-	 * @return void
155
-	 */
156
-	public function init_hooks() {
157
-		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
158
-	}
159
-
160
-	/**
161
-	 * Load scripts and styles for the current menu page.
162
-	 *
163
-	 * @return void
164
-	 */
165
-	public function enqueue_scripts() {
166
-		wp_enqueue_style( $this->plugin_name . '-vendors' );
167
-		wp_enqueue_style( $this->plugin_name . '-admin' );
168
-		wp_enqueue_script( $this->plugin_name . '-admin' );
169
-	}
24
+    /**
25
+     * The menu page title.
26
+     *
27
+     * @since    1.0.0
28
+     * @access   public
29
+     * @var      string    $page_title    The string used to set menu page title.
30
+     */
31
+    public $page_title;
32
+
33
+    /**
34
+     * The menu title.
35
+     *
36
+     * @since    1.0.0
37
+     * @access   public
38
+     * @var      string    $menu_title    The string used to set menu title.
39
+     */
40
+    public $menu_title;
41
+
42
+    /**
43
+     * The menu capability.
44
+     *
45
+     * @since    1.0.0
46
+     * @access   public
47
+     * @var      string    $capability    The string used to set menu capability.
48
+     */
49
+    public $capability;
50
+
51
+    /**
52
+     * The menu slug.
53
+     *
54
+     * @since    1.0.0
55
+     * @access   public
56
+     * @var      string    $slug    The string used to set menu slug.
57
+     */
58
+    public $slug;
59
+
60
+    /**
61
+     * The callback to render content.
62
+     *
63
+     * @since    1.0.0
64
+     * @access   public
65
+     * @var      callback    $callback    The callback used to render content.
66
+     */
67
+    public $callback;
68
+
69
+    /**
70
+     * The menu icon.
71
+     *
72
+     * @since    1.0.0
73
+     * @access   public
74
+     * @var      string    $icon    The string used to set menu icon.
75
+     */
76
+    public $icon;
77
+
78
+    /**
79
+     * The menu position.
80
+     *
81
+     * @since    1.0.0
82
+     * @access   public
83
+     * @var      int    $position    The string used to set menu position.
84
+     */
85
+    public $position;
86
+
87
+    /**
88
+     * The menu plugin name.
89
+     *
90
+     * @since    1.0.0
91
+     * @access   private
92
+     * @var      string    $plugin_name    The string used to uniquely identify this plugin.
93
+     */
94
+    private $plugin_name;
95
+
96
+    /**
97
+     * Boot Menu.
98
+     *
99
+     * @param  string $plugin_name The string used to uniquely identify this plugin.
100
+     * @since    1.0.0
101
+     * @access   public
102
+     */
103
+    public function __construct( $plugin_name ) {
104
+        $this->plugin_name = $plugin_name;
105
+    }
106
+
107
+    /**
108
+     * Create a new menu page.
109
+     *
110
+     * @since    1.0.0
111
+     * @access   public
112
+     */
113
+    public function save() {
114
+        add_action( 'admin_menu', array( $this, 'create_menu' ) );
115
+    }
116
+
117
+    /**
118
+     * Create a new menu page.
119
+     *
120
+     * @since    1.0.0
121
+     * @param    array $options Pass proprties as an array.
122
+     * @access   public
123
+     */
124
+    public function make( $options = array() ) {
125
+        foreach ( $options as $property => $value ) {
126
+            if ( property_exists( get_called_class(), $property ) ) {
127
+                $this->{$property} = $value;
128
+            }
129
+        }
130
+        add_action( 'admin_menu', array( $this, 'create_menu' ) );
131
+    }
132
+
133
+    /**
134
+     * Register new menu page.
135
+     *
136
+     * @return void
137
+     */
138
+    public function create_menu() {
139
+        $hook = add_menu_page(
140
+            $this->page_title,
141
+            $this->menu_title,
142
+            $this->capability,
143
+            $this->slug,
144
+            $this->callback,
145
+            $this->icon
146
+        );
147
+
148
+        add_action( 'load-' . $hook, array( $this, 'init_hooks' ) );
149
+    }
150
+
151
+    /**
152
+     * Initialize hooks for the admin page.
153
+     *
154
+     * @return void
155
+     */
156
+    public function init_hooks() {
157
+        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
158
+    }
159
+
160
+    /**
161
+     * Load scripts and styles for the current menu page.
162
+     *
163
+     * @return void
164
+     */
165
+    public function enqueue_scripts() {
166
+        wp_enqueue_style( $this->plugin_name . '-vendors' );
167
+        wp_enqueue_style( $this->plugin_name . '-admin' );
168
+        wp_enqueue_script( $this->plugin_name . '-admin' );
169
+    }
170 170
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * @since    1.0.0
101 101
 	 * @access   public
102 102
 	 */
103
-	public function __construct( $plugin_name ) {
103
+	public function __construct($plugin_name) {
104 104
 		$this->plugin_name = $plugin_name;
105 105
 	}
106 106
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @access   public
112 112
 	 */
113 113
 	public function save() {
114
-		add_action( 'admin_menu', array( $this, 'create_menu' ) );
114
+		add_action('admin_menu', array($this, 'create_menu'));
115 115
 	}
116 116
 
117 117
 	/**
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
 	 * @param    array $options Pass proprties as an array.
122 122
 	 * @access   public
123 123
 	 */
124
-	public function make( $options = array() ) {
125
-		foreach ( $options as $property => $value ) {
126
-			if ( property_exists( get_called_class(), $property ) ) {
124
+	public function make($options = array()) {
125
+		foreach ($options as $property => $value) {
126
+			if (property_exists(get_called_class(), $property)) {
127 127
 				$this->{$property} = $value;
128 128
 			}
129 129
 		}
130
-		add_action( 'admin_menu', array( $this, 'create_menu' ) );
130
+		add_action('admin_menu', array($this, 'create_menu'));
131 131
 	}
132 132
 
133 133
 	/**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 			$this->icon
146 146
 		);
147 147
 
148
-		add_action( 'load-' . $hook, array( $this, 'init_hooks' ) );
148
+		add_action('load-'.$hook, array($this, 'init_hooks'));
149 149
 	}
150 150
 
151 151
 	/**
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 * @return void
155 155
 	 */
156 156
 	public function init_hooks() {
157
-		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
157
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));
158 158
 	}
159 159
 
160 160
 	/**
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
 	 * @return void
164 164
 	 */
165 165
 	public function enqueue_scripts() {
166
-		wp_enqueue_style( $this->plugin_name . '-vendors' );
167
-		wp_enqueue_style( $this->plugin_name . '-admin' );
168
-		wp_enqueue_script( $this->plugin_name . '-admin' );
166
+		wp_enqueue_style($this->plugin_name.'-vendors');
167
+		wp_enqueue_style($this->plugin_name.'-admin');
168
+		wp_enqueue_script($this->plugin_name.'-admin');
169 169
 	}
170 170
 }
Please login to merge, or discard this patch.
admin/class-wpb-admin-submenu.php 2 patches
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -22,153 +22,153 @@
 block discarded – undo
22 22
  */
23 23
 class WPB_Admin_SubMenu {
24 24
 
25
-	/**
26
-	 * The menu page title.
27
-	 *
28
-	 * @since    1.0.0
29
-	 * @access   public
30
-	 * @var      string    $page_title    The string used to set menu page title.
31
-	 */
32
-	public $page_title;
33
-
34
-	/**
35
-	 * The menu title.
36
-	 *
37
-	 * @since    1.0.0
38
-	 * @access   public
39
-	 * @var      string    $menu_title    The string used to set menu title.
40
-	 */
41
-	public $menu_title;
42
-
43
-	/**
44
-	 * The menu capability.
45
-	 *
46
-	 * @since    1.0.0
47
-	 * @access   public
48
-	 * @var      string    $capability    The string used to set menu capability.
49
-	 */
50
-	public $capability;
51
-
52
-	/**
53
-	 * The menu slug.
54
-	 *
55
-	 * @since    1.0.0
56
-	 * @access   public
57
-	 * @var      string    $slug    The string used to set menu slug.
58
-	 */
59
-	public $slug;
60
-
61
-	/**
62
-	 * The callback to render content.
63
-	 *
64
-	 * @since    1.0.0
65
-	 * @access   public
66
-	 * @var      callback    $callback    The callback used to render content.
67
-	 */
68
-	public $callback;
69
-
70
-	/**
71
-	 * The menu icon.
72
-	 *
73
-	 * @since    1.0.0
74
-	 * @access   public
75
-	 * @var      string    $icon    The string used to set menu icon.
76
-	 */
77
-	public $icon;
78
-
79
-	/**
80
-	 * The menu position.
81
-	 *
82
-	 * @since    1.0.0
83
-	 * @access   public
84
-	 * @var      int    $position    The string used to set menu position.
85
-	 */
86
-	public $position;
87
-
88
-	/**
89
-	 * The menu plugin name.
90
-	 *
91
-	 * @since    1.0.0
92
-	 * @access   private
93
-	 * @var      string    $plugin_name    The string used to uniquely identify this plugin.
94
-	 */
95
-	private $plugin_name;
96
-
97
-	/**
98
-	 * Boot Menu.
99
-	 *
100
-	 * @param  string $plugin_name The string used to uniquely identify this plugin.
101
-	 * @since    1.0.0
102
-	 * @access   public
103
-	 */
104
-	public function __construct( $plugin_name ) {
105
-		$this->plugin_name = $plugin_name;
106
-	}
107
-
108
-	/**
109
-	 * Create a new menu page.
110
-	 *
111
-	 * @since    1.0.0
112
-	 * @access   public
113
-	 */
114
-	public function save() {
115
-		add_action( 'admin_menu', array( $this, 'create_submenu' ) );
116
-	}
117
-
118
-	/**
119
-	 * Create a new submenu page.
120
-	 *
121
-	 * @since    1.0.0
122
-	 * @param    array $options Pass proprties as an array.
123
-	 * @access   public
124
-	 */
125
-	public function make( $options = array() ) {
126
-		foreach ( $options as $property => $value ) {
127
-			if ( property_exists( $this, $property ) ) {
128
-				$this->{$property} = $value;
129
-			}
130
-		}
131
-		add_action( 'admin_menu', array( $this, 'create_submenu' ) );
132
-	}
133
-
134
-	/**
135
-	 * Register new submenu page.
136
-	 *
137
-	 * @return void
138
-	 */
139
-	public function create_submenu() {
140
-		if ( current_user_can( $this->capability ) ) {
141
-			$hook = add_submenu_page(
142
-				$this->parent_slug,
143
-				$this->page_title,
144
-				$this->menu_title,
145
-				$this->capability,
146
-				$this->slug,
147
-				$this->callback,
148
-				$this->icon
149
-			);
150
-		}
151
-
152
-		add_action( 'load-' . $hook, array( $this, 'init_hooks' ) );
153
-	}
154
-
155
-	/**
156
-	 * Initialize hooks for the admin page.
157
-	 *
158
-	 * @return void
159
-	 */
160
-	public function init_hooks() {
161
-		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
162
-	}
163
-
164
-	/**
165
-	 * Load scripts and styles for the submenu page.
166
-	 *
167
-	 * @return void
168
-	 */
169
-	public function enqueue_scripts() {
170
-		wp_enqueue_style( $this->plugin_name . '-vendors' );
171
-		wp_enqueue_style( $this->plugin_name . '-admin' );
172
-		wp_enqueue_script( $this->plugin_name . '-admin' );
173
-	}
25
+    /**
26
+     * The menu page title.
27
+     *
28
+     * @since    1.0.0
29
+     * @access   public
30
+     * @var      string    $page_title    The string used to set menu page title.
31
+     */
32
+    public $page_title;
33
+
34
+    /**
35
+     * The menu title.
36
+     *
37
+     * @since    1.0.0
38
+     * @access   public
39
+     * @var      string    $menu_title    The string used to set menu title.
40
+     */
41
+    public $menu_title;
42
+
43
+    /**
44
+     * The menu capability.
45
+     *
46
+     * @since    1.0.0
47
+     * @access   public
48
+     * @var      string    $capability    The string used to set menu capability.
49
+     */
50
+    public $capability;
51
+
52
+    /**
53
+     * The menu slug.
54
+     *
55
+     * @since    1.0.0
56
+     * @access   public
57
+     * @var      string    $slug    The string used to set menu slug.
58
+     */
59
+    public $slug;
60
+
61
+    /**
62
+     * The callback to render content.
63
+     *
64
+     * @since    1.0.0
65
+     * @access   public
66
+     * @var      callback    $callback    The callback used to render content.
67
+     */
68
+    public $callback;
69
+
70
+    /**
71
+     * The menu icon.
72
+     *
73
+     * @since    1.0.0
74
+     * @access   public
75
+     * @var      string    $icon    The string used to set menu icon.
76
+     */
77
+    public $icon;
78
+
79
+    /**
80
+     * The menu position.
81
+     *
82
+     * @since    1.0.0
83
+     * @access   public
84
+     * @var      int    $position    The string used to set menu position.
85
+     */
86
+    public $position;
87
+
88
+    /**
89
+     * The menu plugin name.
90
+     *
91
+     * @since    1.0.0
92
+     * @access   private
93
+     * @var      string    $plugin_name    The string used to uniquely identify this plugin.
94
+     */
95
+    private $plugin_name;
96
+
97
+    /**
98
+     * Boot Menu.
99
+     *
100
+     * @param  string $plugin_name The string used to uniquely identify this plugin.
101
+     * @since    1.0.0
102
+     * @access   public
103
+     */
104
+    public function __construct( $plugin_name ) {
105
+        $this->plugin_name = $plugin_name;
106
+    }
107
+
108
+    /**
109
+     * Create a new menu page.
110
+     *
111
+     * @since    1.0.0
112
+     * @access   public
113
+     */
114
+    public function save() {
115
+        add_action( 'admin_menu', array( $this, 'create_submenu' ) );
116
+    }
117
+
118
+    /**
119
+     * Create a new submenu page.
120
+     *
121
+     * @since    1.0.0
122
+     * @param    array $options Pass proprties as an array.
123
+     * @access   public
124
+     */
125
+    public function make( $options = array() ) {
126
+        foreach ( $options as $property => $value ) {
127
+            if ( property_exists( $this, $property ) ) {
128
+                $this->{$property} = $value;
129
+            }
130
+        }
131
+        add_action( 'admin_menu', array( $this, 'create_submenu' ) );
132
+    }
133
+
134
+    /**
135
+     * Register new submenu page.
136
+     *
137
+     * @return void
138
+     */
139
+    public function create_submenu() {
140
+        if ( current_user_can( $this->capability ) ) {
141
+            $hook = add_submenu_page(
142
+                $this->parent_slug,
143
+                $this->page_title,
144
+                $this->menu_title,
145
+                $this->capability,
146
+                $this->slug,
147
+                $this->callback,
148
+                $this->icon
149
+            );
150
+        }
151
+
152
+        add_action( 'load-' . $hook, array( $this, 'init_hooks' ) );
153
+    }
154
+
155
+    /**
156
+     * Initialize hooks for the admin page.
157
+     *
158
+     * @return void
159
+     */
160
+    public function init_hooks() {
161
+        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
162
+    }
163
+
164
+    /**
165
+     * Load scripts and styles for the submenu page.
166
+     *
167
+     * @return void
168
+     */
169
+    public function enqueue_scripts() {
170
+        wp_enqueue_style( $this->plugin_name . '-vendors' );
171
+        wp_enqueue_style( $this->plugin_name . '-admin' );
172
+        wp_enqueue_script( $this->plugin_name . '-admin' );
173
+    }
174 174
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @since    1.0.0
102 102
 	 * @access   public
103 103
 	 */
104
-	public function __construct( $plugin_name ) {
104
+	public function __construct($plugin_name) {
105 105
 		$this->plugin_name = $plugin_name;
106 106
 	}
107 107
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 * @access   public
113 113
 	 */
114 114
 	public function save() {
115
-		add_action( 'admin_menu', array( $this, 'create_submenu' ) );
115
+		add_action('admin_menu', array($this, 'create_submenu'));
116 116
 	}
117 117
 
118 118
 	/**
@@ -122,13 +122,13 @@  discard block
 block discarded – undo
122 122
 	 * @param    array $options Pass proprties as an array.
123 123
 	 * @access   public
124 124
 	 */
125
-	public function make( $options = array() ) {
126
-		foreach ( $options as $property => $value ) {
127
-			if ( property_exists( $this, $property ) ) {
125
+	public function make($options = array()) {
126
+		foreach ($options as $property => $value) {
127
+			if (property_exists($this, $property)) {
128 128
 				$this->{$property} = $value;
129 129
 			}
130 130
 		}
131
-		add_action( 'admin_menu', array( $this, 'create_submenu' ) );
131
+		add_action('admin_menu', array($this, 'create_submenu'));
132 132
 	}
133 133
 
134 134
 	/**
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * @return void
138 138
 	 */
139 139
 	public function create_submenu() {
140
-		if ( current_user_can( $this->capability ) ) {
140
+		if (current_user_can($this->capability)) {
141 141
 			$hook = add_submenu_page(
142 142
 				$this->parent_slug,
143 143
 				$this->page_title,
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 			);
150 150
 		}
151 151
 
152
-		add_action( 'load-' . $hook, array( $this, 'init_hooks' ) );
152
+		add_action('load-'.$hook, array($this, 'init_hooks'));
153 153
 	}
154 154
 
155 155
 	/**
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 * @return void
159 159
 	 */
160 160
 	public function init_hooks() {
161
-		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
161
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));
162 162
 	}
163 163
 
164 164
 	/**
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 	 * @return void
168 168
 	 */
169 169
 	public function enqueue_scripts() {
170
-		wp_enqueue_style( $this->plugin_name . '-vendors' );
171
-		wp_enqueue_style( $this->plugin_name . '-admin' );
172
-		wp_enqueue_script( $this->plugin_name . '-admin' );
170
+		wp_enqueue_style($this->plugin_name.'-vendors');
171
+		wp_enqueue_style($this->plugin_name.'-admin');
172
+		wp_enqueue_script($this->plugin_name.'-admin');
173 173
 	}
174 174
 }
Please login to merge, or discard this patch.
src/Composer/ComposerScripts.php 2 patches
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -26,149 +26,149 @@
 block discarded – undo
26 26
  */
27 27
 class ComposerScripts {
28 28
 
29
-	/**
30
-	 * Handle the post-install Composer event.
31
-	 *
32
-	 * @param  \Composer\Script\Event $event The composer event.
33
-	 * @return void
34
-	 */
35
-	public static function post_install( Event $event ) {
36
-		require_once $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/autoload.php';
37
-	}
38
-
39
-	/**
40
-	 * Handle the post-update Composer event.
41
-	 *
42
-	 * @param  \Composer\Script\Event $event The composer event.
43
-	 * @return void
44
-	 */
45
-	public static function post_update( Event $event ) {
46
-		require_once $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/autoload.php';
47
-	}
48
-
49
-	/**
50
-	 * Handle the post-autoload-dump Composer event.
51
-	 *
52
-	 * @param  \Composer\Script\Event $event The composer event.
53
-	 * @return void
54
-	 */
55
-	public static function post_autoload_dump( Event $event ) {
56
-		require_once $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/autoload.php';
57
-
58
-		$dir  = $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/../';
59
-		$root = dirname( $event->getComposer()->getConfig()->get( 'vendor-dir' ) );
60
-
61
-		$vendor_name         = strtolower( basename( $root ) );
62
-		$partials            = explode( '-', $vendor_name );
63
-		$camel_case_partials = array();
64
-		foreach ( $partials as $partial ) {
65
-			$camel_case_partials[] = ucfirst( strtolower( $partial ) );
66
-		}
67
-		$camel_case = implode( '_', $camel_case_partials );
68
-		$snake_case = implode( '_', $partials );
69
-
70
-		$files = array(
71
-			'/admin/class-wpb-admin.php',
72
-			'/admin/class-wpb-admin-menu.php',
73
-			'/admin/class-wpb-admin-submenu.php',
74
-			'/admin/partials/wpb-admin-display.php',
75
-			'/admin/css/wpb-admin.css',
76
-			'/admin/js/wpb-admin.js',
77
-			'/app/User.php',
78
-			'/app/Post.php',
79
-			'/app/Http/Controllers/ProductController.php',
80
-			'/app/Http/Middleware/AuthMiddleware.php',
81
-			'/app/Http/Middleware/VerifyCsrfToken.php',
82
-			'/app/Http/Kernel.php',
83
-			'/app/Exceptions/Handler.php',
84
-			'/bootstrap/app.php',
85
-			'/database/migrations/class-create-customers-table.php',
86
-			'/database/seeds/class-customers-table.php',
87
-			'/includes/class-wpb-activator.php',
88
-			'/includes/class-wpb-deactivator.php',
89
-			'/includes/class-wpb-i18n.php',
90
-			'/includes/class-wpb-loader.php',
91
-			'/includes/class-wpb.php',
92
-			'/public/class-wpb-public.php',
93
-			'/public/partials/wpb-public-display.php',
94
-			'/public/css/wpb-public.css',
95
-			'/public/js/wpb-public.js',
96
-			'/resources/js/admin/main.js',
97
-			'/resources/js/frontend/main.js',
98
-			'/resources/js/spa/main.js',
99
-			'/routes/web.php',
100
-			'/routes/api.php',
101
-			'/src/Database/Eloquent/Scopes/PostAuthorScope.php',
102
-			'/src/Database/Eloquent/Scopes/PostStatusScope.php',
103
-			'/src/Database/Eloquent/Scopes/PostTypeScope.php',
104
-			'/src/Database/DB.php',
105
-			'/src/Exceptions/Handler.php',
106
-			'/src/Http/Kernel.php',
107
-			'/src/Http/Events/RequestHandler.php',
108
-			'/src/helpers.php',
109
-			'/src/Support/Facades/Config.php',
110
-			'/src/Support/Facades/Route.php',
111
-			'/src/Application.php',
112
-			'/tests/Application.php',
113
-			'/wpb.php',
114
-		);
115
-
116
-		foreach ( $files as $file ) {
117
-			$file = $root . $file;
118
-			if ( file_exists( $file ) ) {
119
-				global $wp_filesystem;
120
-
121
-				$contents = $wp_filesystem->get_contents( $file );
122
-				$contents = str_replace( 'wpb_', $snake_case . '_', $contents );
123
-				$contents = str_replace( 'wpb', $vendor_name, $contents );
124
-				$contents = str_replace( 'WPB_APP_ROOT', strtoupper( $camel_case ) . '_APP_ROOT', $contents );
125
-				$contents = str_replace( 'WPB_FILE', strtoupper( $camel_case ) . '_FILE', $contents );
126
-				$contents = str_replace( 'WPB_PATH', strtoupper( $camel_case ) . '_PATH', $contents );
127
-				$contents = str_replace( 'WPB_INCLUDES', strtoupper( $camel_case ) . '_INCLUDES', $contents );
128
-				$contents = str_replace( 'WPB_URL', strtoupper( $camel_case ) . '_URL', $contents );
129
-				$contents = str_replace( 'WPB_ASSETS', strtoupper( $camel_case ) . '_ASSETS', $contents );
130
-				$contents = str_replace( 'WPB_VERSION', strtoupper( $camel_case ) . '_VERSION', $contents );
131
-				$contents = str_replace( 'WPB', $camel_case, $contents );
132
-				$wp_filesystem->put_contents(
133
-					$file,
134
-					$contents
135
-				);
136
-
137
-				$dir           = dirname( $file );
138
-				$file_name     = basename( $file );
139
-				$new_file_name = str_replace( 'wpb', $vendor_name, $file_name );
140
-
141
-				if ( $file_name !== $new_file_name ) {
142
-					rename( $file, $dir . '/' . $new_file_name );
143
-				}
144
-			}
145
-		}
146
-
147
-		static::update_bootstrap( $root, $camel_case );
148
-	}
149
-
150
-	/**
151
-	 * Replace bootstrap file.
152
-	 *
153
-	 * @since    1.0.0
154
-	 * @access   public
155
-	 *
156
-	 * @param string $root The string is unique root path for each plugin.
157
-	 * @param string $camel_case This string is camel case of project name.
158
-	 *
159
-	 * @return void
160
-	 */
161
-	protected static function update_bootstrap( $root, $camel_case ) {
162
-		$file = $root . '/bootstrap/app.php';
163
-		if ( file_exists( $file ) ) {
164
-			global $wp_filesystem;
165
-			$contents = $wp_filesystem->get_contents( $file );
166
-			$contents = str_replace( 'WPB_APP_ROOT', strtoupper( $camel_case ) . '_APP_ROOT', $contents );
167
-			$wp_filesystem->put_contents(
168
-				$file,
169
-				$contents
170
-			);
171
-
172
-		}
173
-	}
29
+    /**
30
+     * Handle the post-install Composer event.
31
+     *
32
+     * @param  \Composer\Script\Event $event The composer event.
33
+     * @return void
34
+     */
35
+    public static function post_install( Event $event ) {
36
+        require_once $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/autoload.php';
37
+    }
38
+
39
+    /**
40
+     * Handle the post-update Composer event.
41
+     *
42
+     * @param  \Composer\Script\Event $event The composer event.
43
+     * @return void
44
+     */
45
+    public static function post_update( Event $event ) {
46
+        require_once $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/autoload.php';
47
+    }
48
+
49
+    /**
50
+     * Handle the post-autoload-dump Composer event.
51
+     *
52
+     * @param  \Composer\Script\Event $event The composer event.
53
+     * @return void
54
+     */
55
+    public static function post_autoload_dump( Event $event ) {
56
+        require_once $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/autoload.php';
57
+
58
+        $dir  = $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/../';
59
+        $root = dirname( $event->getComposer()->getConfig()->get( 'vendor-dir' ) );
60
+
61
+        $vendor_name         = strtolower( basename( $root ) );
62
+        $partials            = explode( '-', $vendor_name );
63
+        $camel_case_partials = array();
64
+        foreach ( $partials as $partial ) {
65
+            $camel_case_partials[] = ucfirst( strtolower( $partial ) );
66
+        }
67
+        $camel_case = implode( '_', $camel_case_partials );
68
+        $snake_case = implode( '_', $partials );
69
+
70
+        $files = array(
71
+            '/admin/class-wpb-admin.php',
72
+            '/admin/class-wpb-admin-menu.php',
73
+            '/admin/class-wpb-admin-submenu.php',
74
+            '/admin/partials/wpb-admin-display.php',
75
+            '/admin/css/wpb-admin.css',
76
+            '/admin/js/wpb-admin.js',
77
+            '/app/User.php',
78
+            '/app/Post.php',
79
+            '/app/Http/Controllers/ProductController.php',
80
+            '/app/Http/Middleware/AuthMiddleware.php',
81
+            '/app/Http/Middleware/VerifyCsrfToken.php',
82
+            '/app/Http/Kernel.php',
83
+            '/app/Exceptions/Handler.php',
84
+            '/bootstrap/app.php',
85
+            '/database/migrations/class-create-customers-table.php',
86
+            '/database/seeds/class-customers-table.php',
87
+            '/includes/class-wpb-activator.php',
88
+            '/includes/class-wpb-deactivator.php',
89
+            '/includes/class-wpb-i18n.php',
90
+            '/includes/class-wpb-loader.php',
91
+            '/includes/class-wpb.php',
92
+            '/public/class-wpb-public.php',
93
+            '/public/partials/wpb-public-display.php',
94
+            '/public/css/wpb-public.css',
95
+            '/public/js/wpb-public.js',
96
+            '/resources/js/admin/main.js',
97
+            '/resources/js/frontend/main.js',
98
+            '/resources/js/spa/main.js',
99
+            '/routes/web.php',
100
+            '/routes/api.php',
101
+            '/src/Database/Eloquent/Scopes/PostAuthorScope.php',
102
+            '/src/Database/Eloquent/Scopes/PostStatusScope.php',
103
+            '/src/Database/Eloquent/Scopes/PostTypeScope.php',
104
+            '/src/Database/DB.php',
105
+            '/src/Exceptions/Handler.php',
106
+            '/src/Http/Kernel.php',
107
+            '/src/Http/Events/RequestHandler.php',
108
+            '/src/helpers.php',
109
+            '/src/Support/Facades/Config.php',
110
+            '/src/Support/Facades/Route.php',
111
+            '/src/Application.php',
112
+            '/tests/Application.php',
113
+            '/wpb.php',
114
+        );
115
+
116
+        foreach ( $files as $file ) {
117
+            $file = $root . $file;
118
+            if ( file_exists( $file ) ) {
119
+                global $wp_filesystem;
120
+
121
+                $contents = $wp_filesystem->get_contents( $file );
122
+                $contents = str_replace( 'wpb_', $snake_case . '_', $contents );
123
+                $contents = str_replace( 'wpb', $vendor_name, $contents );
124
+                $contents = str_replace( 'WPB_APP_ROOT', strtoupper( $camel_case ) . '_APP_ROOT', $contents );
125
+                $contents = str_replace( 'WPB_FILE', strtoupper( $camel_case ) . '_FILE', $contents );
126
+                $contents = str_replace( 'WPB_PATH', strtoupper( $camel_case ) . '_PATH', $contents );
127
+                $contents = str_replace( 'WPB_INCLUDES', strtoupper( $camel_case ) . '_INCLUDES', $contents );
128
+                $contents = str_replace( 'WPB_URL', strtoupper( $camel_case ) . '_URL', $contents );
129
+                $contents = str_replace( 'WPB_ASSETS', strtoupper( $camel_case ) . '_ASSETS', $contents );
130
+                $contents = str_replace( 'WPB_VERSION', strtoupper( $camel_case ) . '_VERSION', $contents );
131
+                $contents = str_replace( 'WPB', $camel_case, $contents );
132
+                $wp_filesystem->put_contents(
133
+                    $file,
134
+                    $contents
135
+                );
136
+
137
+                $dir           = dirname( $file );
138
+                $file_name     = basename( $file );
139
+                $new_file_name = str_replace( 'wpb', $vendor_name, $file_name );
140
+
141
+                if ( $file_name !== $new_file_name ) {
142
+                    rename( $file, $dir . '/' . $new_file_name );
143
+                }
144
+            }
145
+        }
146
+
147
+        static::update_bootstrap( $root, $camel_case );
148
+    }
149
+
150
+    /**
151
+     * Replace bootstrap file.
152
+     *
153
+     * @since    1.0.0
154
+     * @access   public
155
+     *
156
+     * @param string $root The string is unique root path for each plugin.
157
+     * @param string $camel_case This string is camel case of project name.
158
+     *
159
+     * @return void
160
+     */
161
+    protected static function update_bootstrap( $root, $camel_case ) {
162
+        $file = $root . '/bootstrap/app.php';
163
+        if ( file_exists( $file ) ) {
164
+            global $wp_filesystem;
165
+            $contents = $wp_filesystem->get_contents( $file );
166
+            $contents = str_replace( 'WPB_APP_ROOT', strtoupper( $camel_case ) . '_APP_ROOT', $contents );
167
+            $wp_filesystem->put_contents(
168
+                $file,
169
+                $contents
170
+            );
171
+
172
+        }
173
+    }
174 174
 }
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 	 * @param  \Composer\Script\Event $event The composer event.
33 33
 	 * @return void
34 34
 	 */
35
-	public static function post_install( Event $event ) {
36
-		require_once $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/autoload.php';
35
+	public static function post_install(Event $event) {
36
+		require_once $event->getComposer()->getConfig()->get('vendor-dir').'/autoload.php';
37 37
 	}
38 38
 
39 39
 	/**
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	 * @param  \Composer\Script\Event $event The composer event.
43 43
 	 * @return void
44 44
 	 */
45
-	public static function post_update( Event $event ) {
46
-		require_once $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/autoload.php';
45
+	public static function post_update(Event $event) {
46
+		require_once $event->getComposer()->getConfig()->get('vendor-dir').'/autoload.php';
47 47
 	}
48 48
 
49 49
 	/**
@@ -52,20 +52,20 @@  discard block
 block discarded – undo
52 52
 	 * @param  \Composer\Script\Event $event The composer event.
53 53
 	 * @return void
54 54
 	 */
55
-	public static function post_autoload_dump( Event $event ) {
56
-		require_once $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/autoload.php';
55
+	public static function post_autoload_dump(Event $event) {
56
+		require_once $event->getComposer()->getConfig()->get('vendor-dir').'/autoload.php';
57 57
 
58
-		$dir  = $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/../';
59
-		$root = dirname( $event->getComposer()->getConfig()->get( 'vendor-dir' ) );
58
+		$dir  = $event->getComposer()->getConfig()->get('vendor-dir').'/../';
59
+		$root = dirname($event->getComposer()->getConfig()->get('vendor-dir'));
60 60
 
61
-		$vendor_name         = strtolower( basename( $root ) );
62
-		$partials            = explode( '-', $vendor_name );
61
+		$vendor_name         = strtolower(basename($root));
62
+		$partials            = explode('-', $vendor_name);
63 63
 		$camel_case_partials = array();
64
-		foreach ( $partials as $partial ) {
65
-			$camel_case_partials[] = ucfirst( strtolower( $partial ) );
64
+		foreach ($partials as $partial) {
65
+			$camel_case_partials[] = ucfirst(strtolower($partial));
66 66
 		}
67
-		$camel_case = implode( '_', $camel_case_partials );
68
-		$snake_case = implode( '_', $partials );
67
+		$camel_case = implode('_', $camel_case_partials);
68
+		$snake_case = implode('_', $partials);
69 69
 
70 70
 		$files = array(
71 71
 			'/admin/class-wpb-admin.php',
@@ -113,38 +113,38 @@  discard block
 block discarded – undo
113 113
 			'/wpb.php',
114 114
 		);
115 115
 
116
-		foreach ( $files as $file ) {
117
-			$file = $root . $file;
118
-			if ( file_exists( $file ) ) {
116
+		foreach ($files as $file) {
117
+			$file = $root.$file;
118
+			if (file_exists($file)) {
119 119
 				global $wp_filesystem;
120 120
 
121
-				$contents = $wp_filesystem->get_contents( $file );
122
-				$contents = str_replace( 'wpb_', $snake_case . '_', $contents );
123
-				$contents = str_replace( 'wpb', $vendor_name, $contents );
124
-				$contents = str_replace( 'WPB_APP_ROOT', strtoupper( $camel_case ) . '_APP_ROOT', $contents );
125
-				$contents = str_replace( 'WPB_FILE', strtoupper( $camel_case ) . '_FILE', $contents );
126
-				$contents = str_replace( 'WPB_PATH', strtoupper( $camel_case ) . '_PATH', $contents );
127
-				$contents = str_replace( 'WPB_INCLUDES', strtoupper( $camel_case ) . '_INCLUDES', $contents );
128
-				$contents = str_replace( 'WPB_URL', strtoupper( $camel_case ) . '_URL', $contents );
129
-				$contents = str_replace( 'WPB_ASSETS', strtoupper( $camel_case ) . '_ASSETS', $contents );
130
-				$contents = str_replace( 'WPB_VERSION', strtoupper( $camel_case ) . '_VERSION', $contents );
131
-				$contents = str_replace( 'WPB', $camel_case, $contents );
121
+				$contents = $wp_filesystem->get_contents($file);
122
+				$contents = str_replace('wpb_', $snake_case.'_', $contents);
123
+				$contents = str_replace('wpb', $vendor_name, $contents);
124
+				$contents = str_replace('WPB_APP_ROOT', strtoupper($camel_case).'_APP_ROOT', $contents);
125
+				$contents = str_replace('WPB_FILE', strtoupper($camel_case).'_FILE', $contents);
126
+				$contents = str_replace('WPB_PATH', strtoupper($camel_case).'_PATH', $contents);
127
+				$contents = str_replace('WPB_INCLUDES', strtoupper($camel_case).'_INCLUDES', $contents);
128
+				$contents = str_replace('WPB_URL', strtoupper($camel_case).'_URL', $contents);
129
+				$contents = str_replace('WPB_ASSETS', strtoupper($camel_case).'_ASSETS', $contents);
130
+				$contents = str_replace('WPB_VERSION', strtoupper($camel_case).'_VERSION', $contents);
131
+				$contents = str_replace('WPB', $camel_case, $contents);
132 132
 				$wp_filesystem->put_contents(
133 133
 					$file,
134 134
 					$contents
135 135
 				);
136 136
 
137
-				$dir           = dirname( $file );
138
-				$file_name     = basename( $file );
139
-				$new_file_name = str_replace( 'wpb', $vendor_name, $file_name );
137
+				$dir           = dirname($file);
138
+				$file_name     = basename($file);
139
+				$new_file_name = str_replace('wpb', $vendor_name, $file_name);
140 140
 
141
-				if ( $file_name !== $new_file_name ) {
142
-					rename( $file, $dir . '/' . $new_file_name );
141
+				if ($file_name !== $new_file_name) {
142
+					rename($file, $dir.'/'.$new_file_name);
143 143
 				}
144 144
 			}
145 145
 		}
146 146
 
147
-		static::update_bootstrap( $root, $camel_case );
147
+		static::update_bootstrap($root, $camel_case);
148 148
 	}
149 149
 
150 150
 	/**
@@ -158,12 +158,12 @@  discard block
 block discarded – undo
158 158
 	 *
159 159
 	 * @return void
160 160
 	 */
161
-	protected static function update_bootstrap( $root, $camel_case ) {
162
-		$file = $root . '/bootstrap/app.php';
163
-		if ( file_exists( $file ) ) {
161
+	protected static function update_bootstrap($root, $camel_case) {
162
+		$file = $root.'/bootstrap/app.php';
163
+		if (file_exists($file)) {
164 164
 			global $wp_filesystem;
165
-			$contents = $wp_filesystem->get_contents( $file );
166
-			$contents = str_replace( 'WPB_APP_ROOT', strtoupper( $camel_case ) . '_APP_ROOT', $contents );
165
+			$contents = $wp_filesystem->get_contents($file);
166
+			$contents = str_replace('WPB_APP_ROOT', strtoupper($camel_case).'_APP_ROOT', $contents);
167 167
 			$wp_filesystem->put_contents(
168 168
 				$file,
169 169
 				$contents
Please login to merge, or discard this patch.