Commit a3688eb7 authored by Erick Hitter's avatar Erick Hitter

Remove unnecessary whitespace

parent 2651fdb2
......@@ -25,7 +25,7 @@ class Syndication_WP_REST_Client implements Syndication_Client {
public static function get_client_data() {
return array( 'id' => 'WP_REST', 'modes' => array( 'push' ), 'name' => 'WordPress.com REST' );
}
public function new_post( $post_ID ) {
$post = (array)get_post( $post_ID );
......@@ -34,7 +34,7 @@ class Syndication_WP_REST_Client implements Syndication_Client {
$post = apply_filters( 'syn_rest_push_filter_new_post', $post, $post_ID );
if ( false === $post )
return true;
$response = wp_remote_post( 'https://public-api.wordpress.com/rest/v1/sites/' . $this->blog_ID . '/posts/new/', array(
'timeout' => $this->timeout,
'user-agent' => $this->useragent,
......@@ -77,7 +77,7 @@ class Syndication_WP_REST_Client implements Syndication_Client {
$post = apply_filters( 'syn_rest_push_filter_edit_post', $post, $post_ID );
if ( false === $post )
return true;
$response = wp_remote_post( 'https://public-api.wordpress.com/rest/v1/sites/' . $this->blog_ID . '/posts/' . $ext_ID . '/', array(
'timeout' => $this->timeout,
'user-agent' => $this->useragent,
......
......@@ -153,7 +153,7 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client
<?php
do_action( 'syn_after_site_form', $site );
do_action( 'syn_after_site_form', $site );
}
public static function save_settings( $site_ID ) {
......@@ -209,7 +209,7 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client
return $posts;
}
public function set_taxonomy( $item ) {
$cats = $item->get_categories();
$ids = array(
......@@ -226,7 +226,7 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client
} elseif ( $result = get_term_by( 'name', $cat->term, 'post_tag' ) ) {
if ( isset( $result->term_id ) ) {
$ids['tags'][] = $result->term_id;
}
}
} else {
// creates if not
$result = wp_insert_term( $cat->term, 'category' );
......@@ -239,7 +239,7 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client
// returns array ready for post creation
return $ids;
}
public static function save_meta( $result, $post, $site, $transport_type, $client ) {
if ( ! $result || is_wp_error( $result ) || ! isset( $post['postmeta'] ) ) {
return false;
......@@ -247,7 +247,7 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client
$categories = $post['post_category'];
wp_set_post_terms($result, $categories, 'category', true);
$metas = $post['postmeta'];
//handle enclosures separately first
$enc_field = isset( $metas['enc_field'] ) ? $metas['enc_field'] : null;
$enclosures = isset( $metas['enclosures'] ) ? $metas['enclosures'] : null;
......@@ -260,16 +260,16 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client
}
add_post_meta($result, $enc_field, $enclosure, false);
}
// now remove them from the rest of the metadata before saving the rest
unset($metas['enclosures']);
}
foreach ($metas as $meta_key => $meta_value) {
add_post_meta($result, $meta_key, $meta_value, true);
}
}
public static function update_meta( $result, $post, $site, $transport_type, $client ) {
if ( ! $result || is_wp_error( $result ) || ! isset( $post['postmeta'] ) ) {
return false;
......@@ -277,7 +277,7 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client
$categories = $post['post_category'];
wp_set_post_terms($result, $categories, 'category', true);
$metas = $post['postmeta'];
// handle enclosures separately first
$enc_field = isset( $metas['enc_field'] ) ? $metas['enc_field'] : null;
$enclosures = isset( $metas['enclosures'] ) ? $metas['enclosures'] : null;
......@@ -290,17 +290,17 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client
}
add_post_meta($result, $enc_field, $enclosure, false);
}
// now remove them from the rest of the metadata before saving the rest
unset($metas['enclosures']);
}
foreach ($metas as $meta_key => $meta_value) {
update_post_meta($result, $meta_key, $meta_value);
}
}
public static function save_tax( $result, $post, $site, $transport_type, $client ) {
public static function save_tax( $result, $post, $site, $transport_type, $client ) {
if ( ! $result || is_wp_error( $result ) || ! isset( $post['tax'] ) ) {
return false;
}
......@@ -313,7 +313,7 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client
wp_set_object_terms($result, (string)$tax_value, $tax_name, true);
}
}
public static function update_tax( $result, $post, $site, $transport_type, $client ) {
if ( ! $result || is_wp_error( $result ) || ! isset( $post['tax'] ) ) {
return false;
......@@ -328,7 +328,7 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client
if ( !in_array($tax_name, $replace_tax_list ) ) {
//if we haven't processed this taxonomy before, replace any terms on the post with the first new one
wp_set_object_terms($result, (string)$tax_value, $tax_name );
$replace_tax_list[] = $tax_name;
$replace_tax_list[] = $tax_name;
} else {
//if we've already added one term for this taxonomy, append any others
wp_set_object_terms($result, (string)$tax_value, $tax_name, true);
......
......@@ -41,7 +41,7 @@ class Syndication_WP_XMLRPC_Client extends WP_HTTP_IXR_Client implements Syndica
function post_push_send_thumbnail( $remote_post_id, $post_id ) {
$thumbnail_meta_keys = $this->get_thumbnail_meta_keys( $post_id );
$thumbnail_meta_keys = $this->get_thumbnail_meta_keys( $post_id );
foreach ( $thumbnail_meta_keys as $thumbnail_meta ) {
$thumbnail_id = get_post_meta( $post_id, $thumbnail_meta, true );
......@@ -65,7 +65,7 @@ class Syndication_WP_XMLRPC_Client extends WP_HTTP_IXR_Client implements Syndica
$thumbnail_meta
);
unset( $syndicated_thumbnails_by_site[ $this->site_ID ] );
unset( $syndicated_thumbnails_by_site[ $this->site_ID ] );
update_post_meta( $post_id, $syn_local_meta_key, $syndicated_thumbnails_by_site );
}
......@@ -81,7 +81,7 @@ class Syndication_WP_XMLRPC_Client extends WP_HTTP_IXR_Client implements Syndica
//has to be this way since mw_newMediaObject doesn't allow to pass description and caption along
$thumbnail_post_data = get_post( $thumbnail_id );
$thumbnail_alt_text = get_post_meta( $thumbnail_id, '_wp_attachment_image_alt', true );
$result = $this->query(
'syndication.addThumbnail',
'1',
......@@ -104,7 +104,7 @@ class Syndication_WP_XMLRPC_Client extends WP_HTTP_IXR_Client implements Syndica
public static function get_client_data() {
return array( 'id' => 'WP_XMLRPC', 'modes' => array( 'push' ), 'name' => 'WordPress XMLRPC' );
}
public function new_post( $post_ID ) {
$post = (array)get_post( $post_ID );
......@@ -114,7 +114,7 @@ class Syndication_WP_XMLRPC_Client extends WP_HTTP_IXR_Client implements Syndica
if ( false === $post ) {
return true;
}
//Uploads all gallery images to the remote site and replaces [gallery] tags with new IDs
$post['post_content'] = $this->syndicate_gallery_images( $post['post_content'] );
......@@ -175,7 +175,7 @@ class Syndication_WP_XMLRPC_Client extends WP_HTTP_IXR_Client implements Syndica
// Delete existing metadata to avoid duplicates
$args['custom_fields'] = array();
foreach ( $remote_post['custom_fields'] as $custom_field ) {
$args['custom_fields'][] = array(
$args['custom_fields'][] = array(
'id' => $custom_field['id'],
'meta_key_lookup' => $custom_field['key'],
);
......@@ -260,9 +260,9 @@ class Syndication_WP_XMLRPC_Client extends WP_HTTP_IXR_Client implements Syndica
$image_ids = array();
$new_image_ids = array();
if ( preg_match_all( '/' . $pattern . '/s', $post_content, $matches ) ) {
$count=count( $matches[3] );
$count=count( $matches[3] );
for ( $i = 0; $i < $count; $i++ ) {
$atts = shortcode_parse_atts( $matches[3][$i] );
if ( isset( $atts['ids'] ) ) {
......@@ -492,7 +492,7 @@ class Syndication_WP_XMLRPC_Client extends WP_HTTP_IXR_Client implements Syndica
<?php
do_action( 'syn_after_site_form', $site );
do_action( 'syn_after_site_form', $site );
}
public static function save_settings( $site_ID ) {
......@@ -591,7 +591,7 @@ class Syndication_WP_XMLRPC_Client_Extensions {
if ( ! $thumbnail_set )
return new IXR_Error( 403, __( 'Could not attach post thumbnail.' ) );
$args = array(
$blog_id,
$username,
......@@ -692,7 +692,7 @@ class Syndication_WP_XMLRPC_Client_Extensions {
if ( empty( $thumbnail_id ) ) {
return new IXR_Error( 500, __( 'Sorry, looks like the image upload failed.', 'syndication' ) );
}
$args = array(
$blog_id,
$username,
......
......@@ -132,7 +132,7 @@ class Syndication_CLI_Command extends WP_CLI_Command {
return;
$this->enabled_verbosity = true;
add_filter( 'syn_pre_push_post_sites', function( $sites, $post_id, $slave_states ) {
WP_CLI::line( sprintf( "Processing post_id #%d (%s)", $post_id, get_the_title( $post_id ) ) );
WP_CLI::line( sprintf( "-- pushing to %s sites and deleting from %s sites", number_format( count( $sites['selected_sites'] ) ), number_format( count( $sites['removed_sites'] ) ) ) );
......
......@@ -21,7 +21,7 @@ class WP_Push_Syndication_Server {
// custom columns
add_filter( 'manage_edit-syn_site_columns', array( $this, 'add_new_columns' ) );
add_action( 'manage_syn_site_posts_custom_column', array( $this, 'manage_columns' ), 10, 2);
// submenus
add_action( 'admin_menu', array( $this, 'register_syndicate_settings' ) );
......@@ -64,14 +64,14 @@ class WP_Push_Syndication_Server {
'publish_posts' => $capability,
'read_private_posts' => $capability
);
$taxonomy_capabilities = array(
'manage_terms' => 'manage_categories',
'edit_terms' => 'manage_categories',
'delete_terms' => 'manage_categories',
'assign_terms' => 'edit_posts',
);
register_post_type( 'syn_site', array(
'labels' => array(
'name' => __( 'Sites' ),
......@@ -179,11 +179,11 @@ class WP_Push_Syndication_Server {
break;
}
}
public function admin_init() {
// @TODO define more parameters
$name_match = '#class-syndication-(.+)-client\.php$#';
$full_path = __DIR__ . '/';
if ( $handle = opendir( $full_path ) ) {
while ( false !== ( $entry = readdir( $handle ) ) ) {
......@@ -196,7 +196,7 @@ class WP_Push_Syndication_Server {
continue;
$client_data = call_user_func( array( $class_name, 'get_client_data' ) );
if ( is_array( $client_data ) && !empty( $client_data ) ) {
$this->push_syndicate_transports[$client_data['id']] = array( 'name' => $client_data['name'], 'modes' => $client_data['modes'] );
$this->push_syndicate_transports[$client_data['id']] = array( 'name' => $client_data['name'], 'modes' => $client_data['modes'] );
}
}
}
......@@ -652,7 +652,7 @@ class WP_Push_Syndication_Server {
// @TODO validate that type and mode are valid
update_post_meta( $post->ID, 'syn_transport_type', $transport_type );
$site_enabled = sanitize_text_field( $_POST['site_enabled'] );
try {
......@@ -854,19 +854,19 @@ class WP_Push_Syndication_Server {
$push_new_shortcircuit = apply_filters( 'syn_pre_push_new_post_shortcircuit', false, $post_ID, $site, $transport_type, $client, $info );
if ( true === $push_new_shortcircuit )
continue;
$result = $client->new_post( $post_ID );
$this->validate_result_new_post( $result, $slave_post_states, $site->ID, $client );
$this->update_slave_post_states( $post_ID, $slave_post_states );
do_action( 'syn_post_push_new_post', $result, $post_ID, $site, $transport_type, $client, $info );
} else { // states 'success', 'edit-error' and 'remove-error'
$push_edit_shortcircuit = apply_filters( 'syn_pre_push_edit_post_shortcircuit', false, $post_ID, $site, $transport_type, $client, $info );
if ( true === $push_edit_shortcircuit )
continue;
$result = $client->edit_post( $post_ID, $info['ext_ID'] );
$this->validate_result_edit_post( $result, $info['ext_ID'], $slave_post_states, $site->ID, $client );
......@@ -1110,11 +1110,11 @@ class WP_Push_Syndication_Server {
$push_delete_shortcircuit = apply_filters( 'syn_pre_push_delete_post_shortcircuit', false, $ext_ID, $post_ID, $site_ID, $transport_type, $client );
if ( true === $push_delete_shortcircuit )
continue;
$result = $client->delete_post( $ext_ID );
do_action( 'syn_post_push_delete_post', $result, $ext_ID, $post_ID, $site_ID, $transport_type, $client );
if( !$result ) {
$delete_error_sites[ $site_ID ] = array( $ext_ID );
}
......@@ -1184,7 +1184,7 @@ class WP_Push_Syndication_Server {
$sites = array_merge( $sites, $this->get_sites_by_sitegroup( $selected_sitegroup ) );
}
$this->schedule_pull_content( $sites );
}
......@@ -1238,7 +1238,7 @@ class WP_Push_Syndication_Server {
public function pull_content( $sites ) {
add_filter( 'http_headers_useragent', array( $this, 'syndication_user_agent' ) );
if ( empty( $sites ) )
$sites = $this->pull_get_selected_sites();
......@@ -1271,7 +1271,7 @@ class WP_Push_Syndication_Server {
$pull_edit_shortcircuit = apply_filters( 'syn_pre_pull_edit_post_shortcircuit', false, $post, $site, $transport_type, $client );
if ( true === $pull_edit_shortcircuit )
continue;
// if updation is disabled continue
if( $this->push_syndicate_settings['update_pulled_posts'] != 'on' )
continue;
......@@ -1283,7 +1283,7 @@ class WP_Push_Syndication_Server {
$result = wp_update_post( $post, true );
do_action( 'syn_post_pull_edit_post', $result, $post, $site, $transport_type, $client );
} else {
$pull_new_shortcircuit = apply_filters( 'syn_pre_pull_new_post_shortcircuit', false, $post, $site, $transport_type, $client );
if ( true === $pull_new_shortcircuit )
......@@ -1357,6 +1357,6 @@ class WP_Push_Syndication_Server {
update_option( 'syn_version', SYNDICATION_VERSION );
}
}
......@@ -7,7 +7,7 @@ interface Syndication_Client {
* @return array array( 'id' => (string) $transport_name, 'modes' => array( 'push', 'pull' ), 'name' => (string) $name );
*/
public static function get_client_data();
/**
* Creates a new post in the slave site.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment