33namespace WP2StaticS3 ;
44
55class Controller {
6- public function run () {
7- // initialize options DB
6+ public function run () : void {
87 global $ wpdb ;
98
109 $ table_name = $ wpdb ->prefix . 'wp2static_addon_s3_options ' ;
@@ -23,8 +22,6 @@ public function run() {
2322 require_once ABSPATH . 'wp-admin/includes/upgrade.php ' ;
2423 dbDelta ( $ sql );
2524
26- // check for seed data
27- // if deployment_url option doesn't exist, create:
2825 $ options = $ this ->getOptions ();
2926
3027 if ( ! isset ( $ options ['s3Bucket ' ] ) ) {
@@ -49,21 +46,17 @@ public function run() {
4946
5047 add_action (
5148 'wp2static_post_deploy_trigger ' ,
52- [ 'WP2StaticS3\Deployer ' , 'cloudfront_invalidate ' ],
49+ [ 'WP2StaticS3\Deployer ' , 'cloudfront_invalidate_all_items ' ],
5350 15 ,
5451 1
5552 );
5653
57- // if ( defined( 'WP_CLI' ) ) {
58- // \WP_CLI::add_command(
59- // 'wp2static s3',
60- // [ 'WP2StaticS3\CLI', 's3' ]);
61- // }
62- }
63-
64- // TODO: is this needed? confirm slashing of destination URLs...
65- public function modifyWordPressSiteURL ( $ site_url ) {
66- return rtrim ( $ site_url , '/ ' );
54+ if ( defined ( 'WP_CLI ' ) ) {
55+ \WP_CLI ::add_command (
56+ 'wp2static s3 ' ,
57+ [ 'WP2StaticS3\CLI ' , 's3 ' ]
58+ );
59+ }
6760 }
6861
6962 /**
@@ -210,8 +203,10 @@ public static function seedOptions() : void {
210203
211204 /**
212205 * Save options
206+ *
207+ * @param mixed $value option value to save
213208 */
214- public static function saveOption ( $ name , $ value ) : void {
209+ public static function saveOption ( string $ name , $ value ) : void {
215210 global $ wpdb ;
216211
217212 $ table_name = $ wpdb ->prefix . 'wp2static_addon_s3_options ' ;
@@ -238,7 +233,7 @@ public static function renderS3Page() : void {
238233 }
239234
240235
241- public function deploy ( $ processed_site_path ) {
236+ public function deploy ( string $ processed_site_path ) : void {
242237 \WP2Static \WsLog::l ( 'S3 Addon deploying ' );
243238
244239 $ s3_deployer = new Deployer ();
@@ -249,7 +244,7 @@ public function deploy( $processed_site_path ) {
249244 * Naive encypting/decrypting
250245 *
251246 */
252- public static function encrypt_decrypt ( $ action , $ string ) {
247+ public static function encrypt_decrypt ( string $ action , string $ string ) : string {
253248 $ output = false ;
254249 $ encrypt_method = 'AES-256-CBC ' ;
255250
@@ -268,13 +263,13 @@ public static function encrypt_decrypt( $action, $string ) {
268263
269264 if ( $ action == 'encrypt ' ) {
270265 $ output = openssl_encrypt ( $ string , $ encrypt_method , $ key , 0 , $ variate );
271- $ output = base64_encode ( $ output );
266+ $ output = base64_encode ( ( string ) $ output );
272267 } elseif ( $ action == 'decrypt ' ) {
273268 $ output =
274269 openssl_decrypt ( base64_decode ( $ string ), $ encrypt_method , $ key , 0 , $ variate );
275270 }
276271
277- return $ output ;
272+ return ( string ) $ output ;
278273 }
279274
280275 public static function activate_for_single_site () : void {
@@ -337,13 +332,19 @@ public static function activate( bool $network_wide = null ) : void {
337332 }
338333 }
339334
340- public static function addSubmenuPage ( $ submenu_pages ) {
335+ /**
336+ * Add WP2Static submenu
337+ *
338+ * @param mixed[] $submenu_pages array of submenu pages
339+ * @return mixed[] array of submenu pages
340+ */
341+ public static function addSubmenuPage ( array $ submenu_pages ) : array {
341342 $ submenu_pages ['s3 ' ] = [ 'WP2StaticS3\Controller ' , 'renderS3Page ' ];
342343
343344 return $ submenu_pages ;
344345 }
345346
346- public static function saveOptionsFromUI () {
347+ public static function saveOptionsFromUI () : void {
347348 check_admin_referer ( 'wp2static-s3-options ' );
348349
349350 global $ wpdb ;
0 commit comments