Changeset 2378844
- Timestamp:
- 09/10/2020 03:57:26 PM (6 years ago)
- Location:
- highways-sync-for-intercom
- Files:
-
- 1 deleted
- 21 edited
-
.idea/workspace.xml (modified) (5 diffs)
-
tags/1.0.1 (deleted)
-
trunk/highways-sync-for-intercom.php (modified) (2 diffs)
-
trunk/includes/intercom.php (modified) (2 diffs)
-
trunk/includes/lib/action-scheduler/action-scheduler.php (modified) (4 diffs)
-
trunk/includes/lib/action-scheduler/classes/ActionScheduler_ActionFactory.php (modified) (6 diffs)
-
trunk/includes/lib/action-scheduler/classes/ActionScheduler_AdminView.php (modified) (3 diffs)
-
trunk/includes/lib/action-scheduler/classes/ActionScheduler_DataController.php (modified) (2 diffs)
-
trunk/includes/lib/action-scheduler/classes/ActionScheduler_ListTable.php (modified) (4 diffs)
-
trunk/includes/lib/action-scheduler/classes/ActionScheduler_QueueRunner.php (modified) (1 diff)
-
trunk/includes/lib/action-scheduler/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php (modified) (1 diff)
-
trunk/includes/lib/action-scheduler/classes/abstracts/ActionScheduler.php (modified) (5 diffs)
-
trunk/includes/lib/action-scheduler/classes/abstracts/ActionScheduler_Abstract_ListTable.php (modified) (3 diffs)
-
trunk/includes/lib/action-scheduler/classes/abstracts/ActionScheduler_Abstract_Schema.php (modified) (2 diffs)
-
trunk/includes/lib/action-scheduler/classes/abstracts/ActionScheduler_Logger.php (modified) (1 diff)
-
trunk/includes/lib/action-scheduler/classes/abstracts/ActionScheduler_Store.php (modified) (1 diff)
-
trunk/includes/lib/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php (modified) (1 diff)
-
trunk/includes/lib/action-scheduler/classes/data-stores/ActionScheduler_HybridStore.php (modified) (4 diffs)
-
trunk/includes/lib/action-scheduler/classes/migration/Controller.php (modified) (1 diff)
-
trunk/includes/lib/action-scheduler/classes/migration/Scheduler.php (modified) (1 diff)
-
trunk/includes/lib/action-scheduler/functions.php (modified) (10 diffs)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
highways-sync-for-intercom/.idea/workspace.xml
r2261884 r2378844 3 3 <component name="ChangeListManager"> 4 4 <list default="true" id="75bfd89f-af77-46a3-ba15-a576098cd96d" name="Default Changelist" comment=""> 5 <change afterPath="$PROJECT_DIR$/../../infusionsoft/infusionsoft-php" afterDir="false" /> 6 <change beforePath="$PROJECT_DIR$/trunk/includes/webhooks.php" beforeDir="false" afterPath="$PROJECT_DIR$/trunk/includes/webhooks.php" afterDir="false" /> 5 <change afterPath="$PROJECT_DIR$/../../thinkific-video/app/Http/Middleware/SSLRedirect.php" afterDir="false" /> 6 <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> 7 <change beforePath="$PROJECT_DIR$/tags/1.0.1" beforeDir="true" /> 8 <change beforePath="$PROJECT_DIR$/trunk/highways-sync-for-intercom.php" beforeDir="false" afterPath="$PROJECT_DIR$/trunk/highways-sync-for-intercom.php" afterDir="false" /> 9 <change beforePath="$PROJECT_DIR$/trunk/includes/intercom.php" beforeDir="false" afterPath="$PROJECT_DIR$/trunk/includes/intercom.php" afterDir="false" /> 10 <change beforePath="$PROJECT_DIR$/trunk/readme.txt" beforeDir="false" afterPath="$PROJECT_DIR$/trunk/readme.txt" afterDir="false" /> 11 <change beforePath="$PROJECT_DIR$/../../drone-mapper/.idea/drone-mapper.iml" beforeDir="false" afterPath="$PROJECT_DIR$/../../drone-mapper/.idea/drone-mapper.iml" afterDir="false" /> 12 <change beforePath="$PROJECT_DIR$/../../drone-mapper/.idea/php.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../../drone-mapper/.idea/php.xml" afterDir="false" /> 13 <change beforePath="$PROJECT_DIR$/../../drone-mapper/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../../drone-mapper/.idea/vcs.xml" afterDir="false" /> 14 <change beforePath="$PROJECT_DIR$/../../drone-mapper/.vagrant/machines/drone-mapper/virtualbox/action_set_name" beforeDir="false" afterPath="$PROJECT_DIR$/../../drone-mapper/.vagrant/machines/drone-mapper/virtualbox/action_set_name" afterDir="false" /> 15 <change beforePath="$PROJECT_DIR$/../../drone-mapper/app/Drone.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../drone-mapper/app/Drone.php" afterDir="false" /> 16 <change beforePath="$PROJECT_DIR$/../../drone-mapper/app/Flight.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../drone-mapper/app/Flight.php" afterDir="false" /> 17 <change beforePath="$PROJECT_DIR$/../../drone-mapper/app/Http/Controllers/MapController.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../drone-mapper/app/Http/Controllers/MapController.php" afterDir="false" /> 18 <change beforePath="$PROJECT_DIR$/../../drone-mapper/app/Pilot.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../drone-mapper/app/Pilot.php" afterDir="false" /> 19 <change beforePath="$PROJECT_DIR$/../../drone-mapper/app/Point.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../drone-mapper/app/Point.php" afterDir="false" /> 20 <change beforePath="$PROJECT_DIR$/../../drone-mapper/app/PointMeta.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../drone-mapper/app/PointMeta.php" afterDir="false" /> 21 <change beforePath="$PROJECT_DIR$/../../drone-mapper/database/migrations/2020_07_08_174416_create_points_table.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../drone-mapper/database/migrations/2020_07_08_174416_create_points_table.php" afterDir="false" /> 22 <change beforePath="$PROJECT_DIR$/../../drone-mapper/database/migrations/2020_07_08_174852_create_point_metas_table.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../drone-mapper/database/migrations/2020_07_08_174852_create_point_metas_table.php" afterDir="false" /> 23 <change beforePath="$PROJECT_DIR$/../../drone-mapper/database/migrations/2020_07_10_123314_create_flights_table.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../drone-mapper/database/migrations/2020_07_10_123314_create_flights_table.php" afterDir="false" /> 24 <change beforePath="$PROJECT_DIR$/../../drone-mapper/database/migrations/2020_07_10_123328_create_drones_table.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../drone-mapper/database/migrations/2020_07_10_123328_create_drones_table.php" afterDir="false" /> 25 <change beforePath="$PROJECT_DIR$/../../drone-mapper/database/migrations/2020_07_10_123340_create_pilots_table.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../drone-mapper/database/migrations/2020_07_10_123340_create_pilots_table.php" afterDir="false" /> 26 <change beforePath="$PROJECT_DIR$/../../drone-mapper/database/seeds/IrishAirspaceSeeder.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../drone-mapper/database/seeds/IrishAirspaceSeeder.php" afterDir="false" /> 27 <change beforePath="$PROJECT_DIR$/../../drone-mapper/resources/views/map.blade.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../drone-mapper/resources/views/map.blade.php" afterDir="false" /> 28 <change beforePath="$PROJECT_DIR$/../../highways-saas/app/Http/Controllers/Services/ThinkificController.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../highways-saas/app/Http/Controllers/Services/ThinkificController.php" afterDir="false" /> 29 <change beforePath="$PROJECT_DIR$/../../highways-sync/app/Http/Auth/LoginController.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../highways-sync/app/Http/Auth/LoginController.php" afterDir="false" /> 30 <change beforePath="$PROJECT_DIR$/../../highways-sync/app/Http/Controllers/V2/SyncController.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../highways-sync/app/Http/Controllers/V2/SyncController.php" afterDir="false" /> 31 <change beforePath="$PROJECT_DIR$/../../highways-sync/app/Rules/ReCaptcha.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../highways-sync/app/Rules/ReCaptcha.php" afterDir="false" /> 32 <change beforePath="$PROJECT_DIR$/../../highways-sync/resources/js/components/LogChart.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../../highways-sync/resources/js/components/LogChart.vue" afterDir="false" /> 33 <change beforePath="$PROJECT_DIR$/../../highways-sync/resources/js/components/SyncOverview.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../../highways-sync/resources/js/components/SyncOverview.vue" afterDir="false" /> 34 <change beforePath="$PROJECT_DIR$/../../highways-sync/resources/views/vendor/spark/modals/sync-delete.blade.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../highways-sync/resources/views/vendor/spark/modals/sync-delete.blade.php" afterDir="false" /> 35 <change beforePath="$PROJECT_DIR$/../../infusionsoft/infusionsoft-php" beforeDir="false" afterPath="$PROJECT_DIR$/../../infusionsoft/infusionsoft-php" afterDir="false" /> 36 <change beforePath="$PROJECT_DIR$/../../nimble-php/.gitignore" beforeDir="false" /> 37 <change beforePath="$PROJECT_DIR$/../../nimble-php/README.md" beforeDir="false" /> 38 <change beforePath="$PROJECT_DIR$/../../nimble-php/composer.json" beforeDir="false" /> 39 <change beforePath="$PROJECT_DIR$/../../nimble-php/src/NimbleClient.php" beforeDir="false" /> 40 <change beforePath="$PROJECT_DIR$/../../nimble-php/src/NimbleContacts.php" beforeDir="false" /> 41 <change beforePath="$PROJECT_DIR$/../../nimble-php/src/NimbleResource.php" beforeDir="false" /> 42 <change beforePath="$PROJECT_DIR$/../../nimble-php/src/NimbleUser.php" beforeDir="false" /> 43 <change beforePath="$PROJECT_DIR$/../../thinkific-video/.idea/php.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../../thinkific-video/.idea/php.xml" afterDir="false" /> 44 <change beforePath="$PROJECT_DIR$/../../thinkific-video/.idea/thinkific-video.iml" beforeDir="false" afterPath="$PROJECT_DIR$/../../thinkific-video/.idea/thinkific-video.iml" afterDir="false" /> 45 <change beforePath="$PROJECT_DIR$/../../thinkific-video/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../../thinkific-video/.idea/vcs.xml" afterDir="false" /> 46 <change beforePath="$PROJECT_DIR$/../../thinkific-video/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../../thinkific-video/.idea/workspace.xml" afterDir="false" /> 47 <change beforePath="$PROJECT_DIR$/../../thinkific-video/app/Assignment.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../thinkific-video/app/Assignment.php" afterDir="false" /> 48 <change beforePath="$PROJECT_DIR$/../../thinkific-video/app/Http/Auth/LoginController.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../thinkific-video/app/Http/Auth/LoginController.php" afterDir="false" /> 49 <change beforePath="$PROJECT_DIR$/../../thinkific-video/app/Http/Controllers/EmbedController.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../thinkific-video/app/Http/Controllers/EmbedController.php" afterDir="false" /> 50 <change beforePath="$PROJECT_DIR$/../../thinkific-video/app/Http/Kernel.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../thinkific-video/app/Http/Kernel.php" afterDir="false" /> 51 <change beforePath="$PROJECT_DIR$/../../thinkific-video/app/Http/Middleware/TrustProxies.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../thinkific-video/app/Http/Middleware/TrustProxies.php" afterDir="false" /> 52 <change beforePath="$PROJECT_DIR$/../../thinkific-video/app/Providers/SparkServiceProvider.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../thinkific-video/app/Providers/SparkServiceProvider.php" afterDir="false" /> 53 <change beforePath="$PROJECT_DIR$/../../thinkific-video/app/Student.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../thinkific-video/app/Student.php" afterDir="false" /> 54 <change beforePath="$PROJECT_DIR$/../../thinkific-video/app/Submission.php" beforeDir="false" afterPath="$PROJECT_DIR$/../../thinkific-video/app/Submission.php" afterDir="false" /> 55 <change beforePath="$PROJECT_DIR$/../../thinkific-video/composer.json" beforeDir="false" afterPath="$PROJECT_DIR$/../../thinkific-video/composer.json" afterDir="false" /> 56 <change beforePath="$PROJECT_DIR$/../../thinkific-video/composer.lock" beforeDir="false" afterPath="$PROJECT_DIR$/../../thinkific-video/composer.lock" afterDir="false" /> 57 <change beforePath="$PROJECT_DIR$/../../thinkific-video/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/../../thinkific-video/package.json" afterDir="false" /> 58 <change beforePath="$PROJECT_DIR$/../../thinkific-video/public/js/app.js" beforeDir="false" afterPath="$PROJECT_DIR$/../../thinkific-video/public/js/app.js" afterDir="false" /> 59 <change beforePath="$PROJECT_DIR$/../../thinkific-video/resources/js/components/public/pComments.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../../thinkific-video/resources/js/components/public/pComments.vue" afterDir="false" /> 60 <change beforePath="$PROJECT_DIR$/../../thinkific-video/resources/js/components/public/pPasscode.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../../thinkific-video/resources/js/components/public/pPasscode.vue" afterDir="false" /> 61 <change beforePath="$PROJECT_DIR$/../../thinkific-video/resources/js/components/public/pSubmissionViewer.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../../thinkific-video/resources/js/components/public/pSubmissionViewer.vue" afterDir="false" /> 7 62 </list> 8 63 <option name="SHOW_DIALOG" value="false" /> … … 12 67 </component> 13 68 <component name="ComposerSettings"> 14 <execution> 15 <executable /> 16 </execution> 69 <execution /> 17 70 </component> 18 71 <component name="Git.Settings"> … … 23 76 <component name="ProjectViewState"> 24 77 <option name="hideEmptyMiddlePackages" value="true" /> 25 <option name="showExcludedFiles" value="true" />26 78 <option name="showLibraryContents" value="true" /> 27 79 </component> … … 32 84 <property name="settings.editor.selected.configurable" value="preferences.pluginManager" /> 33 85 </component> 86 <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" /> 34 87 <component name="SvnConfiguration" cleanupOnStartRun="true"> 35 88 <configuration>$USER_HOME$/.subversion</configuration> 89 <supportedVersion>125</supportedVersion> 36 90 </component> 37 91 <component name="SvnFileUrlMappingImpl"> … … 61 115 <updated>1583673047784</updated> 62 116 <workItem from="1583673049069" duration="640000" /> 117 <workItem from="1587651197430" duration="3000" /> 118 <workItem from="1599750767017" duration="1718000" /> 63 119 </task> 64 120 <servers /> 65 121 </component> 66 122 <component name="TypeScriptGeneratedFilesManager"> 67 <option name="version" value=" 1" />123 <option name="version" value="3" /> 68 124 </component> 69 125 <component name="WindowStateProjectService"> -
highways-sync-for-intercom/trunk/highways-sync-for-intercom.php
r2285958 r2378844 4 4 * Plugin URI: https://www.highways.io/?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash 5 5 * Description: A complete WordPress to Intercom Sync Plugin 6 * Version: 1.0. 56 * Version: 1.0.6 7 7 * Author: Highways.io 8 8 * Author URI: https://www.highways.io/?utm_source=wp-plugins&utm_campaign=intercom-wp&utm_medium=wp-dash … … 22 22 if ( ! defined( 'ABSPATH' ) ) exit; 23 23 24 define( 'INTERCOM_WP_VERSION', '1.0. 5' );25 define( 'INTERCOM_WP_PREVIOUS_STABLE_VERSION', '1.0. 4' );24 define( 'INTERCOM_WP_VERSION', '1.0.6' ); 25 define( 'INTERCOM_WP_PREVIOUS_STABLE_VERSION', '1.0.5' ); 26 26 define( 'INTERCOM_WP_NAME', 'Highways Sync for Intercom' ); 27 27 define( 'INTERCOM_WP__FILE__', __FILE__ ); -
highways-sync-for-intercom/trunk/includes/intercom.php
r2261884 r2378844 5 5 use Intercom\IntercomClient; 6 6 7 if ( ! defined( 'ABSPATH' ) ) exit; 8 9 class Intercom { 10 7 if (!defined('ABSPATH')) exit; 8 9 class Intercom 10 { 11 11 12 const API_KEY_OPTION = 'intercom_wp_intercom_api_key'; 12 13 13 14 public $user_id, $wp_user, $client, $options; 14 15 15 16 public function __construct($user_id = false) 16 17 { 17 $this->includes(); 18 18 $this->includes(); 19 19 20 $this->user_id = $user_id; 20 21 if ($this->user_id) {22 23 $this->wp_user = get_user_by( 'id', $this->user_id);24 25 } 26 21 22 if ($this->user_id) { 23 24 $this->wp_user = get_user_by('id', $this->user_id); 25 26 } 27 27 28 $this->client = self::intercom_client(); 28 29 29 30 $this->options = []; 30 31 31 32 /* Intercom Hook */ 32 33 add_action('iwp_send_to_intercom', [$this, 'iwp_send_to_intercom']); 33 34 } 34 35 35 36 public function includes() 36 37 { 37 38 /* Intercom PHP SDK */ 38 39 require INTERCOM_WP_PATH . '/includes/lib/intercom-php/vendor/autoload.php'; 40 41 } 42 43 private function intercom_client() { 44 45 $this->options = get_option('intercom_wp_settings'); 46 47 if(empty($this->options)) { 48 49 $this->options = []; 50 51 } 52 53 if(isset($this->options[self::API_KEY_OPTION])) { 54 55 $api_key = $this->options[self::API_KEY_OPTION]; 56 } 57 58 else $api_key = false; 59 60 if(empty($api_key)) return false; 61 39 40 require INTERCOM_WP_PATH . '/includes/lib/intercom-php/vendor/autoload.php'; 41 42 } 43 44 public function logMe($message) 45 { 46 if(!is_string($message)) $message = print_r($message); 47 48 if (function_exists('wc_get_logger')) { 49 50 $logger = wc_get_logger(); 51 52 $logger->info($message, array('source' => 'highways-sync-for-intercom')); 53 } else error_log($message); 54 } 55 56 private function intercom_client() 57 { 58 62 59 try { 63 60 61 $this->options = get_option('intercom_wp_settings'); 62 63 if (empty($this->options)) { 64 65 $this->options = []; 66 67 } 68 69 if (isset($this->options[self::API_KEY_OPTION])) { 70 71 $api_key = $this->options[self::API_KEY_OPTION]; 72 } else $api_key = false; 73 74 if (empty($api_key)) throw new \Exception('Intercom API key is missing. Please reconnect Intercom or check your API Key is entered correctly.'); 75 64 76 return new IntercomClient($api_key, null, ['Intercom-Version' => apply_filters('iwp_api_version', 1.4)]); 65 66 } 67 68 catch (\Exception $e) { 69 70 error_log($e->getMessage()); 71 } 72 73 } 74 75 public function iwp_send_to_intercom($key) { 76 77 78 } catch (\Exception $e) { 79 80 $this->logMe($e->getMessage()); 81 } 82 83 } 84 85 public function iwp_send_to_intercom($key) 86 { 87 77 88 $payload = get_transient($key); 78 79 if (is_array($payload) && $this->client) {80 89 90 if (is_array($payload) && $this->client) { 91 81 92 delete_transient($key); 82 93 83 94 $intercom = new Intercom; 84 95 85 96 $type = $payload['type']; 86 97 87 98 unset($payload['type']); 88 89 $method = $payload['method'];90 99 100 $method = $payload['method']; 101 91 102 unset($payload['method']); 92 103 93 104 try { 94 105 95 106 $response = $this->client->{$type}->{$method}($payload); 96 97 } 98 99 catch(\Http\Client\Exception $e) { 100 101 error_log('Intercom Response Exception:: '.$e->getMessage()); 102 } 103 104 catch(\Exception $e) { 105 106 error_log('Intercom Response Exception::'.$e->getMessage()); 107 } 108 109 } 110 } 111 112 public function schedule_intercom_call($payload) { 113 107 108 } catch (\Http\Client\Exception $e) { 109 110 $this->logMe('Intercom Response Exception:: ' . $e->getMessage()); 111 } catch (\Exception $e) { 112 113 $this->logMe('Intercom Response Exception:: ' . $e->getMessage()); 114 } 115 116 } 117 } 118 119 public function schedule_intercom_call($payload) 120 { 121 114 122 $key = self::create_transient_id($payload); 115 123 116 124 $sync = isset($this->options['enable_sync_calls']) ? $this->options['enable_sync_calls'] : false; 117 118 if(set_transient($key, $payload, DAY_IN_SECONDS)) { 119 120 if($sync) $this->iwp_send_to_intercom($key); 121 122 else as_schedule_single_action( time() + 5, 'iwp_send_to_intercom', array($key) ); 123 } 124 125 } 126 127 public function create_user() { 128 129 $disabled = isset($this->options['disable_user_creation']) ? $this->options['disable_user_creation'] : false; 130 131 if($disabled) return; 132 133 if(self::API_VERSION > 1.4) { 134 125 126 if (set_transient($key, $payload, DAY_IN_SECONDS)) { 127 128 if ($sync) $this->iwp_send_to_intercom($key); 129 130 else { 131 132 if (function_exists('as_schedule_single_action')) { 133 134 as_schedule_single_action(time() + 5, 'iwp_send_to_intercom', array($key)); 135 136 } else wp_schedule_single_event(time() + 5, 'iwp_send_to_intercom', array($key)); 137 138 139 } 140 } 141 142 } 143 144 public function create_user() 145 { 146 147 $disabled = isset($this->options['disable_user_creation']) ? $this->options['disable_user_creation'] : false; 148 149 if ($disabled) return; 150 151 if (self::API_VERSION > 1.4) { 152 135 153 $this->create_contact(); 136 154 137 155 return; 138 156 } 139 157 140 158 $payload = array( 141 'method' => 'update',142 'type' => 'users',143 'name' => $this->wp_user->user_firstname.' '.$this->wp_user->user_lastname,144 'last_request_at' => time()145 );146 159 'method' => 'update', 160 'type' => 'users', 161 'name' => $this->wp_user->user_firstname . ' ' . $this->wp_user->user_lastname, 162 'last_request_at' => time() 163 ); 164 147 165 $payload = apply_filters('iwp_create_user', $payload, $this->user_id); 148 166 149 167 $payload = self::add_user_data($payload); 150 168 151 169 $this->schedule_intercom_call($payload); 152 153 } 154 155 public function create_lead() { 156 157 $disabled = isset($this->options['disable_lead_creation']) ? $this->options['disable_lead_creation'] : false; 158 159 if($disabled) return; 160 161 if(self::API_VERSION > 1.4) { 162 170 171 } 172 173 public function create_lead() 174 { 175 176 $disabled = isset($this->options['disable_lead_creation']) ? $this->options['disable_lead_creation'] : false; 177 178 if ($disabled) return; 179 180 if (self::API_VERSION > 1.4) { 181 163 182 $this->create_contact(); 164 183 165 184 return; 166 185 } 167 186 168 187 $payload = array( 169 'method' => 'update',170 'type' => 'leads',171 'name' => $this->wp_user->user_firstname.' '.$this->wp_user->user_lastname,172 'last_request_at' => time()173 );174 188 'method' => 'update', 189 'type' => 'leads', 190 'name' => $this->wp_user->user_firstname . ' ' . $this->wp_user->user_lastname, 191 'last_request_at' => time() 192 ); 193 175 194 $payload = apply_filters('iwp_create_lead', $payload, $this->user_id); 176 195 177 196 $payload = self::add_user_data($payload); 178 197 179 198 $this->schedule_intercom_call($payload); 180 181 } 182 183 public function create_contact() { 184 199 200 } 201 202 public function create_contact() 203 { 204 185 205 $payload = array( 186 'method' => 'create',187 'type' => 'contacts',188 'name' => $this->wp_user->user_firstname.' '.$this->wp_user->user_lastname,189 'role' => apply_filters('iwp_create_contact_role', 'user', $this->user_id),190 'last_request_at' => time()191 );192 206 'method' => 'create', 207 'type' => 'contacts', 208 'name' => $this->wp_user->user_firstname . ' ' . $this->wp_user->user_lastname, 209 'role' => apply_filters('iwp_create_contact_role', 'user', $this->user_id), 210 'last_request_at' => time() 211 ); 212 193 213 $payload = apply_filters('iwp_create_contact', $payload, $this->user_id); 194 214 195 215 $payload = self::add_user_data($payload); 196 216 197 217 $this->schedule_intercom_call($payload); 198 218 } 199 200 public function update_user($update = []) { 201 202 $disabled = isset($this->options['disable_intercom_updates']) ? $this->options['disable_intercom_updates'] : false; 203 204 if($disabled) return; 205 219 220 public function update_user($update = []) 221 { 222 223 $disabled = isset($this->options['disable_intercom_updates']) ? $this->options['disable_intercom_updates'] : false; 224 225 if ($disabled) return; 226 206 227 $type = apply_filters('iwp_update_type', 'users', $this->user_id); 207 228 208 229 $payload = array( 209 'method' => 'update',210 'type' => $type,211 'last_request_at' => time()230 'method' => 'update', 231 'type' => $type, 232 'last_request_at' => time() 212 233 ); 213 234 214 235 $payload = self::add_user_data($payload); 215 236 216 237 $payload = array_merge($payload, $update); 217 238 218 239 $this->schedule_intercom_call($payload); 219 220 } 221 222 public function create_event($event, $metadata = []) { 223 224 $disabled = isset($this->options['disable_events']) ? $this->options['disable_events'] : false; 225 226 if($disabled) return; 227 228 if(self::is_event_permitted($event)) { 229 240 241 } 242 243 public function create_event($event, $metadata = []) 244 { 245 246 $disabled = isset($this->options['disable_events']) ? $this->options['disable_events'] : false; 247 248 if ($disabled) return; 249 250 if (self::is_event_permitted($event)) { 251 230 252 $prefix = apply_filters('iwp_event_prefix', 'wp_'); 231 232 $event = $prefix .$event;233 253 254 $event = $prefix . $event; 255 234 256 $payload = array( 235 'event_name' => $event, 257 'event_name' => $event, 236 258 'created_at' => time(), 237 259 'method' => 'create', 238 260 'type' => 'events', 239 261 ); 240 241 if (!empty($metadata)) {242 262 263 if (!empty($metadata)) { 264 243 265 $payload['metadata'] = $metadata; 244 266 } 245 267 246 268 $payload = self::add_user_data($payload); 247 269 248 270 $this->schedule_intercom_call($payload); 249 271 } 250 251 } 252 253 public function add_tag($tags) { 254 255 $disabled = isset($this->options['disable_tags']) ? $this->options['disable_tags'] : false; 256 257 if($disabled) return; 258 272 273 } 274 275 public function add_tag($tags) 276 { 277 278 $disabled = isset($this->options['disable_tags']) ? $this->options['disable_tags'] : false; 279 280 if ($disabled) return; 281 259 282 $tags = apply_filters('iwp_add_tag', $tags, $this->user_id); 260 261 if (is_array($tags)) {262 263 foreach ($tags as $tag) {264 283 284 if (is_array($tags)) { 285 286 foreach ($tags as $tag) { 287 265 288 $payload = []; 266 289 $payload['name'] = $tag; 267 290 $payload['method'] = 'tag'; 268 $payload['type'] = 'tags'; 269 291 $payload['type'] = 'tags'; 292 270 293 $payload['user'][] = self::add_user_data([]); 271 294 272 295 $this->schedule_intercom_call($payload); 273 274 } 275 } 276 277 else { 278 296 297 } 298 } else { 299 279 300 $payload = []; 280 301 $payload['name'] = $tags; … … 282 303 $payload['type'] = 'tags'; 283 304 $payload['user'][] = self::add_user_data([]); 284 305 285 306 $this->schedule_intercom_call($payload); 286 287 } 288 289 } 290 291 private function create_transient_id($payload) { 292 293 return 'iwp_transient_'.sha1(json_encode($payload)); 294 } 295 307 308 } 309 310 } 311 312 private function create_transient_id($payload) 313 { 314 315 return 'iwp_transient_' . sha1(json_encode($payload)); 316 } 317 296 318 // Add the User ID or Email to Intercom Payload 297 319 // Can assign by custom User ID or Email 298 320 // Default is ['email' => 'john.smith@example.com'] 299 300 private function add_user_data($payload) { 301 321 322 private function add_user_data($payload) 323 { 324 302 325 $key = apply_filters('iwp_user_identifier_key', 'email', $this->user_id); 303 326 304 327 $value = apply_filters('iwp_user_identifier_value', $this->wp_user->user_email, $this->user_id); 305 306 $payload["" .$key.""] = $value;307 328 329 $payload["" . $key . ""] = $value; 330 308 331 $payload = apply_filters('iwp_add_user_data_payload', $payload); 309 332 310 333 return $payload; 311 312 } 313 334 335 } 336 314 337 //Allow users to fine tune event tracking 315 316 private function is_event_permitted($event) { 317 318 if(in_array($event, apply_filters( 'iwp_permitted_events', [] ))) { 319 320 return true; 321 } 322 338 339 private function is_event_permitted($event) 340 { 341 342 if (in_array($event, apply_filters('iwp_permitted_events', []))) { 343 344 return true; 345 } 346 323 347 error_log("$event is not permitted!"); 324 348 325 349 return false; 326 350 } 327 351 328 352 } -
highways-sync-for-intercom/trunk/includes/lib/action-scheduler/action-scheduler.php
r2261884 r2378844 6 6 * Author: Automattic 7 7 * Author URI: https://automattic.com/ 8 * Version: 3.1. 28 * Version: 3.1.6 9 9 * License: GPLv3 10 10 * … … 26 26 */ 27 27 28 if ( ! function_exists( 'action_scheduler_register_3_dot_1_dot_ 2' ) ) {28 if ( ! function_exists( 'action_scheduler_register_3_dot_1_dot_6' ) ) { 29 29 30 30 if ( ! class_exists( 'ActionScheduler_Versions' ) ) { … … 33 33 } 34 34 35 add_action( 'plugins_loaded', 'action_scheduler_register_3_dot_1_dot_ 2', 0, 0 );35 add_action( 'plugins_loaded', 'action_scheduler_register_3_dot_1_dot_6', 0, 0 ); 36 36 37 function action_scheduler_register_3_dot_1_dot_ 2() {37 function action_scheduler_register_3_dot_1_dot_6() { 38 38 $versions = ActionScheduler_Versions::instance(); 39 $versions->register( '3.1. 2', 'action_scheduler_initialize_3_dot_1_dot_2' );39 $versions->register( '3.1.6', 'action_scheduler_initialize_3_dot_1_dot_6' ); 40 40 } 41 41 42 function action_scheduler_initialize_3_dot_1_dot_ 2() {42 function action_scheduler_initialize_3_dot_1_dot_6() { 43 43 require_once( 'classes/abstracts/ActionScheduler.php' ); 44 44 ActionScheduler::init( __FILE__ ); … … 47 47 // Support usage in themes - load this version if no plugin has loaded a version yet. 48 48 if ( did_action( 'plugins_loaded' ) && ! class_exists( 'ActionScheduler' ) ) { 49 action_scheduler_initialize_3_dot_1_dot_ 2();49 action_scheduler_initialize_3_dot_1_dot_6(); 50 50 do_action( 'action_scheduler_pre_theme_init' ); 51 51 ActionScheduler_Versions::initialize_latest_version(); -
highways-sync-for-intercom/trunk/includes/lib/action-scheduler/classes/ActionScheduler_ActionFactory.php
r2248936 r2378844 23 23 case ActionScheduler_Store::STATUS_CANCELED : 24 24 $action_class = 'ActionScheduler_CanceledAction'; 25 if ( ! is_null( $schedule ) && ! is_a( $schedule, 'ActionScheduler_CanceledSchedule' ) ) {25 if ( ! is_null( $schedule ) && ! is_a( $schedule, 'ActionScheduler_CanceledSchedule' ) && ! is_a( $schedule, 'ActionScheduler_NullSchedule' ) ) { 26 26 $schedule = new ActionScheduler_CanceledSchedule( $schedule->get_date() ); 27 27 } … … 62 62 * @param string $group A group to put the action in 63 63 * 64 * @return stringThe ID of the stored action64 * @return int The ID of the stored action 65 65 */ 66 66 public function async( $hook, $args = array(), $group = '' ) { … … 76 76 * @param string $group A group to put the action in 77 77 * 78 * @return stringThe ID of the stored action78 * @return int The ID of the stored action 79 79 */ 80 80 public function single( $hook, $args = array(), $when = null, $group = '' ) { … … 94 94 * @param string $group A group to put the action in 95 95 * 96 * @return stringThe ID of the stored action96 * @return int The ID of the stored action 97 97 */ 98 98 public function recurring( $hook, $args = array(), $first = null, $interval = null, $group = '' ) { … … 117 117 * @param string $group A group to put the action in 118 118 * 119 * @return stringThe ID of the stored action119 * @return int The ID of the stored action 120 120 */ 121 121 public function cron( $hook, $args = array(), $base_timestamp = null, $schedule = null, $group = '' ) { … … 171 171 * @param ActionScheduler_Action $action 172 172 * 173 * @return stringThe ID of the stored action173 * @return int The ID of the stored action 174 174 */ 175 175 protected function store( ActionScheduler_Action $action ) { -
highways-sync-for-intercom/trunk/includes/lib/action-scheduler/classes/ActionScheduler_AdminView.php
r2248936 r2378844 10 10 11 11 private static $screen_id = 'tools_page_action-scheduler'; 12 13 /** @var ActionScheduler_ListTable */ 14 protected $list_table; 12 15 13 16 /** … … 83 86 */ 84 87 public function process_admin_ui() { 85 $table = new ActionScheduler_ListTable( ActionScheduler::store(), ActionScheduler::logger(), ActionScheduler::runner() ); 86 $table->process_actions(); 88 $this->get_list_table(); 87 89 } 88 90 … … 91 93 */ 92 94 public function render_admin_ui() { 93 $table = new ActionScheduler_ListTable( ActionScheduler::store(), ActionScheduler::logger(), ActionScheduler::runner());95 $table = $this->get_list_table(); 94 96 $table->display_page(); 97 } 98 99 /** 100 * Get the admin UI object and process any requested actions. 101 * 102 * @return ActionScheduler_ListTable 103 */ 104 protected function get_list_table() { 105 if ( null === $this->list_table ) { 106 $this->list_table = new ActionScheduler_ListTable( ActionScheduler::store(), ActionScheduler::logger(), ActionScheduler::runner() ); 107 $this->list_table->process_actions(); 108 } 109 110 return $this->list_table; 95 111 } 96 112 -
highways-sync-for-intercom/trunk/includes/lib/action-scheduler/classes/ActionScheduler_DataController.php
r2261884 r2378844 102 102 */ 103 103 public static function set_sleep_time( $sleep_time ) { 104 self::$sleep_time = $sleep_time;104 self::$sleep_time = (int) $sleep_time; 105 105 } 106 106 … … 111 111 */ 112 112 public static function set_free_ticks( $free_ticks ) { 113 self::$free_ticks = $free_ticks;113 self::$free_ticks = (int) $free_ticks; 114 114 } 115 115 -
highways-sync-for-intercom/trunk/includes/lib/action-scheduler/classes/ActionScheduler_ListTable.php
r2248936 r2378844 308 308 */ 309 309 protected function maybe_render_actions( $row, $column_name ) { 310 if ( 'pending' === strtolower( $row[ 'status'] ) ) {310 if ( 'pending' === strtolower( $row[ 'status_name' ] ) ) { 311 311 return parent::maybe_render_actions( $row, $column_name ); 312 312 } … … 319 319 * 320 320 * Notifications: 321 * 1. When the maximum number of tasks are being executed simultaneously 322 * 2. Notifications when a task is manually executed 321 * 1. When the maximum number of tasks are being executed simultaneously. 322 * 2. Notifications when a task is manually executed. 323 * 3. Tables are missing. 323 324 */ 324 325 public function display_admin_notices() { 326 global $wpdb; 327 328 if ( ( is_a( $this->store, 'ActionScheduler_HybridStore' ) || is_a( $this->store, 'ActionScheduler_DBStore' ) ) && apply_filters( 'action_scheduler_enable_recreate_data_store', true ) ) { 329 $table_list = array( 330 'actionscheduler_actions', 331 'actionscheduler_logs', 332 'actionscheduler_groups', 333 'actionscheduler_claims', 334 ); 335 336 $found_tables = $wpdb->get_col( "SHOW TABLES LIKE '{$wpdb->prefix}actionscheduler%'" ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared 337 foreach ( $table_list as $table_name ) { 338 if ( ! in_array( $wpdb->prefix . $table_name, $found_tables ) ) { 339 $this->admin_notices[] = array( 340 'class' => 'error', 341 'message' => __( 'It appears one or more database tables were missing. Attempting to re-create the missing table(s).' , 'action-scheduler' ), 342 ); 343 $this->recreate_tables(); 344 parent::display_admin_notices(); 345 346 return; 347 } 348 } 349 } 350 325 351 if ( $this->runner->has_maximum_concurrent_batches() ) { 326 352 $claim_count = $this->store->get_claim_count(); … … 475 501 476 502 /** 503 * Force the data store schema updates. 504 */ 505 protected function recreate_tables() { 506 if ( is_a( $this->store, 'ActionScheduler_HybridStore' ) ) { 507 $store = $this->store; 508 } else { 509 $store = new ActionScheduler_HybridStore(); 510 } 511 add_action( 'action_scheduler/created_table', array( $store, 'set_autoincrement' ), 10, 2 ); 512 513 $store_schema = new ActionScheduler_StoreSchema(); 514 $logger_schema = new ActionScheduler_LoggerSchema(); 515 $store_schema->register_tables( true ); 516 $logger_schema->register_tables( true ); 517 518 remove_action( 'action_scheduler/created_table', array( $store, 'set_autoincrement' ), 10 ); 519 } 520 /** 477 521 * Implements the logic behind processing an action once an action link is clicked on the list table. 478 522 * … … 528 572 continue; 529 573 } 574 if ( is_a( $action, 'ActionScheduler_NullAction' ) ) { 575 continue; 576 } 530 577 $this->items[ $action_id ] = array( 531 578 'ID' => $action_id, 532 579 'hook' => $action->get_hook(), 580 'status_name' => $this->store->get_status( $action_id ), 533 581 'status' => $status_labels[ $this->store->get_status( $action_id ) ], 534 582 'args' => $action->get_args(), -
highways-sync-for-intercom/trunk/includes/lib/action-scheduler/classes/ActionScheduler_QueueRunner.php
r2248936 r2378844 51 51 add_filter( 'cron_schedules', array( self::instance(), 'add_wp_cron_schedule' ) ); 52 52 53 // Check for and remove any WP Cron hook scheduled by Action Scheduler < 3.0.0, which didn't include the $context param 54 $next_timestamp = wp_next_scheduled( self::WP_CRON_HOOK ); 55 if ( $next_timestamp ) { 56 wp_unschedule_event( $next_timestamp, self::WP_CRON_HOOK ); 57 } 58 53 59 $cron_context = array( 'WP Cron' ); 54 60 55 61 if ( ! wp_next_scheduled( self::WP_CRON_HOOK, $cron_context ) ) { 56 57 // Check for and remove any WP Cron hook scheduled by Action Scheduler < 3.0.0, which didn't include the $context param58 $next_timestamp = wp_next_scheduled( self::WP_CRON_HOOK );59 if ( $next_timestamp ) {60 wp_unschedule_event( $next_timestamp, self::WP_CRON_HOOK );61 }62 63 62 $schedule = apply_filters( 'action_scheduler_run_schedule', self::WP_CRON_SCHEDULE ); 64 63 wp_schedule_event( time(), $schedule, self::WP_CRON_HOOK, $cron_context ); -
highways-sync-for-intercom/trunk/includes/lib/action-scheduler/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php
r2248936 r2378844 49 49 $hooks = array_filter( array_map( 'trim', $hooks ) ); 50 50 $group = \WP_CLI\Utils\get_flag_value( $assoc_args, 'group', '' ); 51 $free_on = \WP_CLI\Utils\get_flag_value( $assoc_args, 'free-memory-on', '');52 $sleep = \WP_CLI\Utils\get_flag_value( $assoc_args, 'pause', '');51 $free_on = \WP_CLI\Utils\get_flag_value( $assoc_args, 'free-memory-on', 50 ); 52 $sleep = \WP_CLI\Utils\get_flag_value( $assoc_args, 'pause', 0 ); 53 53 $force = \WP_CLI\Utils\get_flag_value( $assoc_args, 'force', false ); 54 54 -
highways-sync-for-intercom/trunk/includes/lib/action-scheduler/classes/abstracts/ActionScheduler.php
r2261884 r2378844 12 12 /** @var ActionScheduler_ActionFactory */ 13 13 private static $factory = NULL; 14 /** @var bool */ 15 private static $data_store_initialized = false; 14 16 15 17 public static function factory() { … … 138 140 do_action( 'action_scheduler_pre_init' ); 139 141 140 require_once( self::plugin_path( 'functions.php') );142 require_once( self::plugin_path( 'functions.php' ) ); 141 143 ActionScheduler_DataController::init(); 142 144 143 $store = self::store(); 144 add_action( 'init', array( $store, 'init' ), 1, 0 ); 145 146 $logger = self::logger(); 147 add_action( 'init', array( $logger, 'init' ), 1, 0 ); 148 149 $runner = self::runner(); 150 add_action( 'init', array( $runner, 'init' ), 1, 0 ); 151 145 $store = self::store(); 146 $logger = self::logger(); 147 $runner = self::runner(); 152 148 $admin_view = self::admin_view(); 153 add_action( 'init', array( $admin_view, 'init' ), 0, 0 ); // run before $store::init()154 149 155 150 // Ensure initialization on plugin activation. 156 if ( did_action( 'init' ) ) { 151 if ( ! did_action( 'init' ) ) { 152 add_action( 'init', array( $admin_view, 'init' ), 0, 0 ); // run before $store::init() 153 add_action( 'init', array( $store, 'init' ), 1, 0 ); 154 add_action( 'init', array( $logger, 'init' ), 1, 0 ); 155 add_action( 'init', array( $runner, 'init' ), 1, 0 ); 156 } else { 157 $admin_view->init(); 157 158 $store->init(); 158 159 $logger->init(); 159 160 $runner->init(); 160 $admin_view->init();161 161 } 162 162 163 163 if ( apply_filters( 'action_scheduler_load_deprecated_functions', true ) ) { 164 require_once( self::plugin_path( 'deprecated/functions.php') );164 require_once( self::plugin_path( 'deprecated/functions.php' ) ); 165 165 } 166 166 … … 173 173 } 174 174 175 self::$data_store_initialized = true; 176 175 177 /** 176 178 * Handle WP comment cleanup after migration. … … 181 183 182 184 add_action( 'action_scheduler/migration_complete', 'ActionScheduler_WPCommentCleaner::maybe_schedule_cleanup' ); 185 } 186 187 /** 188 * Check whether the AS data store has been initialized. 189 * 190 * @param string $function_name The name of the function being called. Optional. Default `null`. 191 * @return bool 192 */ 193 public static function is_initialized( $function_name = null ) { 194 if ( ! self::$data_store_initialized && ! empty( $function_name ) ) { 195 $message = sprintf( __( '%s() was called before the Action Scheduler data store was initialized', 'action-scheduler' ), esc_attr( $function_name ) ); 196 error_log( $message, E_WARNING ); 197 } 198 199 return self::$data_store_initialized; 183 200 } 184 201 … … 275 292 return as_get_datetime_object( $when, $timezone ); 276 293 } 294 295 /** 296 * Issue deprecated warning if an Action Scheduler function is called in the shutdown hook. 297 * 298 * @param string $function_name The name of the function being called. 299 * @deprecated 3.1.6. 300 */ 301 public static function check_shutdown_hook( $function_name ) { 302 _deprecated_function( __FUNCTION__, '3.1.6' ); 303 } 277 304 } -
highways-sync-for-intercom/trunk/includes/lib/action-scheduler/classes/abstracts/ActionScheduler_Abstract_ListTable.php
r2248936 r2378844 141 141 // Detect when a bulk action is being triggered. 142 142 $action = $this->current_action(); 143 144 143 if ( ! $action ) { 145 144 return; … … 162 161 163 162 /** 164 * Default code for deleting entries. We trust ids_sql because it is163 * Default code for deleting entries. 165 164 * validated already by process_bulk_action() 166 165 */ 167 166 protected function bulk_delete( array $ids, $ids_sql ) { 168 global $wpdb; 169 170 $wpdb->query( "DELETE FROM {$this->table_name} WHERE {$this->ID} IN $ids_sql" ); 167 $store = ActionScheduler::store(); 168 foreach ( $ids as $action_id ) { 169 $store->delete( $action_id ); 170 } 171 171 } 172 172 … … 643 643 public function process_actions() { 644 644 $this->process_bulk_action(); 645 646 645 $this->process_row_actions(); 647 646 -
highways-sync-for-intercom/trunk/includes/lib/action-scheduler/classes/abstracts/ActionScheduler_Abstract_Schema.php
r2248936 r2378844 26 26 * Register tables with WordPress, and create them if needed. 27 27 * 28 * @param bool $force_update Optional. Default false. Use true to always run the schema update. 29 * 28 30 * @return void 29 31 */ 30 public function register_tables( ) {32 public function register_tables( $force_update = false ) { 31 33 global $wpdb; 32 34 … … 39 41 40 42 // create the tables 41 if ( $this->schema_update_required() ) {43 if ( $this->schema_update_required() || $force_update ) { 42 44 foreach ( $this->tables as $table ) { 43 45 $this->update_table( $table ); -
highways-sync-for-intercom/trunk/includes/lib/action-scheduler/classes/abstracts/ActionScheduler_Logger.php
r2248936 r2378844 131 131 $message = __( 'action ignored', 'action-scheduler' ); 132 132 } 133 $this->log( $action_id, __( 'action ignored', 'action-scheduler' ));133 $this->log( $action_id, $message ); 134 134 } 135 135 -
highways-sync-for-intercom/trunk/includes/lib/action-scheduler/classes/abstracts/ActionScheduler_Store.php
r2248936 r2378844 25 25 * schedule. 26 26 * 27 * @return stringThe action ID27 * @return int The action ID 28 28 */ 29 29 abstract public function save_action( ActionScheduler_Action $action, DateTime $scheduled_date = NULL ); -
highways-sync-for-intercom/trunk/includes/lib/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php
r2248936 r2378844 57 57 } 58 58 59 $wpdb->insert( $wpdb->actionscheduler_actions, $data ); 59 $table_name = ! empty( $wpdb->actionscheduler_actions ) ? $wpdb->actionscheduler_actions : $wpdb->prefix . 'actionscheduler_actions'; 60 $wpdb->insert( $table_name, $data ); 60 61 $action_id = $wpdb->insert_id; 61 62 -
highways-sync-for-intercom/trunk/includes/lib/action-scheduler/classes/data-stores/ActionScheduler_HybridStore.php
r2248936 r2378844 78 78 /** @var \wpdb $wpdb */ 79 79 global $wpdb; 80 $wpdb->insert( 80 /** 81 * A default date of '0000-00-00 00:00:00' is invalid in MySQL 5.7 when configured with 82 * sql_mode including both STRICT_TRANS_TABLES and NO_ZERO_DATE. 83 */ 84 $default_date = new DateTime( 'tomorrow' ); 85 $null_action = new ActionScheduler_NullAction(); 86 $date_gmt = $this->get_scheduled_date_string( $null_action, $default_date ); 87 $date_local = $this->get_scheduled_date_string_local( $null_action, $default_date ); 88 89 $row_count = $wpdb->insert( 81 90 $wpdb->{ActionScheduler_StoreSchema::ACTIONS_TABLE}, 82 91 [ 83 'action_id' => $this->demarkation_id, 84 'hook' => '', 85 'status' => '', 92 'action_id' => $this->demarkation_id, 93 'hook' => '', 94 'status' => '', 95 'scheduled_date_gmt' => $date_gmt, 96 'scheduled_date_local' => $date_local, 97 'last_attempt_gmt' => $date_gmt, 98 'last_attempt_local' => $date_local, 86 99 ] 87 100 ); 88 $wpdb->delete( 89 $wpdb->{ActionScheduler_StoreSchema::ACTIONS_TABLE}, 90 [ 'action_id' => $this->demarkation_id ] 91 ); 101 if ( $row_count > 0 ) { 102 $wpdb->delete( 103 $wpdb->{ActionScheduler_StoreSchema::ACTIONS_TABLE}, 104 [ 'action_id' => $this->demarkation_id ] 105 ); 106 } 92 107 } 93 108 } … … 221 236 * @param ActionScheduler_Action $action Action object to be saved. 222 237 * @param DateTime $date Optional. Schedule date. Default null. 238 * 239 * @return int The action ID 223 240 */ 224 241 public function save_action( ActionScheduler_Action $action, DateTime $date = null ) { … … 232 249 */ 233 250 public function fetch_action( $action_id ) { 234 if ( $action_id < $this->demarkation_id ) { 235 return $this->secondary_store->fetch_action( $action_id ); 251 $store = $this->get_store_from_action_id( $action_id, true ); 252 if ( $store ) { 253 return $store->fetch_action( $action_id ); 236 254 } else { 237 return $this->primary_store->fetch_action( $action_id);255 return new ActionScheduler_NullAction(); 238 256 } 239 257 } … … 245 263 */ 246 264 public function cancel_action( $action_id ) { 247 if ( $action_id < $this->demarkation_id ) { 248 $this->secondary_store->cancel_action( $action_id ); 265 $store = $this->get_store_from_action_id( $action_id ); 266 if ( $store ) { 267 $store->cancel_action( $action_id ); 268 } 269 } 270 271 /** 272 * Delete an existing action whether migrated or not. 273 * 274 * @param int $action_id Action ID. 275 */ 276 public function delete_action( $action_id ) { 277 $store = $this->get_store_from_action_id( $action_id ); 278 if ( $store ) { 279 $store->delete_action( $action_id ); 280 } 281 } 282 283 /** 284 * Get the schedule date an existing action whether migrated or not. 285 * 286 * @param int $action_id Action ID. 287 */ 288 public function get_date( $action_id ) { 289 $store = $this->get_store_from_action_id( $action_id ); 290 if ( $store ) { 291 return $store->get_date( $action_id ); 249 292 } else { 250 $this->primary_store->cancel_action( $action_id ); 251 } 252 } 253 254 /** 255 * Delete an existing action whether migrated or not. 256 * 257 * @param int $action_id Action ID. 258 */ 259 public function delete_action( $action_id ) { 260 if ( $action_id < $this->demarkation_id ) { 261 $this->secondary_store->delete_action( $action_id ); 293 return null; 294 } 295 } 296 297 /** 298 * Mark an existing action as failed whether migrated or not. 299 * 300 * @param int $action_id Action ID. 301 */ 302 public function mark_failure( $action_id ) { 303 $store = $this->get_store_from_action_id( $action_id ); 304 if ( $store ) { 305 $store->mark_failure( $action_id ); 306 } 307 } 308 309 /** 310 * Log the execution of an existing action whether migrated or not. 311 * 312 * @param int $action_id Action ID. 313 */ 314 public function log_execution( $action_id ) { 315 $store = $this->get_store_from_action_id( $action_id ); 316 if ( $store ) { 317 $store->log_execution( $action_id ); 318 } 319 } 320 321 /** 322 * Mark an existing action complete whether migrated or not. 323 * 324 * @param int $action_id Action ID. 325 */ 326 public function mark_complete( $action_id ) { 327 $store = $this->get_store_from_action_id( $action_id ); 328 if ( $store ) { 329 $store->mark_complete( $action_id ); 330 } 331 } 332 333 /** 334 * Get an existing action status whether migrated or not. 335 * 336 * @param int $action_id Action ID. 337 */ 338 public function get_status( $action_id ) { 339 $store = $this->get_store_from_action_id( $action_id ); 340 if ( $store ) { 341 return $store->get_status( $action_id ); 342 } 343 return null; 344 } 345 346 /** 347 * Return which store an action is stored in. 348 * 349 * @param int $action_id ID of the action. 350 * @param bool $primary_first Optional flag indicating search the primary store first. 351 * @return ActionScheduler_Store 352 */ 353 protected function get_store_from_action_id( $action_id, $primary_first = false ) { 354 if ( $primary_first ) { 355 $stores = [ 356 $this->primary_store, 357 $this->secondary_store, 358 ]; 359 } elseif ( $action_id < $this->demarkation_id ) { 360 $stores = [ 361 $this->secondary_store, 362 $this->primary_store, 363 ]; 262 364 } else { 263 $this->primary_store->delete_action( $action_id ); 264 } 265 } 266 267 /** 268 * Get the schedule date an existing action whether migrated or not. 269 * 270 * @param int $action_id Action ID. 271 */ 272 public function get_date( $action_id ) { 273 if ( $action_id < $this->demarkation_id ) { 274 return $this->secondary_store->get_date( $action_id ); 275 } else { 276 return $this->primary_store->get_date( $action_id ); 277 } 278 } 279 280 /** 281 * Mark an existing action as failed whether migrated or not. 282 * 283 * @param int $action_id Action ID. 284 */ 285 public function mark_failure( $action_id ) { 286 if ( $action_id < $this->demarkation_id ) { 287 $this->secondary_store->mark_failure( $action_id ); 288 } else { 289 $this->primary_store->mark_failure( $action_id ); 290 } 291 } 292 293 /** 294 * Log the execution of an existing action whether migrated or not. 295 * 296 * @param int $action_id Action ID. 297 */ 298 public function log_execution( $action_id ) { 299 if ( $action_id < $this->demarkation_id ) { 300 $this->secondary_store->log_execution( $action_id ); 301 } else { 302 $this->primary_store->log_execution( $action_id ); 303 } 304 } 305 306 /** 307 * Mark an existing action complete whether migrated or not. 308 * 309 * @param int $action_id Action ID. 310 */ 311 public function mark_complete( $action_id ) { 312 if ( $action_id < $this->demarkation_id ) { 313 $this->secondary_store->mark_complete( $action_id ); 314 } else { 315 $this->primary_store->mark_complete( $action_id ); 316 } 317 } 318 319 /** 320 * Get an existing action status whether migrated or not. 321 * 322 * @param int $action_id Action ID. 323 */ 324 public function get_status( $action_id ) { 325 if ( $action_id < $this->demarkation_id ) { 326 return $this->secondary_store->get_status( $action_id ); 327 } else { 328 return $this->primary_store->get_status( $action_id ); 329 } 330 } 331 365 $stores = [ 366 $this->primary_store, 367 ]; 368 } 369 370 foreach ( $stores as $store ) { 371 $action = $store->fetch_action( $action_id ); 372 if ( ! is_a( $action, 'ActionScheduler_NullAction' ) ) { 373 return $store; 374 } 375 } 376 return null; 377 } 332 378 333 379 /* * * * * * * * * * * * * * * * * * * * * * * * * * * -
highways-sync-for-intercom/trunk/includes/lib/action-scheduler/classes/migration/Controller.php
r2248936 r2378844 150 150 add_filter( 'action_scheduler_logger_class', array( $this, 'get_logger_class' ), 100, 1 ); 151 151 add_action( 'init', array( $this, 'maybe_hook_migration' ) ); 152 add_action( ' shutdown', array( $this, 'schedule_migration' ), 0, 0);152 add_action( 'wp_loaded', array( $this, 'schedule_migration' ) ); 153 153 154 154 // Action Scheduler may be displayed as a Tools screen or WooCommerce > Status administration screen -
highways-sync-for-intercom/trunk/includes/lib/action-scheduler/classes/migration/Scheduler.php
r2248936 r2378844 84 84 85 85 if ( empty( $when ) ) { 86 $when = time() ;86 $when = time() + MINUTE_IN_SECONDS; 87 87 } 88 88 -
highways-sync-for-intercom/trunk/includes/lib/action-scheduler/functions.php
r2248936 r2378844 11 11 * @param array $args Arguments to pass when the hook triggers. 12 12 * @param string $group The group to assign this job to. 13 * @return stringThe action ID.13 * @return int The action ID. 14 14 */ 15 15 function as_enqueue_async_action( $hook, $args = array(), $group = '' ) { 16 if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { 17 return 0; 18 } 16 19 return ActionScheduler::factory()->async( $hook, $args, $group ); 17 20 } … … 20 23 * Schedule an action to run one time 21 24 * 22 * @param int $timestamp When the job will run 23 * @param string $hook The hook to trigger 24 * @param array $args Arguments to pass when the hook triggers 25 * @param string $group The group to assign this job to 26 * 27 * @return string The job ID25 * @param int $timestamp When the job will run. 26 * @param string $hook The hook to trigger. 27 * @param array $args Arguments to pass when the hook triggers. 28 * @param string $group The group to assign this job to. 29 * 30 * @return int The action ID. 28 31 */ 29 32 function as_schedule_single_action( $timestamp, $hook, $args = array(), $group = '' ) { 33 if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { 34 return 0; 35 } 30 36 return ActionScheduler::factory()->single( $hook, $args, $timestamp, $group ); 31 37 } … … 34 40 * Schedule a recurring action 35 41 * 36 * @param int $timestamp When the first instance of the job will run 37 * @param int $interval_in_seconds How long to wait between runs 38 * @param string $hook The hook to trigger 39 * @param array $args Arguments to pass when the hook triggers 40 * @param string $group The group to assign this job to 41 * 42 * @return string The job ID42 * @param int $timestamp When the first instance of the job will run. 43 * @param int $interval_in_seconds How long to wait between runs. 44 * @param string $hook The hook to trigger. 45 * @param array $args Arguments to pass when the hook triggers. 46 * @param string $group The group to assign this job to. 47 * 48 * @return int The action ID. 43 49 */ 44 50 function as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '' ) { 51 if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { 52 return 0; 53 } 45 54 return ActionScheduler::factory()->recurring( $hook, $args, $timestamp, $interval_in_seconds, $group ); 46 55 } … … 63 72 * | +-------------------- hour (0 - 23) 64 73 * +------------------------- min (0 - 59) 65 * @param string $hook The hook to trigger 66 * @param array $args Arguments to pass when the hook triggers 67 * @param string $group The group to assign this job to 68 * 69 * @return string The job ID74 * @param string $hook The hook to trigger. 75 * @param array $args Arguments to pass when the hook triggers. 76 * @param string $group The group to assign this job to. 77 * 78 * @return int The action ID. 70 79 */ 71 80 function as_schedule_cron_action( $timestamp, $schedule, $hook, $args = array(), $group = '' ) { 81 if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { 82 return 0; 83 } 72 84 return ActionScheduler::factory()->cron( $hook, $args, $timestamp, $schedule, $group ); 73 85 } … … 83 95 * by this method also. 84 96 * 85 * @param string $hook The hook that the job will trigger 86 * @param array $args Args that would have been passed to the job 87 * @param string $group 88 * 89 * @return string The scheduled action ID if a scheduled action was found, or empty stringif no matching action found.97 * @param string $hook The hook that the job will trigger. 98 * @param array $args Args that would have been passed to the job. 99 * @param string $group The group the job is assigned to. 100 * 101 * @return string|null The scheduled action ID if a scheduled action was found, or null if no matching action found. 90 102 */ 91 103 function as_unschedule_action( $hook, $args = array(), $group = '' ) { 104 if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { 105 return 0; 106 } 92 107 $params = array(); 93 108 if ( is_array($args) ) { … … 109 124 * Cancel all occurrences of a scheduled action. 110 125 * 111 * @param string $hook The hook that the job will trigger 112 * @param array $args Args that would have been passed to the job 113 * @param string $group 126 * @param string $hook The hook that the job will trigger. 127 * @param array $args Args that would have been passed to the job. 128 * @param string $group The group the job is assigned to. 114 129 */ 115 130 function as_unschedule_all_actions( $hook, $args = array(), $group = '' ) { 131 if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { 132 return; 133 } 116 134 if ( empty( $args ) ) { 117 135 if ( ! empty( $hook ) && empty( $group ) ) { … … 132 150 * Check if there is an existing action in the queue with a given hook, args and group combination. 133 151 * 134 * An action in the queue could be pending, in-progress or a ysnc. If the is pending for a time in152 * An action in the queue could be pending, in-progress or async. If the is pending for a time in 135 153 * future, its scheduled date will be returned as a timestamp. If it is currently being run, or an 136 154 * async action sitting in the queue waiting to be processed, in which case boolean true will be … … 145 163 */ 146 164 function as_next_scheduled_action( $hook, $args = NULL, $group = '' ) { 165 if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { 166 return false; 167 } 147 168 $params = array(); 148 169 if ( is_array($args) ) { … … 192 213 * 'order' => 'ASC' 193 214 * 194 * @param string $return_format OBJECT, ARRAY_A, or ids 215 * @param string $return_format OBJECT, ARRAY_A, or ids. 195 216 * 196 217 * @return array 197 218 */ 198 219 function as_get_scheduled_actions( $args = array(), $return_format = OBJECT ) { 220 if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { 221 return array(); 222 } 199 223 $store = ActionScheduler::store(); 200 224 foreach ( array('date', 'modified') as $key ) { … … 235 259 * the PHP default. 236 260 * 237 * @param mixed $date_string A date/time string. Valid formats are explained in http://php.net/manual/en/datetime.formats.php 238 * @param string $timezone A timezone identifier, like UTC or Europe/Lisbon. The list of valid identifiers is available http://php.net/manual/en/timezones.php 261 * @param mixed $date_string A date/time string. Valid formats are explained in http://php.net/manual/en/datetime.formats.php. 262 * @param string $timezone A timezone identifier, like UTC or Europe/Lisbon. The list of valid identifiers is available http://php.net/manual/en/timezones.php. 239 263 * 240 264 * @return ActionScheduler_DateTime -
highways-sync-for-intercom/trunk/readme.txt
r2285958 r2378844 96 96 == Changelog == 97 97 98 = 1.0.6 = 99 * Added: Updated Action Scheduler to 3.1.6 100 * Added: Logging to WooCommerce Logs (If installed and available) 101 98 102 = 1.0.5 = 99 103 * FIX: Bug Fix for Chat Bubble (Logged Out Users)
Note: See TracChangeset
for help on using the changeset viewer.