From 3d260e2565b75966c0e73051258d550db86fd28c Mon Sep 17 00:00:00 2001 From: thanghv Date: Fri, 12 Jun 2020 16:30:18 +0700 Subject: [PATCH] Refact --- class/class-mainwp-child-back-up-buddy.php | 3 +++ class/class-mainwp-child-ithemes-security.php | 2 ++ class/class-mainwp-child-posts.php | 8 +++++--- class/class-mainwp-child-stats.php | 2 +- class/class-mainwp-child-updraft-plus-backups.php | 2 ++ class/class-mainwp-client-report-base.php | 5 +++++ mainwp-child.php | 5 ++++- 7 files changed, 22 insertions(+), 5 deletions(-) diff --git a/class/class-mainwp-child-back-up-buddy.php b/class/class-mainwp-child-back-up-buddy.php index 0565462..7b12e24 100644 --- a/class/class-mainwp-child-back-up-buddy.php +++ b/class/class-mainwp-child-back-up-buddy.php @@ -10,6 +10,9 @@ * * The code is used for the MainWP Buddy Extension * Extension URL: https://mainwp.com/extension/mainwpbuddy/ + * + * @package MainWP\Child + * */ use MainWP\Child\MainWP_Helper; diff --git a/class/class-mainwp-child-ithemes-security.php b/class/class-mainwp-child-ithemes-security.php index 5241240..950faec 100644 --- a/class/class-mainwp-child-ithemes-security.php +++ b/class/class-mainwp-child-ithemes-security.php @@ -11,6 +11,8 @@ * * The code is used for the MainWP iThemes Security Extension * Extension URL: https://mainwp.com/extension/ithemes-security/ + * + * @package MainWP\Child */ use MainWP\Child\MainWP_Helper; diff --git a/class/class-mainwp-child-posts.php b/class/class-mainwp-child-posts.php index 99ebb68..85261e2 100644 --- a/class/class-mainwp-child-posts.php +++ b/class/class-mainwp-child-posts.php @@ -9,6 +9,8 @@ namespace MainWP\Child; +//phpcs:disable Generic.Metrics.CyclomaticComplexity -- Required to achieve desired results, pull request solutions appreciated. + /** * Class MainWP_Child_Posts * @@ -815,7 +817,7 @@ class MainWP_Child_Posts { * @param bool $is_post_plus TRUE|FALSE, Whether or not this came from MainWP Post Plus Extension. * * @uses \MainWP\Child\MainWP_Child_Posts::set_custom_post_fields() - * @uses \MainWP\Child\MainWP_Child_Posts::create_seo_extension_activated() + * @uses \MainWP\Child\MainWP_Child_Posts::update_seo_meta() * @uses \MainWP\Child\MainWP_Child_Posts::create_set_categories() * @uses \MainWP\Child\MainWP_Child_Posts::create_featured_image() * @uses \MainWP\Child\MainWP_Child_Posts::post_plus_update_author() @@ -834,7 +836,7 @@ class MainWP_Child_Posts { // yoast seo plugin activated. if ( $seo_ext_activated ) { - $this->create_seo_extension_activated( $new_post_id, $post_custom ); + $this->update_seo_meta( $new_post_id, $post_custom ); } $this->create_set_categories( $new_post_id, $post_category, $post_to_only_existing_categories ); @@ -1233,7 +1235,7 @@ class MainWP_Child_Posts { * @uses \WPSEO_Meta::$meta_prefix() * @uses \Exception() */ - private function create_seo_extension_activated( $new_post_id, $post_custom ) { + private function update_seo_meta( $new_post_id, $post_custom ) { $_seo_opengraph_image = isset( $post_custom[ \WPSEO_Meta::$meta_prefix . 'opengraph-image' ] ) ? $post_custom[ \WPSEO_Meta::$meta_prefix . 'opengraph-image' ] : array(); $_seo_opengraph_image = current( $_seo_opengraph_image ); diff --git a/class/class-mainwp-child-stats.php b/class/class-mainwp-child-stats.php index 4198520..9f96ce3 100644 --- a/class/class-mainwp-child-stats.php +++ b/class/class-mainwp-child-stats.php @@ -733,7 +733,7 @@ class MainWP_Child_Stats { $uploadDir = $uploadDir[0]; $popenHandle = popen( 'du -s ' . $directory . ' --exclude "' . str_replace( ABSPATH, '', $uploadDir ) . '"', 'r' ); // phpcs:ignore -- run if enabled. if ( 'resource' === gettype( $popenHandle ) ) { - $size = fread( $popenHandle, 1024 ); + $size = fread( $popenHandle, 1024 ); //phpcs:ignore -- custom read file. pclose( $popenHandle ); $size = substr( $size, 0, strpos( $size, "\t" ) ); if ( $size && MainWP_Helper::ctype_digit( $size ) ) { diff --git a/class/class-mainwp-child-updraft-plus-backups.php b/class/class-mainwp-child-updraft-plus-backups.php index c8e6bb3..6e82adc 100644 --- a/class/class-mainwp-child-updraft-plus-backups.php +++ b/class/class-mainwp-child-updraft-plus-backups.php @@ -3,6 +3,8 @@ * MainWP Updraft Plus Backups * * This code is used for the MainWP UpdraftPlus Extension. + * + * @package MainWP\Child */ use MainWP\Child\MainWP_Helper; diff --git a/class/class-mainwp-client-report-base.php b/class/class-mainwp-client-report-base.php index e5ebb15..bbc0f4c 100644 --- a/class/class-mainwp-client-report-base.php +++ b/class/class-mainwp-client-report-base.php @@ -17,6 +17,11 @@ namespace MainWP\Child; */ class MainWP_Client_Report_Base { + /** + * Public static variable to hold the single instance of the class. + * + * @var mixed Default null + */ public static $instance = null; /** diff --git a/mainwp-child.php b/mainwp-child.php index f3bf928..76e3adf 100644 --- a/mainwp-child.php +++ b/mainwp-child.php @@ -1,6 +1,9 @@