Plugin Directory

Changeset 2719676


Ignore:
Timestamp:
05/06/2022 10:18:47 PM (4 years ago)
Author:
sophidev
Message:

Update to version 1.1.0 from GitHub

Location:
sophi
Files:
32 edited
1 copied

Legend:

Unmodified
Added
Removed
  • sophi/tags/1.1.0/dist/blocks/site-automation-block/editor.asset.php

    r2712442 r2719676  
    1 <?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-polyfill', 'wp-server-side-render'), 'version' => 'c1ea6466e2019ebe4c1d34efbbe14c08');
     1<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => '6b770778443ef1bc5e7ce8bc2155af63');
  • sophi/tags/1.1.0/dist/css/admin-style.asset.php

    r2712442 r2719676  
    1 <?php return array('dependencies' => array(), 'version' => '0ba91fbea2966d6e37e0cc39726ecc91');
     1<?php return array('dependencies' => array(), 'version' => 'f61f5d166b686d75e9ae92cfc4a725fe');
  • sophi/tags/1.1.0/dist/css/admin-style.css

    r2681627 r2719676  
    1 .sophi-settings .brand{display:none}.sophi-settings .brand .logo img{max-width:170px}.sophi-settings .brand nav a{display:block;text-decoration:none}.sophi-settings .brand nav a span{font-size:inherit;line-height:inherit;vertical-align:unset}.sophi-settings .general-settings:not(.connected),.sophi-settings .general-settings:not(.connected)+table{display:none}.sophi-settings .enable-for td{padding-bottom:5px}.sophi-settings .post-types td{padding-left:40px;padding-top:0}.sophi-settings .credentials-setup ul{list-style:disc;padding-left:25px}.sophi-settings .credentials-actions a{text-decoration:none}.sophi-settings .credentials-actions span{font-size:inherit;line-height:1.5}.sophi-settings .credentials-setup.connected .close,.sophi-settings .credentials-setup.connected .credentials-instructions,.sophi-settings .credentials-setup.connected+table,.sophi-settings .credentials-setup:not(.connected) .open{display:none}@media (min-width:1024px){.sophi-settings{display:flex}.sophi-settings form{margin-right:50px;width:70%}.sophi-settings .brand{display:block}}@media (min-width:1200px){.sophi-settings form{margin-right:10%;width:60%}}
     1.sophi-settings .brand{display:none}.sophi-settings .brand .logo img{max-width:170px}.sophi-settings .brand nav a{display:block;text-decoration:none}.sophi-settings .brand nav a span{font-size:inherit;line-height:inherit;vertical-align:baseline;vertical-align:initial}.sophi-settings .general-settings:not(.connected),.sophi-settings .general-settings:not(.connected)+table{display:none}.sophi-settings .enable-for td{padding-bottom:5px}.sophi-settings .post-types td{padding-left:40px;padding-top:0}.sophi-settings .credentials-setup ul{list-style:disc;padding-left:25px}.sophi-settings .credentials-actions a{text-decoration:none}.sophi-settings .credentials-actions span{font-size:inherit;line-height:1.5}.sophi-settings .credentials-setup.connected .close,.sophi-settings .credentials-setup.connected .credentials-instructions,.sophi-settings .credentials-setup.connected+table,.sophi-settings .credentials-setup:not(.connected) .open{display:none}@media (min-width:1024px){.sophi-settings{display:flex}.sophi-settings form{margin-right:50px;width:70%}.sophi-settings .brand{display:block}}@media (min-width:1200px){.sophi-settings form{margin-right:10%;width:60%}}
  • sophi/tags/1.1.0/dist/js/sophi-tag.asset.php

    r2712442 r2719676  
    1 <?php return array('dependencies' => array('wp-polyfill'), 'version' => '343e76706b96c9a1821ae7c24c72678c');
     1<?php return array('dependencies' => array(), 'version' => '4a6e3a2547675352240f0648a13f4fa1');
  • sophi/tags/1.1.0/includes/classes/Command.php

    r2548540 r2719676  
    221221                if ( $count < $limit ) {
    222222                    if ( ! $dry_run ) {
    223                         $response = track_event( 'publish', 'publish', $post );
     223                        $response = track_event( $post->ID, $post, true, null );
    224224                        if ( is_wp_error( $response ) ) {
    225225                            $error_count++;
  • sophi/tags/1.1.0/includes/classes/SiteAutomation/Auth.php

    r2648442 r2719676  
    6565     */
    6666    public function request_access_token( $client_id, $client_secret ) {
    67         $body    = [
     67        $body = [
    6868            'client_id'     => $client_id,
    6969            'client_secret' => $client_secret,
     
    7171            'grant_type'    => 'client_credentials',
    7272        ];
    73         $request = wp_remote_post(
    74             $this->get_auth_url(),
    75             [
    76                 'headers' => [ 'Content-Type' => 'application/json' ],
    77                 'body'    => wp_json_encode( $body ),
    78             ]
    79         );
     73        $args = [
     74            'headers' => [ 'Content-Type' => 'application/json' ],
     75            'body'    => wp_json_encode( $body ),
     76        ];
     77
     78        $auth_url = $this->get_auth_url();
     79
     80        /** This filter is documented in includes/classes/SiteAutomation/Request.php */
     81        $args = apply_filters( 'sophi_request_args', $args, $auth_url );
     82
     83        $request = wp_remote_post( $auth_url, $args );
     84
     85        /** This filter is documented in includes/classes/SiteAutomation/Request.php */
     86        $request = apply_filters( 'sophi_request_result', $request, $args, $auth_url );
    8087
    8188        if ( is_wp_error( $request ) ) {
  • sophi/tags/1.1.0/includes/classes/SiteAutomation/Integration.php

    r2681627 r2719676  
    104104         *
    105105         * @param {array} $posts Post list.
    106          * @param {string} $query_vars['sophi_curated_page'] Sophi curated page param.
    107          * @param {string} $query_vars['sophi_curated_widget'] Sophi curated widget param.
     106         * @param {string} $sophi_curated_page Sophi curated page param.
     107         * @param {string} $sophi_curated_widget Sophi curated widget param.
    108108         * @param {array}  $request_status The request status, whether it was successful or not.
    109109         * @param {WP_Query} $query Original query.
  • sophi/tags/1.1.0/includes/classes/SiteAutomation/Request.php

    r2686283 r2719676  
    5151
    5252    /**
     53     * Post ID for Site Automation request.
     54     *
     55     * @var string $post_id
     56     */
     57    protected $post_id;
     58
     59    /**
    5360     * Class constructor.
    5461     *
     
    7986        $this->widget  = $widget;
    8087        $this->api_url = $this->set_api_url( $page, $widget );
     88        $this->post_id = get_the_ID();
    8189
    8290        $this->status         = $this->get_status();
     
    98106
    99107        if ( ! $bypass_cache ) {
    100             $site_automation_data = get_option( "sophi_site_automation_data_{$page}_{$widget}" );
     108            $site_automation_data = get_post_meta( $this->post_id, "_sophi_site_automation_data_{$this->page}_{$this->widget}", true );
    101109        }
    102110
     
    183191
    184192        $this->status = $data;
    185         set_transient( "sophi_site_automation_status_{$this->page}_{$this->widget}", $data, $this->get_cache_duration() );
     193
     194        if ( ! empty( $this->post_id ) ) {
     195            set_transient( "sophi_site_automation_status_{$this->post_id}_{$this->page}_{$this->widget}", $data, $this->get_cache_duration() );
     196        }
    186197    }
    187198
     
    207218        ];
    208219
     220        /**
     221         * Filters the arguments used in Sophi HTTP request.
     222         *
     223         * @since 1.0.14
     224         * @hook sophi_request_args
     225         *
     226         * @param {array}   $args HTTP request arguments.
     227         * @param {string}  $url  The request URL.
     228         *
     229         * @return {array} HTTP request arguments.
     230         */
     231        $args = apply_filters( 'sophi_request_args', $args, $this->api_url );
     232
    209233        if ( function_exists( 'vip_safe_wp_remote_get' ) ) {
    210234            $request = vip_safe_wp_remote_get( $this->api_url, '', 3, $timeout, 20, $args );
     
    214238        }
    215239
     240        /**
     241         * Filters a Sophi HTTP request immediately after the response is received.
     242         *
     243         * @since 1.0.14
     244         * @hook sophi_request_result
     245         *
     246         * @param {array|WP_Error}  $request Result of HTTP request.
     247         * @param {array}           $args     HTTP request arguments.
     248         * @param {string}          $url      The request URL.
     249         *
     250         * @return {array|WP_Error} Result of HTTP request.
     251         */
     252        $request = apply_filters( 'sophi_request_result', $request, $args, $this->api_url );
     253
    216254        if ( is_wp_error( $request ) ) {
    217255            return $request;
     
    238276        }
    239277
    240         if ( ! $bypass_cache ) {
    241             update_option( "sophi_site_automation_data_{$this->page}_{$this->widget}", $response );
    242         }
     278
     279        $post = get_post();
     280
     281        if ( ! $post || wp_is_post_revision( $post ) ) {
     282            return $response;
     283        }
     284
     285        $meta_key   = "_sophi_site_automation_data_{$this->page}_{$this->widget}";
     286        $created_at = date_create( 'now', wp_timezone() );
     287
     288        if ( $created_at && ! $bypass_cache ) {
     289            update_post_meta( $post->ID, $meta_key, $response );
     290            update_post_meta( $post->ID, $meta_key . '_created_at', $created_at->getTimestamp() );
     291        }
     292
    243293        return $response;
    244294    }
  • sophi/tags/1.1.0/includes/functions/content-sync.php

    r2712442 r2719676  
    132132    }
    133133
     134    /**
     135     * Filters the data used in Sophi track event request.
     136     *
     137     * @since 1.0.14
     138     * @hook sophi_tracking_data
     139     *
     140     * @param {array}   $data    Tracking data to send.
     141     * @param {Tracker} $tracker Tracker being used.
     142     * @param {string}  $url     Post object.
     143     * @param {string}  $action  Publishing action.
     144     *
     145     * @return {array} Tracking data to send.
     146     */
     147    $data = apply_filters_ref_array( 'sophi_cms_tracking_request_data', array( $data, &$tracker, $post, $action ) );
    134148    $tracker->trackUnstructEvent(
    135149        [
     
    147161        ]
    148162    );
     163
     164    /**
     165     * Fires after tracker sends the request.
     166     *
     167     * @since 1.0.14
     168     * @hook sophi_tracking_result
     169     *
     170     * @param {array}   $data    Tracked data.
     171     * @param {Tracker} $tracker Tracker object.
     172     * @param {WP_Post} $post    Post object.
     173     * @param {string}  $action  Publishing action.
     174     */
     175    do_action_ref_array( 'sophi_cms_tracking_result', array( $data, &$tracker, $post, $action ) );
    149176}
    150177
     
    172199    }
    173200
     201    /**
     202     * Whether to turn on emitter debug
     203     *
     204     * @since 1.0.14
     205     * @hook sophi_tracker_emitter_debug
     206     *
     207     * @param {bool} $debug Debug is active.
     208     *
     209     * @return {bool} Whether to turn on emitter debug.
     210     */
     211    $debug = apply_filters( 'sophi_tracker_emitter_debug', false );
     212
    174213    $app_id  = sprintf( '%s:cms', $tracker_client_id );
    175     $emitter = new SyncEmitter( $collector_url, 'https', 'POST', 1, false );
     214    $emitter = new SyncEmitter( $collector_url, 'https', 'POST', 1, $debug );
    176215    $subject = new Subject();
    177216    return new Tracker( $emitter, $subject, 'sophiTag', $app_id, false );
  • sophi/tags/1.1.0/includes/functions/utils.php

    r2698689 r2719676  
    8585        $terms    = get_the_terms( $post, $taxonomy );
    8686
    87         if ( count( $terms ) > 0 ) {
     87        if ( is_array( $terms ) && count( $terms ) > 0 ) {
    8888            return get_term_breadcrumb( $terms[0] );
    8989        }
     
    114114            $terms    = get_the_terms( $post, $taxonomy );
    115115
    116             if ( count( $terms ) > 0 ) {
     116            if ( is_array( $terms ) && count( $terms ) > 0 ) {
    117117                return $terms[0]->slug;
    118118            }
  • sophi/tags/1.1.0/readme.txt

    r2712442 r2719676  
    22Contributors:      10up, sophidev
    33Tags:              Sophi, Site Automation, Curator, Collector, AI, Artifical Intelligence, ML, Machine Learning, Content Curation
    4 Tested up to:      5.8
    5 Stable tag:        1.0.13
     4Tested up to:      5.9
     5Stable tag:        1.1.0
    66License:           GPLv2 or later
    77License URI:       http://www.gnu.org/licenses/gpl-2.0.html
     
    5151== Usage ==
    5252
    53 There are two ways that Sophi Site Automation results can be included in a WordPress site, via a Site Automation block and a direct integration with WP_Query.  More details on each of these options are described below.
     53There are two potential ways to integrate Sophi Site Automation results with your WordPress site. The default approach includes a Sophi Site Automation block that integrates with `WP_Query` by injecting Posts IDs via the `posts_pre_query` filter that gets fetched later to return the actual Posts. In the same fashion, you can integrate Sophi results with your `WP_Query` object by setting the `sophi_curated_page` and `sophi_curated_widget` query parameters.
     54
     55More details on each of these two options are described below.  If you are not certain on the best integration approach, considering the following:
     56
     57Reasons to use the Site Automation block:
     58- No additional development effort needed for initial Sophi integration
     59- Immediate integration with Sophi Site Automation API and page/widget settings
     60- Basic block display settings allow for basic configurations (show/hide post excerpt, author name, post date, featured image)
     61
     62Reasons to use the Query integration:
     63- Can implement more custom caching and content fallback options
     64- Can implement support into non-block editor setups
     65- Likely more flexible for headless setups
     66- Block editor is not in-use within your WordPress environment
     67- You need an integration with Category/Taxonomy Pages and cannot integrate using a sidebar widget
    5468
    5569= Site Automation block =
     
    94108`
    95109
     110== Caveats ==
     111
     112While the above query integration works just fine, it has been observed on [WordPress VIP](https://wpvip.com/) infrastructure that `WP_Query` may return latest posts instead of the posts curated by Sophi due to the [Advanced Post Cache](https://github.com/Automattic/advanced-post-cache) plugin used by the VIP platform. A workaround for this is to use [`get_posts()`](https://developer.wordpress.org/reference/functions/get_posts/) instead and as good practice to add a comment explaining the usage of it so that developers new to it don't swap it for `WP_Query`. Also remember to whitelist `get_posts` by adding the following inline comment so that PHPCS doesn't throw a warning:
     113
     114`phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.get_posts_get_posts`
     115
    96116= Post content type =
    97117
     
    121141WordPress SEO (Yoast) canonical is supported out of the box. For other SEO plugins and custom implementations, [`get_canonical_url`](https://developer.wordpress.org/reference/functions/wp_get_canonical_url/) filter can be used to change the canonical URL.
    122142
     143= Object caching =
     144
     145Object caching is encouraged, as the plugin saves Sophi data as a transient.  If you do not have object caching, then the data will be saved as a transient in the options table but note that these will eventually expire.
     146
    123147== Documentation ==
    124148
    125 Sophi for WordPress has an in-depth documentation site that details the available actions and filters found within the plugin. [Visit the hook docs ☞](https://globeandmail.github.io/sophi-for-wordpress/)
    126 
    127 == Developers ==
    128 
    129 If you're looking to contribute to or extend the Sophi for WordPress plugin, then the following sub-sections are things to be aware of in terms of how the plugin is architected.
    130 
    131 = Dependencies =
    132 
    133 1. [Node >= 8.11 & NPM](https://www.npmjs.com/get-npm) - Build packages and 3rd party dependencies are managed through NPM, so you will need that installed globally.
    134 2. [Webpack](https://webpack.js.org/) - Webpack is used to process the JavaScript, CSS, and other assets.
    135 3. [Composer](https://getcomposer.org/) - Composer is used to manage PHP.
    136 
    137 = NPM Commands =
    138 
    139 - `npm run test` (runs phpunit)
    140 - `npm run start` (install dependencies)
    141 - `npm run watch` (watch)
    142 - `npm run build` (build all files)
    143 - `npm run build-release` (build all files for release)
    144 - `npm run dev` (build all files for development)
    145 - `npm run lint-release` (install dependencies and run linting)
    146 - `npm run lint-css` (lint CSS)
    147 - `npm run lint-js` (lint JS)
    148 - `npm run lint-php` (lint PHP)
    149 - `npm run lint` (run all lints)
    150 - `npm run format-js` (format JS using eslint)
    151 - `npm run format` (alias for `npm run format-js`)
    152 - `npm run test-a11y` (run accessibility tests)
    153 
    154 = Composer Commands =
    155 
    156 - `composer lint` (lint PHP files)
    157 - `composer lint-fix` (lint PHP files and automatically correct coding standard violations)
    158 
    159 = WP-CLI Commands =
    160 
    161 **Sync content to Sophi Collector**
    162 
    163 `$ wp sophi sync [--post_types=<string>] [--limit=<number>] [--per_page=<number>] [--include=<number>]`
    164 
    165 Sync all supported content to Sophi Collector, firing off update events for all of them.  The expected use case with the Sophi for WordPress plugin is that someone will install it on an existing site and instead of having to manually update each piece of content to ensure that it makes it to the Collector, they can run this script to handle that all at once.
    166 
    167 *Options*
    168 
    169 **`--post_types=<string>`**
    170 
    171 Post types to be processed. Comma separated for passing multiple post types.
    172 
    173 default: `false`
    174 options:
    175 - any post type name
    176 - `false`
    177 
    178 **`--limit=<number>`**
    179 
    180 Limit the amount of posts to be synced.
    181 
    182 default: `false`
    183 options:
    184 - `false`, no limit
    185 - `N`, max number of posts to sync
    186 
    187 **`--per_page=<number>`**
    188 
    189 Number of posts to process each batch.
    190 
    191 default: `false`
    192 options:
    193 - `false`, no limit
    194 - `N`, max number of posts to sync each batch
    195 
    196 **`--include=<number>`**
    197 
    198 Post IDs to process. Comma separated for passing multiple item.
    199 
    200 default: `false`
    201 options:
    202 - `false`, no limit
    203 - `N`, Post IDs to sync
     149Sophi for WordPress has an in-depth documentation site that details the available actions and filters found within the plugin. [Visit the developer docs ☞](https://globeandmail.github.io/sophi-for-wordpress/)
    204150
    205151== Frequently Asked Questions ==
     
    228174
    229175== Changelog ==
     176
     177= 1.1.0 - 2022-05-06 =
     178* **Added:** Filter `sophi_request_args` filters arguments used in Sophi HTTP request (props [@cadic](https://github.com/cadic), [@iamdharmesh](https://github.com/iamdharmesh) via [#257](https://github.com/globeandmail/sophi-for-wordpress/pull/257)).
     179* **Added:** Filter `sophi_request_result` filters a Sophi HTTP request immediately after the response is received (props [@cadic](https://github.com/cadic), [@iamdharmesh](https://github.com/iamdharmesh) via [#257](https://github.com/globeandmail/sophi-for-wordpress/pull/257), [#261](https://github.com/globeandmail/sophi-for-wordpress/pull/261)).
     180* **Added:** Filter `sophi_cms_tracking_request_data` filters the data used in Sophi track event request (props [@cadic](https://github.com/cadic), [@iamdharmesh](https://github.com/iamdharmesh), [@jeffpaul](https://github.com/jeffpaul) via [#257](https://github.com/globeandmail/sophi-for-wordpress/pull/257), [#263](https://github.com/globeandmail/sophi-for-wordpress/pull/263)).
     181* **Added:** Action `sophi_cms_tracking_result` fires after tracker sends the request (props [@cadic](https://github.com/cadic), [@iamdharmesh](https://github.com/iamdharmesh), [@jeffpaul](https://github.com/jeffpaul) via [#257](https://github.com/globeandmail/sophi-for-wordpress/pull/257), [#263](https://github.com/globeandmail/sophi-for-wordpress/pull/263)).
     182* **Added:** Filter `sophi_tracker_emitter_debug` allows to enable debug mode in the tracking emitter (props [@cadic](https://github.com/cadic), [@iamdharmesh](https://github.com/iamdharmesh) via [#257](https://github.com/globeandmail/sophi-for-wordpress/pull/257)).
     183* **Added:** Documentation on rational for block vs. custom query integration uses and `WP_Query` caveat on WordPress VIP (props [@Sidsector9](https://github.com/Sidsector9), [@jeffpaul](https://github.com/jeffpaul), [@oscarssanchez](https://github.com/oscarssanchez) via [#242](https://github.com/globeandmail/sophi-for-wordpress/pull/242), [#249](https://github.com/globeandmail/sophi-for-wordpress/pull/249), [#251](https://github.com/globeandmail/sophi-for-wordpress/pull/251)).
     184* **Changed:** Update response saving from options table to post meta field (props [@Rahmon](https://github.com/Rahmon), [@oscarssanchez](https://github.com/oscarssanchez) via [#253](https://github.com/globeandmail/sophi-for-wordpress/pull/253)).
     185* **Changed:** Bump WordPress "tested up to" version 5.9 (props [@jeffpaul](https://github.com/jeffpaul) via [#248](https://github.com/globeandmail/sophi-for-wordpress/pull/248)).
     186* **Changed:** Updated hookdocs site (now [Developer Docs](https://globeandmail.github.io/sophi-for-wordpress/)) to properly run on release and migrate in docs from readme (props [@iamdharmesh](https://github.com/iamdharmesh), [@jeffpaul](https://github.com/jeffpaul) via [#256](https://github.com/globeandmail/sophi-for-wordpress/pull/256)).
     187* **Fixed:** Check if `$terms` is an array before using `count()` within `get_the_terms()` (props [@barryceelen](https://github.com/barryceelen), [@Sidsector9](https://github.com/Sidsector9) via [#215](https://github.com/globeandmail/sophi-for-wordpress/pull/215)).
     188* **Fixed:** Update `track_event` arguments list inside `sync` WP-CLI command (props [@cadic](https://github.com/cadic), [@Sidsector9](https://github.com/Sidsector9) via [#250](https://github.com/globeandmail/sophi-for-wordpress/pull/250)).
     189* **Security:** Update `actions/checkout` action to from v2.4.0 to v3.0.2 (props [@renovate](https://github.com/apps/renovate), [@iamdharmesh](https://github.com/iamdharmesh) via [#240](https://github.com/globeandmail/sophi-for-wordpress/pull/240), [#241](https://github.com/globeandmail/sophi-for-wordpress/pull/241), [#243](https://github.com/globeandmail/sophi-for-wordpress/pull/243)).
     190* **Security:** Update `actions/setup-node` action from v1 to v3 (props [@renovate](https://github.com/apps/renovate), [@iamdharmesh](https://github.com/iamdharmesh) via [#244](https://github.com/globeandmail/sophi-for-wordpress/pull/244)).
     191* **Security:** Update dependency `10up-toolkit` from 3.1.2 to 4.0.0 (props [@renovate](https://github.com/apps/renovate), [@cadic](https://github.com/cadic) via [#264](https://github.com/globeandmail/sophi-for-wordpress/pull/264)).
    230192
    231193= 1.0.13 - 2022-04-20 =
     
    252214* **Security:** Update dependency `snowplow/snowplow-tracker` from 0.4.0 to 0.5.0 (props [@renovate](https://github.com/apps/renovate)).
    253215
    254 = 1.0.9 - 2022-02-18 = 
     216= 1.0.9 - 2022-02-18 =
    255217* **Added:** `hostname` and `path` fields to schema (props [@Rahmon](https://github.com/Rahmon), [@dinhtungdu](https://github.com/dinhtungdu)).
    256218* **Fixed:** Return empty post list from Sophi response (props [@oscarssanchez](https://github.com/oscarssanchez), [@barryceelen](https://github.com/barryceelen), [@felipeelia](https://github.com/felipeelia)).
  • sophi/tags/1.1.0/sophi.php

    r2712442 r2719676  
    44 * Plugin URI:        https://github.com/globeandmail/sophi-for-wordpress
    55 * Description:       WordPress VIP-compatible plugin for the Sophi.io Site Automation service.
    6  * Version:           1.0.13
     6 * Version:           1.1.0
    77 * Requires at least: 5.6
    88 * Requires PHP:      7.4
     
    1717
    1818// Useful global constants.
    19 define( 'SOPHI_WP_VERSION', '1.0.13' );
     19define( 'SOPHI_WP_VERSION', '1.1.0' );
    2020define( 'SOPHI_WP_URL', plugin_dir_url( __FILE__ ) );
    2121define( 'SOPHI_WP_PATH', plugin_dir_path( __FILE__ ) );
     
    123123
    124124}
     125
     126/**
     127 * Upgrader function for version 1.1.0
     128 * Deletes sophi_site_automation like options in favor of new post_meta approach.
     129 *
     130 * @param $installed string The version installed.
     131 */
     132function sophi_upgrade_1_1_0( $installed ) {
     133    global $wpdb;
     134    if ( $installed && version_compare( $installed, '1.1.0', '<' ) ) {
     135
     136        $options = $wpdb->get_results( $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE'%s' LIMIT 1000",  '%sophi_site_automation_data%' ) );
     137
     138        foreach ( $options as $option ) {
     139            delete_option( $option->option_name );
     140        }
     141    }
     142}
     143
     144add_action( 'sophi_upgrade', 'sophi_upgrade_1_1_0' );
     145
     146$installed = get_option( 'sophi_version' );
     147
     148if ( ! $installed || version_compare( $installed, SOPHI_WP_VERSION, '<' ) ) {
     149    /**
     150     * Upgrader hook to
     151     *
     152     * @param string $installed The previous version reference installed.
     153     */
     154    do_action( 'sophi_upgrade', $installed );
     155
     156    update_option( 'sophi_version', SOPHI_WP_VERSION, false );
     157}
  • sophi/tags/1.1.0/vendor/autoload.php

    r2712442 r2719676  
    1010require_once __DIR__ . '/composer/autoload_real.php';
    1111
    12 return ComposerAutoloaderInitcc764d3c724e24bbeeacdab81c50a2f0::getLoader();
     12return ComposerAutoloaderInitbdfd77ff5462663cbbe04b8ffeb39221::getLoader();
  • sophi/tags/1.1.0/vendor/composer/autoload_real.php

    r2712442 r2719676  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInitcc764d3c724e24bbeeacdab81c50a2f0
     5class ComposerAutoloaderInitbdfd77ff5462663cbbe04b8ffeb39221
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInitcc764d3c724e24bbeeacdab81c50a2f0', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInitbdfd77ff5462663cbbe04b8ffeb39221', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    29         spl_autoload_unregister(array('ComposerAutoloaderInitcc764d3c724e24bbeeacdab81c50a2f0', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInitbdfd77ff5462663cbbe04b8ffeb39221', 'loadClassLoader'));
    3030
    3131        require __DIR__ . '/autoload_static.php';
    32         call_user_func(\Composer\Autoload\ComposerStaticInitcc764d3c724e24bbeeacdab81c50a2f0::getInitializer($loader));
     32        call_user_func(\Composer\Autoload\ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221::getInitializer($loader));
    3333
    3434        $loader->register(true);
    3535
    36         $includeFiles = \Composer\Autoload\ComposerStaticInitcc764d3c724e24bbeeacdab81c50a2f0::$files;
     36        $includeFiles = \Composer\Autoload\ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221::$files;
    3737        foreach ($includeFiles as $fileIdentifier => $file) {
    38             composerRequirecc764d3c724e24bbeeacdab81c50a2f0($fileIdentifier, $file);
     38            composerRequirebdfd77ff5462663cbbe04b8ffeb39221($fileIdentifier, $file);
    3939        }
    4040
     
    4848 * @return void
    4949 */
    50 function composerRequirecc764d3c724e24bbeeacdab81c50a2f0($fileIdentifier, $file)
     50function composerRequirebdfd77ff5462663cbbe04b8ffeb39221($fileIdentifier, $file)
    5151{
    5252    if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • sophi/tags/1.1.0/vendor/composer/autoload_static.php

    r2712442 r2719676  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInitcc764d3c724e24bbeeacdab81c50a2f0
     7class ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221
    88{
    99    public static $files = array (
     
    8181    {
    8282        return \Closure::bind(function () use ($loader) {
    83             $loader->prefixLengthsPsr4 = ComposerStaticInitcc764d3c724e24bbeeacdab81c50a2f0::$prefixLengthsPsr4;
    84             $loader->prefixDirsPsr4 = ComposerStaticInitcc764d3c724e24bbeeacdab81c50a2f0::$prefixDirsPsr4;
    85             $loader->classMap = ComposerStaticInitcc764d3c724e24bbeeacdab81c50a2f0::$classMap;
     83            $loader->prefixLengthsPsr4 = ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221::$prefixLengthsPsr4;
     84            $loader->prefixDirsPsr4 = ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221::$prefixDirsPsr4;
     85            $loader->classMap = ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221::$classMap;
    8686
    8787        }, null, ClassLoader::class);
  • sophi/tags/1.1.0/vendor/composer/installed.php

    r2712442 r2719676  
    11<?php return array(
    22    'root' => array(
    3         'pretty_version' => '1.0.13',
    4         'version' => '1.0.13.0',
     3        'pretty_version' => '1.1.0',
     4        'version' => '1.1.0.0',
    55        'type' => 'wordpress-plugin',
    66        'install_path' => __DIR__ . '/../../',
    77        'aliases' => array(),
    8         'reference' => 'b8b608c50580b36a0a8f9a61e2e252dcca683835',
     8        'reference' => 'd84a89aaba7208a28828807ba338aa7dfbf8246e',
    99        'name' => 'globeandmail/sophi-for-wordpress',
    1010        'dev' => false,
     
    2121        ),
    2222        'globeandmail/sophi-for-wordpress' => array(
    23             'pretty_version' => '1.0.13',
    24             'version' => '1.0.13.0',
     23            'pretty_version' => '1.1.0',
     24            'version' => '1.1.0.0',
    2525            'type' => 'wordpress-plugin',
    2626            'install_path' => __DIR__ . '/../../',
    2727            'aliases' => array(),
    28             'reference' => 'b8b608c50580b36a0a8f9a61e2e252dcca683835',
     28            'reference' => 'd84a89aaba7208a28828807ba338aa7dfbf8246e',
    2929            'dev_requirement' => false,
    3030        ),
  • sophi/trunk/dist/blocks/site-automation-block/editor.asset.php

    r2712442 r2719676  
    1 <?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-polyfill', 'wp-server-side-render'), 'version' => 'c1ea6466e2019ebe4c1d34efbbe14c08');
     1<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => '6b770778443ef1bc5e7ce8bc2155af63');
  • sophi/trunk/dist/css/admin-style.asset.php

    r2712442 r2719676  
    1 <?php return array('dependencies' => array(), 'version' => '0ba91fbea2966d6e37e0cc39726ecc91');
     1<?php return array('dependencies' => array(), 'version' => 'f61f5d166b686d75e9ae92cfc4a725fe');
  • sophi/trunk/dist/css/admin-style.css

    r2681627 r2719676  
    1 .sophi-settings .brand{display:none}.sophi-settings .brand .logo img{max-width:170px}.sophi-settings .brand nav a{display:block;text-decoration:none}.sophi-settings .brand nav a span{font-size:inherit;line-height:inherit;vertical-align:unset}.sophi-settings .general-settings:not(.connected),.sophi-settings .general-settings:not(.connected)+table{display:none}.sophi-settings .enable-for td{padding-bottom:5px}.sophi-settings .post-types td{padding-left:40px;padding-top:0}.sophi-settings .credentials-setup ul{list-style:disc;padding-left:25px}.sophi-settings .credentials-actions a{text-decoration:none}.sophi-settings .credentials-actions span{font-size:inherit;line-height:1.5}.sophi-settings .credentials-setup.connected .close,.sophi-settings .credentials-setup.connected .credentials-instructions,.sophi-settings .credentials-setup.connected+table,.sophi-settings .credentials-setup:not(.connected) .open{display:none}@media (min-width:1024px){.sophi-settings{display:flex}.sophi-settings form{margin-right:50px;width:70%}.sophi-settings .brand{display:block}}@media (min-width:1200px){.sophi-settings form{margin-right:10%;width:60%}}
     1.sophi-settings .brand{display:none}.sophi-settings .brand .logo img{max-width:170px}.sophi-settings .brand nav a{display:block;text-decoration:none}.sophi-settings .brand nav a span{font-size:inherit;line-height:inherit;vertical-align:baseline;vertical-align:initial}.sophi-settings .general-settings:not(.connected),.sophi-settings .general-settings:not(.connected)+table{display:none}.sophi-settings .enable-for td{padding-bottom:5px}.sophi-settings .post-types td{padding-left:40px;padding-top:0}.sophi-settings .credentials-setup ul{list-style:disc;padding-left:25px}.sophi-settings .credentials-actions a{text-decoration:none}.sophi-settings .credentials-actions span{font-size:inherit;line-height:1.5}.sophi-settings .credentials-setup.connected .close,.sophi-settings .credentials-setup.connected .credentials-instructions,.sophi-settings .credentials-setup.connected+table,.sophi-settings .credentials-setup:not(.connected) .open{display:none}@media (min-width:1024px){.sophi-settings{display:flex}.sophi-settings form{margin-right:50px;width:70%}.sophi-settings .brand{display:block}}@media (min-width:1200px){.sophi-settings form{margin-right:10%;width:60%}}
  • sophi/trunk/dist/js/sophi-tag.asset.php

    r2712442 r2719676  
    1 <?php return array('dependencies' => array('wp-polyfill'), 'version' => '343e76706b96c9a1821ae7c24c72678c');
     1<?php return array('dependencies' => array(), 'version' => '4a6e3a2547675352240f0648a13f4fa1');
  • sophi/trunk/includes/classes/Command.php

    r2548540 r2719676  
    221221                if ( $count < $limit ) {
    222222                    if ( ! $dry_run ) {
    223                         $response = track_event( 'publish', 'publish', $post );
     223                        $response = track_event( $post->ID, $post, true, null );
    224224                        if ( is_wp_error( $response ) ) {
    225225                            $error_count++;
  • sophi/trunk/includes/classes/SiteAutomation/Auth.php

    r2648442 r2719676  
    6565     */
    6666    public function request_access_token( $client_id, $client_secret ) {
    67         $body    = [
     67        $body = [
    6868            'client_id'     => $client_id,
    6969            'client_secret' => $client_secret,
     
    7171            'grant_type'    => 'client_credentials',
    7272        ];
    73         $request = wp_remote_post(
    74             $this->get_auth_url(),
    75             [
    76                 'headers' => [ 'Content-Type' => 'application/json' ],
    77                 'body'    => wp_json_encode( $body ),
    78             ]
    79         );
     73        $args = [
     74            'headers' => [ 'Content-Type' => 'application/json' ],
     75            'body'    => wp_json_encode( $body ),
     76        ];
     77
     78        $auth_url = $this->get_auth_url();
     79
     80        /** This filter is documented in includes/classes/SiteAutomation/Request.php */
     81        $args = apply_filters( 'sophi_request_args', $args, $auth_url );
     82
     83        $request = wp_remote_post( $auth_url, $args );
     84
     85        /** This filter is documented in includes/classes/SiteAutomation/Request.php */
     86        $request = apply_filters( 'sophi_request_result', $request, $args, $auth_url );
    8087
    8188        if ( is_wp_error( $request ) ) {
  • sophi/trunk/includes/classes/SiteAutomation/Integration.php

    r2681627 r2719676  
    104104         *
    105105         * @param {array} $posts Post list.
    106          * @param {string} $query_vars['sophi_curated_page'] Sophi curated page param.
    107          * @param {string} $query_vars['sophi_curated_widget'] Sophi curated widget param.
     106         * @param {string} $sophi_curated_page Sophi curated page param.
     107         * @param {string} $sophi_curated_widget Sophi curated widget param.
    108108         * @param {array}  $request_status The request status, whether it was successful or not.
    109109         * @param {WP_Query} $query Original query.
  • sophi/trunk/includes/classes/SiteAutomation/Request.php

    r2686283 r2719676  
    5151
    5252    /**
     53     * Post ID for Site Automation request.
     54     *
     55     * @var string $post_id
     56     */
     57    protected $post_id;
     58
     59    /**
    5360     * Class constructor.
    5461     *
     
    7986        $this->widget  = $widget;
    8087        $this->api_url = $this->set_api_url( $page, $widget );
     88        $this->post_id = get_the_ID();
    8189
    8290        $this->status         = $this->get_status();
     
    98106
    99107        if ( ! $bypass_cache ) {
    100             $site_automation_data = get_option( "sophi_site_automation_data_{$page}_{$widget}" );
     108            $site_automation_data = get_post_meta( $this->post_id, "_sophi_site_automation_data_{$this->page}_{$this->widget}", true );
    101109        }
    102110
     
    183191
    184192        $this->status = $data;
    185         set_transient( "sophi_site_automation_status_{$this->page}_{$this->widget}", $data, $this->get_cache_duration() );
     193
     194        if ( ! empty( $this->post_id ) ) {
     195            set_transient( "sophi_site_automation_status_{$this->post_id}_{$this->page}_{$this->widget}", $data, $this->get_cache_duration() );
     196        }
    186197    }
    187198
     
    207218        ];
    208219
     220        /**
     221         * Filters the arguments used in Sophi HTTP request.
     222         *
     223         * @since 1.0.14
     224         * @hook sophi_request_args
     225         *
     226         * @param {array}   $args HTTP request arguments.
     227         * @param {string}  $url  The request URL.
     228         *
     229         * @return {array} HTTP request arguments.
     230         */
     231        $args = apply_filters( 'sophi_request_args', $args, $this->api_url );
     232
    209233        if ( function_exists( 'vip_safe_wp_remote_get' ) ) {
    210234            $request = vip_safe_wp_remote_get( $this->api_url, '', 3, $timeout, 20, $args );
     
    214238        }
    215239
     240        /**
     241         * Filters a Sophi HTTP request immediately after the response is received.
     242         *
     243         * @since 1.0.14
     244         * @hook sophi_request_result
     245         *
     246         * @param {array|WP_Error}  $request Result of HTTP request.
     247         * @param {array}           $args     HTTP request arguments.
     248         * @param {string}          $url      The request URL.
     249         *
     250         * @return {array|WP_Error} Result of HTTP request.
     251         */
     252        $request = apply_filters( 'sophi_request_result', $request, $args, $this->api_url );
     253
    216254        if ( is_wp_error( $request ) ) {
    217255            return $request;
     
    238276        }
    239277
    240         if ( ! $bypass_cache ) {
    241             update_option( "sophi_site_automation_data_{$this->page}_{$this->widget}", $response );
    242         }
     278
     279        $post = get_post();
     280
     281        if ( ! $post || wp_is_post_revision( $post ) ) {
     282            return $response;
     283        }
     284
     285        $meta_key   = "_sophi_site_automation_data_{$this->page}_{$this->widget}";
     286        $created_at = date_create( 'now', wp_timezone() );
     287
     288        if ( $created_at && ! $bypass_cache ) {
     289            update_post_meta( $post->ID, $meta_key, $response );
     290            update_post_meta( $post->ID, $meta_key . '_created_at', $created_at->getTimestamp() );
     291        }
     292
    243293        return $response;
    244294    }
  • sophi/trunk/includes/functions/content-sync.php

    r2712442 r2719676  
    132132    }
    133133
     134    /**
     135     * Filters the data used in Sophi track event request.
     136     *
     137     * @since 1.0.14
     138     * @hook sophi_tracking_data
     139     *
     140     * @param {array}   $data    Tracking data to send.
     141     * @param {Tracker} $tracker Tracker being used.
     142     * @param {string}  $url     Post object.
     143     * @param {string}  $action  Publishing action.
     144     *
     145     * @return {array} Tracking data to send.
     146     */
     147    $data = apply_filters_ref_array( 'sophi_cms_tracking_request_data', array( $data, &$tracker, $post, $action ) );
    134148    $tracker->trackUnstructEvent(
    135149        [
     
    147161        ]
    148162    );
     163
     164    /**
     165     * Fires after tracker sends the request.
     166     *
     167     * @since 1.0.14
     168     * @hook sophi_tracking_result
     169     *
     170     * @param {array}   $data    Tracked data.
     171     * @param {Tracker} $tracker Tracker object.
     172     * @param {WP_Post} $post    Post object.
     173     * @param {string}  $action  Publishing action.
     174     */
     175    do_action_ref_array( 'sophi_cms_tracking_result', array( $data, &$tracker, $post, $action ) );
    149176}
    150177
     
    172199    }
    173200
     201    /**
     202     * Whether to turn on emitter debug
     203     *
     204     * @since 1.0.14
     205     * @hook sophi_tracker_emitter_debug
     206     *
     207     * @param {bool} $debug Debug is active.
     208     *
     209     * @return {bool} Whether to turn on emitter debug.
     210     */
     211    $debug = apply_filters( 'sophi_tracker_emitter_debug', false );
     212
    174213    $app_id  = sprintf( '%s:cms', $tracker_client_id );
    175     $emitter = new SyncEmitter( $collector_url, 'https', 'POST', 1, false );
     214    $emitter = new SyncEmitter( $collector_url, 'https', 'POST', 1, $debug );
    176215    $subject = new Subject();
    177216    return new Tracker( $emitter, $subject, 'sophiTag', $app_id, false );
  • sophi/trunk/includes/functions/utils.php

    r2698689 r2719676  
    8585        $terms    = get_the_terms( $post, $taxonomy );
    8686
    87         if ( count( $terms ) > 0 ) {
     87        if ( is_array( $terms ) && count( $terms ) > 0 ) {
    8888            return get_term_breadcrumb( $terms[0] );
    8989        }
     
    114114            $terms    = get_the_terms( $post, $taxonomy );
    115115
    116             if ( count( $terms ) > 0 ) {
     116            if ( is_array( $terms ) && count( $terms ) > 0 ) {
    117117                return $terms[0]->slug;
    118118            }
  • sophi/trunk/readme.txt

    r2712442 r2719676  
    22Contributors:      10up, sophidev
    33Tags:              Sophi, Site Automation, Curator, Collector, AI, Artifical Intelligence, ML, Machine Learning, Content Curation
    4 Tested up to:      5.8
    5 Stable tag:        1.0.13
     4Tested up to:      5.9
     5Stable tag:        1.1.0
    66License:           GPLv2 or later
    77License URI:       http://www.gnu.org/licenses/gpl-2.0.html
     
    5151== Usage ==
    5252
    53 There are two ways that Sophi Site Automation results can be included in a WordPress site, via a Site Automation block and a direct integration with WP_Query.  More details on each of these options are described below.
     53There are two potential ways to integrate Sophi Site Automation results with your WordPress site. The default approach includes a Sophi Site Automation block that integrates with `WP_Query` by injecting Posts IDs via the `posts_pre_query` filter that gets fetched later to return the actual Posts. In the same fashion, you can integrate Sophi results with your `WP_Query` object by setting the `sophi_curated_page` and `sophi_curated_widget` query parameters.
     54
     55More details on each of these two options are described below.  If you are not certain on the best integration approach, considering the following:
     56
     57Reasons to use the Site Automation block:
     58- No additional development effort needed for initial Sophi integration
     59- Immediate integration with Sophi Site Automation API and page/widget settings
     60- Basic block display settings allow for basic configurations (show/hide post excerpt, author name, post date, featured image)
     61
     62Reasons to use the Query integration:
     63- Can implement more custom caching and content fallback options
     64- Can implement support into non-block editor setups
     65- Likely more flexible for headless setups
     66- Block editor is not in-use within your WordPress environment
     67- You need an integration with Category/Taxonomy Pages and cannot integrate using a sidebar widget
    5468
    5569= Site Automation block =
     
    94108`
    95109
     110== Caveats ==
     111
     112While the above query integration works just fine, it has been observed on [WordPress VIP](https://wpvip.com/) infrastructure that `WP_Query` may return latest posts instead of the posts curated by Sophi due to the [Advanced Post Cache](https://github.com/Automattic/advanced-post-cache) plugin used by the VIP platform. A workaround for this is to use [`get_posts()`](https://developer.wordpress.org/reference/functions/get_posts/) instead and as good practice to add a comment explaining the usage of it so that developers new to it don't swap it for `WP_Query`. Also remember to whitelist `get_posts` by adding the following inline comment so that PHPCS doesn't throw a warning:
     113
     114`phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.get_posts_get_posts`
     115
    96116= Post content type =
    97117
     
    121141WordPress SEO (Yoast) canonical is supported out of the box. For other SEO plugins and custom implementations, [`get_canonical_url`](https://developer.wordpress.org/reference/functions/wp_get_canonical_url/) filter can be used to change the canonical URL.
    122142
     143= Object caching =
     144
     145Object caching is encouraged, as the plugin saves Sophi data as a transient.  If you do not have object caching, then the data will be saved as a transient in the options table but note that these will eventually expire.
     146
    123147== Documentation ==
    124148
    125 Sophi for WordPress has an in-depth documentation site that details the available actions and filters found within the plugin. [Visit the hook docs ☞](https://globeandmail.github.io/sophi-for-wordpress/)
    126 
    127 == Developers ==
    128 
    129 If you're looking to contribute to or extend the Sophi for WordPress plugin, then the following sub-sections are things to be aware of in terms of how the plugin is architected.
    130 
    131 = Dependencies =
    132 
    133 1. [Node >= 8.11 & NPM](https://www.npmjs.com/get-npm) - Build packages and 3rd party dependencies are managed through NPM, so you will need that installed globally.
    134 2. [Webpack](https://webpack.js.org/) - Webpack is used to process the JavaScript, CSS, and other assets.
    135 3. [Composer](https://getcomposer.org/) - Composer is used to manage PHP.
    136 
    137 = NPM Commands =
    138 
    139 - `npm run test` (runs phpunit)
    140 - `npm run start` (install dependencies)
    141 - `npm run watch` (watch)
    142 - `npm run build` (build all files)
    143 - `npm run build-release` (build all files for release)
    144 - `npm run dev` (build all files for development)
    145 - `npm run lint-release` (install dependencies and run linting)
    146 - `npm run lint-css` (lint CSS)
    147 - `npm run lint-js` (lint JS)
    148 - `npm run lint-php` (lint PHP)
    149 - `npm run lint` (run all lints)
    150 - `npm run format-js` (format JS using eslint)
    151 - `npm run format` (alias for `npm run format-js`)
    152 - `npm run test-a11y` (run accessibility tests)
    153 
    154 = Composer Commands =
    155 
    156 - `composer lint` (lint PHP files)
    157 - `composer lint-fix` (lint PHP files and automatically correct coding standard violations)
    158 
    159 = WP-CLI Commands =
    160 
    161 **Sync content to Sophi Collector**
    162 
    163 `$ wp sophi sync [--post_types=<string>] [--limit=<number>] [--per_page=<number>] [--include=<number>]`
    164 
    165 Sync all supported content to Sophi Collector, firing off update events for all of them.  The expected use case with the Sophi for WordPress plugin is that someone will install it on an existing site and instead of having to manually update each piece of content to ensure that it makes it to the Collector, they can run this script to handle that all at once.
    166 
    167 *Options*
    168 
    169 **`--post_types=<string>`**
    170 
    171 Post types to be processed. Comma separated for passing multiple post types.
    172 
    173 default: `false`
    174 options:
    175 - any post type name
    176 - `false`
    177 
    178 **`--limit=<number>`**
    179 
    180 Limit the amount of posts to be synced.
    181 
    182 default: `false`
    183 options:
    184 - `false`, no limit
    185 - `N`, max number of posts to sync
    186 
    187 **`--per_page=<number>`**
    188 
    189 Number of posts to process each batch.
    190 
    191 default: `false`
    192 options:
    193 - `false`, no limit
    194 - `N`, max number of posts to sync each batch
    195 
    196 **`--include=<number>`**
    197 
    198 Post IDs to process. Comma separated for passing multiple item.
    199 
    200 default: `false`
    201 options:
    202 - `false`, no limit
    203 - `N`, Post IDs to sync
     149Sophi for WordPress has an in-depth documentation site that details the available actions and filters found within the plugin. [Visit the developer docs ☞](https://globeandmail.github.io/sophi-for-wordpress/)
    204150
    205151== Frequently Asked Questions ==
     
    228174
    229175== Changelog ==
     176
     177= 1.1.0 - 2022-05-06 =
     178* **Added:** Filter `sophi_request_args` filters arguments used in Sophi HTTP request (props [@cadic](https://github.com/cadic), [@iamdharmesh](https://github.com/iamdharmesh) via [#257](https://github.com/globeandmail/sophi-for-wordpress/pull/257)).
     179* **Added:** Filter `sophi_request_result` filters a Sophi HTTP request immediately after the response is received (props [@cadic](https://github.com/cadic), [@iamdharmesh](https://github.com/iamdharmesh) via [#257](https://github.com/globeandmail/sophi-for-wordpress/pull/257), [#261](https://github.com/globeandmail/sophi-for-wordpress/pull/261)).
     180* **Added:** Filter `sophi_cms_tracking_request_data` filters the data used in Sophi track event request (props [@cadic](https://github.com/cadic), [@iamdharmesh](https://github.com/iamdharmesh), [@jeffpaul](https://github.com/jeffpaul) via [#257](https://github.com/globeandmail/sophi-for-wordpress/pull/257), [#263](https://github.com/globeandmail/sophi-for-wordpress/pull/263)).
     181* **Added:** Action `sophi_cms_tracking_result` fires after tracker sends the request (props [@cadic](https://github.com/cadic), [@iamdharmesh](https://github.com/iamdharmesh), [@jeffpaul](https://github.com/jeffpaul) via [#257](https://github.com/globeandmail/sophi-for-wordpress/pull/257), [#263](https://github.com/globeandmail/sophi-for-wordpress/pull/263)).
     182* **Added:** Filter `sophi_tracker_emitter_debug` allows to enable debug mode in the tracking emitter (props [@cadic](https://github.com/cadic), [@iamdharmesh](https://github.com/iamdharmesh) via [#257](https://github.com/globeandmail/sophi-for-wordpress/pull/257)).
     183* **Added:** Documentation on rational for block vs. custom query integration uses and `WP_Query` caveat on WordPress VIP (props [@Sidsector9](https://github.com/Sidsector9), [@jeffpaul](https://github.com/jeffpaul), [@oscarssanchez](https://github.com/oscarssanchez) via [#242](https://github.com/globeandmail/sophi-for-wordpress/pull/242), [#249](https://github.com/globeandmail/sophi-for-wordpress/pull/249), [#251](https://github.com/globeandmail/sophi-for-wordpress/pull/251)).
     184* **Changed:** Update response saving from options table to post meta field (props [@Rahmon](https://github.com/Rahmon), [@oscarssanchez](https://github.com/oscarssanchez) via [#253](https://github.com/globeandmail/sophi-for-wordpress/pull/253)).
     185* **Changed:** Bump WordPress "tested up to" version 5.9 (props [@jeffpaul](https://github.com/jeffpaul) via [#248](https://github.com/globeandmail/sophi-for-wordpress/pull/248)).
     186* **Changed:** Updated hookdocs site (now [Developer Docs](https://globeandmail.github.io/sophi-for-wordpress/)) to properly run on release and migrate in docs from readme (props [@iamdharmesh](https://github.com/iamdharmesh), [@jeffpaul](https://github.com/jeffpaul) via [#256](https://github.com/globeandmail/sophi-for-wordpress/pull/256)).
     187* **Fixed:** Check if `$terms` is an array before using `count()` within `get_the_terms()` (props [@barryceelen](https://github.com/barryceelen), [@Sidsector9](https://github.com/Sidsector9) via [#215](https://github.com/globeandmail/sophi-for-wordpress/pull/215)).
     188* **Fixed:** Update `track_event` arguments list inside `sync` WP-CLI command (props [@cadic](https://github.com/cadic), [@Sidsector9](https://github.com/Sidsector9) via [#250](https://github.com/globeandmail/sophi-for-wordpress/pull/250)).
     189* **Security:** Update `actions/checkout` action to from v2.4.0 to v3.0.2 (props [@renovate](https://github.com/apps/renovate), [@iamdharmesh](https://github.com/iamdharmesh) via [#240](https://github.com/globeandmail/sophi-for-wordpress/pull/240), [#241](https://github.com/globeandmail/sophi-for-wordpress/pull/241), [#243](https://github.com/globeandmail/sophi-for-wordpress/pull/243)).
     190* **Security:** Update `actions/setup-node` action from v1 to v3 (props [@renovate](https://github.com/apps/renovate), [@iamdharmesh](https://github.com/iamdharmesh) via [#244](https://github.com/globeandmail/sophi-for-wordpress/pull/244)).
     191* **Security:** Update dependency `10up-toolkit` from 3.1.2 to 4.0.0 (props [@renovate](https://github.com/apps/renovate), [@cadic](https://github.com/cadic) via [#264](https://github.com/globeandmail/sophi-for-wordpress/pull/264)).
    230192
    231193= 1.0.13 - 2022-04-20 =
     
    252214* **Security:** Update dependency `snowplow/snowplow-tracker` from 0.4.0 to 0.5.0 (props [@renovate](https://github.com/apps/renovate)).
    253215
    254 = 1.0.9 - 2022-02-18 = 
     216= 1.0.9 - 2022-02-18 =
    255217* **Added:** `hostname` and `path` fields to schema (props [@Rahmon](https://github.com/Rahmon), [@dinhtungdu](https://github.com/dinhtungdu)).
    256218* **Fixed:** Return empty post list from Sophi response (props [@oscarssanchez](https://github.com/oscarssanchez), [@barryceelen](https://github.com/barryceelen), [@felipeelia](https://github.com/felipeelia)).
  • sophi/trunk/sophi.php

    r2712442 r2719676  
    44 * Plugin URI:        https://github.com/globeandmail/sophi-for-wordpress
    55 * Description:       WordPress VIP-compatible plugin for the Sophi.io Site Automation service.
    6  * Version:           1.0.13
     6 * Version:           1.1.0
    77 * Requires at least: 5.6
    88 * Requires PHP:      7.4
     
    1717
    1818// Useful global constants.
    19 define( 'SOPHI_WP_VERSION', '1.0.13' );
     19define( 'SOPHI_WP_VERSION', '1.1.0' );
    2020define( 'SOPHI_WP_URL', plugin_dir_url( __FILE__ ) );
    2121define( 'SOPHI_WP_PATH', plugin_dir_path( __FILE__ ) );
     
    123123
    124124}
     125
     126/**
     127 * Upgrader function for version 1.1.0
     128 * Deletes sophi_site_automation like options in favor of new post_meta approach.
     129 *
     130 * @param $installed string The version installed.
     131 */
     132function sophi_upgrade_1_1_0( $installed ) {
     133    global $wpdb;
     134    if ( $installed && version_compare( $installed, '1.1.0', '<' ) ) {
     135
     136        $options = $wpdb->get_results( $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE'%s' LIMIT 1000",  '%sophi_site_automation_data%' ) );
     137
     138        foreach ( $options as $option ) {
     139            delete_option( $option->option_name );
     140        }
     141    }
     142}
     143
     144add_action( 'sophi_upgrade', 'sophi_upgrade_1_1_0' );
     145
     146$installed = get_option( 'sophi_version' );
     147
     148if ( ! $installed || version_compare( $installed, SOPHI_WP_VERSION, '<' ) ) {
     149    /**
     150     * Upgrader hook to
     151     *
     152     * @param string $installed The previous version reference installed.
     153     */
     154    do_action( 'sophi_upgrade', $installed );
     155
     156    update_option( 'sophi_version', SOPHI_WP_VERSION, false );
     157}
  • sophi/trunk/vendor/autoload.php

    r2712442 r2719676  
    1010require_once __DIR__ . '/composer/autoload_real.php';
    1111
    12 return ComposerAutoloaderInitcc764d3c724e24bbeeacdab81c50a2f0::getLoader();
     12return ComposerAutoloaderInitbdfd77ff5462663cbbe04b8ffeb39221::getLoader();
  • sophi/trunk/vendor/composer/autoload_real.php

    r2712442 r2719676  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInitcc764d3c724e24bbeeacdab81c50a2f0
     5class ComposerAutoloaderInitbdfd77ff5462663cbbe04b8ffeb39221
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInitcc764d3c724e24bbeeacdab81c50a2f0', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInitbdfd77ff5462663cbbe04b8ffeb39221', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    29         spl_autoload_unregister(array('ComposerAutoloaderInitcc764d3c724e24bbeeacdab81c50a2f0', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInitbdfd77ff5462663cbbe04b8ffeb39221', 'loadClassLoader'));
    3030
    3131        require __DIR__ . '/autoload_static.php';
    32         call_user_func(\Composer\Autoload\ComposerStaticInitcc764d3c724e24bbeeacdab81c50a2f0::getInitializer($loader));
     32        call_user_func(\Composer\Autoload\ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221::getInitializer($loader));
    3333
    3434        $loader->register(true);
    3535
    36         $includeFiles = \Composer\Autoload\ComposerStaticInitcc764d3c724e24bbeeacdab81c50a2f0::$files;
     36        $includeFiles = \Composer\Autoload\ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221::$files;
    3737        foreach ($includeFiles as $fileIdentifier => $file) {
    38             composerRequirecc764d3c724e24bbeeacdab81c50a2f0($fileIdentifier, $file);
     38            composerRequirebdfd77ff5462663cbbe04b8ffeb39221($fileIdentifier, $file);
    3939        }
    4040
     
    4848 * @return void
    4949 */
    50 function composerRequirecc764d3c724e24bbeeacdab81c50a2f0($fileIdentifier, $file)
     50function composerRequirebdfd77ff5462663cbbe04b8ffeb39221($fileIdentifier, $file)
    5151{
    5252    if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • sophi/trunk/vendor/composer/autoload_static.php

    r2712442 r2719676  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInitcc764d3c724e24bbeeacdab81c50a2f0
     7class ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221
    88{
    99    public static $files = array (
     
    8181    {
    8282        return \Closure::bind(function () use ($loader) {
    83             $loader->prefixLengthsPsr4 = ComposerStaticInitcc764d3c724e24bbeeacdab81c50a2f0::$prefixLengthsPsr4;
    84             $loader->prefixDirsPsr4 = ComposerStaticInitcc764d3c724e24bbeeacdab81c50a2f0::$prefixDirsPsr4;
    85             $loader->classMap = ComposerStaticInitcc764d3c724e24bbeeacdab81c50a2f0::$classMap;
     83            $loader->prefixLengthsPsr4 = ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221::$prefixLengthsPsr4;
     84            $loader->prefixDirsPsr4 = ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221::$prefixDirsPsr4;
     85            $loader->classMap = ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221::$classMap;
    8686
    8787        }, null, ClassLoader::class);
  • sophi/trunk/vendor/composer/installed.php

    r2712442 r2719676  
    11<?php return array(
    22    'root' => array(
    3         'pretty_version' => '1.0.13',
    4         'version' => '1.0.13.0',
     3        'pretty_version' => '1.1.0',
     4        'version' => '1.1.0.0',
    55        'type' => 'wordpress-plugin',
    66        'install_path' => __DIR__ . '/../../',
    77        'aliases' => array(),
    8         'reference' => 'b8b608c50580b36a0a8f9a61e2e252dcca683835',
     8        'reference' => 'd84a89aaba7208a28828807ba338aa7dfbf8246e',
    99        'name' => 'globeandmail/sophi-for-wordpress',
    1010        'dev' => false,
     
    2121        ),
    2222        'globeandmail/sophi-for-wordpress' => array(
    23             'pretty_version' => '1.0.13',
    24             'version' => '1.0.13.0',
     23            'pretty_version' => '1.1.0',
     24            'version' => '1.1.0.0',
    2525            'type' => 'wordpress-plugin',
    2626            'install_path' => __DIR__ . '/../../',
    2727            'aliases' => array(),
    28             'reference' => 'b8b608c50580b36a0a8f9a61e2e252dcca683835',
     28            'reference' => 'd84a89aaba7208a28828807ba338aa7dfbf8246e',
    2929            'dev_requirement' => false,
    3030        ),
Note: See TracChangeset for help on using the changeset viewer.