-
Mohammad Jangda authoredMohammad Jangda authored
Code owners
class-syndication-wp-xml-client.php 31.25 KiB
<?php
include_once( dirname(__FILE__) . '/interface-syndication-client.php' );
class Syndication_WP_XML_Client implements Syndication_Client {
private $site_ID;
private $default_post_type;
private $default_post_status;
private $default_comment_status;
private $default_ping_status;
private $nodes_to_post;
private $id_field;
private $enc_field;
private $enc_is_photo;
private $response;
private $error_message;
private $error_code;
private $feed_url;
function __construct( $site_ID ) {
$this->site_ID = $site_ID;
$this->set_feed_url( get_post_meta( $site_ID, 'syn_feed_url', true ) );
$this->default_post_type= get_post_meta( $site_ID, 'syn_default_post_type', true );
$this->default_post_status = get_post_meta( $site_ID, 'syn_default_post_status', true );
$this->default_comment_status = get_post_meta( $site_ID, 'syn_default_comment_status', true );
$this->default_ping_status = get_post_meta( $site_ID, 'syn_default_ping_status', true );
$this->nodes_to_post = get_post_meta( $site_ID, 'syn_node_config', false);
$this->id_field = get_post_meta( $site_ID, 'syn_id_field', true);
$this->enc_field = get_post_meta( $site_ID, 'syn_enc_field', true );
$this->enc_is_photo = get_post_meta( $site_ID, 'syn_enc_is_photo', true);
add_action( 'syn_post_pull_new_post', array( __CLASS__, 'save_meta' ), 10, 5 );
add_action( 'syn_post_pull_new_post', array( __CLASS__, 'save_tax' ), 10, 5 );
add_action( 'syn_post_pull_edit_post', array( __CLASS__, 'update_meta' ), 10, 5 );
add_action( 'syn_post_pull_edit_post', array( __CLASS__, 'update_tax' ), 10, 5 );
add_action ( 'syn_post_pull_new_post', array(__CLASS__ , 'publish_pulled_post' ), 10, 5 );
// Debugging
add_action ( 'syn_post_pull_new_post', array(__CLASS__, 'log_new' ), 10, 5 );
add_action ( 'syn_post_pull_edit_post', array(__CLASS__, 'log_update' ), 10, 5 );
}
/**
* Return Client Data
* @return array array( 'id' => (string) $transport_name, 'modes' => array( 'push', 'pull' ), 'name' => (string) $name );
*/
private function set_feed_url($url) {
if ( parse_url( $url ) ) {
$this->feed_url = $url;
} else {
$this->error_code = 0;
$this->error_message = sprintf( __( 'Feed url not set for this feed: %s', 'push-syndication' ), $site_ID );
}
}
public static function get_client_data() {
return array( 'id' => 'WP_XML', 'modes' => array( 'pull' ), 'name' => 'XML' );
}
public function new_post( $post_ID ) {
return false; // Not supported
}
public function edit_post( $post_ID, $ext_ID ) {
return false; // Not supported