@@ -26,149 +26,149 @@ |
||
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 | } |
@@ -32,8 +32,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |