Changeset 2719676
- Timestamp:
- 05/06/2022 10:18:47 PM (4 years ago)
- Location:
- sophi
- Files:
-
- 32 edited
- 1 copied
-
tags/1.1.0 (copied) (copied from sophi/trunk)
-
tags/1.1.0/dist/blocks/site-automation-block/editor.asset.php (modified) (1 diff)
-
tags/1.1.0/dist/css/admin-style.asset.php (modified) (1 diff)
-
tags/1.1.0/dist/css/admin-style.css (modified) (1 diff)
-
tags/1.1.0/dist/js/sophi-tag.asset.php (modified) (1 diff)
-
tags/1.1.0/includes/classes/Command.php (modified) (1 diff)
-
tags/1.1.0/includes/classes/SiteAutomation/Auth.php (modified) (2 diffs)
-
tags/1.1.0/includes/classes/SiteAutomation/Integration.php (modified) (1 diff)
-
tags/1.1.0/includes/classes/SiteAutomation/Request.php (modified) (7 diffs)
-
tags/1.1.0/includes/functions/content-sync.php (modified) (3 diffs)
-
tags/1.1.0/includes/functions/utils.php (modified) (2 diffs)
-
tags/1.1.0/readme.txt (modified) (6 diffs)
-
tags/1.1.0/sophi.php (modified) (3 diffs)
-
tags/1.1.0/vendor/autoload.php (modified) (1 diff)
-
tags/1.1.0/vendor/composer/autoload_real.php (modified) (3 diffs)
-
tags/1.1.0/vendor/composer/autoload_static.php (modified) (2 diffs)
-
tags/1.1.0/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/dist/blocks/site-automation-block/editor.asset.php (modified) (1 diff)
-
trunk/dist/css/admin-style.asset.php (modified) (1 diff)
-
trunk/dist/css/admin-style.css (modified) (1 diff)
-
trunk/dist/js/sophi-tag.asset.php (modified) (1 diff)
-
trunk/includes/classes/Command.php (modified) (1 diff)
-
trunk/includes/classes/SiteAutomation/Auth.php (modified) (2 diffs)
-
trunk/includes/classes/SiteAutomation/Integration.php (modified) (1 diff)
-
trunk/includes/classes/SiteAutomation/Request.php (modified) (7 diffs)
-
trunk/includes/functions/content-sync.php (modified) (3 diffs)
-
trunk/includes/functions/utils.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (6 diffs)
-
trunk/sophi.php (modified) (3 diffs)
-
trunk/vendor/autoload.php (modified) (1 diff)
-
trunk/vendor/composer/autoload_real.php (modified) (3 diffs)
-
trunk/vendor/composer/autoload_static.php (modified) (2 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
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 221 221 if ( $count < $limit ) { 222 222 if ( ! $dry_run ) { 223 $response = track_event( 'publish', 'publish', $post);223 $response = track_event( $post->ID, $post, true, null ); 224 224 if ( is_wp_error( $response ) ) { 225 225 $error_count++; -
sophi/tags/1.1.0/includes/classes/SiteAutomation/Auth.php
r2648442 r2719676 65 65 */ 66 66 public function request_access_token( $client_id, $client_secret ) { 67 $body = [67 $body = [ 68 68 'client_id' => $client_id, 69 69 'client_secret' => $client_secret, … … 71 71 'grant_type' => 'client_credentials', 72 72 ]; 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 ); 80 87 81 88 if ( is_wp_error( $request ) ) { -
sophi/tags/1.1.0/includes/classes/SiteAutomation/Integration.php
r2681627 r2719676 104 104 * 105 105 * @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. 108 108 * @param {array} $request_status The request status, whether it was successful or not. 109 109 * @param {WP_Query} $query Original query. -
sophi/tags/1.1.0/includes/classes/SiteAutomation/Request.php
r2686283 r2719676 51 51 52 52 /** 53 * Post ID for Site Automation request. 54 * 55 * @var string $post_id 56 */ 57 protected $post_id; 58 59 /** 53 60 * Class constructor. 54 61 * … … 79 86 $this->widget = $widget; 80 87 $this->api_url = $this->set_api_url( $page, $widget ); 88 $this->post_id = get_the_ID(); 81 89 82 90 $this->status = $this->get_status(); … … 98 106 99 107 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 ); 101 109 } 102 110 … … 183 191 184 192 $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 } 186 197 } 187 198 … … 207 218 ]; 208 219 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 209 233 if ( function_exists( 'vip_safe_wp_remote_get' ) ) { 210 234 $request = vip_safe_wp_remote_get( $this->api_url, '', 3, $timeout, 20, $args ); … … 214 238 } 215 239 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 216 254 if ( is_wp_error( $request ) ) { 217 255 return $request; … … 238 276 } 239 277 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 243 293 return $response; 244 294 } -
sophi/tags/1.1.0/includes/functions/content-sync.php
r2712442 r2719676 132 132 } 133 133 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 ) ); 134 148 $tracker->trackUnstructEvent( 135 149 [ … … 147 161 ] 148 162 ); 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 ) ); 149 176 } 150 177 … … 172 199 } 173 200 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 174 213 $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 ); 176 215 $subject = new Subject(); 177 216 return new Tracker( $emitter, $subject, 'sophiTag', $app_id, false ); -
sophi/tags/1.1.0/includes/functions/utils.php
r2698689 r2719676 85 85 $terms = get_the_terms( $post, $taxonomy ); 86 86 87 if ( count( $terms ) > 0 ) {87 if ( is_array( $terms ) && count( $terms ) > 0 ) { 88 88 return get_term_breadcrumb( $terms[0] ); 89 89 } … … 114 114 $terms = get_the_terms( $post, $taxonomy ); 115 115 116 if ( count( $terms ) > 0 ) {116 if ( is_array( $terms ) && count( $terms ) > 0 ) { 117 117 return $terms[0]->slug; 118 118 } -
sophi/tags/1.1.0/readme.txt
r2712442 r2719676 2 2 Contributors: 10up, sophidev 3 3 Tags: Sophi, Site Automation, Curator, Collector, AI, Artifical Intelligence, ML, Machine Learning, Content Curation 4 Tested up to: 5. 85 Stable tag: 1. 0.134 Tested up to: 5.9 5 Stable tag: 1.1.0 6 6 License: GPLv2 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 51 51 == Usage == 52 52 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. 53 There 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 55 More details on each of these two options are described below. If you are not certain on the best integration approach, considering the following: 56 57 Reasons 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 62 Reasons 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 54 68 55 69 = Site Automation block = … … 94 108 ` 95 109 110 == Caveats == 111 112 While 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 96 116 = Post content type = 97 117 … … 121 141 WordPress 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. 122 142 143 = Object caching = 144 145 Object 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 123 147 == Documentation == 124 148 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 149 Sophi 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/) 204 150 205 151 == Frequently Asked Questions == … … 228 174 229 175 == 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)). 230 192 231 193 = 1.0.13 - 2022-04-20 = … … 252 214 * **Security:** Update dependency `snowplow/snowplow-tracker` from 0.4.0 to 0.5.0 (props [@renovate](https://github.com/apps/renovate)). 253 215 254 = 1.0.9 - 2022-02-18 = 216 = 1.0.9 - 2022-02-18 = 255 217 * **Added:** `hostname` and `path` fields to schema (props [@Rahmon](https://github.com/Rahmon), [@dinhtungdu](https://github.com/dinhtungdu)). 256 218 * **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 4 4 * Plugin URI: https://github.com/globeandmail/sophi-for-wordpress 5 5 * Description: WordPress VIP-compatible plugin for the Sophi.io Site Automation service. 6 * Version: 1. 0.136 * Version: 1.1.0 7 7 * Requires at least: 5.6 8 8 * Requires PHP: 7.4 … … 17 17 18 18 // Useful global constants. 19 define( 'SOPHI_WP_VERSION', '1. 0.13' );19 define( 'SOPHI_WP_VERSION', '1.1.0' ); 20 20 define( 'SOPHI_WP_URL', plugin_dir_url( __FILE__ ) ); 21 21 define( 'SOPHI_WP_PATH', plugin_dir_path( __FILE__ ) ); … … 123 123 124 124 } 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 */ 132 function 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 144 add_action( 'sophi_upgrade', 'sophi_upgrade_1_1_0' ); 145 146 $installed = get_option( 'sophi_version' ); 147 148 if ( ! $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 10 10 require_once __DIR__ . '/composer/autoload_real.php'; 11 11 12 return ComposerAutoloaderInit cc764d3c724e24bbeeacdab81c50a2f0::getLoader();12 return ComposerAutoloaderInitbdfd77ff5462663cbbe04b8ffeb39221::getLoader(); -
sophi/tags/1.1.0/vendor/composer/autoload_real.php
r2712442 r2719676 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit cc764d3c724e24bbeeacdab81c50a2f05 class ComposerAutoloaderInitbdfd77ff5462663cbbe04b8ffeb39221 6 6 { 7 7 private static $loader; … … 25 25 require __DIR__ . '/platform_check.php'; 26 26 27 spl_autoload_register(array('ComposerAutoloaderInit cc764d3c724e24bbeeacdab81c50a2f0', 'loadClassLoader'), true, true);27 spl_autoload_register(array('ComposerAutoloaderInitbdfd77ff5462663cbbe04b8ffeb39221', 'loadClassLoader'), true, true); 28 28 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 29 spl_autoload_unregister(array('ComposerAutoloaderInit cc764d3c724e24bbeeacdab81c50a2f0', 'loadClassLoader'));29 spl_autoload_unregister(array('ComposerAutoloaderInitbdfd77ff5462663cbbe04b8ffeb39221', 'loadClassLoader')); 30 30 31 31 require __DIR__ . '/autoload_static.php'; 32 call_user_func(\Composer\Autoload\ComposerStaticInit cc764d3c724e24bbeeacdab81c50a2f0::getInitializer($loader));32 call_user_func(\Composer\Autoload\ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221::getInitializer($loader)); 33 33 34 34 $loader->register(true); 35 35 36 $includeFiles = \Composer\Autoload\ComposerStaticInit cc764d3c724e24bbeeacdab81c50a2f0::$files;36 $includeFiles = \Composer\Autoload\ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221::$files; 37 37 foreach ($includeFiles as $fileIdentifier => $file) { 38 composerRequire cc764d3c724e24bbeeacdab81c50a2f0($fileIdentifier, $file);38 composerRequirebdfd77ff5462663cbbe04b8ffeb39221($fileIdentifier, $file); 39 39 } 40 40 … … 48 48 * @return void 49 49 */ 50 function composerRequire cc764d3c724e24bbeeacdab81c50a2f0($fileIdentifier, $file)50 function composerRequirebdfd77ff5462663cbbe04b8ffeb39221($fileIdentifier, $file) 51 51 { 52 52 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { -
sophi/tags/1.1.0/vendor/composer/autoload_static.php
r2712442 r2719676 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit cc764d3c724e24bbeeacdab81c50a2f07 class ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221 8 8 { 9 9 public static $files = array ( … … 81 81 { 82 82 return \Closure::bind(function () use ($loader) { 83 $loader->prefixLengthsPsr4 = ComposerStaticInit cc764d3c724e24bbeeacdab81c50a2f0::$prefixLengthsPsr4;84 $loader->prefixDirsPsr4 = ComposerStaticInit cc764d3c724e24bbeeacdab81c50a2f0::$prefixDirsPsr4;85 $loader->classMap = ComposerStaticInit cc764d3c724e24bbeeacdab81c50a2f0::$classMap;83 $loader->prefixLengthsPsr4 = ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221::$prefixLengthsPsr4; 84 $loader->prefixDirsPsr4 = ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221::$prefixDirsPsr4; 85 $loader->classMap = ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221::$classMap; 86 86 87 87 }, null, ClassLoader::class); -
sophi/tags/1.1.0/vendor/composer/installed.php
r2712442 r2719676 1 1 <?php return array( 2 2 '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', 5 5 'type' => 'wordpress-plugin', 6 6 'install_path' => __DIR__ . '/../../', 7 7 'aliases' => array(), 8 'reference' => ' b8b608c50580b36a0a8f9a61e2e252dcca683835',8 'reference' => 'd84a89aaba7208a28828807ba338aa7dfbf8246e', 9 9 'name' => 'globeandmail/sophi-for-wordpress', 10 10 'dev' => false, … … 21 21 ), 22 22 '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', 25 25 'type' => 'wordpress-plugin', 26 26 'install_path' => __DIR__ . '/../../', 27 27 'aliases' => array(), 28 'reference' => ' b8b608c50580b36a0a8f9a61e2e252dcca683835',28 'reference' => 'd84a89aaba7208a28828807ba338aa7dfbf8246e', 29 29 'dev_requirement' => false, 30 30 ), -
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 221 221 if ( $count < $limit ) { 222 222 if ( ! $dry_run ) { 223 $response = track_event( 'publish', 'publish', $post);223 $response = track_event( $post->ID, $post, true, null ); 224 224 if ( is_wp_error( $response ) ) { 225 225 $error_count++; -
sophi/trunk/includes/classes/SiteAutomation/Auth.php
r2648442 r2719676 65 65 */ 66 66 public function request_access_token( $client_id, $client_secret ) { 67 $body = [67 $body = [ 68 68 'client_id' => $client_id, 69 69 'client_secret' => $client_secret, … … 71 71 'grant_type' => 'client_credentials', 72 72 ]; 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 ); 80 87 81 88 if ( is_wp_error( $request ) ) { -
sophi/trunk/includes/classes/SiteAutomation/Integration.php
r2681627 r2719676 104 104 * 105 105 * @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. 108 108 * @param {array} $request_status The request status, whether it was successful or not. 109 109 * @param {WP_Query} $query Original query. -
sophi/trunk/includes/classes/SiteAutomation/Request.php
r2686283 r2719676 51 51 52 52 /** 53 * Post ID for Site Automation request. 54 * 55 * @var string $post_id 56 */ 57 protected $post_id; 58 59 /** 53 60 * Class constructor. 54 61 * … … 79 86 $this->widget = $widget; 80 87 $this->api_url = $this->set_api_url( $page, $widget ); 88 $this->post_id = get_the_ID(); 81 89 82 90 $this->status = $this->get_status(); … … 98 106 99 107 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 ); 101 109 } 102 110 … … 183 191 184 192 $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 } 186 197 } 187 198 … … 207 218 ]; 208 219 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 209 233 if ( function_exists( 'vip_safe_wp_remote_get' ) ) { 210 234 $request = vip_safe_wp_remote_get( $this->api_url, '', 3, $timeout, 20, $args ); … … 214 238 } 215 239 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 216 254 if ( is_wp_error( $request ) ) { 217 255 return $request; … … 238 276 } 239 277 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 243 293 return $response; 244 294 } -
sophi/trunk/includes/functions/content-sync.php
r2712442 r2719676 132 132 } 133 133 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 ) ); 134 148 $tracker->trackUnstructEvent( 135 149 [ … … 147 161 ] 148 162 ); 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 ) ); 149 176 } 150 177 … … 172 199 } 173 200 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 174 213 $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 ); 176 215 $subject = new Subject(); 177 216 return new Tracker( $emitter, $subject, 'sophiTag', $app_id, false ); -
sophi/trunk/includes/functions/utils.php
r2698689 r2719676 85 85 $terms = get_the_terms( $post, $taxonomy ); 86 86 87 if ( count( $terms ) > 0 ) {87 if ( is_array( $terms ) && count( $terms ) > 0 ) { 88 88 return get_term_breadcrumb( $terms[0] ); 89 89 } … … 114 114 $terms = get_the_terms( $post, $taxonomy ); 115 115 116 if ( count( $terms ) > 0 ) {116 if ( is_array( $terms ) && count( $terms ) > 0 ) { 117 117 return $terms[0]->slug; 118 118 } -
sophi/trunk/readme.txt
r2712442 r2719676 2 2 Contributors: 10up, sophidev 3 3 Tags: Sophi, Site Automation, Curator, Collector, AI, Artifical Intelligence, ML, Machine Learning, Content Curation 4 Tested up to: 5. 85 Stable tag: 1. 0.134 Tested up to: 5.9 5 Stable tag: 1.1.0 6 6 License: GPLv2 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 51 51 == Usage == 52 52 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. 53 There 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 55 More details on each of these two options are described below. If you are not certain on the best integration approach, considering the following: 56 57 Reasons 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 62 Reasons 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 54 68 55 69 = Site Automation block = … … 94 108 ` 95 109 110 == Caveats == 111 112 While 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 96 116 = Post content type = 97 117 … … 121 141 WordPress 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. 122 142 143 = Object caching = 144 145 Object 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 123 147 == Documentation == 124 148 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 149 Sophi 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/) 204 150 205 151 == Frequently Asked Questions == … … 228 174 229 175 == 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)). 230 192 231 193 = 1.0.13 - 2022-04-20 = … … 252 214 * **Security:** Update dependency `snowplow/snowplow-tracker` from 0.4.0 to 0.5.0 (props [@renovate](https://github.com/apps/renovate)). 253 215 254 = 1.0.9 - 2022-02-18 = 216 = 1.0.9 - 2022-02-18 = 255 217 * **Added:** `hostname` and `path` fields to schema (props [@Rahmon](https://github.com/Rahmon), [@dinhtungdu](https://github.com/dinhtungdu)). 256 218 * **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 4 4 * Plugin URI: https://github.com/globeandmail/sophi-for-wordpress 5 5 * Description: WordPress VIP-compatible plugin for the Sophi.io Site Automation service. 6 * Version: 1. 0.136 * Version: 1.1.0 7 7 * Requires at least: 5.6 8 8 * Requires PHP: 7.4 … … 17 17 18 18 // Useful global constants. 19 define( 'SOPHI_WP_VERSION', '1. 0.13' );19 define( 'SOPHI_WP_VERSION', '1.1.0' ); 20 20 define( 'SOPHI_WP_URL', plugin_dir_url( __FILE__ ) ); 21 21 define( 'SOPHI_WP_PATH', plugin_dir_path( __FILE__ ) ); … … 123 123 124 124 } 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 */ 132 function 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 144 add_action( 'sophi_upgrade', 'sophi_upgrade_1_1_0' ); 145 146 $installed = get_option( 'sophi_version' ); 147 148 if ( ! $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 10 10 require_once __DIR__ . '/composer/autoload_real.php'; 11 11 12 return ComposerAutoloaderInit cc764d3c724e24bbeeacdab81c50a2f0::getLoader();12 return ComposerAutoloaderInitbdfd77ff5462663cbbe04b8ffeb39221::getLoader(); -
sophi/trunk/vendor/composer/autoload_real.php
r2712442 r2719676 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit cc764d3c724e24bbeeacdab81c50a2f05 class ComposerAutoloaderInitbdfd77ff5462663cbbe04b8ffeb39221 6 6 { 7 7 private static $loader; … … 25 25 require __DIR__ . '/platform_check.php'; 26 26 27 spl_autoload_register(array('ComposerAutoloaderInit cc764d3c724e24bbeeacdab81c50a2f0', 'loadClassLoader'), true, true);27 spl_autoload_register(array('ComposerAutoloaderInitbdfd77ff5462663cbbe04b8ffeb39221', 'loadClassLoader'), true, true); 28 28 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 29 spl_autoload_unregister(array('ComposerAutoloaderInit cc764d3c724e24bbeeacdab81c50a2f0', 'loadClassLoader'));29 spl_autoload_unregister(array('ComposerAutoloaderInitbdfd77ff5462663cbbe04b8ffeb39221', 'loadClassLoader')); 30 30 31 31 require __DIR__ . '/autoload_static.php'; 32 call_user_func(\Composer\Autoload\ComposerStaticInit cc764d3c724e24bbeeacdab81c50a2f0::getInitializer($loader));32 call_user_func(\Composer\Autoload\ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221::getInitializer($loader)); 33 33 34 34 $loader->register(true); 35 35 36 $includeFiles = \Composer\Autoload\ComposerStaticInit cc764d3c724e24bbeeacdab81c50a2f0::$files;36 $includeFiles = \Composer\Autoload\ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221::$files; 37 37 foreach ($includeFiles as $fileIdentifier => $file) { 38 composerRequire cc764d3c724e24bbeeacdab81c50a2f0($fileIdentifier, $file);38 composerRequirebdfd77ff5462663cbbe04b8ffeb39221($fileIdentifier, $file); 39 39 } 40 40 … … 48 48 * @return void 49 49 */ 50 function composerRequire cc764d3c724e24bbeeacdab81c50a2f0($fileIdentifier, $file)50 function composerRequirebdfd77ff5462663cbbe04b8ffeb39221($fileIdentifier, $file) 51 51 { 52 52 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { -
sophi/trunk/vendor/composer/autoload_static.php
r2712442 r2719676 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit cc764d3c724e24bbeeacdab81c50a2f07 class ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221 8 8 { 9 9 public static $files = array ( … … 81 81 { 82 82 return \Closure::bind(function () use ($loader) { 83 $loader->prefixLengthsPsr4 = ComposerStaticInit cc764d3c724e24bbeeacdab81c50a2f0::$prefixLengthsPsr4;84 $loader->prefixDirsPsr4 = ComposerStaticInit cc764d3c724e24bbeeacdab81c50a2f0::$prefixDirsPsr4;85 $loader->classMap = ComposerStaticInit cc764d3c724e24bbeeacdab81c50a2f0::$classMap;83 $loader->prefixLengthsPsr4 = ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221::$prefixLengthsPsr4; 84 $loader->prefixDirsPsr4 = ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221::$prefixDirsPsr4; 85 $loader->classMap = ComposerStaticInitbdfd77ff5462663cbbe04b8ffeb39221::$classMap; 86 86 87 87 }, null, ClassLoader::class); -
sophi/trunk/vendor/composer/installed.php
r2712442 r2719676 1 1 <?php return array( 2 2 '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', 5 5 'type' => 'wordpress-plugin', 6 6 'install_path' => __DIR__ . '/../../', 7 7 'aliases' => array(), 8 'reference' => ' b8b608c50580b36a0a8f9a61e2e252dcca683835',8 'reference' => 'd84a89aaba7208a28828807ba338aa7dfbf8246e', 9 9 'name' => 'globeandmail/sophi-for-wordpress', 10 10 'dev' => false, … … 21 21 ), 22 22 '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', 25 25 'type' => 'wordpress-plugin', 26 26 'install_path' => __DIR__ . '/../../', 27 27 'aliases' => array(), 28 'reference' => ' b8b608c50580b36a0a8f9a61e2e252dcca683835',28 'reference' => 'd84a89aaba7208a28828807ba338aa7dfbf8246e', 29 29 'dev_requirement' => false, 30 30 ),
Note: See TracChangeset
for help on using the changeset viewer.