Code Monkey home page Code Monkey logo

syndication's Introduction

Syndication

Syndicate content to and from your sites.

Here's how it works:

  1. Configure which post types are "pushable", as well as whether you'd like syndicated posts to be deleted when the master post is deleted.
  2. Register and group your sites into "Sitegroups" in settings.
  3. In the WordPress posting interface, you'll see a new "Syndication" metabox, with all of your sitegroups listed. Select the sitegroups you want to push to and the post will be automatically syndicated to your other sites when it's published and updated.

WordPress.com REST API

To push content using the WordPress.com REST API you need to create an application from the WordPress.com Developer Resources site - and you can also generate API tokens directly from the plugin's settings page.

Fill in the client ID and client secret as displayed on the app page, and click the authorize button to get directed to the authorization page on WordPress.com. Select which site you'd like to push to and click "Authorize", at which point you'll be redirected back to your settings page-which will now display the API token, Blog ID, and Blog URL. You can now use this information to register your WordPress.com site.

Security

To store passwords securely, we recommend defining an encryption key, which will be used to encrypt credentials when saved to the database.

define('PUSH_SYNDICATE_KEY', 'this-is-a-random-key')

Pulling from RSS Feeds

Push Syndication can ingest RSS feeds into your site for you. It's as simple as adding a site, setting the transport type to "RSS (pull)" and entering an RSS URL and title.

To add a site, go to the WordPress admin and find the "Sites" menu item, below Settings and choose "Add New". In the settings, you'll be able to customize the post's type, status, comment settings, pingback settings and category.

Using WordPress XMLRPC

Note that, if you use the XMLRPC push syndication method and you have two-factor authentication enabled on your account, you will need to create an application password to use when adding a new site. Using your regular password will not work.

Contributing

If you are interested in contributing, we need help with two main areas:

  1. Fixing bugs in v1
  2. Feature development in v2

Issues have been created for each of the planned feature developments. Help with documentation for both versions is also greatly appreciated.

syndication's People

Contributors

alexiskulash avatar bhartshorn avatar brandwaffle avatar dlh01 avatar emrikol avatar garyjones avatar gudmdharalds avatar jeffsebring avatar joshbetz avatar keoshi avatar lovestulip avatar maevelander avatar mjangda avatar nickdaugherty avatar nprasath002 avatar philipjohn avatar sboisvert avatar simonwheatley avatar tannerm avatar tomjn avatar tott avatar trepmal avatar vaurdan avatar vgfitzger avatar yoavf avatar yolih avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

syndication's Issues

IE9 chokes on a nested form

When you try to save Syndication settings in IE9, all settings get wiped except the site title.

This seems related to a nested form element in WP_Push_Syndication_Server::display_transports, form. (Amazingly other browsers seem able to cope with this.)

Improve efficiency

For big syndication jobs, we spend a lot of time clearing and priming caches. Let's treat it like an import and wait until the end to clear any caches.

Need multiple Publishers

Right now, we have an author "Bill." Bill can't log in to syndicate his own stories for physical reasons, so we have Larry log in for him. Larry's credentials are set on the settings for transport type credentials on Sites /wp-admin/edit.php?post_type=syn_site

We also have sites where Bill and Bob are publishing and Lynda might be the one responsible for syndicating (and Larry might while she's on vacation). We need both authors to be shown on the child site. So, we need multiple author and publisher capability. We believe Issue #61 might address multiple authors, but also need the multiple publishers, which is what this issue is for.

XPath tester

We should make it easy to verify how the settings for the XPath nodes translate into a post.

Fix Syndication Client architecture

There is a lot of duplicated code in the plugin. We should convert the Syndication_Client interface to an abstract class and abstract common code there. We might also be able to remove the Syndication_Client_Factory as well.

Use hidden field when there's 1 transport

If there is only one transport, currently we show a select box with just one element. Instead we should:

  • Use a hidden field
  • Set the UI fields for the edit site screen as appropriate for that transport

Auto retry

A better way to find and retry failed syndications.

Failures will happen, but Syndication stores them in a weird way that isn't easy to surface. You have to run through them all to find failures. A cron job that finds those and retries them would be ideal.

props @nickdaugherty

XML Pull: UI Cleanup

The UI is a bit clunky right now. Let's fix up the labelling and clean it up a bit.

On-demand pulling of feeds

We should be able to pull an individual feed on-demand. It should queue a single cron to process the feed.

Do not show config related to inactive transports

The current settings page is pretty scary, and also largely unnecessary if you only have RSS transport active.

If a transport is inactive then the settings related to that transport should not be visible.

XML Pull: Feed Validation

We should be good and validate:

  • that the URL is a valid XML file; and
  • that the required values (like post identifier/GUID) are set

Problem with xml pull syndication feed interface when node is used for two items in post

there is a small bug in the user interface for creating feeds. Sometimes you need to use the same node in the feed for two things in the post. Maybe the post title and also a post_meta for example. So... this is fine, as long as you enter the duplicate nodes LAST. If you make any change after you've entered and save, they get combined into one. Can you take a look at this and see if you see the bug that causes this to work this way?

Thanks,

James

Add Custom Taxonomy Support && Add automatic Category / Tag mapping

This is a copy paste of a patch that was worked on for a while with these features. See ZD 27099 for more info:

diff --git a/includes/class-syndication-wp-rss-client.php b/includes/class-syndication-wp-rss-client.php
index d2241cd..d5b1832 100644
--- a/includes/class-syndication-wp-rss-client.php
+++ b/includes/class-syndication-wp-rss-client.php
@@ -10,6 +10,7 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client
     private $default_comment_status;
     private $default_ping_status;
     private $default_cat_status;
+    private $default_tax_import;

     function __construct( $site_ID ) {

@@ -34,6 +35,7 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client
         $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->default_cat_status       = get_post_meta( $site_ID, 'syn_default_cat_status', true );
+        $this->default_tax_import       = get_post_meta( $site_ID, 'syn_default_tax_import', 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 );
@@ -78,6 +80,7 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client
         $default_comment_status     = get_post_meta( $site->ID, 'syn_default_comment_status', true );
         $default_ping_status        = get_post_meta( $site->ID, 'syn_default_ping_status', true );
         $default_cat_status         = get_post_meta( $site->ID, 'syn_default_cat_status', true );
+        $default_tax_import         = get_post_meta( $site->ID, 'syn_default_tax_import', true );

         ?>

@@ -146,10 +149,34 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client
         </p>
         <p>
             <select name="default_cat_status" id="default_cat_status" />
-            <option value="yes" <?php selected( 'yes', $default_cat_status )  ?> ><?php echo esc_html__( 'import categories', 'push-syndication' ); ?></option>
             <option value="no" <?php selected( 'no', $default_cat_status )  ?> ><?php echo esc_html__( 'ignore categories', 'push-syndication' ); ?></option>
+            <option value="yes" <?php selected( 'yes', $default_cat_status )  ?> ><?php echo esc_html__( 'import categories', 'push-syndication' ); ?></option>
             </select>
         </p>
+        <p class="tax_import_type">
+            <label for="default_tax_import"><?php echo esc_html__( 'Import as taxonomy', 'push-syndication' ); ?></label>
+        </p>
+        <p class="tax_import_type">
+            <?php
+            $args = array( 'public' => true );
+            $taxonomies = get_taxonomies( $args, 'objects', 'and' );
+            if ( $taxonomies ) :
+                ?>
+                <select name="default_tax_import" id="default_tax_import" />
+                    <option value="existing" <?php selected( 'existing', $default_tax_import )  ?> ><?php echo esc_html__( 'Check for existing', 'push-syndication' ); ?></option>
+                    <?php
+                      foreach ( $taxonomies  as $taxonomy ) :
+                       if ( 'post_format' != $taxonomy->name ) :?>
+                            <option value="<?php echo esc_attr( $taxonomy->name ); ?>" <?php selected( $taxonomy->name, $default_tax_import )  ?> ><?php echo $taxonomy->labels->singular_name; ?></option>
+                  <?php endif;
+                      endforeach;
+                    ?>
+                </select>
+                <?php
+            endif;
+            ?>
+            <p class="tax_import_type"><?php echo esc_html__( '"Check for existing" will see if an imported category exists as a term in any public taxonomy if it does not exist it will be created as a category.', 'push-syndication' ); ?></p>
+        </p>

         <?php

@@ -164,6 +191,7 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client
         update_post_meta( $site_ID, 'syn_default_comment_status', $_POST['default_comment_status'] );
         update_post_meta( $site_ID, 'syn_default_ping_status', $_POST['default_ping_status'] );
         update_post_meta( $site_ID, 'syn_default_cat_status', $_POST['default_cat_status'] );
+        update_post_meta( $site_ID, 'syn_default_tax_import', $_POST['default_tax_import'] );
         return true;

     }
@@ -179,7 +207,7 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client

         // hold all the posts
         $posts = array();
-        $taxonomy = array( 'cats' => array(), 'tags' => array() );
+        $taxonomy = array( 'category' => array(), 'post_tag' => array(), 'taxonomy' => array() );

         foreach( $this->get_items() as $item ) {
             if ( 'yes' == $this->default_cat_status ) {
@@ -196,9 +224,11 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client
                 'comment_status'    => $this->default_comment_status,
                 'ping_status'       => $this->default_ping_status,
                 'post_guid'         => $item->get_id(),
-                'post_category'     => $taxonomy['cats'],
-                'tags_input'        => $taxonomy['tags']
+                'post_category'     => $taxonomy['category'],
+                'tags_input'        => $taxonomy['post_tag'],
+                'tax_input'            => $taxonomy['tax']
             );
+
             // This filter can be used to exclude or alter posts during a pull import
             $post = apply_filters( 'syn_rss_pull_filter_post', $post, $args, $item );
             if ( false === $post )
@@ -209,30 +239,62 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client
         return $posts;

     }
-    
+
     public function set_taxonomy( $item ) {
         $cats = $item->get_categories();
         $ids = array(
-            'cats'    => array(),
-            'tags'            => array()
+            'category'    => array(),
+            'post_tag'    => array(),
+            'tax'     => array()
         );

-        foreach ( $cats as $cat ) {
-            // checks if term exists
-            if ( $result = get_term_by( 'name', $cat->term, 'category' ) ) {
-                if ( isset( $result->term_id ) ) {
-                    $ids['cats'][] = $result->term_id;
+        // get taxonomies
+        $args = array( 'public' => true );
+        $taxonomies = get_taxonomies( $args, 'objects', 'and' );
+        $tax = 'category';
+
+        if ( 'existing' == $this->default_tax_import ) {
+            foreach ( $cats as $cat ) {
+                // checks if term exists
+                foreach( $taxonomies as $taxonomy ) {
+                    $term = term_exists($cat->term,  $taxonomy->name);
+                    if ( ! is_null( $term ) ) {
+                        $tax =  $taxonomy->name;
+                    }
+                }
+
+                // checks if term exists
+                if ( ! $result = get_term_by( 'name', $cat->term, $tax ) ) {
+                    // if neither exist creates category
+                    $result = wp_insert_term( $cat->term, 'category' );
                 }
-            } elseif ( $result = get_term_by( 'name', $cat->term, 'post_tag' ) ) {
+
+                // sets ids for terms and tags
                 if ( isset( $result->term_id ) ) {
-                    $ids['tags'][] = $result->term_id;
-                }                    
-            } else {
-                // creates if not
-                $result = wp_insert_term( $cat->term, 'category' );
+                    $ids['tax'][$tax][] = $result->term_id;
+                }
+
+            }
+        } else {
+            foreach ( $cats as $cat ) {
+                if ( 'category' == $this->default_tax_import || 'post_tag' == $this->default_tax_import ) {
+                    $tax = $this->default_tax_import;
+                } else {
+                    $tax = 'tax';
+                }
+
+                // checks to see if term exists, creates it if it does.
+                if ( ! $result = get_term_by( 'name', $cat->term, $this->default_tax_import ) ) {
+                    $result = wp_insert_term( $cat->term, $this->default_tax_import );
+                }
+
                 if ( isset( $result->term_id ) ) {
-                    $ids['cats'][] = $result->term_id;
+                    $ids[$tax][] = ( is_taxonomy_hierarchical( $this->default_tax_import ) ) ? $result->term_id : $result->name;
                 }
+
+            }
+            if ( $tax == 'tax' ) {
+                $ids[$tax] = array( $this->default_tax_import => implode( ',', $ids[$tax] ) );
             }
         }

You can add settings for RSS syndication but not use them

There's an action syn_after_site_form which enables form fields to be added to the configuration screen for an individual feed.

You can intercept, validate, sanitise, and save the settings into post meta on the feed post during the save_post hook.

There is a filter,syn_rss_pull_filter_post, provided to "exclude or alter posts during a pull import", but this filter is not passed the ID of the post where the site data is saved, so you cannot access the additional post meta at this point.

Parse Error on install and activation

Parse error: syntax error, unexpected T_FUNCTION in /home/content/35/8172135/html/wp-content/plugins/syndication-master/includes/class-syndication-logger-viewer.php on line 154

Add a nice dashicon

The current standard "posts" icon is a bit sad. ๐Ÿ˜ž

If we go for something from the existing dashicons, the most appropriate might be dashicons-rss, but it might be nice to get creative.

Syndicate Author data

Currently, author data is not syndicated; whatever account is used for syndication on the child site is what is used to publish the syndicated post. Author data should be pushed out as well.

Too easy to create sites which do not syndicate

Currently, to create a new RSS pull site, you must assign it to a site group for anything to work. This is not obvious to the user; we do not show an error, nor do we assign default site groups.

Suggestion: We should create a default site group, then we should assign all auto-draft sites to that default site group.

Better UI for creating Endpoints/Sites

Right now, it's a bit clunky. We should have a more streamlined flow for creating an endpoint, where we select the type we want and then go from there.

Cron is not passing an array of sites to `pull_content`

When scheduling the event for RSS pulls, at least, we need to pass an array of site objects as the first argument on the cron hook, this corresponds to the $sites argument in the pull_content method on the WP_Push_Syndication_Server class. Currently the code to schedule the event looks like:

// Schedule new jobs: one job for each site. 
foreach ( $sites as $site ) {
    wp_schedule_event(
        time() - 1,
        'syn_pull_time_interval',
        'syn_pull_content',
        array( $site )
    );
}

I believe the fourth parameter needs to be wrapped in another array, e.g. array( array( $site ) ). This parameter equates to $v['args'] in this call: do_action_ref_array( $hook, $v['args'] ); in wp-cron.phpโ€ฆ i.e. the first index in the outer array is used as the first parameter passed to the cron hook, the second index is used as the second parameter, and so on.

Parent Push/Pull classes

We should have another set of parent classes for both push and pull clients that clients can extend and hold shared/common functionality.

Meta does not support storing multiple values

It would be nice to be able to store multiple repeating values in meta for the same feed item. Currently, the meta saving portion does the following:

$meta_data[$save_location['field']] = (string)$value_array[0];

But the tax saving portion does this:

foreach ( $value_array as $value ) {
    $tax_data[] = array( 'tax_name' => $save_location['field'], 'tax_value'=> ( string ) $value );
}

If it seems reasonable, I can implement saving of multiple items as an array in the meta. Thoughts?

XML Pull Client does not set post_status based on default_post_status

The XML pull client is publishing posts using the syn_post_pull_new_post filter hook. $this->default_post_status is never used to set the post status, which means all posts are run through wp_insert_post with no default post_status (therefore the post status is set to 'draft').

This can result in weird behavior (it allows for the post to have no slug, for example, unless one is explicitly passed as part of the $post data). Since the post is then published by default using the wp_publish_post function (called by publish_pulled_post in class-syndication-wp-xml-client.php, there is no control over the final post_status of the post (it's always 'publish') unless one removes that filter explicitly.

wp-cli: push_post

New command to push a post out to the selected sites.

Should be able to specify sites by group or ID, or default to the pre-selected ones.

RSS feed discoverability

Currently the user must add the feed URL itself, it would be good to allow them to add a site URL and have the plugin discover the feed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.