Changeset 2725617
- Timestamp:
- 05/17/2022 07:49:55 PM (4 years ago)
- Location:
- sophi
- Files:
-
- 2 added
- 22 edited
- 1 copied
-
tags/1.1.1 (copied) (copied from sophi/trunk)
-
tags/1.1.1/includes/blocks/site-automation-block/register.php (modified) (1 diff)
-
tags/1.1.1/includes/classes/Emitter.php (added)
-
tags/1.1.1/includes/classes/SiteAutomation/Auth.php (modified) (1 diff)
-
tags/1.1.1/includes/classes/SiteAutomation/Request.php (modified) (3 diffs)
-
tags/1.1.1/includes/functions/content-sync.php (modified) (6 diffs)
-
tags/1.1.1/includes/functions/utils.php (modified) (1 diff)
-
tags/1.1.1/readme.txt (modified) (3 diffs)
-
tags/1.1.1/sophi.php (modified) (2 diffs)
-
tags/1.1.1/vendor/autoload.php (modified) (1 diff)
-
tags/1.1.1/vendor/composer/autoload_real.php (modified) (3 diffs)
-
tags/1.1.1/vendor/composer/autoload_static.php (modified) (2 diffs)
-
tags/1.1.1/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/includes/blocks/site-automation-block/register.php (modified) (1 diff)
-
trunk/includes/classes/Emitter.php (added)
-
trunk/includes/classes/SiteAutomation/Auth.php (modified) (1 diff)
-
trunk/includes/classes/SiteAutomation/Request.php (modified) (3 diffs)
-
trunk/includes/functions/content-sync.php (modified) (6 diffs)
-
trunk/includes/functions/utils.php (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/sophi.php (modified) (2 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.1/includes/blocks/site-automation-block/register.php
r2648442 r2725617 43 43 $curated_posts_transient_key = 'sophi_curated_posts_' . $page_name . '_' . $widget_name; 44 44 45 /** 46 * Whether to bypass caching. 47 * 48 * @since 1.1.1 49 * @hook sophi_bypass_curated_posts_cache 50 * 51 * @param {bool} $bypass_cache True or false. 52 * @param {string} $page Page name. 53 * @param {string} $widget Widget name. 54 * 55 * @return {bool} Whether to bypass cache. 56 */ 57 $bypass_cache = apply_filters( 'sophi_bypass_curated_posts_cache', false, $page_name, $widget_name ); 58 45 59 $curated_posts = get_transient( $curated_posts_transient_key ); 46 60 47 if ( false === $curated_posts ) {61 if ( $bypass_cache || false === $curated_posts ) { 48 62 // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.get_posts_get_posts 49 63 $curated_posts = get_posts( -
sophi/tags/1.1.1/includes/classes/SiteAutomation/Auth.php
r2719676 r2725617 81 81 $args = apply_filters( 'sophi_request_args', $args, $auth_url ); 82 82 83 $re quest = wp_remote_post( $auth_url, $args );83 $result = wp_remote_post( $auth_url, $args ); 84 84 85 85 /** This filter is documented in includes/classes/SiteAutomation/Request.php */ 86 $re quest = apply_filters( 'sophi_request_result', $request, $args, $auth_url );86 $result = apply_filters( 'sophi_request_result', $result, $args, $auth_url ); 87 87 88 if ( is_wp_error( $re quest ) ) {89 return $re quest;88 if ( is_wp_error( $result ) ) { 89 return $result; 90 90 } 91 91 92 if ( 401 === wp_remote_retrieve_response_code( $re quest ) ) {92 if ( 401 === wp_remote_retrieve_response_code( $result ) ) { 93 93 return new \WP_Error( 401, __( 'Invalid credentials! Please confirm your client ID and secret then try again.', 'sophi-wp' ) ); 94 94 } 95 95 96 if ( 200 !== wp_remote_retrieve_response_code( $re quest ) ) {97 return new \WP_Error( $re quest['response']['code'], $request['response']['message'] );96 if ( 200 !== wp_remote_retrieve_response_code( $result ) ) { 97 return new \WP_Error( $result['response']['code'], $result['response']['message'] ); 98 98 } 99 99 100 $response = wp_remote_retrieve_body( $request ); 101 $response = json_decode( $response, true ); 100 $response = wp_remote_retrieve_body( $result ); 102 101 103 return $response;102 return json_decode( $response, true ); 104 103 } 105 104 -
sophi/tags/1.1.1/includes/classes/SiteAutomation/Request.php
r2719676 r2725617 226 226 * @param {array} $args HTTP request arguments. 227 227 * @param {string} $url The request URL. 228 * 228 * 229 229 * @return {array} HTTP request arguments. 230 230 */ … … 232 232 233 233 if ( function_exists( 'vip_safe_wp_remote_get' ) ) { 234 $re quest = vip_safe_wp_remote_get( $this->api_url, '', 3, $timeout, 20, $args );234 $result = vip_safe_wp_remote_get( $this->api_url, '', 3, $timeout, 20, $args ); 235 235 } else { 236 236 $args['timeout'] = $timeout; 237 $re quest= wp_remote_get( $this->api_url, $args ); // phpcs:ignore237 $result = wp_remote_get( $this->api_url, $args ); // phpcs:ignore 238 238 } 239 239 … … 244 244 * @hook sophi_request_result 245 245 * 246 * @param {array|WP_Error} $re quest Result of HTTP request.246 * @param {array|WP_Error} $result Result of HTTP request. 247 247 * @param {array} $args HTTP request arguments. 248 248 * @param {string} $url The request URL. 249 * 249 * 250 250 * @return {array|WP_Error} Result of HTTP request. 251 251 */ 252 $re quest = apply_filters( 'sophi_request_result', $request, $args, $this->api_url );253 254 if ( is_wp_error( $re quest ) ) {255 return $re quest;256 } 257 258 if ( wp_remote_retrieve_response_code( $re quest ) !== 200 ) {259 return new \WP_Error( wp_remote_retrieve_response_code( $re quest ), $request['response']['message'] );260 } 261 262 return json_decode( wp_remote_retrieve_body( $re quest ), true );252 $result = apply_filters( 'sophi_request_result', $result, $args, $this->api_url ); 253 254 if ( is_wp_error( $result ) ) { 255 return $result; 256 } 257 258 if ( wp_remote_retrieve_response_code( $result ) !== 200 ) { 259 return new \WP_Error( wp_remote_retrieve_response_code( $result ), $result['response']['message'] ); 260 } 261 262 return json_decode( wp_remote_retrieve_body( $result ), true ); 263 263 } 264 264 -
sophi/tags/1.1.1/includes/functions/content-sync.php
r2719676 r2725617 16 16 use Snowplow\Tracker\Tracker; 17 17 use Snowplow\Tracker\Subject; 18 use S nowplow\Tracker\Emitters\SyncEmitter;18 use SophiWP\Emitter; 19 19 20 20 /** … … 136 136 * 137 137 * @since 1.0.14 138 * @hook sophi_ tracking_data138 * @hook sophi_cms_tracking_request_data 139 139 * 140 140 * @param {array} $data Tracking data to send. 141 141 * @param {Tracker} $tracker Tracker being used. 142 * @param {string} $ urlPost object.142 * @param {string} $post Post object. 143 143 * @param {string} $action Publishing action. 144 144 * … … 146 146 */ 147 147 $data = apply_filters_ref_array( 'sophi_cms_tracking_request_data', array( $data, &$tracker, $post, $action ) ); 148 149 /** This filter is documented in includes/functions/content-sync.php */ 150 $debug = apply_filters( 'sophi_tracker_emitter_debug', false ); 151 152 // Suppress stdout from Emitters in debug mode. 153 if ( true === $debug ) { 154 ob_start(); 155 } 156 148 157 $tracker->trackUnstructEvent( 149 158 [ … … 162 171 ); 163 172 173 if ( true === $debug ) { 174 ob_end_clean(); 175 } 176 164 177 /** 165 178 * Fires after tracker sends the request. 166 179 * 167 180 * @since 1.0.14 168 * @hook sophi_ tracking_result181 * @hook sophi_cms_tracking_result 169 182 * 170 183 * @param {array} $data Tracked data. … … 212 225 213 226 $app_id = sprintf( '%s:cms', $tracker_client_id ); 214 $emitter = new SyncEmitter( $collector_url, 'https', 'POST', 1, $debug );227 $emitter = new Emitter( $collector_url, 'https', 'POST', 1, $debug ); 215 228 $subject = new Subject(); 216 229 return new Tracker( $emitter, $subject, 'sophiTag', $app_id, false ); … … 257 270 'plainText' => wp_strip_all_tags( $content ), 258 271 'size' => str_word_count( wp_strip_all_tags( $content ) ), 272 'allSections' => Utils\get_post_categories_paths( $post->ID ), 259 273 'sectionNames' => Utils\get_post_categories( $post->ID ), 260 274 'modifiedAt' => gmdate( \DateTime::RFC3339, strtotime( $post->post_modified_gmt ) ), -
sophi/tags/1.1.1/includes/functions/utils.php
r2719676 r2725617 399 399 400 400 /** 401 * Return an array of category paths from a given post. 402 * 403 * @param int $post_id The post ID. 404 * @return array The array of category paths, or an empty array if no categories. 405 */ 406 function get_post_categories_paths( $post_id ) { 407 $categories = get_the_category( $post_id ); 408 $paths = []; 409 410 foreach ( $categories as $category ) { 411 if ( is_a( $category, 'WP_Term' ) && 'category' === $category->taxonomy ) { 412 $hierarchical_slugs = []; 413 $ancestors = get_ancestors( $category->term_id, $category->taxonomy, 'taxonomy' ); 414 foreach ( (array) $ancestors as $ancestor ) { 415 $ancestor_term = get_term( $ancestor, $category->taxonomy ); 416 $hierarchical_slugs[] = $ancestor_term->slug; 417 } 418 $hierarchical_slugs = array_reverse( $hierarchical_slugs ); 419 $hierarchical_slugs[] = $category->slug; 420 $paths[] = '/' . implode( '/', $hierarchical_slugs ); 421 } 422 } 423 424 return $paths; 425 } 426 427 /** 401 428 * Get the post categories preserving the hierarchical order 402 429 * -
sophi/tags/1.1.1/readme.txt
r2719676 r2725617 3 3 Tags: Sophi, Site Automation, Curator, Collector, AI, Artifical Intelligence, ML, Machine Learning, Content Curation 4 4 Tested up to: 5.9 5 Stable tag: 1.1. 05 Stable tag: 1.1.1 6 6 License: GPLv2 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 149 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/) 150 150 151 == Debugging == 152 153 If you are having difficulties with your Sophi integration, then we recommend utilizing the [Debug Bar for Sophi](https://wordpress.org/plugins/debug-bar-for-sophi/) plugin to help triage your Sophi Authentication, Sophi API integration, and CMS publish/update events. 154 151 155 == Frequently Asked Questions == 152 156 … … 174 178 175 179 == Changelog == 180 181 = 1.1.1 - 2022-05-17 = 182 * **Added:** `sophi_bypass_curated_posts_cache` filter to bypess curated posts cache (props [@cadic](https://github.com/cadic)). 183 * **Added:** Send all Categories in new `allSections` field to Sophi (props [@oscarssanchez](https://github.com/oscarssanchez), [@jeffpaul](https://github.com/jeffpaul), [@tott](https://github.com/tott)). 184 * **Changed:** `$result` is used instead of `$request` to store return value of the `sophi_request_result` filter (props [@faisal-alvi](https://github.com/faisal-alvi), [@Sidsector9](https://github.com/Sidsector9), [@cadic](https://github.com/cadic)). 185 * **Changed:** Suppress Emitter debug output and writing logs (props [@cadic](https://github.com/cadic)). 186 * **Fixed:** [Hook Docs](https://globeandmail.github.io/sophi-for-wordpress/) deployment GitHub Action and included filter docs (props [@iamdharmesh](https://github.com/iamdharmesh), [@jeffpaul](https://github.com/jeffpaul), [@cadic](https://github.com/cadic)). 176 187 177 188 = 1.1.0 - 2022-05-06 = -
sophi/tags/1.1.1/sophi.php
r2719676 r2725617 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.1. 06 * Version: 1.1.1 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.1. 0' );19 define( 'SOPHI_WP_VERSION', '1.1.1' ); 20 20 define( 'SOPHI_WP_URL', plugin_dir_url( __FILE__ ) ); 21 21 define( 'SOPHI_WP_PATH', plugin_dir_path( __FILE__ ) ); -
sophi/tags/1.1.1/vendor/autoload.php
r2719676 r2725617 10 10 require_once __DIR__ . '/composer/autoload_real.php'; 11 11 12 return ComposerAutoloaderInit bdfd77ff5462663cbbe04b8ffeb39221::getLoader();12 return ComposerAutoloaderInitedebab5f8c141d80dad48983397e451b::getLoader(); -
sophi/tags/1.1.1/vendor/composer/autoload_real.php
r2719676 r2725617 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit bdfd77ff5462663cbbe04b8ffeb392215 class ComposerAutoloaderInitedebab5f8c141d80dad48983397e451b 6 6 { 7 7 private static $loader; … … 25 25 require __DIR__ . '/platform_check.php'; 26 26 27 spl_autoload_register(array('ComposerAutoloaderInit bdfd77ff5462663cbbe04b8ffeb39221', 'loadClassLoader'), true, true);27 spl_autoload_register(array('ComposerAutoloaderInitedebab5f8c141d80dad48983397e451b', 'loadClassLoader'), true, true); 28 28 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 29 spl_autoload_unregister(array('ComposerAutoloaderInit bdfd77ff5462663cbbe04b8ffeb39221', 'loadClassLoader'));29 spl_autoload_unregister(array('ComposerAutoloaderInitedebab5f8c141d80dad48983397e451b', 'loadClassLoader')); 30 30 31 31 require __DIR__ . '/autoload_static.php'; 32 call_user_func(\Composer\Autoload\ComposerStaticInit bdfd77ff5462663cbbe04b8ffeb39221::getInitializer($loader));32 call_user_func(\Composer\Autoload\ComposerStaticInitedebab5f8c141d80dad48983397e451b::getInitializer($loader)); 33 33 34 34 $loader->register(true); 35 35 36 $includeFiles = \Composer\Autoload\ComposerStaticInit bdfd77ff5462663cbbe04b8ffeb39221::$files;36 $includeFiles = \Composer\Autoload\ComposerStaticInitedebab5f8c141d80dad48983397e451b::$files; 37 37 foreach ($includeFiles as $fileIdentifier => $file) { 38 composerRequire bdfd77ff5462663cbbe04b8ffeb39221($fileIdentifier, $file);38 composerRequireedebab5f8c141d80dad48983397e451b($fileIdentifier, $file); 39 39 } 40 40 … … 48 48 * @return void 49 49 */ 50 function composerRequire bdfd77ff5462663cbbe04b8ffeb39221($fileIdentifier, $file)50 function composerRequireedebab5f8c141d80dad48983397e451b($fileIdentifier, $file) 51 51 { 52 52 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { -
sophi/tags/1.1.1/vendor/composer/autoload_static.php
r2719676 r2725617 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit bdfd77ff5462663cbbe04b8ffeb392217 class ComposerStaticInitedebab5f8c141d80dad48983397e451b 8 8 { 9 9 public static $files = array ( … … 81 81 { 82 82 return \Closure::bind(function () use ($loader) { 83 $loader->prefixLengthsPsr4 = ComposerStaticInit bdfd77ff5462663cbbe04b8ffeb39221::$prefixLengthsPsr4;84 $loader->prefixDirsPsr4 = ComposerStaticInit bdfd77ff5462663cbbe04b8ffeb39221::$prefixDirsPsr4;85 $loader->classMap = ComposerStaticInit bdfd77ff5462663cbbe04b8ffeb39221::$classMap;83 $loader->prefixLengthsPsr4 = ComposerStaticInitedebab5f8c141d80dad48983397e451b::$prefixLengthsPsr4; 84 $loader->prefixDirsPsr4 = ComposerStaticInitedebab5f8c141d80dad48983397e451b::$prefixDirsPsr4; 85 $loader->classMap = ComposerStaticInitedebab5f8c141d80dad48983397e451b::$classMap; 86 86 87 87 }, null, ClassLoader::class); -
sophi/tags/1.1.1/vendor/composer/installed.php
r2719676 r2725617 1 1 <?php return array( 2 2 'root' => array( 3 'pretty_version' => '1.1. 0',4 'version' => '1.1. 0.0',3 'pretty_version' => '1.1.1', 4 'version' => '1.1.1.0', 5 5 'type' => 'wordpress-plugin', 6 6 'install_path' => __DIR__ . '/../../', 7 7 'aliases' => array(), 8 'reference' => ' d84a89aaba7208a28828807ba338aa7dfbf8246e',8 'reference' => '4bd4a394893a598c7fe75a10b6704d8312a57969', 9 9 'name' => 'globeandmail/sophi-for-wordpress', 10 10 'dev' => false, … … 21 21 ), 22 22 'globeandmail/sophi-for-wordpress' => array( 23 'pretty_version' => '1.1. 0',24 'version' => '1.1. 0.0',23 'pretty_version' => '1.1.1', 24 'version' => '1.1.1.0', 25 25 'type' => 'wordpress-plugin', 26 26 'install_path' => __DIR__ . '/../../', 27 27 'aliases' => array(), 28 'reference' => ' d84a89aaba7208a28828807ba338aa7dfbf8246e',28 'reference' => '4bd4a394893a598c7fe75a10b6704d8312a57969', 29 29 'dev_requirement' => false, 30 30 ), -
sophi/trunk/includes/blocks/site-automation-block/register.php
r2648442 r2725617 43 43 $curated_posts_transient_key = 'sophi_curated_posts_' . $page_name . '_' . $widget_name; 44 44 45 /** 46 * Whether to bypass caching. 47 * 48 * @since 1.1.1 49 * @hook sophi_bypass_curated_posts_cache 50 * 51 * @param {bool} $bypass_cache True or false. 52 * @param {string} $page Page name. 53 * @param {string} $widget Widget name. 54 * 55 * @return {bool} Whether to bypass cache. 56 */ 57 $bypass_cache = apply_filters( 'sophi_bypass_curated_posts_cache', false, $page_name, $widget_name ); 58 45 59 $curated_posts = get_transient( $curated_posts_transient_key ); 46 60 47 if ( false === $curated_posts ) {61 if ( $bypass_cache || false === $curated_posts ) { 48 62 // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.get_posts_get_posts 49 63 $curated_posts = get_posts( -
sophi/trunk/includes/classes/SiteAutomation/Auth.php
r2719676 r2725617 81 81 $args = apply_filters( 'sophi_request_args', $args, $auth_url ); 82 82 83 $re quest = wp_remote_post( $auth_url, $args );83 $result = wp_remote_post( $auth_url, $args ); 84 84 85 85 /** This filter is documented in includes/classes/SiteAutomation/Request.php */ 86 $re quest = apply_filters( 'sophi_request_result', $request, $args, $auth_url );86 $result = apply_filters( 'sophi_request_result', $result, $args, $auth_url ); 87 87 88 if ( is_wp_error( $re quest ) ) {89 return $re quest;88 if ( is_wp_error( $result ) ) { 89 return $result; 90 90 } 91 91 92 if ( 401 === wp_remote_retrieve_response_code( $re quest ) ) {92 if ( 401 === wp_remote_retrieve_response_code( $result ) ) { 93 93 return new \WP_Error( 401, __( 'Invalid credentials! Please confirm your client ID and secret then try again.', 'sophi-wp' ) ); 94 94 } 95 95 96 if ( 200 !== wp_remote_retrieve_response_code( $re quest ) ) {97 return new \WP_Error( $re quest['response']['code'], $request['response']['message'] );96 if ( 200 !== wp_remote_retrieve_response_code( $result ) ) { 97 return new \WP_Error( $result['response']['code'], $result['response']['message'] ); 98 98 } 99 99 100 $response = wp_remote_retrieve_body( $request ); 101 $response = json_decode( $response, true ); 100 $response = wp_remote_retrieve_body( $result ); 102 101 103 return $response;102 return json_decode( $response, true ); 104 103 } 105 104 -
sophi/trunk/includes/classes/SiteAutomation/Request.php
r2719676 r2725617 226 226 * @param {array} $args HTTP request arguments. 227 227 * @param {string} $url The request URL. 228 * 228 * 229 229 * @return {array} HTTP request arguments. 230 230 */ … … 232 232 233 233 if ( function_exists( 'vip_safe_wp_remote_get' ) ) { 234 $re quest = vip_safe_wp_remote_get( $this->api_url, '', 3, $timeout, 20, $args );234 $result = vip_safe_wp_remote_get( $this->api_url, '', 3, $timeout, 20, $args ); 235 235 } else { 236 236 $args['timeout'] = $timeout; 237 $re quest= wp_remote_get( $this->api_url, $args ); // phpcs:ignore237 $result = wp_remote_get( $this->api_url, $args ); // phpcs:ignore 238 238 } 239 239 … … 244 244 * @hook sophi_request_result 245 245 * 246 * @param {array|WP_Error} $re quest Result of HTTP request.246 * @param {array|WP_Error} $result Result of HTTP request. 247 247 * @param {array} $args HTTP request arguments. 248 248 * @param {string} $url The request URL. 249 * 249 * 250 250 * @return {array|WP_Error} Result of HTTP request. 251 251 */ 252 $re quest = apply_filters( 'sophi_request_result', $request, $args, $this->api_url );253 254 if ( is_wp_error( $re quest ) ) {255 return $re quest;256 } 257 258 if ( wp_remote_retrieve_response_code( $re quest ) !== 200 ) {259 return new \WP_Error( wp_remote_retrieve_response_code( $re quest ), $request['response']['message'] );260 } 261 262 return json_decode( wp_remote_retrieve_body( $re quest ), true );252 $result = apply_filters( 'sophi_request_result', $result, $args, $this->api_url ); 253 254 if ( is_wp_error( $result ) ) { 255 return $result; 256 } 257 258 if ( wp_remote_retrieve_response_code( $result ) !== 200 ) { 259 return new \WP_Error( wp_remote_retrieve_response_code( $result ), $result['response']['message'] ); 260 } 261 262 return json_decode( wp_remote_retrieve_body( $result ), true ); 263 263 } 264 264 -
sophi/trunk/includes/functions/content-sync.php
r2719676 r2725617 16 16 use Snowplow\Tracker\Tracker; 17 17 use Snowplow\Tracker\Subject; 18 use S nowplow\Tracker\Emitters\SyncEmitter;18 use SophiWP\Emitter; 19 19 20 20 /** … … 136 136 * 137 137 * @since 1.0.14 138 * @hook sophi_ tracking_data138 * @hook sophi_cms_tracking_request_data 139 139 * 140 140 * @param {array} $data Tracking data to send. 141 141 * @param {Tracker} $tracker Tracker being used. 142 * @param {string} $ urlPost object.142 * @param {string} $post Post object. 143 143 * @param {string} $action Publishing action. 144 144 * … … 146 146 */ 147 147 $data = apply_filters_ref_array( 'sophi_cms_tracking_request_data', array( $data, &$tracker, $post, $action ) ); 148 149 /** This filter is documented in includes/functions/content-sync.php */ 150 $debug = apply_filters( 'sophi_tracker_emitter_debug', false ); 151 152 // Suppress stdout from Emitters in debug mode. 153 if ( true === $debug ) { 154 ob_start(); 155 } 156 148 157 $tracker->trackUnstructEvent( 149 158 [ … … 162 171 ); 163 172 173 if ( true === $debug ) { 174 ob_end_clean(); 175 } 176 164 177 /** 165 178 * Fires after tracker sends the request. 166 179 * 167 180 * @since 1.0.14 168 * @hook sophi_ tracking_result181 * @hook sophi_cms_tracking_result 169 182 * 170 183 * @param {array} $data Tracked data. … … 212 225 213 226 $app_id = sprintf( '%s:cms', $tracker_client_id ); 214 $emitter = new SyncEmitter( $collector_url, 'https', 'POST', 1, $debug );227 $emitter = new Emitter( $collector_url, 'https', 'POST', 1, $debug ); 215 228 $subject = new Subject(); 216 229 return new Tracker( $emitter, $subject, 'sophiTag', $app_id, false ); … … 257 270 'plainText' => wp_strip_all_tags( $content ), 258 271 'size' => str_word_count( wp_strip_all_tags( $content ) ), 272 'allSections' => Utils\get_post_categories_paths( $post->ID ), 259 273 'sectionNames' => Utils\get_post_categories( $post->ID ), 260 274 'modifiedAt' => gmdate( \DateTime::RFC3339, strtotime( $post->post_modified_gmt ) ), -
sophi/trunk/includes/functions/utils.php
r2719676 r2725617 399 399 400 400 /** 401 * Return an array of category paths from a given post. 402 * 403 * @param int $post_id The post ID. 404 * @return array The array of category paths, or an empty array if no categories. 405 */ 406 function get_post_categories_paths( $post_id ) { 407 $categories = get_the_category( $post_id ); 408 $paths = []; 409 410 foreach ( $categories as $category ) { 411 if ( is_a( $category, 'WP_Term' ) && 'category' === $category->taxonomy ) { 412 $hierarchical_slugs = []; 413 $ancestors = get_ancestors( $category->term_id, $category->taxonomy, 'taxonomy' ); 414 foreach ( (array) $ancestors as $ancestor ) { 415 $ancestor_term = get_term( $ancestor, $category->taxonomy ); 416 $hierarchical_slugs[] = $ancestor_term->slug; 417 } 418 $hierarchical_slugs = array_reverse( $hierarchical_slugs ); 419 $hierarchical_slugs[] = $category->slug; 420 $paths[] = '/' . implode( '/', $hierarchical_slugs ); 421 } 422 } 423 424 return $paths; 425 } 426 427 /** 401 428 * Get the post categories preserving the hierarchical order 402 429 * -
sophi/trunk/readme.txt
r2719676 r2725617 3 3 Tags: Sophi, Site Automation, Curator, Collector, AI, Artifical Intelligence, ML, Machine Learning, Content Curation 4 4 Tested up to: 5.9 5 Stable tag: 1.1. 05 Stable tag: 1.1.1 6 6 License: GPLv2 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 149 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/) 150 150 151 == Debugging == 152 153 If you are having difficulties with your Sophi integration, then we recommend utilizing the [Debug Bar for Sophi](https://wordpress.org/plugins/debug-bar-for-sophi/) plugin to help triage your Sophi Authentication, Sophi API integration, and CMS publish/update events. 154 151 155 == Frequently Asked Questions == 152 156 … … 174 178 175 179 == Changelog == 180 181 = 1.1.1 - 2022-05-17 = 182 * **Added:** `sophi_bypass_curated_posts_cache` filter to bypess curated posts cache (props [@cadic](https://github.com/cadic)). 183 * **Added:** Send all Categories in new `allSections` field to Sophi (props [@oscarssanchez](https://github.com/oscarssanchez), [@jeffpaul](https://github.com/jeffpaul), [@tott](https://github.com/tott)). 184 * **Changed:** `$result` is used instead of `$request` to store return value of the `sophi_request_result` filter (props [@faisal-alvi](https://github.com/faisal-alvi), [@Sidsector9](https://github.com/Sidsector9), [@cadic](https://github.com/cadic)). 185 * **Changed:** Suppress Emitter debug output and writing logs (props [@cadic](https://github.com/cadic)). 186 * **Fixed:** [Hook Docs](https://globeandmail.github.io/sophi-for-wordpress/) deployment GitHub Action and included filter docs (props [@iamdharmesh](https://github.com/iamdharmesh), [@jeffpaul](https://github.com/jeffpaul), [@cadic](https://github.com/cadic)). 176 187 177 188 = 1.1.0 - 2022-05-06 = -
sophi/trunk/sophi.php
r2719676 r2725617 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.1. 06 * Version: 1.1.1 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.1. 0' );19 define( 'SOPHI_WP_VERSION', '1.1.1' ); 20 20 define( 'SOPHI_WP_URL', plugin_dir_url( __FILE__ ) ); 21 21 define( 'SOPHI_WP_PATH', plugin_dir_path( __FILE__ ) ); -
sophi/trunk/vendor/autoload.php
r2719676 r2725617 10 10 require_once __DIR__ . '/composer/autoload_real.php'; 11 11 12 return ComposerAutoloaderInit bdfd77ff5462663cbbe04b8ffeb39221::getLoader();12 return ComposerAutoloaderInitedebab5f8c141d80dad48983397e451b::getLoader(); -
sophi/trunk/vendor/composer/autoload_real.php
r2719676 r2725617 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit bdfd77ff5462663cbbe04b8ffeb392215 class ComposerAutoloaderInitedebab5f8c141d80dad48983397e451b 6 6 { 7 7 private static $loader; … … 25 25 require __DIR__ . '/platform_check.php'; 26 26 27 spl_autoload_register(array('ComposerAutoloaderInit bdfd77ff5462663cbbe04b8ffeb39221', 'loadClassLoader'), true, true);27 spl_autoload_register(array('ComposerAutoloaderInitedebab5f8c141d80dad48983397e451b', 'loadClassLoader'), true, true); 28 28 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 29 spl_autoload_unregister(array('ComposerAutoloaderInit bdfd77ff5462663cbbe04b8ffeb39221', 'loadClassLoader'));29 spl_autoload_unregister(array('ComposerAutoloaderInitedebab5f8c141d80dad48983397e451b', 'loadClassLoader')); 30 30 31 31 require __DIR__ . '/autoload_static.php'; 32 call_user_func(\Composer\Autoload\ComposerStaticInit bdfd77ff5462663cbbe04b8ffeb39221::getInitializer($loader));32 call_user_func(\Composer\Autoload\ComposerStaticInitedebab5f8c141d80dad48983397e451b::getInitializer($loader)); 33 33 34 34 $loader->register(true); 35 35 36 $includeFiles = \Composer\Autoload\ComposerStaticInit bdfd77ff5462663cbbe04b8ffeb39221::$files;36 $includeFiles = \Composer\Autoload\ComposerStaticInitedebab5f8c141d80dad48983397e451b::$files; 37 37 foreach ($includeFiles as $fileIdentifier => $file) { 38 composerRequire bdfd77ff5462663cbbe04b8ffeb39221($fileIdentifier, $file);38 composerRequireedebab5f8c141d80dad48983397e451b($fileIdentifier, $file); 39 39 } 40 40 … … 48 48 * @return void 49 49 */ 50 function composerRequire bdfd77ff5462663cbbe04b8ffeb39221($fileIdentifier, $file)50 function composerRequireedebab5f8c141d80dad48983397e451b($fileIdentifier, $file) 51 51 { 52 52 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { -
sophi/trunk/vendor/composer/autoload_static.php
r2719676 r2725617 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit bdfd77ff5462663cbbe04b8ffeb392217 class ComposerStaticInitedebab5f8c141d80dad48983397e451b 8 8 { 9 9 public static $files = array ( … … 81 81 { 82 82 return \Closure::bind(function () use ($loader) { 83 $loader->prefixLengthsPsr4 = ComposerStaticInit bdfd77ff5462663cbbe04b8ffeb39221::$prefixLengthsPsr4;84 $loader->prefixDirsPsr4 = ComposerStaticInit bdfd77ff5462663cbbe04b8ffeb39221::$prefixDirsPsr4;85 $loader->classMap = ComposerStaticInit bdfd77ff5462663cbbe04b8ffeb39221::$classMap;83 $loader->prefixLengthsPsr4 = ComposerStaticInitedebab5f8c141d80dad48983397e451b::$prefixLengthsPsr4; 84 $loader->prefixDirsPsr4 = ComposerStaticInitedebab5f8c141d80dad48983397e451b::$prefixDirsPsr4; 85 $loader->classMap = ComposerStaticInitedebab5f8c141d80dad48983397e451b::$classMap; 86 86 87 87 }, null, ClassLoader::class); -
sophi/trunk/vendor/composer/installed.php
r2719676 r2725617 1 1 <?php return array( 2 2 'root' => array( 3 'pretty_version' => '1.1. 0',4 'version' => '1.1. 0.0',3 'pretty_version' => '1.1.1', 4 'version' => '1.1.1.0', 5 5 'type' => 'wordpress-plugin', 6 6 'install_path' => __DIR__ . '/../../', 7 7 'aliases' => array(), 8 'reference' => ' d84a89aaba7208a28828807ba338aa7dfbf8246e',8 'reference' => '4bd4a394893a598c7fe75a10b6704d8312a57969', 9 9 'name' => 'globeandmail/sophi-for-wordpress', 10 10 'dev' => false, … … 21 21 ), 22 22 'globeandmail/sophi-for-wordpress' => array( 23 'pretty_version' => '1.1. 0',24 'version' => '1.1. 0.0',23 'pretty_version' => '1.1.1', 24 'version' => '1.1.1.0', 25 25 'type' => 'wordpress-plugin', 26 26 'install_path' => __DIR__ . '/../../', 27 27 'aliases' => array(), 28 'reference' => ' d84a89aaba7208a28828807ba338aa7dfbf8246e',28 'reference' => '4bd4a394893a598c7fe75a10b6704d8312a57969', 29 29 'dev_requirement' => false, 30 30 ),
Note: See TracChangeset
for help on using the changeset viewer.