Skip to content

Commit

Permalink
Running phpcbf to automatically fix phpcs errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mintindeed committed Jul 30, 2015
1 parent c73d4b6 commit 4f600b5
Show file tree
Hide file tree
Showing 21 changed files with 165 additions and 219 deletions.
44 changes: 19 additions & 25 deletions classes/admin.php
Expand Up @@ -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' ) );

}

Expand Down Expand Up @@ -99,7 +99,6 @@ public function register_post_types_for_import() {
}
}


}

/**
Expand All @@ -126,7 +125,6 @@ public function register_taxonomies_for_import() {
Taxonomies_Importer::get_instance()->save_taxonomy( $taxonomy );

}

}

}
Expand Down Expand Up @@ -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',
) );

}
Expand All @@ -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 ) );

}

Expand All @@ -218,17 +216,17 @@ 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;

}

$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 );

Expand All @@ -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,
);
Expand Down Expand Up @@ -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 );
Expand All @@ -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' );
Expand Down
12 changes: 4 additions & 8 deletions classes/attachments-importer.php
Expand Up @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -160,7 +157,6 @@ public function instant_attachments_import( $attachments_json, $post_ID ) {
$attachments_info[] = $attachments_id;

}

}

return $attachments_info;
Expand Down
16 changes: 8 additions & 8 deletions classes/autoloader.php
Expand Up @@ -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 );

Expand Down
5 changes: 2 additions & 3 deletions classes/categories-importer.php
Expand Up @@ -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 {

Expand All @@ -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 );
Expand Down
7 changes: 3 additions & 4 deletions classes/comments-importer.php
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 ) ) {

Expand Down
24 changes: 11 additions & 13 deletions classes/config-helper.php
Expand Up @@ -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' ) );
Expand All @@ -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',
) );

}
Expand All @@ -65,7 +65,6 @@ public function filter_pmc_theme_ut_custom_post_types_to_import( $post_types ) {
}
}


return $post_types;
}

Expand Down Expand Up @@ -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'],
);

}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4f600b5

Please sign in to comment.