From 4f600b5feb1bfeb7cff52dd79f832440b1434dba Mon Sep 17 00:00:00 2001 From: Gabriel Koen Date: Thu, 30 Jul 2015 11:59:16 -0700 Subject: [PATCH] Running phpcbf to automatically fix phpcs errors --- classes/admin.php | 44 +++++++++----------- classes/attachments-importer.php | 12 ++---- classes/autoloader.php | 16 ++++---- classes/categories-importer.php | 5 +-- classes/comments-importer.php | 7 ++-- classes/config-helper.php | 24 +++++------ classes/config.php | 70 ++++++++++++++++---------------- classes/menus-importer.php | 42 ++++++++----------- classes/options-importer.php | 17 +++----- classes/pmc-singleton.php | 8 ++-- classes/posts-importer.php | 21 ++++------ classes/rest-api-oauth.php | 52 +++++++++--------------- classes/rest-api-router.php | 2 +- classes/tags-importer.php | 7 +--- classes/taxonomies-importer.php | 7 ++-- classes/terms-importer.php | 10 ++--- classes/users-importer.php | 9 ++-- classes/xmlrpc-client.php | 8 ++-- classes/xmlrpc-router.php | 11 +++-- pmc-theme-unit-test.php | 10 ++--- templates/admin-ui.php | 2 +- 21 files changed, 165 insertions(+), 219 deletions(-) diff --git a/classes/admin.php b/classes/admin.php index 068e930..83939bf 100644 --- a/classes/admin.php +++ b/classes/admin.php @@ -47,14 +47,14 @@ protected function _setup_hooks() { add_action( 'admin_enqueue_scripts', array( $this, 'load_assets' ) ); - add_action( "wp_ajax_import_data_from_production", array( $this, "import_data_from_production" ) ); + add_action( 'wp_ajax_import_data_from_production', array( $this, 'import_data_from_production' ) ); - add_action( "wp_ajax_import_xmlrpc_data_from_production", array( + add_action( 'wp_ajax_import_xmlrpc_data_from_production', array( $this, - "import_xmlrpc_data_from_production" + 'import_xmlrpc_data_from_production', ) ); - add_action( "wp_ajax_get_client_configuration_details", array( $this, "get_client_configuration_details" ) ); + add_action( 'wp_ajax_get_client_configuration_details', array( $this, 'get_client_configuration_details' ) ); } @@ -99,7 +99,6 @@ public function register_post_types_for_import() { } } - } /** @@ -126,7 +125,6 @@ public function register_taxonomies_for_import() { Taxonomies_Importer::get_instance()->save_taxonomy( $taxonomy ); } - } } @@ -179,7 +177,7 @@ function add_admin_menu() { add_management_page( 'Sync from Production', 'Sync from Production', 'manage_options', 'data-import', array( $this, - 'data_import_options' + 'data_import_options', ) ); } @@ -202,7 +200,7 @@ function data_import_options() { $this->_domains = apply_filters( 'pmc_theme_ut_domains', array() ); - echo Config_Helper::render_template( PMC_THEME_UNIT_TEST_ROOT . '/templates/admin-ui.php', array( "domains" => $this->_domains ) ); + echo Config_Helper::render_template( PMC_THEME_UNIT_TEST_ROOT . '/templates/admin-ui.php', array( 'domains' => $this->_domains ) ); } @@ -218,7 +216,7 @@ public function import_data_from_production() { // check to see if the submitted nonce matches with the // generated nonce we created earlier - if ( empty( $_POST["import_nOnce"] ) || ! wp_verify_nonce( $_POST["import_nOnce"], 'import-from-production' ) || empty( $_POST["domain"] ) ) { + if ( empty( $_POST['import_nOnce'] ) || ! wp_verify_nonce( $_POST['import_nOnce'], 'import-from-production' ) || empty( $_POST['domain'] ) ) { return; @@ -226,9 +224,9 @@ public function import_data_from_production() { $return_info = ''; - if ( ! empty( $_POST["route"] ) ) { + if ( ! empty( $_POST['route'] ) ) { - foreach ( $_POST["route"] as $key => $value ) { + foreach ( $_POST['route'] as $key => $value ) { $route['name'] = sanitize_text_field( $key ); @@ -241,13 +239,11 @@ public function import_data_from_production() { $route['query_params'][ $query_key ] = sanitize_text_field( $query_value ); } - } - } $params = array( - 'domain' => sanitize_text_field( $_POST["domain"] ), + 'domain' => sanitize_text_field( $_POST['domain'] ), 'code' => sanitize_text_field( $_POST['code'] ), 'route' => $route, ); @@ -276,20 +272,19 @@ public function import_xmlrpc_data_from_production() { // check to see if the submitted nonce matches with the // generated nonce we created earlier - if ( empty( $_POST["import_xmlrpc_nOnce"] ) || ! wp_verify_nonce( $_POST["import_xmlrpc_nOnce"], 'import-xmlrpc-from-production' ) || empty( $_POST["domain"] ) ) { + if ( empty( $_POST['import_xmlrpc_nOnce'] ) || ! wp_verify_nonce( $_POST['import_xmlrpc_nOnce'], 'import-xmlrpc-from-production' ) || empty( $_POST['domain'] ) ) { return; } $params = array( - 'domain' => sanitize_text_field( $_POST["domain"] ), - 'route' => sanitize_text_field( $_POST["route"] ), + 'domain' => sanitize_text_field( $_POST['domain'] ), + 'route' => sanitize_text_field( $_POST['route'] ), ); $return_info = XMLRPC_Router::get_instance()->call_xmlrpc_api_route( $params ); - ob_clean(); header( 'Content-Type: application/json' ); echo wp_json_encode( $return_info ); @@ -310,25 +305,24 @@ public function get_client_configuration_details() { // check to see if the submitted nonce matches with the // generated nonce we created earlier - if ( empty( $_POST["client_nOnce"] ) || ! wp_verify_nonce( $_POST["client_nOnce"], 'get-client-config-details' ) ) { + if ( empty( $_POST['client_nOnce'] ) || ! wp_verify_nonce( $_POST['client_nOnce'], 'get-client-config-details' ) ) { return; } - $domain = sanitize_text_field( $_POST["domain"] ); + $domain = sanitize_text_field( $_POST['domain'] ); $params = array( 'domain' => $domain, ); - $client_details["config_oauth"] = apply_filters( 'pmc_theme_ut_endpoints_config', array(), $params ); - - $client_details["xmlrpc_routes"] = apply_filters( 'pmc_theme_ut_xmlrpc_routes', array() ); + $client_details['config_oauth'] = apply_filters( 'pmc_theme_ut_endpoints_config', array(), $params ); - $client_details["all_routes"] = apply_filters( 'pmc_theme_ut_domain_routes', array() ); + $client_details['xmlrpc_routes'] = apply_filters( 'pmc_theme_ut_xmlrpc_routes', array() ); - $client_details["post_routes"] = apply_filters( 'pmc_theme_ut_posts_routes', array() ); + $client_details['all_routes'] = apply_filters( 'pmc_theme_ut_domain_routes', array() ); + $client_details['post_routes'] = apply_filters( 'pmc_theme_ut_posts_routes', array() ); ob_clean(); header( 'Content-Type: application/json' ); diff --git a/classes/attachments-importer.php b/classes/attachments-importer.php index ccc55c2..87ab31a 100644 --- a/classes/attachments-importer.php +++ b/classes/attachments-importer.php @@ -56,7 +56,7 @@ private function _save_attachment( $image_url, $post_ID ) { $image_data = file_get_contents( $image_url ); if ( false === $image_data ) { - throw new \Exception( $time . " No Image data returned for image URL " . $image_url ); + throw new \Exception( $time . ' No Image data returned for image URL ' . $image_url ); } file_put_contents( $file, $image_data ); @@ -67,7 +67,7 @@ private function _save_attachment( $image_url, $post_ID ) { 'post_mime_type' => $wp_filetype['type'], 'post_title' => sanitize_file_name( $filename ), 'post_content' => '', - 'post_status' => 'inherit' + 'post_status' => 'inherit', ); $attachment_id = wp_insert_attachment( $attachment, $file, $post_ID ); @@ -78,18 +78,16 @@ private function _save_attachment( $image_url, $post_ID ) { wp_update_attachment_metadata( $attachment_id, $attach_data ); - if ( is_a( $attachment_id, "WP_Error" ) ) { + if ( is_a( $attachment_id, 'WP_Error' ) ) { - error_log( $time . " -- " . $attachment_id->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' -- ' . $attachment_id->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); } else { error_log( "{$time} -- Attachment URL **-- { $image_url } --** added with ID = {$attachment_id}" . PHP_EOL, 3, PMC_THEME_UNIT_TEST_IMPORT_LOG_FILE ); } - } - } catch ( \Exception $e ) { error_log( $e->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); @@ -125,7 +123,6 @@ public function save_featured_image( $image_url, $post_ID ) { $post_meta_id = set_post_thumbnail( $post_ID, $attach_id ); } - } catch ( \Exception $e ) { error_log( 'Save Featured Image Failed with Error ---- ' . $e->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); @@ -160,7 +157,6 @@ public function instant_attachments_import( $attachments_json, $post_ID ) { $attachments_info[] = $attachments_id; } - } return $attachments_info; diff --git a/classes/autoloader.php b/classes/autoloader.php index bc386c0..60900be 100644 --- a/classes/autoloader.php +++ b/classes/autoloader.php @@ -23,16 +23,16 @@ public static function load_resource( $resource = '' ) { } $path = explode( - '\\', - str_replace( '_', '-', $resource ) - ); + '\\', + str_replace( '_', '-', $resource ) + ); $class_path = strtolower( - implode( - '/', - array_slice( $path, 2 ) - ) - ); + implode( + '/', + array_slice( $path, 2 ) + ) + ); $resource_path = sprintf( '%s/classes/%s.php', untrailingslashit( PMC_THEME_UNIT_TEST_ROOT ), $class_path ); diff --git a/classes/categories-importer.php b/classes/categories-importer.php index 94accc4..d89bedf 100644 --- a/classes/categories-importer.php +++ b/classes/categories-importer.php @@ -50,9 +50,9 @@ public function save_category( $category_json ) { $category_id = wp_insert_category( $category_array ); - if ( is_a( $category_id, "WP_Error" ) ) { + if ( is_a( $category_id, 'WP_Error' ) ) { - error_log( $time . " -- " . $category_id->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' -- ' . $category_id->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); } else { @@ -66,7 +66,6 @@ public function save_category( $category_json ) { error_log( "{$time} -- Exists Category **-- {$category_json['name']} --** with ID = {$category_id['term_id']}" . PHP_EOL, 3, PMC_THEME_UNIT_TEST_DUPLICATE_LOG_FILE ); } - } catch ( \Exception $e ) { error_log( $e->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); diff --git a/classes/comments-importer.php b/classes/comments-importer.php index 1cf8d76..407c85e 100644 --- a/classes/comments-importer.php +++ b/classes/comments-importer.php @@ -55,16 +55,15 @@ public function save_comment( $comment_json, $post_ID ) { $comment_id = wp_insert_comment( $comment_data ); - if ( is_a( $comment_id, "WP_Error" ) ) { + if ( is_a( $comment_id, 'WP_Error' ) ) { - error_log( $time . " -- " . $comment_id->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' -- ' . $comment_id->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); } else { error_log( "{$time} -- Comment from author **-- {$comment_json['author']['name'] } --** added with ID = {$comment_id}" . PHP_EOL, 3, PMC_THEME_UNIT_TEST_IMPORT_LOG_FILE ); } - } catch ( \Exception $e ) { error_log( $e->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); @@ -133,7 +132,7 @@ public function call_rest_api_route( $old_post_id, $new_post_ID ) { //Fetch comment for each post and save to the DB $route = "posts/{$old_post_id}/replies"; - $comments = REST_API_oAuth::get_instance()->access_endpoint( $route, array(), "comments", false ); + $comments = REST_API_oAuth::get_instance()->access_endpoint( $route, array(), 'comments', false ); if ( ! empty( $comments ) ) { diff --git a/classes/config-helper.php b/classes/config-helper.php index d78da9f..d9e1f24 100644 --- a/classes/config-helper.php +++ b/classes/config-helper.php @@ -31,7 +31,7 @@ protected function _setup_hooks() { add_filter( 'pmc_theme_ut_xmlrpc_client_auth', array( $this, - 'filter_pmc_theme_ut_xmlrpc_client_auth' + 'filter_pmc_theme_ut_xmlrpc_client_auth', ), 10, 2 ); add_filter( 'pmc_theme_ut_domains', array( $this, 'filter_pmc_theme_ut_domains' ) ); @@ -46,12 +46,12 @@ protected function _setup_hooks() { add_filter( 'pmc_theme_ut_custom_post_types_to_import', array( $this, - 'filter_pmc_theme_ut_custom_post_types_to_import' + 'filter_pmc_theme_ut_custom_post_types_to_import', ) ); add_filter( 'pmc_theme_ut_custom_taxonomies_to_import', array( $this, - 'filter_pmc_theme_ut_custom_taxonomies_to_import' + 'filter_pmc_theme_ut_custom_taxonomies_to_import', ) ); } @@ -65,7 +65,6 @@ public function filter_pmc_theme_ut_custom_post_types_to_import( $post_types ) { } } - return $post_types; } @@ -101,8 +100,8 @@ public function filter_pmc_theme_ut_xmlrpc_client_auth( $xmlrpc_args, $domain = $xmlrpc_args = array( 'server' => "http://{$domain}/xmlrpc.php", - 'username' => Config::$xmlrpc_auth[ $domain ]["username"], - 'password' => Config::$xmlrpc_auth[ $domain ]["password"], + 'username' => Config::$xmlrpc_auth[ $domain ]['username'], + 'password' => Config::$xmlrpc_auth[ $domain ]['password'], ); } @@ -162,11 +161,10 @@ public function filter_pmc_theme_ut_endpoints_config( $client_configuration, $ar $client_id = $client_configuration['client_id']; - $saved_access_token = get_option( $client_id . "_" . $args['domain'] ); + $saved_access_token = get_option( $client_id . '_' . $args['domain'] ); $client_configuration['has_access_token'] = empty( $saved_access_token ) ? false : true; - } return $client_configuration; @@ -235,11 +233,11 @@ public function filter_pmc_theme_ut_posts_routes( $posts_routes = array() ) { foreach ( $route_post_types as $route_post_type ) { $post_type = array( 'posts' => array( - "access_token" => false, - "query_params" => array( - "type" => $route_post_type, - ) - ) + 'access_token' => false, + 'query_params' => array( + 'type' => $route_post_type, + ), + ), ); $posts_routes[] = $post_type; diff --git a/classes/config.php b/classes/config.php index b93b96c..e100d15 100644 --- a/classes/config.php +++ b/classes/config.php @@ -15,60 +15,60 @@ class Config { const VALIDATE_URL = 'https://public-api.wordpress.com/oauth2/token-info'; public static $rest_api_auth = array( - "YOURDOMAIN_1.com" => array( - "client_id" => "", - "client_secret" => "", - "redirect_uri" => "" + 'YOURDOMAIN_1.com' => array( + 'client_id' => '', + 'client_secret' => '', + 'redirect_uri' => '', ), - "YOURDOMAIN_2.com" => array( - "client_id" => "", - "client_secret" => "", - "redirect_uri" => '' + 'YOURDOMAIN_2.com' => array( + 'client_id' => '', + 'client_secret' => '', + 'redirect_uri' => '', ), ); public static $xmlrpc_auth = array( - "YOURDOMAIN_1.com" => array( - "username" => "", - "password" => "", + 'YOURDOMAIN_1.com' => array( + 'username' => '', + 'password' => '', ), - "YOURDOMAIN_2.com" => array( - "username" => "", - "password" => "", + 'YOURDOMAIN_2.com' => array( + 'username' => '', + 'password' => '', ), ); public static $all_routes = array( 0 => array( - "users" => array( - "access_token" => true, - "query_params" => array( - "authors_only" => false, - ) - ) + 'users' => array( + 'access_token' => true, + 'query_params' => array( + 'authors_only' => false, + ), + ), ), 1 => array( - "menus" => array( - "access_token" => true, - "query_params" => array() - ) + 'menus' => array( + 'access_token' => true, + 'query_params' => array(), + ), ), 2 => array( - "tags" => array( - "access_token" => false, - "query_params" => array() - ) + 'tags' => array( + 'access_token' => false, + 'query_params' => array(), + ), ), 3 => array( - "categories" => array( - "access_token" => false, - "query_params" => array() - ) + 'categories' => array( + 'access_token' => false, + 'query_params' => array(), + ), ), ); - public static $xmlrpc_routes = array( "taxonomies", "options" ); + public static $xmlrpc_routes = array( 'taxonomies', 'options' ); public static $custom_posttypes = array( 'post', 'page' ); @@ -87,7 +87,7 @@ class Config { 'query_var' => true, 'sort' => true, 'args' => array( 'orderby' => 'term_order' ), - 'rewrite' => array( 'slug' => 'NAMETAXONOMY' ) + 'rewrite' => array( 'slug' => 'NAMETAXONOMY' ), ), 1 => array( 'name' => 'NAMETAXONOMY', // Name of the taxonomy @@ -103,7 +103,7 @@ class Config { 'query_var' => true, 'sort' => true, 'args' => array( 'orderby' => 'term_order' ), - 'rewrite' => array( 'slug' => 'NAMETAXONOMY' ) + 'rewrite' => array( 'slug' => 'NAMETAXONOMY' ), ), ); } diff --git a/classes/menus-importer.php b/classes/menus-importer.php index e10f0ed..781de8c 100644 --- a/classes/menus-importer.php +++ b/classes/menus-importer.php @@ -68,7 +68,6 @@ private function _get_type_object_id( $content_id, $type_family, $type ) { $menu_item_object_id = XMLRPC_Router::get_instance()->get_taxonomy_term_by_id( $type, $content_id, $this->_domain ); - } else if ( 'post_type' === $type_family ) { $menu_item_object_id = $this->call_post_rest_api_route( $type, $content_id ); @@ -77,7 +76,7 @@ private function _get_type_object_id( $content_id, $type_family, $type ) { if ( is_wp_error( $menu_item_object_id ) ) { - error_log( $time . " -- " . $menu_item_object_id->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' -- ' . $menu_item_object_id->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); return 0; } @@ -108,7 +107,7 @@ private function _save_menu_item( $menu_id, $menu_item, $menu_item_id = 0 ) { $type_id = $this->_get_type_object_id( $menu_item['content_id'], $menu_item['type_family'], $menu_item['type'] ); $url = $this->_get_menu_url( $menu_item['url'] ); - error_log( $time . " Menu ITEM -- " . json_encode( array( + error_log( $time . ' Menu ITEM -- ' . json_encode( array( 'menu-item-object-id' => $type_id, 'menu-item-object' => $menu_item['type'], 'menu-item-type' => $menu_item['type_family'], @@ -136,7 +135,7 @@ private function _save_menu_item( $menu_id, $menu_item, $menu_item_id = 0 ) { if ( is_wp_error( $menu_item_db_id ) ) { - error_log( $time . " WP_Error -- " . $menu_item_db_id->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' WP_Error -- ' . $menu_item_db_id->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); } else { @@ -144,10 +143,9 @@ private function _save_menu_item( $menu_id, $menu_item, $menu_item_id = 0 ) { error_log( "{$time} -- Menu Item Added **-- {$menu_item['name']} --** with ID = {$menu_item_db_id}" . PHP_EOL, 3, PMC_THEME_UNIT_TEST_IMPORT_LOG_FILE ); } - } catch ( \Exception $e ) { - error_log( $time . " -- " . $e->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' -- ' . $e->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); } @@ -168,8 +166,7 @@ private function _save_menu_item( $menu_id, $menu_item, $menu_item_id = 0 ) { */ private function _save_menu( $menu_json ) { - - $menu_name = $menu_json["name"]; + $menu_name = $menu_json['name']; $items = array(); $time = date( '[d/M/Y:H:i:s]' ); @@ -189,7 +186,6 @@ private function _save_menu( $menu_json ) { if ( is_wp_error( $menu_id ) ) { error_log( "{$time} -- Menu Failed **--** with message = " . $menu_id->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); } - } else { $menu_id = $menu_exists->term_id; @@ -199,9 +195,9 @@ private function _save_menu( $menu_json ) { $items = wp_get_nav_menu_items( $menu_id ); } - if ( ! empty( $menu_json["items"] ) ) { + if ( ! empty( $menu_json['items'] ) ) { - foreach ( $menu_json["items"] as $menu_item ) { + foreach ( $menu_json['items'] as $menu_item ) { $menu_item_id = 0; if ( ! empty( $items ) ) { foreach ( $items as $item ) { @@ -216,9 +212,9 @@ private function _save_menu( $menu_json ) { } // Grab the theme locations and assign our newly-created menu - if ( ! empty( $menu_json["locations"] ) ) { + if ( ! empty( $menu_json['locations'] ) ) { - $menu_locations[] = $menu_json["locations"]; + $menu_locations[] = $menu_json['locations']; foreach ( $menu_locations as $menu_location ) { @@ -232,7 +228,7 @@ private function _save_menu( $menu_json ) { } } catch ( \Exception $e ) { - error_log( $time . " -- " . $e->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' -- ' . $e->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); } } @@ -261,7 +257,6 @@ public function instant_menus_import( $menus_json ) { $menus_info[] = $menu_id; } - } return $menus_info; @@ -304,12 +299,12 @@ public function call_post_rest_api_route( $type, $post_id ) { try { $params['route'] = array( - "name" => "posts/" . $post_id, - "access_token" => false, - "query_params" => array( - "type" => $type, + 'name' => 'posts/' . $post_id, + 'access_token' => false, + 'query_params' => array( + 'type' => $type, ), - "route_index" => 'posts' + 'route_index' => 'posts', ); $params['domain'] = $this->_domain; @@ -317,18 +312,17 @@ public function call_post_rest_api_route( $type, $post_id ) { if ( is_wp_error( $pages ) ) { - error_log( $time . " -- " . $pages->get_error_messages() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' -- ' . $pages->get_error_messages() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); return $pages; } else if ( empty( $pages ) ) { - return new \WP_Error( 'unauthorized_access', " Failed to attach menu to " . $type . " object with id - " . $post_id ); + return new \WP_Error( 'unauthorized_access', ' Failed to attach menu to ' . $type . ' object with id - ' . $post_id ); } - } catch ( \Exception $e ) { - error_log( $time . " -- " . $e->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' -- ' . $e->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); } return $pages[ $post_id ]; diff --git a/classes/options-importer.php b/classes/options-importer.php index fbff8e2..bf467dd 100644 --- a/classes/options-importer.php +++ b/classes/options-importer.php @@ -68,13 +68,10 @@ public function filter_pmc_theme_ut_whitelisted_options( $whitelisted = array() */ public function call_import_route( $api_data, $domain = '' ) { - $saved_options = $this->instant_options_import( $api_data ); - return $saved_options; - } /** @@ -96,7 +93,7 @@ public function instant_options_import( $options_json ) { $options_data = json_decode( $options_json, true ); - $options_to_import = array_keys( $options_data["options"] ); + $options_to_import = array_keys( $options_data['options'] ); $whitelist_options_to_import = apply_filters( 'options_import_whitelist', array() ); @@ -109,7 +106,7 @@ public function instant_options_import( $options_json ) { // Allow others to prevent their options from importing $blacklist = apply_filters( 'options_import_blacklist', array() ); - foreach ( $options_data["options"] as $option_name => $option_value ) { + foreach ( $options_data['options'] as $option_name => $option_value ) { if ( isset( $option_value ) ) { @@ -117,7 +114,7 @@ public function instant_options_import( $options_json ) { if ( in_array( $option_name, $blacklist ) || ! in_array( $option_name, $options_to_import ) ) { $error = "\n

" . sprintf( __( 'Skipped option `%s` because a plugin or theme does not allow it to be imported.' ), esc_html( $option_name ) ) . '

'; - error_log( $time . " -- " . $error . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' -- ' . $error . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); continue; } @@ -129,7 +126,7 @@ public function instant_options_import( $options_json ) { if ( defined( 'WP_OPTION_IMPORT_BLACKLIST_REGEX' ) && preg_match( WP_OPTION_IMPORT_BLACKLIST_REGEX, $option_name ) ) { $error = "\n

" . sprintf( __( 'Skipped option `%s` because this WordPress installation does not allow it.' ), esc_html( $option_name ) ) . '

'; - error_log( $time . " -- " . $error . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' -- ' . $error . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); continue; } @@ -141,7 +138,7 @@ public function instant_options_import( $options_json ) { if ( $old_value !== $hash ) { $error = "\n

" . sprintf( __( 'Skipped option `%s` because it currently exists.' ), esc_html( $option_name ) ) . '

'; - error_log( $time . " -- " . $error . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' -- ' . $error . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); continue; } } @@ -154,12 +151,10 @@ public function instant_options_import( $options_json ) { update_option( $option_name, $option_value ); } } - } - } catch ( \Exception $ex ) { - error_log( $time . " -- " . $ex->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' -- ' . $ex->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); } } diff --git a/classes/pmc-singleton.php b/classes/pmc-singleton.php index e2ec952..d6ebffa 100644 --- a/classes/pmc-singleton.php +++ b/classes/pmc-singleton.php @@ -67,16 +67,16 @@ final public static function get_instance() { * for each subclass. */ $class = get_called_class(); - if( !isset( static::$_instance[$class] ) ){ - self::$_instance[$class] = new $class(); + if ( ! isset( static::$_instance[ $class ] ) ) { + self::$_instance[ $class ] = new $class(); // Run's the class's _init() method, where the class can hook into actions and filters, and do any other initialization it needs - self::$_instance[$class]->_init(); + self::$_instance[ $class ]->_init(); // Dependent items can use the `pmc_singleton_init_{$called_class}` hook to execute code immediately after _init() is called. do_action( "pmc_singleton_init_$class" ); } - return self::$_instance[$class]; + return self::$_instance[ $class ]; } /** diff --git a/classes/posts-importer.php b/classes/posts-importer.php index a557f20..4b31171 100644 --- a/classes/posts-importer.php +++ b/classes/posts-importer.php @@ -111,17 +111,15 @@ private function _save_post( $post_json, $author_id, $cat_IDs ) { } - if ( is_a( $post_ID, "WP_Error" ) ) { + if ( is_a( $post_ID, 'WP_Error' ) ) { - error_log( $time . " -- " . $post_ID->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' -- ' . $post_ID->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); } else { error_log( "{$time} -- {$post_json['type']} **-- {$post_json['title']} --** added with ID = {$post_ID}" . PHP_EOL, 3, PMC_THEME_UNIT_TEST_IMPORT_LOG_FILE ); } - } - } catch ( \Exception $e ) { error_log( $e->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); @@ -179,29 +177,27 @@ public function instant_posts_import( $posts_json ) { $post_ids[ $post_json['ID'] ] = $post_ID; // save tags associated with the post. - if ( ! empty ( $post_json['tags'] ) ) { + if ( ! empty( $post_json['tags'] ) ) { foreach ( $post_json['tags'] as $key => $terms ) { wp_set_post_terms( $post_ID, $terms['name'], 'post_tag' ); } - } // save Post Meta associated with the post. - if ( ! empty ( $post_json['metadata'] ) ) { + if ( ! empty( $post_json['metadata'] ) ) { foreach ( $post_json['metadata'] as $post_metadata ) { $meta_ids[] = $this->_save_post_meta( $post_ID, $post_metadata ); } - } // Save the featured image of the post - if ( ! empty ( $post_json['featured_image'] ) ) { + if ( ! empty( $post_json['featured_image'] ) ) { Attachments_Importer::get_instance()->save_featured_image( $post_json['featured_image'], $post_ID ); @@ -218,12 +214,10 @@ public function instant_posts_import( $posts_json ) { $comments_ids[] = Comments_Importer::get_instance()->call_rest_api_route( $post_json['ID'], $post_ID ); } - } - } catch ( \Exception $ex ) { - error_log( $time . " -- " . esc_html( $ex->get_error_message() ) . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' -- ' . esc_html( $ex->get_error_message() ) . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); continue; @@ -261,7 +255,6 @@ public function call_import_route( $api_data, $domain = '' ) { return $inserted_posts; - } /** @@ -280,7 +273,7 @@ public function save_post_type( $post_type ) { $args = array( 'public' => true, - 'label' => $post_type + 'label' => $post_type, ); register_post_type( $post_type, $args ); diff --git a/classes/rest-api-oauth.php b/classes/rest-api-oauth.php index 9f3681d..a93de38 100644 --- a/classes/rest-api-oauth.php +++ b/classes/rest-api-oauth.php @@ -62,7 +62,7 @@ public function initialize_params( $args ) { if ( $args['route']['access_token'] === 'true' && empty( $this->_access_token ) ) { - $this->_access_token_key = $this->_client_id . "_" . $args['domain']; + $this->_access_token_key = $this->_client_id . '_' . $args['domain']; $this->_access_token = $this->_get_saved_token(); @@ -71,7 +71,6 @@ public function initialize_params( $args ) { $this->_fetch_access_token(); } - } } @@ -87,7 +86,7 @@ public function initialize_params( $args ) { */ private function _get_authorization_code() { - if ( ! empty ( $this->_access_token ) && $this->is_token_valid() ) { + if ( ! empty( $this->_access_token ) && $this->is_token_valid() ) { return; @@ -109,7 +108,6 @@ private function _get_authorization_code() { 'body' => $params, ); - $response = wp_remote_get( Config::AUTHORIZE_URL, $args ); if ( is_wp_error( $response ) ) { @@ -126,7 +124,7 @@ private function _get_authorization_code() { } catch ( \Exception $ex ) { - error_log( $time . " _get_authorization_code() Failed -- " . $ex->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' _get_authorization_code() Failed -- ' . $ex->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); } @@ -148,12 +146,11 @@ private function _get_saved_token() { */ private function _fetch_access_token() { - $time = date( '[d/M/Y:H:i:s]' ); - if ( ! empty ( $this->_access_token ) ) { + if ( ! empty( $this->_access_token ) ) { - error_log( $time . "##### valid token ###### " . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . '##### valid token ###### ' . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); return; @@ -175,12 +172,11 @@ private function _fetch_access_token() { 'body' => $params, ); - $response = wp_remote_post( Config::REQUEST_TOKEN_URL, $args ); if ( is_wp_error( $response ) ) { - error_log( $time . " fetch_access_token() Failed -- " . $response->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' fetch_access_token() Failed -- ' . $response->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); return $response; } @@ -191,9 +187,9 @@ private function _fetch_access_token() { if ( empty( $auth->access_token ) ) { - error_log( $time . " fetch_access_token() Failed -- " . $response_body . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' fetch_access_token() Failed -- ' . $response_body . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); - return new \WP_Error('unauthorized_access'," fetch_access_token() Failed -- " . $response_body); + return new \WP_Error( 'unauthorized_access',' fetch_access_token() Failed -- ' . $response_body ); } $this->_access_token = $auth->access_token; @@ -202,7 +198,7 @@ private function _fetch_access_token() { } catch ( \Exception $ex ) { - error_log( $time . " fetch_access_token() Failed -- " . $ex->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' fetch_access_token() Failed -- ' . $ex->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); } } @@ -217,8 +213,7 @@ private function _fetch_access_token() { */ public function is_token_valid() { - - if ( empty ( $this->_access_token ) ) { + if ( empty( $this->_access_token ) ) { $this->_access_token = get_option( $this->_access_token_key ); } @@ -235,7 +230,6 @@ public function is_token_valid() { 'token' => $this->_access_token, ); - $args = array( 'method' => 'POST', 'timeout' => 500, @@ -246,7 +240,7 @@ public function is_token_valid() { if ( is_wp_error( $valid_token ) ) { - error_log( $time . " is_token_valid() Failed -- " . $valid_token->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' is_token_valid() Failed -- ' . $valid_token->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); return $valid_token; @@ -256,17 +250,15 @@ public function is_token_valid() { $validate_response = json_decode( $response_body, true ); - return ( ! empty ( $validate_response["scope"] ) ); + return ( ! empty( $validate_response['scope'] ) ); } - } catch ( \Exception $ex ) { - error_log( $time . " is_token_valid() Failed -- " . $ex->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' is_token_valid() Failed -- ' . $ex->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); } - } /** @@ -284,7 +276,6 @@ public function is_token_valid() { */ public function access_endpoint( $domain, $route, $query_params = array(), $route_name = '', $token_required = false ) { - $time = date( '[d/M/Y:H:i:s]' ); if ( empty( $route_name ) ) { @@ -295,9 +286,9 @@ public function access_endpoint( $domain, $route, $query_params = array(), $rout if ( empty( $domain ) && empty( $this->domain ) ) { - error_log( $time . " $$$$ No Domain set for route . -- " . $route_name . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' $$$$ No Domain set for route . -- ' . $route_name . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); - return new \WP_Error( 'unauthorized_access', " No Domain Set. Please set a domain. " ); + return new \WP_Error( 'unauthorized_access', ' No Domain Set. Please set a domain. ' ); } else if ( empty( $domain ) && ! empty( $this->domain ) ) { @@ -305,7 +296,6 @@ public function access_endpoint( $domain, $route, $query_params = array(), $rout } - try { if ( ! empty( $domain ) ) { @@ -326,9 +316,9 @@ public function access_endpoint( $domain, $route, $query_params = array(), $rout if ( empty( $response ) ) { - error_log( $time . $api_url . " $$$$ No Data returned. Please Try again. -- " . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . $api_url . ' $$$$ No Data returned. Please Try again. -- ' . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); - return new \WP_Error( 'unauthorized_access', $api_url . " No Data returned. Please Try again. " ); + return new \WP_Error( 'unauthorized_access', $api_url . ' No Data returned. Please Try again. ' ); } @@ -336,17 +326,16 @@ public function access_endpoint( $domain, $route, $query_params = array(), $rout if ( $data['code'] != 200 ) { - return new \WP_Error( 'unauthorized_access', $route_name . " Failed with Exception - " . $data['body']['message'] ); + return new \WP_Error( 'unauthorized_access', $route_name . ' Failed with Exception - ' . $data['body']['message'] ); } - error_log( $time . $api_url . " $$$$ Data fetched -- " . PHP_EOL, 3, PMC_THEME_UNIT_TEST_IMPORT_LOG_FILE ); + error_log( $time . $api_url . ' $$$$ Data fetched -- ' . PHP_EOL, 3, PMC_THEME_UNIT_TEST_IMPORT_LOG_FILE ); return $data['body'][ $route_name ]; } - } catch ( \Exception $ex ) { - error_log( $time . $api_url . " Failed -- " . $ex->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . $api_url . ' Failed -- ' . $ex->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); } @@ -391,7 +380,6 @@ private function _get_required_header( $token_required ) { ), ); } - } else { $options = array( diff --git a/classes/rest-api-router.php b/classes/rest-api-router.php index f92f74e..6bc1154 100644 --- a/classes/rest-api-router.php +++ b/classes/rest-api-router.php @@ -113,7 +113,7 @@ public function call_rest_api_route( $params ) { $route = strtolower( $params['route']['name'] ); - $access_token = ( $params['route']['access_token'] === "true" ); + $access_token = ( $params['route']['access_token'] === 'true' ); $query_params = array(); diff --git a/classes/tags-importer.php b/classes/tags-importer.php index 461ec24..ee4f6b4 100644 --- a/classes/tags-importer.php +++ b/classes/tags-importer.php @@ -49,9 +49,9 @@ public function save_tag( $tag_json ) { $term_id = $tag_info['term_id']; - if ( is_a( $tag_info, "WP_Error" ) ) { + if ( is_a( $tag_info, 'WP_Error' ) ) { - error_log( $time . " -- " . $tag_info->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' -- ' . $tag_info->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); return $tag_info; } else { @@ -59,14 +59,11 @@ public function save_tag( $tag_json ) { error_log( "{$time} -- Tag **-- {$tag_json['name']} --** added with ID = {$term_id}" . PHP_EOL, 3, PMC_THEME_UNIT_TEST_IMPORT_LOG_FILE ); } - } else { error_log( "{$time} -- Exists Tag **-- {$tag_json['name']} --** with ID = {$term_id['term_id']}" . PHP_EOL, 3, PMC_THEME_UNIT_TEST_DUPLICATE_LOG_FILE ); } - - } catch ( \Exception $e ) { error_log( $e->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); diff --git a/classes/taxonomies-importer.php b/classes/taxonomies-importer.php index 7235b0f..90604e4 100644 --- a/classes/taxonomies-importer.php +++ b/classes/taxonomies-importer.php @@ -62,7 +62,7 @@ public function save_taxonomy( $taxonomy_json ) { } else { register_taxonomy_for_object_type( $taxonomy_json['name'], - $taxonomy_json['object_type'] ); + $taxonomy_json['object_type'] ); } @@ -70,9 +70,9 @@ public function save_taxonomy( $taxonomy_json ) { if ( is_wp_error( $taxonomy_id ) ) { - error_log( $time . " -- " . $taxonomy_id->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' -- ' . $taxonomy_id->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); - } else if( false !== $taxonomy_id ) { + } else if ( false !== $taxonomy_id ) { error_log( "{$time} -- Taxonomy **-- {$taxonomy_json['name']} --** added." . PHP_EOL, 3, PMC_THEME_UNIT_TEST_IMPORT_LOG_FILE ); @@ -82,7 +82,6 @@ public function save_taxonomy( $taxonomy_json ) { error_log( "{$time} -- Exists Taxonomy **-- {$taxonomy_json['name']} --**" . PHP_EOL, 3, PMC_THEME_UNIT_TEST_DUPLICATE_LOG_FILE ); } - } catch ( \Exception $e ) { error_log( $e->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); diff --git a/classes/terms-importer.php b/classes/terms-importer.php index c9ec927..6316b0a 100644 --- a/classes/terms-importer.php +++ b/classes/terms-importer.php @@ -40,7 +40,7 @@ public function save_taxonomy_terms( $term_json ) { if ( false === $taxonomy_id ) { - error_log( $time . "Taxonomy -- " . $term_json['taxonomy'] ." -- does not exists". PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . 'Taxonomy -- ' . $term_json['taxonomy'] .' -- does not exists'. PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); return false; } @@ -59,9 +59,9 @@ public function save_taxonomy_terms( $term_json ) { ) ); - if ( is_a( $term_id, "WP_Error" ) ) { + if ( is_a( $term_id, 'WP_Error' ) ) { - error_log( $time . " -- " . $term_id->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' -- ' . $term_id->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); return $term_id; @@ -69,20 +69,18 @@ public function save_taxonomy_terms( $term_json ) { error_log( "{$time} -- Term **-- {$term_json['name']} --** for Taxonomy **-- {$term_json['taxonomy']} **-- added with ID = {$term_id["term_id"]}" . PHP_EOL, 3, PMC_THEME_UNIT_TEST_IMPORT_LOG_FILE ); } - } else { error_log( "{$time} -- Exists Term **-- {$term_json['name']} --** for Taxonomy **-- {$term_json['taxonomy']} **-- with ID = {$term_id["term_id"]}" . PHP_EOL, 3, PMC_THEME_UNIT_TEST_DUPLICATE_LOG_FILE ); } - } catch ( \Exception $e ) { error_log( $e->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); } - return $term_id["term_id"]; + return $term_id['term_id']; } diff --git a/classes/users-importer.php b/classes/users-importer.php index fd452bf..51b1003 100644 --- a/classes/users-importer.php +++ b/classes/users-importer.php @@ -38,7 +38,7 @@ public function save_user( $user_info ) { $user_ID = username_exists( $user_info['login'] ); - error_log( $time . " -- User ID =" . $user_ID . " logging" . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' -- User ID =' . $user_ID . ' logging' . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); if ( empty( $user_ID ) ) { @@ -66,23 +66,20 @@ public function save_user( $user_info ) { $user_ID = wp_insert_user( $user_data ); - if ( is_a( $user_ID, "WP_Error" ) ) { + if ( is_a( $user_ID, 'WP_Error' ) ) { - error_log( $time . " -- " . $user_ID->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' -- ' . $user_ID->get_error_message() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); } else { error_log( "{$time} -- User **-- {$user_info['name']} --** added with ID = {$user_ID}" . PHP_EOL, 3, PMC_THEME_UNIT_TEST_IMPORT_LOG_FILE ); } - } else { error_log( "{$time} -- Exists User **-- {$user_info['name']} --** with ID = {$user_ID}" . PHP_EOL, 3, PMC_THEME_UNIT_TEST_DUPLICATE_LOG_FILE ); } - - } catch ( \Exception $e ) { error_log( $time . $e->getMessage() . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); diff --git a/classes/xmlrpc-client.php b/classes/xmlrpc-client.php index 3b2449b..23c5609 100644 --- a/classes/xmlrpc-client.php +++ b/classes/xmlrpc-client.php @@ -29,7 +29,7 @@ function __construct( $server = '', $username = '', $password = '', $blog_id = 0 if ( empty( $xmlrpc_args['server'] ) || empty( $xmlrpc_args['username'] ) || empty( $xmlrpc_args['password'] ) ) { $time = date( '[d/M/Y:H:i:s]' ); - error_log( $time . " -- " . get_called_class() . ': Missing credentials.' . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + error_log( $time . ' -- ' . get_called_class() . ': Missing credentials.' . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); return new \WP_Error( 'unknown_exception', get_called_class() . ': Missing credentials.' ); } @@ -72,7 +72,7 @@ public function query() { $method = array_shift( $args ); $args = (array) array_shift( $args ); - $default_args = array( $this->blog_id, $this->username, $this->password, ); + $default_args = array( $this->blog_id, $this->username, $this->password ); $args = array_merge( $default_args, (array) $args ); return parent::query( $method, $args ); @@ -154,7 +154,7 @@ public function get_terms( $taxonomies, $filter = array() ) { $args = array( $taxonomies, - $filter + $filter, ); $cache_key = md5( $this->cache_key . serialize( $args ) ); $terms = get_transient( $cache_key ); @@ -182,7 +182,7 @@ public function get_term( $term, $taxonomy ) { $args = array( $taxonomy, - $term + $term, ); $cache_key = md5( $this->cache_key . serialize( $args ) ); diff --git a/classes/xmlrpc-router.php b/classes/xmlrpc-router.php index 52504c1..2c7a589 100644 --- a/classes/xmlrpc-router.php +++ b/classes/xmlrpc-router.php @@ -129,7 +129,7 @@ private function _call_taxonomies_route() { $error = $this->xmlrpc_client->error->message; - return new \WP_Error( "unknown_error", " - Taxonomy import failed with Exception " . $error ); + return new \WP_Error( 'unknown_error', ' - Taxonomy import failed with Exception ' . $error ); } else { @@ -179,7 +179,7 @@ private function _call_options_route() { $error = $this->xmlrpc_client->error->message; - return new \WP_Error( 'unauthorized_access', $error . " Failed with Exception - " ); + return new \WP_Error( 'unauthorized_access', $error . ' Failed with Exception - ' ); } else { @@ -208,8 +208,8 @@ public function get_taxonomy_term_by_id( $taxonomy, $term_id, $domain ) { if ( empty( $this->xmlrpc_client ) ) { - error_log( "NO XMLRPC Client - " . $taxonomy . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); - return new \WP_Error( "unknown_error", "NO XMLRPC Client - " . $taxonomy ); + error_log( 'NO XMLRPC Client - ' . $taxonomy . PHP_EOL, 3, PMC_THEME_UNIT_TEST_ERROR_LOG_FILE ); + return new \WP_Error( 'unknown_error', 'NO XMLRPC Client - ' . $taxonomy ); } @@ -227,13 +227,12 @@ public function get_taxonomy_term_by_id( $taxonomy, $term_id, $domain ) { $error = $this->xmlrpc_client->error->message; - return new \WP_Error( "unknown_error", "Taxonomy Term Failed with Exception - " . $error ); + return new \WP_Error( 'unknown_error', 'Taxonomy Term Failed with Exception - ' . $error ); } else { // Save Taxonomy Term if not exists in the current site. return Terms_Importer::get_instance()->save_taxonomy_terms( $result ); } - } } diff --git a/pmc-theme-unit-test.php b/pmc-theme-unit-test.php index 24d177e..56e1b7c 100644 --- a/pmc-theme-unit-test.php +++ b/pmc-theme-unit-test.php @@ -8,11 +8,11 @@ */ /* Local plugin meta data constants */ -define ( 'PMC_THEME_UNIT_TEST_ROOT', __DIR__ ); -define ( 'PMC_THEME_UNIT_TEST_VERSION', '1.0' ); -define ( 'PMC_THEME_UNIT_TEST_IMPORT_LOG_FILE', PMC_THEME_UNIT_TEST_ROOT . '/import.log' ); -define ( 'PMC_THEME_UNIT_TEST_ERROR_LOG_FILE', PMC_THEME_UNIT_TEST_ROOT . '/error.log' ); -define ( 'PMC_THEME_UNIT_TEST_DUPLICATE_LOG_FILE', PMC_THEME_UNIT_TEST_ROOT . '/duplicate.log' ); +define( 'PMC_THEME_UNIT_TEST_ROOT', __DIR__ ); +define( 'PMC_THEME_UNIT_TEST_VERSION', '1.0' ); +define( 'PMC_THEME_UNIT_TEST_IMPORT_LOG_FILE', PMC_THEME_UNIT_TEST_ROOT . '/import.log' ); +define( 'PMC_THEME_UNIT_TEST_ERROR_LOG_FILE', PMC_THEME_UNIT_TEST_ROOT . '/error.log' ); +define( 'PMC_THEME_UNIT_TEST_DUPLICATE_LOG_FILE', PMC_THEME_UNIT_TEST_ROOT . '/duplicate.log' ); diff --git a/templates/admin-ui.php b/templates/admin-ui.php index 077ae47..6f5b263 100644 --- a/templates/admin-ui.php +++ b/templates/admin-ui.php @@ -68,4 +68,4 @@ - \ No newline at end of file +