Version Description
Download this release
Release Info
Developer | anderly |
Plugin | WooCommerce MailChimp |
Version | 2.1.15 |
Comparing to | |
See all releases |
Code changes from version 2.1.14 to 2.1.15
- includes/class-ss-wc-mailchimp-api.php +25 -26
- includes/class-ss-wc-mailchimp-plugin.php +25 -2
- includes/class-ss-wc-mailchimp.php +2 -0
- includes/class-sswcmc-logger.php +102 -0
- readme.txt +4 -1
- trunk/COPYRIGHT.txt +28 -0
- trunk/LICENSE.txt +674 -0
- trunk/assets/banner-1544x500.png +0 -0
- trunk/assets/banner-772x250.png +0 -0
- trunk/assets/css/style.css +48 -0
- trunk/assets/icon-128x128.png +0 -0
- trunk/assets/icon-256x256.png +0 -0
- trunk/assets/icon-500x500.png +0 -0
- trunk/assets/icon.svg +141 -0
- trunk/assets/js/woocommerce-mailchimp-admin.js +340 -0
- trunk/assets/screenshot-1.png +0 -0
- trunk/assets/screenshot-2.png +0 -0
- trunk/config/default-settings.php +14 -0
- trunk/includes/class-ss-wc-mailchimp-admin-notices.php +193 -0
- trunk/includes/class-ss-wc-mailchimp-api.php +294 -0
- trunk/includes/class-ss-wc-mailchimp-compatibility.php +297 -0
- trunk/includes/class-ss-wc-mailchimp-handler.php +476 -0
- trunk/includes/class-ss-wc-mailchimp-migrator.php +72 -0
- trunk/includes/class-ss-wc-mailchimp-plugin.php +623 -0
- trunk/includes/class-ss-wc-mailchimp.php +401 -0
- trunk/includes/class-ss-wc-settings-mailchimp.php +706 -0
- trunk/includes/class-sswcmc-logger.php +102 -0
- trunk/includes/helper-functions.php +24 -0
- trunk/includes/lib/action-scheduler/.github/release-drafter.yml +15 -0
- trunk/includes/lib/action-scheduler/.gitignore +3 -0
- trunk/includes/lib/action-scheduler/.travis.yml +37 -0
- trunk/includes/lib/action-scheduler/README.md +41 -0
- trunk/includes/lib/action-scheduler/action-scheduler.php +47 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler.php +128 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_Abstract_ListTable.php +656 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_Abstract_QueueRunner.php +216 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_Action.php +75 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_ActionClaim.php +23 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_ActionFactory.php +111 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_AdminView.php +78 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_CanceledAction.php +21 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_Compatibility.php +99 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_CronSchedule.php +50 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_DateTime.php +76 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_Exception.php +11 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_FatalErrorMonitor.php +55 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_FinishedAction.php +16 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_IntervalSchedule.php +62 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_InvalidActionException.php +28 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_ListTable.php +526 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_LogEntry.php +67 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_Logger.php +98 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_NullAction.php +16 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_NullLogEntry.php +11 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_NullSchedule.php +19 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_QueueCleaner.php +144 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_QueueRunner.php +115 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_Schedule.php +18 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_SimpleSchedule.php +44 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_Store.php +212 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_TimezoneHelper.php +152 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_Versions.php +62 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_WPCLI_QueueRunner.php +205 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_WPCLI_Scheduler_command.php +145 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_wpCommentLogger.php +240 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_wpPostStore.php +757 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_wpPostStore_PostStatusRegistrar.php +57 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_wpPostStore_PostTypeRegistrar.php +50 -0
- trunk/includes/lib/action-scheduler/classes/ActionScheduler_wpPostStore_TaxonomyRegistrar.php +26 -0
- trunk/includes/lib/action-scheduler/codecov.yml +13 -0
- trunk/includes/lib/action-scheduler/composer.json +11 -0
- trunk/includes/lib/action-scheduler/composer.lock +2909 -0
- trunk/includes/lib/action-scheduler/deprecated/ActionScheduler_Abstract_QueueRunner_Deprecated.php +27 -0
- trunk/includes/lib/action-scheduler/deprecated/ActionScheduler_AdminView_Deprecated.php +147 -0
- trunk/includes/lib/action-scheduler/deprecated/functions.php +126 -0
- trunk/includes/lib/action-scheduler/docs/CNAME +1 -0
- trunk/includes/lib/action-scheduler/docs/_config.yml +7 -0
- trunk/includes/lib/action-scheduler/docs/_layouts/default.html +57 -0
- trunk/includes/lib/action-scheduler/docs/admin.md +22 -0
- trunk/includes/lib/action-scheduler/docs/android-chrome-192x192.png +0 -0
- trunk/includes/lib/action-scheduler/docs/android-chrome-256x256.png +0 -0
- trunk/includes/lib/action-scheduler/docs/api.md +179 -0
- trunk/includes/lib/action-scheduler/docs/apple-touch-icon.png +0 -0
- trunk/includes/lib/action-scheduler/docs/assets/css/style.scss +32 -0
- trunk/includes/lib/action-scheduler/docs/browserconfig.xml +9 -0
- trunk/includes/lib/action-scheduler/docs/faq.md +101 -0
- trunk/includes/lib/action-scheduler/docs/favicon-16x16.png +0 -0
- trunk/includes/lib/action-scheduler/docs/favicon-32x32.png +0 -0
- trunk/includes/lib/action-scheduler/docs/favicon.ico +0 -0
- trunk/includes/lib/action-scheduler/docs/google14ef723abb376cd3.html +1 -0
- trunk/includes/lib/action-scheduler/docs/index.md +68 -0
- trunk/includes/lib/action-scheduler/docs/mstile-150x150.png +0 -0
- trunk/includes/lib/action-scheduler/docs/perf.md +127 -0
- trunk/includes/lib/action-scheduler/docs/safari-pinned-tab.svg +40 -0
- trunk/includes/lib/action-scheduler/docs/site.webmanifest +19 -0
- trunk/includes/lib/action-scheduler/docs/usage.md +123 -0
- trunk/includes/lib/action-scheduler/docs/wp-cli.md +73 -0
- trunk/includes/lib/action-scheduler/functions.php +209 -0
- trunk/includes/lib/action-scheduler/lib/cron-expression/CronExpression.php +318 -0
- trunk/includes/lib/action-scheduler/lib/cron-expression/CronExpression_AbstractField.php +100 -0
- trunk/includes/lib/action-scheduler/lib/cron-expression/CronExpression_DayOfMonthField.php +110 -0
- trunk/includes/lib/action-scheduler/lib/cron-expression/CronExpression_DayOfWeekField.php +124 -0
- trunk/includes/lib/action-scheduler/lib/cron-expression/CronExpression_FieldFactory.php +55 -0
- trunk/includes/lib/action-scheduler/lib/cron-expression/CronExpression_FieldInterface.php +39 -0
- trunk/includes/lib/action-scheduler/lib/cron-expression/CronExpression_HoursField.php +47 -0
- trunk/includes/lib/action-scheduler/lib/cron-expression/CronExpression_MinutesField.php +39 -0
- trunk/includes/lib/action-scheduler/lib/cron-expression/CronExpression_MonthField.php +55 -0
- trunk/includes/lib/action-scheduler/lib/cron-expression/CronExpression_YearField.php +43 -0
- trunk/includes/lib/action-scheduler/lib/cron-expression/LICENSE +19 -0
- trunk/includes/lib/action-scheduler/lib/cron-expression/README.md +92 -0
- trunk/includes/lib/action-scheduler/license.txt +674 -0
- trunk/includes/lib/action-scheduler/tests/ActionScheduler_UnitTestCase.php +44 -0
- trunk/includes/lib/action-scheduler/tests/bootstrap.php +31 -0
- trunk/includes/lib/action-scheduler/tests/phpunit.xml.dist +32 -0
- trunk/includes/lib/action-scheduler/tests/phpunit/deprecated/ActionScheduler_UnitTestCase.php +44 -0
- trunk/includes/lib/action-scheduler/tests/phpunit/helpers/ActionScheduler_TimezoneHelper_Test.php +100 -0
- trunk/includes/lib/action-scheduler/tests/phpunit/jobs/ActionScheduler_Action_Test.php +55 -0
- trunk/includes/lib/action-scheduler/tests/phpunit/jobs/ActionScheduler_NullAction_Test.php +16 -0
- trunk/includes/lib/action-scheduler/tests/phpunit/jobstore/ActionScheduler_wpPostStore_Test.php +375 -0
- trunk/includes/lib/action-scheduler/tests/phpunit/logging/ActionScheduler_wpCommentLogger_Test.php +185 -0
- trunk/includes/lib/action-scheduler/tests/phpunit/procedural_api/procedural_api_Test.php +222 -0
- trunk/includes/lib/action-scheduler/tests/phpunit/procedural_api/wc_get_scheduled_actions_Test.php +100 -0
- trunk/includes/lib/action-scheduler/tests/phpunit/runner/ActionScheduler_QueueCleaner_Test.php +151 -0
- trunk/includes/lib/action-scheduler/tests/phpunit/runner/ActionScheduler_QueueRunner_Test.php +209 -0
- trunk/includes/lib/action-scheduler/tests/phpunit/schedules/ActionScheduler_CronSchedule_Test.php +45 -0
- trunk/includes/lib/action-scheduler/tests/phpunit/schedules/ActionScheduler_IntervalSchedule_Test.php +28 -0
- trunk/includes/lib/action-scheduler/tests/phpunit/schedules/ActionScheduler_NullSchedule_Test.php +18 -0
- trunk/includes/lib/action-scheduler/tests/phpunit/schedules/ActionScheduler_SimpleSchedule_Test.php +37 -0
- trunk/includes/lib/action-scheduler/tests/phpunit/versioning/ActionScheduler_Versions_Test.php +43 -0
- trunk/includes/lib/action-scheduler/tests/travis/setup.sh +38 -0
- trunk/includes/lib/action-scheduler/tests/travis/wp-tests-config.php +38 -0
- trunk/includes/lib/class-ss-system-info.php +239 -0
- trunk/includes/migrations/class-ss-wc-migration-from-1.3.X-to-2.0.php +76 -0
- trunk/includes/migrations/class-ss-wc-migration-from-2.0-to-2.0.15.php +51 -0
- trunk/includes/migrations/class-ss-wc-migration.php +98 -0
- trunk/index.php +1 -0
- trunk/languages/woocommerce-mailchimp-fr_FR.mo +0 -0
- trunk/languages/woocommerce-mailchimp-fr_FR.po +273 -0
- trunk/languages/woocommerce-mailchimp.pot +404 -0
- trunk/readme.txt +404 -0
- trunk/woocommerce-mailchimp.php +44 -0
- trunk/wpml-config.xml +5 -0
includes/class-ss-wc-mailchimp-api.php
CHANGED
@@ -42,11 +42,6 @@ class SS_WC_MailChimp_API {
|
|
42 |
*/
|
43 |
private $last_error;
|
44 |
|
45 |
-
/**
|
46 |
-
* @var WC_Logger
|
47 |
-
*/
|
48 |
-
private $log;
|
49 |
-
|
50 |
/**
|
51 |
* Create a new instance
|
52 |
* @param string $api_key MailChimp API key
|
@@ -56,10 +51,6 @@ class SS_WC_MailChimp_API {
|
|
56 |
|
57 |
$this->debug = $debug;
|
58 |
|
59 |
-
if ( $this->debug === true ) {
|
60 |
-
$this->log = new WC_Logger();
|
61 |
-
}
|
62 |
-
|
63 |
$this->api_key = $api_key;
|
64 |
$api_key_parts = explode( '-', $this->api_key );
|
65 |
$this->datacenter = empty( $api_key_parts[1] ) ? 'us1' : $api_key_parts[1];
|
@@ -68,6 +59,8 @@ class SS_WC_MailChimp_API {
|
|
68 |
} //end function __construct
|
69 |
|
70 |
/**
|
|
|
|
|
71 |
* @param string $resource
|
72 |
* @param array $args
|
73 |
*
|
@@ -84,6 +77,8 @@ class SS_WC_MailChimp_API {
|
|
84 |
} //end function post
|
85 |
|
86 |
/**
|
|
|
|
|
87 |
* @param string $resource
|
88 |
* @param array $args
|
89 |
*
|
@@ -96,6 +91,8 @@ class SS_WC_MailChimp_API {
|
|
96 |
} //end function post
|
97 |
|
98 |
/**
|
|
|
|
|
99 |
* @param string $resource
|
100 |
* @param array $args
|
101 |
*
|
@@ -108,6 +105,8 @@ class SS_WC_MailChimp_API {
|
|
108 |
} //end function put
|
109 |
|
110 |
/**
|
|
|
|
|
111 |
* @param string $resource
|
112 |
* @param array $args
|
113 |
*
|
@@ -120,6 +119,8 @@ class SS_WC_MailChimp_API {
|
|
120 |
} //end function patch
|
121 |
|
122 |
/**
|
|
|
|
|
123 |
* @param string $resource
|
124 |
* @param array $args
|
125 |
*
|
@@ -133,10 +134,11 @@ class SS_WC_MailChimp_API {
|
|
133 |
|
134 |
/**
|
135 |
* Performs the underlying HTTP request.
|
136 |
-
*
|
137 |
-
* @param string $
|
138 |
-
* @param
|
139 |
-
* @
|
|
|
140 |
*/
|
141 |
private function api_request( $method, $resource, $args = array() ) {
|
142 |
|
@@ -160,8 +162,8 @@ class SS_WC_MailChimp_API {
|
|
160 |
),
|
161 |
);
|
162 |
|
163 |
-
// attach arguments (in body or URL)
|
164 |
-
if (
|
165 |
$url = add_query_arg( $args, $url );
|
166 |
} else {
|
167 |
$request_args['body'] = json_encode( $args );
|
@@ -182,8 +184,8 @@ class SS_WC_MailChimp_API {
|
|
182 |
|
183 |
return false;
|
184 |
|
185 |
-
} elseif ( is_array( $raw_response )
|
186 |
-
&& $raw_response['response']['code']
|
187 |
&& floor( $raw_response['response']['code'] ) / 100 >= 4 ) {
|
188 |
|
189 |
$json = wp_remote_retrieve_body( $raw_response );
|
@@ -216,18 +218,15 @@ class SS_WC_MailChimp_API {
|
|
216 |
|
217 |
/**
|
218 |
* Conditionally log MailChimp API Call
|
219 |
-
*
|
220 |
-
* @param string $
|
221 |
-
* @param
|
222 |
-
* @param array
|
|
|
223 |
* @return void
|
224 |
*/
|
225 |
private function maybe_log( $resource, $method, $args, $response ) {
|
226 |
-
|
227 |
-
if ( $this->debug === true ) {
|
228 |
-
$this->log->add( 'woocommerce-mailchimp', "MailChimp API Call RESOURCE: $resource \n METHOD: $method \n BODY: " . print_r( $args, true ) . " \n RESPONSE: " . print_r( $response, true ) );
|
229 |
-
}
|
230 |
-
|
231 |
}
|
232 |
|
233 |
/**
|
42 |
*/
|
43 |
private $last_error;
|
44 |
|
|
|
|
|
|
|
|
|
|
|
45 |
/**
|
46 |
* Create a new instance
|
47 |
* @param string $api_key MailChimp API key
|
51 |
|
52 |
$this->debug = $debug;
|
53 |
|
|
|
|
|
|
|
|
|
54 |
$this->api_key = $api_key;
|
55 |
$api_key_parts = explode( '-', $this->api_key );
|
56 |
$this->datacenter = empty( $api_key_parts[1] ) ? 'us1' : $api_key_parts[1];
|
59 |
} //end function __construct
|
60 |
|
61 |
/**
|
62 |
+
* Get request.
|
63 |
+
*
|
64 |
* @param string $resource
|
65 |
* @param array $args
|
66 |
*
|
77 |
} //end function post
|
78 |
|
79 |
/**
|
80 |
+
* Post request.
|
81 |
+
*
|
82 |
* @param string $resource
|
83 |
* @param array $args
|
84 |
*
|
91 |
} //end function post
|
92 |
|
93 |
/**
|
94 |
+
* Put request.
|
95 |
+
*
|
96 |
* @param string $resource
|
97 |
* @param array $args
|
98 |
*
|
105 |
} //end function put
|
106 |
|
107 |
/**
|
108 |
+
* Patch request.
|
109 |
+
*
|
110 |
* @param string $resource
|
111 |
* @param array $args
|
112 |
*
|
119 |
} //end function patch
|
120 |
|
121 |
/**
|
122 |
+
* Delete request.
|
123 |
+
*
|
124 |
* @param string $resource
|
125 |
* @param array $args
|
126 |
*
|
134 |
|
135 |
/**
|
136 |
* Performs the underlying HTTP request.
|
137 |
+
*
|
138 |
+
* @param string $method HTTP method (GET|POST|PUT|PATCH|DELETE).
|
139 |
+
* @param string $resource MailChimp API resource to be called.
|
140 |
+
* @param array $args array of parameters to be passed.
|
141 |
+
* @return array array of decoded result.
|
142 |
*/
|
143 |
private function api_request( $method, $resource, $args = array() ) {
|
144 |
|
162 |
),
|
163 |
);
|
164 |
|
165 |
+
// attach arguments (in body or URL).
|
166 |
+
if ( 'GET' === $method ) {
|
167 |
$url = add_query_arg( $args, $url );
|
168 |
} else {
|
169 |
$request_args['body'] = json_encode( $args );
|
184 |
|
185 |
return false;
|
186 |
|
187 |
+
} elseif ( is_array( $raw_response )
|
188 |
+
&& $raw_response['response']['code']
|
189 |
&& floor( $raw_response['response']['code'] ) / 100 >= 4 ) {
|
190 |
|
191 |
$json = wp_remote_retrieve_body( $raw_response );
|
218 |
|
219 |
/**
|
220 |
* Conditionally log MailChimp API Call
|
221 |
+
*
|
222 |
+
* @param string $resource MailChimp API Resource.
|
223 |
+
* @param string $method HTTP Method.
|
224 |
+
* @param array $args HTTP Request Body.
|
225 |
+
* @param array $response WP HTTP Response.
|
226 |
* @return void
|
227 |
*/
|
228 |
private function maybe_log( $resource, $method, $args, $response ) {
|
229 |
+
do_action( 'sswcmc_log', "MailChimp API Call RESOURCE: $resource \n METHOD: $method \n BODY: " . print_r( $args, true ) . " \n RESPONSE: " . print_r( $response, true ) );
|
|
|
|
|
|
|
|
|
230 |
}
|
231 |
|
232 |
/**
|
includes/class-ss-wc-mailchimp-plugin.php
CHANGED
@@ -15,7 +15,7 @@ final class SS_WC_MailChimp_Plugin {
|
|
15 |
*
|
16 |
* @var string
|
17 |
*/
|
18 |
-
private static $version = '2.1.
|
19 |
|
20 |
/**
|
21 |
* Plugin singleton instance
|
@@ -77,6 +77,7 @@ final class SS_WC_MailChimp_Plugin {
|
|
77 |
self::$instance->settings();
|
78 |
self::$instance->includes();
|
79 |
self::$instance->mailchimp();
|
|
|
80 |
self::$instance->handler = SS_WC_MailChimp_Handler::get_instance();
|
81 |
self::$instance->compatibility = SS_WC_MailChimp_Compatibility::get_instance();
|
82 |
self::$instance->admin_notices = new SS_WC_MailChimp_Admin_Notices();
|
@@ -372,6 +373,8 @@ final class SS_WC_MailChimp_Plugin {
|
|
372 |
|
373 |
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp-handler.php' );
|
374 |
|
|
|
|
|
375 |
} //end function includes
|
376 |
|
377 |
/**
|
@@ -396,6 +399,8 @@ final class SS_WC_MailChimp_Plugin {
|
|
396 |
|
397 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
398 |
|
|
|
|
|
399 |
}
|
400 |
|
401 |
} //end function add_hooks
|
@@ -475,7 +480,7 @@ final class SS_WC_MailChimp_Plugin {
|
|
475 |
);
|
476 |
|
477 |
if ( ! function_exists( 'SSWCMCPRO' ) ) {
|
478 |
-
|
479 |
'support' => '<a href="' . esc_url( apply_filters( 'ss_wc_mailchimp_support_url', 'https://www.saintsystems.com/products/woocommerce-mailchimp-pro/#utm_source=wp-plugin&utm_medium=woocommerce-mailchimp&utm_campaign=plugins-upgrade-link' ) ) . '" aria-label="' . esc_attr__( 'Upgrade to WooCommerce MailChimp Pro', 'woocommerce-mailchimp' ) . '" target="_blank">' . esc_html__( 'Upgrade to Pro', 'woocommerce-mailchimp' ) . '</a>',
|
480 |
);
|
481 |
}
|
@@ -534,6 +539,24 @@ final class SS_WC_MailChimp_Plugin {
|
|
534 |
|
535 |
} //end function enqueue_scripts
|
536 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
537 |
/**
|
538 |
* Handles running plugin upgrades if necessary
|
539 |
*
|
15 |
*
|
16 |
* @var string
|
17 |
*/
|
18 |
+
private static $version = '2.1.15';
|
19 |
|
20 |
/**
|
21 |
* Plugin singleton instance
|
77 |
self::$instance->settings();
|
78 |
self::$instance->includes();
|
79 |
self::$instance->mailchimp();
|
80 |
+
self::$instance->logger = SSWCMC_Logger::get_instance();
|
81 |
self::$instance->handler = SS_WC_MailChimp_Handler::get_instance();
|
82 |
self::$instance->compatibility = SS_WC_MailChimp_Compatibility::get_instance();
|
83 |
self::$instance->admin_notices = new SS_WC_MailChimp_Admin_Notices();
|
373 |
|
374 |
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp-handler.php' );
|
375 |
|
376 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-sswcmc-logger.php' );
|
377 |
+
|
378 |
} //end function includes
|
379 |
|
380 |
/**
|
399 |
|
400 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
401 |
|
402 |
+
add_action( 'admin_init', array( $this, 'process_actions' ) );
|
403 |
+
|
404 |
}
|
405 |
|
406 |
} //end function add_hooks
|
480 |
);
|
481 |
|
482 |
if ( ! function_exists( 'SSWCMCPRO' ) ) {
|
483 |
+
$row_meta[] = array(
|
484 |
'support' => '<a href="' . esc_url( apply_filters( 'ss_wc_mailchimp_support_url', 'https://www.saintsystems.com/products/woocommerce-mailchimp-pro/#utm_source=wp-plugin&utm_medium=woocommerce-mailchimp&utm_campaign=plugins-upgrade-link' ) ) . '" aria-label="' . esc_attr__( 'Upgrade to WooCommerce MailChimp Pro', 'woocommerce-mailchimp' ) . '" target="_blank">' . esc_html__( 'Upgrade to Pro', 'woocommerce-mailchimp' ) . '</a>',
|
485 |
);
|
486 |
}
|
539 |
|
540 |
} //end function enqueue_scripts
|
541 |
|
542 |
+
/**
|
543 |
+
* Processes all SSWCMC actions sent via POST and GET by looking for the 'sswcmc-action'
|
544 |
+
* request and running do_action() to call the function
|
545 |
+
*
|
546 |
+
* @since 2.1.15
|
547 |
+
* @access public
|
548 |
+
* @return void
|
549 |
+
*/
|
550 |
+
public function process_actions() {
|
551 |
+
if ( isset( $_POST['sswcmc-action'] ) ) {
|
552 |
+
do_action( 'sswcmc_' . $_POST['sswcmc-action'], $_POST );
|
553 |
+
}
|
554 |
+
|
555 |
+
if ( isset( $_GET['sswcmc-action'] ) ) {
|
556 |
+
do_action( 'sswcmc_' . $_GET['sswcmc-action'], $_GET );
|
557 |
+
}
|
558 |
+
}
|
559 |
+
|
560 |
/**
|
561 |
* Handles running plugin upgrades if necessary
|
562 |
*
|
includes/class-ss-wc-mailchimp.php
CHANGED
@@ -72,6 +72,8 @@ class SS_WC_MailChimp {
|
|
72 |
return false;
|
73 |
}
|
74 |
|
|
|
|
|
75 |
return $account;
|
76 |
|
77 |
} //end function get_account
|
72 |
return false;
|
73 |
}
|
74 |
|
75 |
+
do_action( 'sswcmc_log', __METHOD__ . ' Mailchimp Account Retrieved: ' . print_r( $account, true ) );
|
76 |
+
|
77 |
return $account;
|
78 |
|
79 |
} //end function get_account
|
includes/class-sswcmc-logger.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Logging helper.
|
7 |
+
*
|
8 |
+
* @class SSWCMC_Logger
|
9 |
+
* @version 2.1.15
|
10 |
+
* @package WooCommerce MailChimp
|
11 |
+
* @author Saint Systems
|
12 |
+
*/
|
13 |
+
final class SSWCMC_Logger {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Plugin singleton instance
|
17 |
+
*
|
18 |
+
* @var SSWCMC_Logger
|
19 |
+
*/
|
20 |
+
private static $instance = null;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Whether plugin is in debug/troubleshooting mode.
|
24 |
+
*
|
25 |
+
* @var boolean
|
26 |
+
*/
|
27 |
+
public $debug;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* The WC_Logger handle.
|
31 |
+
*
|
32 |
+
* @var string
|
33 |
+
*/
|
34 |
+
const WC_LOG_FILENAME = 'woocommerce-mailchimp';
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Constructor
|
38 |
+
*
|
39 |
+
* @access public
|
40 |
+
* @return void
|
41 |
+
*/
|
42 |
+
public function __construct() {
|
43 |
+
|
44 |
+
$this->sswcmc = SSWCMC();
|
45 |
+
$this->register_hooks();
|
46 |
+
|
47 |
+
} //end function __construct
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Get the singleton instance
|
51 |
+
*
|
52 |
+
* @return SSWCMC_Logger
|
53 |
+
*/
|
54 |
+
public static function get_instance() {
|
55 |
+
if ( empty( self::$instance ) ) {
|
56 |
+
self::$instance = new self;
|
57 |
+
}
|
58 |
+
|
59 |
+
return self::$instance;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Register the class hooks.
|
64 |
+
* @access public
|
65 |
+
* @return void
|
66 |
+
*/
|
67 |
+
public function register_hooks() {
|
68 |
+
add_action( 'sswcmc_log', array( $this, 'log' ), 10, 1 );
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Conditionally log
|
73 |
+
*
|
74 |
+
* @param string $message The log message.
|
75 |
+
* @return void
|
76 |
+
*/
|
77 |
+
public function log( $message ) {
|
78 |
+
|
79 |
+
if ( ! $this->sswcmc->debug_enabled() ) return;
|
80 |
+
$log = $this->get_logger();
|
81 |
+
if ( version_compare( WC_VERSION, '3.0.0', '>=' ) ) {
|
82 |
+
$log->debug( $message, array( 'source' => self::WC_LOG_FILENAME ) );
|
83 |
+
} else {
|
84 |
+
$log->add( self::WC_LOG_FILENAME, $message );
|
85 |
+
}
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Get the WC_Logger reference
|
91 |
+
*
|
92 |
+
* @var WC_Logger
|
93 |
+
*/
|
94 |
+
private function get_logger() {
|
95 |
+
if ( version_compare( WC_VERSION, '3.0.0', '>=' ) ) {
|
96 |
+
return wc_get_logger();
|
97 |
+
} else {
|
98 |
+
return new WC_Logger();
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
} //end class SSWCMC_Logger
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: woocommerce, mailchimp
|
|
5 |
Requires at least: 3.5.1
|
6 |
Tested up to: 5.0.3
|
7 |
WC tested up to: 3.5.4
|
8 |
-
Stable tag: 2.1.
|
9 |
License: GPLv3
|
10 |
|
11 |
Simple and flexible MailChimp integration for WooCommerce.
|
@@ -114,6 +114,9 @@ Also, if you enjoy using the software [we'd love it if you could give us a revie
|
|
114 |
|
115 |
== Changelog ==
|
116 |
|
|
|
|
|
|
|
117 |
#### 2.1.14 - February 5, 2019
|
118 |
- Fix MailChimp interest group limit
|
119 |
|
5 |
Requires at least: 3.5.1
|
6 |
Tested up to: 5.0.3
|
7 |
WC tested up to: 3.5.4
|
8 |
+
Stable tag: 2.1.15
|
9 |
License: GPLv3
|
10 |
|
11 |
Simple and flexible MailChimp integration for WooCommerce.
|
114 |
|
115 |
== Changelog ==
|
116 |
|
117 |
+
#### 2.1.15 - February 5, 2019
|
118 |
+
- Fix fatal error.
|
119 |
+
|
120 |
#### 2.1.14 - February 5, 2019
|
121 |
- Fix MailChimp interest group limit
|
122 |
|
trunk/COPYRIGHT.txt
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
WooCommerce MailChimp
|
3 |
+
|
4 |
+
Copyright 2018 "saintsystems" (Saint Systems) www.saintsystems.com
|
5 |
+
|
6 |
+
The files COPYRIGHT.txt and LICENSE.txt as well as ALL NOTICES IN THE
|
7 |
+
HEADERS OF ALL FILES MUST BE KEPT INTACT.
|
8 |
+
|
9 |
+
GPL-licensed
|
10 |
+
|
11 |
+
Unless otherwise stated, all code in this plugin is licensed under
|
12 |
+
the GPL License:
|
13 |
+
|
14 |
+
All code is part of this plugin, hereinafter referred to as "program".
|
15 |
+
|
16 |
+
This program is free software: you can redistribute it and/or modify
|
17 |
+
it under the terms of the GNU General Public License as published by
|
18 |
+
the Free Software Foundation, either version 3 of the License, or
|
19 |
+
(at your option) any later version.
|
20 |
+
|
21 |
+
This program is distributed in the hope that it will be useful,
|
22 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
+
GNU General Public License for more details.
|
25 |
+
|
26 |
+
You should have received a copy of the GNU General Public License
|
27 |
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
28 |
+
|
trunk/LICENSE.txt
ADDED
@@ -0,0 +1,674 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 3, 29 June 2007
|
3 |
+
|
4 |
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5 |
+
Everyone is permitted to copy and distribute verbatim copies
|
6 |
+
of this license document, but changing it is not allowed.
|
7 |
+
|
8 |
+
Preamble
|
9 |
+
|
10 |
+
The GNU General Public License is a free, copyleft license for
|
11 |
+
software and other kinds of works.
|
12 |
+
|
13 |
+
The licenses for most software and other practical works are designed
|
14 |
+
to take away your freedom to share and change the works. By contrast,
|
15 |
+
the GNU General Public License is intended to guarantee your freedom to
|
16 |
+
share and change all versions of a program--to make sure it remains free
|
17 |
+
software for all its users. We, the Free Software Foundation, use the
|
18 |
+
GNU General Public License for most of our software; it applies also to
|
19 |
+
any other work released this way by its authors. You can apply it to
|
20 |
+
your programs, too.
|
21 |
+
|
22 |
+
When we speak of free software, we are referring to freedom, not
|
23 |
+
price. Our General Public Licenses are designed to make sure that you
|
24 |
+
have the freedom to distribute copies of free software (and charge for
|
25 |
+
them if you wish), that you receive source code or can get it if you
|
26 |
+
want it, that you can change the software or use pieces of it in new
|
27 |
+
free programs, and that you know you can do these things.
|
28 |
+
|
29 |
+
To protect your rights, we need to prevent others from denying you
|
30 |
+
these rights or asking you to surrender the rights. Therefore, you have
|
31 |
+
certain responsibilities if you distribute copies of the software, or if
|
32 |
+
you modify it: responsibilities to respect the freedom of others.
|
33 |
+
|
34 |
+
For example, if you distribute copies of such a program, whether
|
35 |
+
gratis or for a fee, you must pass on to the recipients the same
|
36 |
+
freedoms that you received. You must make sure that they, too, receive
|
37 |
+
or can get the source code. And you must show them these terms so they
|
38 |
+
know their rights.
|
39 |
+
|
40 |
+
Developers that use the GNU GPL protect your rights with two steps:
|
41 |
+
(1) assert copyright on the software, and (2) offer you this License
|
42 |
+
giving you legal permission to copy, distribute and/or modify it.
|
43 |
+
|
44 |
+
For the developers' and authors' protection, the GPL clearly explains
|
45 |
+
that there is no warranty for this free software. For both users' and
|
46 |
+
authors' sake, the GPL requires that modified versions be marked as
|
47 |
+
changed, so that their problems will not be attributed erroneously to
|
48 |
+
authors of previous versions.
|
49 |
+
|
50 |
+
Some devices are designed to deny users access to install or run
|
51 |
+
modified versions of the software inside them, although the manufacturer
|
52 |
+
can do so. This is fundamentally incompatible with the aim of
|
53 |
+
protecting users' freedom to change the software. The systematic
|
54 |
+
pattern of such abuse occurs in the area of products for individuals to
|
55 |
+
use, which is precisely where it is most unacceptable. Therefore, we
|
56 |
+
have designed this version of the GPL to prohibit the practice for those
|
57 |
+
products. If such problems arise substantially in other domains, we
|
58 |
+
stand ready to extend this provision to those domains in future versions
|
59 |
+
of the GPL, as needed to protect the freedom of users.
|
60 |
+
|
61 |
+
Finally, every program is threatened constantly by software patents.
|
62 |
+
States should not allow patents to restrict development and use of
|
63 |
+
software on general-purpose computers, but in those that do, we wish to
|
64 |
+
avoid the special danger that patents applied to a free program could
|
65 |
+
make it effectively proprietary. To prevent this, the GPL assures that
|
66 |
+
patents cannot be used to render the program non-free.
|
67 |
+
|
68 |
+
The precise terms and conditions for copying, distribution and
|
69 |
+
modification follow.
|
70 |
+
|
71 |
+
TERMS AND CONDITIONS
|
72 |
+
|
73 |
+
0. Definitions.
|
74 |
+
|
75 |
+
"This License" refers to version 3 of the GNU General Public License.
|
76 |
+
|
77 |
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
78 |
+
works, such as semiconductor masks.
|
79 |
+
|
80 |
+
"The Program" refers to any copyrightable work licensed under this
|
81 |
+
License. Each licensee is addressed as "you". "Licensees" and
|
82 |
+
"recipients" may be individuals or organizations.
|
83 |
+
|
84 |
+
To "modify" a work means to copy from or adapt all or part of the work
|
85 |
+
in a fashion requiring copyright permission, other than the making of an
|
86 |
+
exact copy. The resulting work is called a "modified version" of the
|
87 |
+
earlier work or a work "based on" the earlier work.
|
88 |
+
|
89 |
+
A "covered work" means either the unmodified Program or a work based
|
90 |
+
on the Program.
|
91 |
+
|
92 |
+
To "propagate" a work means to do anything with it that, without
|
93 |
+
permission, would make you directly or secondarily liable for
|
94 |
+
infringement under applicable copyright law, except executing it on a
|
95 |
+
computer or modifying a private copy. Propagation includes copying,
|
96 |
+
distribution (with or without modification), making available to the
|
97 |
+
public, and in some countries other activities as well.
|
98 |
+
|
99 |
+
To "convey" a work means any kind of propagation that enables other
|
100 |
+
parties to make or receive copies. Mere interaction with a user through
|
101 |
+
a computer network, with no transfer of a copy, is not conveying.
|
102 |
+
|
103 |
+
An interactive user interface displays "Appropriate Legal Notices"
|
104 |
+
to the extent that it includes a convenient and prominently visible
|
105 |
+
feature that (1) displays an appropriate copyright notice, and (2)
|
106 |
+
tells the user that there is no warranty for the work (except to the
|
107 |
+
extent that warranties are provided), that licensees may convey the
|
108 |
+
work under this License, and how to view a copy of this License. If
|
109 |
+
the interface presents a list of user commands or options, such as a
|
110 |
+
menu, a prominent item in the list meets this criterion.
|
111 |
+
|
112 |
+
1. Source Code.
|
113 |
+
|
114 |
+
The "source code" for a work means the preferred form of the work
|
115 |
+
for making modifications to it. "Object code" means any non-source
|
116 |
+
form of a work.
|
117 |
+
|
118 |
+
A "Standard Interface" means an interface that either is an official
|
119 |
+
standard defined by a recognized standards body, or, in the case of
|
120 |
+
interfaces specified for a particular programming language, one that
|
121 |
+
is widely used among developers working in that language.
|
122 |
+
|
123 |
+
The "System Libraries" of an executable work include anything, other
|
124 |
+
than the work as a whole, that (a) is included in the normal form of
|
125 |
+
packaging a Major Component, but which is not part of that Major
|
126 |
+
Component, and (b) serves only to enable use of the work with that
|
127 |
+
Major Component, or to implement a Standard Interface for which an
|
128 |
+
implementation is available to the public in source code form. A
|
129 |
+
"Major Component", in this context, means a major essential component
|
130 |
+
(kernel, window system, and so on) of the specific operating system
|
131 |
+
(if any) on which the executable work runs, or a compiler used to
|
132 |
+
produce the work, or an object code interpreter used to run it.
|
133 |
+
|
134 |
+
The "Corresponding Source" for a work in object code form means all
|
135 |
+
the source code needed to generate, install, and (for an executable
|
136 |
+
work) run the object code and to modify the work, including scripts to
|
137 |
+
control those activities. However, it does not include the work's
|
138 |
+
System Libraries, or general-purpose tools or generally available free
|
139 |
+
programs which are used unmodified in performing those activities but
|
140 |
+
which are not part of the work. For example, Corresponding Source
|
141 |
+
includes interface definition files associated with source files for
|
142 |
+
the work, and the source code for shared libraries and dynamically
|
143 |
+
linked subprograms that the work is specifically designed to require,
|
144 |
+
such as by intimate data communication or control flow between those
|
145 |
+
subprograms and other parts of the work.
|
146 |
+
|
147 |
+
The Corresponding Source need not include anything that users
|
148 |
+
can regenerate automatically from other parts of the Corresponding
|
149 |
+
Source.
|
150 |
+
|
151 |
+
The Corresponding Source for a work in source code form is that
|
152 |
+
same work.
|
153 |
+
|
154 |
+
2. Basic Permissions.
|
155 |
+
|
156 |
+
All rights granted under this License are granted for the term of
|
157 |
+
copyright on the Program, and are irrevocable provided the stated
|
158 |
+
conditions are met. This License explicitly affirms your unlimited
|
159 |
+
permission to run the unmodified Program. The output from running a
|
160 |
+
covered work is covered by this License only if the output, given its
|
161 |
+
content, constitutes a covered work. This License acknowledges your
|
162 |
+
rights of fair use or other equivalent, as provided by copyright law.
|
163 |
+
|
164 |
+
You may make, run and propagate covered works that you do not
|
165 |
+
convey, without conditions so long as your license otherwise remains
|
166 |
+
in force. You may convey covered works to others for the sole purpose
|
167 |
+
of having them make modifications exclusively for you, or provide you
|
168 |
+
with facilities for running those works, provided that you comply with
|
169 |
+
the terms of this License in conveying all material for which you do
|
170 |
+
not control copyright. Those thus making or running the covered works
|
171 |
+
for you must do so exclusively on your behalf, under your direction
|
172 |
+
and control, on terms that prohibit them from making any copies of
|
173 |
+
your copyrighted material outside their relationship with you.
|
174 |
+
|
175 |
+
Conveying under any other circumstances is permitted solely under
|
176 |
+
the conditions stated below. Sublicensing is not allowed; section 10
|
177 |
+
makes it unnecessary.
|
178 |
+
|
179 |
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
180 |
+
|
181 |
+
No covered work shall be deemed part of an effective technological
|
182 |
+
measure under any applicable law fulfilling obligations under article
|
183 |
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
184 |
+
similar laws prohibiting or restricting circumvention of such
|
185 |
+
measures.
|
186 |
+
|
187 |
+
When you convey a covered work, you waive any legal power to forbid
|
188 |
+
circumvention of technological measures to the extent such circumvention
|
189 |
+
is effected by exercising rights under this License with respect to
|
190 |
+
the covered work, and you disclaim any intention to limit operation or
|
191 |
+
modification of the work as a means of enforcing, against the work's
|
192 |
+
users, your or third parties' legal rights to forbid circumvention of
|
193 |
+
technological measures.
|
194 |
+
|
195 |
+
4. Conveying Verbatim Copies.
|
196 |
+
|
197 |
+
You may convey verbatim copies of the Program's source code as you
|
198 |
+
receive it, in any medium, provided that you conspicuously and
|
199 |
+
appropriately publish on each copy an appropriate copyright notice;
|
200 |
+
keep intact all notices stating that this License and any
|
201 |
+
non-permissive terms added in accord with section 7 apply to the code;
|
202 |
+
keep intact all notices of the absence of any warranty; and give all
|
203 |
+
recipients a copy of this License along with the Program.
|
204 |
+
|
205 |
+
You may charge any price or no price for each copy that you convey,
|
206 |
+
and you may offer support or warranty protection for a fee.
|
207 |
+
|
208 |
+
5. Conveying Modified Source Versions.
|
209 |
+
|
210 |
+
You may convey a work based on the Program, or the modifications to
|
211 |
+
produce it from the Program, in the form of source code under the
|
212 |
+
terms of section 4, provided that you also meet all of these conditions:
|
213 |
+
|
214 |
+
a) The work must carry prominent notices stating that you modified
|
215 |
+
it, and giving a relevant date.
|
216 |
+
|
217 |
+
b) The work must carry prominent notices stating that it is
|
218 |
+
released under this License and any conditions added under section
|
219 |
+
7. This requirement modifies the requirement in section 4 to
|
220 |
+
"keep intact all notices".
|
221 |
+
|
222 |
+
c) You must license the entire work, as a whole, under this
|
223 |
+
License to anyone who comes into possession of a copy. This
|
224 |
+
License will therefore apply, along with any applicable section 7
|
225 |
+
additional terms, to the whole of the work, and all its parts,
|
226 |
+
regardless of how they are packaged. This License gives no
|
227 |
+
permission to license the work in any other way, but it does not
|
228 |
+
invalidate such permission if you have separately received it.
|
229 |
+
|
230 |
+
d) If the work has interactive user interfaces, each must display
|
231 |
+
Appropriate Legal Notices; however, if the Program has interactive
|
232 |
+
interfaces that do not display Appropriate Legal Notices, your
|
233 |
+
work need not make them do so.
|
234 |
+
|
235 |
+
A compilation of a covered work with other separate and independent
|
236 |
+
works, which are not by their nature extensions of the covered work,
|
237 |
+
and which are not combined with it such as to form a larger program,
|
238 |
+
in or on a volume of a storage or distribution medium, is called an
|
239 |
+
"aggregate" if the compilation and its resulting copyright are not
|
240 |
+
used to limit the access or legal rights of the compilation's users
|
241 |
+
beyond what the individual works permit. Inclusion of a covered work
|
242 |
+
in an aggregate does not cause this License to apply to the other
|
243 |
+
parts of the aggregate.
|
244 |
+
|
245 |
+
6. Conveying Non-Source Forms.
|
246 |
+
|
247 |
+
You may convey a covered work in object code form under the terms
|
248 |
+
of sections 4 and 5, provided that you also convey the
|
249 |
+
machine-readable Corresponding Source under the terms of this License,
|
250 |
+
in one of these ways:
|
251 |
+
|
252 |
+
a) Convey the object code in, or embodied in, a physical product
|
253 |
+
(including a physical distribution medium), accompanied by the
|
254 |
+
Corresponding Source fixed on a durable physical medium
|
255 |
+
customarily used for software interchange.
|
256 |
+
|
257 |
+
b) Convey the object code in, or embodied in, a physical product
|
258 |
+
(including a physical distribution medium), accompanied by a
|
259 |
+
written offer, valid for at least three years and valid for as
|
260 |
+
long as you offer spare parts or customer support for that product
|
261 |
+
model, to give anyone who possesses the object code either (1) a
|
262 |
+
copy of the Corresponding Source for all the software in the
|
263 |
+
product that is covered by this License, on a durable physical
|
264 |
+
medium customarily used for software interchange, for a price no
|
265 |
+
more than your reasonable cost of physically performing this
|
266 |
+
conveying of source, or (2) access to copy the
|
267 |
+
Corresponding Source from a network server at no charge.
|
268 |
+
|
269 |
+
c) Convey individual copies of the object code with a copy of the
|
270 |
+
written offer to provide the Corresponding Source. This
|
271 |
+
alternative is allowed only occasionally and noncommercially, and
|
272 |
+
only if you received the object code with such an offer, in accord
|
273 |
+
with subsection 6b.
|
274 |
+
|
275 |
+
d) Convey the object code by offering access from a designated
|
276 |
+
place (gratis or for a charge), and offer equivalent access to the
|
277 |
+
Corresponding Source in the same way through the same place at no
|
278 |
+
further charge. You need not require recipients to copy the
|
279 |
+
Corresponding Source along with the object code. If the place to
|
280 |
+
copy the object code is a network server, the Corresponding Source
|
281 |
+
may be on a different server (operated by you or a third party)
|
282 |
+
that supports equivalent copying facilities, provided you maintain
|
283 |
+
clear directions next to the object code saying where to find the
|
284 |
+
Corresponding Source. Regardless of what server hosts the
|
285 |
+
Corresponding Source, you remain obligated to ensure that it is
|
286 |
+
available for as long as needed to satisfy these requirements.
|
287 |
+
|
288 |
+
e) Convey the object code using peer-to-peer transmission, provided
|
289 |
+
you inform other peers where the object code and Corresponding
|
290 |
+
Source of the work are being offered to the general public at no
|
291 |
+
charge under subsection 6d.
|
292 |
+
|
293 |
+
A separable portion of the object code, whose source code is excluded
|
294 |
+
from the Corresponding Source as a System Library, need not be
|
295 |
+
included in conveying the object code work.
|
296 |
+
|
297 |
+
A "User Product" is either (1) a "consumer product", which means any
|
298 |
+
tangible personal property which is normally used for personal, family,
|
299 |
+
or household purposes, or (2) anything designed or sold for incorporation
|
300 |
+
into a dwelling. In determining whether a product is a consumer product,
|
301 |
+
doubtful cases shall be resolved in favor of coverage. For a particular
|
302 |
+
product received by a particular user, "normally used" refers to a
|
303 |
+
typical or common use of that class of product, regardless of the status
|
304 |
+
of the particular user or of the way in which the particular user
|
305 |
+
actually uses, or expects or is expected to use, the product. A product
|
306 |
+
is a consumer product regardless of whether the product has substantial
|
307 |
+
commercial, industrial or non-consumer uses, unless such uses represent
|
308 |
+
the only significant mode of use of the product.
|
309 |
+
|
310 |
+
"Installation Information" for a User Product means any methods,
|
311 |
+
procedures, authorization keys, or other information required to install
|
312 |
+
and execute modified versions of a covered work in that User Product from
|
313 |
+
a modified version of its Corresponding Source. The information must
|
314 |
+
suffice to ensure that the continued functioning of the modified object
|
315 |
+
code is in no case prevented or interfered with solely because
|
316 |
+
modification has been made.
|
317 |
+
|
318 |
+
If you convey an object code work under this section in, or with, or
|
319 |
+
specifically for use in, a User Product, and the conveying occurs as
|
320 |
+
part of a transaction in which the right of possession and use of the
|
321 |
+
User Product is transferred to the recipient in perpetuity or for a
|
322 |
+
fixed term (regardless of how the transaction is characterized), the
|
323 |
+
Corresponding Source conveyed under this section must be accompanied
|
324 |
+
by the Installation Information. But this requirement does not apply
|
325 |
+
if neither you nor any third party retains the ability to install
|
326 |
+
modified object code on the User Product (for example, the work has
|
327 |
+
been installed in ROM).
|
328 |
+
|
329 |
+
The requirement to provide Installation Information does not include a
|
330 |
+
requirement to continue to provide support service, warranty, or updates
|
331 |
+
for a work that has been modified or installed by the recipient, or for
|
332 |
+
the User Product in which it has been modified or installed. Access to a
|
333 |
+
network may be denied when the modification itself materially and
|
334 |
+
adversely affects the operation of the network or violates the rules and
|
335 |
+
protocols for communication across the network.
|
336 |
+
|
337 |
+
Corresponding Source conveyed, and Installation Information provided,
|
338 |
+
in accord with this section must be in a format that is publicly
|
339 |
+
documented (and with an implementation available to the public in
|
340 |
+
source code form), and must require no special password or key for
|
341 |
+
unpacking, reading or copying.
|
342 |
+
|
343 |
+
7. Additional Terms.
|
344 |
+
|
345 |
+
"Additional permissions" are terms that supplement the terms of this
|
346 |
+
License by making exceptions from one or more of its conditions.
|
347 |
+
Additional permissions that are applicable to the entire Program shall
|
348 |
+
be treated as though they were included in this License, to the extent
|
349 |
+
that they are valid under applicable law. If additional permissions
|
350 |
+
apply only to part of the Program, that part may be used separately
|
351 |
+
under those permissions, but the entire Program remains governed by
|
352 |
+
this License without regard to the additional permissions.
|
353 |
+
|
354 |
+
When you convey a copy of a covered work, you may at your option
|
355 |
+
remove any additional permissions from that copy, or from any part of
|
356 |
+
it. (Additional permissions may be written to require their own
|
357 |
+
removal in certain cases when you modify the work.) You may place
|
358 |
+
additional permissions on material, added by you to a covered work,
|
359 |
+
for which you have or can give appropriate copyright permission.
|
360 |
+
|
361 |
+
Notwithstanding any other provision of this License, for material you
|
362 |
+
add to a covered work, you may (if authorized by the copyright holders of
|
363 |
+
that material) supplement the terms of this License with terms:
|
364 |
+
|
365 |
+
a) Disclaiming warranty or limiting liability differently from the
|
366 |
+
terms of sections 15 and 16 of this License; or
|
367 |
+
|
368 |
+
b) Requiring preservation of specified reasonable legal notices or
|
369 |
+
author attributions in that material or in the Appropriate Legal
|
370 |
+
Notices displayed by works containing it; or
|
371 |
+
|
372 |
+
c) Prohibiting misrepresentation of the origin of that material, or
|
373 |
+
requiring that modified versions of such material be marked in
|
374 |
+
reasonable ways as different from the original version; or
|
375 |
+
|
376 |
+
d) Limiting the use for publicity purposes of names of licensors or
|
377 |
+
authors of the material; or
|
378 |
+
|
379 |
+
e) Declining to grant rights under trademark law for use of some
|
380 |
+
trade names, trademarks, or service marks; or
|
381 |
+
|
382 |
+
f) Requiring indemnification of licensors and authors of that
|
383 |
+
material by anyone who conveys the material (or modified versions of
|
384 |
+
it) with contractual assumptions of liability to the recipient, for
|
385 |
+
any liability that these contractual assumptions directly impose on
|
386 |
+
those licensors and authors.
|
387 |
+
|
388 |
+
All other non-permissive additional terms are considered "further
|
389 |
+
restrictions" within the meaning of section 10. If the Program as you
|
390 |
+
received it, or any part of it, contains a notice stating that it is
|
391 |
+
governed by this License along with a term that is a further
|
392 |
+
restriction, you may remove that term. If a license document contains
|
393 |
+
a further restriction but permits relicensing or conveying under this
|
394 |
+
License, you may add to a covered work material governed by the terms
|
395 |
+
of that license document, provided that the further restriction does
|
396 |
+
not survive such relicensing or conveying.
|
397 |
+
|
398 |
+
If you add terms to a covered work in accord with this section, you
|
399 |
+
must place, in the relevant source files, a statement of the
|
400 |
+
additional terms that apply to those files, or a notice indicating
|
401 |
+
where to find the applicable terms.
|
402 |
+
|
403 |
+
Additional terms, permissive or non-permissive, may be stated in the
|
404 |
+
form of a separately written license, or stated as exceptions;
|
405 |
+
the above requirements apply either way.
|
406 |
+
|
407 |
+
8. Termination.
|
408 |
+
|
409 |
+
You may not propagate or modify a covered work except as expressly
|
410 |
+
provided under this License. Any attempt otherwise to propagate or
|
411 |
+
modify it is void, and will automatically terminate your rights under
|
412 |
+
this License (including any patent licenses granted under the third
|
413 |
+
paragraph of section 11).
|
414 |
+
|
415 |
+
However, if you cease all violation of this License, then your
|
416 |
+
license from a particular copyright holder is reinstated (a)
|
417 |
+
provisionally, unless and until the copyright holder explicitly and
|
418 |
+
finally terminates your license, and (b) permanently, if the copyright
|
419 |
+
holder fails to notify you of the violation by some reasonable means
|
420 |
+
prior to 60 days after the cessation.
|
421 |
+
|
422 |
+
Moreover, your license from a particular copyright holder is
|
423 |
+
reinstated permanently if the copyright holder notifies you of the
|
424 |
+
violation by some reasonable means, this is the first time you have
|
425 |
+
received notice of violation of this License (for any work) from that
|
426 |
+
copyright holder, and you cure the violation prior to 30 days after
|
427 |
+
your receipt of the notice.
|
428 |
+
|
429 |
+
Termination of your rights under this section does not terminate the
|
430 |
+
licenses of parties who have received copies or rights from you under
|
431 |
+
this License. If your rights have been terminated and not permanently
|
432 |
+
reinstated, you do not qualify to receive new licenses for the same
|
433 |
+
material under section 10.
|
434 |
+
|
435 |
+
9. Acceptance Not Required for Having Copies.
|
436 |
+
|
437 |
+
You are not required to accept this License in order to receive or
|
438 |
+
run a copy of the Program. Ancillary propagation of a covered work
|
439 |
+
occurring solely as a consequence of using peer-to-peer transmission
|
440 |
+
to receive a copy likewise does not require acceptance. However,
|
441 |
+
nothing other than this License grants you permission to propagate or
|
442 |
+
modify any covered work. These actions infringe copyright if you do
|
443 |
+
not accept this License. Therefore, by modifying or propagating a
|
444 |
+
covered work, you indicate your acceptance of this License to do so.
|
445 |
+
|
446 |
+
10. Automatic Licensing of Downstream Recipients.
|
447 |
+
|
448 |
+
Each time you convey a covered work, the recipient automatically
|
449 |
+
receives a license from the original licensors, to run, modify and
|
450 |
+
propagate that work, subject to this License. You are not responsible
|
451 |
+
for enforcing compliance by third parties with this License.
|
452 |
+
|
453 |
+
An "entity transaction" is a transaction transferring control of an
|
454 |
+
organization, or substantially all assets of one, or subdividing an
|
455 |
+
organization, or merging organizations. If propagation of a covered
|
456 |
+
work results from an entity transaction, each party to that
|
457 |
+
transaction who receives a copy of the work also receives whatever
|
458 |
+
licenses to the work the party's predecessor in interest had or could
|
459 |
+
give under the previous paragraph, plus a right to possession of the
|
460 |
+
Corresponding Source of the work from the predecessor in interest, if
|
461 |
+
the predecessor has it or can get it with reasonable efforts.
|
462 |
+
|
463 |
+
You may not impose any further restrictions on the exercise of the
|
464 |
+
rights granted or affirmed under this License. For example, you may
|
465 |
+
not impose a license fee, royalty, or other charge for exercise of
|
466 |
+
rights granted under this License, and you may not initiate litigation
|
467 |
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
468 |
+
any patent claim is infringed by making, using, selling, offering for
|
469 |
+
sale, or importing the Program or any portion of it.
|
470 |
+
|
471 |
+
11. Patents.
|
472 |
+
|
473 |
+
A "contributor" is a copyright holder who authorizes use under this
|
474 |
+
License of the Program or a work on which the Program is based. The
|
475 |
+
work thus licensed is called the contributor's "contributor version".
|
476 |
+
|
477 |
+
A contributor's "essential patent claims" are all patent claims
|
478 |
+
owned or controlled by the contributor, whether already acquired or
|
479 |
+
hereafter acquired, that would be infringed by some manner, permitted
|
480 |
+
by this License, of making, using, or selling its contributor version,
|
481 |
+
but do not include claims that would be infringed only as a
|
482 |
+
consequence of further modification of the contributor version. For
|
483 |
+
purposes of this definition, "control" includes the right to grant
|
484 |
+
patent sublicenses in a manner consistent with the requirements of
|
485 |
+
this License.
|
486 |
+
|
487 |
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
488 |
+
patent license under the contributor's essential patent claims, to
|
489 |
+
make, use, sell, offer for sale, import and otherwise run, modify and
|
490 |
+
propagate the contents of its contributor version.
|
491 |
+
|
492 |
+
In the following three paragraphs, a "patent license" is any express
|
493 |
+
agreement or commitment, however denominated, not to enforce a patent
|
494 |
+
(such as an express permission to practice a patent or covenant not to
|
495 |
+
sue for patent infringement). To "grant" such a patent license to a
|
496 |
+
party means to make such an agreement or commitment not to enforce a
|
497 |
+
patent against the party.
|
498 |
+
|
499 |
+
If you convey a covered work, knowingly relying on a patent license,
|
500 |
+
and the Corresponding Source of the work is not available for anyone
|
501 |
+
to copy, free of charge and under the terms of this License, through a
|
502 |
+
publicly available network server or other readily accessible means,
|
503 |
+
then you must either (1) cause the Corresponding Source to be so
|
504 |
+
available, or (2) arrange to deprive yourself of the benefit of the
|
505 |
+
patent license for this particular work, or (3) arrange, in a manner
|
506 |
+
consistent with the requirements of this License, to extend the patent
|
507 |
+
license to downstream recipients. "Knowingly relying" means you have
|
508 |
+
actual knowledge that, but for the patent license, your conveying the
|
509 |
+
covered work in a country, or your recipient's use of the covered work
|
510 |
+
in a country, would infringe one or more identifiable patents in that
|
511 |
+
country that you have reason to believe are valid.
|
512 |
+
|
513 |
+
If, pursuant to or in connection with a single transaction or
|
514 |
+
arrangement, you convey, or propagate by procuring conveyance of, a
|
515 |
+
covered work, and grant a patent license to some of the parties
|
516 |
+
receiving the covered work authorizing them to use, propagate, modify
|
517 |
+
or convey a specific copy of the covered work, then the patent license
|
518 |
+
you grant is automatically extended to all recipients of the covered
|
519 |
+
work and works based on it.
|
520 |
+
|
521 |
+
A patent license is "discriminatory" if it does not include within
|
522 |
+
the scope of its coverage, prohibits the exercise of, or is
|
523 |
+
conditioned on the non-exercise of one or more of the rights that are
|
524 |
+
specifically granted under this License. You may not convey a covered
|
525 |
+
work if you are a party to an arrangement with a third party that is
|
526 |
+
in the business of distributing software, under which you make payment
|
527 |
+
to the third party based on the extent of your activity of conveying
|
528 |
+
the work, and under which the third party grants, to any of the
|
529 |
+
parties who would receive the covered work from you, a discriminatory
|
530 |
+
patent license (a) in connection with copies of the covered work
|
531 |
+
conveyed by you (or copies made from those copies), or (b) primarily
|
532 |
+
for and in connection with specific products or compilations that
|
533 |
+
contain the covered work, unless you entered into that arrangement,
|
534 |
+
or that patent license was granted, prior to 28 March 2007.
|
535 |
+
|
536 |
+
Nothing in this License shall be construed as excluding or limiting
|
537 |
+
any implied license or other defenses to infringement that may
|
538 |
+
otherwise be available to you under applicable patent law.
|
539 |
+
|
540 |
+
12. No Surrender of Others' Freedom.
|
541 |
+
|
542 |
+
If conditions are imposed on you (whether by court order, agreement or
|
543 |
+
otherwise) that contradict the conditions of this License, they do not
|
544 |
+
excuse you from the conditions of this License. If you cannot convey a
|
545 |
+
covered work so as to satisfy simultaneously your obligations under this
|
546 |
+
License and any other pertinent obligations, then as a consequence you may
|
547 |
+
not convey it at all. For example, if you agree to terms that obligate you
|
548 |
+
to collect a royalty for further conveying from those to whom you convey
|
549 |
+
the Program, the only way you could satisfy both those terms and this
|
550 |
+
License would be to refrain entirely from conveying the Program.
|
551 |
+
|
552 |
+
13. Use with the GNU Affero General Public License.
|
553 |
+
|
554 |
+
Notwithstanding any other provision of this License, you have
|
555 |
+
permission to link or combine any covered work with a work licensed
|
556 |
+
under version 3 of the GNU Affero General Public License into a single
|
557 |
+
combined work, and to convey the resulting work. The terms of this
|
558 |
+
License will continue to apply to the part which is the covered work,
|
559 |
+
but the special requirements of the GNU Affero General Public License,
|
560 |
+
section 13, concerning interaction through a network will apply to the
|
561 |
+
combination as such.
|
562 |
+
|
563 |
+
14. Revised Versions of this License.
|
564 |
+
|
565 |
+
The Free Software Foundation may publish revised and/or new versions of
|
566 |
+
the GNU General Public License from time to time. Such new versions will
|
567 |
+
be similar in spirit to the present version, but may differ in detail to
|
568 |
+
address new problems or concerns.
|
569 |
+
|
570 |
+
Each version is given a distinguishing version number. If the
|
571 |
+
Program specifies that a certain numbered version of the GNU General
|
572 |
+
Public License "or any later version" applies to it, you have the
|
573 |
+
option of following the terms and conditions either of that numbered
|
574 |
+
version or of any later version published by the Free Software
|
575 |
+
Foundation. If the Program does not specify a version number of the
|
576 |
+
GNU General Public License, you may choose any version ever published
|
577 |
+
by the Free Software Foundation.
|
578 |
+
|
579 |
+
If the Program specifies that a proxy can decide which future
|
580 |
+
versions of the GNU General Public License can be used, that proxy's
|
581 |
+
public statement of acceptance of a version permanently authorizes you
|
582 |
+
to choose that version for the Program.
|
583 |
+
|
584 |
+
Later license versions may give you additional or different
|
585 |
+
permissions. However, no additional obligations are imposed on any
|
586 |
+
author or copyright holder as a result of your choosing to follow a
|
587 |
+
later version.
|
588 |
+
|
589 |
+
15. Disclaimer of Warranty.
|
590 |
+
|
591 |
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
592 |
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
593 |
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
594 |
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
595 |
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
596 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
597 |
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
598 |
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
599 |
+
|
600 |
+
16. Limitation of Liability.
|
601 |
+
|
602 |
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
603 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
604 |
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
605 |
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
606 |
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
607 |
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
608 |
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
609 |
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
610 |
+
SUCH DAMAGES.
|
611 |
+
|
612 |
+
17. Interpretation of Sections 15 and 16.
|
613 |
+
|
614 |
+
If the disclaimer of warranty and limitation of liability provided
|
615 |
+
above cannot be given local legal effect according to their terms,
|
616 |
+
reviewing courts shall apply local law that most closely approximates
|
617 |
+
an absolute waiver of all civil liability in connection with the
|
618 |
+
Program, unless a warranty or assumption of liability accompanies a
|
619 |
+
copy of the Program in return for a fee.
|
620 |
+
|
621 |
+
END OF TERMS AND CONDITIONS
|
622 |
+
|
623 |
+
How to Apply These Terms to Your New Programs
|
624 |
+
|
625 |
+
If you develop a new program, and you want it to be of the greatest
|
626 |
+
possible use to the public, the best way to achieve this is to make it
|
627 |
+
free software which everyone can redistribute and change under these terms.
|
628 |
+
|
629 |
+
To do so, attach the following notices to the program. It is safest
|
630 |
+
to attach them to the start of each source file to most effectively
|
631 |
+
state the exclusion of warranty; and each file should have at least
|
632 |
+
the "copyright" line and a pointer to where the full notice is found.
|
633 |
+
|
634 |
+
<one line to give the program's name and a brief idea of what it does.>
|
635 |
+
Copyright (C) <year> <name of author>
|
636 |
+
|
637 |
+
This program is free software: you can redistribute it and/or modify
|
638 |
+
it under the terms of the GNU General Public License as published by
|
639 |
+
the Free Software Foundation, either version 3 of the License, or
|
640 |
+
(at your option) any later version.
|
641 |
+
|
642 |
+
This program is distributed in the hope that it will be useful,
|
643 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
644 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
645 |
+
GNU General Public License for more details.
|
646 |
+
|
647 |
+
You should have received a copy of the GNU General Public License
|
648 |
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
649 |
+
|
650 |
+
Also add information on how to contact you by electronic and paper mail.
|
651 |
+
|
652 |
+
If the program does terminal interaction, make it output a short
|
653 |
+
notice like this when it starts in an interactive mode:
|
654 |
+
|
655 |
+
<program> Copyright (C) <year> <name of author>
|
656 |
+
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
657 |
+
This is free software, and you are welcome to redistribute it
|
658 |
+
under certain conditions; type `show c' for details.
|
659 |
+
|
660 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
661 |
+
parts of the General Public License. Of course, your program's commands
|
662 |
+
might be different; for a GUI interface, you would use an "about box".
|
663 |
+
|
664 |
+
You should also get your employer (if you work as a programmer) or school,
|
665 |
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
666 |
+
For more information on this, and how to apply and follow the GNU GPL, see
|
667 |
+
<http://www.gnu.org/licenses/>.
|
668 |
+
|
669 |
+
The GNU General Public License does not permit incorporating your program
|
670 |
+
into proprietary programs. If your program is a subroutine library, you
|
671 |
+
may consider it more useful to permit linking proprietary applications with
|
672 |
+
the library. If this is what you want to do, use the GNU Lesser General
|
673 |
+
Public License instead of this License. But first, please read
|
674 |
+
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
trunk/assets/banner-1544x500.png
ADDED
Binary file
|
trunk/assets/banner-772x250.png
ADDED
Binary file
|
trunk/assets/css/style.css
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.loading-indicator {
|
2 |
+
display: inline-block;
|
3 |
+
vertical-align:top;
|
4 |
+
margin-top:5px;
|
5 |
+
}
|
6 |
+
|
7 |
+
.woocommerce table.form-table .select2-container {
|
8 |
+
display: inline-block !important;
|
9 |
+
}
|
10 |
+
|
11 |
+
.woocommerce-mailchimp-loading {
|
12 |
+
margin-left: 5px;
|
13 |
+
margin-top: 2px;
|
14 |
+
display: inline-block;
|
15 |
+
}
|
16 |
+
|
17 |
+
.woocommerce-mailchimp-loading-indicator {
|
18 |
+
color: #32373c;
|
19 |
+
}
|
20 |
+
|
21 |
+
.woocommerce-mailchimp-loading-indicator:before {
|
22 |
+
font-family: dashicons;
|
23 |
+
line-height: 1.5em;
|
24 |
+
display: inline-block;
|
25 |
+
font-size: 20px;
|
26 |
+
line-height: 1;
|
27 |
+
text-decoration: inherit;
|
28 |
+
font-weight: 400;
|
29 |
+
font-style: normal;
|
30 |
+
vertical-align: top;
|
31 |
+
text-align: center;
|
32 |
+
content: "\f463";
|
33 |
+
}
|
34 |
+
|
35 |
+
.woocommerce-mailchimp-loading-indicator.loading:before {\
|
36 |
+
-webkit-animation: rotation 2s infinite linear;
|
37 |
+
animation: rotation 2s infinite linear;
|
38 |
+
}
|
39 |
+
|
40 |
+
.woocommerce-mailchimp-loading-indicator.success:before {
|
41 |
+
color: #46b450;
|
42 |
+
content: "\f147";
|
43 |
+
}
|
44 |
+
|
45 |
+
.woocommerce-mailchimp-loading-indicator.error:before {
|
46 |
+
color: #dc3232;
|
47 |
+
content: "\f534";
|
48 |
+
}
|
trunk/assets/icon-128x128.png
ADDED
Binary file
|
trunk/assets/icon-256x256.png
ADDED
Binary file
|
trunk/assets/icon-500x500.png
ADDED
Binary file
|
trunk/assets/icon.svg
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
2 |
+
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3 |
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
4 |
+
viewBox="0 0 500 500" style="enable-background:new 0 0 500 500;" xml:space="preserve">
|
5 |
+
<style type="text/css">
|
6 |
+
.st0{fill:url(#SVGID_1_);}
|
7 |
+
.st1{fill:#684C46;}
|
8 |
+
.st2{fill:#F5DCBA;}
|
9 |
+
.st3{fill:#0788BF;}
|
10 |
+
.st4{fill:#46B8E3;}
|
11 |
+
.st5{fill:#FFD14F;}
|
12 |
+
.st6{fill:#122030;}
|
13 |
+
.st7{fill:#FFFFFF;}
|
14 |
+
.st8{fill:#EABE8D;}
|
15 |
+
.st9{fill:#9C7356;}
|
16 |
+
.st10{fill:#9B5C8F;}
|
17 |
+
</style>
|
18 |
+
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="-1" y1="250" x2="501" y2="250" gradientTransform="matrix(4.489659e-11 1 -1 4.489659e-11 500 0)">
|
19 |
+
<stop offset="0" style="stop-color:#0087C1"/>
|
20 |
+
<stop offset="1" style="stop-color:#3FB7E5"/>
|
21 |
+
</linearGradient>
|
22 |
+
<rect x="-1" y="-1" class="st0" width="502" height="502"/>
|
23 |
+
<g>
|
24 |
+
<path class="st1" d="M425,374.1c-0.3,1-27.9,107-136.3,107c-93.7,0-138.2-81.5-138.2-81.5c-6.8,0.4-13.4-0.7-19.5-2.9
|
25 |
+
c-27.5-10.1-40.7-41.6-31.2-68l-15.1-11.5C26.2,272.5,192,68.5,250.7,114.6c0.3,0.2,14,11.3,14,11.3c21.1-12.8,41.9-19.7,58.9-19.7
|
26 |
+
c12,0,22.1,3.5,28.9,10.8c15.2,16.5,9.8,48-11,79.8c4.5,4.2,8.2,10,10.8,15.7c6.6,5.1,10.9,12.8,13,23.6
|
27 |
+
c2.4,11.9,2.9,28.9,4.3,36.1c5.6,2.5,3.2,1.4,9.2,4.3c6.2,3.1,13.8,6.9,22.2,15c14.9,3.7,20.6,19.6,11.9,30.4
|
28 |
+
c-0.2,0.3-1.3,1.5-2.4,2.8c0.3,0.7,3.1,5.3,5.2,14.7c6.2,1.5,11.1,5.3,13.7,10.8C433.8,361.1,425,374.1,425,374.1z M382,454.2v4.4
|
29 |
+
h1.7v-4.4h1.7v-1.4h-5.2v1.4H382z M386,452.8v5.8h1.6v-4.2l1.3,4.2h1.3l1.3-4.2v4.2h1.6v-5.8h-2.4l-1,3.4l-1.1-3.4H386z"/>
|
30 |
+
<path class="st2" d="M172.7,334.2L172.7,334.2L172.7,334.2c2.4-6,3.6-10.9,3.6-10.9c2.7,8.3,4.1,17,3.5,25.7l0,0l0,0
|
31 |
+
c2.2-3,4.6-8.6,4.6-8.6c4.2,24.5-13.7,47-37.3,47c-20.9,0-37.9-17.9-37.9-39.9c0-22.1,17-39.9,37.9-39.9c5.4,0,10.6,1.2,15.3,3.4
|
32 |
+
C162.3,310.9,170.4,315,172.7,334.2z M379.1,420.7c29.4-23.1,34.5-50.9,35-51.9c7.2-8.7,5.3-17.2-4.3-17.2c-3,0-5.3,0.8-5.3,0.8
|
33 |
+
s0-12.7-5.8-22.5c-4.5,5.1-17,15.1-33.5,22.9c-15.4,7.3-36,13.7-61.5,14.6h0c-7.1,0.3-11.6-0.9-14,7.5c-0.8,2.9-0.5,7.3,0.1,8.6
|
34 |
+
c2,6.9,7.3,9.9,14.2,11.5c5.2,1.2,10.8,1.3,10.8,1.3c51.7,1.5,93.3-38.9,93.7-39.2c0.5-0.4,0.9-0.9,0.9-0.9s-0.5,1.1-0.5,1.2
|
35 |
+
c-7.5,16.8-50.7,47.3-93.8,46.4l-0.1,0c-10,0-22.1-2.6-28.4-10.4c-10-12.4-4.8-32.9,11.1-33.4c0,0,3.7-0.1,5.3-0.1
|
36 |
+
c39.4-1.2,74.7-15.7,100-45.9c3.5-4.3-0.4-10.3-7.9-10.4c-0.1,0-0.1,0-0.2-0.1c-8.9-9.6-16.8-13-23.8-16.5
|
37 |
+
c-14.7-7.5-13.3-1-16.7-37.2c-0.9-9.8-2.8-23.1-11.3-28.2c-2.2-1.3-4.7-1.9-7.3-1.9c-2.5,0-3.7,0.5-4.2,0.6
|
38 |
+
c-4.7,1-7.4,3.7-10.7,6.8c-15.8,14.6-28.5,10.6-47.3,10.5c-17.7-0.2-33.4,12.2-36.4,31.2l0,0c-1.5,9.9-0.5,20,1,24.6
|
39 |
+
c0,0-4.8-3.2-7.1-6c2.8,17.3,18.6,28.7,18.6,28.7c-2.5,0.6-6.1,0.3-6.1,0.3c0,0,9,7.1,16.9,9.6c-2,1.3-12.3,11.4-17.7,25.5
|
40 |
+
c-5,13.1-2.9,28.8-2.9,28.8l4.3-6.4c0,0-2.8,14.4,2.6,28.3c1.8-4.1,5.8-11.5,5.8-11.5s-0.6,15.4,6.8,28c0.2-2.9,1.3-10.3,1.3-10.3
|
41 |
+
s4.3,13.2,14.1,22.4C293.2,446.9,342,449.9,379.1,420.7z"/>
|
42 |
+
<path class="st3" d="M105.5,317.5c-0.1,0-14.3-10.4-16.3-13.8c-11.9-20.1,8.8-61.2,23.5-84.7c36.4-57.9,96.9-103.5,124.4-97
|
43 |
+
l28.2,14.6c-11,6.4-21.6,14.4-27.9,19.6l-6,5c0,0-17.5,11.8-26.3,19.3c-35,29.8-69.4,76-82.2,120.6
|
44 |
+
C123,301.1,112.5,306.3,105.5,317.5z"/>
|
45 |
+
<path class="st4" d="M237.1,122L237.1,122c-27.5-6.5-88,39.1-124.4,97c0,0,0,0,0,0.1l0.1,0l29,22.8c31.8-50.5,71.8-76.5,72.9-77.3
|
46 |
+
l-4.6-30.9l8.6-4.1l17.3,5.6l-1.3-5.8L237.1,122L237.1,122z"/>
|
47 |
+
<path class="st5" d="M265.3,136.5l-27.9,19.6l-2,1.5l-24.7-20.2l-0.6-3.8l8.6-4.1c0.4,0.1,16.6,5.4,17.3,5.6l0.3-10.7l0.8-2.4
|
48 |
+
l7.6-2.9C244.7,119.1,265.3,136.5,265.3,136.5z"/>
|
49 |
+
<g>
|
50 |
+
<path class="st6" d="M320.4,117.3c-18.5,0-39.2,9.7-55.1,19.3c-2.2,1.3-4.4,2.7-6.6,4.1l-8.3-7l3,10.5c-1.1,0.8-2.3,1.6-3.3,2.3
|
51 |
+
l-17.2-5.2l11.4,9.5c-2.6,2-4.9,3.8-6.8,5.4l-27.3-22.5l1.4,10.1l19.8,17.5c0,0-17.5,11.8-26.3,19.3c-35,29.8-69.4,76-82.2,120.6
|
52 |
+
l0.7-0.4c0.1-0.1,0.2-0.1,0.3-0.2c0.4-0.2,0.7-0.4,1.1-0.6c0.2-0.1,0.5-0.2,0.7-0.3c0.4-0.2,0.7-0.3,1.1-0.5
|
53 |
+
c0.2-0.1,0.4-0.2,0.6-0.3c0.4-0.2,0.8-0.3,1.2-0.5c0.2-0.1,0.4-0.1,0.5-0.2c0.6-0.2,1.2-0.4,1.7-0.6c8.7-2.6,20.5-4.3,34.3,1.6
|
54 |
+
c6.9-17.5,15.2-35.3,28.3-52.4c10.6-13.9,20.8-26.3,33-33.1c23.2-21.8,85.6-44.8,105.6-24.8c4.7-7.7,8.8-15.1,12.2-24.2
|
55 |
+
C352.7,142.6,352.9,117.3,320.4,117.3z"/>
|
56 |
+
<polygon class="st6" points="241.2,136.8 237.1,122 234.7,129.4 236.1,135.2 "/>
|
57 |
+
</g>
|
58 |
+
<path class="st7" d="M404.5,352.4c0,0,0-12.7-5.8-22.5c-4.5,5.1-17,15.1-33.5,22.9c-15.4,7.3-36,13.7-61.5,14.6h0
|
59 |
+
c-7.1,0.3-11.6-0.9-14,7.5c-0.2,0.7-0.3,1.5-0.4,2.3l0,0.1c0,0,0,0,0,0c0,0.3,0,0.5,0,0.8c0,0.8,0,1.4,0,2c0,0,0,0,0,0
|
60 |
+
c0,0,0,0.1,0,0.1c0,0.4,0.1,0.7,0.1,1c0,0,0,0,0,0c0,0,0,0,0,0.1c0.2,1.3,0.4,1.9,0.5,2c0,0,0,0,0,0l0,0.1c2,6.8,7.3,9.8,14.2,11.4
|
61 |
+
c5.2,1.2,10.8,1.3,10.8,1.3c42.2,1.2,77.6-25.5,89.5-35.5C404.5,358,404.6,356,404.5,352.4z M283.3,127c10.1-4.6,20.9-8.3,31.2-9.4
|
62 |
+
c-10.3,2.3-22.8,7.7-37.7,16.7c-0.4,0.2-35.2,23.7-56.4,44.8c-11.6,11.5-58.1,67.3-58.1,67.2c8.5-16.1,14.1-24,27.6-40.9
|
63 |
+
c7.6-9.6,15.7-18.9,24.1-27.5c2.8-2.9,5.6-5.7,8.4-8.4l0,0l0,0C223.4,168.5,247.8,143.6,283.3,127z"/>
|
64 |
+
<path class="st8" d="M379.1,420.7c-5,4-10.3,7.3-15.7,10.2c-12.4-4.7-20-14.8-20-14.8s10.7-2.5,24.9-9.8
|
65 |
+
c17.3-8.8,33.5-21.5,45.9-37.5C413.6,369.8,408.5,397.6,379.1,420.7z M345.3,286.6c-6-4.3-16-0.9-18.2,6.2c3.5,0.2,7.2,2.8,6.9,6.2
|
66 |
+
c2.5-2.4,5.9-3.7,9.3-3.7C341.8,292.7,342.6,288.1,345.3,286.6z M282.2,372.9c1.9-7,7.2-12.6,15.4-12.9c0,0,3.7-0.1,5.3-0.1
|
67 |
+
c39.4-1.2,74.7-15.7,100-45.9c3.5-4.3-0.4-10.3-7.9-10.4c0,0-0.1,0-0.1,0c-1.3,1.3-1.5,3.8-3.6,7.5c-7.7,13.4-18.3,19.5-32.5,26.6
|
68 |
+
c-43.5,21.7-66.1,11.6-75.1,24.8C281,366.4,280.9,370.7,282.2,372.9C282.2,372.9,282.2,372.9,282.2,372.9z M360.9,282
|
69 |
+
c-4.2-3-4.3-8.2-6.6-32.3c-0.7-7.7-2-17.6-6.7-23.9c-1-0.8-2.3-1.8-4.3-1.8c-3-0.1-6.3,2.9-8.2,5.1c-5.4,7.8-10.6,12.8-19.7,17.2
|
70 |
+
c-9.2,4.2-18,5.7-27.1,5.4c-6.7-0.2-12.5-1.3-18.2-1.4c-10.6-0.2-19.8,3.3-26.5,11.7c-4.6,5.8-6.4,11.9-7,19.3
|
71 |
+
c0,0.9,0.1,1.7,0.1,2.5c0.1,1.2,0.2,2.3,0.3,3.3c0.5,3.7,1.1,5.6,1.1,5.6c0,0,0,0.1,0,0.1c0.1,0.2,0.1,0.4,0.2,0.5
|
72 |
+
c0,0-4.8-3.2-7.1-6c2.3,14.5,13.7,24.7,17.4,27.8c0.2,0.2,0.4,0.3,0.6,0.5c0,0,0,0,0,0c0.3,0.2,0.5,0.4,0.5,0.4
|
73 |
+
c-2.5,0.6-6.1,0.3-6.1,0.3c0,0,9,7.1,16.9,9.6c10.4-8.8,22.1-12.1,31.8-13.2c5.9-3.6,12.2-7.2,18.9-10.6
|
74 |
+
c-2-12.7,9.3-25.6,23.5-26.8c10.7-0.8,16,4,19.7,9.2c2-0.7,4.3-1.4,6.9-2.1C361.2,282.2,361,282.2,360.9,282z M366.1,367.9
|
75 |
+
c-0.1,0-0.2,0-0.4,0.1c-4.3,1-48.5,18.1-76.5,9.3c-0.1,1.5-0.1,4.7,0.5,6.1c0,0,0,0,0,0c4.2,0.8,9.6,1.4,15.8,1.4
|
76 |
+
C342.3,384.8,368.8,368.1,366.1,367.9z M160.3,364.5C160.3,364.5,160.3,364.4,160.3,364.5c2.3-2.4,3.2-5.8,2.7-9
|
77 |
+
c-0.8-4.6-6.1-5.6-9.5-9.2c-0.1-0.1-0.1-0.1-0.2-0.2c-0.1-0.1-0.1-0.1-0.2-0.2c0,0,0,0,0,0c-1.6-1.8-2.1-3.8-2-5.7
|
78 |
+
c0.3-4.7,4.5-6.1,6.7-5.2c0,0,2.6,0.6,4.6,3.4c0,0,0,0,0,0c-0.3-0.9-0.2-2.4-1.8-4.6c-2.6-3.7-8.5-7.4-16.9-5.6h0
|
79 |
+
c-1.6,0.3-0.7,0.1-2.2,0.6c-0.2,0.1-0.5,0.1-0.6,0.2c-0.5,0.2-0.9,0.4-1.4,0.6l0,0c-0.2,0.1-1.5,0.7-3,1.8
|
80 |
+
C127,343.6,143,365.7,160.3,364.5z"/>
|
81 |
+
<path class="st9" d="M299.4,289.5c0.8,1.2,1,2,0.7,2.4c-0.6,0.7-2.9-0.3-6.3-1.6c-8.7-3.2-15-3.7-26.3,0.6
|
82 |
+
c-2.9,1.1-4.9,1.9-5.9,1.8c-1.6-0.2-0.1-3.1,3.4-5.9c7-5.6,16.5-7.3,24.7-4.2C293.3,283.8,297.3,286.4,299.4,289.5z M297.7,298.4
|
83 |
+
c-2.4-1.8-6.7-3-11.3-2.3c-1,0.1-1.8,0.4-2.7,0.7c-0.3,0.1-0.6,0.2-0.9,0.3c-1.9,0.8-3.5,1.6-5.1,3.2c-1.8,1.7-2.3,3.4-1.8,3.8
|
84 |
+
c0.5,0.4,1.8-0.2,3.7-1c6.5-2.7,11.1-2.8,15.4-2.5c2.1,0.1,3.5,0.3,3.8-0.3C299.1,299.9,298.7,299.1,297.7,298.4z M158.1,331.6
|
85 |
+
L158.1,331.6L158.1,331.6c1.1,0.8,1.9,1.8,2.5,2.6c2,2.8,1.4,4.5,2.2,5.3c0.3,0.3,0.7,0.4,1.1,0.2c1.1-0.5,1.7-2.3,1.8-3.5l0,0l0,0
|
86 |
+
l0,0c0.3-3-1.3-6.4-3.4-8.8l0,0l0,0l0,0c-1.3-1.5-3-2.9-5-4c-2-1.1-4.4-2-7-2.4c-4.5-0.7-8.9,0.2-10.1,0.6l0,0
|
87 |
+
c-0.6,0.2-1.4,0.3-2.1,0.6c-7.3,2.8-12.1,8.1-14.2,15l0,0l0,0c-0.8,2.6-1.1,5.2-1.1,7.5c0,2,0.2,3.9,0.6,5.6v0l0,0l0,0
|
88 |
+
c0.6,2.8,1.9,6,3.8,8.1l0,0l0,0l0,0c2.5,2.7,5.2,2.2,4-0.3c-0.3-0.7-1.8-3.5-2-8.6c-0.1-3.3,0.3-6.8,1.5-9.9
|
89 |
+
c0.7-1.7,1.6-3.4,2.8-4.9c2.5-3,5.5-4.4,5.9-4.6l0,0c0.4-0.2,0.9-0.4,1.4-0.6c0.2-0.1,0.4-0.1,0.6-0.2c1.5-0.4,0.7-0.2,2.2-0.6h0
|
90 |
+
C149.5,327.4,154.5,328.7,158.1,331.6z M156.8,342.9c-0.8-0.6-1.2-1.2-1.4-2c-0.3-1.5-0.2-2.4,1.1-3.3c1-0.7,1.8-1,1.8-1.5
|
91 |
+
c0-0.8-3.3-1.7-5.7,0.7c-2,2.1-2.6,6.4,0.5,9.8c3.5,3.7,8.9,4.6,9.7,9.3c0.1,0.7,0.2,1.4,0.1,2.1c0,0.8-0.3,2.1-0.3,2.1
|
92 |
+
c-1,4.5-5.4,8.9-12.5,7.8c-1.3-0.2-2.2-0.4-2.4,0c-0.5,0.8,2.5,4.3,8.1,4.1c5.5-0.1,10.9-4.2,12.6-10.3c0-0.1,0.5-1.8,0.6-3.4
|
93 |
+
c0.1-1.2,0-2.3-0.2-3.6C167.6,346.8,159.7,345.2,156.8,342.9z M347.1,286.5c-2.2-0.3-4.3,1.8-4.7,4.7c-0.5,3,0.9,5.6,3.1,6
|
94 |
+
c2.2,0.3,4.3-1.8,4.7-4.7C350.7,289.6,349.3,286.9,347.1,286.5z M323.4,295.2c-1.2,2.2,0.3,5.2,3.2,6.9c3,1.6,6.3,1.2,7.5-1
|
95 |
+
c1.2-2.2-0.3-5.2-3.2-6.9C328,292.6,324.6,293,323.4,295.2z M236.6,207.6c40.8-26.5,81.6-29.5,95.6-18.8c0,0,0,0,0,0
|
96 |
+
c0-0.1-0.3-0.7-0.3-0.9l0,0c-3.5-7.5-11.8-12.8-19.2-14.9c1.3,1.3,3.2,3.8,3.9,5.3c-5.6-3.8-13-7.2-20.7-8.8c0,0,0.9,0.7,1.1,0.8
|
97 |
+
c1.5,1.4,3.6,3.7,4.4,5.6c-7.4-3-16.7-4.6-24.7-3.1c-0.1,0-1,0.2-1,0.2s1,0.3,1.3,0.3c2.6,0.8,6.4,2.4,8.1,4.6
|
98 |
+
c-13.3-2.3-27.8,0.2-35.7,4.6c1,0,1,0,1.9,0c2.9,0.1,8.7,0.5,11.2,2c-8.4,1.7-20.5,5.4-27,11c1.1-0.1,7.7-1,10.3-0.5
|
99 |
+
c-35.8,20.5-52.2,51.5-52.2,51.5l0,0C204.2,233,217.9,219.7,236.6,207.6z"/>
|
100 |
+
<path class="st1" d="M332.9,265.4c-0.1-2.8,0.4-7.5,3-8.3l0,0c0,0,0,0,0,0l0,0c4.5-1.6,10.5,10,10.8,20.3
|
101 |
+
c-3.6-1.8-7.8-2.6-12.1-2.2C333.5,271.9,333,268.8,332.9,265.4z"/>
|
102 |
+
</g>
|
103 |
+
<g>
|
104 |
+
<path class="st10" d="M35.4,19.2h126.9c8,0,14.5,6.5,14.5,14.5v48.4c0,8-6.5,14.5-14.5,14.5h-45.5L123,112L95.5,96.7H35.4
|
105 |
+
c-8,0-14.5-6.5-14.5-14.5V33.7C20.8,25.8,27.3,19.2,35.4,19.2z"/>
|
106 |
+
<path class="st7" d="M28.7,32.4c0.9-1.2,2.2-1.8,4-2c3.3-0.3,5.1,1.3,5.5,4.6c2,13.3,4.1,24.6,6.4,33.8l14-26.6
|
107 |
+
c1.3-2.4,2.9-3.7,4.8-3.8c2.8-0.2,4.5,1.6,5.2,5.4c1.6,8.5,3.6,15.7,6.1,21.8c1.7-16.2,4.5-27.9,8.4-35.1c1-1.8,2.4-2.7,4.2-2.8
|
108 |
+
c1.5-0.1,2.8,0.3,4,1.3c1.2,1,1.8,2.2,2,3.6c0.1,1.1-0.1,2.1-0.6,3.1c-2.5,4.6-4.5,12.3-6.2,23c-1.6,10.4-2.2,18.5-1.8,24.3
|
109 |
+
c0.1,1.6-0.1,3-0.8,4.2c-0.8,1.4-1.9,2.2-3.4,2.3c-1.7,0.1-3.4-0.6-5-2.4C69.6,81.1,64.9,72,61.4,60c-4.1,8.2-7.2,14.3-9.2,18.4
|
110 |
+
c-3.8,7.2-6.9,10.9-9.6,11.1c-1.7,0.1-3.2-1.3-4.5-4.4c-3.3-8.3-6.8-24.5-10.5-48.4C27.5,35,27.8,33.5,28.7,32.4z"/>
|
111 |
+
<path class="st7" d="M165.7,42.4c-2.3-4-5.7-6.4-10.2-7.4c-1.2-0.3-2.4-0.4-3.4-0.4c-6.1,0-11.1,3.2-15,9.6c-3.3,5.4-5,11.4-5,18
|
112 |
+
c0,4.9,1,9.1,3.1,12.6c2.3,4,5.7,6.4,10.2,7.4c1.2,0.3,2.4,0.4,3.4,0.4c6.2,0,11.2-3.2,15-9.6c3.3-5.5,5-11.5,5-18
|
113 |
+
C168.8,50,167.7,45.8,165.7,42.4L165.7,42.4z M157.7,60c-0.9,4.2-2.5,7.3-4.8,9.4c-1.8,1.7-3.6,2.4-5.2,2c-1.5-0.3-2.8-1.7-3.8-4.1
|
114 |
+
c-0.8-2-1.1-4-1.1-5.8c0-1.6,0.1-3.2,0.4-4.7c0.6-2.6,1.7-5.2,3.4-7.6c2.1-3.1,4.3-4.4,6.6-4c1.5,0.3,2.8,1.7,3.8,4.1
|
115 |
+
c0.8,2,1.1,4,1.1,5.8C158.1,57,157.9,58.6,157.7,60L157.7,60z"/>
|
116 |
+
<path class="st7" d="M125.7,42.4c-2.3-4-5.7-6.4-10.2-7.4c-1.2-0.3-2.4-0.4-3.4-0.4c-6.1,0-11.1,3.2-15,9.6c-3.3,5.4-5,11.4-5,18
|
117 |
+
c0,4.9,1,9.1,3.1,12.6c2.3,4,5.7,6.4,10.2,7.4c1.2,0.3,2.4,0.4,3.4,0.4c6.2,0,11.2-3.2,15-9.6c3.3-5.5,5-11.5,5-18
|
118 |
+
C128.8,50,127.8,45.8,125.7,42.4L125.7,42.4z M117.7,60c-0.9,4.2-2.5,7.3-4.8,9.4c-1.8,1.7-3.6,2.4-5.2,2c-1.5-0.3-2.8-1.7-3.8-4.1
|
119 |
+
c-0.8-2-1.1-4-1.1-5.8c0-1.6,0.1-3.2,0.4-4.7c0.6-2.6,1.7-5.2,3.4-7.6c2.1-3.1,4.3-4.4,6.6-4c1.5,0.3,2.8,1.7,3.8,4.1
|
120 |
+
c0.8,2,1.1,4,1.1,5.8C118.1,57,118,58.6,117.7,60L117.7,60z"/>
|
121 |
+
<g>
|
122 |
+
<g>
|
123 |
+
<path d="M192.9,41.8c-4.3,4.2-6.4,9.6-6.4,16.1c0,6.9,2.1,12.6,6.3,16.9c4.2,4.3,9.7,6.4,16.5,6.4c2,0,4.2-0.3,6.6-1V69.9
|
124 |
+
c-2.2,0.6-4.1,1-5.8,1c-3.4,0-6.1-1.1-8.1-3.4c-2-2.3-3.1-5.4-3.1-9.2c0-3.6,1-6.6,3-8.9c2-2.4,4.5-3.5,7.6-3.5
|
125 |
+
c2,0,4.1,0.3,6.4,1V36.4c-2.1-0.6-4.5-0.8-6.9-0.8C202.5,35.5,197.2,37.6,192.9,41.8z M237.1,35.5c-5.9,0-10.5,2-13.8,5.9
|
126 |
+
s-4.9,9.4-4.9,16.4c0,7.6,1.7,13.4,4.9,17.4s8,6.1,14.3,6.1c6.1,0,10.7-2,14-6.1s4.9-9.7,4.9-17s-1.7-12.9-5-16.8
|
127 |
+
C248.2,37.5,243.4,35.5,237.1,35.5z M242.2,68.6c-1.1,1.8-2.9,2.7-5,2.7c-2,0-3.6-0.9-4.7-2.7c-1.1-1.8-1.6-5.4-1.6-10.8
|
128 |
+
c0-8.3,2.1-12.5,6.4-12.5c4.5,0,6.8,4.2,6.8,12.7C244,63.3,243.3,66.9,242.2,68.6z M288,36.7l-2.3,9.8c-0.6,2.5-1.1,5-1.7,7.6
|
129 |
+
l-1.3,6.8c-1.2-6.8-2.9-14.8-5-24.2H263l-5.5,43.4h11.1l3-29.9l7.6,29.9h7.9l7.3-29.8l3.1,29.8H309l-5.9-43.4L288,36.7L288,36.7z
|
130 |
+
M341.1,36.7l-2.3,9.8c-0.6,2.5-1.1,5-1.7,7.6l-1.3,6.8c-1.2-6.8-2.9-14.8-5-24.2h-14.8l-5.5,43.4h11.1l3-29.9l7.6,29.9h7.9
|
131 |
+
l7.2-29.8l3.1,29.8h11.6l-5.9-43.4H341.1z M377.2,63h10.4v-9h-10.4v-8h12v-9.2h-23.7v43.4h23.8v-9.2h-12V63z M422.2,56.1
|
132 |
+
c1.2-2,1.8-4,1.8-6.1c0-4.1-1.6-7.3-4.8-9.7c-3.2-2.4-7.6-3.6-13.1-3.6h-13.6v43.4h11.7V60.4h0.2l9.5,19.8h12.4L417,60.6
|
133 |
+
C419.2,59.5,421,58.1,422.2,56.1z M404.2,55.4V45.1c2.8,0.1,4.8,0.5,6,1.4c1.2,0.9,1.8,2.3,1.8,4.3
|
134 |
+
C412,53.8,409.4,55.3,404.2,55.4z M431,41.8c-4.3,4.2-6.4,9.6-6.4,16.1c0,6.9,2.1,12.6,6.3,16.9c4.2,4.3,9.7,6.4,16.5,6.4
|
135 |
+
c2,0,4.2-0.3,6.6-1V69.9c-2.2,0.6-4.1,1-5.8,1c-3.4,0-6.1-1.1-8.1-3.4c-2-2.3-3.1-5.4-3.1-9.2c0-3.6,1-6.6,3-8.9
|
136 |
+
c2-2.4,4.5-3.5,7.6-3.5c2,0,4.1,0.3,6.4,1V36.4c-2.1-0.6-4.5-0.8-6.9-0.8C440.6,35.5,435.2,37.6,431,41.8z M469,70.8v-7.9h10.4
|
137 |
+
v-9H469v-8h12v-9.2h-23.7v43.4h23.8v-9.2L469,70.8L469,70.8z"/>
|
138 |
+
</g>
|
139 |
+
</g>
|
140 |
+
</g>
|
141 |
+
</svg>
|
trunk/assets/js/woocommerce-mailchimp-admin.js
ADDED
@@ -0,0 +1,340 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* WooCommerce MailChimp Plugin
|
3 |
+
*/
|
4 |
+
var SS_WC_MailChimp = function($) {
|
5 |
+
|
6 |
+
var $enabled;
|
7 |
+
var $apiKey;
|
8 |
+
var $accountLoadingIndicator;
|
9 |
+
var $listsLoadingIndicator;
|
10 |
+
var $mainList;
|
11 |
+
var $interestGroupsLoadingIndicator;
|
12 |
+
var $interestGroups;
|
13 |
+
var $displayOptIn;
|
14 |
+
var $occurs;
|
15 |
+
var $optInLabel;
|
16 |
+
var $optInCheckboxDefault;
|
17 |
+
var $optInCheckboxLocation;
|
18 |
+
var $doubleOptIn;
|
19 |
+
|
20 |
+
var namespace = 'ss_wc_mailchimp';
|
21 |
+
|
22 |
+
return {
|
23 |
+
init: init,
|
24 |
+
checkApiKey: checkApiKey,
|
25 |
+
loadLists: loadLists,
|
26 |
+
loadGroups: loadGroups,
|
27 |
+
};
|
28 |
+
|
29 |
+
function init() {
|
30 |
+
|
31 |
+
initHandles();
|
32 |
+
initAccount();
|
33 |
+
initHandlers();
|
34 |
+
initLists();
|
35 |
+
initGroups();
|
36 |
+
|
37 |
+
} //end function init
|
38 |
+
|
39 |
+
function initHandles() {
|
40 |
+
// Capture jQuery handles to elements
|
41 |
+
$enabled = $('#' + namespace_prefixed('enabled'));
|
42 |
+
$apiKey = $('#' + namespace_prefixed('api_key'));
|
43 |
+
$mainList = $('#' + namespace_prefixed('list'));
|
44 |
+
$interestGroups = $('#' + namespace_prefixed('interest_groups'));
|
45 |
+
$displayOptIn = $('#' + namespace_prefixed('display_opt_in'));
|
46 |
+
$occurs = $('#' + namespace_prefixed('occurs'));
|
47 |
+
$optInLabel = $('#' + namespace_prefixed('opt_in_label'));
|
48 |
+
$optInCheckboxDefault = $('#' + namespace_prefixed('opt_in_checkbox_default_status'));
|
49 |
+
$optInCheckboxLocation = $('#' + namespace_prefixed('opt_in_checkbox_display_location'));
|
50 |
+
$doubleOptIn = $('#' + namespace_prefixed('double_opt_in'));
|
51 |
+
}
|
52 |
+
|
53 |
+
function initHandlers() {
|
54 |
+
$mainList.closest('tr').hide();
|
55 |
+
|
56 |
+
if ($mainList.val() === '') {
|
57 |
+
$interestGroups.attr('disabled','disabled');
|
58 |
+
}
|
59 |
+
|
60 |
+
$apiKey.change(function() {
|
61 |
+
checkApiKey($apiKey.val(), true);
|
62 |
+
});
|
63 |
+
checkApiKey($apiKey.val(), false)
|
64 |
+
|
65 |
+
$mainList.change(function() {
|
66 |
+
if ($mainList.val()) {
|
67 |
+
$interestGroups.removeAttr('disabled');
|
68 |
+
} else {
|
69 |
+
$interestGroups.children().remove();
|
70 |
+
$interestGroups.attr('disabled','disabled');
|
71 |
+
}
|
72 |
+
});
|
73 |
+
|
74 |
+
$apiKey.on('paste cut', function() {
|
75 |
+
// Short pause to wait for paste to complete
|
76 |
+
setTimeout( function() {
|
77 |
+
$apiKey.change();
|
78 |
+
$apiKey.blur();
|
79 |
+
}, 100);
|
80 |
+
});
|
81 |
+
|
82 |
+
$mainList.on('change', function() {
|
83 |
+
if ($mainList.val() !== '') {
|
84 |
+
loadGroups($apiKey.val(), $mainList.val());
|
85 |
+
}
|
86 |
+
});
|
87 |
+
|
88 |
+
$optInLabel.closest('tr').hide();
|
89 |
+
$optInCheckboxDefault.closest('tr').hide();
|
90 |
+
$optInCheckboxLocation.closest('tr').hide();
|
91 |
+
$doubleOptIn.closest('tr').hide();
|
92 |
+
$displayOptIn.change(function() {
|
93 |
+
if ( '' === $apiKey.val() ) return;
|
94 |
+
|
95 |
+
switch ($displayOptIn.val()) {
|
96 |
+
case 'no':
|
97 |
+
$optInLabel.closest('tr').fadeOut();
|
98 |
+
$optInCheckboxDefault.closest('tr').fadeOut();
|
99 |
+
$optInCheckboxLocation.closest('tr').fadeOut();
|
100 |
+
$doubleOptIn.closest('tr').fadeIn();
|
101 |
+
break;
|
102 |
+
case 'yes':
|
103 |
+
$optInLabel.closest('tr').fadeIn();
|
104 |
+
$optInCheckboxDefault.closest('tr').fadeIn();
|
105 |
+
$optInCheckboxLocation.closest('tr').fadeIn();
|
106 |
+
$doubleOptIn.closest('tr').fadeIn();
|
107 |
+
break;
|
108 |
+
}
|
109 |
+
}).change();
|
110 |
+
|
111 |
+
} //end function initHandlers
|
112 |
+
|
113 |
+
function initAccount() {
|
114 |
+
$accountLoadingIndicator = $('<div id="ss_wc_mailchimp_loading_account" class="woocommerce-mailchimp-loading"><span id="woocommerce_mailchimp_account_indicator" class="woocommerce-mailchimp-loading-indicator"></span></div>');
|
115 |
+
$apiKey.after($accountLoadingIndicator.hide());
|
116 |
+
|
117 |
+
} //end function initAccount
|
118 |
+
|
119 |
+
function initLists() {
|
120 |
+
$listsLoadingIndicator = $('<div id="ss_wc_mailchimp_loading_lists" class="woocommerce-mailchimp-loading"><span class="woocommerce-mailchimp-loading-indicator"> '+SS_WC_MailChimp_Messages.connecting_to_mailchimp+'</span></div>');
|
121 |
+
$mainList.after($listsLoadingIndicator.hide());
|
122 |
+
|
123 |
+
} //end function initLists
|
124 |
+
|
125 |
+
function initGroups() {
|
126 |
+
//return;
|
127 |
+
|
128 |
+
// Reinitialize the <optgroup> elements by splitting out the option names
|
129 |
+
var currentGroup = '';
|
130 |
+
var lastGroup = '';
|
131 |
+
var grouping;
|
132 |
+
var $options = $interestGroups.children('option').clone();
|
133 |
+
|
134 |
+
$interestGroups.attr('data-placeholder', SS_WC_MailChimp_Messages.select_groups_placeholder);
|
135 |
+
|
136 |
+
$interestGroups.select2('destroy').select2();
|
137 |
+
var groupsMessage = $('#ss-wc-mailchimp-groups-msg').length > 0 ? $('#ss-wc-mailchimp-groups-msg') : $('<div id="ss-wc-mailchimp-groups-msg" style="display: inline-block"/>');
|
138 |
+
$interestGroups.after(groupsMessage);
|
139 |
+
if ($options.length === 0) {
|
140 |
+
groupsMessage.text(SS_WC_MailChimp_Messages.interest_groups_not_enabled);
|
141 |
+
$interestGroups.siblings('.select2-container').remove();
|
142 |
+
groupsMessage.show();
|
143 |
+
} else {
|
144 |
+
$interestGroups.siblings('.select2-container').show();
|
145 |
+
groupsMessage.hide();
|
146 |
+
}
|
147 |
+
|
148 |
+
// Add the loading indicator for groups (set to hidden by default)
|
149 |
+
$interestGroupsLoadingIndicator = $('<div id="ss_wc_mailchimp_loading_groups" class="woocommerce-mailchimp-loading"><span class="woocommerce-mailchimp-loading-indicator"> '+SS_WC_MailChimp_Messages.connecting_to_mailchimp+'</span></div>');
|
150 |
+
$interestGroups.parent().append($interestGroupsLoadingIndicator.hide());
|
151 |
+
|
152 |
+
} //end function initGroups
|
153 |
+
|
154 |
+
function checkApiKey(apiKey, shouldLoadLists = false) {
|
155 |
+
|
156 |
+
if ( $apiKey.val() === '' ) {
|
157 |
+
toggleAllSettings('hide');
|
158 |
+
} else {
|
159 |
+
toggleAllSettings('show');
|
160 |
+
}
|
161 |
+
|
162 |
+
if (apiKey === '') return;
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Load account
|
166 |
+
*/
|
167 |
+
$mainList.attr('disabled','disabled');
|
168 |
+
$accountLoadingIndicator.show();
|
169 |
+
$accountIndicator = $accountLoadingIndicator.children().first();
|
170 |
+
$accountIndicator.removeClass('success').removeClass('error');
|
171 |
+
$accountIndicator.addClass('loading');
|
172 |
+
$accountIndicator.html(' '+SS_WC_MailChimp_Messages.connecting_to_mailchimp);
|
173 |
+
$.post(
|
174 |
+
ajaxurl,
|
175 |
+
{
|
176 |
+
'action': '' + namespace_prefixed('get_account'),
|
177 |
+
'data': { 'api_key': apiKey }
|
178 |
+
},
|
179 |
+
function(response) {
|
180 |
+
console.log(response);
|
181 |
+
$accountIndicator.removeClass('loading');
|
182 |
+
var result = [];
|
183 |
+
|
184 |
+
try {
|
185 |
+
result = $.parseJSON(response);
|
186 |
+
} catch (err) {
|
187 |
+
console.error(err);
|
188 |
+
$accountIndicator.addClass('error');
|
189 |
+
$accountIndicator.html(' '+SS_WC_MailChimp_Messages.error_loading_account);
|
190 |
+
return;
|
191 |
+
}
|
192 |
+
|
193 |
+
if ( result.error ) {
|
194 |
+
$accountIndicator.addClass('error');
|
195 |
+
$accountIndicator.html(result.error);
|
196 |
+
return;
|
197 |
+
}
|
198 |
+
|
199 |
+
if ( ! result.account_id ) {
|
200 |
+
$accountIndicator.addClass('error');
|
201 |
+
$accountIndicator.html(' '+SS_WC_MailChimp_Messages.error_loading_account);
|
202 |
+
return;
|
203 |
+
}
|
204 |
+
|
205 |
+
$accountIndicator.addClass('success');
|
206 |
+
$mainList.removeAttr('disabled');
|
207 |
+
$accountIndicator.html('');
|
208 |
+
|
209 |
+
// API Key looks good. Let's load the lists.
|
210 |
+
if ( shouldLoadLists ) {
|
211 |
+
loadLists( apiKey );
|
212 |
+
}
|
213 |
+
}
|
214 |
+
);
|
215 |
+
|
216 |
+
} //end function checkApiKey
|
217 |
+
|
218 |
+
function loadLists(apiKey) {
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Load lists
|
222 |
+
*/
|
223 |
+
$mainList.attr('disabled','disabled');
|
224 |
+
$listsLoadingIndicator.show();
|
225 |
+
$listsIndicator = $listsLoadingIndicator.children().first();
|
226 |
+
$listsIndicator.addClass('loading');
|
227 |
+
$.post(
|
228 |
+
ajaxurl,
|
229 |
+
{
|
230 |
+
'action': '' + namespace_prefixed('get_lists'),
|
231 |
+
'data': { 'api_key': apiKey }
|
232 |
+
},
|
233 |
+
function(response) {
|
234 |
+
console.log(response);
|
235 |
+
$listsLoadingIndicator.hide();
|
236 |
+
$listsIndicator.removeClass('loading');
|
237 |
+
var result = [];
|
238 |
+
|
239 |
+
try {
|
240 |
+
result = $.parseJSON(response);
|
241 |
+
} catch (err) {
|
242 |
+
console.error(err);
|
243 |
+
alert(SS_WC_MailChimp_Messages.error_loading_lists);
|
244 |
+
}
|
245 |
+
|
246 |
+
if (result) {
|
247 |
+
$mainList.select2('destroy');
|
248 |
+
$mainList.removeAttr('disabled');
|
249 |
+
$mainList.children().remove();
|
250 |
+
$.each(result, function(key, val) {
|
251 |
+
$mainList
|
252 |
+
.append($('<option></option>')
|
253 |
+
.attr('value',key)
|
254 |
+
.text(val));
|
255 |
+
});
|
256 |
+
$mainList.select2();
|
257 |
+
}
|
258 |
+
}
|
259 |
+
);
|
260 |
+
|
261 |
+
} //end function loadLists
|
262 |
+
|
263 |
+
function loadGroups(apiKey, listId) {
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Load interest groups
|
267 |
+
*/
|
268 |
+
$interestGroups.attr('disabled','disabled');
|
269 |
+
|
270 |
+
$interestGroups.children().remove();
|
271 |
+
|
272 |
+
$interestGroups.select2().hide();
|
273 |
+
$('#ss-wc-mailchimp-groups-msg').hide();
|
274 |
+
$interestGroupsLoadingIndicator.show();
|
275 |
+
$interestGroupsIndicator = $interestGroupsLoadingIndicator.children().first();
|
276 |
+
$interestGroupsIndicator.addClass('loading');
|
277 |
+
$.post(
|
278 |
+
ajaxurl,
|
279 |
+
{
|
280 |
+
'action': '' + namespace_prefixed('get_interest_groups'),
|
281 |
+
'data': { 'api_key': apiKey, 'list_id': listId }
|
282 |
+
},
|
283 |
+
function(response) {
|
284 |
+
console.log(response);
|
285 |
+
$interestGroupsLoadingIndicator.hide();
|
286 |
+
$interestGroupsIndicator.removeClass('loading');
|
287 |
+
var result = [];
|
288 |
+
|
289 |
+
try {
|
290 |
+
result = $.parseJSON(response);
|
291 |
+
} catch (err) {
|
292 |
+
console.error(err);
|
293 |
+
alert(SS_WC_MailChimp_Messages.error_loading_groups);
|
294 |
+
}
|
295 |
+
|
296 |
+
if (result.error) {
|
297 |
+
$('#ss-wc-mailchimp-groups-msg').text(result.error).show();
|
298 |
+
$interestGroups.children().remove();
|
299 |
+
$interestGroups.select2('destroy');
|
300 |
+
$interestGroups.hide();
|
301 |
+
return;
|
302 |
+
}
|
303 |
+
|
304 |
+
if (result.length === 0) {
|
305 |
+
$('#ss-wc-mailchimp-groups-msg').show();
|
306 |
+
initGroups();
|
307 |
+
return;
|
308 |
+
}
|
309 |
+
|
310 |
+
$interestGroups.show();
|
311 |
+
$interestGroups.removeAttr('disabled');
|
312 |
+
$interestGroups.children().remove();
|
313 |
+
$.each(result, function(id, grouping) {
|
314 |
+
$interestGroups.append(
|
315 |
+
$('<option></option>')
|
316 |
+
.attr('value',id)
|
317 |
+
.text(grouping));
|
318 |
+
});
|
319 |
+
|
320 |
+
initGroups();
|
321 |
+
}
|
322 |
+
);
|
323 |
+
|
324 |
+
} //end function loadGroups
|
325 |
+
|
326 |
+
function toggleAllSettings( show_hide ) {
|
327 |
+
if (show_hide == 'show') {
|
328 |
+
$apiKey.closest('tr').nextAll('tr').fadeIn();
|
329 |
+
$apiKey.closest('table').nextAll('h2, .form-table').fadeIn();
|
330 |
+
} else {
|
331 |
+
$apiKey.closest('tr').nextAll('tr').fadeOut();
|
332 |
+
$apiKey.closest('table').nextAll('h2, .form-table').fadeOut();
|
333 |
+
}
|
334 |
+
}
|
335 |
+
|
336 |
+
function namespace_prefixed( suffix ) {
|
337 |
+
return namespace + '_' + suffix;
|
338 |
+
}
|
339 |
+
|
340 |
+
}(jQuery);
|
trunk/assets/screenshot-1.png
ADDED
Binary file
|
trunk/assets/screenshot-2.png
ADDED
Binary file
|
trunk/config/default-settings.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
return array(
|
3 |
+
'api_key' => '',
|
4 |
+
'enabled' => 'yes',
|
5 |
+
'list' => '',
|
6 |
+
'interest_groups' => '',
|
7 |
+
'display_opt_in' => 'no',
|
8 |
+
'occurs' => 'pending',
|
9 |
+
'double_opt_in' => 'no',
|
10 |
+
'opt_in_label' => __( 'Subscribe to our newsletter', 'ss_wc_mailchimp' ),
|
11 |
+
'opt_in_checkbox_default_status' => 'checked',
|
12 |
+
'opt_in_checkbox_display_location' => 'woocommerce_review_order_before_submit',
|
13 |
+
'debug' => 'no',
|
14 |
+
);
|
trunk/includes/class-ss-wc-mailchimp-admin-notices.php
ADDED
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WooCommerce MailChimp Admin notices
|
4 |
+
*
|
5 |
+
* @package WooCommerce MailChimp
|
6 |
+
* @author Saint Systems, LLC
|
7 |
+
* @link http://www.saintsystems.com
|
8 |
+
* @copyright Copyright 2016, Saint Systems, LLC
|
9 |
+
*
|
10 |
+
* @since 2.0.13
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Handle displaying and storing of admin notices for WooCommerce MailChimp
|
15 |
+
* @since 2.0.13
|
16 |
+
*/
|
17 |
+
class SS_WC_MailChimp_Admin_Notices {
|
18 |
+
|
19 |
+
static private $admin_notices = array();
|
20 |
+
|
21 |
+
static private $dismissed_notices = array();
|
22 |
+
|
23 |
+
function __construct() {
|
24 |
+
|
25 |
+
$this->add_hooks();
|
26 |
+
}
|
27 |
+
|
28 |
+
function add_hooks() {
|
29 |
+
add_action( 'network_admin_notices', array( $this, 'dismiss_notice' ), 50 );
|
30 |
+
add_action( 'admin_notices', array( $this, 'dismiss_notice' ), 50 );
|
31 |
+
add_action( 'admin_notices', array( $this, 'admin_notice' ), 100 );
|
32 |
+
add_action( 'network_admin_notices', array( $this, 'admin_notice' ), 100 );
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Dismiss a WooCommerce notice - stores the dismissed notices for 16 weeks
|
37 |
+
* @return void
|
38 |
+
*/
|
39 |
+
public function dismiss_notice() {
|
40 |
+
|
41 |
+
// No dismiss sent
|
42 |
+
if ( empty( $_GET['sswcmc-dismiss'] ) ) {
|
43 |
+
return;
|
44 |
+
}
|
45 |
+
|
46 |
+
// Invalid nonce
|
47 |
+
if ( !wp_verify_nonce( $_GET['sswcmc-dismiss'], 'dismiss' ) ) {
|
48 |
+
return;
|
49 |
+
}
|
50 |
+
|
51 |
+
$notice_id = esc_attr( $_GET['notice'] );
|
52 |
+
|
53 |
+
//don't display a message if use has dismissed the message for this version
|
54 |
+
$dismissed_notices = (array)get_transient( 'ss_wc_mailchimp_dismissed_notices' );
|
55 |
+
|
56 |
+
$dismissed_notices[] = $notice_id;
|
57 |
+
|
58 |
+
$dismissed_notices = array_unique( $dismissed_notices );
|
59 |
+
|
60 |
+
// Remind users every 16 weeks
|
61 |
+
set_transient( 'ss_wc_mailchimp_dismissed_notices', $dismissed_notices, WEEK_IN_SECONDS * 16 );
|
62 |
+
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Should the notice be shown in the admin (Has it been dismissed already)?
|
67 |
+
*
|
68 |
+
* If the passed notice array has a `dismiss` key, the notice is dismissable. If it's dismissable,
|
69 |
+
* we check against other notices that have already been dismissed.
|
70 |
+
*
|
71 |
+
* @see GravityView_Admin::dismiss_notice()
|
72 |
+
* @see GravityView_Admin::add_notice()
|
73 |
+
* @param string $notice Notice array, set using `add_notice()`.
|
74 |
+
* @return boolean True: show notice; False: hide notice
|
75 |
+
*/
|
76 |
+
function _maybe_show_notice( $notice ) {
|
77 |
+
|
78 |
+
// There are no dismissed notices.
|
79 |
+
if( empty( self::$dismissed_notices ) ) {
|
80 |
+
return true;
|
81 |
+
}
|
82 |
+
|
83 |
+
// Has the
|
84 |
+
$is_dismissed = !empty( $notice['dismiss'] ) && in_array( $notice['dismiss'], self::$dismissed_notices );
|
85 |
+
|
86 |
+
return $is_dismissed ? false : true;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Get admin notices
|
91 |
+
* @since 1.12
|
92 |
+
* @return array
|
93 |
+
*/
|
94 |
+
public static function get_notices() {
|
95 |
+
return self::$admin_notices;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Handle whether to display notices in Multisite based on plugin activation status
|
100 |
+
*
|
101 |
+
* @since 2.0.13
|
102 |
+
*
|
103 |
+
* @return bool True: show the notices; false: don't show
|
104 |
+
*/
|
105 |
+
private function check_show_multisite_notices() {
|
106 |
+
|
107 |
+
if ( ! is_multisite() ) {
|
108 |
+
return true;
|
109 |
+
}
|
110 |
+
|
111 |
+
// It's network activated but the user can't manage network plugins; they can't do anything about it.
|
112 |
+
if ( SS_WC_MailChimp_Plugin::is_network_activated() && ! is_main_site() ) {
|
113 |
+
return false;
|
114 |
+
}
|
115 |
+
|
116 |
+
// or they don't have admin capabilities
|
117 |
+
if ( ! is_super_admin() ) {
|
118 |
+
return false;
|
119 |
+
}
|
120 |
+
|
121 |
+
return true;
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Outputs the admin notices generated by the plugin
|
126 |
+
*
|
127 |
+
* @since 2.0.13
|
128 |
+
*
|
129 |
+
* @return void
|
130 |
+
*/
|
131 |
+
public function admin_notice() {
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Modify the notices displayed
|
135 |
+
* @since 2.0.13
|
136 |
+
*/
|
137 |
+
$notices = apply_filters( 'ss_wc_mailchimp/admin/notices', self::$admin_notices );
|
138 |
+
|
139 |
+
if( empty( $notices ) || ! $this->check_show_multisite_notices() ) {
|
140 |
+
return;
|
141 |
+
}
|
142 |
+
|
143 |
+
//don't display a message if use has dismissed the message for this version
|
144 |
+
self::$dismissed_notices = isset( $_GET['show-dismissed-notices'] ) ? array() : (array)get_transient( 'ss_wc_mailchimp_dismissed_notices' );
|
145 |
+
|
146 |
+
foreach( $notices as $notice ) {
|
147 |
+
|
148 |
+
if( false === $this->_maybe_show_notice( $notice ) ) {
|
149 |
+
continue;
|
150 |
+
}
|
151 |
+
|
152 |
+
echo '<div id="message" class="notice '. sswcmc_sanitize_html_class( $notice['class'] ).'">';
|
153 |
+
|
154 |
+
if( !empty( $notice['title'] ) ) {
|
155 |
+
echo '<h3>'.esc_html( $notice['title'] ) .'</h3>';
|
156 |
+
}
|
157 |
+
|
158 |
+
echo wpautop( $notice['message'] );
|
159 |
+
|
160 |
+
if( !empty( $notice['dismiss'] ) ) {
|
161 |
+
|
162 |
+
$dismiss = esc_attr($notice['dismiss']);
|
163 |
+
|
164 |
+
$url = esc_url( add_query_arg( array( 'sswcmc-dismiss' => wp_create_nonce( 'dismiss' ), 'notice' => $dismiss ) ) );
|
165 |
+
|
166 |
+
echo wpautop( '<a href="'.$url.'" data-notice="'.$dismiss.'" class="button-small button button-secondary">'.esc_html__( 'Dismiss', 'woocommerce-mailchimp' ).'</a>' );
|
167 |
+
}
|
168 |
+
|
169 |
+
echo '<div class="clear"></div>';
|
170 |
+
echo '</div>';
|
171 |
+
|
172 |
+
}
|
173 |
+
|
174 |
+
//reset the notices handler
|
175 |
+
self::$admin_notices = array();
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Add a notice to be displayed in the admin.
|
180 |
+
* @param array $notice Array with `class` and `message` keys. The message is not escaped.
|
181 |
+
*/
|
182 |
+
public static function add_notice( $notice = array() ) {
|
183 |
+
|
184 |
+
if( !isset( $notice['message'] ) ) {
|
185 |
+
do_action( 'ss_wc_mailchimp_log_error', 'SSWCMC_Admin[add_notice] Notice not set', $notice );
|
186 |
+
return;
|
187 |
+
}
|
188 |
+
|
189 |
+
$notice['class'] = empty( $notice['class'] ) ? 'error' : $notice['class'];
|
190 |
+
|
191 |
+
self::$admin_notices[] = $notice;
|
192 |
+
}
|
193 |
+
}
|
trunk/includes/class-ss-wc-mailchimp-api.php
ADDED
@@ -0,0 +1,294 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Minimal MailChimp API v3.0 wrapper
|
7 |
+
*
|
8 |
+
* @class SS_WC_MailChimp_API
|
9 |
+
* @version 2.0
|
10 |
+
* @package WooCommerce MailChimp
|
11 |
+
* @author Saint Systems
|
12 |
+
*/
|
13 |
+
class SS_WC_MailChimp_API {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $api_key;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
+
public $datacenter = 'us1';
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @var string
|
27 |
+
*/
|
28 |
+
private $api_root = 'https://<dc>.api.mailchimp.com/3.0/';
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @var boolean
|
32 |
+
*/
|
33 |
+
private $debug = false;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @var array
|
37 |
+
*/
|
38 |
+
private $last_response;
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @var WP_Error
|
42 |
+
*/
|
43 |
+
private $last_error;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Create a new instance
|
47 |
+
* @param string $api_key MailChimp API key
|
48 |
+
* @param boolean $debug Whether or not to log API calls
|
49 |
+
*/
|
50 |
+
function __construct( $api_key, $debug = false ) {
|
51 |
+
|
52 |
+
$this->debug = $debug;
|
53 |
+
|
54 |
+
$this->api_key = $api_key;
|
55 |
+
$api_key_parts = explode( '-', $this->api_key );
|
56 |
+
$this->datacenter = empty( $api_key_parts[1] ) ? 'us1' : $api_key_parts[1];
|
57 |
+
$this->api_root = str_replace( '<dc>', $this->datacenter, $this->api_root );
|
58 |
+
|
59 |
+
} //end function __construct
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Get request.
|
63 |
+
*
|
64 |
+
* @param string $resource
|
65 |
+
* @param array $args
|
66 |
+
*
|
67 |
+
* @return mixed
|
68 |
+
*/
|
69 |
+
public function get( $resource, $args = array() ) {
|
70 |
+
|
71 |
+
if ( is_array( $args) && ! array_key_exists( 'count', $args ) ) {
|
72 |
+
$args['count'] = 10;
|
73 |
+
}
|
74 |
+
|
75 |
+
return $this->api_request( 'GET', $resource, $args );
|
76 |
+
|
77 |
+
} //end function post
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Post request.
|
81 |
+
*
|
82 |
+
* @param string $resource
|
83 |
+
* @param array $args
|
84 |
+
*
|
85 |
+
* @return mixed
|
86 |
+
*/
|
87 |
+
public function post( $resource, $args = array() ) {
|
88 |
+
|
89 |
+
return $this->api_request( 'POST', $resource, $args );
|
90 |
+
|
91 |
+
} //end function post
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Put request.
|
95 |
+
*
|
96 |
+
* @param string $resource
|
97 |
+
* @param array $args
|
98 |
+
*
|
99 |
+
* @return mixed
|
100 |
+
*/
|
101 |
+
public function put( $resource, $args = array() ) {
|
102 |
+
|
103 |
+
return $this->api_request( 'PUT', $resource, $args );
|
104 |
+
|
105 |
+
} //end function put
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Patch request.
|
109 |
+
*
|
110 |
+
* @param string $resource
|
111 |
+
* @param array $args
|
112 |
+
*
|
113 |
+
* @return mixed
|
114 |
+
*/
|
115 |
+
public function patch( $resource, $args = array() ) {
|
116 |
+
|
117 |
+
return $this->api_request( 'PATCH', $resource, $args );
|
118 |
+
|
119 |
+
} //end function patch
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Delete request.
|
123 |
+
*
|
124 |
+
* @param string $resource
|
125 |
+
* @param array $args
|
126 |
+
*
|
127 |
+
* @return mixed
|
128 |
+
*/
|
129 |
+
public function delete( $resource, $args = array() ) {
|
130 |
+
|
131 |
+
return $this->api_request( 'DELETE', $resource, $args );
|
132 |
+
|
133 |
+
} //end function delete
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Performs the underlying HTTP request.
|
137 |
+
*
|
138 |
+
* @param string $method HTTP method (GET|POST|PUT|PATCH|DELETE).
|
139 |
+
* @param string $resource MailChimp API resource to be called.
|
140 |
+
* @param array $args array of parameters to be passed.
|
141 |
+
* @return array array of decoded result.
|
142 |
+
*/
|
143 |
+
private function api_request( $method, $resource, $args = array() ) {
|
144 |
+
|
145 |
+
$this->reset();
|
146 |
+
|
147 |
+
$url = $this->api_root . $resource;
|
148 |
+
|
149 |
+
global $wp_version;
|
150 |
+
|
151 |
+
$request_args = array(
|
152 |
+
'method' => $method,
|
153 |
+
'sslverify' => false,
|
154 |
+
'timeout' => 60,
|
155 |
+
'redirection' => 5,
|
156 |
+
'httpversion' => '1.1',
|
157 |
+
'headers' => array(
|
158 |
+
'Content-Type' => 'application/json',
|
159 |
+
'Accept' => 'application/json',
|
160 |
+
'Authorization' => 'apikey ' . $this->api_key,
|
161 |
+
'User-Agent' => 'woocommerce-mailchimp/' . SS_WC_MAILCHIMP_VERSION . '; WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
|
162 |
+
),
|
163 |
+
);
|
164 |
+
|
165 |
+
// attach arguments (in body or URL).
|
166 |
+
if ( 'GET' === $method ) {
|
167 |
+
$url = add_query_arg( $args, $url );
|
168 |
+
} else {
|
169 |
+
$request_args['body'] = json_encode( $args );
|
170 |
+
}
|
171 |
+
|
172 |
+
// print_r($url);
|
173 |
+
// die();
|
174 |
+
|
175 |
+
$raw_response = wp_remote_request( $url, $request_args );
|
176 |
+
|
177 |
+
$this->last_response = $raw_response;
|
178 |
+
|
179 |
+
$this->maybe_log( $url, $method, $args, $raw_response );
|
180 |
+
|
181 |
+
if ( is_wp_error( $raw_response ) ) {
|
182 |
+
|
183 |
+
$this->last_error = new WP_Error( 'ss-wc-mc-api-request-error', $raw_response->get_error_message(), $this->format_error( $resource, $method, $raw_response ) );
|
184 |
+
|
185 |
+
return false;
|
186 |
+
|
187 |
+
} elseif ( is_array( $raw_response )
|
188 |
+
&& $raw_response['response']['code']
|
189 |
+
&& floor( $raw_response['response']['code'] ) / 100 >= 4 ) {
|
190 |
+
|
191 |
+
$json = wp_remote_retrieve_body( $raw_response );
|
192 |
+
|
193 |
+
$error = json_decode( $json, true );
|
194 |
+
|
195 |
+
$this->last_error = new WP_Error( 'ss-wc-mc-api-request-error', $error['detail'], $this->format_error( $resource, $method, $raw_response ) );
|
196 |
+
|
197 |
+
return false;
|
198 |
+
|
199 |
+
} else {
|
200 |
+
|
201 |
+
$json = wp_remote_retrieve_body( $raw_response );
|
202 |
+
|
203 |
+
$result = json_decode( $json, true );
|
204 |
+
|
205 |
+
return $result;
|
206 |
+
|
207 |
+
}
|
208 |
+
|
209 |
+
} //end function api_request
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Empties all data from previous response
|
213 |
+
*/
|
214 |
+
private function reset() {
|
215 |
+
$this->last_response = null;
|
216 |
+
$this->last_error = null;
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Conditionally log MailChimp API Call
|
221 |
+
*
|
222 |
+
* @param string $resource MailChimp API Resource.
|
223 |
+
* @param string $method HTTP Method.
|
224 |
+
* @param array $args HTTP Request Body.
|
225 |
+
* @param array $response WP HTTP Response.
|
226 |
+
* @return void
|
227 |
+
*/
|
228 |
+
private function maybe_log( $resource, $method, $args, $response ) {
|
229 |
+
do_action( 'sswcmc_log', "MailChimp API Call RESOURCE: $resource \n METHOD: $method \n BODY: " . print_r( $args, true ) . " \n RESPONSE: " . print_r( $response, true ) );
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Formats api_request info for inclusion in WP_Error $data
|
234 |
+
* @param [type] $resource [description]
|
235 |
+
* @param [type] $method [description]
|
236 |
+
* @param [type] $response [description]
|
237 |
+
* @return [type] [description]
|
238 |
+
*/
|
239 |
+
private function format_error( $resource, $method, $response ) {
|
240 |
+
return array(
|
241 |
+
'resource' => $resource,
|
242 |
+
'method' => $method,
|
243 |
+
'response' => json_encode($response),
|
244 |
+
);
|
245 |
+
}
|
246 |
+
|
247 |
+
/**
|
248 |
+
* has_api_key function.
|
249 |
+
*
|
250 |
+
* @access public
|
251 |
+
* @return void
|
252 |
+
*/
|
253 |
+
public function has_api_key() {
|
254 |
+
|
255 |
+
return !empty( $this->api_key );
|
256 |
+
|
257 |
+
} //end function has_api_key
|
258 |
+
|
259 |
+
/**
|
260 |
+
* @return array|WP_Error
|
261 |
+
*/
|
262 |
+
public function get_last_response() {
|
263 |
+
return $this->last_response;
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* Returns error code from error property
|
268 |
+
* @return string error code
|
269 |
+
*/
|
270 |
+
public function get_error_code() {
|
271 |
+
|
272 |
+
$last_error = $this->last_error;
|
273 |
+
if ( is_wp_error( $last_error ) ) {
|
274 |
+
return $last_error->get_error_code();
|
275 |
+
}
|
276 |
+
return null;
|
277 |
+
|
278 |
+
} //end get_error_code
|
279 |
+
|
280 |
+
/**
|
281 |
+
* Returns error message from error property
|
282 |
+
* @return string error message
|
283 |
+
*/
|
284 |
+
public function get_error_message() {
|
285 |
+
|
286 |
+
$last_error = $this->last_error;
|
287 |
+
if ( is_wp_error( $last_error ) ) {
|
288 |
+
return $last_error->get_error_message();
|
289 |
+
}
|
290 |
+
return null;
|
291 |
+
|
292 |
+
} //end get_error_message
|
293 |
+
|
294 |
+
} //end class SS_WC_MailChimp_API
|
trunk/includes/class-ss-wc-mailchimp-compatibility.php
ADDED
@@ -0,0 +1,297 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Handle issues with plugin and version compatibility
|
4 |
+
*
|
5 |
+
* @package WooCommerce MailChimp
|
6 |
+
* @author Saint Systems, LLC
|
7 |
+
* @link http://www.saintsystems.com
|
8 |
+
* @copyright Copyright 2016, Saint Systems, LLC
|
9 |
+
*
|
10 |
+
* @since 2.0.13
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Handle WooCommerce MailChimp compatibility notices and fallback shortcodes
|
15 |
+
* @since 2.0.13
|
16 |
+
*/
|
17 |
+
final class SS_WC_MailChimp_Compatibility {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Plugin singleton instance
|
21 |
+
* @var SS_WC_MailChimp_Compatibility
|
22 |
+
*/
|
23 |
+
private static $instance = null;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @var bool Is WooCommerce version valid and is WooCommerce loaded?
|
27 |
+
*/
|
28 |
+
public static $valid_woocommerce = false;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @var bool Is the WordPress installation compatible?
|
32 |
+
*/
|
33 |
+
public static $valid_wordpress = false;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @var bool Is the server's PHP version compatible?
|
37 |
+
*/
|
38 |
+
public static $valid_php = false;
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @var array Holder for notices to be displayed in frontend shortcodes if not valid
|
42 |
+
*/
|
43 |
+
static private $notices = array();
|
44 |
+
|
45 |
+
function __construct() {
|
46 |
+
|
47 |
+
self::$valid_woocommerce = self::check_woocommerce();
|
48 |
+
|
49 |
+
self::$valid_wordpress = self::check_wordpress();
|
50 |
+
|
51 |
+
self::$valid_php = self::check_php();
|
52 |
+
|
53 |
+
$this->add_hooks();
|
54 |
+
}
|
55 |
+
|
56 |
+
function add_hooks() {
|
57 |
+
|
58 |
+
add_filter( 'ss_wc_mailchimp/admin/notices', array( $this, 'insert_admin_notices' ) );
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Add the compatibility notices to the other admin notices
|
64 |
+
* @param array $notices
|
65 |
+
*
|
66 |
+
* @return array
|
67 |
+
*/
|
68 |
+
function insert_admin_notices( $notices = array() ) {
|
69 |
+
|
70 |
+
return array_merge( $notices, self::$notices );
|
71 |
+
|
72 |
+
} //end function insert_admin_notices
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @return SS_WC_MailChimp_Compatibility
|
76 |
+
*/
|
77 |
+
public static function get_instance() {
|
78 |
+
|
79 |
+
if ( empty( self::$instance ) ) {
|
80 |
+
self::$instance = new self;
|
81 |
+
}
|
82 |
+
|
83 |
+
return self::$instance;
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Is everything compatible with this version of the plugin?
|
89 |
+
* @return bool
|
90 |
+
*/
|
91 |
+
public static function is_valid() {
|
92 |
+
|
93 |
+
return ( self::is_valid_woocommerce()
|
94 |
+
&& self::is_valid_wordpress()
|
95 |
+
&& self::is_valid_php()
|
96 |
+
);
|
97 |
+
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Is the version of WordPress compatible?
|
102 |
+
* @since 2.0.13
|
103 |
+
*/
|
104 |
+
static function is_valid_wordpress() {
|
105 |
+
return self::$valid_wordpress;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* @since 2.0.13
|
110 |
+
* @return bool
|
111 |
+
*/
|
112 |
+
static function is_valid_woocommerce() {
|
113 |
+
return self::$valid_woocommerce;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* @since 2.0.13
|
118 |
+
* @return bool
|
119 |
+
*/
|
120 |
+
static function is_valid_php() {
|
121 |
+
return self::$valid_php;
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Get admin notices
|
126 |
+
* @since 2.0.13
|
127 |
+
* @return array
|
128 |
+
*/
|
129 |
+
public static function get_notices() {
|
130 |
+
return self::$notices;
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Is the version of PHP compatible?
|
135 |
+
*
|
136 |
+
* @since 2.0.13
|
137 |
+
* @return boolean
|
138 |
+
*/
|
139 |
+
public static function check_php() {
|
140 |
+
if ( false === version_compare( phpversion(), SS_WC_MAILCHIMP_MIN_PHP_VERSION , '>=' ) ) {
|
141 |
+
|
142 |
+
self::$notices['php_version'] = array(
|
143 |
+
'class' => 'notice-error',
|
144 |
+
'message' => sprintf( __( "%sWooCommerce MailChimp requires PHP Version %s or newer.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'woocommerce-mailchimp' ), '<h3>', SS_WC_MAILCHIMP_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.phpversion().'</span>' )
|
145 |
+
);
|
146 |
+
|
147 |
+
return false;
|
148 |
+
}
|
149 |
+
|
150 |
+
return true;
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Is WordPress compatible?
|
155 |
+
*
|
156 |
+
* @since 2.0.13
|
157 |
+
* @return boolean
|
158 |
+
*/
|
159 |
+
public static function check_wordpress() {
|
160 |
+
global $wp_version;
|
161 |
+
|
162 |
+
if ( version_compare( $wp_version, SS_WC_MAILCHIMP_MIN_WP_VERSION ) <= 0 ) {
|
163 |
+
|
164 |
+
self::$notices['wp_version'] = array(
|
165 |
+
'class' => 'notice-error',
|
166 |
+
'message' => sprintf( __( "%sWooCommerce MailChimp requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'woocommerce-mailchimp' ), '<h3>', SS_WC_MAILCHIMP_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$wp_version.'</span>' )
|
167 |
+
);
|
168 |
+
|
169 |
+
return false;
|
170 |
+
}
|
171 |
+
|
172 |
+
return true;
|
173 |
+
|
174 |
+
} //end public static function check_wordpress()
|
175 |
+
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Check if WooCommerce plugin is active and show notice if not.
|
179 |
+
*
|
180 |
+
* @since 2.0.13
|
181 |
+
*
|
182 |
+
* @access public
|
183 |
+
* @return boolean True: checks have been passed; WooCommerce MailChimp is fine to run; False: checks have failed, don't continue loading
|
184 |
+
*/
|
185 |
+
public static function check_woocommerce() {
|
186 |
+
|
187 |
+
$woocommerce_is_active = false;
|
188 |
+
|
189 |
+
// Bypass other checks: if the class exists
|
190 |
+
if ( class_exists( 'WooCommerce' ) ) {
|
191 |
+
|
192 |
+
$woocommerce_is_active = true;
|
193 |
+
$woocommerce_version = WC()->version;
|
194 |
+
|
195 |
+
} else {
|
196 |
+
|
197 |
+
if ( $wc_status = self::get_plugin_status( 'woocommerce/woocommerce.php' ) ) {
|
198 |
+
if ( true === $wc_status ) {
|
199 |
+
$woocommerce_is_active = true;
|
200 |
+
}
|
201 |
+
$wc_data = get_plugin_data( WP_CONTENT_DIR . '/plugins/woocommerce/woocommerce.php' );
|
202 |
+
$woocommerce_version = $wc_data['Version'];
|
203 |
+
}
|
204 |
+
|
205 |
+
}
|
206 |
+
|
207 |
+
if ( true === $woocommerce_is_active ) {
|
208 |
+
// and the version's right, we're good.
|
209 |
+
if ( true === version_compare( $woocommerce_version, SS_WC_MAILCHIMP_MIN_WC_VERSION, ">=" ) ) {
|
210 |
+
return true;
|
211 |
+
}
|
212 |
+
|
213 |
+
$button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#woocommerce">' : '<strong><a href="'. wp_nonce_url( admin_url( 'update.php?action=upgrade-plugin&plugin=woocommerce/woocommerce.php' ), 'upgrade-plugin_woocommerce/woocommerce.php') . '" class="button button-large">';
|
214 |
+
|
215 |
+
// Or the version's wrong
|
216 |
+
self::$notices['wc_version'] = array(
|
217 |
+
'class' => 'notice-error',
|
218 |
+
'message' => sprintf( __( "%sWooCommerce MailChimp requires WooCommerce Version %s or newer.%s You're using Version %s. %sUpdate WooCommerce%s to use the WooCommerce MailChimp plugin.", 'woocommerce-mailchimp' ), '<h3>', SS_WC_MAILCHIMP_MIN_WC_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$woocommerce_version.'</span>', $button, '</strong></a>' )
|
219 |
+
);
|
220 |
+
|
221 |
+
return false;
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* The plugin is activated and yet somehow WooCommerce didn't get picked up...
|
226 |
+
* OR
|
227 |
+
* It's the Network Admin and we just don't know whether the sites have WooCommerce activated themselves.
|
228 |
+
*/
|
229 |
+
if ( $woocommerce_is_active || is_network_admin() ) {
|
230 |
+
return true;
|
231 |
+
}
|
232 |
+
|
233 |
+
// If WooCommerce doesn't exist, assume WooCommerce not active
|
234 |
+
$return = false;
|
235 |
+
|
236 |
+
// Required for multisite
|
237 |
+
if ( ! function_exists('wp_create_nonce') ) {
|
238 |
+
require_once ABSPATH . WPINC . '/pluggable.php';
|
239 |
+
}
|
240 |
+
|
241 |
+
// Otherwise, throws an error on activation & deactivation "Use of undefined constant LOGGED_IN_COOKIE"
|
242 |
+
if ( is_multisite() ) {
|
243 |
+
wp_cookie_constants();
|
244 |
+
}
|
245 |
+
|
246 |
+
switch ( $wc_status ) {
|
247 |
+
case 'inactive':
|
248 |
+
$return = false;
|
249 |
+
|
250 |
+
$button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#woocommerce">' : '<strong><a href="'. wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=woocommerce/woocommerce.php' ), 'activate-plugin_woocommerce/woocommerce.php') . '" class="button button-large">';
|
251 |
+
|
252 |
+
self::$notices['wc_inactive'] = array( 'class' => 'error', 'message' => sprintf( __( '%sWooCommerce MailChimp requires WooCommerce to be active. %sActivate WooCommerce%s to use the WooCommerce MailChimp plugin.', 'woocommerce-mailchimp' ), '<h3>', "</h3>\n\n". $button, '</a></strong>' ) );
|
253 |
+
break;
|
254 |
+
default:
|
255 |
+
$button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#woocommerce">' : '<strong><a href="'. wp_nonce_url( admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' ) . '" class="button button-large">';
|
256 |
+
|
257 |
+
self::$notices['wc_installed'] = array( 'class' => 'error', 'message' => sprintf( __( '%sWooCommerce MailChimp requires WooCommerce to be installed in order to run properly. %sInstall WooCommerce%s to use the WooCommerce MailChimp plugin.', 'woocommerce-mailchimp' ), '<h3>', "</h3>\n\n". $button, '</a></strong>') );
|
258 |
+
break;
|
259 |
+
}
|
260 |
+
|
261 |
+
return $return;
|
262 |
+
|
263 |
+
} //end public static function check_woocommerce()
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Check if specified plugin is active, inactive or not installed
|
267 |
+
*
|
268 |
+
* @access public
|
269 |
+
* @static
|
270 |
+
* @param string $location (default: '')
|
271 |
+
* @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive
|
272 |
+
*/
|
273 |
+
public static function get_plugin_status( $location = '' ) {
|
274 |
+
|
275 |
+
if ( ! function_exists('is_plugin_active') ) {
|
276 |
+
include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
277 |
+
}
|
278 |
+
|
279 |
+
if ( is_network_admin() && is_plugin_active_for_network( $location ) ) {
|
280 |
+
return true;
|
281 |
+
}
|
282 |
+
|
283 |
+
if ( !is_network_admin() && is_plugin_active( $location ) ) {
|
284 |
+
return true;
|
285 |
+
}
|
286 |
+
|
287 |
+
if (
|
288 |
+
!file_exists( trailingslashit( WP_PLUGIN_DIR ) . $location ) &&
|
289 |
+
!file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $location )
|
290 |
+
) {
|
291 |
+
return false;
|
292 |
+
}
|
293 |
+
|
294 |
+
return 'inactive';
|
295 |
+
}
|
296 |
+
|
297 |
+
} //SS_WC_MailChimp_Compatibility
|
trunk/includes/class-ss-wc-mailchimp-handler.php
ADDED
@@ -0,0 +1,476 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WooCommerce MailChimp Handler
|
4 |
+
*
|
5 |
+
* @author Saint Systems
|
6 |
+
* @package WooCommerce MailChimp
|
7 |
+
* @version 2.0
|
8 |
+
*/
|
9 |
+
|
10 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
11 |
+
|
12 |
+
if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @class SS_WC_MailChimp_Handler
|
16 |
+
*/
|
17 |
+
final class SS_WC_MailChimp_Handler {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Plugin singleton instance
|
21 |
+
* @var SS_WC_MailChimp_Handler
|
22 |
+
*/
|
23 |
+
private static $instance = null;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Constructor
|
27 |
+
*
|
28 |
+
* @access public
|
29 |
+
* @return void
|
30 |
+
*/
|
31 |
+
public function __construct() {
|
32 |
+
|
33 |
+
$this->id = 'mailchimp';
|
34 |
+
$this->namespace = 'ss_wc_' . $this->id;
|
35 |
+
$this->label = __( 'MailChimp', 'woocommerce-mailchimp' );
|
36 |
+
$this->sswcmc = SSWCMC();
|
37 |
+
$this->register_hooks();
|
38 |
+
|
39 |
+
} //end function __construct
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @return SS_WC_MailChimp_Handler
|
43 |
+
*/
|
44 |
+
public static function get_instance() {
|
45 |
+
|
46 |
+
if ( empty( self::$instance ) ) {
|
47 |
+
self::$instance = new self;
|
48 |
+
}
|
49 |
+
|
50 |
+
return self::$instance;
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Register plugin hooks
|
56 |
+
*
|
57 |
+
* @access public
|
58 |
+
* @return void
|
59 |
+
*/
|
60 |
+
public function register_hooks() {
|
61 |
+
|
62 |
+
// We would use the 'woocommerce_new_order' action but first name, last name and email address (order meta) is not yet available,
|
63 |
+
// so instead we use the 'woocommerce_checkout_update_order_meta' action hook which fires after the checkout process on the "thank you" page
|
64 |
+
add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'order_status_changed' ), 1000, 1 );
|
65 |
+
|
66 |
+
// hook into woocommerce order status changed hook to handle the desired subscription event trigger
|
67 |
+
add_action( 'woocommerce_order_status_changed', array( $this, 'order_status_changed' ), 10, 3 );
|
68 |
+
|
69 |
+
$opt_in_checkbox_display_location = $this->sswcmc->opt_in_checkbox_display_location();
|
70 |
+
|
71 |
+
// Maybe add an "opt-in" field to the checkout
|
72 |
+
$opt_in_checkbox_display_location = !empty( $opt_in_checkbox_display_location ) ? $opt_in_checkbox_display_location : 'woocommerce_review_order_before_submit';
|
73 |
+
|
74 |
+
// Old opt-in checkbox display locations
|
75 |
+
$old_opt_in_checkbox_display_locations = array(
|
76 |
+
'billing' => 'woocommerce_after_checkout_billing_form',
|
77 |
+
'order' => 'woocommerce_review_order_before_submit',
|
78 |
+
);
|
79 |
+
|
80 |
+
// Map old billing/order checkbox display locations to new format
|
81 |
+
if ( array_key_exists( $opt_in_checkbox_display_location, $old_opt_in_checkbox_display_locations ) ) {
|
82 |
+
$opt_in_checkbox_display_location = $old_opt_in_checkbox_display_locations[ $opt_in_checkbox_display_location ];
|
83 |
+
}
|
84 |
+
|
85 |
+
add_action( $opt_in_checkbox_display_location, array( $this, 'maybe_add_checkout_fields' ) );
|
86 |
+
|
87 |
+
// Maybe save the "opt-in" field on the checkout
|
88 |
+
add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'maybe_save_checkout_fields' ) );
|
89 |
+
|
90 |
+
add_action( 'wp_ajax_ss_wc_mailchimp_get_account', array( $this, 'ajax_get_account' ) );
|
91 |
+
|
92 |
+
add_action( 'wp_ajax_ss_wc_mailchimp_get_lists', array( $this, 'ajax_get_lists' ) );
|
93 |
+
|
94 |
+
add_action( 'wp_ajax_ss_wc_mailchimp_get_interest_groups', array( $this, 'ajax_get_interest_groups' ) );
|
95 |
+
|
96 |
+
add_action( 'wp_ajax_ss_wc_mailchimp_get_merge_fields', array( $this, 'ajax_get_merge_fields' ) );
|
97 |
+
|
98 |
+
add_action( 'queue_ss_wc_mailchimp_maybe_subscribe', array( $this, 'maybe_subscribe' ), 10, 6 );
|
99 |
+
|
100 |
+
} //end function ensure_tab
|
101 |
+
|
102 |
+
/**
|
103 |
+
* order_status_changed function.
|
104 |
+
*
|
105 |
+
* @access public
|
106 |
+
* @return void
|
107 |
+
*/
|
108 |
+
public function order_status_changed( $id, $status = 'new', $new_status = 'pending' ) {
|
109 |
+
if ( $this->sswcmc->is_valid() && $new_status === $this->sswcmc->occurs() ) {
|
110 |
+
// Get WC order
|
111 |
+
$order = $this->wc_get_order( $id );
|
112 |
+
|
113 |
+
// get the ss_wc_mailchimp_opt_in value from the post meta. "order_custom_fields" was removed with WooCommerce 2.1
|
114 |
+
$subscribe_customer = get_post_meta( $id, 'ss_wc_mailchimp_opt_in', true );
|
115 |
+
|
116 |
+
$order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
|
117 |
+
$order_billing_email = method_exists( $order, 'get_billing_email' ) ? $order->get_billing_email() : $order->billing_email;
|
118 |
+
$order_billing_first_name = method_exists( $order, 'get_billing_first_name' ) ? $order->get_billing_first_name() : $order->billing_first_name;
|
119 |
+
$order_billing_last_name = method_exists( $order, 'get_billing_last_name' ) ? $order->get_billing_last_name() : $order->billing_last_name;
|
120 |
+
|
121 |
+
$list_id = $this->sswcmc->get_list();
|
122 |
+
|
123 |
+
$this->log( sprintf( __( __METHOD__ . '(): Queueing maybe subscribe ($subscribe_customer: %s) for customer (%s) to list %s', 'woocommerce-mailchimp'), $subscribe_customer, $order_billing_email, $list_id ) );
|
124 |
+
|
125 |
+
// Queue the subscription.
|
126 |
+
as_schedule_single_action( time(), 'queue_ss_wc_mailchimp_maybe_subscribe', array( $subscribe_customer, $order_id, $order_billing_first_name, $order_billing_last_name, $order_billing_email, $list_id ), 'sswcmc' );
|
127 |
+
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Return all lists from MailChimp to be used in select fields
|
133 |
+
*
|
134 |
+
* @access public
|
135 |
+
* @return array
|
136 |
+
*/
|
137 |
+
public function ajax_get_account() {
|
138 |
+
|
139 |
+
try {
|
140 |
+
|
141 |
+
if ( ! isset( $_POST['data'] ) ) {
|
142 |
+
throw new Exception( __( __METHOD__ . ': $_POST[\'data\'] not provided.', 'woocommerce-mailchimp' ) );
|
143 |
+
}
|
144 |
+
|
145 |
+
if ( ! $_POST['data']['api_key'] || empty( $_POST['data']['api_key'] ) ) {
|
146 |
+
|
147 |
+
throw new Exception( __( 'Please enter an api key.', 'woocommerce-mailchimp' ) );
|
148 |
+
|
149 |
+
}
|
150 |
+
|
151 |
+
$api_key = $_POST['data']['api_key'];
|
152 |
+
|
153 |
+
$account = $this->sswcmc->mailchimp()->get_account( $api_key );
|
154 |
+
|
155 |
+
$results = $account;
|
156 |
+
|
157 |
+
} catch ( Exception $e ) {
|
158 |
+
|
159 |
+
return $this->toJSON( array( 'error' => $e->getMessage() ) );
|
160 |
+
|
161 |
+
}
|
162 |
+
|
163 |
+
return $this->toJSON( $results );
|
164 |
+
|
165 |
+
} //end function ajax_get_account
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Return all lists from MailChimp to be used in select fields
|
169 |
+
*
|
170 |
+
* @access public
|
171 |
+
* @return array
|
172 |
+
*/
|
173 |
+
public function ajax_get_lists() {
|
174 |
+
|
175 |
+
try {
|
176 |
+
|
177 |
+
if ( ! $_POST['data']['api_key'] || empty( $_POST['data']['api_key'] ) ) {
|
178 |
+
|
179 |
+
return $this->toJSON( array( '' => __( 'Enter your api key above to see your lists', 'woocommerce-mailchimp' ) ) );
|
180 |
+
|
181 |
+
}
|
182 |
+
|
183 |
+
$api_key = $_POST['data']['api_key'];
|
184 |
+
|
185 |
+
$lists = $this->sswcmc->mailchimp( $api_key )->get_lists();
|
186 |
+
|
187 |
+
$results = array_merge( array( '' => 'Select a list...' ), $lists );
|
188 |
+
|
189 |
+
} catch ( Exception $e ) {
|
190 |
+
|
191 |
+
return $this->toJSON( array( 'error' => $e->getMessage() ) );
|
192 |
+
|
193 |
+
}
|
194 |
+
|
195 |
+
return $this->toJSON( $results );
|
196 |
+
|
197 |
+
} //end function ajax_get_lists
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Return interest categories for the passed MailChimp List to be used in select fields
|
201 |
+
*
|
202 |
+
* @access public
|
203 |
+
* @return array
|
204 |
+
*/
|
205 |
+
public function ajax_get_interest_groups() {
|
206 |
+
|
207 |
+
try {
|
208 |
+
|
209 |
+
if ( ! $_POST['data']['api_key'] || empty( $_POST['data']['api_key'] ) ) {
|
210 |
+
|
211 |
+
return $this->toJSON( array( '' => __( 'Enter your api key above to see your lists', 'ss_wc_mailchimp' ) ) );
|
212 |
+
|
213 |
+
}
|
214 |
+
|
215 |
+
if ( ! $_POST['data']['list_id'] || empty( $_POST['data']['list_id'] ) ) {
|
216 |
+
|
217 |
+
return $this->toJSON( array( '' => __( 'Please select a list from above.', 'ss_wc_mailchimp' ) ) );
|
218 |
+
|
219 |
+
}
|
220 |
+
|
221 |
+
$api_key = $_POST['data']['api_key'];
|
222 |
+
$list_id = $_POST['data']['list_id'];
|
223 |
+
|
224 |
+
$interest_groups = $this->sswcmc->mailchimp( $api_key )->get_interest_categories_with_interests( $list_id );
|
225 |
+
|
226 |
+
$results = $interest_groups;
|
227 |
+
|
228 |
+
} catch ( Exception $e ) {
|
229 |
+
|
230 |
+
return $this->toJSON( array( 'error' => $e->getMessage() ) );
|
231 |
+
|
232 |
+
}
|
233 |
+
|
234 |
+
return $this->toJSON( $results );
|
235 |
+
|
236 |
+
} //end function ajax_get_interest_groups
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Return merge fields (a.k.a. merge tags) for the passed MailChimp List
|
240 |
+
*
|
241 |
+
* @access public
|
242 |
+
* @return array
|
243 |
+
*/
|
244 |
+
public function ajax_get_merge_fields() {
|
245 |
+
|
246 |
+
try {
|
247 |
+
|
248 |
+
if ( !$_POST['data']['api_key'] || empty( $_POST['data']['api_key'] ) ) {
|
249 |
+
|
250 |
+
return $this->toJSON( array( '' => __( 'Please enter your api key above.', 'ss_wc_mailchimp' ) ) );
|
251 |
+
|
252 |
+
}
|
253 |
+
|
254 |
+
if ( !$_POST['data']['list_id'] || empty( $_POST['data']['list_id'] ) ) {
|
255 |
+
|
256 |
+
return $this->toJSON( array( '' => __( 'Please select a list from above.', 'ss_wc_mailchimp' ) ) );
|
257 |
+
|
258 |
+
}
|
259 |
+
|
260 |
+
$api_key = $_POST['data']['api_key'];
|
261 |
+
$list_id = $_POST['data']['list_id'];
|
262 |
+
|
263 |
+
$merge_fields = $this->sswcmc->mailchimp( $api_key )->get_merge_fields( $list_id );
|
264 |
+
|
265 |
+
$results = $merge_fields;
|
266 |
+
|
267 |
+
}
|
268 |
+
catch ( Exception $e ) {
|
269 |
+
|
270 |
+
return $this->toJSON( array( 'error' => $e->getMessage() ) );
|
271 |
+
|
272 |
+
}
|
273 |
+
|
274 |
+
return $this->toJSON( $results );
|
275 |
+
|
276 |
+
} //end function ajax_get_merge_fields
|
277 |
+
|
278 |
+
private function toJSON( $response ) {
|
279 |
+
|
280 |
+
// Commented out due to json_encode not preserving quotes around MailChimp ids
|
281 |
+
// header('Content-Type: application/json');
|
282 |
+
echo json_encode( $response );
|
283 |
+
exit();
|
284 |
+
|
285 |
+
} //end function toJSON
|
286 |
+
|
287 |
+
/**
|
288 |
+
* WooCommerce 2.2 support for wc_get_order
|
289 |
+
*
|
290 |
+
* @since 1.2.1
|
291 |
+
*
|
292 |
+
* @access private
|
293 |
+
* @param int $order_id
|
294 |
+
* @return void
|
295 |
+
*/
|
296 |
+
private function wc_get_order( $order_id ) {
|
297 |
+
if ( function_exists( 'wc_get_order' ) ) {
|
298 |
+
return wc_get_order( $order_id );
|
299 |
+
} else {
|
300 |
+
return new WC_Order( $order_id );
|
301 |
+
}
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Get message
|
306 |
+
* @return string Error
|
307 |
+
*/
|
308 |
+
private function get_message( $message, $type = 'error' ) {
|
309 |
+
ob_start();
|
310 |
+
|
311 |
+
?>
|
312 |
+
<div class="<?php echo $type ?>">
|
313 |
+
<p><?php echo $message ?></p>
|
314 |
+
</div>
|
315 |
+
<?php
|
316 |
+
return ob_get_clean();
|
317 |
+
}
|
318 |
+
|
319 |
+
/**
|
320 |
+
* subscribe function.
|
321 |
+
*
|
322 |
+
* @access public
|
323 |
+
* @param boolean $subscribe_customer
|
324 |
+
* @param int $order_id
|
325 |
+
* @param mixed $first_name
|
326 |
+
* @param mixed $last_name
|
327 |
+
* @param mixed $email
|
328 |
+
* @param string $listid (default: 'false')
|
329 |
+
* @return void
|
330 |
+
*/
|
331 |
+
public function maybe_subscribe( $subscribe_customer, $order_id, $first_name, $last_name, $email, $list_id = 'false' ) {
|
332 |
+
|
333 |
+
// throw new Exception('Failure: Houston we have a problem!');
|
334 |
+
|
335 |
+
$this->log( sprintf( __( __METHOD__ . '(): Processing queued maybe_subscribe ($subscribe_customer: %s) for customer (%s) to list %s', 'woocommerce-mailchimp' ), $subscribe_customer, $email, $list_id ) );
|
336 |
+
|
337 |
+
if ( ! $email ) {
|
338 |
+
return; // Email is required.
|
339 |
+
}
|
340 |
+
|
341 |
+
if ( 'false' == $list_id ) {
|
342 |
+
$list_id = $this->sswcmc->get_list();
|
343 |
+
}
|
344 |
+
|
345 |
+
$merge_tags = array(
|
346 |
+
'FNAME' => $first_name,
|
347 |
+
'LNAME' => $last_name,
|
348 |
+
);
|
349 |
+
|
350 |
+
$interest_groups = $this->sswcmc->interest_groups();
|
351 |
+
|
352 |
+
if ( ! empty( $interest_groups ) ) {
|
353 |
+
$interest_groups = array_fill_keys( $this->sswcmc->interest_groups(), true );
|
354 |
+
|
355 |
+
// Allow hooking into variables.
|
356 |
+
$interest_groups = apply_filters( 'ss_wc_mailchimp_subscribe_interest_groups', $interest_groups, $order_id, $email );
|
357 |
+
}
|
358 |
+
|
359 |
+
// Allow hooking into variables.
|
360 |
+
$merge_tags = apply_filters( 'ss_wc_mailchimp_subscribe_merge_tags', $merge_tags, $order_id, $email );
|
361 |
+
|
362 |
+
// Set subscription options.
|
363 |
+
$subscribe_options = array(
|
364 |
+
'list_id' => $list_id,
|
365 |
+
'email' => $email,
|
366 |
+
'merge_tags' => $merge_tags,
|
367 |
+
'interest_groups' => $interest_groups,
|
368 |
+
'email_type' => 'html',
|
369 |
+
'double_opt_in' => $this->sswcmc->double_opt_in(),
|
370 |
+
);
|
371 |
+
|
372 |
+
// Allow hooking into subscription options.
|
373 |
+
$options = apply_filters( 'ss_wc_mailchimp_subscribe_options', $subscribe_options, $order_id );
|
374 |
+
|
375 |
+
// Extract options into variables.
|
376 |
+
extract( $options );
|
377 |
+
|
378 |
+
// Log.
|
379 |
+
$this->log( sprintf( __( __METHOD__ . '(): Maybe subscribing customer ($subscribe_customer: %s) to MailChimp: %s', 'woocommerce-mailchimp' ), $subscribe_customer, print_r( $options, true ) ) );
|
380 |
+
|
381 |
+
do_action( 'ss_wc_mailchimp_before_subscribe', $subscribe_options, $order_id );
|
382 |
+
|
383 |
+
// If the 'ss_wc_mailchimp_opt_in' meta value isn't set
|
384 |
+
// (because 'display_opt_in' wasn't enabled at the time the order was placed)
|
385 |
+
// or the 'ss_wc_mailchimp_opt_in' is yes, subscriber the customer
|
386 |
+
|
387 |
+
if ( ! empty( $list_id ) && ( ! $subscribe_customer || empty( $subscribe_customer ) || 'yes' === $subscribe_customer ) ) {
|
388 |
+
// Call API.
|
389 |
+
$api_response = $this->sswcmc->mailchimp()->subscribe( $list_id, $email, $email_type, $merge_tags, $interest_groups, $double_opt_in );
|
390 |
+
|
391 |
+
// Log api response.
|
392 |
+
$this->log( sprintf( __( __METHOD__ . '(): MailChimp API response: %s', 'woocommerce-mailchimp' ), print_r( $api_response, true ) ) );
|
393 |
+
|
394 |
+
if ( $api_response === false ) {
|
395 |
+
// Format error message.
|
396 |
+
$error_response = sprintf( __( __METHOD__ . '(): WooCommerce MailChimp subscription failed: %s (%s)', 'woocommerce-mailchimp' ), $this->sswcmc->mailchimp()->get_error_message(), $this->sswcmc->mailchimp()->get_error_code() );
|
397 |
+
|
398 |
+
// Log the error response.
|
399 |
+
$this->log( $error_response );
|
400 |
+
|
401 |
+
// New hook for failing operations.
|
402 |
+
do_action( 'ss_wc_mailchimp_subscription_failed', $email, array( 'list_id' => $list_id, 'order_id' => $order_id ) );
|
403 |
+
|
404 |
+
// Email admin.
|
405 |
+
$admin_email = get_option( 'admin_email' );
|
406 |
+
$admin_email = apply_filters( 'ss_wc_mailchimp_admin_email', $admin_email );
|
407 |
+
wp_mail( $admin_email, __( 'WooCommerce MailChimp subscription failed', 'woocommerce-mailchimp' ), $error_response );
|
408 |
+
} else {
|
409 |
+
// Hook on success.
|
410 |
+
do_action( 'ss_wc_mailchimp_subscription_success', $email, array( 'list_id' => $list_id, 'order_id' => $order_id ) );
|
411 |
+
}
|
412 |
+
}
|
413 |
+
|
414 |
+
do_action( 'ss_wc_mailchimp_after_subscribe', $subscribe_options, $order_id );
|
415 |
+
|
416 |
+
}
|
417 |
+
|
418 |
+
/**
|
419 |
+
* Add the opt-in checkbox to the checkout fields (to be displayed on checkout).
|
420 |
+
*
|
421 |
+
* @since 1.1
|
422 |
+
*/
|
423 |
+
function maybe_add_checkout_fields() {
|
424 |
+
|
425 |
+
if ( $this->sswcmc->is_valid() ) {
|
426 |
+
if ( $this->sswcmc->display_opt_in() ) {
|
427 |
+
do_action( 'ss_wc_mailchimp_before_opt_in_checkbox' );
|
428 |
+
|
429 |
+
echo apply_filters( 'ss_wc_mailchimp_opt_in_checkbox', '<p class="form-row woocommerce-mailchimp-opt-in"><label class="checkbox" for="ss_wc_mailchimp_opt_in"><input type="checkbox" name="ss_wc_mailchimp_opt_in" id="ss_wc_mailchimp_opt_in" class="input-checkbox" value="yes"' . ($this->sswcmc->opt_in_checkbox_default_status() == 'checked' ? ' checked="checked"' : '') . '/> ' . esc_html( $this->sswcmc->opt_in_label() ) . '</label></p>' . "\n", $this->sswcmc->opt_in_checkbox_default_status(), $this->sswcmc->opt_in_label(), $this->sswcmc->opt_in_checkbox_default_status(), $this->sswcmc->opt_in_label() );
|
430 |
+
// woocommerce_form_field( '2ss_wc_mailchimp_opt_in', array(
|
431 |
+
// 'type' => 'checkbox',
|
432 |
+
// 'class' => array('woocommerce-mailchimp-opt-in'),
|
433 |
+
// 'label' => esc_html( $this->sswcmc->opt_in_label() ),
|
434 |
+
// 'custom_attributes' => array(
|
435 |
+
// 'for' => '2ss_wc_mailchimp_opt_in',
|
436 |
+
// ),
|
437 |
+
// ), $this->sswcmc->opt_in_checkbox_default_status() == 'checked' );
|
438 |
+
do_action( 'ss_wc_mailchimp_after_opt_in_checkbox' );
|
439 |
+
}
|
440 |
+
}
|
441 |
+
}
|
442 |
+
|
443 |
+
/**
|
444 |
+
* When the checkout form is submitted, save opt-in value.
|
445 |
+
*
|
446 |
+
* @version 1.1
|
447 |
+
*/
|
448 |
+
function maybe_save_checkout_fields( $order_id ) {
|
449 |
+
if ( $this->sswcmc->display_opt_in() ) {
|
450 |
+
$opt_in = isset( $_POST[ 'ss_wc_mailchimp_opt_in' ] ) ? 'yes' : 'no';
|
451 |
+
|
452 |
+
update_post_meta( $order_id, 'ss_wc_mailchimp_opt_in', $opt_in );
|
453 |
+
}
|
454 |
+
}
|
455 |
+
|
456 |
+
/**
|
457 |
+
* Helper log function for debugging
|
458 |
+
*
|
459 |
+
* @since 1.2.2
|
460 |
+
*/
|
461 |
+
private function log( $message ) {
|
462 |
+
if ( $this->sswcmc->debug_enabled() ) {
|
463 |
+
$logger = new WC_Logger();
|
464 |
+
|
465 |
+
if ( is_array( $message ) || is_object( $message ) ) {
|
466 |
+
$logger->add( 'woocommerce-mailchimp', print_r( $message, true ) );
|
467 |
+
}
|
468 |
+
else {
|
469 |
+
$logger->add( 'woocommerce-mailchimp', $message );
|
470 |
+
}
|
471 |
+
}
|
472 |
+
}
|
473 |
+
|
474 |
+
} //end class SS_WC_MailChimp_Handler
|
475 |
+
|
476 |
+
} //end if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) )
|
trunk/includes/class-ss-wc-mailchimp-migrator.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* WooCommerce MailChimp plugin migrator class
|
5 |
+
*/
|
6 |
+
final class SS_WC_MailChimp_Migrator {
|
7 |
+
|
8 |
+
const VERSION_KEY = 'ss_wc_mailchimp_version';
|
9 |
+
const OLD_SETTINGS_KEY = 'woocommerce_mailchimp_settings';
|
10 |
+
|
11 |
+
protected static $versions = array(
|
12 |
+
'1.3.X',
|
13 |
+
'2.0',
|
14 |
+
'2.0.15',
|
15 |
+
);
|
16 |
+
|
17 |
+
public static function migrate( $target_version ) {
|
18 |
+
|
19 |
+
$old_settings = get_option( self::OLD_SETTINGS_KEY );
|
20 |
+
$current_version = get_option( self::VERSION_KEY );
|
21 |
+
|
22 |
+
if ( ! $old_settings && ! $current_version ) {
|
23 |
+
// This is a new install, so no need to migrate
|
24 |
+
return;
|
25 |
+
}
|
26 |
+
|
27 |
+
if ( ! $current_version ) {
|
28 |
+
$current_version = '1.3.X';
|
29 |
+
}
|
30 |
+
|
31 |
+
if ( $current_version !== $target_version ) {
|
32 |
+
|
33 |
+
// error_log( 'Need to migrate from ' . $current_version . ' to ' . $target_version );
|
34 |
+
|
35 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/migrations/class-ss-wc-migration.php' );
|
36 |
+
|
37 |
+
$start = array_search( $current_version, self::$versions );
|
38 |
+
|
39 |
+
// error_log( 'Starting at migration ' . $start );
|
40 |
+
|
41 |
+
for ($start; $start < count(self::$versions) - 1; $start++) {
|
42 |
+
$next = $start + 1;
|
43 |
+
$current_version = self::$versions[$start];
|
44 |
+
$next_version = self::$versions[$next];
|
45 |
+
|
46 |
+
// error_log( 'Migrating from ' . $current_version . ' to ' . $target_version );
|
47 |
+
//
|
48 |
+
if ( file_exists( SS_WC_MAILCHIMP_DIR . "includes/migrations/class-ss-wc-migration-from-$current_version-to-$next_version.php" ) ) {
|
49 |
+
|
50 |
+
require_once( SS_WC_MAILCHIMP_DIR . "includes/migrations/class-ss-wc-migration-from-$current_version-to-$next_version.php" );
|
51 |
+
|
52 |
+
$migration_name = 'SS_WC_MailChimp_Migration_From_'. self::clean_version( $current_version ) .'_To_'. self::clean_version( $next_version );
|
53 |
+
|
54 |
+
$migration = new $migration_name( $current_version, $next_version );
|
55 |
+
if ( $migration->up() ) {
|
56 |
+
// Update the current plugin version
|
57 |
+
update_option( self::VERSION_KEY, $next_version );
|
58 |
+
}
|
59 |
+
|
60 |
+
}
|
61 |
+
}
|
62 |
+
//update_option( self::VERSION_KEY, $target_version );
|
63 |
+
|
64 |
+
}
|
65 |
+
|
66 |
+
}
|
67 |
+
|
68 |
+
private static function clean_version( $version ) {
|
69 |
+
return str_replace( '.', '_', $version );
|
70 |
+
}
|
71 |
+
|
72 |
+
}
|
trunk/includes/class-ss-wc-mailchimp-plugin.php
ADDED
@@ -0,0 +1,623 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Main Plugin Class
|
4 |
+
*
|
5 |
+
* @package WooCommerce MailChimp
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* WooCommerce MailChimp plugin main class
|
10 |
+
*/
|
11 |
+
final class SS_WC_MailChimp_Plugin {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Plugin version
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
private static $version = '2.1.15';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Plugin singleton instance
|
22 |
+
*
|
23 |
+
* @var SS_WC_MailChimp_Plugin
|
24 |
+
*/
|
25 |
+
private static $instance;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Plugin namespace
|
29 |
+
*
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
private $namespace = 'ss_wc_mailchimp';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Plugin settings
|
36 |
+
*
|
37 |
+
* @var array
|
38 |
+
*/
|
39 |
+
private $settings;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Plugin MailChimp helper instance
|
43 |
+
*
|
44 |
+
* @var SS_WC_MailChimp
|
45 |
+
*/
|
46 |
+
private $mailchimp;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Plugin compatibility checker
|
50 |
+
*
|
51 |
+
* @var SS_WC_MailChimp_Compatibility
|
52 |
+
*/
|
53 |
+
public $compatibility;
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Returns the plugin version
|
57 |
+
*
|
58 |
+
* @return string
|
59 |
+
*/
|
60 |
+
public static function version() {
|
61 |
+
return self::$version;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Singleton instance
|
66 |
+
*
|
67 |
+
* @return SS_WC_MailChimp_Plugin SS_WC_MailChimp_Plugin object
|
68 |
+
*/
|
69 |
+
public static function get_instance() {
|
70 |
+
|
71 |
+
if ( empty( self::$instance ) && ! ( self::$instance instanceof SS_WC_MailChimp_Plugin ) ) {
|
72 |
+
|
73 |
+
self::$instance = new SS_WC_MailChimp_Plugin();
|
74 |
+
self::$instance->define_constants();
|
75 |
+
|
76 |
+
self::$instance->save_settings();
|
77 |
+
self::$instance->settings();
|
78 |
+
self::$instance->includes();
|
79 |
+
self::$instance->mailchimp();
|
80 |
+
self::$instance->logger = SSWCMC_Logger::get_instance();
|
81 |
+
self::$instance->handler = SS_WC_MailChimp_Handler::get_instance();
|
82 |
+
self::$instance->compatibility = SS_WC_MailChimp_Compatibility::get_instance();
|
83 |
+
self::$instance->admin_notices = new SS_WC_MailChimp_Admin_Notices();
|
84 |
+
self::$instance->load_plugin_textdomain();
|
85 |
+
|
86 |
+
self::update();
|
87 |
+
self::$instance->add_hooks();
|
88 |
+
do_action( 'ss_wc_mailchimp_loaded' );
|
89 |
+
|
90 |
+
}
|
91 |
+
|
92 |
+
return self::$instance;
|
93 |
+
|
94 |
+
} //end function instance
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Gets the plugin db settings
|
98 |
+
*
|
99 |
+
* @param boolean $refresh refresh the settings from DB.
|
100 |
+
* @return array The plugin db settings
|
101 |
+
*/
|
102 |
+
public function settings( $refresh = false ) {
|
103 |
+
|
104 |
+
if ( empty( $this->settings ) || true === $refresh ) {
|
105 |
+
|
106 |
+
$defaults = require( SS_WC_MAILCHIMP_DIR . 'config/default-settings.php' );
|
107 |
+
$defaults = apply_filters( 'ss_wc_mailchimp_default_settings', $defaults );
|
108 |
+
$settings = array();
|
109 |
+
|
110 |
+
foreach ( $defaults as $key => $default_value ) {
|
111 |
+
|
112 |
+
$setting_value = get_option( $this->namespace_prefixed( $key ) );
|
113 |
+
|
114 |
+
$settings[ $key ] = $setting_value ? $setting_value : $default_value;
|
115 |
+
}
|
116 |
+
|
117 |
+
$merged_settings = apply_filters( 'ss_wc_mailchimp_settings', array_merge( $defaults, $settings ) );
|
118 |
+
|
119 |
+
$this->settings = $merged_settings;
|
120 |
+
|
121 |
+
$this->mailchimp( $settings['api_key'] );
|
122 |
+
|
123 |
+
}
|
124 |
+
|
125 |
+
return $this->settings;
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Returns the api key.
|
130 |
+
*
|
131 |
+
* @return string MailChimp API Key
|
132 |
+
*/
|
133 |
+
public function api_key() {
|
134 |
+
return $this->settings['api_key'];
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Whether or not the plugin functionality is enabled.
|
139 |
+
*
|
140 |
+
* @access public
|
141 |
+
* @return boolean
|
142 |
+
*/
|
143 |
+
public function is_enabled() {
|
144 |
+
return 'yes' === $this->settings['enabled'];
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Whether or not a main list has been selected.
|
149 |
+
*
|
150 |
+
* @access public
|
151 |
+
* @return boolean
|
152 |
+
*/
|
153 |
+
public function has_list() {
|
154 |
+
$has_list = false;
|
155 |
+
|
156 |
+
if ( $this->get_list() ) {
|
157 |
+
$has_list = true;
|
158 |
+
}
|
159 |
+
return apply_filters( 'ss_wc_mailchimp_has_list', $has_list );
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* When the subscription should be triggered.
|
164 |
+
*
|
165 |
+
* @return string
|
166 |
+
*/
|
167 |
+
public function occurs() {
|
168 |
+
return $this->settings['occurs'];
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Returns the selected list.
|
173 |
+
*
|
174 |
+
* @access public
|
175 |
+
* @return string MailChimp list ID
|
176 |
+
*/
|
177 |
+
public function get_list() {
|
178 |
+
return $this->settings['list'];
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Whether or not double opt-in is selected.
|
183 |
+
*
|
184 |
+
* @access public
|
185 |
+
* @return boolean
|
186 |
+
*/
|
187 |
+
public function double_opt_in() {
|
188 |
+
return 'yes' === $this->settings['double_opt_in'];
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Whether or not to display opt-in checkbox to user.
|
193 |
+
*
|
194 |
+
* @access public
|
195 |
+
* @return boolean
|
196 |
+
*/
|
197 |
+
public function display_opt_in() {
|
198 |
+
return 'yes' === $this->settings['display_opt_in'];
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Opt-in label.
|
203 |
+
*
|
204 |
+
* @access public
|
205 |
+
* @return string
|
206 |
+
*/
|
207 |
+
public function opt_in_label() {
|
208 |
+
return $this->settings['opt_in_label'];
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Opt-in checkbox default status.
|
213 |
+
*
|
214 |
+
* @access public
|
215 |
+
* @return string
|
216 |
+
*/
|
217 |
+
public function opt_in_checkbox_default_status() {
|
218 |
+
return $this->settings['opt_in_checkbox_default_status'];
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Opt-in checkbox display location.
|
223 |
+
*
|
224 |
+
* @access public
|
225 |
+
* @return string
|
226 |
+
*/
|
227 |
+
public function opt_in_checkbox_display_location() {
|
228 |
+
return $this->settings['opt_in_checkbox_display_location'];
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Returns selected MailChimp interest groups.
|
233 |
+
*
|
234 |
+
* @access public
|
235 |
+
* @return array
|
236 |
+
*/
|
237 |
+
public function interest_groups() {
|
238 |
+
return $this->settings['interest_groups'];
|
239 |
+
}
|
240 |
+
|
241 |
+
/**
|
242 |
+
* Whether or not an api key has been set.
|
243 |
+
*
|
244 |
+
* @access public
|
245 |
+
* @return boolean
|
246 |
+
*/
|
247 |
+
public function has_api_key() {
|
248 |
+
$api_key = $this->api_key();
|
249 |
+
return ! empty( $api_key );
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Whether or not the configuration is valid.
|
254 |
+
*
|
255 |
+
* @access public
|
256 |
+
* @return boolean
|
257 |
+
*/
|
258 |
+
public function is_valid() {
|
259 |
+
return $this->is_enabled() && $this->has_api_key();
|
260 |
+
}
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Whether or not debug is enabled.
|
264 |
+
*
|
265 |
+
* @access public
|
266 |
+
* @return boolean
|
267 |
+
*/
|
268 |
+
public function debug_enabled() {
|
269 |
+
return 'yes' === $this->settings['debug'];
|
270 |
+
}
|
271 |
+
|
272 |
+
/**
|
273 |
+
* Saves the settings back to the DB
|
274 |
+
*
|
275 |
+
* @return void
|
276 |
+
*/
|
277 |
+
public function save_settings() {
|
278 |
+
|
279 |
+
$settings = $this->settings();
|
280 |
+
|
281 |
+
foreach ( $settings as $key => $value ) {
|
282 |
+
update_option( $this->namespace_prefixed( $key ), $value );
|
283 |
+
}
|
284 |
+
|
285 |
+
} //end function save_settings
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Gets the MailChimp Helper
|
289 |
+
*
|
290 |
+
* @param string $api_key MailChimp API Key.
|
291 |
+
* @param boolean $debug Debug mode enabled/disabled.
|
292 |
+
* @return SS_WC_MailChimp MailChimp Helper class
|
293 |
+
*/
|
294 |
+
public function mailchimp( $api_key = null, $debug = false ) {
|
295 |
+
|
296 |
+
$settings = $this->settings();
|
297 |
+
|
298 |
+
if ( empty( $this->mailchimp ) || ! is_null( $api_key ) ) {
|
299 |
+
|
300 |
+
$api_key = $api_key ? $api_key : $settings['api_key'];
|
301 |
+
$debug = $debug ? $debug : $settings['debug'];
|
302 |
+
|
303 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp.php' );
|
304 |
+
$this->mailchimp = new SS_WC_MailChimp( $api_key, $debug );
|
305 |
+
|
306 |
+
delete_transient( 'sswcmc_lists' );
|
307 |
+
}
|
308 |
+
|
309 |
+
return $this->mailchimp;
|
310 |
+
|
311 |
+
} //end function mailchimp
|
312 |
+
|
313 |
+
/**
|
314 |
+
* Define Plugin Constants.
|
315 |
+
*/
|
316 |
+
private function define_constants() {
|
317 |
+
|
318 |
+
// Minimum supported version of WordPress.
|
319 |
+
$this->define( 'SS_WC_MAILCHIMP_MIN_WP_VERSION', '3.5.1' );
|
320 |
+
|
321 |
+
// Minimum supported version of WooCommerce.
|
322 |
+
$this->define( 'SS_WC_MAILCHIMP_MIN_WC_VERSION', '2.2.0' );
|
323 |
+
|
324 |
+
// Minimum supported version of PHP.
|
325 |
+
$this->define( 'SS_WC_MAILCHIMP_MIN_PHP_VERSION', '5.4.0' );
|
326 |
+
|
327 |
+
// Plugin version.
|
328 |
+
$this->define( 'SS_WC_MAILCHIMP_VERSION', self::version() );
|
329 |
+
|
330 |
+
// Plugin Folder Path.
|
331 |
+
$this->define( 'SS_WC_MAILCHIMP_DIR', plugin_dir_path( SS_WC_MAILCHIMP_FILE ) );
|
332 |
+
|
333 |
+
// Plugin Folder URL.
|
334 |
+
$this->define( 'SS_WC_MAILCHIMP_URL', plugin_dir_url( SS_WC_MAILCHIMP_FILE ) );
|
335 |
+
|
336 |
+
$settings_url = admin_url( 'admin.php?page=wc-settings&tab=mailchimp' );
|
337 |
+
|
338 |
+
$this->define( 'SS_WC_MAILCHIMP_SETTINGS_URL', $settings_url );
|
339 |
+
|
340 |
+
} //function define_constants
|
341 |
+
|
342 |
+
/**
|
343 |
+
* Define constant if not already set.
|
344 |
+
*
|
345 |
+
* @param string $name Constant name.
|
346 |
+
* @param string|bool $value Constant value.
|
347 |
+
* @return void
|
348 |
+
*/
|
349 |
+
private function define( $name, $value ) {
|
350 |
+
if ( ! defined( $name ) ) {
|
351 |
+
define( $name, $value );
|
352 |
+
}
|
353 |
+
} //function define
|
354 |
+
|
355 |
+
/**
|
356 |
+
* Include required core plugin files
|
357 |
+
*
|
358 |
+
* @return void
|
359 |
+
*/
|
360 |
+
public function includes() {
|
361 |
+
|
362 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/lib/class-ss-system-info.php' );
|
363 |
+
|
364 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/helper-functions.php' );
|
365 |
+
|
366 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp-compatibility.php' );
|
367 |
+
|
368 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp-admin-notices.php' );
|
369 |
+
|
370 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp-api.php' );
|
371 |
+
|
372 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp.php' );
|
373 |
+
|
374 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp-handler.php' );
|
375 |
+
|
376 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-sswcmc-logger.php' );
|
377 |
+
|
378 |
+
} //end function includes
|
379 |
+
|
380 |
+
/**
|
381 |
+
* Add plugin hooks
|
382 |
+
*
|
383 |
+
* @return void
|
384 |
+
*/
|
385 |
+
private function add_hooks() {
|
386 |
+
|
387 |
+
/** Register hooks that are fired when the plugin is activated and deactivated. */
|
388 |
+
register_activation_hook( SS_WC_MAILCHIMP_FILE, array( __CLASS__, 'activate' ) );
|
389 |
+
register_deactivation_hook( SS_WC_MAILCHIMP_FILE, array( __CLASS__, 'deactivate' ) );
|
390 |
+
|
391 |
+
// Add the "Settings" links on the Plugins administration screen.
|
392 |
+
if ( is_admin() ) {
|
393 |
+
|
394 |
+
add_filter( 'plugin_action_links_' . plugin_basename( SS_WC_MAILCHIMP_FILE ), array( $this, 'action_links' ) );
|
395 |
+
|
396 |
+
//add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
|
397 |
+
|
398 |
+
add_filter( 'woocommerce_get_settings_pages', array( $this, 'add_mailchimp_settings' ) );
|
399 |
+
|
400 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
401 |
+
|
402 |
+
add_action( 'admin_init', array( $this, 'process_actions' ) );
|
403 |
+
|
404 |
+
}
|
405 |
+
|
406 |
+
} //end function add_hooks
|
407 |
+
|
408 |
+
/**
|
409 |
+
* Load Localization files.
|
410 |
+
*
|
411 |
+
* Note: the first-loaded translation file overrides any following ones if the same translation is present.
|
412 |
+
*
|
413 |
+
* Locales found in:
|
414 |
+
* - WP_LANG_DIR/plugins/woocommerce-mailchimp/woocommerce-mailchimp-{lang}_{country}.mo
|
415 |
+
* - WP_CONTENT_DIR/plugins/woocommerce-mailchimp/languages/woocommerce-mailchimp-{lang}_{country}.mo
|
416 |
+
*
|
417 |
+
* @return void
|
418 |
+
*/
|
419 |
+
public function load_plugin_textdomain() {
|
420 |
+
|
421 |
+
// Set filter for plugin's languages directory.
|
422 |
+
$woocommerce_mailchimp_lang_dir = dirname( plugin_basename( SS_WC_MAILCHIMP_FILE ) ) . '/languages/';
|
423 |
+
|
424 |
+
// Traditional WordPress plugin locale filter.
|
425 |
+
// get locale in {lang}_{country} format (e.g. en_US).
|
426 |
+
$locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-mailchimp' );
|
427 |
+
|
428 |
+
$mofile = sprintf( '%1$s-%2$s.mo', 'woocommerce-mailchimp', $locale );
|
429 |
+
|
430 |
+
// Look for wp-content/languages/woocommerce-mailchimp/woocommerce-mailchimp-{lang}_{country}.mo
|
431 |
+
$mofile_global1 = WP_LANG_DIR . '/woocommerce-mailchimp/' . $mofile;
|
432 |
+
|
433 |
+
// Look in wp-content/languages/plugins/woocommerce-mailchimp
|
434 |
+
$mofile_global2 = WP_LANG_DIR . '/plugins/woocommerce-mailchimp/' . $mofile;
|
435 |
+
|
436 |
+
if ( file_exists( $mofile_global1 ) ) {
|
437 |
+
|
438 |
+
load_textdomain( 'woocommerce-mailchimp', $mofile_global1 );
|
439 |
+
|
440 |
+
} elseif ( file_exists( $mofile_global2 ) ) {
|
441 |
+
|
442 |
+
load_textdomain( 'woocommerce-mailchimp', $mofile_global2 );
|
443 |
+
|
444 |
+
} else {
|
445 |
+
|
446 |
+
// Load the default language files.
|
447 |
+
load_plugin_textdomain( 'woocommerce-mailchimp', false, $woocommerce_mailchimp_lang_dir );
|
448 |
+
|
449 |
+
}
|
450 |
+
|
451 |
+
} //end function load_plugin_textdomain
|
452 |
+
|
453 |
+
/**
|
454 |
+
* Add Settings link to plugins list
|
455 |
+
*
|
456 |
+
* @param array $links Plugin links.
|
457 |
+
* @return array Modified plugin links
|
458 |
+
*/
|
459 |
+
public function action_links( $links ) {
|
460 |
+
$plugin_links = array(
|
461 |
+
'<a href="' . SS_WC_MAILCHIMP_SETTINGS_URL . '">' . __( 'Settings', 'woocommerce-mailchimp' ) . '</a>',
|
462 |
+
);
|
463 |
+
|
464 |
+
return array_merge( $plugin_links, $links );
|
465 |
+
|
466 |
+
} //end function action_links
|
467 |
+
|
468 |
+
/**
|
469 |
+
* Show row meta on the plugin screen.
|
470 |
+
*
|
471 |
+
* @param mixed $links Plugin Row Meta.
|
472 |
+
* @param mixed $file Plugin Base file.
|
473 |
+
*
|
474 |
+
* @return array
|
475 |
+
*/
|
476 |
+
public static function plugin_row_meta( $links, $file ) {
|
477 |
+
if ( plugin_basename( SS_WC_MAILCHIMP_FILE ) === $file ) {
|
478 |
+
$row_meta = array(
|
479 |
+
'docs' => '<a href="' . esc_url( apply_filters( 'ss_wc_mailchimp_docs_url', 'https://docs.woocommerce.com/documentation/plugins/woocommerce/' ) ) . '" aria-label="' . esc_attr__( 'View WooCommerce MailChimp documentation', 'woocommerce-mailchimp' ) . '">' . esc_html__( 'Documentation', 'woocommerce-mailchimp' ) . '</a>',
|
480 |
+
);
|
481 |
+
|
482 |
+
if ( ! function_exists( 'SSWCMCPRO' ) ) {
|
483 |
+
$row_meta[] = array(
|
484 |
+
'support' => '<a href="' . esc_url( apply_filters( 'ss_wc_mailchimp_support_url', 'https://www.saintsystems.com/products/woocommerce-mailchimp-pro/#utm_source=wp-plugin&utm_medium=woocommerce-mailchimp&utm_campaign=plugins-upgrade-link' ) ) . '" aria-label="' . esc_attr__( 'Upgrade to WooCommerce MailChimp Pro', 'woocommerce-mailchimp' ) . '" target="_blank">' . esc_html__( 'Upgrade to Pro', 'woocommerce-mailchimp' ) . '</a>',
|
485 |
+
);
|
486 |
+
}
|
487 |
+
|
488 |
+
return array_merge( $row_meta, $links );
|
489 |
+
}
|
490 |
+
|
491 |
+
return (array) $links;
|
492 |
+
}
|
493 |
+
|
494 |
+
/**
|
495 |
+
* Add the MailChimp settings tab to WooCommerce
|
496 |
+
*
|
497 |
+
* @param array $settings MailChimp settings.
|
498 |
+
* @return array Settings.
|
499 |
+
*/
|
500 |
+
function add_mailchimp_settings( $settings ) {
|
501 |
+
|
502 |
+
if ( ! is_array( $settings ) ) {
|
503 |
+
$settings = array();
|
504 |
+
}
|
505 |
+
|
506 |
+
$settings[] = require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-settings-mailchimp.php' );
|
507 |
+
|
508 |
+
return $settings;
|
509 |
+
|
510 |
+
} //end function add_mailchimp_settings
|
511 |
+
|
512 |
+
/**
|
513 |
+
* Load scripts required for admin
|
514 |
+
*
|
515 |
+
* @access public
|
516 |
+
* @return void
|
517 |
+
*/
|
518 |
+
public function enqueue_scripts() {
|
519 |
+
|
520 |
+
// Plugin scripts and styles.
|
521 |
+
wp_register_script( 'woocommerce-mailchimp-admin', SS_WC_MAILCHIMP_URL . 'assets/js/woocommerce-mailchimp-admin.js', array( 'jquery' ), self::version() );
|
522 |
+
wp_register_style( 'woocommerce-mailchimp', SS_WC_MAILCHIMP_URL . 'assets/css/style.css', array(), self::version() );
|
523 |
+
|
524 |
+
// Localize javascript messages.
|
525 |
+
$translation_array = array(
|
526 |
+
'connecting_to_mailchimp' => __( 'Connecting to MailChimp', 'woocommerce-mailchimp' ),
|
527 |
+
'error_loading_account' => __( 'Error. Please check your api key.', 'woocommerce-mailchimp' ),
|
528 |
+
'error_loading_groups' => __( 'Error loading groups. Please check your MailChimp Interest Groups for the selected list.', 'woocommerce-mailchimp' ),
|
529 |
+
'select_groups_placeholder' => __( 'Select one or more groups (optional)', 'woocommerce-mailchimp' ),
|
530 |
+
'interest_groups_not_enabled' => __( 'This list does not have interest groups enabled', 'woocommerce-mailchimp' ),
|
531 |
+
);
|
532 |
+
wp_localize_script( 'woocommerce-mailchimp-admin', 'SS_WC_MailChimp_Messages', $translation_array );
|
533 |
+
|
534 |
+
// Scripts.
|
535 |
+
wp_enqueue_script( 'woocommerce-mailchimp-admin' );
|
536 |
+
|
537 |
+
// Styles.
|
538 |
+
wp_enqueue_style( 'woocommerce-mailchimp' );
|
539 |
+
|
540 |
+
} //end function enqueue_scripts
|
541 |
+
|
542 |
+
/**
|
543 |
+
* Processes all SSWCMC actions sent via POST and GET by looking for the 'sswcmc-action'
|
544 |
+
* request and running do_action() to call the function
|
545 |
+
*
|
546 |
+
* @since 2.1.15
|
547 |
+
* @access public
|
548 |
+
* @return void
|
549 |
+
*/
|
550 |
+
public function process_actions() {
|
551 |
+
if ( isset( $_POST['sswcmc-action'] ) ) {
|
552 |
+
do_action( 'sswcmc_' . $_POST['sswcmc-action'], $_POST );
|
553 |
+
}
|
554 |
+
|
555 |
+
if ( isset( $_GET['sswcmc-action'] ) ) {
|
556 |
+
do_action( 'sswcmc_' . $_GET['sswcmc-action'], $_GET );
|
557 |
+
}
|
558 |
+
}
|
559 |
+
|
560 |
+
/**
|
561 |
+
* Handles running plugin upgrades if necessary
|
562 |
+
*
|
563 |
+
* @return void
|
564 |
+
*/
|
565 |
+
public static function update() {
|
566 |
+
|
567 |
+
require_once( 'class-ss-wc-mailchimp-migrator.php' );
|
568 |
+
|
569 |
+
SS_WC_MailChimp_Migrator::migrate( self::version() );
|
570 |
+
|
571 |
+
} //end function update
|
572 |
+
|
573 |
+
/**
|
574 |
+
* Plugin activate function.
|
575 |
+
*
|
576 |
+
* @access public
|
577 |
+
* @static
|
578 |
+
* @param mixed $network_wide Network activate.
|
579 |
+
* @return void
|
580 |
+
*/
|
581 |
+
public static function activate( $network_wide = false ) {
|
582 |
+
|
583 |
+
self::update();
|
584 |
+
|
585 |
+
} //end function activate
|
586 |
+
|
587 |
+
/**
|
588 |
+
* Plugin deactivate function.
|
589 |
+
*
|
590 |
+
* @access public
|
591 |
+
* @static
|
592 |
+
* @param mixed $network_wide Network activate.
|
593 |
+
* @return void
|
594 |
+
*/
|
595 |
+
public static function deactivate( $network_wide ) {
|
596 |
+
|
597 |
+
// Placeholder.
|
598 |
+
|
599 |
+
} //end function deactivate
|
600 |
+
|
601 |
+
/**
|
602 |
+
* Check whether WooCommerce MailChimp is network activated
|
603 |
+
*
|
604 |
+
* @since 1.0
|
605 |
+
* @return bool
|
606 |
+
*/
|
607 |
+
public static function is_network_activated() {
|
608 |
+
return is_multisite() && ( function_exists( 'is_plugin_active_for_network' ) && is_plugin_active_for_network( 'woocommerce-mailchimp/woocommerce-mailchimp.php' ) );
|
609 |
+
}
|
610 |
+
|
611 |
+
/**
|
612 |
+
* Returns namespace prefixed value
|
613 |
+
*
|
614 |
+
* @param string $suffix The suffix to prefix.
|
615 |
+
* @return string
|
616 |
+
*/
|
617 |
+
private function namespace_prefixed( $suffix ) {
|
618 |
+
|
619 |
+
return $this->namespace . '_' . $suffix;
|
620 |
+
|
621 |
+
} // end function namespace_prefixed
|
622 |
+
|
623 |
+
} //end final class SS_WC_MailChimp_Plugin
|
trunk/includes/class-ss-wc-mailchimp.php
ADDED
@@ -0,0 +1,401 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Minimal MailChimp helper
|
7 |
+
*
|
8 |
+
* @class SS_WC_MailChimp
|
9 |
+
* @version 2.0
|
10 |
+
* @package WooCommerce MailChimp
|
11 |
+
* @author Saint Systems
|
12 |
+
*/
|
13 |
+
class SS_WC_MailChimp {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @var SS_WC_MailChimp_API
|
17 |
+
*/
|
18 |
+
public $api;
|
19 |
+
|
20 |
+
public $api_key;
|
21 |
+
|
22 |
+
public $debug;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Create a new instance
|
26 |
+
* @param string $api_key MailChimp API key
|
27 |
+
*/
|
28 |
+
function __construct( $api_key, $debug = false ) {
|
29 |
+
|
30 |
+
$this->api_key = $api_key;
|
31 |
+
|
32 |
+
$this->debug = $debug;
|
33 |
+
|
34 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp-api.php' );
|
35 |
+
$this->api = new SS_WC_MailChimp_API( $api_key, $debug );
|
36 |
+
|
37 |
+
} //end function __construct
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Get account
|
41 |
+
*
|
42 |
+
* @access public
|
43 |
+
* @return mixed
|
44 |
+
*/
|
45 |
+
public function get_account( $api_key = null ) {
|
46 |
+
|
47 |
+
$resource = '';
|
48 |
+
|
49 |
+
$api = $this->api;
|
50 |
+
|
51 |
+
if ( ! empty( $api_key ) ) {
|
52 |
+
$api = new SS_WC_MailChimp_API( $api_key, $this->debug );
|
53 |
+
}
|
54 |
+
|
55 |
+
$account = $api->get( $resource );
|
56 |
+
|
57 |
+
if ( ! $account ) {
|
58 |
+
$last_response = $api->get_last_response();
|
59 |
+
if (floor( $last_response['response']['code'] ) / 100 >= 4) {
|
60 |
+
$body = $last_response['body'];
|
61 |
+
$errorMessage = $last_response['response']['code'] . ' ' . $last_response['response']['message'];
|
62 |
+
if (preg_match("'<h1>(.*)</h1>'si", $body, $matches)) {
|
63 |
+
$errorMessage .= '<br/>' . $matches[1] . ': ';
|
64 |
+
}
|
65 |
+
if (preg_match("'<p>(.*)</p>'si", $body, $matches)) {
|
66 |
+
$errorMessage .= $matches[1];
|
67 |
+
}
|
68 |
+
return array(
|
69 |
+
'error' => $errorMessage
|
70 |
+
);
|
71 |
+
}
|
72 |
+
return false;
|
73 |
+
}
|
74 |
+
|
75 |
+
do_action( 'sswcmc_log', __METHOD__ . ' Mailchimp Account Retrieved: ' . print_r( $account, true ) );
|
76 |
+
|
77 |
+
return $account;
|
78 |
+
|
79 |
+
} //end function get_account
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Get list
|
83 |
+
*
|
84 |
+
* @access public
|
85 |
+
* @return mixed
|
86 |
+
*/
|
87 |
+
public function get_lists( $args = array() ) {
|
88 |
+
|
89 |
+
if ( ! $results = get_transient( 'sswcmc_lists' ) ) {
|
90 |
+
|
91 |
+
$resource = 'lists';
|
92 |
+
|
93 |
+
if ( ! array_key_exists( 'count', $args ) ) {
|
94 |
+
$args['count'] = 100;
|
95 |
+
}
|
96 |
+
|
97 |
+
$response = $this->api->get( $resource, $args );
|
98 |
+
|
99 |
+
if ( ! $response ) {
|
100 |
+
return false;
|
101 |
+
}
|
102 |
+
|
103 |
+
$lists = $response['lists'];
|
104 |
+
|
105 |
+
$results = array();
|
106 |
+
|
107 |
+
foreach ( $lists as $list ) {
|
108 |
+
|
109 |
+
$results[ (string)$list['id'] ] = $list['name'];
|
110 |
+
|
111 |
+
}
|
112 |
+
|
113 |
+
set_transient( 'sswcmc_lists', $results, 60*15*1 );
|
114 |
+
|
115 |
+
}
|
116 |
+
|
117 |
+
return $results;
|
118 |
+
|
119 |
+
} //end function get_lists
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Get Subscriber
|
123 |
+
* @param string $list_id The MailChimp list ID
|
124 |
+
* @param string $email_address The user's email address
|
125 |
+
* @return string The status of the subscriber
|
126 |
+
*/
|
127 |
+
public function get_subscriber_status( $list_id, $email_address ) {
|
128 |
+
|
129 |
+
$subscriber_hash = $this->get_subscriber_hash( $email_address );
|
130 |
+
|
131 |
+
$resource = "lists/$list_id/members/$subscriber_hash";
|
132 |
+
|
133 |
+
$response = $this->api->get( $resource, array() );
|
134 |
+
|
135 |
+
if ( ! $response ) {
|
136 |
+
return false;
|
137 |
+
}
|
138 |
+
|
139 |
+
return $response['status'];
|
140 |
+
|
141 |
+
} //end function get_subscriber_status
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Subscribe the user to the list
|
145 |
+
* @param string $list_id The MailChimp list ID
|
146 |
+
* @param string $email_address The user's email address
|
147 |
+
* @param string $email_type html|text
|
148 |
+
* @param array $merge_fields Array of MailChimp Merge Tags
|
149 |
+
* @param array $interests Array of MailChimp Interest Groups
|
150 |
+
* @param boolean $double_opt_in Whether to send a double opt-in email to confirm subscription
|
151 |
+
* @return mixed $response The MailChimp API response
|
152 |
+
*/
|
153 |
+
public function subscribe( $list_id, $email_address, $email_type, $merge_fields, $interests, $double_opt_in ) {
|
154 |
+
|
155 |
+
$args = array(
|
156 |
+
'email_address' => $email_address,
|
157 |
+
'status' => $double_opt_in ? 'pending' : 'subscribed',
|
158 |
+
'email_type' => $email_type,
|
159 |
+
'merge_fields' => $merge_fields,
|
160 |
+
);
|
161 |
+
|
162 |
+
if ( is_array( $interests ) && !empty( $interests ) ) {
|
163 |
+
$args['interests'] = $interests;
|
164 |
+
}
|
165 |
+
|
166 |
+
$subscriber_status = $this->get_subscriber_status( $list_id, $email_address );
|
167 |
+
|
168 |
+
// If user is already subscribed or unsubscribed, set their status to 'subscribed' (and bypass the double opt-in email)
|
169 |
+
if ( 'subscribed' === $subscriber_status || 'unsubscribed' === $subscriber_status ) {
|
170 |
+
$args['status'] = 'subscribed';
|
171 |
+
}
|
172 |
+
|
173 |
+
$subscriber_hash = $this->get_subscriber_hash( $email_address );
|
174 |
+
|
175 |
+
$resource = "lists/$list_id/members/$subscriber_hash";
|
176 |
+
|
177 |
+
$response = $this->api->put( $resource, $args );
|
178 |
+
|
179 |
+
if ( ! $response ) {
|
180 |
+
return false;
|
181 |
+
}
|
182 |
+
|
183 |
+
return $response;
|
184 |
+
|
185 |
+
} //end function subscribe
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Unsubscribe the user from the list
|
189 |
+
* @param string $list_id The MailChimp list ID
|
190 |
+
* @param string $email_address The user's email address
|
191 |
+
* @return mixed $response The MailChimp API response
|
192 |
+
*/
|
193 |
+
public function unsubscribe( $list_id, $email_address ) {
|
194 |
+
|
195 |
+
$args = array(
|
196 |
+
'status' => 'unsubscribed',
|
197 |
+
);
|
198 |
+
|
199 |
+
if ( ! $subscriber_status = $this->get_subscriber_status( $list_id, $email_address ) ) {
|
200 |
+
return false;
|
201 |
+
}
|
202 |
+
|
203 |
+
$subscriber_hash = $this->get_subscriber_hash( $email_address );
|
204 |
+
|
205 |
+
$resource = "lists/$list_id/members/$subscriber_hash";
|
206 |
+
|
207 |
+
$response = $this->api->put( $resource, $args );
|
208 |
+
|
209 |
+
if ( ! $response ) {
|
210 |
+
return false;
|
211 |
+
}
|
212 |
+
|
213 |
+
return $response;
|
214 |
+
|
215 |
+
} //end function subscribe
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Returns the MD5 hash of the email
|
219 |
+
* @param string $email_address The email address to hash
|
220 |
+
* @return string MD5 hash of the lower-cased email address
|
221 |
+
*/
|
222 |
+
public function get_subscriber_hash( $email_address ) {
|
223 |
+
|
224 |
+
return md5( strtolower( $email_address ) );
|
225 |
+
|
226 |
+
} //end function get_subscriber_hash
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Get merge fields
|
230 |
+
*
|
231 |
+
* @access public
|
232 |
+
* @param string $list_id
|
233 |
+
* @return mixed
|
234 |
+
*/
|
235 |
+
public function get_merge_fields( $list_id ) {
|
236 |
+
|
237 |
+
if ( ! $results = get_transient( "sswcmc_{$list_id}_merge_fields" ) ) {
|
238 |
+
|
239 |
+
$resource = "lists/$list_id/merge-fields";
|
240 |
+
|
241 |
+
$response = $this->api->get( $resource );
|
242 |
+
|
243 |
+
if ( ! $response ) {
|
244 |
+
return false;
|
245 |
+
}
|
246 |
+
|
247 |
+
$merge_fields = $response['merge_fields'];
|
248 |
+
|
249 |
+
$results = array();
|
250 |
+
|
251 |
+
foreach ( $merge_fields as $merge_field ) {
|
252 |
+
|
253 |
+
$results[ $merge_field['tag'] ] = array(
|
254 |
+
'name' => sprintf( '%s (%s)', $merge_field['name'], $merge_field['tag'] ),
|
255 |
+
'required' => $merge_field['required'],
|
256 |
+
);
|
257 |
+
|
258 |
+
}
|
259 |
+
|
260 |
+
// Cache list merge tags for 15 minutes
|
261 |
+
set_transient( "sswcmc_{$list_id}_merge_fields", $results, 60*15*1 );
|
262 |
+
|
263 |
+
}
|
264 |
+
|
265 |
+
return $results;
|
266 |
+
|
267 |
+
} //end function get_merge_fields
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Get interest categories
|
271 |
+
*
|
272 |
+
* @access public
|
273 |
+
* @param string $list_id
|
274 |
+
* @return mixed
|
275 |
+
*/
|
276 |
+
public function get_interest_categories( $list_id ) {
|
277 |
+
|
278 |
+
if ( ! $results = get_transient( "sswcmc_{$list_id}_interest_categories" ) ) {
|
279 |
+
|
280 |
+
$resource = "lists/$list_id/interest-categories";
|
281 |
+
|
282 |
+
$response = $this->api->get( $resource, array( 'count' => 100 ) );
|
283 |
+
|
284 |
+
if ( ! $response ) {
|
285 |
+
return false;
|
286 |
+
}
|
287 |
+
|
288 |
+
$categories = $response['categories'];
|
289 |
+
|
290 |
+
$results = array();
|
291 |
+
|
292 |
+
foreach ( $categories as $category ) {
|
293 |
+
|
294 |
+
$results[ $category['id'] ] = $category['title'];
|
295 |
+
|
296 |
+
}
|
297 |
+
|
298 |
+
set_transient( "sswcmc_{$list_id}_interest_categories", $results, 60*15*1 );
|
299 |
+
|
300 |
+
}
|
301 |
+
|
302 |
+
return $results;
|
303 |
+
|
304 |
+
} //end function get_interest_categories
|
305 |
+
|
306 |
+
/**
|
307 |
+
* Get interest category interests
|
308 |
+
*
|
309 |
+
* @access public
|
310 |
+
* @param string $list_id
|
311 |
+
* * @param string $interest_category_id
|
312 |
+
* @return mixed
|
313 |
+
*/
|
314 |
+
public function get_interest_category_interests( $list_id, $interest_category_id ) {
|
315 |
+
|
316 |
+
if ( ! $results = get_transient( "sswcmc_{$list_id}_{$interest_category_id }_interests" ) ) {
|
317 |
+
|
318 |
+
$resource = "lists/$list_id/interest-categories/$interest_category_id/interests";
|
319 |
+
|
320 |
+
$response = $this->api->get( $resource, array( 'count' => 100 ) );
|
321 |
+
|
322 |
+
if ( ! $response ) {
|
323 |
+
return false;
|
324 |
+
}
|
325 |
+
|
326 |
+
$interests = $response['interests'];
|
327 |
+
|
328 |
+
$results = array();
|
329 |
+
|
330 |
+
foreach ( $interests as $interest ) {
|
331 |
+
|
332 |
+
$results[ $interest['id'] ] = $interest['name'];
|
333 |
+
|
334 |
+
}
|
335 |
+
|
336 |
+
set_transient( "sswcmc_{$list_id}_{$interest_category_id }_interests", $results, 60*15*1 );
|
337 |
+
|
338 |
+
}
|
339 |
+
|
340 |
+
return $results;
|
341 |
+
|
342 |
+
} //end function get_interest_category_interests
|
343 |
+
|
344 |
+
/**
|
345 |
+
* Get interest categories with interests
|
346 |
+
*
|
347 |
+
* @access public
|
348 |
+
* @param string $list_id
|
349 |
+
* @return mixed
|
350 |
+
*/
|
351 |
+
public function get_interest_categories_with_interests( $list_id ) {
|
352 |
+
|
353 |
+
$categories = $this->get_interest_categories( $list_id );
|
354 |
+
|
355 |
+
if ( ! $categories ) {
|
356 |
+
return false;
|
357 |
+
}
|
358 |
+
|
359 |
+
$results = array();
|
360 |
+
|
361 |
+
foreach ( $categories as $category_id => $category ) {
|
362 |
+
|
363 |
+
$interests = $this->get_interest_category_interests( $list_id, $category_id );
|
364 |
+
|
365 |
+
if ( ! $interests ) {
|
366 |
+
return false;
|
367 |
+
}
|
368 |
+
|
369 |
+
foreach ( $interests as $interest_id => $interest ) {
|
370 |
+
|
371 |
+
$results[ $interest_id ] = $category . ': ' . $interest;
|
372 |
+
|
373 |
+
}
|
374 |
+
|
375 |
+
}
|
376 |
+
|
377 |
+
return $results;
|
378 |
+
|
379 |
+
} //end function get_interest_categories_with_interests
|
380 |
+
|
381 |
+
/**
|
382 |
+
* Returns error code from error property
|
383 |
+
* @return string error code
|
384 |
+
*/
|
385 |
+
public function get_error_code() {
|
386 |
+
|
387 |
+
return $this->api->get_error_code();
|
388 |
+
|
389 |
+
} //end get_error_code
|
390 |
+
|
391 |
+
/**
|
392 |
+
* Returns error message from error property
|
393 |
+
* @return string error message
|
394 |
+
*/
|
395 |
+
public function get_error_message() {
|
396 |
+
|
397 |
+
return $this->api->get_error_message();
|
398 |
+
|
399 |
+
} //end get_error_message
|
400 |
+
|
401 |
+
} //end class SS_WC_MailChimp
|
trunk/includes/class-ss-wc-settings-mailchimp.php
ADDED
@@ -0,0 +1,706 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WooCommerce MailChimp Settings
|
4 |
+
*
|
5 |
+
* @author Saint Systems
|
6 |
+
* @package WooCommerce MailChimp
|
7 |
+
* @version 2.0
|
8 |
+
*/
|
9 |
+
|
10 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
11 |
+
|
12 |
+
if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @class SS_WC_Settings_MailChimp
|
16 |
+
* @extends WC_Settings_Page
|
17 |
+
*/
|
18 |
+
class SS_WC_Settings_MailChimp extends WC_Settings_Page {
|
19 |
+
|
20 |
+
private static $instance;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Singleton instance
|
24 |
+
*
|
25 |
+
* @return SS_WC_Settings_MailChimp SS_WC_Settings_MailChimp object
|
26 |
+
*/
|
27 |
+
public static function get_instance() {
|
28 |
+
|
29 |
+
if ( empty( self::$instance ) ) {
|
30 |
+
self::$instance = new self;
|
31 |
+
}
|
32 |
+
|
33 |
+
return self::$instance;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Constructor
|
38 |
+
*
|
39 |
+
* @access public
|
40 |
+
* @return void
|
41 |
+
*/
|
42 |
+
public function __construct() {
|
43 |
+
|
44 |
+
$this->id = 'mailchimp';
|
45 |
+
$this->namespace = 'ss_wc_' . $this->id;
|
46 |
+
$this->label = __( 'MailChimp', 'woocommerce-mailchimp' );
|
47 |
+
$this->init();
|
48 |
+
|
49 |
+
$this->register_hooks();
|
50 |
+
|
51 |
+
} //end function __construct
|
52 |
+
|
53 |
+
/**
|
54 |
+
* api_key function.
|
55 |
+
* @return string MailChimp API Key
|
56 |
+
*/
|
57 |
+
public function api_key() {
|
58 |
+
return $this->get_option( 'api_key' );
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* is_enabled function.
|
63 |
+
*
|
64 |
+
* @access public
|
65 |
+
* @return boolean
|
66 |
+
*/
|
67 |
+
public function is_enabled() {
|
68 |
+
return 'yes' === $this->get_option( 'enabled' );
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* occurs function
|
73 |
+
* @return string
|
74 |
+
*/
|
75 |
+
public function occurs() {
|
76 |
+
return $this->get_option( 'occurs' );
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* get_list function.
|
81 |
+
*
|
82 |
+
* @access public
|
83 |
+
* @return string MailChimp list ID
|
84 |
+
*/
|
85 |
+
public function get_list() {
|
86 |
+
return $this->get_option( 'list' );
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* double_opt_in function.
|
91 |
+
*
|
92 |
+
* @access public
|
93 |
+
* @return boolean
|
94 |
+
*/
|
95 |
+
public function double_opt_in() {
|
96 |
+
return 'yes' === $this->get_option( 'double_opt_in' );
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* display_opt_in function.
|
101 |
+
*
|
102 |
+
* @access public
|
103 |
+
* @return boolean
|
104 |
+
*/
|
105 |
+
public function display_opt_in() {
|
106 |
+
return 'yes' === $this->get_option( 'display_opt_in' );
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* opt_in_label function.
|
111 |
+
*
|
112 |
+
* @access public
|
113 |
+
* @return string
|
114 |
+
*/
|
115 |
+
public function opt_in_label() {
|
116 |
+
return $this->get_option( 'opt_in_label' );
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* opt_in_checkbox_default_status function.
|
121 |
+
*
|
122 |
+
* @access public
|
123 |
+
* @return string
|
124 |
+
*/
|
125 |
+
public function opt_in_checkbox_default_status() {
|
126 |
+
return $this->get_option( 'opt_in_checkbox_default_status' );
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* opt_in_checkbox_display_location function.
|
131 |
+
*
|
132 |
+
* @access public
|
133 |
+
* @return string
|
134 |
+
*/
|
135 |
+
public function opt_in_checkbox_display_location() {
|
136 |
+
return $this->get_option( 'opt_in_checkbox_display_location' );
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* interests function.
|
141 |
+
*
|
142 |
+
* @access public
|
143 |
+
* @return array
|
144 |
+
*/
|
145 |
+
public function interest_groups() {
|
146 |
+
return $this->get_option( 'interest_groups' );
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* has_list function.
|
151 |
+
*
|
152 |
+
* @access public
|
153 |
+
* @return boolean
|
154 |
+
*/
|
155 |
+
public function has_list() {
|
156 |
+
if ( $this->get_list() ) {
|
157 |
+
return true;
|
158 |
+
}
|
159 |
+
return false;
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* has_api_key function.
|
164 |
+
*
|
165 |
+
* @access public
|
166 |
+
* @return boolean
|
167 |
+
*/
|
168 |
+
public function has_api_key() {
|
169 |
+
$api_key = $this->api_key();
|
170 |
+
return !empty( $api_key );
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* is_valid function.
|
175 |
+
*
|
176 |
+
* @access public
|
177 |
+
* @return boolean
|
178 |
+
*/
|
179 |
+
public function is_valid() {
|
180 |
+
return $this->is_enabled() && $this->has_api_key() && $this->has_list();
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* debug_enabled function.
|
185 |
+
*
|
186 |
+
* @access public
|
187 |
+
* @return boolean
|
188 |
+
*/
|
189 |
+
public function debug_enabled() {
|
190 |
+
return 'yes' === $this->get_option( 'debug' );
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Check if the user has enabled the plugin functionality, but hasn't provided an api key
|
195 |
+
**/
|
196 |
+
function checks() {
|
197 |
+
// Check required fields
|
198 |
+
if ( $this->is_enabled() && ! $this->has_api_key() ) {
|
199 |
+
// Show notice
|
200 |
+
echo $this->get_message( sprintf( __( 'WooCommerce MailChimp error: Plugin is enabled but no api key provided. Please enter your api key <a href="%s">here</a>.', 'woocommerce-mailchimp' ), SS_WC_MAILCHIMP_SETTINGS_URL )
|
201 |
+
);
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
public function init() {
|
206 |
+
|
207 |
+
$this->api_key = $this->get_option( 'api_key' );
|
208 |
+
|
209 |
+
$this->enabled = $this->get_option( 'enabled' );
|
210 |
+
|
211 |
+
}
|
212 |
+
|
213 |
+
public function get_option( $option_suffix ) {
|
214 |
+
|
215 |
+
return get_option( $this->namespace_prefixed( $option_suffix ) );
|
216 |
+
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Register plugin hooks
|
221 |
+
*
|
222 |
+
* @access public
|
223 |
+
* @return void
|
224 |
+
*/
|
225 |
+
public function register_hooks() {
|
226 |
+
|
227 |
+
// Hook in to add the MailChimp tab
|
228 |
+
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
|
229 |
+
add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
|
230 |
+
add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
|
231 |
+
add_action( 'woocommerce_sections_' . $this->id, array( $this, 'output_sections' ) );
|
232 |
+
add_action( 'woocommerce_settings_saved', array( $this, 'init' ) );
|
233 |
+
|
234 |
+
// Hooks
|
235 |
+
add_action( 'admin_notices', array( $this, 'checks' ) );
|
236 |
+
add_action( 'woocommerce_admin_field_sysinfo', array( $this, 'sysinfo_field' ), 10, 1 );
|
237 |
+
|
238 |
+
} //end function ensure_tab
|
239 |
+
|
240 |
+
// /**
|
241 |
+
// * Get sections
|
242 |
+
// *
|
243 |
+
// * @return array
|
244 |
+
// */
|
245 |
+
public function get_sections() {
|
246 |
+
|
247 |
+
$sections = array();
|
248 |
+
|
249 |
+
$sections[''] = __( 'General', 'woocommerce-mailchimp' );
|
250 |
+
|
251 |
+
if ( $this->has_api_key() ) {
|
252 |
+
$sections['troubleshooting'] = __( 'Troubleshooting', 'woocommerce-mailchimp' );
|
253 |
+
}
|
254 |
+
|
255 |
+
return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections );
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Output the settings
|
260 |
+
*/
|
261 |
+
public function output() {
|
262 |
+
|
263 |
+
global $current_section;
|
264 |
+
|
265 |
+
$settings = $this->get_settings( $current_section );
|
266 |
+
|
267 |
+
WC_Admin_Settings::output_fields( $settings );
|
268 |
+
|
269 |
+
$this->wc_enqueue_js("
|
270 |
+
(function($){
|
271 |
+
|
272 |
+
$(document).ready(function() {
|
273 |
+
SS_WC_MailChimp.init();
|
274 |
+
});
|
275 |
+
|
276 |
+
})(jQuery);
|
277 |
+
");
|
278 |
+
|
279 |
+
do_action( 'ss_wc_mailchimp_after_settings_enqueue_js' );
|
280 |
+
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Save settings
|
285 |
+
*/
|
286 |
+
public function save() {
|
287 |
+
global $current_section;
|
288 |
+
|
289 |
+
$settings = $this->get_settings( $current_section );
|
290 |
+
|
291 |
+
WC_Admin_Settings::save_fields( $settings );
|
292 |
+
|
293 |
+
if ( !isset( $_POST[ 'ss_wc_mailchimp_api_key' ] ) || empty( $_POST[ 'ss_wc_mailchimp_api_key' ] ) ) {
|
294 |
+
delete_transient( 'sswcmc_lists' );
|
295 |
+
}
|
296 |
+
|
297 |
+
$sswcmc = SSWCMC();
|
298 |
+
// Trigger reload of plugin settings
|
299 |
+
$settings = $sswcmc->settings( true );
|
300 |
+
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Get settings array
|
305 |
+
*
|
306 |
+
* @return array
|
307 |
+
*/
|
308 |
+
public function get_settings( $current_section = '' ) {
|
309 |
+
|
310 |
+
$settings = array();
|
311 |
+
|
312 |
+
if ( '' === $current_section ) {
|
313 |
+
|
314 |
+
$settings = array(
|
315 |
+
array(
|
316 |
+
'title' => __( 'MailChimp', 'woocommerce-mailchimp' ),
|
317 |
+
'type' => 'title',
|
318 |
+
'desc' => __( 'Enter your MailChimp settings below to control how WooCommerce integrates with your MailChimp account.', 'woocommerce-mailchimp' ),
|
319 |
+
'id' => 'general_options',
|
320 |
+
),
|
321 |
+
);
|
322 |
+
|
323 |
+
$settings[] = array(
|
324 |
+
'id' => $this->namespace_prefixed( 'api_key' ),
|
325 |
+
'title' => __( 'API Key', 'woocommerce-mailchimp' ),
|
326 |
+
'type' => 'text',
|
327 |
+
'desc' => sprintf( __( '%sLogin to MailChimp%s to look up your api key.', 'woocommerce-mailchimp' ), '<br/><a href="https://admin.mailchimp.com/account/api/" target="_blank">', '</a>'
|
328 |
+
),
|
329 |
+
'placeholder' => __( 'Paste your MailChimp API key here', 'woocommerce-mailchimp' ),
|
330 |
+
'default' => '',
|
331 |
+
'css' => 'min-width:350px;',
|
332 |
+
'desc_tip' => 'Your API Key is required for the plugin to communicate with your MailChimp account.',
|
333 |
+
);
|
334 |
+
|
335 |
+
$settings[] = array(
|
336 |
+
'id' => $this->namespace_prefixed( 'enabled' ),
|
337 |
+
'title' => __( 'Enable/Disable', 'woocommerce-mailchimp' ),
|
338 |
+
'label' => __( 'Enable MailChimp Integration', 'woocommerce-mailchimp' ),
|
339 |
+
'type' => 'checkbox',
|
340 |
+
'desc' => __( 'Enable/disable the plugin functionality.', 'woocommerce-mailchimp' ),
|
341 |
+
'default' => 'yes',
|
342 |
+
);
|
343 |
+
|
344 |
+
$mailchimp_lists = $this->get_lists();
|
345 |
+
|
346 |
+
if ( $this->has_api_key() && $this->has_list() ) {
|
347 |
+
$interest_groups = $this->get_interest_groups();
|
348 |
+
} else {
|
349 |
+
$interest_groups = array();
|
350 |
+
}
|
351 |
+
|
352 |
+
$settings[] = array(
|
353 |
+
'id' => $this->namespace_prefixed( 'list' ),
|
354 |
+
'title' => __( 'Main List', 'woocommerce-mailchimp' ),
|
355 |
+
'type' => 'select',
|
356 |
+
'desc' => __( 'All customers will be added to this list.', 'woocommerce-mailchimp' ),
|
357 |
+
'default' => '',
|
358 |
+
'options' => $mailchimp_lists,
|
359 |
+
'class' => 'wc-enhanced-select',
|
360 |
+
'css' => 'min-width: 350px;',
|
361 |
+
'desc_tip' => true,
|
362 |
+
);
|
363 |
+
|
364 |
+
$settings[] = array(
|
365 |
+
'id' => $this->namespace_prefixed( 'interest_groups' ),
|
366 |
+
'title' => __( 'Interest Groups', 'woocommerce-mailchimp' ),
|
367 |
+
'type' => 'multiselect',
|
368 |
+
'desc' => __( 'Optional: Interest groups to assign to subscribers.', 'woocommerce-mailchimp' ),
|
369 |
+
'default' => '',
|
370 |
+
'options' => $interest_groups,
|
371 |
+
'class' => 'wc-enhanced-select',
|
372 |
+
'custom_attributes' => array(
|
373 |
+
'placeholder' => __( 'Select interest groups...', 'woocommerce-mailchimp' ),
|
374 |
+
),
|
375 |
+
'css' => 'min-width: 350px;',
|
376 |
+
'desc_tip' => true,
|
377 |
+
);
|
378 |
+
|
379 |
+
$settings = apply_filters( $this->namespace_prefixed( 'settings_general_after_interest_groups' ), $settings );
|
380 |
+
|
381 |
+
$settings[] = array(
|
382 |
+
'id' => $this->namespace_prefixed( 'occurs' ),
|
383 |
+
'title' => __( 'Subscribe Event', 'woocommerce-mailchimp' ),
|
384 |
+
'type' => 'select',
|
385 |
+
'desc' => __( 'Choose whether to subscribe customers as soon as an order is placed or after the order is processing or completed.', 'woocommerce-mailchimp' ),
|
386 |
+
'class' => 'wc-enhanced-select',
|
387 |
+
'default' => 'pending',
|
388 |
+
'options' => array(
|
389 |
+
'pending' => __( 'Order Created', 'woocommerce-mailchimp' ),
|
390 |
+
'processing' => __( 'Order Processing', 'woocommerce-mailchimp' ),
|
391 |
+
'completed' => __( 'Order Completed', 'woocommerce-mailchimp' ),
|
392 |
+
),
|
393 |
+
'desc_tip' => true,
|
394 |
+
);
|
395 |
+
|
396 |
+
$settings[] = array(
|
397 |
+
'id' => $this->namespace_prefixed( 'double_opt_in' ),
|
398 |
+
'title' => __( 'Double Opt-In', 'woocommerce-mailchimp' ),
|
399 |
+
'desc' => __( 'Enable Double Opt-In', 'woocommerce-mailchimp' ),
|
400 |
+
'type' => 'checkbox',
|
401 |
+
'default' => 'no',
|
402 |
+
'desc_tip' => __( 'If enabled, customers will receive an email prompting them to confirm their subscription to the list above.', 'woocommerce-mailchimp' ),
|
403 |
+
);
|
404 |
+
|
405 |
+
$settings[] = array(
|
406 |
+
'id' => $this->namespace_prefixed( 'display_opt_in' ),
|
407 |
+
'title' => __( 'Subscribe Customers', 'woocommerce-mailchimp' ),
|
408 |
+
'desc' => __( '<p>Choose <strong>Ask for permission</strong> to show an "Opt-in" checkbox during checkout. Customers will only be subscribed to the list above if they opt-in. <p>Choose <strong>Automatically</strong> to subscribe customers silently upon checkout. Caution, this is without the customer\'s consent.</p>', 'woocommerce-mailchimp' ),
|
409 |
+
'type' => 'select',
|
410 |
+
'css' => 'min-width:300px;',
|
411 |
+
'class' => 'wc-enhanced-select',
|
412 |
+
'desc_tip' => true,
|
413 |
+
'default' => 'yes',
|
414 |
+
'options' => array(
|
415 |
+
// '0' => __( 'Disabled', 'woocommerce-mailchimp' ),
|
416 |
+
'yes' => __( 'Ask for permission', 'woocommerce-mailchimp' ),
|
417 |
+
'no' => __( 'Automatically', 'woocommerce-mailchimp' ),
|
418 |
+
)
|
419 |
+
);
|
420 |
+
|
421 |
+
$settings[] = array(
|
422 |
+
'id' => $this->namespace_prefixed( 'opt_in_label' ),
|
423 |
+
'title' => __( 'Opt-In Field Label', 'woocommerce-mailchimp' ),
|
424 |
+
'type' => 'text',
|
425 |
+
'desc' => __( 'Optional: customize the label displayed next to the opt-in checkbox.', 'woocommerce-mailchimp' ),
|
426 |
+
'default' => __( 'Subscribe to our newsletter', 'woocommerce-mailchimp' ),
|
427 |
+
'css' => 'min-width:350px;',
|
428 |
+
'desc_tip' => true,
|
429 |
+
);
|
430 |
+
|
431 |
+
$settings[] = array(
|
432 |
+
'id' => $this->namespace_prefixed( 'opt_in_checkbox_default_status' ),
|
433 |
+
'title' => __( 'Opt-In Checkbox Default', 'woocommerce-mailchimp' ),
|
434 |
+
'type' => 'select',
|
435 |
+
'desc' => __( 'The default state of the opt-in checkbox.', 'woocommerce-mailchimp' ),
|
436 |
+
'class' => 'wc-enhanced-select',
|
437 |
+
'default' => 'checked',
|
438 |
+
'options' => array(
|
439 |
+
'checked' => __( 'Checked', 'woocommerce-mailchimp' ),
|
440 |
+
'unchecked' => __( 'Unchecked', 'woocommerce-mailchimp' )
|
441 |
+
),
|
442 |
+
'desc_tip' => true,
|
443 |
+
);
|
444 |
+
|
445 |
+
$settings[] = array(
|
446 |
+
'id' => $this->namespace_prefixed( 'opt_in_checkbox_display_location' ),
|
447 |
+
'title' => __( 'Opt-In Checkbox Location', 'woocommerce-mailchimp' ),
|
448 |
+
'type' => 'select',
|
449 |
+
'desc' => __( 'Where to display the opt-in checkbox on the checkout page.', 'woocommerce-mailchimp' ),
|
450 |
+
'class' => 'wc-enhanced-select',
|
451 |
+
'default' => 'woocommerce_review_order_before_submit',
|
452 |
+
'options' => array(
|
453 |
+
'woocommerce_checkout_before_customer_details' => __( 'Above customer details', 'woocommerce-mailchimp' ),
|
454 |
+
'woocommerce_checkout_after_customer_details' => __( 'Below customer details', 'woocommerce-mailchimp' ),
|
455 |
+
'woocommerce_checkout_before_order_review' => __( 'Order review above cart/product table.', 'woocommerce-mailchimp' ),
|
456 |
+
'woocommerce_review_order_before_submit' => __( 'Order review above submit', 'woocommerce-mailchimp' ),
|
457 |
+
'woocommerce_review_order_after_submit' => __( 'Order review below submit', 'woocommerce-mailchimp' ),
|
458 |
+
'woocommerce_review_order_before_order_total' => __( 'Order review above total', 'woocommerce-mailchimp' ),
|
459 |
+
'woocommerce_checkout_billing' => __( 'Above billing details', 'woocommerce-mailchimp' ),
|
460 |
+
'woocommerce_checkout_shipping' => __( 'Above shipping details', 'woocommerce-mailchimp' ),
|
461 |
+
'woocommerce_after_checkout_billing_form' => __( 'Below Checkout billing form', 'woocommerce-mailchimp' ),
|
462 |
+
'woocommerce_checkout_before_terms_and_conditions' => __( 'Above Checkout Terms and Conditions', 'woocommerce-mailchimp' ),
|
463 |
+
'woocommerce_checkout_after_terms_and_conditions' => __( 'Below Checkout Terms and Conditions', 'woocommerce-mailchimp' ),
|
464 |
+
),
|
465 |
+
'desc_tip' => true,
|
466 |
+
);
|
467 |
+
|
468 |
+
$settings = apply_filters( $this->namespace_prefixed( 'settings_general' ), $settings );
|
469 |
+
|
470 |
+
$settings[] = array( 'type' => 'sectionend', 'id' => 'general_options' );
|
471 |
+
|
472 |
+
} elseif ( 'troubleshooting' === $current_section ) {
|
473 |
+
|
474 |
+
$label = __( 'Enable Logging', 'woocommerce-mailchimp' );
|
475 |
+
|
476 |
+
if ( defined( 'WC_LOG_DIR' ) ) {
|
477 |
+
$debug_log_url = add_query_arg( 'tab', 'logs', add_query_arg( 'page', 'wc-status', admin_url( 'admin.php' ) ) );
|
478 |
+
$debug_log_key = 'woocommerce-mailchimp-' . sanitize_file_name( wp_hash( 'woocommerce-mailchimp' ) ) . '-log';
|
479 |
+
$debug_log_url = add_query_arg( 'log_file', $debug_log_key, $debug_log_url );
|
480 |
+
|
481 |
+
$label .= ' | ' . sprintf( __( '%1$sView Log%2$s', 'woocommerce-mailchimp' ), '<a href="' . esc_url( $debug_log_url ) . '">', '</a>' );
|
482 |
+
}
|
483 |
+
|
484 |
+
$settings[] = array(
|
485 |
+
'title' => __( 'Troubleshooting', 'woocommerce-mailchimp' ),
|
486 |
+
'type' => 'title',
|
487 |
+
'desc' => '',
|
488 |
+
'id' => 'troubleshooting_settings'
|
489 |
+
);
|
490 |
+
|
491 |
+
$settings[] = array(
|
492 |
+
'id' => $this->namespace_prefixed( 'debug' ),
|
493 |
+
'title' => __( 'Debug Log', 'woocommerce-mailchimp' ),
|
494 |
+
'desc' => $label,
|
495 |
+
'type' => 'checkbox',
|
496 |
+
'default' => 'no',
|
497 |
+
'desc_tip' => __( 'Enable logging MailChimp API calls. Only enable for troubleshooting purposes.', 'woocommerce-mailchimp' ),
|
498 |
+
);
|
499 |
+
|
500 |
+
$settings[] = array(
|
501 |
+
'id' => 'sysinfo',
|
502 |
+
'title' => __( 'System Info', 'woocommerce-mailchimp' ),
|
503 |
+
'type' => 'sysinfo',
|
504 |
+
'desc' => __( 'Copy the information below and send it to us when reporting an issue with the plugin.', 'woocommerce-mailchimp' ) . '<p/>',
|
505 |
+
'desc_tip' => '',
|
506 |
+
);
|
507 |
+
|
508 |
+
$settings[] = array( 'type' => 'sectionend', 'id' => 'troubleshooting_settings' );
|
509 |
+
|
510 |
+
$settings = apply_filters( $this->namespace_prefixed( 'settings_troubleshooting' ), $settings );
|
511 |
+
|
512 |
+
}
|
513 |
+
|
514 |
+
return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings, $current_section );
|
515 |
+
|
516 |
+
} //end function get_settings
|
517 |
+
|
518 |
+
private function namespace_prefixed( $value ) {
|
519 |
+
return $this->namespace . '_' . $value;
|
520 |
+
}
|
521 |
+
|
522 |
+
/**
|
523 |
+
* WooCommerce 2.1 support for wc_enqueue_js
|
524 |
+
*
|
525 |
+
* @since 1.2.1
|
526 |
+
*
|
527 |
+
* @access private
|
528 |
+
* @param string $code
|
529 |
+
* @return void
|
530 |
+
*/
|
531 |
+
private function wc_enqueue_js( $code ) {
|
532 |
+
if ( function_exists( 'wc_enqueue_js' ) ) {
|
533 |
+
wc_enqueue_js( $code );
|
534 |
+
} else {
|
535 |
+
global $woocommerce;
|
536 |
+
$woocommerce->add_inline_js( $code );
|
537 |
+
}
|
538 |
+
}
|
539 |
+
|
540 |
+
/**
|
541 |
+
* Get message
|
542 |
+
* @return string Error
|
543 |
+
*/
|
544 |
+
private function get_message( $message, $type = 'error' ) {
|
545 |
+
ob_start();
|
546 |
+
|
547 |
+
?>
|
548 |
+
<div class="<?php echo $type ?>">
|
549 |
+
<p><?php echo $message ?></p>
|
550 |
+
</div>
|
551 |
+
<?php
|
552 |
+
return ob_get_clean();
|
553 |
+
}
|
554 |
+
|
555 |
+
/**
|
556 |
+
* API Instance Singleton
|
557 |
+
* @return Object
|
558 |
+
*/
|
559 |
+
public function mailchimp( $api_key = null ) {
|
560 |
+
|
561 |
+
$sswcmc = SSWCMC();
|
562 |
+
|
563 |
+
return $sswcmc->mailchimp( $api_key );
|
564 |
+
|
565 |
+
}
|
566 |
+
|
567 |
+
/**
|
568 |
+
* get_lists function.
|
569 |
+
*
|
570 |
+
* @access public
|
571 |
+
* @return void
|
572 |
+
*/
|
573 |
+
public function get_lists() {
|
574 |
+
|
575 |
+
if ( $this->mailchimp() ) {
|
576 |
+
$mailchimp_lists = $this->mailchimp()->get_lists();
|
577 |
+
} else {
|
578 |
+
return false;
|
579 |
+
}
|
580 |
+
|
581 |
+
if ( $mailchimp_lists === false ) {
|
582 |
+
|
583 |
+
add_action( 'admin_notices', array( $this, 'mailchimp_api_error_msg' ) );
|
584 |
+
add_action( 'network_admin_notices', array( $this, 'mailchimp_api_error_msg' ) );
|
585 |
+
|
586 |
+
return false;
|
587 |
+
|
588 |
+
}
|
589 |
+
|
590 |
+
if ( count( $mailchimp_lists ) === 0 ) {
|
591 |
+
$default = array(
|
592 |
+
'no_lists' => __( 'Oops! No lists in your MailChimp account...', 'woocommerce-mailchimp' ),
|
593 |
+
);
|
594 |
+
add_action( 'admin_notices', array( $this, 'mailchimp_no_lists_found' ) );
|
595 |
+
} else {
|
596 |
+
$default = array(
|
597 |
+
'' => __( 'Select a list...', 'woocommerce-mailchimp' ),
|
598 |
+
);
|
599 |
+
}
|
600 |
+
$mailchimp_lists = $default + $mailchimp_lists;
|
601 |
+
|
602 |
+
return $mailchimp_lists;
|
603 |
+
|
604 |
+
}
|
605 |
+
|
606 |
+
/**
|
607 |
+
* get_interest_groups function.
|
608 |
+
*
|
609 |
+
* @access public
|
610 |
+
* @return void
|
611 |
+
*/
|
612 |
+
public function get_interest_groups() {
|
613 |
+
|
614 |
+
if ( $this->mailchimp() && $this->has_list() ) {
|
615 |
+
$interest_groups = $this->mailchimp()->get_interest_categories_with_interests( $this->get_list() );
|
616 |
+
} else {
|
617 |
+
return array();
|
618 |
+
}
|
619 |
+
|
620 |
+
if ( $interest_groups === false ) {
|
621 |
+
|
622 |
+
// add_action( 'admin_notices', array( $this, 'mailchimp_api_error_msg' ) );
|
623 |
+
// add_action( 'network_admin_notices', array( $this, 'mailchimp_api_error_msg' ) );
|
624 |
+
|
625 |
+
return array();
|
626 |
+
|
627 |
+
}
|
628 |
+
|
629 |
+
return $interest_groups;
|
630 |
+
|
631 |
+
}
|
632 |
+
|
633 |
+
/**
|
634 |
+
* Inform the user they don't have any MailChimp lists
|
635 |
+
*/
|
636 |
+
public function mailchimp_no_lists_found() {
|
637 |
+
echo $this->get_message( sprintf( __( 'Oops! There are no lists in your MailChimp account. %sClick here%s to create one.', 'woocommerce-mailchimp' ), '<a href="https://admin.mailchimp.com/lists/new-list/" target="_blank">', '</a>' ) );
|
638 |
+
}
|
639 |
+
|
640 |
+
/**
|
641 |
+
* Display message to user if there is an issue with the MailChimp API call
|
642 |
+
*
|
643 |
+
* @since 1.0
|
644 |
+
* @param void
|
645 |
+
* @return html the message for the user
|
646 |
+
*/
|
647 |
+
public function mailchimp_api_error_msg() {
|
648 |
+
echo $this->get_message(
|
649 |
+
sprintf( __( 'Unable to load lists from MailChimp: (%s) %s. ', 'woocommerce-mailchimp' ), $this->mailchimp()->get_error_code(), $this->mailchimp()->get_error_message() ) .
|
650 |
+
sprintf( __( 'Please check your Settings %ssettings%s.', 'woocommerce-mailchimp' ), '<a href="' . SS_WC_MAILCHIMP_SETTINGS_URL .'">', '</a>' )
|
651 |
+
);
|
652 |
+
} //end function mailchimp_api_error_msg
|
653 |
+
|
654 |
+
/**
|
655 |
+
* Helper log function for debugging
|
656 |
+
*
|
657 |
+
* @since 1.2.2
|
658 |
+
*/
|
659 |
+
private function log( $message ) {
|
660 |
+
if ( $this->debug_enabled() ) {
|
661 |
+
$logger = new WC_Logger();
|
662 |
+
|
663 |
+
if ( is_array( $message ) || is_object( $message ) ) {
|
664 |
+
$logger->add( 'woocommerce-mailchimp', print_r( $message, true ) );
|
665 |
+
}
|
666 |
+
else {
|
667 |
+
$logger->add( 'woocommerce-mailchimp', $message );
|
668 |
+
}
|
669 |
+
}
|
670 |
+
}
|
671 |
+
|
672 |
+
public function sysinfo_field( $value ) {
|
673 |
+
|
674 |
+
// $option_value = self::get_option( $value['id'], $value['default'] );
|
675 |
+
$option_value = SS_System_Info::get_system_info();
|
676 |
+
// Description handling
|
677 |
+
$field_description = WC_Admin_Settings::get_field_description( $value );
|
678 |
+
extract( $field_description );
|
679 |
+
?>
|
680 |
+
<tr valign="top">
|
681 |
+
<th scope="row" class="titledesc">
|
682 |
+
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
683 |
+
<?php echo $tooltip_html; ?>
|
684 |
+
</th>
|
685 |
+
<td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
|
686 |
+
<?php echo $description; ?>
|
687 |
+
|
688 |
+
<textarea
|
689 |
+
name="<?php echo esc_attr( $value['id'] ); ?>"
|
690 |
+
id="<?php echo esc_attr( $value['id'] ); ?>"
|
691 |
+
style="font-family: Menlo,Monaco,monospace;display: block; overflow: auto; white-space: pre; width: 800px; height: 400px;<?php echo esc_attr( $value['css'] ); ?>"
|
692 |
+
class="<?php echo esc_attr( $value['class'] ); ?>"
|
693 |
+
placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>"
|
694 |
+
readonly="readonly" onclick="this.focus(); this.select()"
|
695 |
+
<?php //echo implode( ' ', $custom_attributes ); ?>
|
696 |
+
><?php echo esc_textarea( $option_value ); ?></textarea>
|
697 |
+
</td>
|
698 |
+
</tr>
|
699 |
+
<?php
|
700 |
+
}
|
701 |
+
|
702 |
+
} //end class SS_WC_MailChimp
|
703 |
+
|
704 |
+
return SS_WC_Settings_MailChimp::get_instance();
|
705 |
+
|
706 |
+
} //end if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) )
|
trunk/includes/class-sswcmc-logger.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Logging helper.
|
7 |
+
*
|
8 |
+
* @class SSWCMC_Logger
|
9 |
+
* @version 2.1.15
|
10 |
+
* @package WooCommerce MailChimp
|
11 |
+
* @author Saint Systems
|
12 |
+
*/
|
13 |
+
final class SSWCMC_Logger {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Plugin singleton instance
|
17 |
+
*
|
18 |
+
* @var SSWCMC_Logger
|
19 |
+
*/
|
20 |
+
private static $instance = null;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Whether plugin is in debug/troubleshooting mode.
|
24 |
+
*
|
25 |
+
* @var boolean
|
26 |
+
*/
|
27 |
+
public $debug;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* The WC_Logger handle.
|
31 |
+
*
|
32 |
+
* @var string
|
33 |
+
*/
|
34 |
+
const WC_LOG_FILENAME = 'woocommerce-mailchimp';
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Constructor
|
38 |
+
*
|
39 |
+
* @access public
|
40 |
+
* @return void
|
41 |
+
*/
|
42 |
+
public function __construct() {
|
43 |
+
|
44 |
+
$this->sswcmc = SSWCMC();
|
45 |
+
$this->register_hooks();
|
46 |
+
|
47 |
+
} //end function __construct
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Get the singleton instance
|
51 |
+
*
|
52 |
+
* @return SSWCMC_Logger
|
53 |
+
*/
|
54 |
+
public static function get_instance() {
|
55 |
+
if ( empty( self::$instance ) ) {
|
56 |
+
self::$instance = new self;
|
57 |
+
}
|
58 |
+
|
59 |
+
return self::$instance;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Register the class hooks.
|
64 |
+
* @access public
|
65 |
+
* @return void
|
66 |
+
*/
|
67 |
+
public function register_hooks() {
|
68 |
+
add_action( 'sswcmc_log', array( $this, 'log' ), 10, 1 );
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Conditionally log
|
73 |
+
*
|
74 |
+
* @param string $message The log message.
|
75 |
+
* @return void
|
76 |
+
*/
|
77 |
+
public function log( $message ) {
|
78 |
+
|
79 |
+
if ( ! $this->sswcmc->debug_enabled() ) return;
|
80 |
+
$log = $this->get_logger();
|
81 |
+
if ( version_compare( WC_VERSION, '3.0.0', '>=' ) ) {
|
82 |
+
$log->debug( $message, array( 'source' => self::WC_LOG_FILENAME ) );
|
83 |
+
} else {
|
84 |
+
$log->add( self::WC_LOG_FILENAME, $message );
|
85 |
+
}
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Get the WC_Logger reference
|
91 |
+
*
|
92 |
+
* @var WC_Logger
|
93 |
+
*/
|
94 |
+
private function get_logger() {
|
95 |
+
if ( version_compare( WC_VERSION, '3.0.0', '>=' ) ) {
|
96 |
+
return wc_get_logger();
|
97 |
+
} else {
|
98 |
+
return new WC_Logger();
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
} //end class SSWCMC_Logger
|
trunk/includes/helper-functions.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Utility helper functions
|
4 |
+
*/
|
5 |
+
|
6 |
+
/**
|
7 |
+
* sanitize_html_class doesn't handle spaces (multiple classes). We remedy that.
|
8 |
+
* @uses sanitize_html_class
|
9 |
+
* @param string|array $classes Text or arrray of classes to sanitize
|
10 |
+
* @return string Sanitized CSS string
|
11 |
+
*/
|
12 |
+
function sswcmc_sanitize_html_class( $classes ) {
|
13 |
+
|
14 |
+
if( is_string( $classes ) ) {
|
15 |
+
$classes = explode(' ', $classes );
|
16 |
+
}
|
17 |
+
|
18 |
+
// If someone passes something not string or array, we get outta here.
|
19 |
+
if( !is_array( $classes ) ) { return $classes; }
|
20 |
+
|
21 |
+
$classes = array_map( 'sanitize_html_class' , $classes );
|
22 |
+
|
23 |
+
return implode( ' ', $classes );
|
24 |
+
}
|
trunk/includes/lib/action-scheduler/.github/release-drafter.yml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
template: |
|
2 |
+
## next release – date
|
3 |
+
|
4 |
+
<!-- Move the individual changes below into the appropriate section -->
|
5 |
+
|
6 |
+
$CHANGES
|
7 |
+
|
8 |
+
**Added**
|
9 |
+
**Changed**
|
10 |
+
**Deprecated**
|
11 |
+
**Removed**
|
12 |
+
**Fixed**
|
13 |
+
**Security**
|
14 |
+
|
15 |
+
change-template: '* $TITLE (PR #$NUMBER)'
|
trunk/includes/lib/action-scheduler/.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
phpunit.xml
|
2 |
+
vendor
|
3 |
+
.idea
|
trunk/includes/lib/action-scheduler/.travis.yml
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Travis CI Configuration File
|
2 |
+
|
3 |
+
# Tell Travis CI we're using PHP
|
4 |
+
language: php
|
5 |
+
|
6 |
+
# We nee to use Precise, not Trusty, to test against PHP 5.3, see https://github.com/travis-ci/travis-ci/issues/8219
|
7 |
+
dist: precise
|
8 |
+
|
9 |
+
# Versions of PHP to test against
|
10 |
+
php:
|
11 |
+
- "5.3"
|
12 |
+
- "5.4"
|
13 |
+
- "5.5"
|
14 |
+
- "5.6"
|
15 |
+
- "7.0"
|
16 |
+
- "7.1"
|
17 |
+
|
18 |
+
# Specify versions of WordPress to test against
|
19 |
+
# WP_VERSION = WordPress version number (use "master" for SVN trunk)
|
20 |
+
# WP_MULTISITE = whether to test multisite (use either "0" or "1")
|
21 |
+
env:
|
22 |
+
- WP_VERSION=4.8 WP_MULTISITE=0
|
23 |
+
- WP_VERSION=4.7 WP_MULTISITE=0
|
24 |
+
- WP_VERSION=4.6 WP_MULTISITE=0
|
25 |
+
- WP_VERSION=4.8 WP_MULTISITE=1
|
26 |
+
- WP_VERSION=4.7 WP_MULTISITE=1
|
27 |
+
- WP_VERSION=4.6 WP_MULTISITE=1
|
28 |
+
|
29 |
+
# Grab the setup script and execute
|
30 |
+
before_script:
|
31 |
+
- source tests/travis/setup.sh $TRAVIS_PHP_VERSION
|
32 |
+
|
33 |
+
script:
|
34 |
+
- if [[ "$TRAVIS_PHP_VERSION" == "7.1" ]] && [[ "$WP_VERSION" == "4.8" ]] && [[ "$WP_MULTISITE" == "0" ]] && [[ "$TRAVIS_BRANCH" == "master" ]]; then phpunit --configuration tests/phpunit.xml.dist --coverage-clover clover.xml; else phpunit --configuration tests/phpunit.xml.dist; fi
|
35 |
+
|
36 |
+
after_script:
|
37 |
+
- bash <(curl -s https://codecov.io/bash)
|
trunk/includes/lib/action-scheduler/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Action Scheduler - Job Queue for WordPress [![Build Status](https://travis-ci.org/Prospress/action-scheduler.png?branch=master)](https://travis-ci.org/Prospress/action-scheduler) [![codecov](https://codecov.io/gh/Prospress/action-scheduler/branch/master/graph/badge.svg)](https://codecov.io/gh/Prospress/action-scheduler)
|
2 |
+
|
3 |
+
Action Scheduler is a scalable, traceable job queue for background processing large sets of actions in WordPress. It's specially designed to be distributed in WordPress plugins.
|
4 |
+
|
5 |
+
Action Scheduler works by triggering an action hook to run at some time in the future. Each hook can be scheduled with unique data, to allow callbacks to perform operations on that data. The hook can also be scheduled to run on one or more occassions.
|
6 |
+
|
7 |
+
Think of it like an extension to `do_action()` which adds the ability to delay and repeat a hook.
|
8 |
+
|
9 |
+
## Battle-Tested Background Processing
|
10 |
+
|
11 |
+
Every month, Action Scheduler processes millions of payments for [Subscriptions](https://woocommerce.com/products/woocommerce-subscriptions/), webhooks for [WooCommerce](https://wordpress.org/plugins/woocommerce/), as well as emails and other events for a range of other plugins.
|
12 |
+
|
13 |
+
It's been seen on live sites processing queues in excess of 50,000 jobs and doing resource intensive operations, like processing payments and creating orders, at a sustained rate of over 10,000 / hour without negatively impacting normal site operations.
|
14 |
+
|
15 |
+
This is all on infrastructure and WordPress sites outside the control of the plugin author.
|
16 |
+
|
17 |
+
If your plugin needs background processing, especially of large sets of tasks, Action Scheduler can help.
|
18 |
+
|
19 |
+
## Learn More
|
20 |
+
|
21 |
+
To learn more about how to Action Scheduler works, and how to use it in your plugin, check out the docs on [ActionScheduler.org](https://actionscheduler.org).
|
22 |
+
|
23 |
+
There you will find:
|
24 |
+
|
25 |
+
* [Usage guide](https://actionscheduler.org/usage/): instructions on installing and using Action Scheduler
|
26 |
+
* [WP CLI guide](https://actionscheduler.org/wp-cli/): instructions on running Action Scheduler at scale via WP CLI
|
27 |
+
* [API Reference](https://actionscheduler.org/api/): complete reference guide for all API functions
|
28 |
+
* [Administration Guide](https://actionscheduler.org/admin/): guide to managing scheduled actions via the administration screen
|
29 |
+
* [Guide to Background Processing at Scale](https://actionscheduler.org/perf/): instructions for running Action Scheduler at scale via the default WP Cron queue runner
|
30 |
+
|
31 |
+
## Credits
|
32 |
+
|
33 |
+
Action Scheduler is developed and maintained by [Prospress](http://prospress.com/) in collaboration with [Flightless](https://flightless.us/).
|
34 |
+
|
35 |
+
Collaboration is cool. We'd love to work with you to improve Action Scheduler. [Pull Requests](https://github.com/prospress/action-scheduler/pulls) welcome.
|
36 |
+
|
37 |
+
---
|
38 |
+
|
39 |
+
<p align="center">
|
40 |
+
<img src="https://cloud.githubusercontent.com/assets/235523/11986380/bb6a0958-a983-11e5-8e9b-b9781d37c64a.png" width="160">
|
41 |
+
</p>
|
trunk/includes/lib/action-scheduler/action-scheduler.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Plugin Name: Action Scheduler
|
4 |
+
* Plugin URI: https://github.com/prospress/action-scheduler
|
5 |
+
* Description: A robust scheduling library for use in WordPress plugins.
|
6 |
+
* Author: Prospress
|
7 |
+
* Author URI: http://prospress.com/
|
8 |
+
* Version: 2.1.1
|
9 |
+
* License: GPLv3
|
10 |
+
*
|
11 |
+
* Copyright 2018 Prospress, Inc. (email : freedoms@prospress.com)
|
12 |
+
*
|
13 |
+
* This program is free software: you can redistribute it and/or modify
|
14 |
+
* it under the terms of the GNU General Public License as published by
|
15 |
+
* the Free Software Foundation, either version 3 of the License, or
|
16 |
+
* (at your option) any later version.
|
17 |
+
*
|
18 |
+
* This program is distributed in the hope that it will be useful,
|
19 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21 |
+
* GNU General Public License for more details.
|
22 |
+
*
|
23 |
+
* You should have received a copy of the GNU General Public License
|
24 |
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
25 |
+
*
|
26 |
+
*/
|
27 |
+
|
28 |
+
if ( ! function_exists( 'action_scheduler_register_2_dot_1_dot_1' ) ) {
|
29 |
+
|
30 |
+
if ( ! class_exists( 'ActionScheduler_Versions' ) ) {
|
31 |
+
require_once( 'classes/ActionScheduler_Versions.php' );
|
32 |
+
add_action( 'plugins_loaded', array( 'ActionScheduler_Versions', 'initialize_latest_version' ), 1, 0 );
|
33 |
+
}
|
34 |
+
|
35 |
+
add_action( 'plugins_loaded', 'action_scheduler_register_2_dot_1_dot_1', 0, 0 );
|
36 |
+
|
37 |
+
function action_scheduler_register_2_dot_1_dot_1() {
|
38 |
+
$versions = ActionScheduler_Versions::instance();
|
39 |
+
$versions->register( '2.1.1', 'action_scheduler_initialize_2_dot_1_dot_1' );
|
40 |
+
}
|
41 |
+
|
42 |
+
function action_scheduler_initialize_2_dot_1_dot_1() {
|
43 |
+
require_once( 'classes/ActionScheduler.php' );
|
44 |
+
ActionScheduler::init( __FILE__ );
|
45 |
+
}
|
46 |
+
|
47 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler.php
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler
|
5 |
+
* @codeCoverageIgnore
|
6 |
+
*/
|
7 |
+
abstract class ActionScheduler {
|
8 |
+
private static $plugin_file = '';
|
9 |
+
/** @var ActionScheduler_ActionFactory */
|
10 |
+
private static $factory = NULL;
|
11 |
+
|
12 |
+
public static function factory() {
|
13 |
+
if ( !isset(self::$factory) ) {
|
14 |
+
self::$factory = new ActionScheduler_ActionFactory();
|
15 |
+
}
|
16 |
+
return self::$factory;
|
17 |
+
}
|
18 |
+
|
19 |
+
public static function store() {
|
20 |
+
return ActionScheduler_Store::instance();
|
21 |
+
}
|
22 |
+
|
23 |
+
public static function logger() {
|
24 |
+
return ActionScheduler_Logger::instance();
|
25 |
+
}
|
26 |
+
|
27 |
+
public static function runner() {
|
28 |
+
return ActionScheduler_QueueRunner::instance();
|
29 |
+
}
|
30 |
+
|
31 |
+
public static function admin_view() {
|
32 |
+
return ActionScheduler_AdminView::instance();
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Get the absolute system path to the plugin directory, or a file therein
|
37 |
+
* @static
|
38 |
+
* @param string $path
|
39 |
+
* @return string
|
40 |
+
*/
|
41 |
+
public static function plugin_path( $path ) {
|
42 |
+
$base = dirname(self::$plugin_file);
|
43 |
+
if ( $path ) {
|
44 |
+
return trailingslashit($base).$path;
|
45 |
+
} else {
|
46 |
+
return untrailingslashit($base);
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Get the absolute URL to the plugin directory, or a file therein
|
52 |
+
* @static
|
53 |
+
* @param string $path
|
54 |
+
* @return string
|
55 |
+
*/
|
56 |
+
public static function plugin_url( $path ) {
|
57 |
+
return plugins_url($path, self::$plugin_file);
|
58 |
+
}
|
59 |
+
|
60 |
+
public static function autoload( $class ) {
|
61 |
+
$d = DIRECTORY_SEPARATOR;
|
62 |
+
if ( 'Deprecated' === substr( $class, -10 ) ) {
|
63 |
+
$dir = self::plugin_path('deprecated'.$d);
|
64 |
+
} elseif ( strpos( $class, 'ActionScheduler' ) === 0 ) {
|
65 |
+
$dir = self::plugin_path('classes'.$d);
|
66 |
+
} elseif ( strpos( $class, 'CronExpression' ) === 0 ) {
|
67 |
+
$dir = self::plugin_path('lib'.$d.'cron-expression'.$d);
|
68 |
+
} else {
|
69 |
+
return;
|
70 |
+
}
|
71 |
+
|
72 |
+
if ( file_exists( "{$dir}{$class}.php" ) ) {
|
73 |
+
include( "{$dir}{$class}.php" );
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Initialize the plugin
|
80 |
+
*
|
81 |
+
* @static
|
82 |
+
* @param string $plugin_file
|
83 |
+
*/
|
84 |
+
public static function init( $plugin_file ) {
|
85 |
+
self::$plugin_file = $plugin_file;
|
86 |
+
spl_autoload_register( array( __CLASS__, 'autoload' ) );
|
87 |
+
|
88 |
+
$store = self::store();
|
89 |
+
add_action( 'init', array( $store, 'init' ), 1, 0 );
|
90 |
+
|
91 |
+
$logger = self::logger();
|
92 |
+
add_action( 'init', array( $logger, 'init' ), 1, 0 );
|
93 |
+
|
94 |
+
$runner = self::runner();
|
95 |
+
add_action( 'init', array( $runner, 'init' ), 1, 0 );
|
96 |
+
|
97 |
+
$admin_view = self::admin_view();
|
98 |
+
add_action( 'init', array( $admin_view, 'init' ), 0, 0 ); // run before $store::init()
|
99 |
+
|
100 |
+
require_once( self::plugin_path('functions.php') );
|
101 |
+
|
102 |
+
if ( apply_filters( 'action_scheduler_load_deprecated_functions', true ) ) {
|
103 |
+
require_once( self::plugin_path('deprecated/functions.php') );
|
104 |
+
}
|
105 |
+
|
106 |
+
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
107 |
+
WP_CLI::add_command( 'action-scheduler', 'ActionScheduler_WPCLI_Scheduler_command' );
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
|
112 |
+
final public function __clone() {
|
113 |
+
trigger_error("Singleton. No cloning allowed!", E_USER_ERROR);
|
114 |
+
}
|
115 |
+
|
116 |
+
final public function __wakeup() {
|
117 |
+
trigger_error("Singleton. No serialization allowed!", E_USER_ERROR);
|
118 |
+
}
|
119 |
+
|
120 |
+
final private function __construct() {}
|
121 |
+
|
122 |
+
/** Deprecated **/
|
123 |
+
|
124 |
+
public static function get_datetime_object( $when = null, $timezone = 'UTC' ) {
|
125 |
+
_deprecated_function( __METHOD__, '2.0', 'wcs_add_months()' );
|
126 |
+
return as_get_datetime_object( $when, $timezone );
|
127 |
+
}
|
128 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_Abstract_ListTable.php
ADDED
@@ -0,0 +1,656 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! class_exists( 'WP_List_Table' ) ) {
|
4 |
+
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
|
5 |
+
}
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Action Scheduler Abstract List Table class
|
9 |
+
*
|
10 |
+
* This abstract class enhances WP_List_Table making it ready to use.
|
11 |
+
*
|
12 |
+
* By extending this class we can focus on describing how our table looks like,
|
13 |
+
* which columns needs to be shown, filter, ordered by and more and forget about the details.
|
14 |
+
*
|
15 |
+
* This class supports:
|
16 |
+
* - Bulk actions
|
17 |
+
* - Search
|
18 |
+
* - Sortable columns
|
19 |
+
* - Automatic translations of the columns
|
20 |
+
*
|
21 |
+
* @codeCoverageIgnore
|
22 |
+
* @since 2.0.0
|
23 |
+
*/
|
24 |
+
abstract class ActionScheduler_Abstract_ListTable extends WP_List_Table {
|
25 |
+
|
26 |
+
/**
|
27 |
+
* The table name
|
28 |
+
*/
|
29 |
+
protected $table_name;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Package name, used in translations
|
33 |
+
*/
|
34 |
+
protected $package;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* How many items do we render per page?
|
38 |
+
*/
|
39 |
+
protected $items_per_page = 10;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Enables search in this table listing. If this array
|
43 |
+
* is empty it means the listing is not searchable.
|
44 |
+
*/
|
45 |
+
protected $search_by = array();
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Columns to show in the table listing. It is a key => value pair. The
|
49 |
+
* key must much the table column name and the value is the label, which is
|
50 |
+
* automatically translated.
|
51 |
+
*/
|
52 |
+
protected $columns = array();
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Defines the row-actions. It expects an array where the key
|
56 |
+
* is the column name and the value is an array of actions.
|
57 |
+
*
|
58 |
+
* The array of actions are key => value, where key is the method name
|
59 |
+
* (with the prefix row_action_<key>) and the value is the label
|
60 |
+
* and title.
|
61 |
+
*/
|
62 |
+
protected $row_actions = array();
|
63 |
+
|
64 |
+
/**
|
65 |
+
* The Primary key of our table
|
66 |
+
*/
|
67 |
+
protected $ID = 'ID';
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Enables sorting, it expects an array
|
71 |
+
* of columns (the column names are the values)
|
72 |
+
*/
|
73 |
+
protected $sort_by = array();
|
74 |
+
|
75 |
+
protected $filter_by = array();
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @var array The status name => count combinations for this table's items. Used to display status filters.
|
79 |
+
*/
|
80 |
+
protected $status_counts = array();
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @var array Notices to display when loading the table. Array of arrays of form array( 'class' => {updated|error}, 'message' => 'This is the notice text display.' ).
|
84 |
+
*/
|
85 |
+
protected $admin_notices = array();
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @var string Localised string displayed in the <h1> element above the able.
|
89 |
+
*/
|
90 |
+
protected $table_header;
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Enables bulk actions. It must be an array where the key is the action name
|
94 |
+
* and the value is the label (which is translated automatically). It is important
|
95 |
+
* to notice that it will check that the method exists (`bulk_$name`) and will throw
|
96 |
+
* an exception if it does not exists.
|
97 |
+
*
|
98 |
+
* This class will automatically check if the current request has a bulk action, will do the
|
99 |
+
* validations and afterwards will execute the bulk method, with two arguments. The first argument
|
100 |
+
* is the array with primary keys, the second argument is a string with a list of the primary keys,
|
101 |
+
* escaped and ready to use (with `IN`).
|
102 |
+
*/
|
103 |
+
protected $bulk_actions = array();
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Makes translation easier, it basically just wraps
|
107 |
+
* `_x` with some default (the package name)
|
108 |
+
*/
|
109 |
+
protected function translate( $text, $context = '' ) {
|
110 |
+
return _x( $text, $context, $this->package );
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Reads `$this->bulk_actions` and returns an array that WP_List_Table understands. It
|
115 |
+
* also validates that the bulk method handler exists. It throws an exception because
|
116 |
+
* this is a library meant for developers and missing a bulk method is a development-time error.
|
117 |
+
*/
|
118 |
+
protected function get_bulk_actions() {
|
119 |
+
$actions = array();
|
120 |
+
|
121 |
+
foreach ( $this->bulk_actions as $action => $label ) {
|
122 |
+
if ( ! is_callable( array( $this, 'bulk_' . $action ) ) ) {
|
123 |
+
throw new RuntimeException( "The bulk action $action does not have a callback method" );
|
124 |
+
}
|
125 |
+
|
126 |
+
$actions[ $action ] = $this->translate( $label );
|
127 |
+
}
|
128 |
+
|
129 |
+
return $actions;
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Checks if the current request has a bulk action. If that is the case it will validate and will
|
134 |
+
* execute the bulk method handler. Regardless if the action is valid or not it will redirect to
|
135 |
+
* the previous page removing the current arguments that makes this request a bulk action.
|
136 |
+
*/
|
137 |
+
protected function process_bulk_action() {
|
138 |
+
global $wpdb;
|
139 |
+
// Detect when a bulk action is being triggered.
|
140 |
+
$action = $this->current_action();
|
141 |
+
|
142 |
+
if ( ! $action ) {
|
143 |
+
return;
|
144 |
+
}
|
145 |
+
|
146 |
+
check_admin_referer( 'bulk-' . $this->_args['plural'] );
|
147 |
+
|
148 |
+
$method = 'bulk_' . $action;
|
149 |
+
if ( array_key_exists( $action, $this->bulk_actions ) && is_callable( array( $this, $method ) ) && ! empty( $_GET['ID'] ) && is_array( $_GET['ID'] ) ) {
|
150 |
+
$ids_sql = '(' . implode( ',', array_fill( 0, count( $_GET['ID'] ), '%s' ) ) . ')';
|
151 |
+
$this->$method( $_GET['ID'], $wpdb->prepare( $ids_sql, $_GET['ID'] ) );
|
152 |
+
}
|
153 |
+
|
154 |
+
wp_redirect( remove_query_arg(
|
155 |
+
array( '_wp_http_referer', '_wpnonce', 'ID', 'action', 'action2' ),
|
156 |
+
wp_unslash( $_SERVER['REQUEST_URI'] )
|
157 |
+
) );
|
158 |
+
exit;
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Default code for deleting entries. We trust ids_sql because it is
|
163 |
+
* validated already by process_bulk_action()
|
164 |
+
*/
|
165 |
+
protected function bulk_delete( array $ids, $ids_sql ) {
|
166 |
+
global $wpdb;
|
167 |
+
|
168 |
+
$wpdb->query( "DELETE FROM {$this->table_name} WHERE {$this->ID} IN $ids_sql" );
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Prepares the _column_headers property which is used by WP_Table_List at rendering.
|
173 |
+
* It merges the columns and the sortable columns.
|
174 |
+
*/
|
175 |
+
protected function prepare_column_headers() {
|
176 |
+
$this->_column_headers = array(
|
177 |
+
$this->get_columns(),
|
178 |
+
array(),
|
179 |
+
$this->get_sortable_columns(),
|
180 |
+
);
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Reads $this->sort_by and returns the columns name in a format that WP_Table_List
|
185 |
+
* expects
|
186 |
+
*/
|
187 |
+
public function get_sortable_columns() {
|
188 |
+
$sort_by = array();
|
189 |
+
foreach ( $this->sort_by as $column ) {
|
190 |
+
$sort_by[ $column ] = array( $column, true );
|
191 |
+
}
|
192 |
+
return $sort_by;
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Returns the columns names for rendering. It adds a checkbox for selecting everything
|
197 |
+
* as the first column
|
198 |
+
*/
|
199 |
+
public function get_columns() {
|
200 |
+
$columns = array_merge(
|
201 |
+
array( 'cb' => '<input type="checkbox" />' ),
|
202 |
+
array_map( array( $this, 'translate' ), $this->columns )
|
203 |
+
);
|
204 |
+
|
205 |
+
return $columns;
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Get prepared LIMIT clause for items query
|
210 |
+
*
|
211 |
+
* @global wpdb $wpdb
|
212 |
+
*
|
213 |
+
* @return string Prepared LIMIT clause for items query.
|
214 |
+
*/
|
215 |
+
protected function get_items_query_limit() {
|
216 |
+
global $wpdb;
|
217 |
+
|
218 |
+
$per_page = $this->get_items_per_page( $this->package . '_items_per_page', $this->items_per_page );
|
219 |
+
return $wpdb->prepare( 'LIMIT %d', $per_page );
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Returns the number of items to offset/skip for this current view.
|
224 |
+
*
|
225 |
+
* @return int
|
226 |
+
*/
|
227 |
+
protected function get_items_offset() {
|
228 |
+
$per_page = $this->get_items_per_page( $this->package . '_items_per_page', $this->items_per_page );
|
229 |
+
$current_page = $this->get_pagenum();
|
230 |
+
if ( 1 < $current_page ) {
|
231 |
+
$offset = $per_page * ( $current_page - 1 );
|
232 |
+
} else {
|
233 |
+
$offset = 0;
|
234 |
+
}
|
235 |
+
|
236 |
+
return $offset;
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Get prepared OFFSET clause for items query
|
241 |
+
*
|
242 |
+
* @global wpdb $wpdb
|
243 |
+
*
|
244 |
+
* @return string Prepared OFFSET clause for items query.
|
245 |
+
*/
|
246 |
+
protected function get_items_query_offset() {
|
247 |
+
global $wpdb;
|
248 |
+
|
249 |
+
return $wpdb->prepare( 'OFFSET %d', $this->get_items_offset() );
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Prepares the ORDER BY sql statement. It uses `$this->sort_by` to know which
|
254 |
+
* columns are sortable. This requests validates the orderby $_GET parameter is a valid
|
255 |
+
* column and sortable. It will also use order (ASC|DESC) using DESC by default.
|
256 |
+
*/
|
257 |
+
protected function get_items_query_order() {
|
258 |
+
if ( empty( $this->sort_by ) ) {
|
259 |
+
return '';
|
260 |
+
}
|
261 |
+
|
262 |
+
$orderby = esc_sql( $this->get_request_orderby() );
|
263 |
+
$order = esc_sql( $this->get_request_order() );
|
264 |
+
|
265 |
+
return "ORDER BY {$orderby} {$order}";
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Return the sortable column specified for this request to order the results by, if any.
|
270 |
+
*
|
271 |
+
* @return string
|
272 |
+
*/
|
273 |
+
protected function get_request_orderby() {
|
274 |
+
|
275 |
+
$valid_sortable_columns = array_values( $this->sort_by );
|
276 |
+
|
277 |
+
if ( ! empty( $_GET['orderby'] ) && in_array( $_GET['orderby'], $valid_sortable_columns ) ) {
|
278 |
+
$orderby = sanitize_text_field( $_GET['orderby'] );
|
279 |
+
} else {
|
280 |
+
$orderby = $valid_sortable_columns[0];
|
281 |
+
}
|
282 |
+
|
283 |
+
return $orderby;
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Return the sortable column order specified for this request.
|
288 |
+
*
|
289 |
+
* @return string
|
290 |
+
*/
|
291 |
+
protected function get_request_order() {
|
292 |
+
|
293 |
+
if ( ! empty( $_GET['order'] ) && 'desc' === strtolower( $_GET['order'] ) ) {
|
294 |
+
$order = 'DESC';
|
295 |
+
} else {
|
296 |
+
$order = 'ASC';
|
297 |
+
}
|
298 |
+
|
299 |
+
return $order;
|
300 |
+
}
|
301 |
+
|
302 |
+
/**
|
303 |
+
* Return the status filter for this request, if any.
|
304 |
+
*
|
305 |
+
* @return string
|
306 |
+
*/
|
307 |
+
protected function get_request_status() {
|
308 |
+
$status = ( ! empty( $_GET['status'] ) ) ? $_GET['status'] : '';
|
309 |
+
return $status;
|
310 |
+
}
|
311 |
+
|
312 |
+
/**
|
313 |
+
* Return the search filter for this request, if any.
|
314 |
+
*
|
315 |
+
* @return string
|
316 |
+
*/
|
317 |
+
protected function get_request_search_query() {
|
318 |
+
$search_query = ( ! empty( $_GET['s'] ) ) ? $_GET['s'] : '';
|
319 |
+
return $search_query;
|
320 |
+
}
|
321 |
+
|
322 |
+
/**
|
323 |
+
* Process and return the columns name. This is meant for using with SQL, this means it
|
324 |
+
* always includes the primary key.
|
325 |
+
*
|
326 |
+
* @return array
|
327 |
+
*/
|
328 |
+
protected function get_table_columns() {
|
329 |
+
$columns = array_keys( $this->columns );
|
330 |
+
if ( ! in_array( $this->ID, $columns ) ) {
|
331 |
+
$columns[] = $this->ID;
|
332 |
+
}
|
333 |
+
|
334 |
+
return $columns;
|
335 |
+
}
|
336 |
+
|
337 |
+
/**
|
338 |
+
* Check if the current request is doing a "full text" search. If that is the case
|
339 |
+
* prepares the SQL to search texts using LIKE.
|
340 |
+
*
|
341 |
+
* If the current request does not have any search or if this list table does not support
|
342 |
+
* that feature it will return an empty string.
|
343 |
+
*
|
344 |
+
* TODO:
|
345 |
+
* - Improve search doing LIKE by word rather than by phrases.
|
346 |
+
*
|
347 |
+
* @return string
|
348 |
+
*/
|
349 |
+
protected function get_items_query_search() {
|
350 |
+
global $wpdb;
|
351 |
+
|
352 |
+
if ( empty( $_GET['s'] ) || empty( $this->search_by ) ) {
|
353 |
+
return '';
|
354 |
+
}
|
355 |
+
|
356 |
+
$filter = array();
|
357 |
+
foreach ( $this->search_by as $column ) {
|
358 |
+
$filter[] = '`' . $column . '` like "%' . $wpdb->esc_like( $_GET['s'] ) . '%"';
|
359 |
+
}
|
360 |
+
return implode( ' OR ', $filter );
|
361 |
+
}
|
362 |
+
|
363 |
+
/**
|
364 |
+
* Prepares the SQL to filter rows by the options defined at `$this->filter_by`. Before trusting
|
365 |
+
* any data sent by the user it validates that it is a valid option.
|
366 |
+
*/
|
367 |
+
protected function get_items_query_filters() {
|
368 |
+
global $wpdb;
|
369 |
+
|
370 |
+
if ( ! $this->filter_by || empty( $_GET['filter_by'] ) || ! is_array( $_GET['filter_by'] ) ) {
|
371 |
+
return '';
|
372 |
+
}
|
373 |
+
|
374 |
+
$filter = array();
|
375 |
+
|
376 |
+
foreach ( $this->filter_by as $column => $options ) {
|
377 |
+
if ( empty( $_GET['filter_by'][ $column ] ) || empty( $options[ $_GET['filter_by'][ $column ] ] ) ) {
|
378 |
+
continue;
|
379 |
+
}
|
380 |
+
|
381 |
+
$filter[] = $wpdb->prepare( "`$column` = %s", $_GET['filter_by'][ $column ] );
|
382 |
+
}
|
383 |
+
|
384 |
+
return implode( ' AND ', $filter );
|
385 |
+
|
386 |
+
}
|
387 |
+
|
388 |
+
/**
|
389 |
+
* Prepares the data to feed WP_Table_List.
|
390 |
+
*
|
391 |
+
* This has the core for selecting, sorting and filting data. To keep the code simple
|
392 |
+
* its logic is split among many methods (get_items_query_*).
|
393 |
+
*
|
394 |
+
* Beside populating the items this function will also count all the records that matches
|
395 |
+
* the filtering criteria and will do fill the pagination variables.
|
396 |
+
*/
|
397 |
+
public function prepare_items() {
|
398 |
+
global $wpdb;
|
399 |
+
|
400 |
+
$this->process_bulk_action();
|
401 |
+
|
402 |
+
$this->process_row_actions();
|
403 |
+
|
404 |
+
if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
|
405 |
+
// _wp_http_referer is used only on bulk actions, we remove it to keep the $_GET shorter
|
406 |
+
wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
|
407 |
+
exit;
|
408 |
+
}
|
409 |
+
|
410 |
+
$this->prepare_column_headers();
|
411 |
+
|
412 |
+
$limit = $this->get_items_query_limit();
|
413 |
+
$offset = $this->get_items_query_offset();
|
414 |
+
$order = $this->get_items_query_order();
|
415 |
+
$where = array_filter(array(
|
416 |
+
$this->get_items_query_search(),
|
417 |
+
$this->get_items_query_filters(),
|
418 |
+
));
|
419 |
+
$columns = '`' . implode( '`, `', $this->get_table_columns() ) . '`';
|
420 |
+
|
421 |
+
if ( ! empty( $where ) ) {
|
422 |
+
$where = 'WHERE ('. implode( ') AND (', $where ) . ')';
|
423 |
+
} else {
|
424 |
+
$where = '';
|
425 |
+
}
|
426 |
+
|
427 |
+
$sql = "SELECT $columns FROM {$this->table_name} {$where} {$order} {$limit} {$offset}";
|
428 |
+
|
429 |
+
$this->set_items( $wpdb->get_results( $sql, ARRAY_A ) );
|
430 |
+
|
431 |
+
$query_count = "SELECT COUNT({$this->ID}) FROM {$this->table_name} {$where}";
|
432 |
+
$total_items = $wpdb->get_var( $query_count );
|
433 |
+
$per_page = $this->get_items_per_page( $this->package . '_items_per_page', $this->items_per_page );
|
434 |
+
$this->set_pagination_args( array(
|
435 |
+
'total_items' => $total_items,
|
436 |
+
'per_page' => $per_page,
|
437 |
+
'total_pages' => ceil( $total_items / $per_page ),
|
438 |
+
) );
|
439 |
+
}
|
440 |
+
|
441 |
+
public function extra_tablenav( $which ) {
|
442 |
+
if ( ! $this->filter_by || 'top' !== $which ) {
|
443 |
+
return;
|
444 |
+
}
|
445 |
+
|
446 |
+
echo '<div class="alignleft actions">';
|
447 |
+
|
448 |
+
foreach ( $this->filter_by as $id => $options ) {
|
449 |
+
$default = ! empty( $_GET['filter_by'][ $id ] ) ? $_GET['filter_by'][ $id ] : '';
|
450 |
+
if ( empty( $options[ $default ] ) ) {
|
451 |
+
$default = '';
|
452 |
+
}
|
453 |
+
|
454 |
+
echo '<select name="filter_by[' . esc_attr( $id ) . ']" class="first" id="filter-by-' . esc_attr( $id ) . '">';
|
455 |
+
|
456 |
+
foreach ( $options as $value => $label ) {
|
457 |
+
echo '<option value="' . esc_attr( $value ) . '" ' . esc_html( $value == $default ? 'selected' : '' ) .'>'
|
458 |
+
. esc_html( $this->translate( $label ) )
|
459 |
+
. '</option>';
|
460 |
+
}
|
461 |
+
|
462 |
+
echo '</select>';
|
463 |
+
}
|
464 |
+
|
465 |
+
submit_button( $this->translate( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
|
466 |
+
echo '</div>';
|
467 |
+
}
|
468 |
+
|
469 |
+
/**
|
470 |
+
* Set the data for displaying. It will attempt to unserialize (There is a chance that some columns
|
471 |
+
* are serialized). This can be override in child classes for futher data transformation.
|
472 |
+
*/
|
473 |
+
protected function set_items( array $items ) {
|
474 |
+
$this->items = array();
|
475 |
+
foreach ( $items as $item ) {
|
476 |
+
$this->items[ $item[ $this->ID ] ] = array_map( 'maybe_unserialize', $item );
|
477 |
+
}
|
478 |
+
}
|
479 |
+
|
480 |
+
/**
|
481 |
+
* Renders the checkbox for each row, this is the first column and it is named ID regardless
|
482 |
+
* of how the primary key is named (to keep the code simpler). The bulk actions will do the proper
|
483 |
+
* name transformation though using `$this->ID`.
|
484 |
+
*/
|
485 |
+
public function column_cb( $row ) {
|
486 |
+
return '<input name="ID[]" type="checkbox" value="' . esc_attr( $row[ $this->ID ] ) .'" />';
|
487 |
+
}
|
488 |
+
|
489 |
+
/**
|
490 |
+
* Renders the row-actions.
|
491 |
+
*
|
492 |
+
* This method renders the action menu, it reads the definition from the $row_actions property,
|
493 |
+
* and it checks that the row action method exists before rendering it.
|
494 |
+
*
|
495 |
+
* @param array $row Row to render
|
496 |
+
* @param $column_name Current row
|
497 |
+
* @return
|
498 |
+
*/
|
499 |
+
protected function maybe_render_actions( $row, $column_name ) {
|
500 |
+
if ( empty( $this->row_actions[ $column_name ] ) ) {
|
501 |
+
return;
|
502 |
+
}
|
503 |
+
|
504 |
+
$row_id = $row[ $this->ID ];
|
505 |
+
|
506 |
+
$actions = '<div class="row-actions">';
|
507 |
+
$action_count = 0;
|
508 |
+
foreach ( $this->row_actions[ $column_name ] as $action_key => $action ) {
|
509 |
+
|
510 |
+
$action_count++;
|
511 |
+
|
512 |
+
if ( ! method_exists( $this, 'row_action_' . $action_key ) ) {
|
513 |
+
continue;
|
514 |
+
}
|
515 |
+
|
516 |
+
$action_link = ! empty( $action['link'] ) ? $action['link'] : add_query_arg( array( 'row_action' => $action_key, 'row_id' => $row_id, 'nonce' => wp_create_nonce( $action_key . '::' . $row_id ) ) );
|
517 |
+
$span_class = ! empty( $action['class'] ) ? $action['class'] : $action_key;
|
518 |
+
$separator = ( $action_count < count( $this->row_actions[ $column_name ] ) ) ? ' | ' : '';
|
519 |
+
|
520 |
+
$actions .= sprintf( '<span class="%s">', esc_attr( $span_class ) );
|
521 |
+
$actions .= sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', esc_url( $action_link ), esc_attr( $action['desc'] ), esc_html( $action['name'] ) );
|
522 |
+
$actions .= sprintf( '%s</span>', $separator );
|
523 |
+
}
|
524 |
+
$actions .= '</div>';
|
525 |
+
return $actions;
|
526 |
+
}
|
527 |
+
|
528 |
+
protected function process_row_actions() {
|
529 |
+
$parameters = array( 'row_action', 'row_id', 'nonce' );
|
530 |
+
foreach ( $parameters as $parameter ) {
|
531 |
+
if ( empty( $_REQUEST[ $parameter ] ) ) {
|
532 |
+
return;
|
533 |
+
}
|
534 |
+
}
|
535 |
+
|
536 |
+
$method = 'row_action_' . $_REQUEST['row_action'];
|
537 |
+
|
538 |
+
if ( $_REQUEST['nonce'] === wp_create_nonce( $_REQUEST[ 'row_action' ] . '::' . $_REQUEST[ 'row_id' ] ) && method_exists( $this, $method ) ) {
|
539 |
+
$this->$method( $_REQUEST['row_id'] );
|
540 |
+
}
|
541 |
+
|
542 |
+
wp_redirect( remove_query_arg(
|
543 |
+
array( 'row_id', 'row_action', 'nonce' ),
|
544 |
+
wp_unslash( $_SERVER['REQUEST_URI'] )
|
545 |
+
) );
|
546 |
+
exit;
|
547 |
+
}
|
548 |
+
|
549 |
+
/**
|
550 |
+
* Default column formatting, it will escape everythig for security.
|
551 |
+
*/
|
552 |
+
public function column_default( $item, $column_name ) {
|
553 |
+
$column_html = esc_html( $item[ $column_name ] );
|
554 |
+
$column_html .= $this->maybe_render_actions( $item, $column_name );
|
555 |
+
return $column_html;
|
556 |
+
}
|
557 |
+
|
558 |
+
/**
|
559 |
+
* Display the table heading and search query, if any
|
560 |
+
*/
|
561 |
+
protected function display_header() {
|
562 |
+
echo '<h1 class="wp-heading-inline">' . esc_attr( $this->table_header ) . '</h1>';
|
563 |
+
if ( $this->get_request_search_query() ) {
|
564 |
+
echo '<span class="subtitle">' . esc_attr( $this->translate( sprintf( 'Search results for "%s"', $this->get_request_search_query() ) ) ) . '</span>';
|
565 |
+
}
|
566 |
+
echo '<hr class="wp-header-end">';
|
567 |
+
}
|
568 |
+
|
569 |
+
/**
|
570 |
+
* Display the table heading and search query, if any
|
571 |
+
*/
|
572 |
+
protected function display_admin_notices() {
|
573 |
+
foreach ( $this->admin_notices as $notice ) {
|
574 |
+
echo '<div id="message" class="' . $notice['class'] . '">';
|
575 |
+
echo ' <p>' . wp_kses_post( $notice['message'] ) . '</p>';
|
576 |
+
echo '</div>';
|
577 |
+
}
|
578 |
+
}
|
579 |
+
|
580 |
+
/**
|
581 |
+
* Prints the available statuses so the user can click to filter.
|
582 |
+
*/
|
583 |
+
protected function display_filter_by_status() {
|
584 |
+
|
585 |
+
$status_list_items = array();
|
586 |
+
$request_status = $this->get_request_status();
|
587 |
+
|
588 |
+
// Helper to set 'all' filter when not set on status counts passed in
|
589 |
+
if ( ! isset( $this->status_counts['all'] ) ) {
|
590 |
+
$this->status_counts = array( 'all' => array_sum( $this->status_counts ) ) + $this->status_counts;
|
591 |
+
}
|
592 |
+
|
593 |
+
foreach ( $this->status_counts as $status_name => $count ) {
|
594 |
+
|
595 |
+
if ( 0 === $count ) {
|
596 |
+
continue;
|
597 |
+
}
|
598 |
+
|
599 |
+
if ( $status_name === $request_status || ( empty( $request_status ) && 'all' === $status_name ) ) {
|
600 |
+
$status_list_item = '<li class="%1$s"><strong>%3$s</strong> (%4$d)</li>';
|
601 |
+
} else {
|
602 |
+
$status_list_item = '<li class="%1$s"><a href="%2$s">%3$s</a> (%4$d)</li>';
|
603 |
+
}
|
604 |
+
|
605 |
+
$status_filter_url = ( 'all' === $status_name ) ? remove_query_arg( 'status' ) : add_query_arg( 'status', $status_name );
|
606 |
+
$status_list_items[] = sprintf( $status_list_item, esc_attr( $status_name ), esc_url( $status_filter_url ), esc_html( ucfirst( $status_name ) ), absint( $count ) );
|
607 |
+
}
|
608 |
+
|
609 |
+
if ( $status_list_items ) {
|
610 |
+
echo '<ul class="subsubsub">';
|
611 |
+
echo implode( " | \n", $status_list_items );
|
612 |
+
echo '</ul>';
|
613 |
+
}
|
614 |
+
}
|
615 |
+
|
616 |
+
/**
|
617 |
+
* Renders the table list, we override the original class to render the table inside a form
|
618 |
+
* and to render any needed HTML (like the search box). By doing so the callee of a function can simple
|
619 |
+
* forget about any extra HTML.
|
620 |
+
*/
|
621 |
+
protected function display_table() {
|
622 |
+
echo '<form id="' . esc_attr( $this->_args['plural'] ) . '-filter" method="get">';
|
623 |
+
foreach ( $_GET as $key => $value ) {
|
624 |
+
if ( '_' === $key[0] || 'paged' === $key ) {
|
625 |
+
continue;
|
626 |
+
}
|
627 |
+
echo '<input type="hidden" name="' . esc_attr( $key ) . '" value="' . esc_attr( $value ) . '" />';
|
628 |
+
}
|
629 |
+
if ( ! empty( $this->search_by ) ) {
|
630 |
+
echo $this->search_box( $this->get_search_box_button_text(), 'plugin' ); // WPCS: XSS OK
|
631 |
+
}
|
632 |
+
parent::display();
|
633 |
+
echo '</form>';
|
634 |
+
}
|
635 |
+
|
636 |
+
/**
|
637 |
+
* Render the list table page, including header, notices, status filters and table.
|
638 |
+
*/
|
639 |
+
public function display_page() {
|
640 |
+
$this->prepare_items();
|
641 |
+
|
642 |
+
echo '<div class="wrap">';
|
643 |
+
$this->display_header();
|
644 |
+
$this->display_admin_notices();
|
645 |
+
$this->display_filter_by_status();
|
646 |
+
$this->display_table();
|
647 |
+
echo '</div>';
|
648 |
+
}
|
649 |
+
|
650 |
+
/**
|
651 |
+
* Get the text to display in the search box on the list table.
|
652 |
+
*/
|
653 |
+
protected function get_search_box_placeholder() {
|
654 |
+
return $this->translate( 'Search' );
|
655 |
+
}
|
656 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_Abstract_QueueRunner.php
ADDED
@@ -0,0 +1,216 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Abstract class with common Queue Cleaner functionality.
|
5 |
+
*/
|
6 |
+
abstract class ActionScheduler_Abstract_QueueRunner extends ActionScheduler_Abstract_QueueRunner_Deprecated {
|
7 |
+
|
8 |
+
/** @var ActionScheduler_QueueCleaner */
|
9 |
+
protected $cleaner;
|
10 |
+
|
11 |
+
/** @var ActionScheduler_FatalErrorMonitor */
|
12 |
+
protected $monitor;
|
13 |
+
|
14 |
+
/** @var ActionScheduler_Store */
|
15 |
+
protected $store;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* The created time.
|
19 |
+
*
|
20 |
+
* Represents when the queue runner was constructed and used when calculating how long a PHP request has been running.
|
21 |
+
* For this reason it should be as close as possible to the PHP request start time.
|
22 |
+
*
|
23 |
+
* @var int
|
24 |
+
*/
|
25 |
+
private $created_time;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* ActionScheduler_Abstract_QueueRunner constructor.
|
29 |
+
*
|
30 |
+
* @param ActionScheduler_Store $store
|
31 |
+
* @param ActionScheduler_FatalErrorMonitor $monitor
|
32 |
+
* @param ActionScheduler_QueueCleaner $cleaner
|
33 |
+
*/
|
34 |
+
public function __construct( ActionScheduler_Store $store = null, ActionScheduler_FatalErrorMonitor $monitor = null, ActionScheduler_QueueCleaner $cleaner = null ) {
|
35 |
+
|
36 |
+
$this->created_time = microtime( true );
|
37 |
+
|
38 |
+
$this->store = $store ? $store : ActionScheduler_Store::instance();
|
39 |
+
$this->monitor = $monitor ? $monitor : new ActionScheduler_FatalErrorMonitor( $this->store );
|
40 |
+
$this->cleaner = $cleaner ? $cleaner : new ActionScheduler_QueueCleaner( $this->store );
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Process an individual action.
|
45 |
+
*
|
46 |
+
* @param int $action_id The action ID to process.
|
47 |
+
*/
|
48 |
+
public function process_action( $action_id ) {
|
49 |
+
try {
|
50 |
+
do_action( 'action_scheduler_before_execute', $action_id );
|
51 |
+
|
52 |
+
if ( ActionScheduler_Store::STATUS_PENDING !== $this->store->get_status( $action_id ) ) {
|
53 |
+
do_action( 'action_scheduler_execution_ignored', $action_id );
|
54 |
+
return;
|
55 |
+
}
|
56 |
+
|
57 |
+
$action = $this->store->fetch_action( $action_id );
|
58 |
+
$this->store->log_execution( $action_id );
|
59 |
+
$action->execute();
|
60 |
+
do_action( 'action_scheduler_after_execute', $action_id );
|
61 |
+
$this->store->mark_complete( $action_id );
|
62 |
+
} catch ( Exception $e ) {
|
63 |
+
$this->store->mark_failure( $action_id );
|
64 |
+
do_action( 'action_scheduler_failed_execution', $action_id, $e );
|
65 |
+
}
|
66 |
+
$this->schedule_next_instance( $action );
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Schedule the next instance of the action if necessary.
|
71 |
+
*
|
72 |
+
* @param ActionScheduler_Action $action
|
73 |
+
*/
|
74 |
+
protected function schedule_next_instance( ActionScheduler_Action $action ) {
|
75 |
+
$schedule = $action->get_schedule();
|
76 |
+
$next = $schedule->next( as_get_datetime_object() );
|
77 |
+
|
78 |
+
if ( ! is_null( $next ) && $schedule->is_recurring() ) {
|
79 |
+
$this->store->save_action( $action, $next );
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Run the queue cleaner.
|
85 |
+
*
|
86 |
+
* @author Jeremy Pry
|
87 |
+
*/
|
88 |
+
protected function run_cleanup() {
|
89 |
+
$this->cleaner->clean();
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Get the number of concurrent batches a runner allows.
|
94 |
+
*
|
95 |
+
* @return int
|
96 |
+
*/
|
97 |
+
public function get_allowed_concurrent_batches() {
|
98 |
+
return apply_filters( 'action_scheduler_queue_runner_concurrent_batches', 5 );
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Get the maximum number of seconds a batch can run for.
|
103 |
+
*
|
104 |
+
* @return int The number of seconds.
|
105 |
+
*/
|
106 |
+
protected function get_time_limit() {
|
107 |
+
|
108 |
+
$time_limit = 30;
|
109 |
+
|
110 |
+
// Apply deprecated filter from deprecated get_maximum_execution_time() method
|
111 |
+
if ( has_filter( 'action_scheduler_maximum_execution_time' ) ) {
|
112 |
+
_deprecated_function( 'action_scheduler_maximum_execution_time', '2.1.1', 'action_scheduler_queue_runner_time_limit' );
|
113 |
+
$time_limit = apply_filters( 'action_scheduler_maximum_execution_time', $time_limit );
|
114 |
+
}
|
115 |
+
|
116 |
+
return absint( apply_filters( 'action_scheduler_queue_runner_time_limit', $time_limit ) );
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Get the number of seconds the process has been running.
|
121 |
+
*
|
122 |
+
* @return int The number of seconds.
|
123 |
+
*/
|
124 |
+
protected function get_execution_time() {
|
125 |
+
$execution_time = microtime( true ) - $this->created_time;
|
126 |
+
|
127 |
+
// Get the CPU time if the hosting environment uses it rather than wall-clock time to calculate a process's execution time.
|
128 |
+
if ( function_exists( 'getrusage' ) && apply_filters( 'action_scheduler_use_cpu_execution_time', defined( 'PANTHEON_ENVIRONMENT' ) ) ) {
|
129 |
+
$resource_usages = getrusage();
|
130 |
+
|
131 |
+
if ( isset( $resource_usages['ru_stime.tv_usec'], $resource_usages['ru_stime.tv_usec'] ) ) {
|
132 |
+
$execution_time = $resource_usages['ru_stime.tv_sec'] + ( $resource_usages['ru_stime.tv_usec'] / 1000000 );
|
133 |
+
}
|
134 |
+
}
|
135 |
+
|
136 |
+
return $execution_time;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Check if the host's max execution time is (likely) to be exceeded if processing more actions.
|
141 |
+
*
|
142 |
+
* @param int $processed_actions The number of actions processed so far - used to determine the likelihood of exceeding the time limit if processing another action
|
143 |
+
* @return bool
|
144 |
+
*/
|
145 |
+
protected function time_likely_to_be_exceeded( $processed_actions ) {
|
146 |
+
|
147 |
+
$execution_time = $this->get_execution_time();
|
148 |
+
$max_execution_time = $this->get_time_limit();
|
149 |
+
$time_per_action = $execution_time / $processed_actions;
|
150 |
+
$estimated_time = $execution_time + ( $time_per_action * 3 );
|
151 |
+
$likely_to_be_exceeded = $estimated_time > $max_execution_time;
|
152 |
+
|
153 |
+
return apply_filters( 'action_scheduler_maximum_execution_time_likely_to_be_exceeded', $likely_to_be_exceeded, $this, $processed_actions, $execution_time, $max_execution_time );
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Get memory limit
|
158 |
+
*
|
159 |
+
* Based on WP_Background_Process::get_memory_limit()
|
160 |
+
*
|
161 |
+
* @return int
|
162 |
+
*/
|
163 |
+
protected function get_memory_limit() {
|
164 |
+
if ( function_exists( 'ini_get' ) ) {
|
165 |
+
$memory_limit = ini_get( 'memory_limit' );
|
166 |
+
} else {
|
167 |
+
$memory_limit = '128M'; // Sensible default, and minimum required by WooCommerce
|
168 |
+
}
|
169 |
+
|
170 |
+
if ( ! $memory_limit || -1 === $memory_limit || '-1' === $memory_limit ) {
|
171 |
+
// Unlimited, set to 32GB.
|
172 |
+
$memory_limit = '32G';
|
173 |
+
}
|
174 |
+
|
175 |
+
return ActionScheduler_Compatibility::convert_hr_to_bytes( $memory_limit );
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Memory exceeded
|
180 |
+
*
|
181 |
+
* Ensures the batch process never exceeds 90% of the maximum WordPress memory.
|
182 |
+
*
|
183 |
+
* Based on WP_Background_Process::memory_exceeded()
|
184 |
+
*
|
185 |
+
* @return bool
|
186 |
+
*/
|
187 |
+
protected function memory_exceeded() {
|
188 |
+
|
189 |
+
$memory_limit = $this->get_memory_limit() * 0.90;
|
190 |
+
$current_memory = memory_get_usage( true );
|
191 |
+
$memory_exceeded = $current_memory >= $memory_limit;
|
192 |
+
|
193 |
+
return apply_filters( 'action_scheduler_memory_exceeded', $memory_exceeded, $this );
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* See if the batch limits have been exceeded, which is when memory usage is almost at
|
198 |
+
* the maximum limit, or the time to process more actions will exceed the max time limit.
|
199 |
+
*
|
200 |
+
* Based on WC_Background_Process::batch_limits_exceeded()
|
201 |
+
*
|
202 |
+
* @param int $processed_actions The number of actions processed so far - used to determine the likelihood of exceeding the time limit if processing another action
|
203 |
+
* @return bool
|
204 |
+
*/
|
205 |
+
protected function batch_limits_exceeded( $processed_actions ) {
|
206 |
+
return $this->memory_exceeded() || $this->time_likely_to_be_exceeded( $processed_actions );
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Process actions in the queue.
|
211 |
+
*
|
212 |
+
* @author Jeremy Pry
|
213 |
+
* @return int The number of actions processed.
|
214 |
+
*/
|
215 |
+
abstract public function run();
|
216 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_Action.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_Action
|
5 |
+
*/
|
6 |
+
class ActionScheduler_Action {
|
7 |
+
protected $hook = '';
|
8 |
+
protected $args = array();
|
9 |
+
/** @var ActionScheduler_Schedule */
|
10 |
+
protected $schedule = NULL;
|
11 |
+
protected $group = '';
|
12 |
+
|
13 |
+
public function __construct( $hook, array $args = array(), ActionScheduler_Schedule $schedule = NULL, $group = '' ) {
|
14 |
+
$schedule = empty( $schedule ) ? new ActionScheduler_NullSchedule() : $schedule;
|
15 |
+
$this->set_hook($hook);
|
16 |
+
$this->set_schedule($schedule);
|
17 |
+
$this->set_args($args);
|
18 |
+
$this->set_group($group);
|
19 |
+
}
|
20 |
+
|
21 |
+
public function execute() {
|
22 |
+
return do_action_ref_array($this->get_hook(), $this->get_args());
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @param string $hook
|
27 |
+
*/
|
28 |
+
protected function set_hook( $hook ) {
|
29 |
+
$this->hook = $hook;
|
30 |
+
}
|
31 |
+
|
32 |
+
public function get_hook() {
|
33 |
+
return $this->hook;
|
34 |
+
}
|
35 |
+
|
36 |
+
protected function set_schedule( ActionScheduler_Schedule $schedule ) {
|
37 |
+
$this->schedule = $schedule;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @return ActionScheduler_Schedule
|
42 |
+
*/
|
43 |
+
public function get_schedule() {
|
44 |
+
return $this->schedule;
|
45 |
+
}
|
46 |
+
|
47 |
+
protected function set_args( array $args ) {
|
48 |
+
$this->args = $args;
|
49 |
+
}
|
50 |
+
|
51 |
+
public function get_args() {
|
52 |
+
return $this->args;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* @param string $group
|
57 |
+
*/
|
58 |
+
protected function set_group( $group ) {
|
59 |
+
$this->group = $group;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @return string
|
64 |
+
*/
|
65 |
+
public function get_group() {
|
66 |
+
return $this->group;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @return bool If the action has been finished
|
71 |
+
*/
|
72 |
+
public function is_finished() {
|
73 |
+
return FALSE;
|
74 |
+
}
|
75 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_ActionClaim.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_ActionClaim
|
5 |
+
*/
|
6 |
+
class ActionScheduler_ActionClaim {
|
7 |
+
private $id = '';
|
8 |
+
private $action_ids = array();
|
9 |
+
|
10 |
+
public function __construct( $id, array $action_ids ) {
|
11 |
+
$this->id = $id;
|
12 |
+
$this->action_ids = $action_ids;
|
13 |
+
}
|
14 |
+
|
15 |
+
public function get_id() {
|
16 |
+
return $this->id;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function get_actions() {
|
20 |
+
return $this->action_ids;
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_ActionFactory.php
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_ActionFactory
|
5 |
+
*/
|
6 |
+
class ActionScheduler_ActionFactory {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* @param string $status The action's status in the data store
|
10 |
+
* @param string $hook The hook to trigger when this action runs
|
11 |
+
* @param array $args Args to pass to callbacks when the hook is triggered
|
12 |
+
* @param ActionScheduler_Schedule $schedule The action's schedule
|
13 |
+
* @param string $group A group to put the action in
|
14 |
+
*
|
15 |
+
* @return ActionScheduler_Action An instance of the stored action
|
16 |
+
*/
|
17 |
+
public function get_stored_action( $status, $hook, array $args = array(), ActionScheduler_Schedule $schedule = null, $group = '' ) {
|
18 |
+
|
19 |
+
switch ( $status ) {
|
20 |
+
case ActionScheduler_Store::STATUS_PENDING :
|
21 |
+
$action_class = 'ActionScheduler_Action';
|
22 |
+
break;
|
23 |
+
case ActionScheduler_Store::STATUS_CANCELED :
|
24 |
+
$action_class = 'ActionScheduler_CanceledAction';
|
25 |
+
break;
|
26 |
+
default :
|
27 |
+
$action_class = 'ActionScheduler_FinishedAction';
|
28 |
+
break;
|
29 |
+
}
|
30 |
+
|
31 |
+
$action_class = apply_filters( 'action_scheduler_stored_action_class', $action_class, $status, $hook, $args, $schedule, $group );
|
32 |
+
|
33 |
+
$action = new $action_class( $hook, $args, $schedule, $group );
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Allow 3rd party code to change the instantiated action for a given hook, args, schedule and group.
|
37 |
+
*
|
38 |
+
* @param ActionScheduler_Action $action The instantiated action.
|
39 |
+
* @param string $hook The instantiated action's hook.
|
40 |
+
* @param array $args The instantiated action's args.
|
41 |
+
* @param ActionScheduler_Schedule $schedule The instantiated action's schedule.
|
42 |
+
* @param string $group The instantiated action's group.
|
43 |
+
*/
|
44 |
+
return apply_filters( 'action_scheduler_stored_action_instance', $action, $hook, $args, $schedule, $group );
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @param string $hook The hook to trigger when this action runs
|
49 |
+
* @param array $args Args to pass when the hook is triggered
|
50 |
+
* @param int $when Unix timestamp when the action will run
|
51 |
+
* @param string $group A group to put the action in
|
52 |
+
*
|
53 |
+
* @return string The ID of the stored action
|
54 |
+
*/
|
55 |
+
public function single( $hook, $args = array(), $when = null, $group = '' ) {
|
56 |
+
$date = as_get_datetime_object( $when );
|
57 |
+
$schedule = new ActionScheduler_SimpleSchedule( $date );
|
58 |
+
$action = new ActionScheduler_Action( $hook, $args, $schedule, $group );
|
59 |
+
return $this->store( $action );
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @param string $hook The hook to trigger when this action runs
|
64 |
+
* @param array $args Args to pass when the hook is triggered
|
65 |
+
* @param int $first Unix timestamp for the first run
|
66 |
+
* @param int $interval Seconds between runs
|
67 |
+
* @param string $group A group to put the action in
|
68 |
+
*
|
69 |
+
* @return string The ID of the stored action
|
70 |
+
*/
|
71 |
+
public function recurring( $hook, $args = array(), $first = null, $interval = null, $group = '' ) {
|
72 |
+
if ( empty($interval) ) {
|
73 |
+
return $this->single( $hook, $args, $first, $group );
|
74 |
+
}
|
75 |
+
$date = as_get_datetime_object( $first );
|
76 |
+
$schedule = new ActionScheduler_IntervalSchedule( $date, $interval );
|
77 |
+
$action = new ActionScheduler_Action( $hook, $args, $schedule, $group );
|
78 |
+
return $this->store( $action );
|
79 |
+
}
|
80 |
+
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @param string $hook The hook to trigger when this action runs
|
84 |
+
* @param array $args Args to pass when the hook is triggered
|
85 |
+
* @param int $first Unix timestamp for the first run
|
86 |
+
* @param int $schedule A cron definition string
|
87 |
+
* @param string $group A group to put the action in
|
88 |
+
*
|
89 |
+
* @return string The ID of the stored action
|
90 |
+
*/
|
91 |
+
public function cron( $hook, $args = array(), $first = null, $schedule = null, $group = '' ) {
|
92 |
+
if ( empty($schedule) ) {
|
93 |
+
return $this->single( $hook, $args, $first, $group );
|
94 |
+
}
|
95 |
+
$date = as_get_datetime_object( $first );
|
96 |
+
$cron = CronExpression::factory( $schedule );
|
97 |
+
$schedule = new ActionScheduler_CronSchedule( $date, $cron );
|
98 |
+
$action = new ActionScheduler_Action( $hook, $args, $schedule, $group );
|
99 |
+
return $this->store( $action );
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* @param ActionScheduler_Action $action
|
104 |
+
*
|
105 |
+
* @return string The ID of the stored action
|
106 |
+
*/
|
107 |
+
protected function store( ActionScheduler_Action $action ) {
|
108 |
+
$store = ActionScheduler_Store::instance();
|
109 |
+
return $store->save_action( $action );
|
110 |
+
}
|
111 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_AdminView.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_AdminView
|
5 |
+
* @codeCoverageIgnore
|
6 |
+
*/
|
7 |
+
class ActionScheduler_AdminView extends ActionScheduler_AdminView_Deprecated {
|
8 |
+
|
9 |
+
private static $admin_view = NULL;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @return ActionScheduler_QueueRunner
|
13 |
+
* @codeCoverageIgnore
|
14 |
+
*/
|
15 |
+
public static function instance() {
|
16 |
+
|
17 |
+
if ( empty( self::$admin_view ) ) {
|
18 |
+
$class = apply_filters('action_scheduler_admin_view_class', 'ActionScheduler_AdminView');
|
19 |
+
self::$admin_view = new $class();
|
20 |
+
}
|
21 |
+
|
22 |
+
return self::$admin_view;
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @codeCoverageIgnore
|
27 |
+
*/
|
28 |
+
public function init() {
|
29 |
+
if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || false == DOING_AJAX ) ) {
|
30 |
+
|
31 |
+
if ( class_exists( 'WooCommerce' ) ) {
|
32 |
+
add_action( 'woocommerce_admin_status_content_action-scheduler', array( $this, 'render_admin_ui' ) );
|
33 |
+
add_filter( 'woocommerce_admin_status_tabs', array( $this, 'register_system_status_tab' ) );
|
34 |
+
}
|
35 |
+
|
36 |
+
add_action( 'admin_menu', array( $this, 'register_menu' ) );
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Registers action-scheduler into WooCommerce > System status.
|
43 |
+
*
|
44 |
+
* @param array $tabs An associative array of tab key => label.
|
45 |
+
* @return array $tabs An associative array of tab key => label, including Action Scheduler's tabs
|
46 |
+
*/
|
47 |
+
public function register_system_status_tab( array $tabs ) {
|
48 |
+
$tabs['action-scheduler'] = __( 'Scheduled Actions', 'action-scheduler' );
|
49 |
+
|
50 |
+
return $tabs;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Include Action Scheduler's administration under the Tools menu.
|
55 |
+
*
|
56 |
+
* A menu under the Tools menu is important for backward compatibility (as that's
|
57 |
+
* where it started), and also provides more convenient access than the WooCommerce
|
58 |
+
* System Status page, and for sites where WooCommerce isn't active.
|
59 |
+
*/
|
60 |
+
public function register_menu() {
|
61 |
+
add_submenu_page(
|
62 |
+
'tools.php',
|
63 |
+
__( 'Scheduled Actions', 'action-scheduler' ),
|
64 |
+
__( 'Scheduled Actions', 'action-scheduler' ),
|
65 |
+
'manage_options',
|
66 |
+
'action-scheduler',
|
67 |
+
array( $this, 'render_admin_ui' )
|
68 |
+
);
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Renders the Admin UI
|
73 |
+
*/
|
74 |
+
public function render_admin_ui() {
|
75 |
+
$table = new ActionScheduler_ListTable( ActionScheduler::store(), ActionScheduler::logger(), ActionScheduler::runner() );
|
76 |
+
$table->display_page();
|
77 |
+
}
|
78 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_CanceledAction.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_CanceledAction
|
5 |
+
*
|
6 |
+
* Stored action which was canceled and therefore acts like a finished action but should always return a null schedule,
|
7 |
+
* regardless of schedule passed to its constructor.
|
8 |
+
*/
|
9 |
+
class ActionScheduler_CanceledAction extends ActionScheduler_FinishedAction {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @param string $hook
|
13 |
+
* @param array $args
|
14 |
+
* @param ActionScheduler_Schedule $schedule
|
15 |
+
* @param string $group
|
16 |
+
*/
|
17 |
+
public function __construct( $hook, array $args = array(), ActionScheduler_Schedule $schedule = null, $group = '' ) {
|
18 |
+
parent::__construct( $hook, $args, $schedule, $group );
|
19 |
+
$this->set_schedule( new ActionScheduler_NullSchedule() );
|
20 |
+
}
|
21 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_Compatibility.php
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_Compatibility
|
5 |
+
*/
|
6 |
+
class ActionScheduler_Compatibility {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Converts a shorthand byte value to an integer byte value.
|
10 |
+
*
|
11 |
+
* Wrapper for wp_convert_hr_to_bytes(), moved to load.php in WordPress 4.6 from media.php
|
12 |
+
*
|
13 |
+
* @link https://secure.php.net/manual/en/function.ini-get.php
|
14 |
+
* @link https://secure.php.net/manual/en/faq.using.php#faq.using.shorthandbytes
|
15 |
+
*
|
16 |
+
* @param string $value A (PHP ini) byte value, either shorthand or ordinary.
|
17 |
+
* @return int An integer byte value.
|
18 |
+
*/
|
19 |
+
public static function convert_hr_to_bytes( $value ) {
|
20 |
+
if ( function_exists( 'wp_convert_hr_to_bytes' ) ) {
|
21 |
+
return wp_convert_hr_to_bytes( $value );
|
22 |
+
}
|
23 |
+
|
24 |
+
$value = strtolower( trim( $value ) );
|
25 |
+
$bytes = (int) $value;
|
26 |
+
|
27 |
+
if ( false !== strpos( $value, 'g' ) ) {
|
28 |
+
$bytes *= GB_IN_BYTES;
|
29 |
+
} elseif ( false !== strpos( $value, 'm' ) ) {
|
30 |
+
$bytes *= MB_IN_BYTES;
|
31 |
+
} elseif ( false !== strpos( $value, 'k' ) ) {
|
32 |
+
$bytes *= KB_IN_BYTES;
|
33 |
+
}
|
34 |
+
|
35 |
+
// Deal with large (float) values which run into the maximum integer size.
|
36 |
+
return min( $bytes, PHP_INT_MAX );
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Attempts to raise the PHP memory limit for memory intensive processes.
|
41 |
+
*
|
42 |
+
* Only allows raising the existing limit and prevents lowering it.
|
43 |
+
*
|
44 |
+
* Wrapper for wp_raise_memory_limit(), added in WordPress v4.6.0
|
45 |
+
*
|
46 |
+
* @return bool|int|string The limit that was set or false on failure.
|
47 |
+
*/
|
48 |
+
public static function raise_memory_limit() {
|
49 |
+
if ( function_exists( 'wp_raise_memory_limit' ) ) {
|
50 |
+
return wp_raise_memory_limit( 'admin' );
|
51 |
+
}
|
52 |
+
|
53 |
+
$current_limit = @ini_get( 'memory_limit' );
|
54 |
+
$current_limit_int = self::convert_hr_to_bytes( $current_limit );
|
55 |
+
|
56 |
+
if ( -1 === $current_limit_int ) {
|
57 |
+
return false;
|
58 |
+
}
|
59 |
+
|
60 |
+
$wp_max_limit = WP_MAX_MEMORY_LIMIT;
|
61 |
+
$wp_max_limit_int = self::convert_hr_to_bytes( $wp_max_limit );
|
62 |
+
$filtered_limit = apply_filters( 'admin_memory_limit', $wp_max_limit );
|
63 |
+
$filtered_limit_int = self::convert_hr_to_bytes( $filtered_limit );
|
64 |
+
|
65 |
+
if ( -1 === $filtered_limit_int || ( $filtered_limit_int > $wp_max_limit_int && $filtered_limit_int > $current_limit_int ) ) {
|
66 |
+
if ( false !== @ini_set( 'memory_limit', $filtered_limit ) ) {
|
67 |
+
return $filtered_limit;
|
68 |
+
} else {
|
69 |
+
return false;
|
70 |
+
}
|
71 |
+
} elseif ( -1 === $wp_max_limit_int || $wp_max_limit_int > $current_limit_int ) {
|
72 |
+
if ( false !== @ini_set( 'memory_limit', $wp_max_limit ) ) {
|
73 |
+
return $wp_max_limit;
|
74 |
+
} else {
|
75 |
+
return false;
|
76 |
+
}
|
77 |
+
}
|
78 |
+
return false;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Attempts to raise the PHP timeout for time intensive processes.
|
83 |
+
*
|
84 |
+
* Only allows raising the existing limit and prevents lowering it. Wrapper for wc_set_time_limit(), when available.
|
85 |
+
*
|
86 |
+
* @param int The time limit in seconds.
|
87 |
+
*/
|
88 |
+
public static function raise_time_limit( $limit = 0 ) {
|
89 |
+
if ( $limit < ini_get( 'max_execution_time' ) ) {
|
90 |
+
return;
|
91 |
+
}
|
92 |
+
|
93 |
+
if ( function_exists( 'wc_set_time_limit' ) ) {
|
94 |
+
wc_set_time_limit( $limit );
|
95 |
+
} elseif ( function_exists( 'set_time_limit' ) && false === strpos( ini_get( 'disable_functions' ), 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
|
96 |
+
@set_time_limit( $limit );
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_CronSchedule.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_CronSchedule
|
5 |
+
*/
|
6 |
+
class ActionScheduler_CronSchedule implements ActionScheduler_Schedule {
|
7 |
+
/** @var DateTime */
|
8 |
+
private $start = NULL;
|
9 |
+
private $start_timestamp = 0;
|
10 |
+
/** @var CronExpression */
|
11 |
+
private $cron = NULL;
|
12 |
+
|
13 |
+
public function __construct( DateTime $start, CronExpression $cron ) {
|
14 |
+
$this->start = $start;
|
15 |
+
$this->cron = $cron;
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @param DateTime $after
|
20 |
+
* @return DateTime|null
|
21 |
+
*/
|
22 |
+
public function next( DateTime $after = NULL ) {
|
23 |
+
$after = empty($after) ? clone $this->start : clone $after;
|
24 |
+
return $this->cron->getNextRunDate($after, 0, false);
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @return bool
|
29 |
+
*/
|
30 |
+
public function is_recurring() {
|
31 |
+
return true;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* For PHP 5.2 compat, since DateTime objects can't be serialized
|
36 |
+
* @return array
|
37 |
+
*/
|
38 |
+
public function __sleep() {
|
39 |
+
$this->start_timestamp = $this->start->getTimestamp();
|
40 |
+
return array(
|
41 |
+
'start_timestamp',
|
42 |
+
'cron'
|
43 |
+
);
|
44 |
+
}
|
45 |
+
|
46 |
+
public function __wakeup() {
|
47 |
+
$this->start = as_get_datetime_object($this->start_timestamp);
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_DateTime.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* ActionScheduler DateTime class.
|
5 |
+
*
|
6 |
+
* This is a custom extension to DateTime that
|
7 |
+
*/
|
8 |
+
class ActionScheduler_DateTime extends DateTime {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* UTC offset.
|
12 |
+
*
|
13 |
+
* Only used when a timezone is not set. When a timezone string is
|
14 |
+
* used, this will be set to 0.
|
15 |
+
*
|
16 |
+
* @var int
|
17 |
+
*/
|
18 |
+
protected $utcOffset = 0;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Get the unix timestamp of the current object.
|
22 |
+
*
|
23 |
+
* Missing in PHP 5.2 so just here so it can be supported consistently.
|
24 |
+
*
|
25 |
+
* @return int
|
26 |
+
*/
|
27 |
+
public function getTimestamp() {
|
28 |
+
return method_exists( 'DateTime', 'getTimestamp' ) ? parent::getTimestamp() : $this->format( 'U' );
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Set the UTC offset.
|
33 |
+
*
|
34 |
+
* This represents a fixed offset instead of a timezone setting.
|
35 |
+
*
|
36 |
+
* @param $offset
|
37 |
+
*/
|
38 |
+
public function setUtcOffset( $offset ) {
|
39 |
+
$this->utcOffset = intval( $offset );
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Returns the timezone offset.
|
44 |
+
*
|
45 |
+
* @return int
|
46 |
+
* @link http://php.net/manual/en/datetime.getoffset.php
|
47 |
+
*/
|
48 |
+
public function getOffset() {
|
49 |
+
return $this->utcOffset ? $this->utcOffset : parent::getOffset();
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Set the TimeZone associated with the DateTime
|
54 |
+
*
|
55 |
+
* @param DateTimeZone $timezone
|
56 |
+
*
|
57 |
+
* @return static
|
58 |
+
* @link http://php.net/manual/en/datetime.settimezone.php
|
59 |
+
*/
|
60 |
+
public function setTimezone( $timezone ) {
|
61 |
+
$this->utcOffset = 0;
|
62 |
+
parent::setTimezone( $timezone );
|
63 |
+
|
64 |
+
return $this;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Get the timestamp with the WordPress timezone offset added or subtracted.
|
69 |
+
*
|
70 |
+
* @since 3.0.0
|
71 |
+
* @return int
|
72 |
+
*/
|
73 |
+
public function getOffsetTimestamp() {
|
74 |
+
return $this->getTimestamp() + $this->getOffset();
|
75 |
+
}
|
76 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_Exception.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* ActionScheduler Exception Interface.
|
5 |
+
*
|
6 |
+
* Facilitates catching Exceptions unique to Action Scheduler.
|
7 |
+
*
|
8 |
+
* @package Prospress\ActionScheduler
|
9 |
+
* @since %VERSION%
|
10 |
+
*/
|
11 |
+
interface ActionScheduler_Exception {}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_FatalErrorMonitor.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_FatalErrorMonitor
|
5 |
+
*/
|
6 |
+
class ActionScheduler_FatalErrorMonitor {
|
7 |
+
/** @var ActionScheduler_ActionClaim */
|
8 |
+
private $claim = NULL;
|
9 |
+
/** @var ActionScheduler_Store */
|
10 |
+
private $store = NULL;
|
11 |
+
private $action_id = 0;
|
12 |
+
|
13 |
+
public function __construct( ActionScheduler_Store $store ) {
|
14 |
+
$this->store = $store;
|
15 |
+
}
|
16 |
+
|
17 |
+
public function attach( ActionScheduler_ActionClaim $claim ) {
|
18 |
+
$this->claim = $claim;
|
19 |
+
add_action( 'shutdown', array( $this, 'handle_unexpected_shutdown' ) );
|
20 |
+
add_action( 'action_scheduler_before_execute', array( $this, 'track_current_action' ), 0, 1 );
|
21 |
+
add_action( 'action_scheduler_after_execute', array( $this, 'untrack_action' ), 0, 0 );
|
22 |
+
add_action( 'action_scheduler_execution_ignored', array( $this, 'untrack_action' ), 0, 0 );
|
23 |
+
add_action( 'action_scheduler_failed_execution', array( $this, 'untrack_action' ), 0, 0 );
|
24 |
+
}
|
25 |
+
|
26 |
+
public function detach() {
|
27 |
+
$this->claim = NULL;
|
28 |
+
$this->untrack_action();
|
29 |
+
remove_action( 'shutdown', array( $this, 'handle_unexpected_shutdown' ) );
|
30 |
+
remove_action( 'action_scheduler_before_execute', array( $this, 'track_current_action' ), 0 );
|
31 |
+
remove_action( 'action_scheduler_after_execute', array( $this, 'untrack_action' ), 0 );
|
32 |
+
remove_action( 'action_scheduler_execution_ignored', array( $this, 'untrack_action' ), 0 );
|
33 |
+
remove_action( 'action_scheduler_failed_execution', array( $this, 'untrack_action' ), 0 );
|
34 |
+
}
|
35 |
+
|
36 |
+
public function track_current_action( $action_id ) {
|
37 |
+
$this->action_id = $action_id;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function untrack_action() {
|
41 |
+
$this->action_id = 0;
|
42 |
+
}
|
43 |
+
|
44 |
+
public function handle_unexpected_shutdown() {
|
45 |
+
if ( $error = error_get_last() ) {
|
46 |
+
if ( in_array( $error['type'], array( E_ERROR, E_PARSE, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR ) ) ) {
|
47 |
+
if ( !empty($this->action_id) ) {
|
48 |
+
$this->store->mark_failure( $this->action_id );
|
49 |
+
do_action( 'action_scheduler_unexpected_shutdown', $this->action_id, $error );
|
50 |
+
}
|
51 |
+
}
|
52 |
+
$this->store->release_claim( $this->claim );
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_FinishedAction.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_FinishedAction
|
5 |
+
*/
|
6 |
+
class ActionScheduler_FinishedAction extends ActionScheduler_Action {
|
7 |
+
|
8 |
+
public function execute() {
|
9 |
+
// don't execute
|
10 |
+
}
|
11 |
+
|
12 |
+
public function is_finished() {
|
13 |
+
return TRUE;
|
14 |
+
}
|
15 |
+
}
|
16 |
+
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_IntervalSchedule.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_IntervalSchedule
|
5 |
+
*/
|
6 |
+
class ActionScheduler_IntervalSchedule implements ActionScheduler_Schedule {
|
7 |
+
/** @var DateTime */
|
8 |
+
private $start = NULL;
|
9 |
+
private $start_timestamp = 0;
|
10 |
+
private $interval_in_seconds = 0;
|
11 |
+
|
12 |
+
public function __construct( DateTime $start, $interval ) {
|
13 |
+
$this->start = $start;
|
14 |
+
$this->interval_in_seconds = (int)$interval;
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @param DateTime $after
|
19 |
+
*
|
20 |
+
* @return DateTime|null
|
21 |
+
*/
|
22 |
+
public function next( DateTime $after = NULL ) {
|
23 |
+
$after = empty($after) ? as_get_datetime_object('@0') : clone $after;
|
24 |
+
if ( $after > $this->start ) {
|
25 |
+
$after->modify('+'.$this->interval_in_seconds.' seconds');
|
26 |
+
return $after;
|
27 |
+
}
|
28 |
+
return clone $this->start;
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @return bool
|
33 |
+
*/
|
34 |
+
public function is_recurring() {
|
35 |
+
return true;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @param DateTime $after
|
40 |
+
*
|
41 |
+
* @return DateTime|null
|
42 |
+
*/
|
43 |
+
public function interval_in_seconds() {
|
44 |
+
return $this->interval_in_seconds;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* For PHP 5.2 compat, since DateTime objects can't be serialized
|
49 |
+
* @return array
|
50 |
+
*/
|
51 |
+
public function __sleep() {
|
52 |
+
$this->start_timestamp = $this->start->getTimestamp();
|
53 |
+
return array(
|
54 |
+
'start_timestamp',
|
55 |
+
'interval_in_seconds'
|
56 |
+
);
|
57 |
+
}
|
58 |
+
|
59 |
+
public function __wakeup() {
|
60 |
+
$this->start = as_get_datetime_object($this->start_timestamp);
|
61 |
+
}
|
62 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_InvalidActionException.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* InvalidAction Exception.
|
5 |
+
*
|
6 |
+
* Used for identifying actions that are invalid in some way.
|
7 |
+
*
|
8 |
+
* @package Prospress\ActionScheduler
|
9 |
+
*/
|
10 |
+
class ActionScheduler_InvalidActionException extends \InvalidArgumentException implements ActionScheduler_Exception {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Create a new exception when the action's args cannot be decoded to an array.
|
14 |
+
*
|
15 |
+
* @author Jeremy Pry
|
16 |
+
*
|
17 |
+
* @param string $action_id The action ID with bad args.
|
18 |
+
* @return static
|
19 |
+
*/
|
20 |
+
public static function from_decoding_args( $action_id ) {
|
21 |
+
$message = sprintf(
|
22 |
+
__( 'Action [%s] has invalid arguments. It cannot be JSON decoded to an array.', 'action-scheduler' ),
|
23 |
+
$action_id
|
24 |
+
);
|
25 |
+
|
26 |
+
return new static( $message );
|
27 |
+
}
|
28 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_ListTable.php
ADDED
@@ -0,0 +1,526 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Implements the admin view of the actions.
|
5 |
+
* @codeCoverageIgnore
|
6 |
+
*/
|
7 |
+
class ActionScheduler_ListTable extends ActionScheduler_Abstract_ListTable {
|
8 |
+
|
9 |
+
/**
|
10 |
+
* The package name.
|
11 |
+
*
|
12 |
+
* @var string
|
13 |
+
*/
|
14 |
+
protected $package = 'action-scheduler';
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Columns to show (name => label).
|
18 |
+
*
|
19 |
+
* @var array
|
20 |
+
*/
|
21 |
+
protected $columns = array();
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Actions (name => label).
|
25 |
+
*
|
26 |
+
* @var array
|
27 |
+
*/
|
28 |
+
protected $row_actions = array();
|
29 |
+
|
30 |
+
/**
|
31 |
+
* The active data stores
|
32 |
+
*
|
33 |
+
* @var ActionScheduler_Store
|
34 |
+
*/
|
35 |
+
protected $store;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* A logger to use for getting action logs to display
|
39 |
+
*
|
40 |
+
* @var ActionScheduler_Logger
|
41 |
+
*/
|
42 |
+
protected $logger;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* A ActionScheduler_QueueRunner runner instance (or child class)
|
46 |
+
*
|
47 |
+
* @var ActionScheduler_QueueRunner
|
48 |
+
*/
|
49 |
+
protected $runner;
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Bulk actions. The key of the array is the method name of the implementation:
|
53 |
+
*
|
54 |
+
* bulk_<key>(array $ids, string $sql_in).
|
55 |
+
*
|
56 |
+
* See the comments in the parent class for further details
|
57 |
+
*
|
58 |
+
* @var array
|
59 |
+
*/
|
60 |
+
protected $bulk_actions = array();
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Flag variable to render our notifications, if any, once.
|
64 |
+
*
|
65 |
+
* @var bool
|
66 |
+
*/
|
67 |
+
protected static $did_notification = false;
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Array of seconds for common time periods, like week or month, alongside an internationalised string representation, i.e. "Day" or "Days"
|
71 |
+
*
|
72 |
+
* @var array
|
73 |
+
*/
|
74 |
+
private static $time_periods;
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Sets the current data store object into `store->action` and initialises the object.
|
78 |
+
*
|
79 |
+
* @param ActionScheduler_Store $store
|
80 |
+
* @param ActionScheduler_Logger $logger
|
81 |
+
* @param ActionScheduler_QueueRunner $runner
|
82 |
+
*/
|
83 |
+
public function __construct( ActionScheduler_Store $store, ActionScheduler_Logger $logger, ActionScheduler_QueueRunner $runner ) {
|
84 |
+
|
85 |
+
$this->store = $store;
|
86 |
+
$this->logger = $logger;
|
87 |
+
$this->runner = $runner;
|
88 |
+
|
89 |
+
$this->table_header = __( 'Scheduled Actions', 'action-scheduler' );
|
90 |
+
|
91 |
+
$this->bulk_actions = array(
|
92 |
+
'delete' => __( 'Delete', 'action-scheduler' ),
|
93 |
+
);
|
94 |
+
|
95 |
+
$this->columns = array(
|
96 |
+
'hook' => __( 'Hook', 'action-scheduler' ),
|
97 |
+
'status' => __( 'Status', 'action-scheduler' ),
|
98 |
+
'args' => __( 'Arguments', 'action-scheduler' ),
|
99 |
+
'group' => __( 'Group', 'action-scheduler' ),
|
100 |
+
'recurrence' => __( 'Recurrence', 'action-scheduler' ),
|
101 |
+
'schedule' => __( 'Scheduled Date', 'action-scheduler' ),
|
102 |
+
'log_entries' => __( 'Log', 'action-scheduler' ),
|
103 |
+
);
|
104 |
+
|
105 |
+
$this->sort_by = array(
|
106 |
+
'schedule',
|
107 |
+
'hook',
|
108 |
+
'group',
|
109 |
+
);
|
110 |
+
|
111 |
+
$this->search_by = array(
|
112 |
+
'hook',
|
113 |
+
'args',
|
114 |
+
'claim_id',
|
115 |
+
);
|
116 |
+
|
117 |
+
$request_status = $this->get_request_status();
|
118 |
+
|
119 |
+
if ( empty( $request_status ) ) {
|
120 |
+
$this->sort_by[] = 'status';
|
121 |
+
} elseif ( in_array( $request_status, array( 'in-progress', 'failed' ) ) ) {
|
122 |
+
$this->columns += array( 'claim_id' => __( 'Claim ID', 'action-scheduler' ) );
|
123 |
+
$this->sort_by[] = 'claim_id';
|
124 |
+
}
|
125 |
+
|
126 |
+
$this->row_actions = array(
|
127 |
+
'hook' => array(
|
128 |
+
'run' => array(
|
129 |
+
'name' => __( 'Run', 'action-scheduler' ),
|
130 |
+
'desc' => __( 'Process the action now as if it were run as part of a queue', 'action-scheduler' ),
|
131 |
+
),
|
132 |
+
'cancel' => array(
|
133 |
+
'name' => __( 'Cancel', 'action-scheduler' ),
|
134 |
+
'desc' => __( 'Cancel the action now to avoid it being run in future', 'action-scheduler' ),
|
135 |
+
'class' => 'cancel trash',
|
136 |
+
),
|
137 |
+
),
|
138 |
+
);
|
139 |
+
|
140 |
+
self::$time_periods = array(
|
141 |
+
array(
|
142 |
+
'seconds' => YEAR_IN_SECONDS,
|
143 |
+
'names' => _n_noop( '%s year', '%s years', 'action-scheduler' ),
|
144 |
+
),
|
145 |
+
array(
|
146 |
+
'seconds' => MONTH_IN_SECONDS,
|
147 |
+
'names' => _n_noop( '%s month', '%s months', 'action-scheduler' ),
|
148 |
+
),
|
149 |
+
array(
|
150 |
+
'seconds' => WEEK_IN_SECONDS,
|
151 |
+
'names' => _n_noop( '%s week', '%s weeks', 'action-scheduler' ),
|
152 |
+
),
|
153 |
+
array(
|
154 |
+
'seconds' => DAY_IN_SECONDS,
|
155 |
+
'names' => _n_noop( '%s day', '%s days', 'action-scheduler' ),
|
156 |
+
),
|
157 |
+
array(
|
158 |
+
'seconds' => HOUR_IN_SECONDS,
|
159 |
+
'names' => _n_noop( '%s hour', '%s hours', 'action-scheduler' ),
|
160 |
+
),
|
161 |
+
array(
|
162 |
+
'seconds' => MINUTE_IN_SECONDS,
|
163 |
+
'names' => _n_noop( '%s minute', '%s minutes', 'action-scheduler' ),
|
164 |
+
),
|
165 |
+
array(
|
166 |
+
'seconds' => 1,
|
167 |
+
'names' => _n_noop( '%s second', '%s seconds', 'action-scheduler' ),
|
168 |
+
),
|
169 |
+
);
|
170 |
+
|
171 |
+
parent::__construct( array(
|
172 |
+
'singular' => 'action-scheduler',
|
173 |
+
'plural' => 'action-scheduler',
|
174 |
+
'ajax' => false,
|
175 |
+
) );
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Convert an interval of seconds into a two part human friendly string.
|
180 |
+
*
|
181 |
+
* The WordPress human_time_diff() function only calculates the time difference to one degree, meaning
|
182 |
+
* even if an action is 1 day and 11 hours away, it will display "1 day". This function goes one step
|
183 |
+
* further to display two degrees of accuracy.
|
184 |
+
*
|
185 |
+
* Inspired by the Crontrol::interval() function by Edward Dale: https://wordpress.org/plugins/wp-crontrol/
|
186 |
+
*
|
187 |
+
* @param int $interval A interval in seconds.
|
188 |
+
* @param int $periods_to_include Depth of time periods to include, e.g. for an interval of 70, and $periods_to_include of 2, both minutes and seconds would be included. With a value of 1, only minutes would be included.
|
189 |
+
* @return string A human friendly string representation of the interval.
|
190 |
+
*/
|
191 |
+
private static function human_interval( $interval, $periods_to_include = 2 ) {
|
192 |
+
|
193 |
+
if ( $interval <= 0 ) {
|
194 |
+
return __( 'Now!', 'action-scheduler' );
|
195 |
+
}
|
196 |
+
|
197 |
+
$output = '';
|
198 |
+
|
199 |
+
for ( $time_period_index = 0, $periods_included = 0, $seconds_remaining = $interval; $time_period_index < count( self::$time_periods ) && $seconds_remaining > 0 && $periods_included < $periods_to_include; $time_period_index++ ) {
|
200 |
+
|
201 |
+
$periods_in_interval = floor( $seconds_remaining / self::$time_periods[ $time_period_index ]['seconds'] );
|
202 |
+
|
203 |
+
if ( $periods_in_interval > 0 ) {
|
204 |
+
if ( ! empty( $output ) ) {
|
205 |
+
$output .= ' ';
|
206 |
+
}
|
207 |
+
$output .= sprintf( _n( self::$time_periods[ $time_period_index ]['names'][0], self::$time_periods[ $time_period_index ]['names'][1], $periods_in_interval, 'action-scheduler' ), $periods_in_interval );
|
208 |
+
$seconds_remaining -= $periods_in_interval * self::$time_periods[ $time_period_index ]['seconds'];
|
209 |
+
$periods_included++;
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
return $output;
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Returns the recurrence of an action or 'Non-repeating'. The output is human readable.
|
218 |
+
*
|
219 |
+
* @param ActionScheduler_Action $action
|
220 |
+
*
|
221 |
+
* @return string
|
222 |
+
*/
|
223 |
+
protected function get_recurrence( $action ) {
|
224 |
+
$recurrence = $action->get_schedule();
|
225 |
+
if ( method_exists( $recurrence, 'interval_in_seconds' ) ) {
|
226 |
+
return sprintf( __( 'Every %s', 'action-scheduler' ), self::human_interval( $recurrence->interval_in_seconds() ) );
|
227 |
+
}
|
228 |
+
return __( 'Non-repeating', 'action-scheduler' );
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Serializes the argument of an action to render it in a human friendly format.
|
233 |
+
*
|
234 |
+
* @param array $row The array representation of the current row of the table
|
235 |
+
*
|
236 |
+
* @return string
|
237 |
+
*/
|
238 |
+
public function column_args( array $row ) {
|
239 |
+
if ( empty( $row['args'] ) ) {
|
240 |
+
return '';
|
241 |
+
}
|
242 |
+
|
243 |
+
$row_html = '<ul>';
|
244 |
+
foreach ( $row['args'] as $key => $value ) {
|
245 |
+
$row_html .= sprintf( '<li><code>%s => %s</code></li>', esc_html( var_export( $key, true ) ), esc_html( var_export( $value, true ) ) );
|
246 |
+
}
|
247 |
+
$row_html .= '</ul>';
|
248 |
+
|
249 |
+
return apply_filters( 'action_scheduler_list_table_column_args', $row_html, $row );
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Prints the logs entries inline. We do so to avoid loading Javascript and other hacks to show it in a modal.
|
254 |
+
*
|
255 |
+
* @param array $row Action array.
|
256 |
+
* @return string
|
257 |
+
*/
|
258 |
+
public function column_log_entries( array $row ) {
|
259 |
+
|
260 |
+
$log_entries_html = '<ol>';
|
261 |
+
|
262 |
+
$timezone = new DateTimezone( 'UTC' );
|
263 |
+
|
264 |
+
foreach ( $row['log_entries'] as $log_entry ) {
|
265 |
+
$log_entries_html .= $this->get_log_entry_html( $log_entry, $timezone );
|
266 |
+
}
|
267 |
+
|
268 |
+
$log_entries_html .= '</ol>';
|
269 |
+
|
270 |
+
return $log_entries_html;
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Prints the logs entries inline. We do so to avoid loading Javascript and other hacks to show it in a modal.
|
275 |
+
*
|
276 |
+
* @param ActionScheduler_LogEntry $log_entry
|
277 |
+
* @param DateTimezone $timezone
|
278 |
+
* @return string
|
279 |
+
*/
|
280 |
+
protected function get_log_entry_html( ActionScheduler_LogEntry $log_entry, DateTimezone $timezone ) {
|
281 |
+
$date = $log_entry->get_date();
|
282 |
+
$date->setTimezone( $timezone );
|
283 |
+
return sprintf( '<li><strong>%s</strong><br/>%s</li>', esc_html( $date->format( 'Y-m-d H:i:s e' ) ), esc_html( $log_entry->get_message() ) );
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Only display row actions for pending actions.
|
288 |
+
*
|
289 |
+
* @param array $row Row to render
|
290 |
+
* @param string $column_name Current row
|
291 |
+
*
|
292 |
+
* @return string
|
293 |
+
*/
|
294 |
+
protected function maybe_render_actions( $row, $column_name ) {
|
295 |
+
if ( 'pending' === strtolower( $row['status'] ) ) {
|
296 |
+
return parent::maybe_render_actions( $row, $column_name );
|
297 |
+
}
|
298 |
+
|
299 |
+
return '';
|
300 |
+
}
|
301 |
+
|
302 |
+
/**
|
303 |
+
* Renders admin notifications
|
304 |
+
*
|
305 |
+
* Notifications:
|
306 |
+
* 1. When the maximum number of tasks are being executed simultaneously
|
307 |
+
* 2. Notifications when a task us manually executed
|
308 |
+
*/
|
309 |
+
public function display_admin_notices() {
|
310 |
+
|
311 |
+
if ( $this->store->get_claim_count() >= $this->runner->get_allowed_concurrent_batches() ) {
|
312 |
+
$this->admin_notices[] = array(
|
313 |
+
'class' => 'updated',
|
314 |
+
'message' => sprintf( __( 'Maximum simultaneous batches already in progress (%s queues). No actions will be processed until the current batches are complete.', 'action-scheduler' ), $this->store->get_claim_count() ),
|
315 |
+
);
|
316 |
+
}
|
317 |
+
|
318 |
+
$notification = get_transient( 'action_scheduler_admin_notice' );
|
319 |
+
|
320 |
+
if ( is_array( $notification ) ) {
|
321 |
+
delete_transient( 'action_scheduler_admin_notice' );
|
322 |
+
|
323 |
+
$action = $this->store->fetch_action( $notification['action_id'] );
|
324 |
+
$action_hook_html = '<strong><code>' . $action->get_hook() . '</code></strong>';
|
325 |
+
if ( 1 == $notification['success'] ) {
|
326 |
+
$class = 'updated';
|
327 |
+
switch ( $notification['row_action_type'] ) {
|
328 |
+
case 'run' :
|
329 |
+
$action_message_html = sprintf( __( 'Successfully executed action: %s', 'action-scheduler' ), $action_hook_html );
|
330 |
+
break;
|
331 |
+
case 'cancel' :
|
332 |
+
$action_message_html = sprintf( __( 'Successfully canceled action: %s', 'action-scheduler' ), $action_hook_html );
|
333 |
+
break;
|
334 |
+
default :
|
335 |
+
$action_message_html = sprintf( __( 'Successfully processed change for action: %s', 'action-scheduler' ), $action_hook_html );
|
336 |
+
break;
|
337 |
+
}
|
338 |
+
} else {
|
339 |
+
$class = 'error';
|
340 |
+
$action_message_html = sprintf( __( 'Could not process change for action: "%s" (ID: %d). Error: %s', 'action-scheduler' ), $action_hook_html, esc_html( $notification['action_id'] ), esc_html( $notification['error_message'] ) );
|
341 |
+
}
|
342 |
+
|
343 |
+
$action_message_html = apply_filters( 'action_scheduler_admin_notice_html', $action_message_html, $action, $notification );
|
344 |
+
|
345 |
+
$this->admin_notices[] = array(
|
346 |
+
'class' => $class,
|
347 |
+
'message' => $action_message_html,
|
348 |
+
);
|
349 |
+
}
|
350 |
+
|
351 |
+
parent::display_admin_notices();
|
352 |
+
}
|
353 |
+
|
354 |
+
/**
|
355 |
+
* Prints the scheduled date in a human friendly format.
|
356 |
+
*
|
357 |
+
* @param array $row The array representation of the current row of the table
|
358 |
+
*
|
359 |
+
* @return string
|
360 |
+
*/
|
361 |
+
public function column_schedule( $row ) {
|
362 |
+
return $this->get_schedule_display_string( $row['schedule'] );
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Get the scheduled date in a human friendly format.
|
367 |
+
*
|
368 |
+
* @param ActionScheduler_Schedule $schedule
|
369 |
+
* @return string
|
370 |
+
*/
|
371 |
+
protected function get_schedule_display_string( ActionScheduler_Schedule $schedule ) {
|
372 |
+
|
373 |
+
$schedule_display_string = '';
|
374 |
+
|
375 |
+
if ( ! $schedule->next() ) {
|
376 |
+
return $schedule_display_string;
|
377 |
+
}
|
378 |
+
|
379 |
+
$next_timestamp = $schedule->next()->getTimestamp();
|
380 |
+
|
381 |
+
$schedule_display_string .= $schedule->next()->format( 'Y-m-d H:i:s e' );
|
382 |
+
$schedule_display_string .= '<br/>';
|
383 |
+
|
384 |
+
if ( gmdate( 'U' ) > $next_timestamp ) {
|
385 |
+
$schedule_display_string .= sprintf( __( ' (%s ago)', 'action-scheduler' ), self::human_interval( gmdate( 'U' ) - $next_timestamp ) );
|
386 |
+
} else {
|
387 |
+
$schedule_display_string .= sprintf( __( ' (%s)', 'action-scheduler' ), self::human_interval( $next_timestamp - gmdate( 'U' ) ) );
|
388 |
+
}
|
389 |
+
|
390 |
+
return $schedule_display_string;
|
391 |
+
}
|
392 |
+
|
393 |
+
/**
|
394 |
+
* Bulk delete
|
395 |
+
*
|
396 |
+
* Deletes actions based on their ID. This is the handler for the bulk delete. It assumes the data
|
397 |
+
* properly validated by the callee and it will delete the actions without any extra validation.
|
398 |
+
*
|
399 |
+
* @param array $ids
|
400 |
+
* @param string $ids_sql Inherited and unused
|
401 |
+
*/
|
402 |
+
protected function bulk_delete( array $ids, $ids_sql ) {
|
403 |
+
foreach ( $ids as $id ) {
|
404 |
+
$this->store->delete_action( $id );
|
405 |
+
}
|
406 |
+
}
|
407 |
+
|
408 |
+
/**
|
409 |
+
* Implements the logic behind running an action. ActionScheduler_Abstract_ListTable validates the request and their
|
410 |
+
* parameters are valid.
|
411 |
+
*
|
412 |
+
* @param int $action_id
|
413 |
+
*/
|
414 |
+
protected function row_action_cancel( $action_id ) {
|
415 |
+
$this->process_row_action( $action_id, 'cancel' );
|
416 |
+
}
|
417 |
+
|
418 |
+
/**
|
419 |
+
* Implements the logic behind running an action. ActionScheduler_Abstract_ListTable validates the request and their
|
420 |
+
* parameters are valid.
|
421 |
+
*
|
422 |
+
* @param int $action_id
|
423 |
+
*/
|
424 |
+
protected function row_action_run( $action_id ) {
|
425 |
+
$this->process_row_action( $action_id, 'run' );
|
426 |
+
}
|
427 |
+
|
428 |
+
/**
|
429 |
+
* Implements the logic behind processing an action once an action link is clicked on the list table.
|
430 |
+
*
|
431 |
+
* @param int $action_id
|
432 |
+
* @param string $row_action_type The type of action to perform on the action.
|
433 |
+
*/
|
434 |
+
protected function process_row_action( $action_id, $row_action_type ) {
|
435 |
+
try {
|
436 |
+
switch ( $row_action_type ) {
|
437 |
+
case 'run' :
|
438 |
+
$this->runner->process_action( $action_id );
|
439 |
+
break;
|
440 |
+
case 'cancel' :
|
441 |
+
$this->store->cancel_action( $action_id );
|
442 |
+
break;
|
443 |
+
}
|
444 |
+
$success = 1;
|
445 |
+
$error_message = '';
|
446 |
+
} catch ( Exception $e ) {
|
447 |
+
$success = 0;
|
448 |
+
$error_message = $e->getMessage();
|
449 |
+
}
|
450 |
+
|
451 |
+
set_transient( 'action_scheduler_admin_notice', compact( 'action_id', 'success', 'error_message', 'row_action_type' ), 30 );
|
452 |
+
}
|
453 |
+
|
454 |
+
/**
|
455 |
+
* {@inheritDoc}
|
456 |
+
*/
|
457 |
+
public function prepare_items() {
|
458 |
+
$this->process_bulk_action();
|
459 |
+
|
460 |
+
$this->process_row_actions();
|
461 |
+
|
462 |
+
if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
|
463 |
+
// _wp_http_referer is used only on bulk actions, we remove it to keep the $_GET shorter
|
464 |
+
wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
|
465 |
+
exit;
|
466 |
+
}
|
467 |
+
|
468 |
+
$this->prepare_column_headers();
|
469 |
+
|
470 |
+
$per_page = $this->get_items_per_page( $this->package . '_items_per_page', $this->items_per_page );
|
471 |
+
$query = array(
|
472 |
+
'per_page' => $per_page,
|
473 |
+
'offset' => $this->get_items_offset(),
|
474 |
+
'status' => $this->get_request_status(),
|
475 |
+
'orderby' => $this->get_request_orderby(),
|
476 |
+
'order' => $this->get_request_order(),
|
477 |
+
'search' => $this->get_request_search_query(),
|
478 |
+
);
|
479 |
+
|
480 |
+
$this->items = array();
|
481 |
+
|
482 |
+
$total_items = $this->store->query_actions( $query, 'count' );
|
483 |
+
|
484 |
+
$status_labels = $this->store->get_status_labels();
|
485 |
+
|
486 |
+
foreach ( $this->store->query_actions( $query ) as $action_id ) {
|
487 |
+
try {
|
488 |
+
$action = $this->store->fetch_action( $action_id );
|
489 |
+
} catch ( Exception $e ) {
|
490 |
+
continue;
|
491 |
+
}
|
492 |
+
$this->items[ $action_id ] = array(
|
493 |
+
'ID' => $action_id,
|
494 |
+
'hook' => $action->get_hook(),
|
495 |
+
'status' => $status_labels[ $this->store->get_status( $action_id ) ],
|
496 |
+
'args' => $action->get_args(),
|
497 |
+
'group' => $action->get_group(),
|
498 |
+
'log_entries' => $this->logger->get_logs( $action_id ),
|
499 |
+
'claim_id' => $this->store->get_claim_id( $action_id ),
|
500 |
+
'recurrence' => $this->get_recurrence( $action ),
|
501 |
+
'schedule' => $action->get_schedule(),
|
502 |
+
);
|
503 |
+
}
|
504 |
+
|
505 |
+
$this->set_pagination_args( array(
|
506 |
+
'total_items' => $total_items,
|
507 |
+
'per_page' => $per_page,
|
508 |
+
'total_pages' => ceil( $total_items / $per_page ),
|
509 |
+
) );
|
510 |
+
}
|
511 |
+
|
512 |
+
/**
|
513 |
+
* Prints the available statuses so the user can click to filter.
|
514 |
+
*/
|
515 |
+
protected function display_filter_by_status() {
|
516 |
+
$this->status_counts = $this->store->action_counts();
|
517 |
+
parent::display_filter_by_status();
|
518 |
+
}
|
519 |
+
|
520 |
+
/**
|
521 |
+
* Get the text to display in the search box on the list table.
|
522 |
+
*/
|
523 |
+
protected function get_search_box_button_text() {
|
524 |
+
return __( 'Search hook, args and claim ID', 'action-scheduler' );
|
525 |
+
}
|
526 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_LogEntry.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_LogEntry
|
5 |
+
*/
|
6 |
+
class ActionScheduler_LogEntry {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* @var int $action_id
|
10 |
+
*/
|
11 |
+
protected $action_id = '';
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var string $message
|
15 |
+
*/
|
16 |
+
protected $message = '';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var Datetime $date
|
20 |
+
*/
|
21 |
+
protected $date;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Constructor
|
25 |
+
*
|
26 |
+
* @param mixed $action_id Action ID
|
27 |
+
* @param string $message Message
|
28 |
+
* @param Datetime $date Datetime object with the time when this log entry was created. If this parameter is
|
29 |
+
* not provided a new Datetime object (with current time) will be created.
|
30 |
+
*/
|
31 |
+
public function __construct( $action_id, $message, $date = null ) {
|
32 |
+
|
33 |
+
/*
|
34 |
+
* ActionScheduler_wpCommentLogger::get_entry() previously passed a 3rd param of $comment->comment_type
|
35 |
+
* to ActionScheduler_LogEntry::__construct(), goodness knows why, and the Follow-up Emails plugin
|
36 |
+
* hard-codes loading its own version of ActionScheduler_wpCommentLogger with that out-dated method,
|
37 |
+
* goodness knows why, so we need to guard against that here instead of using a DateTime type declaration
|
38 |
+
* for the constructor's 3rd param of $date and causing a fatal error with older versions of FUE.
|
39 |
+
*/
|
40 |
+
if ( null !== $date && ! is_a( $date, 'DateTime' ) ) {
|
41 |
+
_doing_it_wrong( __METHOD__, 'The third parameter must be a valid DateTime instance, or null.', '2.0.0' );
|
42 |
+
$date = null;
|
43 |
+
}
|
44 |
+
|
45 |
+
$this->action_id = $action_id;
|
46 |
+
$this->message = $message;
|
47 |
+
$this->date = $date ? $date : new Datetime;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Returns the date when this log entry was created
|
52 |
+
*
|
53 |
+
* @return Datetime
|
54 |
+
*/
|
55 |
+
public function get_date() {
|
56 |
+
return $this->date;
|
57 |
+
}
|
58 |
+
|
59 |
+
public function get_action_id() {
|
60 |
+
return $this->action_id;
|
61 |
+
}
|
62 |
+
|
63 |
+
public function get_message() {
|
64 |
+
return $this->message;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_Logger.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_Logger
|
5 |
+
* @codeCoverageIgnore
|
6 |
+
*/
|
7 |
+
abstract class ActionScheduler_Logger {
|
8 |
+
private static $logger = NULL;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* @return ActionScheduler_Logger
|
12 |
+
*/
|
13 |
+
public static function instance() {
|
14 |
+
if ( empty(self::$logger) ) {
|
15 |
+
$class = apply_filters('action_scheduler_logger_class', 'ActionScheduler_wpCommentLogger');
|
16 |
+
self::$logger = new $class();
|
17 |
+
}
|
18 |
+
return self::$logger;
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @param string $action_id
|
23 |
+
* @param string $message
|
24 |
+
* @param DateTime $date
|
25 |
+
*
|
26 |
+
* @return string The log entry ID
|
27 |
+
*/
|
28 |
+
abstract public function log( $action_id, $message, DateTime $date = NULL );
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @param string $entry_id
|
32 |
+
*
|
33 |
+
* @return ActionScheduler_LogEntry
|
34 |
+
*/
|
35 |
+
abstract public function get_entry( $entry_id );
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @param string $action_id
|
39 |
+
*
|
40 |
+
* @return ActionScheduler_LogEntry[]
|
41 |
+
*/
|
42 |
+
abstract public function get_logs( $action_id );
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @codeCoverageIgnore
|
47 |
+
*/
|
48 |
+
public function init() {
|
49 |
+
add_action( 'action_scheduler_stored_action', array( $this, 'log_stored_action' ), 10, 1 );
|
50 |
+
add_action( 'action_scheduler_canceled_action', array( $this, 'log_canceled_action' ), 10, 1 );
|
51 |
+
add_action( 'action_scheduler_before_execute', array( $this, 'log_started_action' ), 10, 1 );
|
52 |
+
add_action( 'action_scheduler_after_execute', array( $this, 'log_completed_action' ), 10, 1 );
|
53 |
+
add_action( 'action_scheduler_failed_execution', array( $this, 'log_failed_action' ), 10, 2 );
|
54 |
+
add_action( 'action_scheduler_failed_action', array( $this, 'log_timed_out_action' ), 10, 2 );
|
55 |
+
add_action( 'action_scheduler_unexpected_shutdown', array( $this, 'log_unexpected_shutdown' ), 10, 2 );
|
56 |
+
add_action( 'action_scheduler_reset_action', array( $this, 'log_reset_action' ), 10, 1 );
|
57 |
+
add_action( 'action_scheduler_execution_ignored', array( $this, 'log_ignored_action' ), 10, 1 );
|
58 |
+
}
|
59 |
+
|
60 |
+
public function log_stored_action( $action_id ) {
|
61 |
+
$this->log( $action_id, __( 'action created', 'action-scheduler' ) );
|
62 |
+
}
|
63 |
+
|
64 |
+
public function log_canceled_action( $action_id ) {
|
65 |
+
$this->log( $action_id, __( 'action canceled', 'action-scheduler' ) );
|
66 |
+
}
|
67 |
+
|
68 |
+
public function log_started_action( $action_id ) {
|
69 |
+
$this->log( $action_id, __( 'action started', 'action-scheduler' ) );
|
70 |
+
}
|
71 |
+
|
72 |
+
public function log_completed_action( $action_id ) {
|
73 |
+
$this->log( $action_id, __( 'action complete', 'action-scheduler' ) );
|
74 |
+
}
|
75 |
+
|
76 |
+
public function log_failed_action( $action_id, \Exception $exception ) {
|
77 |
+
$this->log( $action_id, sprintf( __( 'action failed: %s', 'action-scheduler' ), $exception->getMessage() ) );
|
78 |
+
}
|
79 |
+
|
80 |
+
public function log_timed_out_action( $action_id, $timeout ) {
|
81 |
+
$this->log( $action_id, sprintf( __( 'action timed out after %s seconds', 'action-scheduler' ), $timeout ) );
|
82 |
+
}
|
83 |
+
|
84 |
+
public function log_unexpected_shutdown( $action_id, $error ) {
|
85 |
+
if ( ! empty( $error ) ) {
|
86 |
+
$this->log( $action_id, sprintf( __( 'unexpected shutdown: PHP Fatal error %s in %s on line %s', 'action-scheduler' ), $error['message'], $error['file'], $error['line'] ) );
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
public function log_reset_action( $action_id ) {
|
91 |
+
$this->log( $action_id, __( 'action reset', 'action_scheduler' ) );
|
92 |
+
}
|
93 |
+
|
94 |
+
public function log_ignored_action( $action_id ) {
|
95 |
+
$this->log( $action_id, __( 'action ignored', 'action-scheduler' ) );
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_NullAction.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_NullAction
|
5 |
+
*/
|
6 |
+
class ActionScheduler_NullAction extends ActionScheduler_Action {
|
7 |
+
|
8 |
+
public function __construct( $hook = '', array $args = array(), ActionScheduler_Schedule $schedule = NULL ) {
|
9 |
+
$this->set_schedule( new ActionScheduler_NullSchedule() );
|
10 |
+
}
|
11 |
+
|
12 |
+
public function execute() {
|
13 |
+
// don't execute
|
14 |
+
}
|
15 |
+
}
|
16 |
+
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_NullLogEntry.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_NullLogEntry
|
5 |
+
*/
|
6 |
+
class ActionScheduler_NullLogEntry extends ActionScheduler_LogEntry {
|
7 |
+
public function __construct( $action_id = '', $message = '' ) {
|
8 |
+
// nothing to see here
|
9 |
+
}
|
10 |
+
}
|
11 |
+
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_NullSchedule.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_NullSchedule
|
5 |
+
*/
|
6 |
+
class ActionScheduler_NullSchedule implements ActionScheduler_Schedule {
|
7 |
+
|
8 |
+
public function next( DateTime $after = NULL ) {
|
9 |
+
return NULL;
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @return bool
|
14 |
+
*/
|
15 |
+
public function is_recurring() {
|
16 |
+
return false;
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_QueueCleaner.php
ADDED
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_QueueCleaner
|
5 |
+
*/
|
6 |
+
class ActionScheduler_QueueCleaner {
|
7 |
+
|
8 |
+
/** @var int */
|
9 |
+
protected $batch_size;
|
10 |
+
|
11 |
+
/** @var ActionScheduler_Store */
|
12 |
+
private $store = null;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* 31 days in seconds.
|
16 |
+
*
|
17 |
+
* @var int
|
18 |
+
*/
|
19 |
+
private $month_in_seconds = 2678400;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Five minutes in seconds
|
23 |
+
*
|
24 |
+
* @var int
|
25 |
+
*/
|
26 |
+
private $five_minutes = 300;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* ActionScheduler_QueueCleaner constructor.
|
30 |
+
*
|
31 |
+
* @param ActionScheduler_Store $store The store instance.
|
32 |
+
* @param int $batch_size The batch size.
|
33 |
+
*/
|
34 |
+
public function __construct( ActionScheduler_Store $store = null, $batch_size = 20 ) {
|
35 |
+
$this->store = $store ? $store : ActionScheduler_Store::instance();
|
36 |
+
$this->batch_size = $batch_size;
|
37 |
+
}
|
38 |
+
|
39 |
+
public function delete_old_actions() {
|
40 |
+
$lifespan = apply_filters( 'action_scheduler_retention_period', $this->month_in_seconds );
|
41 |
+
$cutoff = as_get_datetime_object($lifespan.' seconds ago');
|
42 |
+
|
43 |
+
$statuses_to_purge = array(
|
44 |
+
ActionScheduler_Store::STATUS_COMPLETE,
|
45 |
+
ActionScheduler_Store::STATUS_CANCELED,
|
46 |
+
);
|
47 |
+
|
48 |
+
foreach ( $statuses_to_purge as $status ) {
|
49 |
+
$actions_to_delete = $this->store->query_actions( array(
|
50 |
+
'status' => $status,
|
51 |
+
'modified' => $cutoff,
|
52 |
+
'modified_compare' => '<=',
|
53 |
+
'per_page' => $this->get_batch_size(),
|
54 |
+
) );
|
55 |
+
|
56 |
+
foreach ( $actions_to_delete as $action_id ) {
|
57 |
+
try {
|
58 |
+
$this->store->delete_action( $action_id );
|
59 |
+
} catch ( Exception $e ) {
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Notify 3rd party code of exceptions when deleting a completed action older than the retention period
|
63 |
+
*
|
64 |
+
* This hook provides a way for 3rd party code to log or otherwise handle exceptions relating to their
|
65 |
+
* actions.
|
66 |
+
*
|
67 |
+
* @since 2.0.0
|
68 |
+
*
|
69 |
+
* @param int $action_id The scheduled actions ID in the data store
|
70 |
+
* @param Exception $e The exception thrown when attempting to delete the action from the data store
|
71 |
+
* @param int $lifespan The retention period, in seconds, for old actions
|
72 |
+
* @param int $count_of_actions_to_delete The number of old actions being deleted in this batch
|
73 |
+
*/
|
74 |
+
do_action( 'action_scheduler_failed_old_action_deletion', $action_id, $e, $lifespan, count( $actions_to_delete ) );
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
public function reset_timeouts() {
|
81 |
+
$timeout = apply_filters( 'action_scheduler_timeout_period', $this->five_minutes );
|
82 |
+
if ( $timeout < 0 ) {
|
83 |
+
return;
|
84 |
+
}
|
85 |
+
$cutoff = as_get_datetime_object($timeout.' seconds ago');
|
86 |
+
$actions_to_reset = $this->store->query_actions( array(
|
87 |
+
'status' => ActionScheduler_Store::STATUS_PENDING,
|
88 |
+
'modified' => $cutoff,
|
89 |
+
'modified_compare' => '<=',
|
90 |
+
'claimed' => true,
|
91 |
+
'per_page' => $this->get_batch_size(),
|
92 |
+
) );
|
93 |
+
|
94 |
+
foreach ( $actions_to_reset as $action_id ) {
|
95 |
+
$this->store->unclaim_action( $action_id );
|
96 |
+
do_action( 'action_scheduler_reset_action', $action_id );
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
public function mark_failures() {
|
101 |
+
$timeout = apply_filters( 'action_scheduler_failure_period', $this->five_minutes );
|
102 |
+
if ( $timeout < 0 ) {
|
103 |
+
return;
|
104 |
+
}
|
105 |
+
$cutoff = as_get_datetime_object($timeout.' seconds ago');
|
106 |
+
$actions_to_reset = $this->store->query_actions( array(
|
107 |
+
'status' => ActionScheduler_Store::STATUS_RUNNING,
|
108 |
+
'modified' => $cutoff,
|
109 |
+
'modified_compare' => '<=',
|
110 |
+
'per_page' => $this->get_batch_size(),
|
111 |
+
) );
|
112 |
+
|
113 |
+
foreach ( $actions_to_reset as $action_id ) {
|
114 |
+
$this->store->mark_failure( $action_id );
|
115 |
+
do_action( 'action_scheduler_failed_action', $action_id, $timeout );
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Do all of the cleaning actions.
|
121 |
+
*
|
122 |
+
* @author Jeremy Pry
|
123 |
+
*/
|
124 |
+
public function clean() {
|
125 |
+
$this->delete_old_actions();
|
126 |
+
$this->reset_timeouts();
|
127 |
+
$this->mark_failures();
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Get the batch size for cleaning the queue.
|
132 |
+
*
|
133 |
+
* @author Jeremy Pry
|
134 |
+
* @return int
|
135 |
+
*/
|
136 |
+
protected function get_batch_size() {
|
137 |
+
/**
|
138 |
+
* Filter the batch size when cleaning the queue.
|
139 |
+
*
|
140 |
+
* @param int $batch_size The number of actions to clean in one batch.
|
141 |
+
*/
|
142 |
+
return absint( apply_filters( 'action_scheduler_cleanup_batch_size', $this->batch_size ) );
|
143 |
+
}
|
144 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_QueueRunner.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_QueueRunner
|
5 |
+
*/
|
6 |
+
class ActionScheduler_QueueRunner extends ActionScheduler_Abstract_QueueRunner {
|
7 |
+
const WP_CRON_HOOK = 'action_scheduler_run_queue';
|
8 |
+
|
9 |
+
const WP_CRON_SCHEDULE = 'every_minute';
|
10 |
+
|
11 |
+
/** @var ActionScheduler_QueueRunner */
|
12 |
+
private static $runner = null;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @return ActionScheduler_QueueRunner
|
16 |
+
* @codeCoverageIgnore
|
17 |
+
*/
|
18 |
+
public static function instance() {
|
19 |
+
if ( empty(self::$runner) ) {
|
20 |
+
$class = apply_filters('action_scheduler_queue_runner_class', 'ActionScheduler_QueueRunner');
|
21 |
+
self::$runner = new $class();
|
22 |
+
}
|
23 |
+
return self::$runner;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* ActionScheduler_QueueRunner constructor.
|
28 |
+
*
|
29 |
+
* @param ActionScheduler_Store $store
|
30 |
+
* @param ActionScheduler_FatalErrorMonitor $monitor
|
31 |
+
* @param ActionScheduler_QueueCleaner $cleaner
|
32 |
+
*/
|
33 |
+
public function __construct( ActionScheduler_Store $store = null, ActionScheduler_FatalErrorMonitor $monitor = null, ActionScheduler_QueueCleaner $cleaner = null ) {
|
34 |
+
parent::__construct( $store, $monitor, $cleaner );
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @codeCoverageIgnore
|
39 |
+
*/
|
40 |
+
public function init() {
|
41 |
+
|
42 |
+
add_filter( 'cron_schedules', array( self::instance(), 'add_wp_cron_schedule' ) );
|
43 |
+
|
44 |
+
if ( !wp_next_scheduled(self::WP_CRON_HOOK) ) {
|
45 |
+
$schedule = apply_filters( 'action_scheduler_run_schedule', self::WP_CRON_SCHEDULE );
|
46 |
+
wp_schedule_event( time(), $schedule, self::WP_CRON_HOOK );
|
47 |
+
}
|
48 |
+
|
49 |
+
add_action( self::WP_CRON_HOOK, array( self::instance(), 'run' ) );
|
50 |
+
}
|
51 |
+
|
52 |
+
public function run() {
|
53 |
+
ActionScheduler_Compatibility::raise_memory_limit();
|
54 |
+
ActionScheduler_Compatibility::raise_time_limit( $this->get_time_limit() );
|
55 |
+
do_action( 'action_scheduler_before_process_queue' );
|
56 |
+
$this->run_cleanup();
|
57 |
+
$processed_actions = 0;
|
58 |
+
if ( $this->store->get_claim_count() < $this->get_allowed_concurrent_batches() ) {
|
59 |
+
$batch_size = apply_filters( 'action_scheduler_queue_runner_batch_size', 25 );
|
60 |
+
do {
|
61 |
+
$processed_actions_in_batch = $this->do_batch( $batch_size );
|
62 |
+
$processed_actions += $processed_actions_in_batch;
|
63 |
+
} while ( $processed_actions_in_batch > 0 && ! $this->batch_limits_exceeded( $processed_actions ) ); // keep going until we run out of actions, time, or memory
|
64 |
+
}
|
65 |
+
|
66 |
+
do_action( 'action_scheduler_after_process_queue' );
|
67 |
+
return $processed_actions;
|
68 |
+
}
|
69 |
+
|
70 |
+
protected function do_batch( $size = 100 ) {
|
71 |
+
$claim = $this->store->stake_claim($size);
|
72 |
+
$this->monitor->attach($claim);
|
73 |
+
$processed_actions = 0;
|
74 |
+
|
75 |
+
foreach ( $claim->get_actions() as $action_id ) {
|
76 |
+
// bail if we lost the claim
|
77 |
+
if ( ! in_array( $action_id, $this->store->find_actions_by_claim_id( $claim->get_id() ) ) ) {
|
78 |
+
break;
|
79 |
+
}
|
80 |
+
$this->process_action( $action_id );
|
81 |
+
$processed_actions++;
|
82 |
+
|
83 |
+
if ( $this->batch_limits_exceeded( $processed_actions ) ) {
|
84 |
+
break;
|
85 |
+
}
|
86 |
+
}
|
87 |
+
$this->store->release_claim($claim);
|
88 |
+
$this->monitor->detach();
|
89 |
+
$this->clear_caches();
|
90 |
+
return $processed_actions;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Running large batches can eat up memory, as WP adds data to its object cache.
|
95 |
+
*
|
96 |
+
* If using a persistent object store, this has the side effect of flushing that
|
97 |
+
* as well, so this is disabled by default. To enable:
|
98 |
+
*
|
99 |
+
* add_filter( 'action_scheduler_queue_runner_flush_cache', '__return_true' );
|
100 |
+
*/
|
101 |
+
protected function clear_caches() {
|
102 |
+
if ( ! wp_using_ext_object_cache() || apply_filters( 'action_scheduler_queue_runner_flush_cache', false ) ) {
|
103 |
+
wp_cache_flush();
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
public function add_wp_cron_schedule( $schedules ) {
|
108 |
+
$schedules['every_minute'] = array(
|
109 |
+
'interval' => 60, // in seconds
|
110 |
+
'display' => __( 'Every minute' ),
|
111 |
+
);
|
112 |
+
|
113 |
+
return $schedules;
|
114 |
+
}
|
115 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_Schedule.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_Schedule
|
5 |
+
*/
|
6 |
+
interface ActionScheduler_Schedule {
|
7 |
+
/**
|
8 |
+
* @param DateTime $after
|
9 |
+
* @return DateTime|null
|
10 |
+
*/
|
11 |
+
public function next( DateTime $after = NULL );
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @return bool
|
15 |
+
*/
|
16 |
+
public function is_recurring();
|
17 |
+
}
|
18 |
+
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_SimpleSchedule.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_SimpleSchedule
|
5 |
+
*/
|
6 |
+
class ActionScheduler_SimpleSchedule implements ActionScheduler_Schedule {
|
7 |
+
private $date = NULL;
|
8 |
+
private $timestamp = 0;
|
9 |
+
public function __construct( DateTime $date ) {
|
10 |
+
$this->date = clone $date;
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @param DateTime $after
|
15 |
+
*
|
16 |
+
* @return DateTime|null
|
17 |
+
*/
|
18 |
+
public function next( DateTime $after = NULL ) {
|
19 |
+
$after = empty($after) ? as_get_datetime_object('@0') : $after;
|
20 |
+
return ( $after > $this->date ) ? NULL : clone $this->date;
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @return bool
|
25 |
+
*/
|
26 |
+
public function is_recurring() {
|
27 |
+
return false;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* For PHP 5.2 compat, since DateTime objects can't be serialized
|
32 |
+
* @return array
|
33 |
+
*/
|
34 |
+
public function __sleep() {
|
35 |
+
$this->timestamp = $this->date->getTimestamp();
|
36 |
+
return array(
|
37 |
+
'timestamp',
|
38 |
+
);
|
39 |
+
}
|
40 |
+
|
41 |
+
public function __wakeup() {
|
42 |
+
$this->date = as_get_datetime_object($this->timestamp);
|
43 |
+
}
|
44 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_Store.php
ADDED
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_Store
|
5 |
+
* @codeCoverageIgnore
|
6 |
+
*/
|
7 |
+
abstract class ActionScheduler_Store {
|
8 |
+
const STATUS_COMPLETE = 'complete';
|
9 |
+
const STATUS_PENDING = 'pending';
|
10 |
+
const STATUS_RUNNING = 'in-progress';
|
11 |
+
const STATUS_FAILED = 'failed';
|
12 |
+
const STATUS_CANCELED = 'canceled';
|
13 |
+
|
14 |
+
/** @var ActionScheduler_Store */
|
15 |
+
private static $store = NULL;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @param ActionScheduler_Action $action
|
19 |
+
* @param DateTime $scheduled_date Optional Date of the first instance
|
20 |
+
* to store. Otherwise uses the first date of the action's
|
21 |
+
* schedule.
|
22 |
+
*
|
23 |
+
* @return string The action ID
|
24 |
+
*/
|
25 |
+
abstract public function save_action( ActionScheduler_Action $action, DateTime $scheduled_date = NULL );
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @param string $action_id
|
29 |
+
*
|
30 |
+
* @return ActionScheduler_Action
|
31 |
+
*/
|
32 |
+
abstract public function fetch_action( $action_id );
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @param string $hook
|
36 |
+
* @param array $params
|
37 |
+
* @return string ID of the next action matching the criteria
|
38 |
+
*/
|
39 |
+
abstract public function find_action( $hook, $params = array() );
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @param array $query
|
43 |
+
* @return array The IDs of actions matching the query
|
44 |
+
*/
|
45 |
+
abstract public function query_actions( $query = array() );
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Get a count of all actions in the store, grouped by status
|
49 |
+
*
|
50 |
+
* @return array
|
51 |
+
*/
|
52 |
+
abstract public function action_counts();
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @param string $action_id
|
56 |
+
*/
|
57 |
+
abstract public function cancel_action( $action_id );
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @param string $action_id
|
61 |
+
*/
|
62 |
+
abstract public function delete_action( $action_id );
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @param string $action_id
|
66 |
+
*
|
67 |
+
* @return DateTime The date the action is schedule to run, or the date that it ran.
|
68 |
+
*/
|
69 |
+
abstract public function get_date( $action_id );
|
70 |
+
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @param int $max_actions
|
74 |
+
* @param DateTime $before_date Claim only actions schedule before the given date. Defaults to now.
|
75 |
+
* @param array $hooks Claim only actions with a hook or hooks.
|
76 |
+
* @param string $group Claim only actions in the given group.
|
77 |
+
*
|
78 |
+
* @return ActionScheduler_ActionClaim
|
79 |
+
*/
|
80 |
+
abstract public function stake_claim( $max_actions = 10, DateTime $before_date = null, $hooks = array(), $group = '' );
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @return int
|
84 |
+
*/
|
85 |
+
abstract public function get_claim_count();
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @param ActionScheduler_ActionClaim $claim
|
89 |
+
*/
|
90 |
+
abstract public function release_claim( ActionScheduler_ActionClaim $claim );
|
91 |
+
|
92 |
+
/**
|
93 |
+
* @param string $action_id
|
94 |
+
*/
|
95 |
+
abstract public function unclaim_action( $action_id );
|
96 |
+
|
97 |
+
/**
|
98 |
+
* @param string $action_id
|
99 |
+
*/
|
100 |
+
abstract public function mark_failure( $action_id );
|
101 |
+
|
102 |
+
/**
|
103 |
+
* @param string $action_id
|
104 |
+
*/
|
105 |
+
abstract public function log_execution( $action_id );
|
106 |
+
|
107 |
+
/**
|
108 |
+
* @param string $action_id
|
109 |
+
*/
|
110 |
+
abstract public function mark_complete( $action_id );
|
111 |
+
|
112 |
+
/**
|
113 |
+
* @param string $action_id
|
114 |
+
*
|
115 |
+
* @return string
|
116 |
+
*/
|
117 |
+
abstract public function get_status( $action_id );
|
118 |
+
|
119 |
+
/**
|
120 |
+
* @param string $action_id
|
121 |
+
* @return mixed
|
122 |
+
*/
|
123 |
+
abstract public function get_claim_id( $action_id );
|
124 |
+
|
125 |
+
/**
|
126 |
+
* @param string $claim_id
|
127 |
+
* @return array
|
128 |
+
*/
|
129 |
+
abstract public function find_actions_by_claim_id( $claim_id );
|
130 |
+
|
131 |
+
/**
|
132 |
+
* @param string $comparison_operator
|
133 |
+
* @return string
|
134 |
+
*/
|
135 |
+
protected function validate_sql_comparator( $comparison_operator ) {
|
136 |
+
if ( in_array( $comparison_operator, array('!=', '>', '>=', '<', '<=', '=') ) ) {
|
137 |
+
return $comparison_operator;
|
138 |
+
}
|
139 |
+
return '=';
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Get the time MySQL formated date/time string for an action's (next) scheduled date.
|
144 |
+
*
|
145 |
+
* @param ActionScheduler_Action $action
|
146 |
+
* @param DateTime $scheduled_date (optional)
|
147 |
+
* @return string
|
148 |
+
*/
|
149 |
+
protected function get_scheduled_date_string( ActionScheduler_Action $action, DateTime $scheduled_date = NULL ) {
|
150 |
+
$next = null === $scheduled_date ? $action->get_schedule()->next() : $scheduled_date;
|
151 |
+
if ( ! $next ) {
|
152 |
+
throw new InvalidArgumentException( __( 'Invalid schedule. Cannot save action.', 'action-scheduler' ) );
|
153 |
+
}
|
154 |
+
$next->setTimezone( new DateTimeZone( 'UTC' ) );
|
155 |
+
|
156 |
+
return $next->format( 'Y-m-d H:i:s' );
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Get the time MySQL formated date/time string for an action's (next) scheduled date.
|
161 |
+
*
|
162 |
+
* @param ActionScheduler_Action $action
|
163 |
+
* @param DateTime $scheduled_date (optional)
|
164 |
+
* @return string
|
165 |
+
*/
|
166 |
+
protected function get_scheduled_date_string_local( ActionScheduler_Action $action, DateTime $scheduled_date = NULL ) {
|
167 |
+
$next = null === $scheduled_date ? $action->get_schedule()->next() : $scheduled_date;
|
168 |
+
if ( ! $next ) {
|
169 |
+
throw new InvalidArgumentException( __( 'Invalid schedule. Cannot save action.', 'action-scheduler' ) );
|
170 |
+
}
|
171 |
+
|
172 |
+
ActionScheduler_TimezoneHelper::set_local_timezone( $next );
|
173 |
+
return $next->format( 'Y-m-d H:i:s' );
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* @return array
|
178 |
+
*/
|
179 |
+
public function get_status_labels() {
|
180 |
+
return array(
|
181 |
+
self::STATUS_COMPLETE => __( 'Complete', 'action-scheduler' ),
|
182 |
+
self::STATUS_PENDING => __( 'Pending', 'action-scheduler' ),
|
183 |
+
self::STATUS_RUNNING => __( 'In-progress', 'action-scheduler' ),
|
184 |
+
self::STATUS_FAILED => __( 'Failed', 'action-scheduler' ),
|
185 |
+
self::STATUS_CANCELED => __( 'Canceled', 'action-scheduler' ),
|
186 |
+
);
|
187 |
+
}
|
188 |
+
|
189 |
+
public function init() {}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* @return ActionScheduler_Store
|
193 |
+
*/
|
194 |
+
public static function instance() {
|
195 |
+
if ( empty(self::$store) ) {
|
196 |
+
$class = apply_filters('action_scheduler_store_class', 'ActionScheduler_wpPostStore');
|
197 |
+
self::$store = new $class();
|
198 |
+
}
|
199 |
+
return self::$store;
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Get the site's local time.
|
204 |
+
*
|
205 |
+
* @deprecated 2.1.0
|
206 |
+
* @return DateTimeZone
|
207 |
+
*/
|
208 |
+
protected function get_local_timezone() {
|
209 |
+
_deprecated_function( __FUNCTION__, '2.1.0', 'ActionScheduler_TimezoneHelper::set_local_timezone()' );
|
210 |
+
return ActionScheduler_TimezoneHelper::get_local_timezone();
|
211 |
+
}
|
212 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_TimezoneHelper.php
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_TimezoneHelper
|
5 |
+
*/
|
6 |
+
abstract class ActionScheduler_TimezoneHelper {
|
7 |
+
private static $local_timezone = NULL;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Set a DateTime's timezone to the WordPress site's timezone, or a UTC offset
|
11 |
+
* if no timezone string is available.
|
12 |
+
*
|
13 |
+
* @since 2.1.0
|
14 |
+
*
|
15 |
+
* @param DateTime $date
|
16 |
+
* @return ActionScheduler_DateTime
|
17 |
+
*/
|
18 |
+
public static function set_local_timezone( DateTime $date ) {
|
19 |
+
|
20 |
+
// Accept a DateTime for easier backward compatibility, even though we require methods on ActionScheduler_DateTime
|
21 |
+
if ( ! is_a( $date, 'ActionScheduler_DateTime' ) ) {
|
22 |
+
$date = as_get_datetime_object( $date->format( 'U' ) );
|
23 |
+
}
|
24 |
+
|
25 |
+
if ( get_option( 'timezone_string' ) ) {
|
26 |
+
$date->setTimezone( new DateTimeZone( self::get_local_timezone_string() ) );
|
27 |
+
} else {
|
28 |
+
$date->setUtcOffset( self::get_local_timezone_offset() );
|
29 |
+
}
|
30 |
+
|
31 |
+
return $date;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Helper to retrieve the timezone string for a site until a WP core method exists
|
36 |
+
* (see https://core.trac.wordpress.org/ticket/24730).
|
37 |
+
*
|
38 |
+
* Adapted from wc_timezone_string() and https://secure.php.net/manual/en/function.timezone-name-from-abbr.php#89155.
|
39 |
+
*
|
40 |
+
* If no timezone string is set, and its not possible to match the UTC offset set for the site to a timezone
|
41 |
+
* string, then an empty string will be returned, and the UTC offset should be used to set a DateTime's
|
42 |
+
* timezone.
|
43 |
+
*
|
44 |
+
* @since 2.1.0
|
45 |
+
* @return string PHP timezone string for the site or empty if no timezone string is available.
|
46 |
+
*/
|
47 |
+
protected static function get_local_timezone_string( $reset = false ) {
|
48 |
+
// If site timezone string exists, return it.
|
49 |
+
$timezone = get_option( 'timezone_string' );
|
50 |
+
if ( $timezone ) {
|
51 |
+
return $timezone;
|
52 |
+
}
|
53 |
+
|
54 |
+
// Get UTC offset, if it isn't set then return UTC.
|
55 |
+
$utc_offset = intval( get_option( 'gmt_offset', 0 ) );
|
56 |
+
if ( 0 === $utc_offset ) {
|
57 |
+
return 'UTC';
|
58 |
+
}
|
59 |
+
|
60 |
+
// Adjust UTC offset from hours to seconds.
|
61 |
+
$utc_offset *= 3600;
|
62 |
+
|
63 |
+
// Attempt to guess the timezone string from the UTC offset.
|
64 |
+
$timezone = timezone_name_from_abbr( '', $utc_offset );
|
65 |
+
if ( $timezone ) {
|
66 |
+
return $timezone;
|
67 |
+
}
|
68 |
+
|
69 |
+
// Last try, guess timezone string manually.
|
70 |
+
foreach ( timezone_abbreviations_list() as $abbr ) {
|
71 |
+
foreach ( $abbr as $city ) {
|
72 |
+
if ( (bool) date( 'I' ) === (bool) $city['dst'] && $city['timezone_id'] && intval( $city['offset'] ) === $utc_offset ) {
|
73 |
+
return $city['timezone_id'];
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
// No timezone string
|
79 |
+
return '';
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Get timezone offset in seconds.
|
84 |
+
*
|
85 |
+
* @since 2.1.0
|
86 |
+
* @return float
|
87 |
+
*/
|
88 |
+
protected static function get_local_timezone_offset() {
|
89 |
+
$timezone = get_option( 'timezone_string' );
|
90 |
+
|
91 |
+
if ( $timezone ) {
|
92 |
+
$timezone_object = new DateTimeZone( $timezone );
|
93 |
+
return $timezone_object->getOffset( new DateTime( 'now' ) );
|
94 |
+
} else {
|
95 |
+
return floatval( get_option( 'gmt_offset', 0 ) ) * HOUR_IN_SECONDS;
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* @deprecated 2.1.0
|
101 |
+
*/
|
102 |
+
public static function get_local_timezone( $reset = FALSE ) {
|
103 |
+
_deprecated_function( __FUNCTION__, '2.1.0', 'ActionScheduler_TimezoneHelper::set_local_timezone()' );
|
104 |
+
if ( $reset ) {
|
105 |
+
self::$local_timezone = NULL;
|
106 |
+
}
|
107 |
+
if ( !isset(self::$local_timezone) ) {
|
108 |
+
$tzstring = get_option('timezone_string');
|
109 |
+
|
110 |
+
if ( empty($tzstring) ) {
|
111 |
+
$gmt_offset = get_option('gmt_offset');
|
112 |
+
if ( $gmt_offset == 0 ) {
|
113 |
+
$tzstring = 'UTC';
|
114 |
+
} else {
|
115 |
+
$gmt_offset *= HOUR_IN_SECONDS;
|
116 |
+
$tzstring = timezone_name_from_abbr( '', $gmt_offset, 1 );
|
117 |
+
|
118 |
+
// If there's no timezone string, try again with no DST.
|
119 |
+
if ( false === $tzstring ) {
|
120 |
+
$tzstring = timezone_name_from_abbr( '', $gmt_offset, 0 );
|
121 |
+
}
|
122 |
+
|
123 |
+
// Try mapping to the first abbreviation we can find.
|
124 |
+
if ( false === $tzstring ) {
|
125 |
+
$is_dst = date( 'I' );
|
126 |
+
foreach ( timezone_abbreviations_list() as $abbr ) {
|
127 |
+
foreach ( $abbr as $city ) {
|
128 |
+
if ( $city['dst'] == $is_dst && $city['offset'] == $gmt_offset ) {
|
129 |
+
// If there's no valid timezone ID, keep looking.
|
130 |
+
if ( null === $city['timezone_id'] ) {
|
131 |
+
continue;
|
132 |
+
}
|
133 |
+
|
134 |
+
$tzstring = $city['timezone_id'];
|
135 |
+
break 2;
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
// If we still have no valid string, then fall back to UTC.
|
142 |
+
if ( false === $tzstring ) {
|
143 |
+
$tzstring = 'UTC';
|
144 |
+
}
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
self::$local_timezone = new DateTimeZone($tzstring);
|
149 |
+
}
|
150 |
+
return self::$local_timezone;
|
151 |
+
}
|
152 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_Versions.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_Versions
|
5 |
+
*/
|
6 |
+
class ActionScheduler_Versions {
|
7 |
+
/**
|
8 |
+
* @var ActionScheduler_Versions
|
9 |
+
*/
|
10 |
+
private static $instance = NULL;
|
11 |
+
|
12 |
+
private $versions = array();
|
13 |
+
|
14 |
+
public function register( $version_string, $initialization_callback ) {
|
15 |
+
if ( isset($this->versions[$version_string]) ) {
|
16 |
+
return FALSE;
|
17 |
+
}
|
18 |
+
$this->versions[$version_string] = $initialization_callback;
|
19 |
+
return TRUE;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function get_versions() {
|
23 |
+
return $this->versions;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function latest_version() {
|
27 |
+
$keys = array_keys($this->versions);
|
28 |
+
if ( empty($keys) ) {
|
29 |
+
return false;
|
30 |
+
}
|
31 |
+
uasort( $keys, 'version_compare' );
|
32 |
+
return end($keys);
|
33 |
+
}
|
34 |
+
|
35 |
+
public function latest_version_callback() {
|
36 |
+
$latest = $this->latest_version();
|
37 |
+
if ( empty($latest) || !isset($this->versions[$latest]) ) {
|
38 |
+
return '__return_null';
|
39 |
+
}
|
40 |
+
return $this->versions[$latest];
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @return ActionScheduler_Versions
|
45 |
+
* @codeCoverageIgnore
|
46 |
+
*/
|
47 |
+
public static function instance() {
|
48 |
+
if ( empty(self::$instance) ) {
|
49 |
+
self::$instance = new self();
|
50 |
+
}
|
51 |
+
return self::$instance;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @codeCoverageIgnore
|
56 |
+
*/
|
57 |
+
public static function initialize_latest_version() {
|
58 |
+
$self = self::instance();
|
59 |
+
call_user_func($self->latest_version_callback());
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_WPCLI_QueueRunner.php
ADDED
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* WP CLI Queue runner.
|
5 |
+
*
|
6 |
+
* This class can only be called from within a WP CLI instance.
|
7 |
+
*/
|
8 |
+
class ActionScheduler_WPCLI_QueueRunner extends ActionScheduler_Abstract_QueueRunner {
|
9 |
+
|
10 |
+
/** @var array */
|
11 |
+
protected $actions;
|
12 |
+
|
13 |
+
/** @var ActionScheduler_ActionClaim */
|
14 |
+
protected $claim;
|
15 |
+
|
16 |
+
/** @var \cli\progress\Bar */
|
17 |
+
protected $progress_bar;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* ActionScheduler_WPCLI_QueueRunner constructor.
|
21 |
+
*
|
22 |
+
* @param ActionScheduler_Store $store
|
23 |
+
* @param ActionScheduler_FatalErrorMonitor $monitor
|
24 |
+
* @param ActionScheduler_QueueCleaner $cleaner
|
25 |
+
*
|
26 |
+
* @throws Exception When this is not run within WP CLI
|
27 |
+
*/
|
28 |
+
public function __construct( ActionScheduler_Store $store = null, ActionScheduler_FatalErrorMonitor $monitor = null, ActionScheduler_QueueCleaner $cleaner = null ) {
|
29 |
+
if ( ! ( defined( 'WP_CLI' ) && WP_CLI ) ) {
|
30 |
+
/* translators: %s php class name */
|
31 |
+
throw new Exception( sprintf( __( 'The %s class can only be run within WP CLI.', 'action-scheduler' ), __CLASS__ ) );
|
32 |
+
}
|
33 |
+
|
34 |
+
parent::__construct( $store, $monitor, $cleaner );
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Set up the Queue before processing.
|
39 |
+
*
|
40 |
+
* @author Jeremy Pry
|
41 |
+
*
|
42 |
+
* @param int $batch_size The batch size to process.
|
43 |
+
* @param array $hooks The hooks being used to filter the actions claimed in this batch.
|
44 |
+
* @param string $group The group of actions to claim with this batch.
|
45 |
+
* @param bool $force Whether to force running even with too many concurrent processes.
|
46 |
+
*
|
47 |
+
* @return int The number of actions that will be run.
|
48 |
+
* @throws \WP_CLI\ExitException When there are too many concurrent batches.
|
49 |
+
*/
|
50 |
+
public function setup( $batch_size, $hooks = array(), $group = '', $force = false ) {
|
51 |
+
$this->run_cleanup();
|
52 |
+
$this->add_hooks();
|
53 |
+
|
54 |
+
// Check to make sure there aren't too many concurrent processes running.
|
55 |
+
$claim_count = $this->store->get_claim_count();
|
56 |
+
$too_many = $claim_count >= $this->get_allowed_concurrent_batches();
|
57 |
+
if ( $too_many ) {
|
58 |
+
if ( $force ) {
|
59 |
+
WP_CLI::warning( __( 'There are too many concurrent batches, but the run is forced to continue.', 'action-scheduler' ) );
|
60 |
+
} else {
|
61 |
+
WP_CLI::error( __( 'There are too many concurrent batches.', 'action-scheduler' ) );
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
// Stake a claim and store it.
|
66 |
+
$this->claim = $this->store->stake_claim( $batch_size, null, $hooks, $group );
|
67 |
+
$this->monitor->attach( $this->claim );
|
68 |
+
$this->actions = $this->claim->get_actions();
|
69 |
+
|
70 |
+
return count( $this->actions );
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Add our hooks to the appropriate actions.
|
75 |
+
*
|
76 |
+
* @author Jeremy Pry
|
77 |
+
*/
|
78 |
+
protected function add_hooks() {
|
79 |
+
add_action( 'action_scheduler_before_execute', array( $this, 'before_execute' ) );
|
80 |
+
add_action( 'action_scheduler_after_execute', array( $this, 'after_execute' ) );
|
81 |
+
add_action( 'action_scheduler_failed_execution', array( $this, 'action_failed' ), 10, 2 );
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Set up the WP CLI progress bar.
|
86 |
+
*
|
87 |
+
* @author Jeremy Pry
|
88 |
+
*/
|
89 |
+
protected function setup_progress_bar() {
|
90 |
+
$count = count( $this->actions );
|
91 |
+
$this->progress_bar = \WP_CLI\Utils\make_progress_bar(
|
92 |
+
sprintf( _n( 'Running %d action', 'Running %d actions', $count, 'action-scheduler' ), number_format_i18n( $count ) ),
|
93 |
+
$count
|
94 |
+
);
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Process actions in the queue.
|
99 |
+
*
|
100 |
+
* @author Jeremy Pry
|
101 |
+
* @return int The number of actions processed.
|
102 |
+
*/
|
103 |
+
public function run() {
|
104 |
+
do_action( 'action_scheduler_before_process_queue' );
|
105 |
+
$this->setup_progress_bar();
|
106 |
+
foreach ( $this->actions as $action_id ) {
|
107 |
+
// Error if we lost the claim.
|
108 |
+
if ( ! in_array( $action_id, $this->store->find_actions_by_claim_id( $this->claim->get_id() ) ) ) {
|
109 |
+
WP_CLI::warning( __( 'The claim has been lost. Aborting current batch.', 'action-scheduler' ) );
|
110 |
+
break;
|
111 |
+
}
|
112 |
+
|
113 |
+
$this->process_action( $action_id );
|
114 |
+
$this->progress_bar->tick();
|
115 |
+
|
116 |
+
// Free up memory after every 50 items
|
117 |
+
if ( 0 === $this->progress_bar->current() % 50 ) {
|
118 |
+
$this->stop_the_insanity();
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
$completed = $this->progress_bar->current();
|
123 |
+
$this->progress_bar->finish();
|
124 |
+
$this->store->release_claim( $this->claim );
|
125 |
+
do_action( 'action_scheduler_after_process_queue' );
|
126 |
+
|
127 |
+
return $completed;
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Handle WP CLI message when the action is starting.
|
132 |
+
*
|
133 |
+
* @author Jeremy Pry
|
134 |
+
*
|
135 |
+
* @param $action_id
|
136 |
+
*/
|
137 |
+
public function before_execute( $action_id ) {
|
138 |
+
/* translators: %s refers to the action ID */
|
139 |
+
WP_CLI::log( sprintf( __( 'Started processing action %s', 'action-scheduler' ), $action_id ) );
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Handle WP CLI message when the action has completed.
|
144 |
+
*
|
145 |
+
* @author Jeremy Pry
|
146 |
+
*
|
147 |
+
* @param $action_id
|
148 |
+
*/
|
149 |
+
public function after_execute( $action_id ) {
|
150 |
+
/* translators: %s refers to the action ID */
|
151 |
+
WP_CLI::log( sprintf( __( 'Completed processing action %s', 'action-scheduler' ), $action_id ) );
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Handle WP CLI message when the action has failed.
|
156 |
+
*
|
157 |
+
* @author Jeremy Pry
|
158 |
+
*
|
159 |
+
* @param int $action_id
|
160 |
+
* @param Exception $exception
|
161 |
+
* @throws \WP_CLI\ExitException With failure message.
|
162 |
+
*/
|
163 |
+
public function action_failed( $action_id, $exception ) {
|
164 |
+
WP_CLI::error(
|
165 |
+
/* translators: %1$s refers to the action ID, %2$s refers to the Exception message */
|
166 |
+
sprintf( __( 'Error processing action %1$s: %2$s', 'action-scheduler' ), $action_id, $exception->getMessage() ),
|
167 |
+
false
|
168 |
+
);
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Sleep and help avoid hitting memory limit
|
173 |
+
*
|
174 |
+
* @param int $sleep_time Amount of seconds to sleep
|
175 |
+
*/
|
176 |
+
protected function stop_the_insanity( $sleep_time = 0 ) {
|
177 |
+
if ( 0 < $sleep_time ) {
|
178 |
+
WP_CLI::warning( sprintf( 'Stopped the insanity for %d %s', $sleep_time, _n( 'second', 'seconds', $sleep_time ) ) );
|
179 |
+
sleep( $sleep_time );
|
180 |
+
}
|
181 |
+
|
182 |
+
WP_CLI::warning( __( 'Attempting to reduce used memory...', 'action-scheduler' ) );
|
183 |
+
|
184 |
+
/**
|
185 |
+
* @var $wpdb \wpdb
|
186 |
+
* @var $wp_object_cache \WP_Object_Cache
|
187 |
+
*/
|
188 |
+
global $wpdb, $wp_object_cache;
|
189 |
+
|
190 |
+
$wpdb->queries = array();
|
191 |
+
|
192 |
+
if ( ! is_object( $wp_object_cache ) ) {
|
193 |
+
return;
|
194 |
+
}
|
195 |
+
|
196 |
+
$wp_object_cache->group_ops = array();
|
197 |
+
$wp_object_cache->stats = array();
|
198 |
+
$wp_object_cache->memcache_debug = array();
|
199 |
+
$wp_object_cache->cache = array();
|
200 |
+
|
201 |
+
if ( is_callable( array( $wp_object_cache, '__remoteset' ) ) ) {
|
202 |
+
call_user_func( array( $wp_object_cache, '__remoteset' ) ); // important
|
203 |
+
}
|
204 |
+
}
|
205 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_WPCLI_Scheduler_command.php
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Commands for the Action Scheduler by Prospress.
|
5 |
+
*/
|
6 |
+
class ActionScheduler_WPCLI_Scheduler_command extends WP_CLI_Command {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Run the Action Scheduler
|
10 |
+
*
|
11 |
+
* ## OPTIONS
|
12 |
+
*
|
13 |
+
* [--batch-size=<size>]
|
14 |
+
* : The maximum number of actions to run. Defaults to 100.
|
15 |
+
*
|
16 |
+
* [--batches=<size>]
|
17 |
+
* : Limit execution to a number of batches. Defaults to 0, meaning batches will continue being executed until all actions are complete.
|
18 |
+
*
|
19 |
+
* [--cleanup-batch-size=<size>]
|
20 |
+
* : The maximum number of actions to clean up. Defaults to the value of --batch-size.
|
21 |
+
*
|
22 |
+
* [--hooks=<hooks>]
|
23 |
+
* : Only run actions with the specified hook. Omitting this option runs actions with any hook. Define multiple hooks as a comma separated string (without spaces), e.g. `--hooks=hook_one,hook_two,hook_three`
|
24 |
+
*
|
25 |
+
* [--group=<group>]
|
26 |
+
* : Only run actions from the specified group. Omitting this option runs actions from all groups.
|
27 |
+
*
|
28 |
+
* [--force]
|
29 |
+
* : Whether to force execution despite the maximum number of concurrent processes being exceeded.
|
30 |
+
*
|
31 |
+
* @param array $args Positional arguments.
|
32 |
+
* @param array $assoc_args Keyed arguments.
|
33 |
+
* @throws \WP_CLI\ExitException When an error occurs.
|
34 |
+
*/
|
35 |
+
public function run( $args, $assoc_args ) {
|
36 |
+
// Handle passed arguments.
|
37 |
+
$batch = absint( \WP_CLI\Utils\get_flag_value( $assoc_args, 'batch-size', 100 ) );
|
38 |
+
$batches = absint( \WP_CLI\Utils\get_flag_value( $assoc_args, 'batches', 0 ) );
|
39 |
+
$clean = absint( \WP_CLI\Utils\get_flag_value( $assoc_args, 'cleanup-batch-size', $batch ) );
|
40 |
+
$hooks = explode( ',', WP_CLI\Utils\get_flag_value( $assoc_args, 'hooks', '' ) );
|
41 |
+
$hooks = array_filter( array_map( 'trim', $hooks ) );
|
42 |
+
$group = \WP_CLI\Utils\get_flag_value( $assoc_args, 'group', '' );
|
43 |
+
$force = \WP_CLI\Utils\get_flag_value( $assoc_args, 'force', false );
|
44 |
+
|
45 |
+
$batches_completed = 0;
|
46 |
+
$actions_completed = 0;
|
47 |
+
$unlimited = $batches === 0;
|
48 |
+
|
49 |
+
try {
|
50 |
+
// Custom queue cleaner instance.
|
51 |
+
$cleaner = new ActionScheduler_QueueCleaner( null, $clean );
|
52 |
+
|
53 |
+
// Get the queue runner instance
|
54 |
+
$runner = new ActionScheduler_WPCLI_QueueRunner( null, null, $cleaner );
|
55 |
+
|
56 |
+
// Determine how many tasks will be run in the first batch.
|
57 |
+
$total = $runner->setup( $batch, $hooks, $group, $force );
|
58 |
+
|
59 |
+
// Run actions for as long as possible.
|
60 |
+
while ( $total > 0 ) {
|
61 |
+
$this->print_total_actions( $total );
|
62 |
+
$actions_completed += $runner->run();
|
63 |
+
$batches_completed++;
|
64 |
+
|
65 |
+
// Maybe set up tasks for the next batch.
|
66 |
+
$total = ( $unlimited || $batches_completed < $batches ) ? $runner->setup( $batch, $hooks, $group, $force ) : 0;
|
67 |
+
}
|
68 |
+
} catch ( Exception $e ) {
|
69 |
+
$this->print_error( $e );
|
70 |
+
}
|
71 |
+
|
72 |
+
$this->print_total_batches( $batches_completed );
|
73 |
+
$this->print_success( $actions_completed );
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Print WP CLI message about how many actions are about to be processed.
|
78 |
+
*
|
79 |
+
* @author Jeremy Pry
|
80 |
+
*
|
81 |
+
* @param int $total
|
82 |
+
*/
|
83 |
+
protected function print_total_actions( $total ) {
|
84 |
+
WP_CLI::log(
|
85 |
+
sprintf(
|
86 |
+
/* translators: %d refers to how many scheduled taks were found to run */
|
87 |
+
_n( 'Found %d scheduled task', 'Found %d scheduled tasks', $total, 'action-scheduler' ),
|
88 |
+
number_format_i18n( $total )
|
89 |
+
)
|
90 |
+
);
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Print WP CLI message about how many batches of actions were processed.
|
95 |
+
*
|
96 |
+
* @author Jeremy Pry
|
97 |
+
*
|
98 |
+
* @param int $batches_completed
|
99 |
+
*/
|
100 |
+
protected function print_total_batches( $batches_completed ) {
|
101 |
+
WP_CLI::log(
|
102 |
+
sprintf(
|
103 |
+
/* translators: %d refers to the total number of batches executed */
|
104 |
+
_n( '%d batch executed.', '%d batches executed.', $batches_completed, 'action-scheduler' ),
|
105 |
+
number_format_i18n( $batches_completed )
|
106 |
+
)
|
107 |
+
);
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Convert an exception into a WP CLI error.
|
112 |
+
*
|
113 |
+
* @author Jeremy Pry
|
114 |
+
*
|
115 |
+
* @param Exception $e The error object.
|
116 |
+
*
|
117 |
+
* @throws \WP_CLI\ExitException
|
118 |
+
*/
|
119 |
+
protected function print_error( Exception $e ) {
|
120 |
+
WP_CLI::error(
|
121 |
+
sprintf(
|
122 |
+
/* translators: %s refers to the exception error message. */
|
123 |
+
__( 'There was an error running the action scheduler: %s', 'action-scheduler' ),
|
124 |
+
$e->getMessage()
|
125 |
+
)
|
126 |
+
);
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Print a success message with the number of completed actions.
|
131 |
+
*
|
132 |
+
* @author Jeremy Pry
|
133 |
+
*
|
134 |
+
* @param int $actions_completed
|
135 |
+
*/
|
136 |
+
protected function print_success( $actions_completed ) {
|
137 |
+
WP_CLI::success(
|
138 |
+
sprintf(
|
139 |
+
/* translators: %d refers to the total number of taskes completed */
|
140 |
+
_n( '%d scheduled task completed.', '%d scheduled tasks completed.', $actions_completed, 'action-scheduler' ),
|
141 |
+
number_format_i18n( $actions_completed )
|
142 |
+
)
|
143 |
+
);
|
144 |
+
}
|
145 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_wpCommentLogger.php
ADDED
@@ -0,0 +1,240 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_wpCommentLogger
|
5 |
+
*/
|
6 |
+
class ActionScheduler_wpCommentLogger extends ActionScheduler_Logger {
|
7 |
+
const AGENT = 'ActionScheduler';
|
8 |
+
const TYPE = 'action_log';
|
9 |
+
|
10 |
+
/**
|
11 |
+
* @param string $action_id
|
12 |
+
* @param string $message
|
13 |
+
* @param DateTime $date
|
14 |
+
*
|
15 |
+
* @return string The log entry ID
|
16 |
+
*/
|
17 |
+
public function log( $action_id, $message, DateTime $date = NULL ) {
|
18 |
+
if ( empty($date) ) {
|
19 |
+
$date = as_get_datetime_object();
|
20 |
+
} else {
|
21 |
+
$date = as_get_datetime_object( clone $date );
|
22 |
+
}
|
23 |
+
$comment_id = $this->create_wp_comment( $action_id, $message, $date );
|
24 |
+
return $comment_id;
|
25 |
+
}
|
26 |
+
|
27 |
+
protected function create_wp_comment( $action_id, $message, DateTime $date ) {
|
28 |
+
|
29 |
+
$comment_date_gmt = $date->format('Y-m-d H:i:s');
|
30 |
+
ActionScheduler_TimezoneHelper::set_local_timezone( $date );
|
31 |
+
$comment_data = array(
|
32 |
+
'comment_post_ID' => $action_id,
|
33 |
+
'comment_date' => $date->format('Y-m-d H:i:s'),
|
34 |
+
'comment_date_gmt' => $comment_date_gmt,
|
35 |
+
'comment_author' => self::AGENT,
|
36 |
+
'comment_content' => $message,
|
37 |
+
'comment_agent' => self::AGENT,
|
38 |
+
'comment_type' => self::TYPE,
|
39 |
+
);
|
40 |
+
return wp_insert_comment($comment_data);
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @param string $entry_id
|
45 |
+
*
|
46 |
+
* @return ActionScheduler_LogEntry
|
47 |
+
*/
|
48 |
+
public function get_entry( $entry_id ) {
|
49 |
+
$comment = $this->get_comment( $entry_id );
|
50 |
+
if ( empty($comment) || $comment->comment_type != self::TYPE ) {
|
51 |
+
return new ActionScheduler_NullLogEntry();
|
52 |
+
}
|
53 |
+
|
54 |
+
$date = as_get_datetime_object( $comment->comment_date_gmt );
|
55 |
+
ActionScheduler_TimezoneHelper::set_local_timezone( $date );
|
56 |
+
return new ActionScheduler_LogEntry( $comment->comment_post_ID, $comment->comment_content, $date );
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @param string $action_id
|
61 |
+
*
|
62 |
+
* @return ActionScheduler_LogEntry[]
|
63 |
+
*/
|
64 |
+
public function get_logs( $action_id ) {
|
65 |
+
$status = 'all';
|
66 |
+
if ( get_post_status($action_id) == 'trash' ) {
|
67 |
+
$status = 'post-trashed';
|
68 |
+
}
|
69 |
+
$comments = get_comments(array(
|
70 |
+
'post_id' => $action_id,
|
71 |
+
'orderby' => 'comment_date_gmt',
|
72 |
+
'order' => 'ASC',
|
73 |
+
'type' => self::TYPE,
|
74 |
+
'status' => $status,
|
75 |
+
));
|
76 |
+
$logs = array();
|
77 |
+
foreach ( $comments as $c ) {
|
78 |
+
$entry = $this->get_entry( $c );
|
79 |
+
if ( !empty($entry) ) {
|
80 |
+
$logs[] = $entry;
|
81 |
+
}
|
82 |
+
}
|
83 |
+
return $logs;
|
84 |
+
}
|
85 |
+
|
86 |
+
protected function get_comment( $comment_id ) {
|
87 |
+
return get_comment( $comment_id );
|
88 |
+
}
|
89 |
+
|
90 |
+
|
91 |
+
|
92 |
+
/**
|
93 |
+
* @param WP_Comment_Query $query
|
94 |
+
*/
|
95 |
+
public function filter_comment_queries( $query ) {
|
96 |
+
foreach ( array('ID', 'parent', 'post_author', 'post_name', 'post_parent', 'type', 'post_type', 'post_id', 'post_ID') as $key ) {
|
97 |
+
if ( !empty($query->query_vars[$key]) ) {
|
98 |
+
return; // don't slow down queries that wouldn't include action_log comments anyway
|
99 |
+
}
|
100 |
+
}
|
101 |
+
$query->query_vars['action_log_filter'] = TRUE;
|
102 |
+
add_filter( 'comments_clauses', array( $this, 'filter_comment_query_clauses' ), 10, 2 );
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* @param array $clauses
|
107 |
+
* @param WP_Comment_Query $query
|
108 |
+
*
|
109 |
+
* @return array
|
110 |
+
*/
|
111 |
+
public function filter_comment_query_clauses( $clauses, $query ) {
|
112 |
+
if ( !empty($query->query_vars['action_log_filter']) ) {
|
113 |
+
$clauses['where'] .= $this->get_where_clause();
|
114 |
+
}
|
115 |
+
return $clauses;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Make sure Action Scheduler logs are excluded from comment feeds, which use WP_Query, not
|
120 |
+
* the WP_Comment_Query class handled by @see self::filter_comment_queries().
|
121 |
+
*
|
122 |
+
* @param string $where
|
123 |
+
* @param WP_Query $query
|
124 |
+
*
|
125 |
+
* @return string
|
126 |
+
*/
|
127 |
+
public function filter_comment_feed( $where, $query ) {
|
128 |
+
if ( is_comment_feed() ) {
|
129 |
+
$where .= $this->get_where_clause();
|
130 |
+
}
|
131 |
+
return $where;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Return a SQL clause to exclude Action Scheduler comments.
|
136 |
+
*
|
137 |
+
* @return string
|
138 |
+
*/
|
139 |
+
protected function get_where_clause() {
|
140 |
+
global $wpdb;
|
141 |
+
return sprintf( " AND {$wpdb->comments}.comment_type != '%s'", self::TYPE );
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Remove action log entries from wp_count_comments()
|
146 |
+
*
|
147 |
+
* @param array $stats
|
148 |
+
* @param int $post_id
|
149 |
+
*
|
150 |
+
* @return object
|
151 |
+
*/
|
152 |
+
public function filter_comment_count( $stats, $post_id ) {
|
153 |
+
global $wpdb;
|
154 |
+
|
155 |
+
if ( 0 === $post_id ) {
|
156 |
+
$stats = $this->get_comment_count();
|
157 |
+
}
|
158 |
+
|
159 |
+
return $stats;
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Retrieve the comment counts from our cache, or the database if the cached version isn't set.
|
164 |
+
*
|
165 |
+
* @return object
|
166 |
+
*/
|
167 |
+
protected function get_comment_count() {
|
168 |
+
global $wpdb;
|
169 |
+
|
170 |
+
$stats = get_transient( 'as_comment_count' );
|
171 |
+
|
172 |
+
if ( ! $stats ) {
|
173 |
+
$stats = array();
|
174 |
+
|
175 |
+
$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} WHERE comment_type NOT IN('order_note','action_log') GROUP BY comment_approved", ARRAY_A );
|
176 |
+
|
177 |
+
$total = 0;
|
178 |
+
$stats = array();
|
179 |
+
$approved = array( '0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed' );
|
180 |
+
|
181 |
+
foreach ( (array) $count as $row ) {
|
182 |
+
// Don't count post-trashed toward totals
|
183 |
+
if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
|
184 |
+
$total += $row['num_comments'];
|
185 |
+
}
|
186 |
+
if ( isset( $approved[ $row['comment_approved'] ] ) ) {
|
187 |
+
$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
$stats['total_comments'] = $total;
|
192 |
+
$stats['all'] = $total;
|
193 |
+
|
194 |
+
foreach ( $approved as $key ) {
|
195 |
+
if ( empty( $stats[ $key ] ) ) {
|
196 |
+
$stats[ $key ] = 0;
|
197 |
+
}
|
198 |
+
}
|
199 |
+
|
200 |
+
$stats = (object) $stats;
|
201 |
+
set_transient( 'as_comment_count', $stats );
|
202 |
+
}
|
203 |
+
|
204 |
+
return $stats;
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Delete comment count cache whenever there is new comment or the status of a comment changes. Cache
|
209 |
+
* will be regenerated next time ActionScheduler_wpCommentLogger::filter_comment_count() is called.
|
210 |
+
*/
|
211 |
+
public function delete_comment_count_cache() {
|
212 |
+
delete_transient( 'as_comment_count' );
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* @codeCoverageIgnore
|
217 |
+
*/
|
218 |
+
public function init() {
|
219 |
+
add_action( 'action_scheduler_before_process_queue', array( $this, 'disable_comment_counting' ), 10, 0 );
|
220 |
+
add_action( 'action_scheduler_after_process_queue', array( $this, 'enable_comment_counting' ), 10, 0 );
|
221 |
+
|
222 |
+
parent::init();
|
223 |
+
|
224 |
+
add_action( 'pre_get_comments', array( $this, 'filter_comment_queries' ), 10, 1 );
|
225 |
+
add_action( 'wp_count_comments', array( $this, 'filter_comment_count' ), 20, 2 ); // run after WC_Comments::wp_count_comments() to make sure we exclude order notes and action logs
|
226 |
+
add_action( 'comment_feed_where', array( $this, 'filter_comment_feed' ), 10, 2 );
|
227 |
+
|
228 |
+
// Delete comments count cache whenever there is a new comment or a comment status changes
|
229 |
+
add_action( 'wp_insert_comment', array( $this, 'delete_comment_count_cache' ) );
|
230 |
+
add_action( 'wp_set_comment_status', array( $this, 'delete_comment_count_cache' ) );
|
231 |
+
}
|
232 |
+
|
233 |
+
public function disable_comment_counting() {
|
234 |
+
wp_defer_comment_counting(true);
|
235 |
+
}
|
236 |
+
public function enable_comment_counting() {
|
237 |
+
wp_defer_comment_counting(false);
|
238 |
+
}
|
239 |
+
|
240 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_wpPostStore.php
ADDED
@@ -0,0 +1,757 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_wpPostStore
|
5 |
+
*/
|
6 |
+
class ActionScheduler_wpPostStore extends ActionScheduler_Store {
|
7 |
+
const POST_TYPE = 'scheduled-action';
|
8 |
+
const GROUP_TAXONOMY = 'action-group';
|
9 |
+
const SCHEDULE_META_KEY = '_action_manager_schedule';
|
10 |
+
|
11 |
+
/** @var DateTimeZone */
|
12 |
+
protected $local_timezone = NULL;
|
13 |
+
|
14 |
+
/** @var int */
|
15 |
+
private static $max_index_length = 191;
|
16 |
+
|
17 |
+
public function save_action( ActionScheduler_Action $action, DateTime $scheduled_date = NULL ){
|
18 |
+
try {
|
19 |
+
$this->validate_action( $action );
|
20 |
+
$post_array = $this->create_post_array( $action, $scheduled_date );
|
21 |
+
$post_id = $this->save_post_array( $post_array );
|
22 |
+
$this->save_post_schedule( $post_id, $action->get_schedule() );
|
23 |
+
$this->save_action_group( $post_id, $action->get_group() );
|
24 |
+
do_action( 'action_scheduler_stored_action', $post_id );
|
25 |
+
return $post_id;
|
26 |
+
} catch ( Exception $e ) {
|
27 |
+
throw new RuntimeException( sprintf( __('Error saving action: %s', 'action-scheduler'), $e->getMessage() ), 0 );
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
protected function create_post_array( ActionScheduler_Action $action, DateTime $scheduled_date = NULL ) {
|
32 |
+
$post = array(
|
33 |
+
'post_type' => self::POST_TYPE,
|
34 |
+
'post_title' => $action->get_hook(),
|
35 |
+
'post_content' => json_encode($action->get_args()),
|
36 |
+
'post_status' => ( $action->is_finished() ? 'publish' : 'pending' ),
|
37 |
+
'post_date_gmt' => $this->get_scheduled_date_string( $action, $scheduled_date ),
|
38 |
+
'post_date' => $this->get_scheduled_date_string_local( $action, $scheduled_date ),
|
39 |
+
);
|
40 |
+
return $post;
|
41 |
+
}
|
42 |
+
|
43 |
+
protected function save_post_array( $post_array ) {
|
44 |
+
add_filter( 'wp_insert_post_data', array( $this, 'filter_insert_post_data' ), 10, 1 );
|
45 |
+
$post_id = wp_insert_post($post_array);
|
46 |
+
remove_filter( 'wp_insert_post_data', array( $this, 'filter_insert_post_data' ), 10 );
|
47 |
+
|
48 |
+
if ( is_wp_error($post_id) || empty($post_id) ) {
|
49 |
+
throw new RuntimeException(__('Unable to save action.', 'action-scheduler'));
|
50 |
+
}
|
51 |
+
return $post_id;
|
52 |
+
}
|
53 |
+
|
54 |
+
public function filter_insert_post_data( $postdata ) {
|
55 |
+
if ( $postdata['post_type'] == self::POST_TYPE ) {
|
56 |
+
$postdata['post_author'] = 0;
|
57 |
+
if ( $postdata['post_status'] == 'future' ) {
|
58 |
+
$postdata['post_status'] = 'publish';
|
59 |
+
}
|
60 |
+
}
|
61 |
+
return $postdata;
|
62 |
+
}
|
63 |
+
|
64 |
+
protected function save_post_schedule( $post_id, $schedule ) {
|
65 |
+
update_post_meta( $post_id, self::SCHEDULE_META_KEY, $schedule );
|
66 |
+
}
|
67 |
+
|
68 |
+
protected function save_action_group( $post_id, $group ) {
|
69 |
+
if ( empty($group) ) {
|
70 |
+
wp_set_object_terms( $post_id, array(), self::GROUP_TAXONOMY, FALSE );
|
71 |
+
} else {
|
72 |
+
wp_set_object_terms( $post_id, array($group), self::GROUP_TAXONOMY, FALSE );
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
public function fetch_action( $action_id ) {
|
77 |
+
$post = $this->get_post( $action_id );
|
78 |
+
if ( empty($post) || $post->post_type != self::POST_TYPE ) {
|
79 |
+
return $this->get_null_action();
|
80 |
+
}
|
81 |
+
return $this->make_action_from_post($post);
|
82 |
+
}
|
83 |
+
|
84 |
+
protected function get_post( $action_id ) {
|
85 |
+
if ( empty($action_id) ) {
|
86 |
+
return NULL;
|
87 |
+
}
|
88 |
+
return get_post($action_id);
|
89 |
+
}
|
90 |
+
|
91 |
+
protected function get_null_action() {
|
92 |
+
return new ActionScheduler_NullAction();
|
93 |
+
}
|
94 |
+
|
95 |
+
protected function make_action_from_post( $post ) {
|
96 |
+
$hook = $post->post_title;
|
97 |
+
$args = json_decode( $post->post_content, true );
|
98 |
+
|
99 |
+
// Handle args that do not decode properly.
|
100 |
+
if ( JSON_ERROR_NONE !== json_last_error() || ! is_array( $args ) ) {
|
101 |
+
throw ActionScheduler_InvalidActionException::from_decoding_args( $post->ID );
|
102 |
+
}
|
103 |
+
|
104 |
+
$schedule = get_post_meta( $post->ID, self::SCHEDULE_META_KEY, true );
|
105 |
+
if ( empty($schedule) ) {
|
106 |
+
$schedule = new ActionScheduler_NullSchedule();
|
107 |
+
}
|
108 |
+
$group = wp_get_object_terms( $post->ID, self::GROUP_TAXONOMY, array('fields' => 'names') );
|
109 |
+
$group = empty( $group ) ? '' : reset($group);
|
110 |
+
|
111 |
+
return ActionScheduler::factory()->get_stored_action( $this->get_action_status_by_post_status( $post->post_status ), $hook, $args, $schedule, $group );
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* @param string $post_status
|
116 |
+
*
|
117 |
+
* @throws InvalidArgumentException if $post_status not in known status fields returned by $this->get_status_labels()
|
118 |
+
* @return string
|
119 |
+
*/
|
120 |
+
protected function get_action_status_by_post_status( $post_status ) {
|
121 |
+
|
122 |
+
switch ( $post_status ) {
|
123 |
+
case 'publish' :
|
124 |
+
$action_status = self::STATUS_COMPLETE;
|
125 |
+
break;
|
126 |
+
case 'trash' :
|
127 |
+
$action_status = self::STATUS_CANCELED;
|
128 |
+
break;
|
129 |
+
default :
|
130 |
+
if ( ! array_key_exists( $post_status, $this->get_status_labels() ) ) {
|
131 |
+
throw new InvalidArgumentException( sprintf( 'Invalid post status: "%s". No matching action status available.', $post_status ) );
|
132 |
+
}
|
133 |
+
$action_status = $post_status;
|
134 |
+
break;
|
135 |
+
}
|
136 |
+
|
137 |
+
return $action_status;
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* @param string $action_status
|
142 |
+
* @throws InvalidArgumentException if $post_status not in known status fields returned by $this->get_status_labels()
|
143 |
+
* @return string
|
144 |
+
*/
|
145 |
+
protected function get_post_status_by_action_status( $action_status ) {
|
146 |
+
|
147 |
+
switch ( $action_status ) {
|
148 |
+
case self::STATUS_COMPLETE :
|
149 |
+
$post_status = 'publish';
|
150 |
+
break;
|
151 |
+
case self::STATUS_CANCELED :
|
152 |
+
$post_status = 'trash';
|
153 |
+
break;
|
154 |
+
default :
|
155 |
+
if ( ! array_key_exists( $action_status, $this->get_status_labels() ) ) {
|
156 |
+
throw new InvalidArgumentException( sprintf( 'Invalid action status: "%s".', $action_status ) );
|
157 |
+
}
|
158 |
+
$post_status = $action_status;
|
159 |
+
break;
|
160 |
+
}
|
161 |
+
|
162 |
+
return $post_status;
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* @param string $hook
|
167 |
+
* @param array $params
|
168 |
+
*
|
169 |
+
* @return string ID of the next action matching the criteria or NULL if not found
|
170 |
+
*/
|
171 |
+
public function find_action( $hook, $params = array() ) {
|
172 |
+
$params = wp_parse_args( $params, array(
|
173 |
+
'args' => NULL,
|
174 |
+
'status' => ActionScheduler_Store::STATUS_PENDING,
|
175 |
+
'group' => '',
|
176 |
+
));
|
177 |
+
/** @var wpdb $wpdb */
|
178 |
+
global $wpdb;
|
179 |
+
$query = "SELECT p.ID FROM {$wpdb->posts} p";
|
180 |
+
$args = array();
|
181 |
+
if ( !empty($params['group']) ) {
|
182 |
+
$query .= " INNER JOIN {$wpdb->term_relationships} tr ON tr.object_id=p.ID";
|
183 |
+
$query .= " INNER JOIN {$wpdb->term_taxonomy} tt ON tr.term_taxonomy_id=tt.term_taxonomy_id";
|
184 |
+
$query .= " INNER JOIN {$wpdb->terms} t ON tt.term_id=t.term_id AND t.slug=%s";
|
185 |
+
$args[] = $params['group'];
|
186 |
+
}
|
187 |
+
$query .= " WHERE p.post_title=%s";
|
188 |
+
$args[] = $hook;
|
189 |
+
$query .= " AND p.post_type=%s";
|
190 |
+
$args[] = self::POST_TYPE;
|
191 |
+
if ( !is_null($params['args']) ) {
|
192 |
+
$query .= " AND p.post_content=%s";
|
193 |
+
$args[] = json_encode($params['args']);
|
194 |
+
}
|
195 |
+
|
196 |
+
if ( ! empty( $params['status'] ) ) {
|
197 |
+
$query .= " AND p.post_status=%s";
|
198 |
+
$args[] = $this->get_post_status_by_action_status( $params['status'] );
|
199 |
+
}
|
200 |
+
|
201 |
+
switch ( $params['status'] ) {
|
202 |
+
case self::STATUS_COMPLETE:
|
203 |
+
case self::STATUS_RUNNING:
|
204 |
+
case self::STATUS_FAILED:
|
205 |
+
$order = 'DESC'; // Find the most recent action that matches
|
206 |
+
break;
|
207 |
+
case self::STATUS_PENDING:
|
208 |
+
default:
|
209 |
+
$order = 'ASC'; // Find the next action that matches
|
210 |
+
break;
|
211 |
+
}
|
212 |
+
$query .= " ORDER BY post_date_gmt $order LIMIT 1";
|
213 |
+
|
214 |
+
$query = $wpdb->prepare( $query, $args );
|
215 |
+
|
216 |
+
$id = $wpdb->get_var($query);
|
217 |
+
return $id;
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Returns the SQL statement to query (or count) actions.
|
222 |
+
*
|
223 |
+
* @param array $query Filtering options
|
224 |
+
* @param string $select_or_count Whether the SQL should select and return the IDs or just the row count
|
225 |
+
* @throws InvalidArgumentException if $select_or_count not count or select
|
226 |
+
* @return string SQL statement. The returned SQL is already properly escaped.
|
227 |
+
*/
|
228 |
+
protected function get_query_actions_sql( array $query, $select_or_count = 'select' ) {
|
229 |
+
|
230 |
+
if ( ! in_array( $select_or_count, array( 'select', 'count' ) ) ) {
|
231 |
+
throw new InvalidArgumentException(__('Invalid schedule. Cannot save action.', 'action-scheduler'));
|
232 |
+
}
|
233 |
+
|
234 |
+
$query = wp_parse_args( $query, array(
|
235 |
+
'hook' => '',
|
236 |
+
'args' => NULL,
|
237 |
+
'date' => NULL,
|
238 |
+
'date_compare' => '<=',
|
239 |
+
'modified' => NULL,
|
240 |
+
'modified_compare' => '<=',
|
241 |
+
'group' => '',
|
242 |
+
'status' => '',
|
243 |
+
'claimed' => NULL,
|
244 |
+
'per_page' => 5,
|
245 |
+
'offset' => 0,
|
246 |
+
'orderby' => 'date',
|
247 |
+
'order' => 'ASC',
|
248 |
+
'search' => '',
|
249 |
+
) );
|
250 |
+
|
251 |
+
/** @var wpdb $wpdb */
|
252 |
+
global $wpdb;
|
253 |
+
$sql = ( 'count' === $select_or_count ) ? 'SELECT count(p.ID)' : 'SELECT p.ID ';
|
254 |
+
$sql .= "FROM {$wpdb->posts} p";
|
255 |
+
$sql_params = array();
|
256 |
+
if ( ! empty( $query['group'] ) || 'group' === $query['orderby'] ) {
|
257 |
+
$sql .= " INNER JOIN {$wpdb->term_relationships} tr ON tr.object_id=p.ID";
|
258 |
+
$sql .= " INNER JOIN {$wpdb->term_taxonomy} tt ON tr.term_taxonomy_id=tt.term_taxonomy_id";
|
259 |
+
$sql .= " INNER JOIN {$wpdb->terms} t ON tt.term_id=t.term_id";
|
260 |
+
|
261 |
+
if ( ! empty( $query['group'] ) ) {
|
262 |
+
$sql .= " AND t.slug=%s";
|
263 |
+
$sql_params[] = $query['group'];
|
264 |
+
}
|
265 |
+
}
|
266 |
+
$sql .= " WHERE post_type=%s";
|
267 |
+
$sql_params[] = self::POST_TYPE;
|
268 |
+
if ( $query['hook'] ) {
|
269 |
+
$sql .= " AND p.post_title=%s";
|
270 |
+
$sql_params[] = $query['hook'];
|
271 |
+
}
|
272 |
+
if ( !is_null($query['args']) ) {
|
273 |
+
$sql .= " AND p.post_content=%s";
|
274 |
+
$sql_params[] = json_encode($query['args']);
|
275 |
+
}
|
276 |
+
|
277 |
+
if ( ! empty( $query['status'] ) ) {
|
278 |
+
$sql .= " AND p.post_status=%s";
|
279 |
+
$sql_params[] = $this->get_post_status_by_action_status( $query['status'] );
|
280 |
+
}
|
281 |
+
|
282 |
+
if ( $query['date'] instanceof DateTime ) {
|
283 |
+
$date = clone $query['date'];
|
284 |
+
$date->setTimezone( new DateTimeZone('UTC') );
|
285 |
+
$date_string = $date->format('Y-m-d H:i:s');
|
286 |
+
$comparator = $this->validate_sql_comparator($query['date_compare']);
|
287 |
+
$sql .= " AND p.post_date_gmt $comparator %s";
|
288 |
+
$sql_params[] = $date_string;
|
289 |
+
}
|
290 |
+
|
291 |
+
if ( $query['modified'] instanceof DateTime ) {
|
292 |
+
$modified = clone $query['modified'];
|
293 |
+
$modified->setTimezone( new DateTimeZone('UTC') );
|
294 |
+
$date_string = $modified->format('Y-m-d H:i:s');
|
295 |
+
$comparator = $this->validate_sql_comparator($query['modified_compare']);
|
296 |
+
$sql .= " AND p.post_modified_gmt $comparator %s";
|
297 |
+
$sql_params[] = $date_string;
|
298 |
+
}
|
299 |
+
|
300 |
+
if ( $query['claimed'] === TRUE ) {
|
301 |
+
$sql .= " AND p.post_password != ''";
|
302 |
+
} elseif ( $query['claimed'] === FALSE ) {
|
303 |
+
$sql .= " AND p.post_password = ''";
|
304 |
+
} elseif ( !is_null($query['claimed']) ) {
|
305 |
+
$sql .= " AND p.post_password = %s";
|
306 |
+
$sql_params[] = $query['claimed'];
|
307 |
+
}
|
308 |
+
|
309 |
+
if ( ! empty( $query['search'] ) ) {
|
310 |
+
$sql .= " AND (p.post_title LIKE %s OR p.post_content LIKE %s OR p.post_password LIKE %s)";
|
311 |
+
for( $i = 0; $i < 3; $i++ ) {
|
312 |
+
$sql_params[] = sprintf( '%%%s%%', $query['search'] );
|
313 |
+
}
|
314 |
+
}
|
315 |
+
|
316 |
+
if ( 'select' === $select_or_count ) {
|
317 |
+
switch ( $query['orderby'] ) {
|
318 |
+
case 'hook':
|
319 |
+
$orderby = 'p.post_title';
|
320 |
+
break;
|
321 |
+
case 'group':
|
322 |
+
$orderby = 't.name';
|
323 |
+
break;
|
324 |
+
case 'status':
|
325 |
+
$orderby = 'p.post_status';
|
326 |
+
break;
|
327 |
+
case 'modified':
|
328 |
+
$orderby = 'p.post_modified';
|
329 |
+
break;
|
330 |
+
case 'claim_id':
|
331 |
+
$orderby = 'p.post_password';
|
332 |
+
break;
|
333 |
+
case 'schedule':
|
334 |
+
case 'date':
|
335 |
+
default:
|
336 |
+
$orderby = 'p.post_date_gmt';
|
337 |
+
break;
|
338 |
+
}
|
339 |
+
if ( 'ASC' === strtoupper( $query['order'] ) ) {
|
340 |
+
$order = 'ASC';
|
341 |
+
} else {
|
342 |
+
$order = 'DESC';
|
343 |
+
}
|
344 |
+
$sql .= " ORDER BY $orderby $order";
|
345 |
+
if ( $query['per_page'] > 0 ) {
|
346 |
+
$sql .= " LIMIT %d, %d";
|
347 |
+
$sql_params[] = $query['offset'];
|
348 |
+
$sql_params[] = $query['per_page'];
|
349 |
+
}
|
350 |
+
}
|
351 |
+
|
352 |
+
return $wpdb->prepare( $sql, $sql_params );
|
353 |
+
}
|
354 |
+
|
355 |
+
/**
|
356 |
+
* @param array $query
|
357 |
+
* @param string $query_type Whether to select or count the results. Default, select.
|
358 |
+
* @return string|array The IDs of actions matching the query
|
359 |
+
*/
|
360 |
+
public function query_actions( $query = array(), $query_type = 'select' ) {
|
361 |
+
/** @var wpdb $wpdb */
|
362 |
+
global $wpdb;
|
363 |
+
|
364 |
+
$sql = $this->get_query_actions_sql( $query, $query_type );
|
365 |
+
|
366 |
+
return ( 'count' === $query_type ) ? $wpdb->get_var( $sql ) : $wpdb->get_col( $sql );
|
367 |
+
}
|
368 |
+
|
369 |
+
/**
|
370 |
+
* Get a count of all actions in the store, grouped by status
|
371 |
+
*
|
372 |
+
* @return array
|
373 |
+
*/
|
374 |
+
public function action_counts() {
|
375 |
+
|
376 |
+
$action_counts_by_status = array();
|
377 |
+
$action_stati_and_labels = $this->get_status_labels();
|
378 |
+
$posts_count_by_status = (array) wp_count_posts( self::POST_TYPE, 'readable' );
|
379 |
+
|
380 |
+
foreach ( $posts_count_by_status as $post_status_name => $count ) {
|
381 |
+
|
382 |
+
try {
|
383 |
+
$action_status_name = $this->get_action_status_by_post_status( $post_status_name );
|
384 |
+
} catch ( Exception $e ) {
|
385 |
+
// Ignore any post statuses that aren't for actions
|
386 |
+
continue;
|
387 |
+
}
|
388 |
+
if ( array_key_exists( $action_status_name, $action_stati_and_labels ) ) {
|
389 |
+
$action_counts_by_status[ $action_status_name ] = $count;
|
390 |
+
}
|
391 |
+
}
|
392 |
+
|
393 |
+
return $action_counts_by_status;
|
394 |
+
}
|
395 |
+
|
396 |
+
/**
|
397 |
+
* @param string $action_id
|
398 |
+
*
|
399 |
+
* @throws InvalidArgumentException
|
400 |
+
*/
|
401 |
+
public function cancel_action( $action_id ) {
|
402 |
+
$post = get_post($action_id);
|
403 |
+
if ( empty($post) || ($post->post_type != self::POST_TYPE) ) {
|
404 |
+
throw new InvalidArgumentException(sprintf(__('Unidentified action %s', 'action-scheduler'), $action_id));
|
405 |
+
}
|
406 |
+
do_action( 'action_scheduler_canceled_action', $action_id );
|
407 |
+
wp_trash_post($action_id);
|
408 |
+
}
|
409 |
+
|
410 |
+
public function delete_action( $action_id ) {
|
411 |
+
$post = get_post($action_id);
|
412 |
+
if ( empty($post) || ($post->post_type != self::POST_TYPE) ) {
|
413 |
+
throw new InvalidArgumentException(sprintf(__('Unidentified action %s', 'action-scheduler'), $action_id));
|
414 |
+
}
|
415 |
+
do_action( 'action_scheduler_deleted_action', $action_id );
|
416 |
+
wp_delete_post($action_id, TRUE);
|
417 |
+
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
* @param string $action_id
|
421 |
+
*
|
422 |
+
* @throws InvalidArgumentException
|
423 |
+
* @return ActionScheduler_DateTime The date the action is schedule to run, or the date that it ran.
|
424 |
+
*/
|
425 |
+
public function get_date( $action_id ) {
|
426 |
+
$next = $this->get_date_gmt( $action_id );
|
427 |
+
return ActionScheduler_TimezoneHelper::set_local_timezone( $next );
|
428 |
+
}
|
429 |
+
|
430 |
+
/**
|
431 |
+
* @param string $action_id
|
432 |
+
*
|
433 |
+
* @throws InvalidArgumentException
|
434 |
+
* @return ActionScheduler_DateTime The date the action is schedule to run, or the date that it ran.
|
435 |
+
*/
|
436 |
+
public function get_date_gmt( $action_id ) {
|
437 |
+
$post = get_post($action_id);
|
438 |
+
if ( empty($post) || ($post->post_type != self::POST_TYPE) ) {
|
439 |
+
throw new InvalidArgumentException(sprintf(__('Unidentified action %s', 'action-scheduler'), $action_id));
|
440 |
+
}
|
441 |
+
if ( $post->post_status == 'publish' ) {
|
442 |
+
return as_get_datetime_object($post->post_modified_gmt);
|
443 |
+
} else {
|
444 |
+
return as_get_datetime_object($post->post_date_gmt);
|
445 |
+
}
|
446 |
+
}
|
447 |
+
|
448 |
+
/**
|
449 |
+
* @param int $max_actions
|
450 |
+
* @param DateTime $before_date Jobs must be schedule before this date. Defaults to now.
|
451 |
+
* @param array $hooks Claim only actions with a hook or hooks.
|
452 |
+
* @param string $group Claim only actions in the given group.
|
453 |
+
*
|
454 |
+
* @return ActionScheduler_ActionClaim
|
455 |
+
* @throws RuntimeException When there is an error staking a claim.
|
456 |
+
* @throws InvalidArgumentException When the given group is not valid.
|
457 |
+
*/
|
458 |
+
public function stake_claim( $max_actions = 10, DateTime $before_date = null, $hooks = array(), $group = '' ) {
|
459 |
+
$claim_id = $this->generate_claim_id();
|
460 |
+
$this->claim_actions( $claim_id, $max_actions, $before_date, $hooks, $group );
|
461 |
+
$action_ids = $this->find_actions_by_claim_id( $claim_id );
|
462 |
+
|
463 |
+
return new ActionScheduler_ActionClaim( $claim_id, $action_ids );
|
464 |
+
}
|
465 |
+
|
466 |
+
/**
|
467 |
+
* @return int
|
468 |
+
*/
|
469 |
+
public function get_claim_count(){
|
470 |
+
global $wpdb;
|
471 |
+
|
472 |
+
$sql = "SELECT COUNT(DISTINCT post_password) FROM {$wpdb->posts} WHERE post_password != '' AND post_type = %s AND post_status IN ('in-progress','pending')";
|
473 |
+
$sql = $wpdb->prepare( $sql, array( self::POST_TYPE ) );
|
474 |
+
|
475 |
+
return $wpdb->get_var( $sql );
|
476 |
+
}
|
477 |
+
|
478 |
+
protected function generate_claim_id() {
|
479 |
+
$claim_id = md5(microtime(true) . rand(0,1000));
|
480 |
+
return substr($claim_id, 0, 20); // to fit in db field with 20 char limit
|
481 |
+
}
|
482 |
+
|
483 |
+
/**
|
484 |
+
* @param string $claim_id
|
485 |
+
* @param int $limit
|
486 |
+
* @param DateTime $before_date Should use UTC timezone.
|
487 |
+
* @param array $hooks Claim only actions with a hook or hooks.
|
488 |
+
* @param string $group Claim only actions in the given group.
|
489 |
+
*
|
490 |
+
* @return int The number of actions that were claimed
|
491 |
+
* @throws RuntimeException When there is a database error.
|
492 |
+
* @throws InvalidArgumentException When the group is invalid.
|
493 |
+
*/
|
494 |
+
protected function claim_actions( $claim_id, $limit, DateTime $before_date = null, $hooks = array(), $group = '' ) {
|
495 |
+
// Set up initial variables.
|
496 |
+
$date = null === $before_date ? as_get_datetime_object() : clone $before_date;
|
497 |
+
$limit_ids = ! empty( $group );
|
498 |
+
$ids = $limit_ids ? $this->get_actions_by_group( $group, $limit, $date ) : array();
|
499 |
+
|
500 |
+
// If limiting by IDs and no posts found, then return early since we have nothing to update.
|
501 |
+
if ( $limit_ids && 0 === count( $ids ) ) {
|
502 |
+
return 0;
|
503 |
+
}
|
504 |
+
|
505 |
+
/** @var wpdb $wpdb */
|
506 |
+
global $wpdb;
|
507 |
+
|
508 |
+
/*
|
509 |
+
* Build up custom query to update the affected posts. Parameters are built as a separate array
|
510 |
+
* to make it easier to identify where they are in the query.
|
511 |
+
*
|
512 |
+
* We can't use $wpdb->update() here because of the "ID IN ..." clause.
|
513 |
+
*/
|
514 |
+
$update = "UPDATE {$wpdb->posts} SET post_password = %s, post_modified_gmt = %s, post_modified = %s";
|
515 |
+
$params = array(
|
516 |
+
$claim_id,
|
517 |
+
current_time( 'mysql', true ),
|
518 |
+
current_time( 'mysql' ),
|
519 |
+
);
|
520 |
+
|
521 |
+
// Build initial WHERE clause.
|
522 |
+
$where = "WHERE post_type = %s AND post_status = %s AND post_password = ''";
|
523 |
+
$params[] = self::POST_TYPE;
|
524 |
+
$params[] = ActionScheduler_Store::STATUS_PENDING;
|
525 |
+
|
526 |
+
if ( ! empty( $hooks ) ) {
|
527 |
+
$placeholders = array_fill( 0, count( $hooks ), '%s' );
|
528 |
+
$where .= ' AND post_title IN (' . join( ', ', $placeholders ) . ')';
|
529 |
+
$params = array_merge( $params, array_values( $hooks ) );
|
530 |
+
}
|
531 |
+
|
532 |
+
/*
|
533 |
+
* Add the IDs to the WHERE clause. IDs not escaped because they came directly from a prior DB query.
|
534 |
+
*
|
535 |
+
* If we're not limiting by IDs, then include the post_date_gmt clause.
|
536 |
+
*/
|
537 |
+
if ( $limit_ids ) {
|
538 |
+
$where .= ' AND ID IN (' . join( ',', $ids ) . ')';
|
539 |
+
} else {
|
540 |
+
$where .= ' AND post_date_gmt <= %s';
|
541 |
+
$params[] = $date->format( 'Y-m-d H:i:s' );
|
542 |
+
}
|
543 |
+
|
544 |
+
// Add the ORDER BY clause and,ms limit.
|
545 |
+
$order = 'ORDER BY menu_order ASC, post_date_gmt ASC, ID ASC LIMIT %d';
|
546 |
+
$params[] = $limit;
|
547 |
+
|
548 |
+
// Run the query and gather results.
|
549 |
+
$rows_affected = $wpdb->query( $wpdb->prepare( "{$update} {$where} {$order}", $params ) );
|
550 |
+
if ( $rows_affected === false ) {
|
551 |
+
throw new RuntimeException( __( 'Unable to claim actions. Database error.', 'action-scheduler' ) );
|
552 |
+
}
|
553 |
+
|
554 |
+
return (int) $rows_affected;
|
555 |
+
}
|
556 |
+
|
557 |
+
/**
|
558 |
+
* Get IDs of actions within a certain group and up to a certain date/time.
|
559 |
+
*
|
560 |
+
* @param string $group The group to use in finding actions.
|
561 |
+
* @param int $limit The number of actions to retrieve.
|
562 |
+
* @param DateTime $date DateTime object representing cutoff time for actions. Actions retrieved will be
|
563 |
+
* up to and including this DateTime.
|
564 |
+
*
|
565 |
+
* @return array IDs of actions in the appropriate group and before the appropriate time.
|
566 |
+
* @throws InvalidArgumentException When the group does not exist.
|
567 |
+
*/
|
568 |
+
protected function get_actions_by_group( $group, $limit, DateTime $date ) {
|
569 |
+
// Ensure the group exists before continuing.
|
570 |
+
if ( ! term_exists( $group, self::GROUP_TAXONOMY )) {
|
571 |
+
throw new InvalidArgumentException( sprintf( __( 'The group "%s" does not exist.', 'action-scheduler' ), $group ) );
|
572 |
+
}
|
573 |
+
|
574 |
+
// Set up a query for post IDs to use later.
|
575 |
+
$query = new WP_Query();
|
576 |
+
$query_args = array(
|
577 |
+
'fields' => 'ids',
|
578 |
+
'post_type' => self::POST_TYPE,
|
579 |
+
'post_status' => ActionScheduler_Store::STATUS_PENDING,
|
580 |
+
'has_password' => false,
|
581 |
+
'posts_per_page' => $limit * 3,
|
582 |
+
'suppress_filters' => true,
|
583 |
+
'no_found_rows' => true,
|
584 |
+
'orderby' => array(
|
585 |
+
'menu_order' => 'ASC',
|
586 |
+
'date' => 'ASC',
|
587 |
+
'ID' => 'ASC',
|
588 |
+
),
|
589 |
+
'date_query' => array(
|
590 |
+
'column' => 'post_date',
|
591 |
+
array(
|
592 |
+
'compare' => '<=',
|
593 |
+
'year' => $date->format( 'Y' ),
|
594 |
+
'month' => $date->format( 'n' ),
|
595 |
+
'day' => $date->format( 'j' ),
|
596 |
+
'hour' => $date->format( 'G' ),
|
597 |
+
'minute' => $date->format( 'i' ),
|
598 |
+
'second' => $date->format( 's' ),
|
599 |
+
),
|
600 |
+
),
|
601 |
+
'tax_query' => array(
|
602 |
+
array(
|
603 |
+
'taxonomy' => self::GROUP_TAXONOMY,
|
604 |
+
'field' => 'slug',
|
605 |
+
'terms' => $group,
|
606 |
+
'include_children' => false,
|
607 |
+
),
|
608 |
+
),
|
609 |
+
);
|
610 |
+
|
611 |
+
return $query->query( $query_args );
|
612 |
+
}
|
613 |
+
|
614 |
+
/**
|
615 |
+
* @param string $claim_id
|
616 |
+
* @return array
|
617 |
+
*/
|
618 |
+
public function find_actions_by_claim_id( $claim_id ) {
|
619 |
+
/** @var wpdb $wpdb */
|
620 |
+
global $wpdb;
|
621 |
+
$sql = "SELECT ID FROM {$wpdb->posts} WHERE post_type = %s AND post_password = %s";
|
622 |
+
$sql = $wpdb->prepare( $sql, array( self::POST_TYPE, $claim_id ) );
|
623 |
+
$action_ids = $wpdb->get_col( $sql );
|
624 |
+
return $action_ids;
|
625 |
+
}
|
626 |
+
|
627 |
+
public function release_claim( ActionScheduler_ActionClaim $claim ) {
|
628 |
+
$action_ids = $this->find_actions_by_claim_id( $claim->get_id() );
|
629 |
+
if ( empty($action_ids) ) {
|
630 |
+
return; // nothing to do
|
631 |
+
}
|
632 |
+
$action_id_string = implode(',', array_map('intval', $action_ids));
|
633 |
+
/** @var wpdb $wpdb */
|
634 |
+
global $wpdb;
|
635 |
+
$sql = "UPDATE {$wpdb->posts} SET post_password = '' WHERE ID IN ($action_id_string) AND post_password = %s";
|
636 |
+
$sql = $wpdb->prepare( $sql, array( $claim->get_id() ) );
|
637 |
+
$result = $wpdb->query($sql);
|
638 |
+
if ( $result === false ) {
|
639 |
+
throw new RuntimeException( sprintf( __('Unable to unlock claim %s. Database error.', 'action-scheduler'), $claim->get_id() ) );
|
640 |
+
}
|
641 |
+
}
|
642 |
+
|
643 |
+
/**
|
644 |
+
* @param string $action_id
|
645 |
+
*/
|
646 |
+
public function unclaim_action( $action_id ) {
|
647 |
+
/** @var wpdb $wpdb */
|
648 |
+
global $wpdb;
|
649 |
+
$sql = "UPDATE {$wpdb->posts} SET post_password = '' WHERE ID = %d AND post_type = %s";
|
650 |
+
$sql = $wpdb->prepare( $sql, $action_id, self::POST_TYPE );
|
651 |
+
$result = $wpdb->query($sql);
|
652 |
+
if ( $result === false ) {
|
653 |
+
throw new RuntimeException( sprintf( __('Unable to unlock claim on action %s. Database error.', 'action-scheduler'), $action_id ) );
|
654 |
+
}
|
655 |
+
}
|
656 |
+
|
657 |
+
public function mark_failure( $action_id ) {
|
658 |
+
/** @var wpdb $wpdb */
|
659 |
+
global $wpdb;
|
660 |
+
$sql = "UPDATE {$wpdb->posts} SET post_status = %s WHERE ID = %d AND post_type = %s";
|
661 |
+
$sql = $wpdb->prepare( $sql, self::STATUS_FAILED, $action_id, self::POST_TYPE );
|
662 |
+
$result = $wpdb->query($sql);
|
663 |
+
if ( $result === false ) {
|
664 |
+
throw new RuntimeException( sprintf( __('Unable to mark failure on action %s. Database error.', 'action-scheduler'), $action_id ) );
|
665 |
+
}
|
666 |
+
}
|
667 |
+
|
668 |
+
/**
|
669 |
+
* Return an action's claim ID, as stored in the post password column
|
670 |
+
*
|
671 |
+
* @param string $action_id
|
672 |
+
* @return mixed
|
673 |
+
*/
|
674 |
+
public function get_claim_id( $action_id ) {
|
675 |
+
return $this->get_post_column( $action_id, 'post_password' );
|
676 |
+
}
|
677 |
+
|
678 |
+
/**
|
679 |
+
* Return an action's status, as stored in the post status column
|
680 |
+
*
|
681 |
+
* @param string $action_id
|
682 |
+
* @return mixed
|
683 |
+
*/
|
684 |
+
public function get_status( $action_id ) {
|
685 |
+
$status = $this->get_post_column( $action_id, 'post_status' );
|
686 |
+
|
687 |
+
if ( $status === null ) {
|
688 |
+
throw new \InvalidArgumentException( __( 'Invalid action ID. No status found.', 'action-scheduler' ) );
|
689 |
+
}
|
690 |
+
|
691 |
+
return $this->get_action_status_by_post_status( $status );
|
692 |
+
}
|
693 |
+
|
694 |
+
private function get_post_column( $action_id, $column_name ) {
|
695 |
+
/** @var \wpdb $wpdb */
|
696 |
+
global $wpdb;
|
697 |
+
return $wpdb->get_var( $wpdb->prepare( "SELECT {$column_name} FROM {$wpdb->posts} WHERE ID=%d AND post_type=%s", $action_id, self::POST_TYPE ) );
|
698 |
+
}
|
699 |
+
|
700 |
+
/**
|
701 |
+
* @param string $action_id
|
702 |
+
*/
|
703 |
+
public function log_execution( $action_id ) {
|
704 |
+
/** @var wpdb $wpdb */
|
705 |
+
global $wpdb;
|
706 |
+
|
707 |
+
$sql = "UPDATE {$wpdb->posts} SET menu_order = menu_order+1, post_status=%s, post_modified_gmt = %s, post_modified = %s WHERE ID = %d AND post_type = %s";
|
708 |
+
$sql = $wpdb->prepare( $sql, self::STATUS_RUNNING, current_time('mysql', true), current_time('mysql'), $action_id, self::POST_TYPE );
|
709 |
+
$wpdb->query($sql);
|
710 |
+
}
|
711 |
+
|
712 |
+
|
713 |
+
public function mark_complete( $action_id ) {
|
714 |
+
$post = get_post($action_id);
|
715 |
+
if ( empty($post) || ($post->post_type != self::POST_TYPE) ) {
|
716 |
+
throw new InvalidArgumentException(sprintf(__('Unidentified action %s', 'action-scheduler'), $action_id));
|
717 |
+
}
|
718 |
+
add_filter( 'wp_insert_post_data', array( $this, 'filter_insert_post_data' ), 10, 1 );
|
719 |
+
$result = wp_update_post(array(
|
720 |
+
'ID' => $action_id,
|
721 |
+
'post_status' => 'publish',
|
722 |
+
), TRUE);
|
723 |
+
remove_filter( 'wp_insert_post_data', array( $this, 'filter_insert_post_data' ), 10 );
|
724 |
+
if ( is_wp_error($result) ) {
|
725 |
+
throw new RuntimeException($result->get_error_message());
|
726 |
+
}
|
727 |
+
}
|
728 |
+
|
729 |
+
/**
|
730 |
+
* InnoDB indexes have a maximum size of 767 bytes by default, which is only 191 characters with utf8mb4.
|
731 |
+
*
|
732 |
+
* Previously, AS wasn't concerned about args length, as we used the (unindex) post_content column. However,
|
733 |
+
* as we prepare to move to custom tables, and can use an indexed VARCHAR column instead, we want to warn
|
734 |
+
* developers of this impending requirement.
|
735 |
+
*
|
736 |
+
* @param ActionScheduler_Action $action
|
737 |
+
*/
|
738 |
+
protected function validate_action( ActionScheduler_Action $action ) {
|
739 |
+
if ( strlen( json_encode( $action->get_args() ) ) > self::$max_index_length ) {
|
740 |
+
_doing_it_wrong( 'ActionScheduler_Action::$args', sprintf( 'To ensure the action args column can be indexed, action args should not be more than %d characters when encoded as JSON. Support for strings longer than this will be removed in a future version.', self::$max_index_length ), '2.1.0' );
|
741 |
+
}
|
742 |
+
}
|
743 |
+
|
744 |
+
/**
|
745 |
+
* @codeCoverageIgnore
|
746 |
+
*/
|
747 |
+
public function init() {
|
748 |
+
$post_type_registrar = new ActionScheduler_wpPostStore_PostTypeRegistrar();
|
749 |
+
$post_type_registrar->register();
|
750 |
+
|
751 |
+
$post_status_registrar = new ActionScheduler_wpPostStore_PostStatusRegistrar();
|
752 |
+
$post_status_registrar->register();
|
753 |
+
|
754 |
+
$taxonomy_registrar = new ActionScheduler_wpPostStore_TaxonomyRegistrar();
|
755 |
+
$taxonomy_registrar->register();
|
756 |
+
}
|
757 |
+
}
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_wpPostStore_PostStatusRegistrar.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_wpPostStore_PostStatusRegistrar
|
5 |
+
* @codeCoverageIgnore
|
6 |
+
*/
|
7 |
+
class ActionScheduler_wpPostStore_PostStatusRegistrar {
|
8 |
+
public function register() {
|
9 |
+
register_post_status( ActionScheduler_Store::STATUS_RUNNING, array_merge( $this->post_status_args(), $this->post_status_running_labels() ) );
|
10 |
+
register_post_status( ActionScheduler_Store::STATUS_FAILED, array_merge( $this->post_status_args(), $this->post_status_failed_labels() ) );
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Build the args array for the post type definition
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
protected function post_status_args() {
|
19 |
+
$args = array(
|
20 |
+
'public' => false,
|
21 |
+
'exclude_from_search' => false,
|
22 |
+
'show_in_admin_all_list' => true,
|
23 |
+
'show_in_admin_status_list' => true,
|
24 |
+
);
|
25 |
+
|
26 |
+
return apply_filters( 'action_scheduler_post_status_args', $args );
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Build the args array for the post type definition
|
31 |
+
*
|
32 |
+
* @return array
|
33 |
+
*/
|
34 |
+
protected function post_status_failed_labels() {
|
35 |
+
$labels = array(
|
36 |
+
'label' => _x( 'Failed', 'post' ),
|
37 |
+
'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>' ),
|
38 |
+
);
|
39 |
+
|
40 |
+
return apply_filters( 'action_scheduler_post_status_failed_labels', $labels );
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Build the args array for the post type definition
|
45 |
+
*
|
46 |
+
* @return array
|
47 |
+
*/
|
48 |
+
protected function post_status_running_labels() {
|
49 |
+
$labels = array(
|
50 |
+
'label' => _x( 'In-Progress', 'post' ),
|
51 |
+
'label_count' => _n_noop( 'In-Progress <span class="count">(%s)</span>', 'In-Progress <span class="count">(%s)</span>' ),
|
52 |
+
);
|
53 |
+
|
54 |
+
return apply_filters( 'action_scheduler_post_status_running_labels', $labels );
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_wpPostStore_PostTypeRegistrar.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_wpPostStore_PostTypeRegistrar
|
5 |
+
* @codeCoverageIgnore
|
6 |
+
*/
|
7 |
+
class ActionScheduler_wpPostStore_PostTypeRegistrar {
|
8 |
+
public function register() {
|
9 |
+
register_post_type( ActionScheduler_wpPostStore::POST_TYPE, $this->post_type_args() );
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Build the args array for the post type definition
|
14 |
+
*
|
15 |
+
* @return array
|
16 |
+
*/
|
17 |
+
protected function post_type_args() {
|
18 |
+
$args = array(
|
19 |
+
'label' => __( 'Scheduled Actions', 'action-scheduler' ),
|
20 |
+
'description' => __( 'Scheduled actions are hooks triggered on a cetain date and time.', 'action-scheduler' ),
|
21 |
+
'public' => false,
|
22 |
+
'map_meta_cap' => true,
|
23 |
+
'hierarchical' => false,
|
24 |
+
'supports' => array('title', 'editor','comments'),
|
25 |
+
'rewrite' => false,
|
26 |
+
'query_var' => false,
|
27 |
+
'can_export' => true,
|
28 |
+
'ep_mask' => EP_NONE,
|
29 |
+
'labels' => array(
|
30 |
+
'name' => __( 'Scheduled Actions', 'action-scheduler' ),
|
31 |
+
'singular_name' => __( 'Scheduled Action', 'action-scheduler' ),
|
32 |
+
'menu_name' => _x( 'Scheduled Actions', 'Admin menu name', 'action-scheduler' ),
|
33 |
+
'add_new' => __( 'Add', 'action-scheduler' ),
|
34 |
+
'add_new_item' => __( 'Add New Scheduled Action', 'action-scheduler' ),
|
35 |
+
'edit' => __( 'Edit', 'action-scheduler' ),
|
36 |
+
'edit_item' => __( 'Edit Scheduled Action', 'action-scheduler' ),
|
37 |
+
'new_item' => __( 'New Scheduled Action', 'action-scheduler' ),
|
38 |
+
'view' => __( 'View Action', 'action-scheduler' ),
|
39 |
+
'view_item' => __( 'View Action', 'action-scheduler' ),
|
40 |
+
'search_items' => __( 'Search Scheduled Actions', 'action-scheduler' ),
|
41 |
+
'not_found' => __( 'No actions found', 'action-scheduler' ),
|
42 |
+
'not_found_in_trash' => __( 'No actions found in trash', 'action-scheduler' ),
|
43 |
+
),
|
44 |
+
);
|
45 |
+
|
46 |
+
$args = apply_filters('action_scheduler_post_type_args', $args);
|
47 |
+
return $args;
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
trunk/includes/lib/action-scheduler/classes/ActionScheduler_wpPostStore_TaxonomyRegistrar.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_wpPostStore_TaxonomyRegistrar
|
5 |
+
* @codeCoverageIgnore
|
6 |
+
*/
|
7 |
+
class ActionScheduler_wpPostStore_TaxonomyRegistrar {
|
8 |
+
public function register() {
|
9 |
+
register_taxonomy( ActionScheduler_wpPostStore::GROUP_TAXONOMY, ActionScheduler_wpPostStore::POST_TYPE, $this->taxonomy_args() );
|
10 |
+
}
|
11 |
+
|
12 |
+
protected function taxonomy_args() {
|
13 |
+
$args = array(
|
14 |
+
'label' => __('Action Group', 'action-scheduler'),
|
15 |
+
'public' => false,
|
16 |
+
'hierarchical' => false,
|
17 |
+
'show_admin_column' => true,
|
18 |
+
'query_var' => false,
|
19 |
+
'rewrite' => false,
|
20 |
+
);
|
21 |
+
|
22 |
+
$args = apply_filters('action_scheduler_taxonomy_args', $args);
|
23 |
+
return $args;
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
trunk/includes/lib/action-scheduler/codecov.yml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
codecov:
|
2 |
+
branch: master
|
3 |
+
|
4 |
+
coverage:
|
5 |
+
ignore:
|
6 |
+
- tests/.*
|
7 |
+
- lib/.*
|
8 |
+
status:
|
9 |
+
project: false
|
10 |
+
patch: false
|
11 |
+
changes: false
|
12 |
+
|
13 |
+
comment: false
|
trunk/includes/lib/action-scheduler/composer.json
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "prospress/action-scheduler",
|
3 |
+
"description": "Action Scheduler for WordPress and WooCommerce",
|
4 |
+
"type": "wordpress-plugin",
|
5 |
+
"license": "GPL-3.0",
|
6 |
+
"minimum-stability": "dev",
|
7 |
+
"require": {},
|
8 |
+
"require-dev": {
|
9 |
+
"wp-cli/wp-cli": "^1.3"
|
10 |
+
}
|
11 |
+
}
|
trunk/includes/lib/action-scheduler/composer.lock
ADDED
@@ -0,0 +1,2909 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_readme": [
|
3 |
+
"This file locks the dependencies of your project to a known state",
|
4 |
+
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
5 |
+
"This file is @generated automatically"
|
6 |
+
],
|
7 |
+
"content-hash": "f4556531e7b95173d1b769b3d7350926",
|
8 |
+
"packages": [],
|
9 |
+
"packages-dev": [
|
10 |
+
{
|
11 |
+
"name": "composer/ca-bundle",
|
12 |
+
"version": "dev-master",
|
13 |
+
"source": {
|
14 |
+
"type": "git",
|
15 |
+
"url": "https://github.com/composer/ca-bundle.git",
|
16 |
+
"reference": "b17e6153cb7f33c7e44eb59578dc12eee5dc8e12"
|
17 |
+
},
|
18 |
+
"dist": {
|
19 |
+
"type": "zip",
|
20 |
+
"url": "https://api.github.com/repos/composer/ca-bundle/zipball/b17e6153cb7f33c7e44eb59578dc12eee5dc8e12",
|
21 |
+
"reference": "b17e6153cb7f33c7e44eb59578dc12eee5dc8e12",
|
22 |
+
"shasum": ""
|
23 |
+
},
|
24 |
+
"require": {
|
25 |
+
"ext-openssl": "*",
|
26 |
+
"ext-pcre": "*",
|
27 |
+
"php": "^5.3.2 || ^7.0"
|
28 |
+
},
|
29 |
+
"require-dev": {
|
30 |
+
"phpunit/phpunit": "^4.5",
|
31 |
+
"psr/log": "^1.0",
|
32 |
+
"symfony/process": "^2.5 || ^3.0"
|
33 |
+
},
|
34 |
+
"suggest": {
|
35 |
+
"symfony/process": "This is necessary to reliably check whether openssl_x509_parse is vulnerable on older php versions, but can be ignored on PHP 5.5.6+"
|
36 |
+
},
|
37 |
+
"type": "library",
|
38 |
+
"extra": {
|
39 |
+
"branch-alias": {
|
40 |
+
"dev-master": "1.x-dev"
|
41 |
+
}
|
42 |
+
},
|
43 |
+
"autoload": {
|
44 |
+
"psr-4": {
|
45 |
+
"Composer\\CaBundle\\": "src"
|
46 |
+
}
|
47 |
+
},
|
48 |
+
"notification-url": "https://packagist.org/downloads/",
|
49 |
+
"license": [
|
50 |
+
"MIT"
|
51 |
+
],
|
52 |
+
"authors": [
|
53 |
+
{
|
54 |
+
"name": "Jordi Boggiano",
|
55 |
+
"email": "j.boggiano@seld.be",
|
56 |
+
"homepage": "http://seld.be"
|
57 |
+
}
|
58 |
+
],
|
59 |
+
"description": "Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.",
|
60 |
+
"keywords": [
|
61 |
+
"cabundle",
|
62 |
+
"cacert",
|
63 |
+
"certificate",
|
64 |
+
"ssl",
|
65 |
+
"tls"
|
66 |
+
],
|
67 |
+
"time": "2017-03-06T11:59:08+00:00"
|
68 |
+
},
|
69 |
+
{
|
70 |
+
"name": "composer/composer",
|
71 |
+
"version": "dev-master",
|
72 |
+
"source": {
|
73 |
+
"type": "git",
|
74 |
+
"url": "https://github.com/composer/composer.git",
|
75 |
+
"reference": "82c27a68bc5cb76f3d00b82c27496e3cdbb6d4ff"
|
76 |
+
},
|
77 |
+
"dist": {
|
78 |
+
"type": "zip",
|
79 |
+
"url": "https://api.github.com/repos/composer/composer/zipball/82c27a68bc5cb76f3d00b82c27496e3cdbb6d4ff",
|
80 |
+
"reference": "82c27a68bc5cb76f3d00b82c27496e3cdbb6d4ff",
|
81 |
+
"shasum": ""
|
82 |
+
},
|
83 |
+
"require": {
|
84 |
+
"composer/ca-bundle": "^1.0",
|
85 |
+
"composer/semver": "^1.0",
|
86 |
+
"composer/spdx-licenses": "^1.0",
|
87 |
+
"justinrainbow/json-schema": "^3.0 || ^4.0 || ^5.0",
|
88 |
+
"php": "^5.3.2 || ^7.0",
|
89 |
+
"psr/log": "^1.0",
|
90 |
+
"seld/cli-prompt": "^1.0",
|
91 |
+
"seld/jsonlint": "^1.4",
|
92 |
+
"seld/phar-utils": "^1.0",
|
93 |
+
"symfony/console": "^2.7 || ^3.0",
|
94 |
+
"symfony/filesystem": "^2.7 || ^3.0",
|
95 |
+
"symfony/finder": "^2.7 || ^3.0",
|
96 |
+
"symfony/process": "^2.7 || ^3.0"
|
97 |
+
},
|
98 |
+
"require-dev": {
|
99 |
+
"phpunit/phpunit": "^4.5 || ^5.0.5",
|
100 |
+
"phpunit/phpunit-mock-objects": "^2.3 || ^3.0"
|
101 |
+
},
|
102 |
+
"suggest": {
|
103 |
+
"ext-openssl": "Enabling the openssl extension allows you to access https URLs for repositories and packages",
|
104 |
+
"ext-zip": "Enabling the zip extension allows you to unzip archives",
|
105 |
+
"ext-zlib": "Allow gzip compression of HTTP requests"
|
106 |
+
},
|
107 |
+
"bin": [
|
108 |
+
"bin/composer"
|
109 |
+
],
|
110 |
+
"type": "library",
|
111 |
+
"extra": {
|
112 |
+
"branch-alias": {
|
113 |
+
"dev-master": "1.6-dev"
|
114 |
+
}
|
115 |
+
},
|
116 |
+
"autoload": {
|
117 |
+
"psr-4": {
|
118 |
+
"Composer\\": "src/Composer"
|
119 |
+
}
|
120 |
+
},
|
121 |
+
"notification-url": "https://packagist.org/downloads/",
|
122 |
+
"license": [
|
123 |
+
"MIT"
|
124 |
+
],
|
125 |
+
"authors": [
|
126 |
+
{
|
127 |
+
"name": "Nils Adermann",
|
128 |
+
"email": "naderman@naderman.de",
|
129 |
+
"homepage": "http://www.naderman.de"
|
130 |
+
},
|
131 |
+
{
|
132 |
+
"name": "Jordi Boggiano",
|
133 |
+
"email": "j.boggiano@seld.be",
|
134 |
+
"homepage": "http://seld.be"
|
135 |
+
}
|
136 |
+
],
|
137 |
+
"description": "Composer helps you declare, manage and install dependencies of PHP projects, ensuring you have the right stack everywhere.",
|
138 |
+
"homepage": "https://getcomposer.org/",
|
139 |
+
"keywords": [
|
140 |
+
"autoload",
|
141 |
+
"dependency",
|
142 |
+
"package"
|
143 |
+
],
|
144 |
+
"time": "2017-08-09T14:23:46+00:00"
|
145 |
+
},
|
146 |
+
{
|
147 |
+
"name": "composer/semver",
|
148 |
+
"version": "dev-master",
|
149 |
+
"source": {
|
150 |
+
"type": "git",
|
151 |
+
"url": "https://github.com/composer/semver.git",
|
152 |
+
"reference": "7ea669582e6396857cf6d1c0a6cd2728f4e7e383"
|
153 |
+
},
|
154 |
+
"dist": {
|
155 |
+
"type": "zip",
|
156 |
+
"url": "https://api.github.com/repos/composer/semver/zipball/7ea669582e6396857cf6d1c0a6cd2728f4e7e383",
|
157 |
+
"reference": "7ea669582e6396857cf6d1c0a6cd2728f4e7e383",
|
158 |
+
"shasum": ""
|
159 |
+
},
|
160 |
+
"require": {
|
161 |
+
"php": "^5.3.2 || ^7.0"
|
162 |
+
},
|
163 |
+
"require-dev": {
|
164 |
+
"phpunit/phpunit": "^4.5 || ^5.0.5",
|
165 |
+
"phpunit/phpunit-mock-objects": "2.3.0 || ^3.0"
|
166 |
+
},
|
167 |
+
"type": "library",
|
168 |
+
"extra": {
|
169 |
+
"branch-alias": {
|
170 |
+
"dev-master": "1.x-dev"
|
171 |
+
}
|
172 |
+
},
|
173 |
+
"autoload": {
|
174 |
+
"psr-4": {
|
175 |
+
"Composer\\Semver\\": "src"
|
176 |
+
}
|
177 |
+
},
|
178 |
+
"notification-url": "https://packagist.org/downloads/",
|
179 |
+
"license": [
|
180 |
+
"MIT"
|
181 |
+
],
|
182 |
+
"authors": [
|
183 |
+
{
|
184 |
+
"name": "Nils Adermann",
|
185 |
+
"email": "naderman@naderman.de",
|
186 |
+
"homepage": "http://www.naderman.de"
|
187 |
+
},
|
188 |
+
{
|
189 |
+
"name": "Jordi Boggiano",
|
190 |
+
"email": "j.boggiano@seld.be",
|
191 |
+
"homepage": "http://seld.be"
|
192 |
+
},
|
193 |
+
{
|
194 |
+
"name": "Rob Bast",
|
195 |
+
"email": "rob.bast@gmail.com",
|
196 |
+
"homepage": "http://robbast.nl"
|
197 |
+
}
|
198 |
+
],
|
199 |
+
"description": "Semver library that offers utilities, version constraint parsing and validation.",
|
200 |
+
"keywords": [
|
201 |
+
"semantic",
|
202 |
+
"semver",
|
203 |
+
"validation",
|
204 |
+
"versioning"
|
205 |
+
],
|
206 |
+
"time": "2017-05-15T12:49:06+00:00"
|
207 |
+
},
|
208 |
+
{
|
209 |
+
"name": "composer/spdx-licenses",
|
210 |
+
"version": "dev-master",
|
211 |
+
"source": {
|
212 |
+
"type": "git",
|
213 |
+
"url": "https://github.com/composer/spdx-licenses.git",
|
214 |
+
"reference": "2603a0d7ddc00a015deb576fa5297ca43dee6b1c"
|
215 |
+
},
|
216 |
+
"dist": {
|
217 |
+
"type": "zip",
|
218 |
+
"url": "https://api.github.com/repos/composer/spdx-licenses/zipball/2603a0d7ddc00a015deb576fa5297ca43dee6b1c",
|
219 |
+
"reference": "2603a0d7ddc00a015deb576fa5297ca43dee6b1c",
|
220 |
+
"shasum": ""
|
221 |
+
},
|
222 |
+
"require": {
|
223 |
+
"php": "^5.3.2 || ^7.0"
|
224 |
+
},
|
225 |
+
"require-dev": {
|
226 |
+
"phpunit/phpunit": "^4.5 || ^5.0.5",
|
227 |
+
"phpunit/phpunit-mock-objects": "2.3.0 || ^3.0"
|
228 |
+
},
|
229 |
+
"type": "library",
|
230 |
+
"extra": {
|
231 |
+
"branch-alias": {
|
232 |
+
"dev-master": "1.x-dev"
|
233 |
+
}
|
234 |
+
},
|
235 |
+
"autoload": {
|
236 |
+
"psr-4": {
|
237 |
+
"Composer\\Spdx\\": "src"
|
238 |
+
}
|
239 |
+
},
|
240 |
+
"notification-url": "https://packagist.org/downloads/",
|
241 |
+
"license": [
|
242 |
+
"MIT"
|
243 |
+
],
|
244 |
+
"authors": [
|
245 |
+
{
|
246 |
+
"name": "Nils Adermann",
|
247 |
+
"email": "naderman@naderman.de",
|
248 |
+
"homepage": "http://www.naderman.de"
|
249 |
+
},
|
250 |
+
{
|
251 |
+
"name": "Jordi Boggiano",
|
252 |
+
"email": "j.boggiano@seld.be",
|
253 |
+
"homepage": "http://seld.be"
|
254 |
+
},
|
255 |
+
{
|
256 |
+
"name": "Rob Bast",
|
257 |
+
"email": "rob.bast@gmail.com",
|
258 |
+
"homepage": "http://robbast.nl"
|
259 |
+
}
|
260 |
+
],
|
261 |
+
"description": "SPDX licenses list and validation library.",
|
262 |
+
"keywords": [
|
263 |
+
"license",
|
264 |
+
"spdx",
|
265 |
+
"validator"
|
266 |
+
],
|
267 |
+
"time": "2017-04-03T19:08:52+00:00"
|
268 |
+
},
|
269 |
+
{
|
270 |
+
"name": "justinrainbow/json-schema",
|
271 |
+
"version": "5.x-dev",
|
272 |
+
"source": {
|
273 |
+
"type": "git",
|
274 |
+
"url": "https://github.com/justinrainbow/json-schema.git",
|
275 |
+
"reference": "36ed4d935f8f5eb958dbd29e1fa5a241ec3ece4d"
|
276 |
+
},
|
277 |
+
"dist": {
|
278 |
+
"type": "zip",
|
279 |
+
"url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/36ed4d935f8f5eb958dbd29e1fa5a241ec3ece4d",
|
280 |
+
"reference": "36ed4d935f8f5eb958dbd29e1fa5a241ec3ece4d",
|
281 |
+
"shasum": ""
|
282 |
+
},
|
283 |
+
"require": {
|
284 |
+
"php": ">=5.3.3"
|
285 |
+
},
|
286 |
+
"require-dev": {
|
287 |
+
"friendsofphp/php-cs-fixer": "^2.1",
|
288 |
+
"json-schema/json-schema-test-suite": "1.2.0",
|
289 |
+
"phpunit/phpunit": "^4.8.22"
|
290 |
+
},
|
291 |
+
"bin": [
|
292 |
+
"bin/validate-json"
|
293 |
+
],
|
294 |
+
"type": "library",
|
295 |
+
"extra": {
|
296 |
+
"branch-alias": {
|
297 |
+
"dev-master": "5.0.x-dev"
|
298 |
+
}
|
299 |
+
},
|
300 |
+
"autoload": {
|
301 |
+
"psr-4": {
|
302 |
+
"JsonSchema\\": "src/JsonSchema/"
|
303 |
+
}
|
304 |
+
},
|
305 |
+
"notification-url": "https://packagist.org/downloads/",
|
306 |
+
"license": [
|
307 |
+
"MIT"
|
308 |
+
],
|
309 |
+
"authors": [
|
310 |
+
{
|
311 |
+
"name": "Bruno Prieto Reis",
|
312 |
+
"email": "bruno.p.reis@gmail.com"
|
313 |
+
},
|
314 |
+
{
|
315 |
+
"name": "Justin Rainbow",
|
316 |
+
"email": "justin.rainbow@gmail.com"
|
317 |
+
},
|
318 |
+
{
|
319 |
+
"name": "Igor Wiedler",
|
320 |
+
"email": "igor@wiedler.ch"
|
321 |
+
},
|
322 |
+
{
|
323 |
+
"name": "Robert Schönthal",
|
324 |
+
"email": "seroscho@googlemail.com"
|
325 |
+
}
|
326 |
+
],
|
327 |
+
"description": "A library to validate a json schema.",
|
328 |
+
"homepage": "https://github.com/justinrainbow/json-schema",
|
329 |
+
"keywords": [
|
330 |
+
"json",
|
331 |
+
"schema"
|
332 |
+
],
|
333 |
+
"time": "2017-06-23T11:43:36+00:00"
|
334 |
+
},
|
335 |
+
{
|
336 |
+
"name": "mustache/mustache",
|
337 |
+
"version": "v2.12.0",
|
338 |
+
"source": {
|
339 |
+
"type": "git",
|
340 |
+
"url": "https://github.com/bobthecow/mustache.php.git",
|
341 |
+
"reference": "fe8fe72e9d580591854de404cc59a1b83ca4d19e"
|
342 |
+
},
|
343 |
+
"dist": {
|
344 |
+
"type": "zip",
|
345 |
+
"url": "https://api.github.com/repos/bobthecow/mustache.php/zipball/fe8fe72e9d580591854de404cc59a1b83ca4d19e",
|
346 |
+
"reference": "fe8fe72e9d580591854de404cc59a1b83ca4d19e",
|
347 |
+
"shasum": ""
|
348 |
+
},
|
349 |
+
"require": {
|
350 |
+
"php": ">=5.2.4"
|
351 |
+
},
|
352 |
+
"require-dev": {
|
353 |
+
"friendsofphp/php-cs-fixer": "~1.11",
|
354 |
+
"phpunit/phpunit": "~3.7|~4.0|~5.0"
|
355 |
+
},
|
356 |
+
"type": "library",
|
357 |
+
"autoload": {
|
358 |
+
"psr-0": {
|
359 |
+
"Mustache": "src/"
|
360 |
+
}
|
361 |
+
},
|
362 |
+
"notification-url": "https://packagist.org/downloads/",
|
363 |
+
"license": [
|
364 |
+
"MIT"
|
365 |
+
],
|
366 |
+
"authors": [
|
367 |
+
{
|
368 |
+
"name": "Justin Hileman",
|
369 |
+
"email": "justin@justinhileman.info",
|
370 |
+
"homepage": "http://justinhileman.com"
|
371 |
+
}
|
372 |
+
],
|
373 |
+
"description": "A Mustache implementation in PHP.",
|
374 |
+
"homepage": "https://github.com/bobthecow/mustache.php",
|
375 |
+
"keywords": [
|
376 |
+
"mustache",
|
377 |
+
"templating"
|
378 |
+
],
|
379 |
+
"time": "2017-07-11T12:54:05+00:00"
|
380 |
+
},
|
381 |
+
{
|
382 |
+
"name": "nb/oxymel",
|
383 |
+
"version": "v0.1.0",
|
384 |
+
"source": {
|
385 |
+
"type": "git",
|
386 |
+
"url": "https://github.com/nb/oxymel.git",
|
387 |
+
"reference": "cbe626ef55d5c4cc9b5e6e3904b395861ea76e3c"
|
388 |
+
},
|
389 |
+
"dist": {
|
390 |
+
"type": "zip",
|
391 |
+
"url": "https://api.github.com/repos/nb/oxymel/zipball/cbe626ef55d5c4cc9b5e6e3904b395861ea76e3c",
|
392 |
+
"reference": "cbe626ef55d5c4cc9b5e6e3904b395861ea76e3c",
|
393 |
+
"shasum": ""
|
394 |
+
},
|
395 |
+
"require": {
|
396 |
+
"php": ">=5.2.4"
|
397 |
+
},
|
398 |
+
"type": "library",
|
399 |
+
"autoload": {
|
400 |
+
"psr-0": {
|
401 |
+
"Oxymel": ""
|
402 |
+
}
|
403 |
+
},
|
404 |
+
"notification-url": "https://packagist.org/downloads/",
|
405 |
+
"license": [
|
406 |
+
"MIT"
|
407 |
+
],
|
408 |
+
"authors": [
|
409 |
+
{
|
410 |
+
"name": "Nikolay Bachiyski",
|
411 |
+
"email": "nb@nikolay.bg",
|
412 |
+
"homepage": "http://extrapolate.me/"
|
413 |
+
}
|
414 |
+
],
|
415 |
+
"description": "A sweet XML builder",
|
416 |
+
"homepage": "https://github.com/nb/oxymel",
|
417 |
+
"keywords": [
|
418 |
+
"xml"
|
419 |
+
],
|
420 |
+
"time": "2013-02-24T15:01:54+00:00"
|
421 |
+
},
|
422 |
+
{
|
423 |
+
"name": "psr/container",
|
424 |
+
"version": "dev-master",
|
425 |
+
"source": {
|
426 |
+
"type": "git",
|
427 |
+
"url": "https://github.com/php-fig/container.git",
|
428 |
+
"reference": "2cc4a01788191489dc7459446ba832fa79a216a7"
|
429 |
+
},
|
430 |
+
"dist": {
|
431 |
+
"type": "zip",
|
432 |
+
"url": "https://api.github.com/repos/php-fig/container/zipball/2cc4a01788191489dc7459446ba832fa79a216a7",
|
433 |
+
"reference": "2cc4a01788191489dc7459446ba832fa79a216a7",
|
434 |
+
"shasum": ""
|
435 |
+
},
|
436 |
+
"require": {
|
437 |
+
"php": ">=5.3.0"
|
438 |
+
},
|
439 |
+
"type": "library",
|
440 |
+
"extra": {
|
441 |
+
"branch-alias": {
|
442 |
+
"dev-master": "1.0.x-dev"
|
443 |
+
}
|
444 |
+
},
|
445 |
+
"autoload": {
|
446 |
+
"psr-4": {
|
447 |
+
"Psr\\Container\\": "src/"
|
448 |
+
}
|
449 |
+
},
|
450 |
+
"notification-url": "https://packagist.org/downloads/",
|
451 |
+
"license": [
|
452 |
+
"MIT"
|
453 |
+
],
|
454 |
+
"authors": [
|
455 |
+
{
|
456 |
+
"name": "PHP-FIG",
|
457 |
+
"homepage": "http://www.php-fig.org/"
|
458 |
+
}
|
459 |
+
],
|
460 |
+
"description": "Common Container Interface (PHP FIG PSR-11)",
|
461 |
+
"homepage": "https://github.com/php-fig/container",
|
462 |
+
"keywords": [
|
463 |
+
"PSR-11",
|
464 |
+
"container",
|
465 |
+
"container-interface",
|
466 |
+
"container-interop",
|
467 |
+
"psr"
|
468 |
+
],
|
469 |
+
"time": "2017-06-28T15:35:32+00:00"
|
470 |
+
},
|
471 |
+
{
|
472 |
+
"name": "psr/log",
|
473 |
+
"version": "dev-master",
|
474 |
+
"source": {
|
475 |
+
"type": "git",
|
476 |
+
"url": "https://github.com/php-fig/log.git",
|
477 |
+
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d"
|
478 |
+
},
|
479 |
+
"dist": {
|
480 |
+
"type": "zip",
|
481 |
+
"url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
|
482 |
+
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
|
483 |
+
"shasum": ""
|
484 |
+
},
|
485 |
+
"require": {
|
486 |
+
"php": ">=5.3.0"
|
487 |
+
},
|
488 |
+
"type": "library",
|
489 |
+
"extra": {
|
490 |
+
"branch-alias": {
|
491 |
+
"dev-master": "1.0.x-dev"
|
492 |
+
}
|
493 |
+
},
|
494 |
+
"autoload": {
|
495 |
+
"psr-4": {
|
496 |
+
"Psr\\Log\\": "Psr/Log/"
|
497 |
+
}
|
498 |
+
},
|
499 |
+
"notification-url": "https://packagist.org/downloads/",
|
500 |
+
"license": [
|
501 |
+
"MIT"
|
502 |
+
],
|
503 |
+
"authors": [
|
504 |
+
{
|
505 |
+
"name": "PHP-FIG",
|
506 |
+
"homepage": "http://www.php-fig.org/"
|
507 |
+
}
|
508 |
+
],
|
509 |
+
"description": "Common interface for logging libraries",
|
510 |
+
"homepage": "https://github.com/php-fig/log",
|
511 |
+
"keywords": [
|
512 |
+
"log",
|
513 |
+
"psr",
|
514 |
+
"psr-3"
|
515 |
+
],
|
516 |
+
"time": "2016-10-10T12:19:37+00:00"
|
517 |
+
},
|
518 |
+
{
|
519 |
+
"name": "ramsey/array_column",
|
520 |
+
"version": "1.1.3",
|
521 |
+
"source": {
|
522 |
+
"type": "git",
|
523 |
+
"url": "https://github.com/ramsey/array_column.git",
|
524 |
+
"reference": "f8e52eb28e67eb50e613b451dd916abcf783c1db"
|
525 |
+
},
|
526 |
+
"dist": {
|
527 |
+
"type": "zip",
|
528 |
+
"url": "https://api.github.com/repos/ramsey/array_column/zipball/f8e52eb28e67eb50e613b451dd916abcf783c1db",
|
529 |
+
"reference": "f8e52eb28e67eb50e613b451dd916abcf783c1db",
|
530 |
+
"shasum": ""
|
531 |
+
},
|
532 |
+
"require-dev": {
|
533 |
+
"jakub-onderka/php-parallel-lint": "0.8.*",
|
534 |
+
"phpunit/phpunit": "~4.5",
|
535 |
+
"satooshi/php-coveralls": "0.6.*",
|
536 |
+
"squizlabs/php_codesniffer": "~2.2"
|
537 |
+
},
|
538 |
+
"type": "library",
|
539 |
+
"autoload": {
|
540 |
+
"files": [
|
541 |
+
"src/array_column.php"
|
542 |
+
]
|
543 |
+
},
|
544 |
+
"notification-url": "https://packagist.org/downloads/",
|
545 |
+
"license": [
|
546 |
+
"MIT"
|
547 |
+
],
|
548 |
+
"authors": [
|
549 |
+
{
|
550 |
+
"name": "Ben Ramsey",
|
551 |
+
"homepage": "http://benramsey.com"
|
552 |
+
}
|
553 |
+
],
|
554 |
+
"description": "Provides functionality for array_column() to projects using PHP earlier than version 5.5.",
|
555 |
+
"homepage": "https://github.com/ramsey/array_column",
|
556 |
+
"keywords": [
|
557 |
+
"array",
|
558 |
+
"array_column",
|
559 |
+
"column"
|
560 |
+
],
|
561 |
+
"time": "2015-03-20T22:07:39+00:00"
|
562 |
+
},
|
563 |
+
{
|
564 |
+
"name": "rmccue/requests",
|
565 |
+
"version": "v1.7.0",
|
566 |
+
"source": {
|
567 |
+
"type": "git",
|
568 |
+
"url": "https://github.com/rmccue/Requests.git",
|
569 |
+
"reference": "87932f52ffad70504d93f04f15690cf16a089546"
|
570 |
+
},
|
571 |
+
"dist": {
|
572 |
+
"type": "zip",
|
573 |
+
"url": "https://api.github.com/repos/rmccue/Requests/zipball/87932f52ffad70504d93f04f15690cf16a089546",
|
574 |
+
"reference": "87932f52ffad70504d93f04f15690cf16a089546",
|
575 |
+
"shasum": ""
|
576 |
+
},
|
577 |
+
"require": {
|
578 |
+
"php": ">=5.2"
|
579 |
+
},
|
580 |
+
"require-dev": {
|
581 |
+
"requests/test-server": "dev-master"
|
582 |
+
},
|
583 |
+
"type": "library",
|
584 |
+
"autoload": {
|
585 |
+
"psr-0": {
|
586 |
+
"Requests": "library/"
|
587 |
+
}
|
588 |
+
},
|
589 |
+
"notification-url": "https://packagist.org/downloads/",
|
590 |
+
"license": [
|
591 |
+
"ISC"
|
592 |
+
],
|
593 |
+
"authors": [
|
594 |
+
{
|
595 |
+
"name": "Ryan McCue",
|
596 |
+
"homepage": "http://ryanmccue.info"
|
597 |
+
}
|
598 |
+
],
|
599 |
+
"description": "A HTTP library written in PHP, for human beings.",
|
600 |
+
"homepage": "http://github.com/rmccue/Requests",
|
601 |
+
"keywords": [
|
602 |
+
"curl",
|
603 |
+
"fsockopen",
|
604 |
+
"http",
|
605 |
+
"idna",
|
606 |
+
"ipv6",
|
607 |
+
"iri",
|
608 |
+
"sockets"
|
609 |
+
],
|
610 |
+
"time": "2016-10-13T00:11:37+00:00"
|
611 |
+
},
|
612 |
+
{
|
613 |
+
"name": "seld/cli-prompt",
|
614 |
+
"version": "dev-master",
|
615 |
+
"source": {
|
616 |
+
"type": "git",
|
617 |
+
"url": "https://github.com/Seldaek/cli-prompt.git",
|
618 |
+
"reference": "a19a7376a4689d4d94cab66ab4f3c816019ba8dd"
|
619 |
+
},
|
620 |
+
"dist": {
|
621 |
+
"type": "zip",
|
622 |
+
"url": "https://api.github.com/repos/Seldaek/cli-prompt/zipball/a19a7376a4689d4d94cab66ab4f3c816019ba8dd",
|
623 |
+
"reference": "a19a7376a4689d4d94cab66ab4f3c816019ba8dd",
|
624 |
+
"shasum": ""
|
625 |
+
},
|
626 |
+
"require": {
|
627 |
+
"php": ">=5.3"
|
628 |
+
},
|
629 |
+
"type": "library",
|
630 |
+
"extra": {
|
631 |
+
"branch-alias": {
|
632 |
+
"dev-master": "1.x-dev"
|
633 |
+
}
|
634 |
+
},
|
635 |
+
"autoload": {
|
636 |
+
"psr-4": {
|
637 |
+
"Seld\\CliPrompt\\": "src/"
|
638 |
+
}
|
639 |
+
},
|
640 |
+
"notification-url": "https://packagist.org/downloads/",
|
641 |
+
"license": [
|
642 |
+
"MIT"
|
643 |
+
],
|
644 |
+
"authors": [
|
645 |
+
{
|
646 |
+
"name": "Jordi Boggiano",
|
647 |
+
"email": "j.boggiano@seld.be"
|
648 |
+
}
|
649 |
+
],
|
650 |
+
"description": "Allows you to prompt for user input on the command line, and optionally hide the characters they type",
|
651 |
+
"keywords": [
|
652 |
+
"cli",
|
653 |
+
"console",
|
654 |
+
"hidden",
|
655 |
+
"input",
|
656 |
+
"prompt"
|
657 |
+
],
|
658 |
+
"time": "2017-03-18T11:32:45+00:00"
|
659 |
+
},
|
660 |
+
{
|
661 |
+
"name": "seld/jsonlint",
|
662 |
+
"version": "1.6.1",
|
663 |
+
"source": {
|
664 |
+
"type": "git",
|
665 |
+
"url": "https://github.com/Seldaek/jsonlint.git",
|
666 |
+
"reference": "50d63f2858d87c4738d5b76a7dcbb99fa8cf7c77"
|
667 |
+
},
|
668 |
+
"dist": {
|
669 |
+
"type": "zip",
|
670 |
+
"url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/50d63f2858d87c4738d5b76a7dcbb99fa8cf7c77",
|
671 |
+
"reference": "50d63f2858d87c4738d5b76a7dcbb99fa8cf7c77",
|
672 |
+
"shasum": ""
|
673 |
+
},
|
674 |
+
"require": {
|
675 |
+
"php": "^5.3 || ^7.0"
|
676 |
+
},
|
677 |
+
"require-dev": {
|
678 |
+
"phpunit/phpunit": "^4.5"
|
679 |
+
},
|
680 |
+
"bin": [
|
681 |
+
"bin/jsonlint"
|
682 |
+
],
|
683 |
+
"type": "library",
|
684 |
+
"autoload": {
|
685 |
+
"psr-4": {
|
686 |
+
"Seld\\JsonLint\\": "src/Seld/JsonLint/"
|
687 |
+
}
|
688 |
+
},
|
689 |
+
"notification-url": "https://packagist.org/downloads/",
|
690 |
+
"license": [
|
691 |
+
"MIT"
|
692 |
+
],
|
693 |
+
"authors": [
|
694 |
+
{
|
695 |
+
"name": "Jordi Boggiano",
|
696 |
+
"email": "j.boggiano@seld.be",
|
697 |
+
"homepage": "http://seld.be"
|
698 |
+
}
|
699 |
+
],
|
700 |
+
"description": "JSON Linter",
|
701 |
+
"keywords": [
|
702 |
+
"json",
|
703 |
+
"linter",
|
704 |
+
"parser",
|
705 |
+
"validator"
|
706 |
+
],
|
707 |
+
"time": "2017-06-18T15:11:04+00:00"
|
708 |
+
},
|
709 |
+
{
|
710 |
+
"name": "seld/phar-utils",
|
711 |
+
"version": "dev-master",
|
712 |
+
"source": {
|
713 |
+
"type": "git",
|
714 |
+
"url": "https://github.com/Seldaek/phar-utils.git",
|
715 |
+
"reference": "7009b5139491975ef6486545a39f3e6dad5ac30a"
|
716 |
+
},
|
717 |
+
"dist": {
|
718 |
+
"type": "zip",
|
719 |
+
"url": "https://api.github.com/repos/Seldaek/phar-utils/zipball/7009b5139491975ef6486545a39f3e6dad5ac30a",
|
720 |
+
"reference": "7009b5139491975ef6486545a39f3e6dad5ac30a",
|
721 |
+
"shasum": ""
|
722 |
+
},
|
723 |
+
"require": {
|
724 |
+
"php": ">=5.3"
|
725 |
+
},
|
726 |
+
"type": "library",
|
727 |
+
"extra": {
|
728 |
+
"branch-alias": {
|
729 |
+
"dev-master": "1.x-dev"
|
730 |
+
}
|
731 |
+
},
|
732 |
+
"autoload": {
|
733 |
+
"psr-4": {
|
734 |
+
"Seld\\PharUtils\\": "src/"
|
735 |
+
}
|
736 |
+
},
|
737 |
+
"notification-url": "https://packagist.org/downloads/",
|
738 |
+
"license": [
|
739 |
+
"MIT"
|
740 |
+
],
|
741 |
+
"authors": [
|
742 |
+
{
|
743 |
+
"name": "Jordi Boggiano",
|
744 |
+
"email": "j.boggiano@seld.be"
|
745 |
+
}
|
746 |
+
],
|
747 |
+
"description": "PHAR file format utilities, for when PHP phars you up",
|
748 |
+
"keywords": [
|
749 |
+
"phra"
|
750 |
+
],
|
751 |
+
"time": "2015-10-13T18:44:15+00:00"
|
752 |
+
},
|
753 |
+
{
|
754 |
+
"name": "symfony/config",
|
755 |
+
"version": "3.4.x-dev",
|
756 |
+
"source": {
|
757 |
+
"type": "git",
|
758 |
+
"url": "https://github.com/symfony/config.git",
|
759 |
+
"reference": "d668d8c0502d2b485c00d107db65fdbc56c26282"
|
760 |
+
},
|
761 |
+
"dist": {
|
762 |
+
"type": "zip",
|
763 |
+
"url": "https://api.github.com/repos/symfony/config/zipball/d668d8c0502d2b485c00d107db65fdbc56c26282",
|
764 |
+
"reference": "d668d8c0502d2b485c00d107db65fdbc56c26282",
|
765 |
+
"shasum": ""
|
766 |
+
},
|
767 |
+
"require": {
|
768 |
+
"php": "^5.5.9|>=7.0.8",
|
769 |
+
"symfony/filesystem": "~2.8|~3.0|~4.0"
|
770 |
+
},
|
771 |
+
"conflict": {
|
772 |
+
"symfony/dependency-injection": "<3.3",
|
773 |
+
"symfony/finder": "<3.3"
|
774 |
+
},
|
775 |
+
"require-dev": {
|
776 |
+
"symfony/dependency-injection": "~3.3|~4.0",
|
777 |
+
"symfony/finder": "~3.3|~4.0",
|
778 |
+
"symfony/yaml": "~3.0|~4.0"
|
779 |
+
},
|
780 |
+
"suggest": {
|
781 |
+
"symfony/yaml": "To use the yaml reference dumper"
|
782 |
+
},
|
783 |
+
"type": "library",
|
784 |
+
"extra": {
|
785 |
+
"branch-alias": {
|
786 |
+
"dev-master": "3.4-dev"
|
787 |
+
}
|
788 |
+
},
|
789 |
+
"autoload": {
|
790 |
+
"psr-4": {
|
791 |
+
"Symfony\\Component\\Config\\": ""
|
792 |
+
},
|
793 |
+
"exclude-from-classmap": [
|
794 |
+
"/Tests/"
|
795 |
+
]
|
796 |
+
},
|
797 |
+
"notification-url": "https://packagist.org/downloads/",
|
798 |
+
"license": [
|
799 |
+
"MIT"
|
800 |
+
],
|
801 |
+
"authors": [
|
802 |
+
{
|
803 |
+
"name": "Fabien Potencier",
|
804 |
+
"email": "fabien@symfony.com"
|
805 |
+
},
|
806 |
+
{
|
807 |
+
"name": "Symfony Community",
|
808 |
+
"homepage": "https://symfony.com/contributors"
|
809 |
+
}
|
810 |
+
],
|
811 |
+
"description": "Symfony Config Component",
|
812 |
+
"homepage": "https://symfony.com",
|
813 |
+
"time": "2017-08-05T17:34:46+00:00"
|
814 |
+
},
|
815 |
+
{
|
816 |
+
"name": "symfony/console",
|
817 |
+
"version": "3.4.x-dev",
|
818 |
+
"source": {
|
819 |
+
"type": "git",
|
820 |
+
"url": "https://github.com/symfony/console.git",
|
821 |
+
"reference": "0e283478c2d68c9bf9cc52592ad1ef1834083a85"
|
822 |
+
},
|
823 |
+
"dist": {
|
824 |
+
"type": "zip",
|
825 |
+
"url": "https://api.github.com/repos/symfony/console/zipball/0e283478c2d68c9bf9cc52592ad1ef1834083a85",
|
826 |
+
"reference": "0e283478c2d68c9bf9cc52592ad1ef1834083a85",
|
827 |
+
"shasum": ""
|
828 |
+
},
|
829 |
+
"require": {
|
830 |
+
"php": "^5.5.9|>=7.0.8",
|
831 |
+
"symfony/debug": "~2.8|~3.0|~4.0",
|
832 |
+
"symfony/polyfill-mbstring": "~1.0"
|
833 |
+
},
|
834 |
+
"conflict": {
|
835 |
+
"symfony/dependency-injection": "<3.3",
|
836 |
+
"symfony/process": "<3.3"
|
837 |
+
},
|
838 |
+
"require-dev": {
|
839 |
+
"psr/log": "~1.0",
|
840 |
+
"symfony/config": "~3.3|~4.0",
|
841 |
+
"symfony/dependency-injection": "~3.3|~4.0",
|
842 |
+
"symfony/event-dispatcher": "~2.8|~3.0|~4.0",
|
843 |
+
"symfony/http-kernel": "~2.8|~3.0|~4.0",
|
844 |
+
"symfony/lock": "~3.4|~4.0",
|
845 |
+
"symfony/process": "~3.3|~4.0"
|
846 |
+
},
|
847 |
+
"suggest": {
|
848 |
+
"psr/log": "For using the console logger",
|
849 |
+
"symfony/event-dispatcher": "",
|
850 |
+
"symfony/lock": "",
|
851 |
+
"symfony/process": ""
|
852 |
+
},
|
853 |
+
"type": "library",
|
854 |
+
"extra": {
|
855 |
+
"branch-alias": {
|
856 |
+
"dev-master": "3.4-dev"
|
857 |
+
}
|
858 |
+
},
|
859 |
+
"autoload": {
|
860 |
+
"psr-4": {
|
861 |
+
"Symfony\\Component\\Console\\": ""
|
862 |
+
},
|
863 |
+
"exclude-from-classmap": [
|
864 |
+
"/Tests/"
|
865 |
+
]
|
866 |
+
},
|
867 |
+
"notification-url": "https://packagist.org/downloads/",
|
868 |
+
"license": [
|
869 |
+
"MIT"
|
870 |
+
],
|
871 |
+
"authors": [
|
872 |
+
{
|
873 |
+
"name": "Fabien Potencier",
|
874 |
+
"email": "fabien@symfony.com"
|
875 |
+
},
|
876 |
+
{
|
877 |
+
"name": "Symfony Community",
|
878 |
+
"homepage": "https://symfony.com/contributors"
|
879 |
+
}
|
880 |
+
],
|
881 |
+
"description": "Symfony Console Component",
|
882 |
+
"homepage": "https://symfony.com",
|
883 |
+
"time": "2017-08-10T07:07:17+00:00"
|
884 |
+
},
|
885 |
+
{
|
886 |
+
"name": "symfony/debug",
|
887 |
+
"version": "3.4.x-dev",
|
888 |
+
"source": {
|
889 |
+
"type": "git",
|
890 |
+
"url": "https://github.com/symfony/debug.git",
|
891 |
+
"reference": "50bda5b4b8641616d45254c6855bcd45f2f64187"
|
892 |
+
},
|
893 |
+
"dist": {
|
894 |
+
"type": "zip",
|
895 |
+
"url": "https://api.github.com/repos/symfony/debug/zipball/50bda5b4b8641616d45254c6855bcd45f2f64187",
|
896 |
+
"reference": "50bda5b4b8641616d45254c6855bcd45f2f64187",
|
897 |
+
"shasum": ""
|
898 |
+
},
|
899 |
+
"require": {
|
900 |
+
"php": "^5.5.9|>=7.0.8",
|
901 |
+
"psr/log": "~1.0"
|
902 |
+
},
|
903 |
+
"conflict": {
|
904 |
+
"symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2"
|
905 |
+
},
|
906 |
+
"require-dev": {
|
907 |
+
"symfony/http-kernel": "~2.8|~3.0|~4.0"
|
908 |
+
},
|
909 |
+
"type": "library",
|
910 |
+
"extra": {
|
911 |
+
"branch-alias": {
|
912 |
+
"dev-master": "3.4-dev"
|
913 |
+
}
|
914 |
+
},
|
915 |
+
"autoload": {
|
916 |
+
"psr-4": {
|
917 |
+
"Symfony\\Component\\Debug\\": ""
|
918 |
+
},
|
919 |
+
"exclude-from-classmap": [
|
920 |
+
"/Tests/"
|
921 |
+
]
|
922 |
+
},
|
923 |
+
"notification-url": "https://packagist.org/downloads/",
|
924 |
+
"license": [
|
925 |
+
"MIT"
|
926 |
+
],
|
927 |
+
"authors": [
|
928 |
+
{
|
929 |
+
"name": "Fabien Potencier",
|
930 |
+
"email": "fabien@symfony.com"
|
931 |
+
},
|
932 |
+
{
|
933 |
+
"name": "Symfony Community",
|
934 |
+
"homepage": "https://symfony.com/contributors"
|
935 |
+
}
|
936 |
+
],
|
937 |
+
"description": "Symfony Debug Component",
|
938 |
+
"homepage": "https://symfony.com",
|
939 |
+
"time": "2017-08-10T07:07:17+00:00"
|
940 |
+
},
|
941 |
+
{
|
942 |
+
"name": "symfony/dependency-injection",
|
943 |
+
"version": "3.4.x-dev",
|
944 |
+
"source": {
|
945 |
+
"type": "git",
|
946 |
+
"url": "https://github.com/symfony/dependency-injection.git",
|
947 |
+
"reference": "aaee88765cb21a838e8da26d6acda4ca2ae3a2ea"
|
948 |
+
},
|
949 |
+
"dist": {
|
950 |
+
"type": "zip",
|
951 |
+
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/aaee88765cb21a838e8da26d6acda4ca2ae3a2ea",
|
952 |
+
"reference": "aaee88765cb21a838e8da26d6acda4ca2ae3a2ea",
|
953 |
+
"shasum": ""
|
954 |
+
},
|
955 |
+
"require": {
|
956 |
+
"php": "^5.5.9|>=7.0.8",
|
957 |
+
"psr/container": "^1.0"
|
958 |
+
},
|
959 |
+
"conflict": {
|
960 |
+
"symfony/config": "<3.3.1",
|
961 |
+
"symfony/finder": "<3.3",
|
962 |
+
"symfony/proxy-manager-bridge": "<3.4",
|
963 |
+
"symfony/yaml": "<3.4"
|
964 |
+
},
|
965 |
+
"provide": {
|
966 |
+
"psr/container-implementation": "1.0"
|
967 |
+
},
|
968 |
+
"require-dev": {
|
969 |
+
"symfony/config": "~3.3|~4.0",
|
970 |
+
"symfony/expression-language": "~2.8|~3.0|~4.0",
|
971 |
+
"symfony/yaml": "~3.4|~4.0"
|
972 |
+
},
|
973 |
+
"suggest": {
|
974 |
+
"symfony/config": "",
|
975 |
+
"symfony/expression-language": "For using expressions in service container configuration",
|
976 |
+
"symfony/finder": "For using double-star glob patterns or when GLOB_BRACE portability is required",
|
977 |
+
"symfony/proxy-manager-bridge": "Generate service proxies to lazy load them",
|
978 |
+
"symfony/yaml": ""
|
979 |
+
},
|
980 |
+
"type": "library",
|
981 |
+
"extra": {
|
982 |
+
"branch-alias": {
|
983 |
+
"dev-master": "3.4-dev"
|
984 |
+
}
|
985 |
+
},
|
986 |
+
"autoload": {
|
987 |
+
"psr-4": {
|
988 |
+
"Symfony\\Component\\DependencyInjection\\": ""
|
989 |
+
},
|
990 |
+
"exclude-from-classmap": [
|
991 |
+
"/Tests/"
|
992 |
+
]
|
993 |
+
},
|
994 |
+
"notification-url": "https://packagist.org/downloads/",
|
995 |
+
"license": [
|
996 |
+
"MIT"
|
997 |
+
],
|
998 |
+
"authors": [
|
999 |
+
{
|
1000 |
+
"name": "Fabien Potencier",
|
1001 |
+
"email": "fabien@symfony.com"
|
1002 |
+
},
|
1003 |
+
{
|
1004 |
+
"name": "Symfony Community",
|
1005 |
+
"homepage": "https://symfony.com/contributors"
|
1006 |
+
}
|
1007 |
+
],
|
1008 |
+
"description": "Symfony DependencyInjection Component",
|
1009 |
+
"homepage": "https://symfony.com",
|
1010 |
+
"time": "2017-08-10T19:43:00+00:00"
|
1011 |
+
},
|
1012 |
+
{
|
1013 |
+
"name": "symfony/event-dispatcher",
|
1014 |
+
"version": "3.4.x-dev",
|
1015 |
+
"source": {
|
1016 |
+
"type": "git",
|
1017 |
+
"url": "https://github.com/symfony/event-dispatcher.git",
|
1018 |
+
"reference": "cd8b015f859e6b60933324db00067c2f060b4d18"
|
1019 |
+
},
|
1020 |
+
"dist": {
|
1021 |
+
"type": "zip",
|
1022 |
+
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/cd8b015f859e6b60933324db00067c2f060b4d18",
|
1023 |
+
"reference": "cd8b015f859e6b60933324db00067c2f060b4d18",
|
1024 |
+
"shasum": ""
|
1025 |
+
},
|
1026 |
+
"require": {
|
1027 |
+
"php": "^5.5.9|>=7.0.8"
|
1028 |
+
},
|
1029 |
+
"conflict": {
|
1030 |
+
"symfony/dependency-injection": "<3.3"
|
1031 |
+
},
|
1032 |
+
"require-dev": {
|
1033 |
+
"psr/log": "~1.0",
|
1034 |
+
"symfony/config": "~2.8|~3.0|~4.0",
|
1035 |
+
"symfony/dependency-injection": "~3.3|~4.0",
|
1036 |
+
"symfony/expression-language": "~2.8|~3.0|~4.0",
|
1037 |
+
"symfony/stopwatch": "~2.8|~3.0|~4.0"
|
1038 |
+
},
|
1039 |
+
"suggest": {
|
1040 |
+
"symfony/dependency-injection": "",
|
1041 |
+
"symfony/http-kernel": ""
|
1042 |
+
},
|
1043 |
+
"type": "library",
|
1044 |
+
"extra": {
|
1045 |
+
"branch-alias": {
|
1046 |
+
"dev-master": "3.4-dev"
|
1047 |
+
}
|
1048 |
+
},
|
1049 |
+
"autoload": {
|
1050 |
+
"psr-4": {
|
1051 |
+
"Symfony\\Component\\EventDispatcher\\": ""
|
1052 |
+
},
|
1053 |
+
"exclude-from-classmap": [
|
1054 |
+
"/Tests/"
|
1055 |
+
]
|
1056 |
+
},
|
1057 |
+
"notification-url": "https://packagist.org/downloads/",
|
1058 |
+
"license": [
|
1059 |
+
"MIT"
|
1060 |
+
],
|
1061 |
+
"authors": [
|
1062 |
+
{
|
1063 |
+
"name": "Fabien Potencier",
|
1064 |
+
"email": "fabien@symfony.com"
|
1065 |
+
},
|
1066 |
+
{
|
1067 |
+
"name": "Symfony Community",
|
1068 |
+
"homepage": "https://symfony.com/contributors"
|
1069 |
+
}
|
1070 |
+
],
|
1071 |
+
"description": "Symfony EventDispatcher Component",
|
1072 |
+
"homepage": "https://symfony.com",
|
1073 |
+
"time": "2017-08-03T09:34:20+00:00"
|
1074 |
+
},
|
1075 |
+
{
|
1076 |
+
"name": "symfony/filesystem",
|
1077 |
+
"version": "3.4.x-dev",
|
1078 |
+
"source": {
|
1079 |
+
"type": "git",
|
1080 |
+
"url": "https://github.com/symfony/filesystem.git",
|
1081 |
+
"reference": "e4d366b620c8b6e2d4977c154f6a1d5b416db4dd"
|
1082 |
+
},
|
1083 |
+
"dist": {
|
1084 |
+
"type": "zip",
|
1085 |
+
"url": "https://api.github.com/repos/symfony/filesystem/zipball/e4d366b620c8b6e2d4977c154f6a1d5b416db4dd",
|
1086 |
+
"reference": "e4d366b620c8b6e2d4977c154f6a1d5b416db4dd",
|
1087 |
+
"shasum": ""
|
1088 |
+
},
|
1089 |
+
"require": {
|
1090 |
+
"php": "^5.5.9|>=7.0.8"
|
1091 |
+
},
|
1092 |
+
"type": "library",
|
1093 |
+
"extra": {
|
1094 |
+
"branch-alias": {
|
1095 |
+
"dev-master": "3.4-dev"
|
1096 |
+
}
|
1097 |
+
},
|
1098 |
+
"autoload": {
|
1099 |
+
"psr-4": {
|
1100 |
+
"Symfony\\Component\\Filesystem\\": ""
|
1101 |
+
},
|
1102 |
+
"exclude-from-classmap": [
|
1103 |
+
"/Tests/"
|
1104 |
+
]
|
1105 |
+
},
|
1106 |
+
"notification-url": "https://packagist.org/downloads/",
|
1107 |
+
"license": [
|
1108 |
+
"MIT"
|
1109 |
+
],
|
1110 |
+
"authors": [
|
1111 |
+
{
|
1112 |
+
"name": "Fabien Potencier",
|
1113 |
+
"email": "fabien@symfony.com"
|
1114 |
+
},
|
1115 |
+
{
|
1116 |
+
"name": "Symfony Community",
|
1117 |
+
"homepage": "https://symfony.com/contributors"
|
1118 |
+
}
|
1119 |
+
],
|
1120 |
+
"description": "Symfony Filesystem Component",
|
1121 |
+
"homepage": "https://symfony.com",
|
1122 |
+
"time": "2017-08-03T09:34:20+00:00"
|
1123 |
+
},
|
1124 |
+
{
|
1125 |
+
"name": "symfony/finder",
|
1126 |
+
"version": "3.4.x-dev",
|
1127 |
+
"source": {
|
1128 |
+
"type": "git",
|
1129 |
+
"url": "https://github.com/symfony/finder.git",
|
1130 |
+
"reference": "bf0450cfe7282c5f06539c4733ba64273e91e918"
|
1131 |
+
},
|
1132 |
+
"dist": {
|
1133 |
+
"type": "zip",
|
1134 |
+
"url": "https://api.github.com/repos/symfony/finder/zipball/bf0450cfe7282c5f06539c4733ba64273e91e918",
|
1135 |
+
"reference": "bf0450cfe7282c5f06539c4733ba64273e91e918",
|
1136 |
+
"shasum": ""
|
1137 |
+
},
|
1138 |
+
"require": {
|
1139 |
+
"php": "^5.5.9|>=7.0.8"
|
1140 |
+
},
|
1141 |
+
"type": "library",
|
1142 |
+
"extra": {
|
1143 |
+
"branch-alias": {
|
1144 |
+
"dev-master": "3.4-dev"
|
1145 |
+
}
|
1146 |
+
},
|
1147 |
+
"autoload": {
|
1148 |
+
"psr-4": {
|
1149 |
+
"Symfony\\Component\\Finder\\": ""
|
1150 |
+
},
|
1151 |
+
"exclude-from-classmap": [
|
1152 |
+
"/Tests/"
|
1153 |
+
]
|
1154 |
+
},
|
1155 |
+
"notification-url": "https://packagist.org/downloads/",
|
1156 |
+
"license": [
|
1157 |
+
"MIT"
|
1158 |
+
],
|
1159 |
+
"authors": [
|
1160 |
+
{
|
1161 |
+
"name": "Fabien Potencier",
|
1162 |
+
"email": "fabien@symfony.com"
|
1163 |
+
},
|
1164 |
+
{
|
1165 |
+
"name": "Symfony Community",
|
1166 |
+
"homepage": "https://symfony.com/contributors"
|
1167 |
+
}
|
1168 |
+
],
|
1169 |
+
"description": "Symfony Finder Component",
|
1170 |
+
"homepage": "https://symfony.com",
|
1171 |
+
"time": "2017-08-03T09:34:20+00:00"
|
1172 |
+
},
|
1173 |
+
{
|
1174 |
+
"name": "symfony/polyfill-mbstring",
|
1175 |
+
"version": "dev-master",
|
1176 |
+
"source": {
|
1177 |
+
"type": "git",
|
1178 |
+
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
1179 |
+
"reference": "7c8fae0ac1d216eb54349e6a8baa57d515fe8803"
|
1180 |
+
},
|
1181 |
+
"dist": {
|
1182 |
+
"type": "zip",
|
1183 |
+
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7c8fae0ac1d216eb54349e6a8baa57d515fe8803",
|
1184 |
+
"reference": "7c8fae0ac1d216eb54349e6a8baa57d515fe8803",
|
1185 |
+
"shasum": ""
|
1186 |
+
},
|
1187 |
+
"require": {
|
1188 |
+
"php": ">=5.3.3"
|
1189 |
+
},
|
1190 |
+
"suggest": {
|
1191 |
+
"ext-mbstring": "For best performance"
|
1192 |
+
},
|
1193 |
+
"type": "library",
|
1194 |
+
"extra": {
|
1195 |
+
"branch-alias": {
|
1196 |
+
"dev-master": "1.5-dev"
|
1197 |
+
}
|
1198 |
+
},
|
1199 |
+
"autoload": {
|
1200 |
+
"psr-4": {
|
1201 |
+
"Symfony\\Polyfill\\Mbstring\\": ""
|
1202 |
+
},
|
1203 |
+
"files": [
|
1204 |
+
"bootstrap.php"
|
1205 |
+
]
|
1206 |
+
},
|
1207 |
+
"notification-url": "https://packagist.org/downloads/",
|
1208 |
+
"license": [
|
1209 |
+
"MIT"
|
1210 |
+
],
|
1211 |
+
"authors": [
|
1212 |
+
{
|
1213 |
+
"name": "Nicolas Grekas",
|
1214 |
+
"email": "p@tchwork.com"
|
1215 |
+
},
|
1216 |
+
{
|
1217 |
+
"name": "Symfony Community",
|
1218 |
+
"homepage": "https://symfony.com/contributors"
|
1219 |
+
}
|
1220 |
+
],
|
1221 |
+
"description": "Symfony polyfill for the Mbstring extension",
|
1222 |
+
"homepage": "https://symfony.com",
|
1223 |
+
"keywords": [
|
1224 |
+
"compatibility",
|
1225 |
+
"mbstring",
|
1226 |
+
"polyfill",
|
1227 |
+
"portable",
|
1228 |
+
"shim"
|
1229 |
+
],
|
1230 |
+
"time": "2017-06-14T15:44:48+00:00"
|
1231 |
+
},
|
1232 |
+
{
|
1233 |
+
"name": "symfony/process",
|
1234 |
+
"version": "3.4.x-dev",
|
1235 |
+
"source": {
|
1236 |
+
"type": "git",
|
1237 |
+
"url": "https://github.com/symfony/process.git",
|
1238 |
+
"reference": "9794f948d9af3be0157185051275d78b24d68b92"
|
1239 |
+
},
|
1240 |
+
"dist": {
|
1241 |
+
"type": "zip",
|
1242 |
+
"url": "https://api.github.com/repos/symfony/process/zipball/9794f948d9af3be0157185051275d78b24d68b92",
|
1243 |
+
"reference": "9794f948d9af3be0157185051275d78b24d68b92",
|
1244 |
+
"shasum": ""
|
1245 |
+
},
|
1246 |
+
"require": {
|
1247 |
+
"php": "^5.5.9|>=7.0.8"
|
1248 |
+
},
|
1249 |
+
"type": "library",
|
1250 |
+
"extra": {
|
1251 |
+
"branch-alias": {
|
1252 |
+
"dev-master": "3.4-dev"
|
1253 |
+
}
|
1254 |
+
},
|
1255 |
+
"autoload": {
|
1256 |
+
"psr-4": {
|
1257 |
+
"Symfony\\Component\\Process\\": ""
|
1258 |
+
},
|
1259 |
+
"exclude-from-classmap": [
|
1260 |
+
"/Tests/"
|
1261 |
+
]
|
1262 |
+
},
|
1263 |
+
"notification-url": "https://packagist.org/downloads/",
|
1264 |
+
"license": [
|
1265 |
+
"MIT"
|
1266 |
+
],
|
1267 |
+
"authors": [
|
1268 |
+
{
|
1269 |
+
"name": "Fabien Potencier",
|
1270 |
+
"email": "fabien@symfony.com"
|
1271 |
+
},
|
1272 |
+
{
|
1273 |
+
"name": "Symfony Community",
|
1274 |
+
"homepage": "https://symfony.com/contributors"
|
1275 |
+
}
|
1276 |
+
],
|
1277 |
+
"description": "Symfony Process Component",
|
1278 |
+
"homepage": "https://symfony.com",
|
1279 |
+
"time": "2017-08-03T09:34:20+00:00"
|
1280 |
+
},
|
1281 |
+
{
|
1282 |
+
"name": "symfony/translation",
|
1283 |
+
"version": "3.4.x-dev",
|
1284 |
+
"source": {
|
1285 |
+
"type": "git",
|
1286 |
+
"url": "https://github.com/symfony/translation.git",
|
1287 |
+
"reference": "62bb068e004874bbe39624101e1aae70ca7c05cd"
|
1288 |
+
},
|
1289 |
+
"dist": {
|
1290 |
+
"type": "zip",
|
1291 |
+
"url": "https://api.github.com/repos/symfony/translation/zipball/62bb068e004874bbe39624101e1aae70ca7c05cd",
|
1292 |
+
"reference": "62bb068e004874bbe39624101e1aae70ca7c05cd",
|
1293 |
+
"shasum": ""
|
1294 |
+
},
|
1295 |
+
"require": {
|
1296 |
+
"php": "^5.5.9|>=7.0.8",
|
1297 |
+
"symfony/polyfill-mbstring": "~1.0"
|
1298 |
+
},
|
1299 |
+
"conflict": {
|
1300 |
+
"symfony/config": "<2.8",
|
1301 |
+
"symfony/dependency-injection": "<3.4",
|
1302 |
+
"symfony/yaml": "<3.3"
|
1303 |
+
},
|
1304 |
+
"require-dev": {
|
1305 |
+
"psr/log": "~1.0",
|
1306 |
+
"symfony/config": "~2.8|~3.0|~4.0",
|
1307 |
+
"symfony/dependency-injection": "~3.4|~4.0",
|
1308 |
+
"symfony/intl": "^2.8.18|^3.2.5|~4.0",
|
1309 |
+
"symfony/yaml": "~3.3|~4.0"
|
1310 |
+
},
|
1311 |
+
"suggest": {
|
1312 |
+
"psr/log": "To use logging capability in translator",
|
1313 |
+
"symfony/config": "",
|
1314 |
+
"symfony/yaml": ""
|
1315 |
+
},
|
1316 |
+
"type": "library",
|
1317 |
+
"extra": {
|
1318 |
+
"branch-alias": {
|
1319 |
+
"dev-master": "3.4-dev"
|
1320 |
+
}
|
1321 |
+
},
|
1322 |
+
"autoload": {
|
1323 |
+
"psr-4": {
|
1324 |
+
"Symfony\\Component\\Translation\\": ""
|
1325 |
+
},
|
1326 |
+
"exclude-from-classmap": [
|
1327 |
+
"/Tests/"
|
1328 |
+
]
|
1329 |
+
},
|
1330 |
+
"notification-url": "https://packagist.org/downloads/",
|
1331 |
+
"license": [
|
1332 |
+
"MIT"
|
1333 |
+
],
|
1334 |
+
"authors": [
|
1335 |
+
{
|
1336 |
+
"name": "Fabien Potencier",
|
1337 |
+
"email": "fabien@symfony.com"
|
1338 |
+
},
|
1339 |
+
{
|
1340 |
+
"name": "Symfony Community",
|
1341 |
+
"homepage": "https://symfony.com/contributors"
|
1342 |
+
}
|
1343 |
+
],
|
1344 |
+
"description": "Symfony Translation Component",
|
1345 |
+
"homepage": "https://symfony.com",
|
1346 |
+
"time": "2017-08-03T12:04:31+00:00"
|
1347 |
+
},
|
1348 |
+
{
|
1349 |
+
"name": "symfony/yaml",
|
1350 |
+
"version": "3.4.x-dev",
|
1351 |
+
"source": {
|
1352 |
+
"type": "git",
|
1353 |
+
"url": "https://github.com/symfony/yaml.git",
|
1354 |
+
"reference": "1395ddba6f65bf46cdf1d80d59223cbab8ff3ccc"
|
1355 |
+
},
|
1356 |
+
"dist": {
|
1357 |
+
"type": "zip",
|
1358 |
+
"url": "https://api.github.com/repos/symfony/yaml/zipball/1395ddba6f65bf46cdf1d80d59223cbab8ff3ccc",
|
1359 |
+
"reference": "1395ddba6f65bf46cdf1d80d59223cbab8ff3ccc",
|
1360 |
+
"shasum": ""
|
1361 |
+
},
|
1362 |
+
"require": {
|
1363 |
+
"php": "^5.5.9|>=7.0.8"
|
1364 |
+
},
|
1365 |
+
"require-dev": {
|
1366 |
+
"symfony/console": "~2.8|~3.0|~4.0"
|
1367 |
+
},
|
1368 |
+
"suggest": {
|
1369 |
+
"symfony/console": "For validating YAML files using the lint command"
|
1370 |
+
},
|
1371 |
+
"type": "library",
|
1372 |
+
"extra": {
|
1373 |
+
"branch-alias": {
|
1374 |
+
"dev-master": "3.4-dev"
|
1375 |
+
}
|
1376 |
+
},
|
1377 |
+
"autoload": {
|
1378 |
+
"psr-4": {
|
1379 |
+
"Symfony\\Component\\Yaml\\": ""
|
1380 |
+
},
|
1381 |
+
"exclude-from-classmap": [
|
1382 |
+
"/Tests/"
|
1383 |
+
]
|
1384 |
+
},
|
1385 |
+
"notification-url": "https://packagist.org/downloads/",
|
1386 |
+
"license": [
|
1387 |
+
"MIT"
|
1388 |
+
],
|
1389 |
+
"authors": [
|
1390 |
+
{
|
1391 |
+
"name": "Fabien Potencier",
|
1392 |
+
"email": "fabien@symfony.com"
|
1393 |
+
},
|
1394 |
+
{
|
1395 |
+
"name": "Symfony Community",
|
1396 |
+
"homepage": "https://symfony.com/contributors"
|
1397 |
+
}
|
1398 |
+
],
|
1399 |
+
"description": "Symfony Yaml Component",
|
1400 |
+
"homepage": "https://symfony.com",
|
1401 |
+
"time": "2017-08-04T13:29:48+00:00"
|
1402 |
+
},
|
1403 |
+
{
|
1404 |
+
"name": "wp-cli/autoload-splitter",
|
1405 |
+
"version": "v0.1.5",
|
1406 |
+
"source": {
|
1407 |
+
"type": "git",
|
1408 |
+
"url": "https://github.com/wp-cli/autoload-splitter.git",
|
1409 |
+
"reference": "fb4302da26390811d2631c62b42b75976d224bb8"
|
1410 |
+
},
|
1411 |
+
"dist": {
|
1412 |
+
"type": "zip",
|
1413 |
+
"url": "https://api.github.com/repos/wp-cli/autoload-splitter/zipball/fb4302da26390811d2631c62b42b75976d224bb8",
|
1414 |
+
"reference": "fb4302da26390811d2631c62b42b75976d224bb8",
|
1415 |
+
"shasum": ""
|
1416 |
+
},
|
1417 |
+
"require": {
|
1418 |
+
"composer-plugin-api": "^1.1"
|
1419 |
+
},
|
1420 |
+
"type": "composer-plugin",
|
1421 |
+
"extra": {
|
1422 |
+
"class": "WP_CLI\\AutoloadSplitter\\ComposerPlugin"
|
1423 |
+
},
|
1424 |
+
"autoload": {
|
1425 |
+
"psr-4": {
|
1426 |
+
"WP_CLI\\AutoloadSplitter\\": "src"
|
1427 |
+
}
|
1428 |
+
},
|
1429 |
+
"notification-url": "https://packagist.org/downloads/",
|
1430 |
+
"license": [
|
1431 |
+
"MIT"
|
1432 |
+
],
|
1433 |
+
"authors": [
|
1434 |
+
{
|
1435 |
+
"name": "Alain Schlesser",
|
1436 |
+
"email": "alain.schlesser@gmail.com",
|
1437 |
+
"homepage": "https://www.alainschlesser.com"
|
1438 |
+
}
|
1439 |
+
],
|
1440 |
+
"description": "Composer plugin for splitting a generated autoloader into two distinct parts.",
|
1441 |
+
"homepage": "https://wp-cli.org",
|
1442 |
+
"time": "2017-08-03T08:40:16+00:00"
|
1443 |
+
},
|
1444 |
+
{
|
1445 |
+
"name": "wp-cli/cache-command",
|
1446 |
+
"version": "dev-master",
|
1447 |
+
"source": {
|
1448 |
+
"type": "git",
|
1449 |
+
"url": "https://github.com/wp-cli/cache-command.git",
|
1450 |
+
"reference": "485f7cc6630ecabe22bbf9fa9e827958e95a2d21"
|
1451 |
+
},
|
1452 |
+
"dist": {
|
1453 |
+
"type": "zip",
|
1454 |
+
"url": "https://api.github.com/repos/wp-cli/cache-command/zipball/485f7cc6630ecabe22bbf9fa9e827958e95a2d21",
|
1455 |
+
"reference": "485f7cc6630ecabe22bbf9fa9e827958e95a2d21",
|
1456 |
+
"shasum": ""
|
1457 |
+
},
|
1458 |
+
"require-dev": {
|
1459 |
+
"behat/behat": "~2.5",
|
1460 |
+
"wp-cli/wp-cli": "*"
|
1461 |
+
},
|
1462 |
+
"type": "wp-cli-package",
|
1463 |
+
"extra": {
|
1464 |
+
"branch-alias": {
|
1465 |
+
"dev-master": "1.x-dev"
|
1466 |
+
},
|
1467 |
+
"bundled": true,
|
1468 |
+
"commands": [
|
1469 |
+
"cache",
|
1470 |
+
"transient"
|
1471 |
+
]
|
1472 |
+
},
|
1473 |
+
"autoload": {
|
1474 |
+
"psr-4": {
|
1475 |
+
"": "src/"
|
1476 |
+
},
|
1477 |
+
"files": [
|
1478 |
+
"cache-command.php"
|
1479 |
+
]
|
1480 |
+
},
|
1481 |
+
"notification-url": "https://packagist.org/downloads/",
|
1482 |
+
"license": [
|
1483 |
+
"MIT"
|
1484 |
+
],
|
1485 |
+
"authors": [
|
1486 |
+
{
|
1487 |
+
"name": "Daniel Bachhuber",
|
1488 |
+
"email": "daniel@runcommand.io",
|
1489 |
+
"homepage": "https://runcommand.io"
|
1490 |
+
}
|
1491 |
+
],
|
1492 |
+
"description": "Manage object and transient caches.",
|
1493 |
+
"homepage": "https://github.com/wp-cli/cache-command",
|
1494 |
+
"time": "2017-08-04T11:37:19+00:00"
|
1495 |
+
},
|
1496 |
+
{
|
1497 |
+
"name": "wp-cli/checksum-command",
|
1498 |
+
"version": "dev-master",
|
1499 |
+
"source": {
|
1500 |
+
"type": "git",
|
1501 |
+
"url": "https://github.com/wp-cli/checksum-command.git",
|
1502 |
+
"reference": "88ccde2e82de5c2232842a9fccc2e6ade232dec6"
|
1503 |
+
},
|
1504 |
+
"dist": {
|
1505 |
+
"type": "zip",
|
1506 |
+
"url": "https://api.github.com/repos/wp-cli/checksum-command/zipball/88ccde2e82de5c2232842a9fccc2e6ade232dec6",
|
1507 |
+
"reference": "88ccde2e82de5c2232842a9fccc2e6ade232dec6",
|
1508 |
+
"shasum": ""
|
1509 |
+
},
|
1510 |
+
"require-dev": {
|
1511 |
+
"behat/behat": "~2.5",
|
1512 |
+
"wp-cli/wp-cli": "*"
|
1513 |
+
},
|
1514 |
+
"type": "wp-cli-package",
|
1515 |
+
"extra": {
|
1516 |
+
"branch-alias": {
|
1517 |
+
"dev-master": "1.x-dev"
|
1518 |
+
},
|
1519 |
+
"bundled": true,
|
1520 |
+
"commands": [
|
1521 |
+
"checksum core"
|
1522 |
+
]
|
1523 |
+
},
|
1524 |
+
"autoload": {
|
1525 |
+
"psr-4": {
|
1526 |
+
"": "src/"
|
1527 |
+
},
|
1528 |
+
"files": [
|
1529 |
+
"checksum-command.php"
|
1530 |
+
]
|
1531 |
+
},
|
1532 |
+
"notification-url": "https://packagist.org/downloads/",
|
1533 |
+
"license": [
|
1534 |
+
"MIT"
|
1535 |
+
],
|
1536 |
+
"authors": [
|
1537 |
+
{
|
1538 |
+
"name": "Daniel Bachhuber",
|
1539 |
+
"email": "daniel@runcommand.io",
|
1540 |
+
"homepage": "https://runcommand.io"
|
1541 |
+
}
|
1542 |
+
],
|
1543 |
+
"description": "Verify WordPress core checksums.",
|
1544 |
+
"homepage": "https://github.com/wp-cli/checksum-command",
|
1545 |
+
"time": "2017-08-09T23:34:29+00:00"
|
1546 |
+
},
|
1547 |
+
{
|
1548 |
+
"name": "wp-cli/config-command",
|
1549 |
+
"version": "dev-master",
|
1550 |
+
"source": {
|
1551 |
+
"type": "git",
|
1552 |
+
"url": "https://github.com/wp-cli/config-command.git",
|
1553 |
+
"reference": "ca83ade8fb2d059b561744610947e38123b10c22"
|
1554 |
+
},
|
1555 |
+
"dist": {
|
1556 |
+
"type": "zip",
|
1557 |
+
"url": "https://api.github.com/repos/wp-cli/config-command/zipball/ca83ade8fb2d059b561744610947e38123b10c22",
|
1558 |
+
"reference": "ca83ade8fb2d059b561744610947e38123b10c22",
|
1559 |
+
"shasum": ""
|
1560 |
+
},
|
1561 |
+
"require-dev": {
|
1562 |
+
"behat/behat": "~2.5",
|
1563 |
+
"wp-cli/wp-cli": "*"
|
1564 |
+
},
|
1565 |
+
"type": "wp-cli-package",
|
1566 |
+
"extra": {
|
1567 |
+
"branch-alias": {
|
1568 |
+
"dev-master": "1.x-dev"
|
1569 |
+
},
|
1570 |
+
"bundled": true,
|
1571 |
+
"commands": [
|
1572 |
+
"config",
|
1573 |
+
"config create",
|
1574 |
+
"config get",
|
1575 |
+
"config path"
|
1576 |
+
]
|
1577 |
+
},
|
1578 |
+
"autoload": {
|
1579 |
+
"psr-4": {
|
1580 |
+
"": "src/"
|
1581 |
+
},
|
1582 |
+
"files": [
|
1583 |
+
"config-command.php"
|
1584 |
+
]
|
1585 |
+
},
|
1586 |
+
"notification-url": "https://packagist.org/downloads/",
|
1587 |
+
"license": [
|
1588 |
+
"MIT"
|
1589 |
+
],
|
1590 |
+
"authors": [
|
1591 |
+
{
|
1592 |
+
"name": "Daniel Bachhuber",
|
1593 |
+
"email": "daniel@runcommand.io",
|
1594 |
+
"homepage": "https://runcommand.io"
|
1595 |
+
}
|
1596 |
+
],
|
1597 |
+
"description": "Manage the wp-config.php file.",
|
1598 |
+
"homepage": "https://github.com/wp-cli/config-command",
|
1599 |
+
"time": "2017-08-04T23:41:35+00:00"
|
1600 |
+
},
|
1601 |
+
{
|
1602 |
+
"name": "wp-cli/core-command",
|
1603 |
+
"version": "dev-master",
|
1604 |
+
"source": {
|
1605 |
+
"type": "git",
|
1606 |
+
"url": "https://github.com/wp-cli/core-command.git",
|
1607 |
+
"reference": "fb743dab792e21b57163c5c0f563987d1471c152"
|
1608 |
+
},
|
1609 |
+
"dist": {
|
1610 |
+
"type": "zip",
|
1611 |
+
"url": "https://api.github.com/repos/wp-cli/core-command/zipball/fb743dab792e21b57163c5c0f563987d1471c152",
|
1612 |
+
"reference": "fb743dab792e21b57163c5c0f563987d1471c152",
|
1613 |
+
"shasum": ""
|
1614 |
+
},
|
1615 |
+
"require-dev": {
|
1616 |
+
"behat/behat": "~2.5",
|
1617 |
+
"wp-cli/wp-cli": "*"
|
1618 |
+
},
|
1619 |
+
"type": "wp-cli-package",
|
1620 |
+
"extra": {
|
1621 |
+
"branch-alias": {
|
1622 |
+
"dev-master": "1.x-dev"
|
1623 |
+
},
|
1624 |
+
"bundled": true,
|
1625 |
+
"commands": [
|
1626 |
+
"core check-update",
|
1627 |
+
"core download",
|
1628 |
+
"core install",
|
1629 |
+
"core is-installed",
|
1630 |
+
"core multisite-convert",
|
1631 |
+
"core multisite-install",
|
1632 |
+
"core update",
|
1633 |
+
"core update-db",
|
1634 |
+
"core version"
|
1635 |
+
]
|
1636 |
+
},
|
1637 |
+
"autoload": {
|
1638 |
+
"psr-4": {
|
1639 |
+
"": "src/"
|
1640 |
+
},
|
1641 |
+
"files": [
|
1642 |
+
"core-command.php"
|
1643 |
+
]
|
1644 |
+
},
|
1645 |
+
"notification-url": "https://packagist.org/downloads/",
|
1646 |
+
"license": [
|
1647 |
+
"MIT"
|
1648 |
+
],
|
1649 |
+
"authors": [
|
1650 |
+
{
|
1651 |
+
"name": "Daniel Bachhuber",
|
1652 |
+
"email": "daniel@runcommand.io",
|
1653 |
+
"homepage": "https://runcommand.io"
|
1654 |
+
}
|
1655 |
+
],
|
1656 |
+
"description": "Download, install, update and manage a WordPress install.",
|
1657 |
+
"homepage": "https://github.com/wp-cli/core-command",
|
1658 |
+
"time": "2017-08-04T12:31:18+00:00"
|
1659 |
+
},
|
1660 |
+
{
|
1661 |
+
"name": "wp-cli/cron-command",
|
1662 |
+
"version": "dev-master",
|
1663 |
+
"source": {
|
1664 |
+
"type": "git",
|
1665 |
+
"url": "https://github.com/wp-cli/cron-command.git",
|
1666 |
+
"reference": "92114b695ab0253bb705d9bd3e6d2fb47b51fad2"
|
1667 |
+
},
|
1668 |
+
"dist": {
|
1669 |
+
"type": "zip",
|
1670 |
+
"url": "https://api.github.com/repos/wp-cli/cron-command/zipball/92114b695ab0253bb705d9bd3e6d2fb47b51fad2",
|
1671 |
+
"reference": "92114b695ab0253bb705d9bd3e6d2fb47b51fad2",
|
1672 |
+
"shasum": ""
|
1673 |
+
},
|
1674 |
+
"require-dev": {
|
1675 |
+
"behat/behat": "~2.5",
|
1676 |
+
"wp-cli/wp-cli": "*"
|
1677 |
+
},
|
1678 |
+
"type": "wp-cli-package",
|
1679 |
+
"extra": {
|
1680 |
+
"branch-alias": {
|
1681 |
+
"dev-master": "1.x-dev"
|
1682 |
+
},
|
1683 |
+
"bundled": true,
|
1684 |
+
"commands": [
|
1685 |
+
"cron test",
|
1686 |
+
"cron event delete",
|
1687 |
+
"cron event list",
|
1688 |
+
"cron event run",
|
1689 |
+
"cron event schedule",
|
1690 |
+
"cron schedule list"
|
1691 |
+
]
|
1692 |
+
},
|
1693 |
+
"autoload": {
|
1694 |
+
"psr-4": {
|
1695 |
+
"": "src/"
|
1696 |
+
},
|
1697 |
+
"files": [
|
1698 |
+
"cron-command.php"
|
1699 |
+
]
|
1700 |
+
},
|
1701 |
+
"notification-url": "https://packagist.org/downloads/",
|
1702 |
+
"license": [
|
1703 |
+
"MIT"
|
1704 |
+
],
|
1705 |
+
"authors": [
|
1706 |
+
{
|
1707 |
+
"name": "Daniel Bachhuber",
|
1708 |
+
"email": "daniel@runcommand.io",
|
1709 |
+
"homepage": "https://runcommand.io"
|
1710 |
+
}
|
1711 |
+
],
|
1712 |
+
"description": "Manage WP-Cron events and schedules.",
|
1713 |
+
"homepage": "https://github.com/wp-cli/cron-command",
|
1714 |
+
"time": "2017-08-04T12:45:50+00:00"
|
1715 |
+
},
|
1716 |
+
{
|
1717 |
+
"name": "wp-cli/db-command",
|
1718 |
+
"version": "dev-master",
|
1719 |
+
"source": {
|
1720 |
+
"type": "git",
|
1721 |
+
"url": "https://github.com/wp-cli/db-command.git",
|
1722 |
+
"reference": "5c597abb642bcaf329e7da0801c69f4405d41c23"
|
1723 |
+
},
|
1724 |
+
"dist": {
|
1725 |
+
"type": "zip",
|
1726 |
+
"url": "https://api.github.com/repos/wp-cli/db-command/zipball/5c597abb642bcaf329e7da0801c69f4405d41c23",
|
1727 |
+
"reference": "5c597abb642bcaf329e7da0801c69f4405d41c23",
|
1728 |
+
"shasum": ""
|
1729 |
+
},
|
1730 |
+
"require": {
|
1731 |
+
"wp-cli/wp-cli": "*"
|
1732 |
+
},
|
1733 |
+
"require-dev": {
|
1734 |
+
"behat/behat": "~2.5"
|
1735 |
+
},
|
1736 |
+
"type": "wp-cli-package",
|
1737 |
+
"extra": {
|
1738 |
+
"branch-alias": {
|
1739 |
+
"dev-master": "1.x-dev"
|
1740 |
+
},
|
1741 |
+
"bundled": true,
|
1742 |
+
"commands": [
|
1743 |
+
"db create",
|
1744 |
+
"db drop",
|
1745 |
+
"db reset",
|
1746 |
+
"db check",
|
1747 |
+
"db optimize",
|
1748 |
+
"db prefix",
|
1749 |
+
"db repair",
|
1750 |
+
"db cli",
|
1751 |
+
"db query",
|
1752 |
+
"db export",
|
1753 |
+
"db import",
|
1754 |
+
"db search",
|
1755 |
+
"db tables",
|
1756 |
+
"db size"
|
1757 |
+
]
|
1758 |
+
},
|
1759 |
+
"autoload": {
|
1760 |
+
"psr-4": {
|
1761 |
+
"": "src/"
|
1762 |
+
},
|
1763 |
+
"files": [
|
1764 |
+
"db-command.php"
|
1765 |
+
]
|
1766 |
+
},
|
1767 |
+
"notification-url": "https://packagist.org/downloads/",
|
1768 |
+
"license": [
|
1769 |
+
"MIT"
|
1770 |
+
],
|
1771 |
+
"authors": [
|
1772 |
+
{
|
1773 |
+
"name": "Daniel Bachhuber",
|
1774 |
+
"email": "daniel@runcommand.io",
|
1775 |
+
"homepage": "https://runcommand.io"
|
1776 |
+
}
|
1777 |
+
],
|
1778 |
+
"description": "Perform basic database operations using credentials stored in wp-config.php.",
|
1779 |
+
"homepage": "https://github.com/wp-cli/db-command",
|
1780 |
+
"time": "2017-08-04T23:21:46+00:00"
|
1781 |
+
},
|
1782 |
+
{
|
1783 |
+
"name": "wp-cli/entity-command",
|
1784 |
+
"version": "dev-master",
|
1785 |
+
"source": {
|
1786 |
+
"type": "git",
|
1787 |
+
"url": "https://github.com/wp-cli/entity-command.git",
|
1788 |
+
"reference": "d0cd99c14e4d01aad368328da97231df0c01f9dc"
|
1789 |
+
},
|
1790 |
+
"dist": {
|
1791 |
+
"type": "zip",
|
1792 |
+
"url": "https://api.github.com/repos/wp-cli/entity-command/zipball/d0cd99c14e4d01aad368328da97231df0c01f9dc",
|
1793 |
+
"reference": "d0cd99c14e4d01aad368328da97231df0c01f9dc",
|
1794 |
+
"shasum": ""
|
1795 |
+
},
|
1796 |
+
"require-dev": {
|
1797 |
+
"behat/behat": "~2.5",
|
1798 |
+
"phpunit/phpunit": "^4.8",
|
1799 |
+
"wp-cli/wp-cli": "*"
|
1800 |
+
},
|
1801 |
+
"type": "wp-cli-package",
|
1802 |
+
"extra": {
|
1803 |
+
"branch-alias": {
|
1804 |
+
"dev-master": "1.x-dev"
|
1805 |
+
},
|
1806 |
+
"bundled": true,
|
1807 |
+
"commands": [
|
1808 |
+
"comment",
|
1809 |
+
"comment meta",
|
1810 |
+
"menu",
|
1811 |
+
"menu item",
|
1812 |
+
"menu location",
|
1813 |
+
"network meta",
|
1814 |
+
"option",
|
1815 |
+
"option add",
|
1816 |
+
"option delete",
|
1817 |
+
"option get",
|
1818 |
+
"option list",
|
1819 |
+
"option update",
|
1820 |
+
"post",
|
1821 |
+
"post meta",
|
1822 |
+
"post term",
|
1823 |
+
"post-type",
|
1824 |
+
"site",
|
1825 |
+
"taxonomy",
|
1826 |
+
"term",
|
1827 |
+
"term meta",
|
1828 |
+
"user",
|
1829 |
+
"user meta",
|
1830 |
+
"user term"
|
1831 |
+
]
|
1832 |
+
},
|
1833 |
+
"autoload": {
|
1834 |
+
"psr-4": {
|
1835 |
+
"": "src/",
|
1836 |
+
"WP_CLI\\": "src/WP_CLI"
|
1837 |
+
},
|
1838 |
+
"files": [
|
1839 |
+
"entity-command.php"
|
1840 |
+
]
|
1841 |
+
},
|
1842 |
+
"notification-url": "https://packagist.org/downloads/",
|
1843 |
+
"license": [
|
1844 |
+
"MIT"
|
1845 |
+
],
|
1846 |
+
"authors": [
|
1847 |
+
{
|
1848 |
+
"name": "Daniel Bachhuber",
|
1849 |
+
"email": "daniel@runcommand.io",
|
1850 |
+
"homepage": "https://runcommand.io"
|
1851 |
+
}
|
1852 |
+
],
|
1853 |
+
"description": "Manage WordPress core entities.",
|
1854 |
+
"homepage": "https://github.com/wp-cli/entity-command",
|
1855 |
+
"time": "2017-08-11T11:53:04+00:00"
|
1856 |
+
},
|
1857 |
+
{
|
1858 |
+
"name": "wp-cli/eval-command",
|
1859 |
+
"version": "dev-master",
|
1860 |
+
"source": {
|
1861 |
+
"type": "git",
|
1862 |
+
"url": "https://github.com/wp-cli/eval-command.git",
|
1863 |
+
"reference": "e3d9502a4f8b8f582130dbb3b8ede76e17ac05a4"
|
1864 |
+
},
|
1865 |
+
"dist": {
|
1866 |
+
"type": "zip",
|
1867 |
+
"url": "https://api.github.com/repos/wp-cli/eval-command/zipball/e3d9502a4f8b8f582130dbb3b8ede76e17ac05a4",
|
1868 |
+
"reference": "e3d9502a4f8b8f582130dbb3b8ede76e17ac05a4",
|
1869 |
+
"shasum": ""
|
1870 |
+
},
|
1871 |
+
"require": {
|
1872 |
+
"wp-cli/wp-cli": "*"
|
1873 |
+
},
|
1874 |
+
"require-dev": {
|
1875 |
+
"behat/behat": "~2.5"
|
1876 |
+
},
|
1877 |
+
"type": "wp-cli-package",
|
1878 |
+
"extra": {
|
1879 |
+
"branch-alias": {
|
1880 |
+
"dev-master": "1.x-dev"
|
1881 |
+
},
|
1882 |
+
"bundled": true,
|
1883 |
+
"commands": [
|
1884 |
+
"eval",
|
1885 |
+
"eval-file"
|
1886 |
+
]
|
1887 |
+
},
|
1888 |
+
"autoload": {
|
1889 |
+
"psr-4": {
|
1890 |
+
"": "src/"
|
1891 |
+
},
|
1892 |
+
"files": [
|
1893 |
+
"eval-command.php"
|
1894 |
+
]
|
1895 |
+
},
|
1896 |
+
"notification-url": "https://packagist.org/downloads/",
|
1897 |
+
"license": [
|
1898 |
+
"MIT"
|
1899 |
+
],
|
1900 |
+
"authors": [
|
1901 |
+
{
|
1902 |
+
"name": "Daniel Bachhuber",
|
1903 |
+
"email": "daniel@runcommand.io",
|
1904 |
+
"homepage": "https://runcommand.io"
|
1905 |
+
}
|
1906 |
+
],
|
1907 |
+
"description": "Execute arbitrary PHP code.",
|
1908 |
+
"homepage": "https://github.com/wp-cli/eval-command",
|
1909 |
+
"time": "2017-08-04T12:46:58+00:00"
|
1910 |
+
},
|
1911 |
+
{
|
1912 |
+
"name": "wp-cli/export-command",
|
1913 |
+
"version": "dev-master",
|
1914 |
+
"source": {
|
1915 |
+
"type": "git",
|
1916 |
+
"url": "https://github.com/wp-cli/export-command.git",
|
1917 |
+
"reference": "f5647155830d1275de4cb69cfb79748b9449b8ab"
|
1918 |
+
},
|
1919 |
+
"dist": {
|
1920 |
+
"type": "zip",
|
1921 |
+
"url": "https://api.github.com/repos/wp-cli/export-command/zipball/f5647155830d1275de4cb69cfb79748b9449b8ab",
|
1922 |
+
"reference": "f5647155830d1275de4cb69cfb79748b9449b8ab",
|
1923 |
+
"shasum": ""
|
1924 |
+
},
|
1925 |
+
"require": {
|
1926 |
+
"nb/oxymel": "~0.1.0",
|
1927 |
+
"wp-cli/wp-cli": "*"
|
1928 |
+
},
|
1929 |
+
"require-dev": {
|
1930 |
+
"behat/behat": "~2.5"
|
1931 |
+
},
|
1932 |
+
"type": "wp-cli-package",
|
1933 |
+
"extra": {
|
1934 |
+
"branch-alias": {
|
1935 |
+
"dev-master": "1.x-dev"
|
1936 |
+
},
|
1937 |
+
"bundled": true,
|
1938 |
+
"commands": [
|
1939 |
+
"export"
|
1940 |
+
]
|
1941 |
+
},
|
1942 |
+
"autoload": {
|
1943 |
+
"psr-4": {
|
1944 |
+
"": "src/"
|
1945 |
+
},
|
1946 |
+
"files": [
|
1947 |
+
"export-command.php"
|
1948 |
+
]
|
1949 |
+
},
|
1950 |
+
"notification-url": "https://packagist.org/downloads/",
|
1951 |
+
"license": [
|
1952 |
+
"MIT"
|
1953 |
+
],
|
1954 |
+
"authors": [
|
1955 |
+
{
|
1956 |
+
"name": "Daniel Bachhuber",
|
1957 |
+
"email": "daniel@runcommand.io",
|
1958 |
+
"homepage": "https://runcommand.io"
|
1959 |
+
}
|
1960 |
+
],
|
1961 |
+
"description": "Export WordPress content to a WXR file.",
|
1962 |
+
"homepage": "https://github.com/wp-cli/export-command",
|
1963 |
+
"time": "2017-08-04T13:13:08+00:00"
|
1964 |
+
},
|
1965 |
+
{
|
1966 |
+
"name": "wp-cli/extension-command",
|
1967 |
+
"version": "dev-master",
|
1968 |
+
"source": {
|
1969 |
+
"type": "git",
|
1970 |
+
"url": "https://github.com/wp-cli/extension-command.git",
|
1971 |
+
"reference": "08bf48e842b9e1cb579b50cec1b6897cebf65bda"
|
1972 |
+
},
|
1973 |
+
"dist": {
|
1974 |
+
"type": "zip",
|
1975 |
+
"url": "https://api.github.com/repos/wp-cli/extension-command/zipball/08bf48e842b9e1cb579b50cec1b6897cebf65bda",
|
1976 |
+
"reference": "08bf48e842b9e1cb579b50cec1b6897cebf65bda",
|
1977 |
+
"shasum": ""
|
1978 |
+
},
|
1979 |
+
"require-dev": {
|
1980 |
+
"behat/behat": "~2.5",
|
1981 |
+
"wp-cli/wp-cli": "*"
|
1982 |
+
},
|
1983 |
+
"type": "wp-cli-package",
|
1984 |
+
"extra": {
|
1985 |
+
"branch-alias": {
|
1986 |
+
"dev-master": "1.x-dev"
|
1987 |
+
},
|
1988 |
+
"bundled": true,
|
1989 |
+
"commands": [
|
1990 |
+
"plugin activate",
|
1991 |
+
"plugin deactivate",
|
1992 |
+
"plugin delete",
|
1993 |
+
"plugin get",
|
1994 |
+
"plugin install",
|
1995 |
+
"plugin is-installed",
|
1996 |
+
"plugin list",
|
1997 |
+
"plugin path",
|
1998 |
+
"plugin search",
|
1999 |
+
"plugin status",
|
2000 |
+
"plugin toggle",
|
2001 |
+
"plugin uninstall",
|
2002 |
+
"plugin update",
|
2003 |
+
"theme activate",
|
2004 |
+
"theme delete",
|
2005 |
+
"theme disable",
|
2006 |
+
"theme enable",
|
2007 |
+
"theme get",
|
2008 |
+
"theme install",
|
2009 |
+
"theme is-installed",
|
2010 |
+
"theme list",
|
2011 |
+
"theme mod get",
|
2012 |
+
"theme mod set",
|
2013 |
+
"theme mod remove",
|
2014 |
+
"theme path",
|
2015 |
+
"theme search",
|
2016 |
+
"theme status",
|
2017 |
+
"theme update"
|
2018 |
+
]
|
2019 |
+
},
|
2020 |
+
"autoload": {
|
2021 |
+
"psr-4": {
|
2022 |
+
"": "src/",
|
2023 |
+
"WP_CLI\\": "src/WP_CLI"
|
2024 |
+
},
|
2025 |
+
"files": [
|
2026 |
+
"extension-command.php"
|
2027 |
+
]
|
2028 |
+
},
|
2029 |
+
"notification-url": "https://packagist.org/downloads/",
|
2030 |
+
"license": [
|
2031 |
+
"MIT"
|
2032 |
+
],
|
2033 |
+
"authors": [
|
2034 |
+
{
|
2035 |
+
"name": "Daniel Bachhuber",
|
2036 |
+
"email": "daniel@runcommand.io",
|
2037 |
+
"homepage": "https://runcommand.io"
|
2038 |
+
}
|
2039 |
+
],
|
2040 |
+
"description": "Manage WordPress plugins and themes.",
|
2041 |
+
"homepage": "https://github.com/wp-cli/extension-command",
|
2042 |
+
"time": "2017-08-04T13:43:53+00:00"
|
2043 |
+
},
|
2044 |
+
{
|
2045 |
+
"name": "wp-cli/import-command",
|
2046 |
+
"version": "dev-master",
|
2047 |
+
"source": {
|
2048 |
+
"type": "git",
|
2049 |
+
"url": "https://github.com/wp-cli/import-command.git",
|
2050 |
+
"reference": "89d14aa4b8b621effbe7f9bacad2ea8a096598a7"
|
2051 |
+
},
|
2052 |
+
"dist": {
|
2053 |
+
"type": "zip",
|
2054 |
+
"url": "https://api.github.com/repos/wp-cli/import-command/zipball/89d14aa4b8b621effbe7f9bacad2ea8a096598a7",
|
2055 |
+
"reference": "89d14aa4b8b621effbe7f9bacad2ea8a096598a7",
|
2056 |
+
"shasum": ""
|
2057 |
+
},
|
2058 |
+
"require": {
|
2059 |
+
"wp-cli/wp-cli": "*"
|
2060 |
+
},
|
2061 |
+
"require-dev": {
|
2062 |
+
"behat/behat": "~2.5"
|
2063 |
+
},
|
2064 |
+
"type": "wp-cli-package",
|
2065 |
+
"extra": {
|
2066 |
+
"branch-alias": {
|
2067 |
+
"dev-master": "1.x-dev"
|
2068 |
+
},
|
2069 |
+
"bundled": true,
|
2070 |
+
"commands": [
|
2071 |
+
"import"
|
2072 |
+
]
|
2073 |
+
},
|
2074 |
+
"autoload": {
|
2075 |
+
"psr-4": {
|
2076 |
+
"": "src/"
|
2077 |
+
},
|
2078 |
+
"files": [
|
2079 |
+
"import-command.php"
|
2080 |
+
]
|
2081 |
+
},
|
2082 |
+
"notification-url": "https://packagist.org/downloads/",
|
2083 |
+
"license": [
|
2084 |
+
"MIT"
|
2085 |
+
],
|
2086 |
+
"authors": [
|
2087 |
+
{
|
2088 |
+
"name": "Daniel Bachhuber",
|
2089 |
+
"email": "daniel@runcommand.io",
|
2090 |
+
"homepage": "https://runcommand.io"
|
2091 |
+
}
|
2092 |
+
],
|
2093 |
+
"description": "Import content from a WXR file.",
|
2094 |
+
"homepage": "https://github.com/wp-cli/import-command",
|
2095 |
+
"time": "2017-08-04T13:45:57+00:00"
|
2096 |
+
},
|
2097 |
+
{
|
2098 |
+
"name": "wp-cli/language-command",
|
2099 |
+
"version": "dev-master",
|
2100 |
+
"source": {
|
2101 |
+
"type": "git",
|
2102 |
+
"url": "https://github.com/wp-cli/language-command.git",
|
2103 |
+
"reference": "aff3fb6c6d7698008c7e5d33a97b25457091ae1b"
|
2104 |
+
},
|
2105 |
+
"dist": {
|
2106 |
+
"type": "zip",
|
2107 |
+
"url": "https://api.github.com/repos/wp-cli/language-command/zipball/aff3fb6c6d7698008c7e5d33a97b25457091ae1b",
|
2108 |
+
"reference": "aff3fb6c6d7698008c7e5d33a97b25457091ae1b",
|
2109 |
+
"shasum": ""
|
2110 |
+
},
|
2111 |
+
"require-dev": {
|
2112 |
+
"behat/behat": "~2.5",
|
2113 |
+
"wp-cli/wp-cli": "*"
|
2114 |
+
},
|
2115 |
+
"type": "wp-cli-package",
|
2116 |
+
"extra": {
|
2117 |
+
"branch-alias": {
|
2118 |
+
"dev-master": "1.x-dev"
|
2119 |
+
},
|
2120 |
+
"commands": [
|
2121 |
+
"language core activate",
|
2122 |
+
"language core install",
|
2123 |
+
"language core list",
|
2124 |
+
"language core uninstall",
|
2125 |
+
"language core update"
|
2126 |
+
],
|
2127 |
+
"bundled": true
|
2128 |
+
},
|
2129 |
+
"autoload": {
|
2130 |
+
"psr-4": {
|
2131 |
+
"": "src/"
|
2132 |
+
},
|
2133 |
+
"files": [
|
2134 |
+
"language-command.php"
|
2135 |
+
]
|
2136 |
+
},
|
2137 |
+
"notification-url": "https://packagist.org/downloads/",
|
2138 |
+
"license": [
|
2139 |
+
"MIT"
|
2140 |
+
],
|
2141 |
+
"authors": [
|
2142 |
+
{
|
2143 |
+
"name": "Daniel Bachhuber",
|
2144 |
+
"email": "daniel@runcommand.io",
|
2145 |
+
"homepage": "https://runcommand.io"
|
2146 |
+
}
|
2147 |
+
],
|
2148 |
+
"description": "Manage language packs.",
|
2149 |
+
"homepage": "https://github.com/wp-cli/language-command",
|
2150 |
+
"time": "2017-08-04T23:23:03+00:00"
|
2151 |
+
},
|
2152 |
+
{
|
2153 |
+
"name": "wp-cli/media-command",
|
2154 |
+
"version": "dev-master",
|
2155 |
+
"source": {
|
2156 |
+
"type": "git",
|
2157 |
+
"url": "https://github.com/wp-cli/media-command.git",
|
2158 |
+
"reference": "4a19de54a11c96b21c10719e2b7f9dd131c4261e"
|
2159 |
+
},
|
2160 |
+
"dist": {
|
2161 |
+
"type": "zip",
|
2162 |
+
"url": "https://api.github.com/repos/wp-cli/media-command/zipball/4a19de54a11c96b21c10719e2b7f9dd131c4261e",
|
2163 |
+
"reference": "4a19de54a11c96b21c10719e2b7f9dd131c4261e",
|
2164 |
+
"shasum": ""
|
2165 |
+
},
|
2166 |
+
"require": {
|
2167 |
+
"wp-cli/wp-cli": "*"
|
2168 |
+
},
|
2169 |
+
"require-dev": {
|
2170 |
+
"behat/behat": "~2.5"
|
2171 |
+
},
|
2172 |
+
"type": "wp-cli-package",
|
2173 |
+
"extra": {
|
2174 |
+
"branch-alias": {
|
2175 |
+
"dev-master": "1.x-dev"
|
2176 |
+
},
|
2177 |
+
"commands": [
|
2178 |
+
"media import",
|
2179 |
+
"media regenerate"
|
2180 |
+
],
|
2181 |
+
"bundled": true
|
2182 |
+
},
|
2183 |
+
"autoload": {
|
2184 |
+
"psr-4": {
|
2185 |
+
"": "src/"
|
2186 |
+
},
|
2187 |
+
"files": [
|
2188 |
+
"media-command.php"
|
2189 |
+
]
|
2190 |
+
},
|
2191 |
+
"notification-url": "https://packagist.org/downloads/",
|
2192 |
+
"license": [
|
2193 |
+
"MIT"
|
2194 |
+
],
|
2195 |
+
"authors": [
|
2196 |
+
{
|
2197 |
+
"name": "Daniel Bachhuber",
|
2198 |
+
"email": "daniel@runcommand.io",
|
2199 |
+
"homepage": "https://runcommand.io"
|
2200 |
+
}
|
2201 |
+
],
|
2202 |
+
"description": "Import new attachments or regenerate existing ones.",
|
2203 |
+
"homepage": "https://github.com/wp-cli/media-command",
|
2204 |
+
"time": "2017-08-05T04:54:48+00:00"
|
2205 |
+
},
|
2206 |
+
{
|
2207 |
+
"name": "wp-cli/mustangostang-spyc",
|
2208 |
+
"version": "0.6.3",
|
2209 |
+
"source": {
|
2210 |
+
"type": "git",
|
2211 |
+
"url": "https://github.com/wp-cli/spyc.git",
|
2212 |
+
"reference": "6aa0b4da69ce9e9a2c8402dab8d43cf32c581cc7"
|
2213 |
+
},
|
2214 |
+
"dist": {
|
2215 |
+
"type": "zip",
|
2216 |
+
"url": "https://api.github.com/repos/wp-cli/spyc/zipball/6aa0b4da69ce9e9a2c8402dab8d43cf32c581cc7",
|
2217 |
+
"reference": "6aa0b4da69ce9e9a2c8402dab8d43cf32c581cc7",
|
2218 |
+
"shasum": ""
|
2219 |
+
},
|
2220 |
+
"require": {
|
2221 |
+
"php": ">=5.3.1"
|
2222 |
+
},
|
2223 |
+
"require-dev": {
|
2224 |
+
"phpunit/phpunit": "4.3.*@dev"
|
2225 |
+
},
|
2226 |
+
"type": "library",
|
2227 |
+
"extra": {
|
2228 |
+
"branch-alias": {
|
2229 |
+
"dev-master": "0.5.x-dev"
|
2230 |
+
}
|
2231 |
+
},
|
2232 |
+
"autoload": {
|
2233 |
+
"psr-4": {
|
2234 |
+
"Mustangostang\\": "src/"
|
2235 |
+
},
|
2236 |
+
"files": [
|
2237 |
+
"includes/functions.php"
|
2238 |
+
]
|
2239 |
+
},
|
2240 |
+
"notification-url": "https://packagist.org/downloads/",
|
2241 |
+
"license": [
|
2242 |
+
"MIT"
|
2243 |
+
],
|
2244 |
+
"authors": [
|
2245 |
+
{
|
2246 |
+
"name": "mustangostang",
|
2247 |
+
"email": "vlad.andersen@gmail.com"
|
2248 |
+
}
|
2249 |
+
],
|
2250 |
+
"description": "A simple YAML loader/dumper class for PHP (WP-CLI fork)",
|
2251 |
+
"homepage": "https://github.com/mustangostang/spyc/",
|
2252 |
+
"time": "2017-04-25T11:26:20+00:00"
|
2253 |
+
},
|
2254 |
+
{
|
2255 |
+
"name": "wp-cli/package-command",
|
2256 |
+
"version": "dev-master",
|
2257 |
+
"source": {
|
2258 |
+
"type": "git",
|
2259 |
+
"url": "https://github.com/wp-cli/package-command.git",
|
2260 |
+
"reference": "744692180a4240ddc75a3196934cafe396dd9178"
|
2261 |
+
},
|
2262 |
+
"dist": {
|
2263 |
+
"type": "zip",
|
2264 |
+
"url": "https://api.github.com/repos/wp-cli/package-command/zipball/744692180a4240ddc75a3196934cafe396dd9178",
|
2265 |
+
"reference": "744692180a4240ddc75a3196934cafe396dd9178",
|
2266 |
+
"shasum": ""
|
2267 |
+
},
|
2268 |
+
"require": {
|
2269 |
+
"composer/composer": "^1.2.0",
|
2270 |
+
"wp-cli/wp-cli": "*"
|
2271 |
+
},
|
2272 |
+
"require-dev": {
|
2273 |
+
"behat/behat": "~2.5"
|
2274 |
+
},
|
2275 |
+
"type": "wp-cli-package",
|
2276 |
+
"extra": {
|
2277 |
+
"branch-alias": {
|
2278 |
+
"dev-master": "1.x-dev"
|
2279 |
+
},
|
2280 |
+
"commands": [
|
2281 |
+
"package browse",
|
2282 |
+
"package install",
|
2283 |
+
"package list",
|
2284 |
+
"package update",
|
2285 |
+
"package uninstall"
|
2286 |
+
],
|
2287 |
+
"bundled": true
|
2288 |
+
},
|
2289 |
+
"autoload": {
|
2290 |
+
"psr-4": {
|
2291 |
+
"": "src/"
|
2292 |
+
},
|
2293 |
+
"files": [
|
2294 |
+
"package-command.php"
|
2295 |
+
]
|
2296 |
+
},
|
2297 |
+
"notification-url": "https://packagist.org/downloads/",
|
2298 |
+
"license": [
|
2299 |
+
"MIT"
|
2300 |
+
],
|
2301 |
+
"authors": [
|
2302 |
+
{
|
2303 |
+
"name": "Daniel Bachhuber",
|
2304 |
+
"email": "daniel@runcommand.io",
|
2305 |
+
"homepage": "https://runcommand.io"
|
2306 |
+
}
|
2307 |
+
],
|
2308 |
+
"description": "Manage WP-CLI packages.",
|
2309 |
+
"homepage": "https://github.com/wp-cli/package-command",
|
2310 |
+
"time": "2017-08-07T12:21:11+00:00"
|
2311 |
+
},
|
2312 |
+
{
|
2313 |
+
"name": "wp-cli/php-cli-tools",
|
2314 |
+
"version": "v0.11.6",
|
2315 |
+
"source": {
|
2316 |
+
"type": "git",
|
2317 |
+
"url": "https://github.com/wp-cli/php-cli-tools.git",
|
2318 |
+
"reference": "d2a4e2eca9f1cd62a5d30f192d10f74e73eb3a05"
|
2319 |
+
},
|
2320 |
+
"dist": {
|
2321 |
+
"type": "zip",
|
2322 |
+
"url": "https://api.github.com/repos/wp-cli/php-cli-tools/zipball/d2a4e2eca9f1cd62a5d30f192d10f74e73eb3a05",
|
2323 |
+
"reference": "d2a4e2eca9f1cd62a5d30f192d10f74e73eb3a05",
|
2324 |
+
"shasum": ""
|
2325 |
+
},
|
2326 |
+
"require": {
|
2327 |
+
"php": ">= 5.3.0"
|
2328 |
+
},
|
2329 |
+
"type": "library",
|
2330 |
+
"autoload": {
|
2331 |
+
"psr-0": {
|
2332 |
+
"cli": "lib/"
|
2333 |
+
},
|
2334 |
+
"files": [
|
2335 |
+
"lib/cli/cli.php"
|
2336 |
+
]
|
2337 |
+
},
|
2338 |
+
"notification-url": "https://packagist.org/downloads/",
|
2339 |
+
"license": [
|
2340 |
+
"MIT"
|
2341 |
+
],
|
2342 |
+
"authors": [
|
2343 |
+
{
|
2344 |
+
"name": "James Logsdon",
|
2345 |
+
"email": "jlogsdon@php.net",
|
2346 |
+
"role": "Developer"
|
2347 |
+
},
|
2348 |
+
{
|
2349 |
+
"name": "Daniel Bachhuber",
|
2350 |
+
"email": "daniel@handbuilt.co",
|
2351 |
+
"role": "Maintainer"
|
2352 |
+
}
|
2353 |
+
],
|
2354 |
+
"description": "Console utilities for PHP",
|
2355 |
+
"homepage": "http://github.com/wp-cli/php-cli-tools",
|
2356 |
+
"keywords": [
|
2357 |
+
"cli",
|
2358 |
+
"console"
|
2359 |
+
],
|
2360 |
+
"time": "2017-08-04T10:42:04+00:00"
|
2361 |
+
},
|
2362 |
+
{
|
2363 |
+
"name": "wp-cli/rewrite-command",
|
2364 |
+
"version": "dev-master",
|
2365 |
+
"source": {
|
2366 |
+
"type": "git",
|
2367 |
+
"url": "https://github.com/wp-cli/rewrite-command.git",
|
2368 |
+
"reference": "e858feac8d3fe053e052d8af43c090ff0b2a4e8a"
|
2369 |
+
},
|
2370 |
+
"dist": {
|
2371 |
+
"type": "zip",
|
2372 |
+
"url": "https://api.github.com/repos/wp-cli/rewrite-command/zipball/e858feac8d3fe053e052d8af43c090ff0b2a4e8a",
|
2373 |
+
"reference": "e858feac8d3fe053e052d8af43c090ff0b2a4e8a",
|
2374 |
+
"shasum": ""
|
2375 |
+
},
|
2376 |
+
"require-dev": {
|
2377 |
+
"behat/behat": "~2.5",
|
2378 |
+
"wp-cli/wp-cli": "*"
|
2379 |
+
},
|
2380 |
+
"type": "wp-cli-package",
|
2381 |
+
"extra": {
|
2382 |
+
"branch-alias": {
|
2383 |
+
"dev-master": "1.x-dev"
|
2384 |
+
},
|
2385 |
+
"commands": [
|
2386 |
+
"rewrite flush",
|
2387 |
+
"rewrite list",
|
2388 |
+
"rewrite structure"
|
2389 |
+
],
|
2390 |
+
"bundled": true
|
2391 |
+
},
|
2392 |
+
"autoload": {
|
2393 |
+
"psr-4": {
|
2394 |
+
"": "src/"
|
2395 |
+
},
|
2396 |
+
"files": [
|
2397 |
+
"rewrite-command.php"
|
2398 |
+
]
|
2399 |
+
},
|
2400 |
+
"notification-url": "https://packagist.org/downloads/",
|
2401 |
+
"license": [
|
2402 |
+
"MIT"
|
2403 |
+
],
|
2404 |
+
"authors": [
|
2405 |
+
{
|
2406 |
+
"name": "Daniel Bachhuber",
|
2407 |
+
"email": "daniel@runcommand.io",
|
2408 |
+
"homepage": "https://runcommand.io"
|
2409 |
+
}
|
2410 |
+
],
|
2411 |
+
"description": "Manage rewrite rules.",
|
2412 |
+
"homepage": "https://github.com/wp-cli/rewrite-command",
|
2413 |
+
"time": "2017-08-04T15:15:53+00:00"
|
2414 |
+
},
|
2415 |
+
{
|
2416 |
+
"name": "wp-cli/role-command",
|
2417 |
+
"version": "dev-master",
|
2418 |
+
"source": {
|
2419 |
+
"type": "git",
|
2420 |
+
"url": "https://github.com/wp-cli/role-command.git",
|
2421 |
+
"reference": "85ddf53525b14ab040830f385710f4493058d295"
|
2422 |
+
},
|
2423 |
+
"dist": {
|
2424 |
+
"type": "zip",
|
2425 |
+
"url": "https://api.github.com/repos/wp-cli/role-command/zipball/85ddf53525b14ab040830f385710f4493058d295",
|
2426 |
+
"reference": "85ddf53525b14ab040830f385710f4493058d295",
|
2427 |
+
"shasum": ""
|
2428 |
+
},
|
2429 |
+
"require-dev": {
|
2430 |
+
"behat/behat": "~2.5",
|
2431 |
+
"wp-cli/wp-cli": "*"
|
2432 |
+
},
|
2433 |
+
"type": "wp-cli-package",
|
2434 |
+
"extra": {
|
2435 |
+
"branch-alias": {
|
2436 |
+
"dev-master": "1.x-dev"
|
2437 |
+
},
|
2438 |
+
"commands": [
|
2439 |
+
"role create",
|
2440 |
+
"role delete",
|
2441 |
+
"role exists",
|
2442 |
+
"role list",
|
2443 |
+
"role reset",
|
2444 |
+
"cap add",
|
2445 |
+
"cap list",
|
2446 |
+
"cap remove"
|
2447 |
+
],
|
2448 |
+
"bundled": true
|
2449 |
+
},
|
2450 |
+
"autoload": {
|
2451 |
+
"psr-4": {
|
2452 |
+
"": "src/"
|
2453 |
+
},
|
2454 |
+
"files": [
|
2455 |
+
"role-command.php"
|
2456 |
+
]
|
2457 |
+
},
|
2458 |
+
"notification-url": "https://packagist.org/downloads/",
|
2459 |
+
"license": [
|
2460 |
+
"MIT"
|
2461 |
+
],
|
2462 |
+
"authors": [
|
2463 |
+
{
|
2464 |
+
"name": "Daniel Bachhuber",
|
2465 |
+
"email": "daniel@runcommand.io",
|
2466 |
+
"homepage": "https://runcommand.io"
|
2467 |
+
}
|
2468 |
+
],
|
2469 |
+
"description": "Manage user roles and capabilities.",
|
2470 |
+
"homepage": "https://github.com/wp-cli/role-command",
|
2471 |
+
"time": "2017-08-04T15:17:29+00:00"
|
2472 |
+
},
|
2473 |
+
{
|
2474 |
+
"name": "wp-cli/scaffold-command",
|
2475 |
+
"version": "dev-master",
|
2476 |
+
"source": {
|
2477 |
+
"type": "git",
|
2478 |
+
"url": "https://github.com/wp-cli/scaffold-command.git",
|
2479 |
+
"reference": "41f1e1aa41af76b70d6cf3d21d52995e854acf4c"
|
2480 |
+
},
|
2481 |
+
"dist": {
|
2482 |
+
"type": "zip",
|
2483 |
+
"url": "https://api.github.com/repos/wp-cli/scaffold-command/zipball/41f1e1aa41af76b70d6cf3d21d52995e854acf4c",
|
2484 |
+
"reference": "41f1e1aa41af76b70d6cf3d21d52995e854acf4c",
|
2485 |
+
"shasum": ""
|
2486 |
+
},
|
2487 |
+
"require-dev": {
|
2488 |
+
"behat/behat": "~2.5",
|
2489 |
+
"wp-cli/wp-cli": "*"
|
2490 |
+
},
|
2491 |
+
"type": "wp-cli-package",
|
2492 |
+
"extra": {
|
2493 |
+
"branch-alias": {
|
2494 |
+
"dev-master": "1.x-dev"
|
2495 |
+
},
|
2496 |
+
"commands": [
|
2497 |
+
"scaffold",
|
2498 |
+
"scaffold _s",
|
2499 |
+
"scaffold child-theme",
|
2500 |
+
"scaffold plugin",
|
2501 |
+
"scaffold plugin-tests",
|
2502 |
+
"scaffold post-type",
|
2503 |
+
"scaffold taxonomy",
|
2504 |
+
"scaffold theme-tests"
|
2505 |
+
],
|
2506 |
+
"bundled": true
|
2507 |
+
},
|
2508 |
+
"autoload": {
|
2509 |
+
"psr-4": {
|
2510 |
+
"": "src/"
|
2511 |
+
},
|
2512 |
+
"files": [
|
2513 |
+
"scaffold-command.php"
|
2514 |
+
]
|
2515 |
+
},
|
2516 |
+
"notification-url": "https://packagist.org/downloads/",
|
2517 |
+
"license": [
|
2518 |
+
"MIT"
|
2519 |
+
],
|
2520 |
+
"authors": [
|
2521 |
+
{
|
2522 |
+
"name": "Daniel Bachhuber",
|
2523 |
+
"email": "daniel@runcommand.io",
|
2524 |
+
"homepage": "https://runcommand.io"
|
2525 |
+
}
|
2526 |
+
],
|
2527 |
+
"description": "Generate code for post types, taxonomies, plugins, child themes, etc.",
|
2528 |
+
"homepage": "https://github.com/wp-cli/scaffold-command",
|
2529 |
+
"time": "2017-08-11T08:07:10+00:00"
|
2530 |
+
},
|
2531 |
+
{
|
2532 |
+
"name": "wp-cli/search-replace-command",
|
2533 |
+
"version": "dev-master",
|
2534 |
+
"source": {
|
2535 |
+
"type": "git",
|
2536 |
+
"url": "https://github.com/wp-cli/search-replace-command.git",
|
2537 |
+
"reference": "3e7499a65354e3a322d4d1043123b3fa55ef4f12"
|
2538 |
+
},
|
2539 |
+
"dist": {
|
2540 |
+
"type": "zip",
|
2541 |
+
"url": "https://api.github.com/repos/wp-cli/search-replace-command/zipball/3e7499a65354e3a322d4d1043123b3fa55ef4f12",
|
2542 |
+
"reference": "3e7499a65354e3a322d4d1043123b3fa55ef4f12",
|
2543 |
+
"shasum": ""
|
2544 |
+
},
|
2545 |
+
"require": {
|
2546 |
+
"wp-cli/wp-cli": "*"
|
2547 |
+
},
|
2548 |
+
"require-dev": {
|
2549 |
+
"behat/behat": "~2.5"
|
2550 |
+
},
|
2551 |
+
"type": "wp-cli-package",
|
2552 |
+
"extra": {
|
2553 |
+
"branch-alias": {
|
2554 |
+
"dev-master": "1.x-dev"
|
2555 |
+
},
|
2556 |
+
"commands": [
|
2557 |
+
"search-replace"
|
2558 |
+
],
|
2559 |
+
"bundled": true
|
2560 |
+
},
|
2561 |
+
"autoload": {
|
2562 |
+
"psr-4": {
|
2563 |
+
"": "src/",
|
2564 |
+
"WP_CLI\\": "src/WP_CLI"
|
2565 |
+
},
|
2566 |
+
"files": [
|
2567 |
+
"search-replace-command.php"
|
2568 |
+
]
|
2569 |
+
},
|
2570 |
+
"notification-url": "https://packagist.org/downloads/",
|
2571 |
+
"license": [
|
2572 |
+
"MIT"
|
2573 |
+
],
|
2574 |
+
"authors": [
|
2575 |
+
{
|
2576 |
+
"name": "Daniel Bachhuber",
|
2577 |
+
"email": "daniel@runcommand.io",
|
2578 |
+
"homepage": "https://runcommand.io"
|
2579 |
+
}
|
2580 |
+
],
|
2581 |
+
"description": "Search/replace strings in the database.",
|
2582 |
+
"homepage": "https://github.com/wp-cli/search-replace-command",
|
2583 |
+
"time": "2017-08-08T16:41:49+00:00"
|
2584 |
+
},
|
2585 |
+
{
|
2586 |
+
"name": "wp-cli/server-command",
|
2587 |
+
"version": "dev-master",
|
2588 |
+
"source": {
|
2589 |
+
"type": "git",
|
2590 |
+
"url": "https://github.com/wp-cli/server-command.git",
|
2591 |
+
"reference": "ce93df07c33e716adbbd2d329c311a3c1dd3a0b0"
|
2592 |
+
},
|
2593 |
+
"dist": {
|
2594 |
+
"type": "zip",
|
2595 |
+
"url": "https://api.github.com/repos/wp-cli/server-command/zipball/ce93df07c33e716adbbd2d329c311a3c1dd3a0b0",
|
2596 |
+
"reference": "ce93df07c33e716adbbd2d329c311a3c1dd3a0b0",
|
2597 |
+
"shasum": ""
|
2598 |
+
},
|
2599 |
+
"require": {
|
2600 |
+
"wp-cli/wp-cli": "*"
|
2601 |
+
},
|
2602 |
+
"require-dev": {
|
2603 |
+
"behat/behat": "~2.5"
|
2604 |
+
},
|
2605 |
+
"type": "wp-cli-package",
|
2606 |
+
"extra": {
|
2607 |
+
"branch-alias": {
|
2608 |
+
"dev-master": "1.x-dev"
|
2609 |
+
},
|
2610 |
+
"commands": [
|
2611 |
+
"server"
|
2612 |
+
],
|
2613 |
+
"bundled": true
|
2614 |
+
},
|
2615 |
+
"autoload": {
|
2616 |
+
"psr-4": {
|
2617 |
+
"": "src/"
|
2618 |
+
},
|
2619 |
+
"files": [
|
2620 |
+
"server-command.php"
|
2621 |
+
]
|
2622 |
+
},
|
2623 |
+
"notification-url": "https://packagist.org/downloads/",
|
2624 |
+
"license": [
|
2625 |
+
"MIT"
|
2626 |
+
],
|
2627 |
+
"authors": [
|
2628 |
+
{
|
2629 |
+
"name": "Daniel Bachhuber",
|
2630 |
+
"email": "daniel@runcommand.io",
|
2631 |
+
"homepage": "https://runcommand.io"
|
2632 |
+
}
|
2633 |
+
],
|
2634 |
+
"description": "Launch PHP's built-in web server for this specific WordPress installation.",
|
2635 |
+
"homepage": "https://github.com/wp-cli/server-command",
|
2636 |
+
"time": "2017-08-04T15:19:26+00:00"
|
2637 |
+
},
|
2638 |
+
{
|
2639 |
+
"name": "wp-cli/shell-command",
|
2640 |
+
"version": "dev-master",
|
2641 |
+
"source": {
|
2642 |
+
"type": "git",
|
2643 |
+
"url": "https://github.com/wp-cli/shell-command.git",
|
2644 |
+
"reference": "70681666302cc193a1bd41bade9ecc61e74a8c83"
|
2645 |
+
},
|
2646 |
+
"dist": {
|
2647 |
+
"type": "zip",
|
2648 |
+
"url": "https://api.github.com/repos/wp-cli/shell-command/zipball/70681666302cc193a1bd41bade9ecc61e74a8c83",
|
2649 |
+
"reference": "70681666302cc193a1bd41bade9ecc61e74a8c83",
|
2650 |
+
"shasum": ""
|
2651 |
+
},
|
2652 |
+
"require": {
|
2653 |
+
"wp-cli/wp-cli": "*"
|
2654 |
+
},
|
2655 |
+
"require-dev": {
|
2656 |
+
"behat/behat": "~2.5"
|
2657 |
+
},
|
2658 |
+
"type": "wp-cli-package",
|
2659 |
+
"extra": {
|
2660 |
+
"branch-alias": {
|
2661 |
+
"dev-master": "1.x-dev"
|
2662 |
+
},
|
2663 |
+
"commands": [
|
2664 |
+
"shell"
|
2665 |
+
],
|
2666 |
+
"bundled": true
|
2667 |
+
},
|
2668 |
+
"autoload": {
|
2669 |
+
"psr-4": {
|
2670 |
+
"": "src/",
|
2671 |
+
"WP_CLI\\": "src/WP_CLI"
|
2672 |
+
},
|
2673 |
+
"files": [
|
2674 |
+
"shell-command.php"
|
2675 |
+
]
|
2676 |
+
},
|
2677 |
+
"notification-url": "https://packagist.org/downloads/",
|
2678 |
+
"license": [
|
2679 |
+
"MIT"
|
2680 |
+
],
|
2681 |
+
"authors": [
|
2682 |
+
{
|
2683 |
+
"name": "Daniel Bachhuber",
|
2684 |
+
"email": "daniel@runcommand.io",
|
2685 |
+
"homepage": "https://runcommand.io"
|
2686 |
+
}
|
2687 |
+
],
|
2688 |
+
"description": "Interactive PHP console.",
|
2689 |
+
"homepage": "https://github.com/wp-cli/shell-command",
|
2690 |
+
"time": "2017-08-04T15:21:52+00:00"
|
2691 |
+
},
|
2692 |
+
{
|
2693 |
+
"name": "wp-cli/super-admin-command",
|
2694 |
+
"version": "dev-master",
|
2695 |
+
"source": {
|
2696 |
+
"type": "git",
|
2697 |
+
"url": "https://github.com/wp-cli/super-admin-command.git",
|
2698 |
+
"reference": "b650836d13762c764df2bbe70ad34212c0b773cd"
|
2699 |
+
},
|
2700 |
+
"dist": {
|
2701 |
+
"type": "zip",
|
2702 |
+
"url": "https://api.github.com/repos/wp-cli/super-admin-command/zipball/b650836d13762c764df2bbe70ad34212c0b773cd",
|
2703 |
+
"reference": "b650836d13762c764df2bbe70ad34212c0b773cd",
|
2704 |
+
"shasum": ""
|
2705 |
+
},
|
2706 |
+
"require-dev": {
|
2707 |
+
"behat/behat": "~2.5",
|
2708 |
+
"wp-cli/wp-cli": "*"
|
2709 |
+
},
|
2710 |
+
"type": "wp-cli-package",
|
2711 |
+
"extra": {
|
2712 |
+
"branch-alias": {
|
2713 |
+
"dev-master": "1.x-dev"
|
2714 |
+
},
|
2715 |
+
"commands": [
|
2716 |
+
"super-admin add",
|
2717 |
+
"super-admin list",
|
2718 |
+
"super-admin remove"
|
2719 |
+
],
|
2720 |
+
"bundled": true
|
2721 |
+
},
|
2722 |
+
"autoload": {
|
2723 |
+
"psr-4": {
|
2724 |
+
"": "src/"
|
2725 |
+
},
|
2726 |
+
"files": [
|
2727 |
+
"super-admin-command.php"
|
2728 |
+
]
|
2729 |
+
},
|
2730 |
+
"notification-url": "https://packagist.org/downloads/",
|
2731 |
+
"license": [
|
2732 |
+
"MIT"
|
2733 |
+
],
|
2734 |
+
"authors": [
|
2735 |
+
{
|
2736 |
+
"name": "Daniel Bachhuber",
|
2737 |
+
"email": "daniel@runcommand.io",
|
2738 |
+
"homepage": "https://runcommand.io"
|
2739 |
+
}
|
2740 |
+
],
|
2741 |
+
"description": "Manage super admins on WordPress multisite.",
|
2742 |
+
"homepage": "https://github.com/wp-cli/super-admin-command",
|
2743 |
+
"time": "2017-08-04T15:45:41+00:00"
|
2744 |
+
},
|
2745 |
+
{
|
2746 |
+
"name": "wp-cli/widget-command",
|
2747 |
+
"version": "dev-master",
|
2748 |
+
"source": {
|
2749 |
+
"type": "git",
|
2750 |
+
"url": "https://github.com/wp-cli/widget-command.git",
|
2751 |
+
"reference": "727af7c7b661031bc8c04ad176d4f24b862e3402"
|
2752 |
+
},
|
2753 |
+
"dist": {
|
2754 |
+
"type": "zip",
|
2755 |
+
"url": "https://api.github.com/repos/wp-cli/widget-command/zipball/727af7c7b661031bc8c04ad176d4f24b862e3402",
|
2756 |
+
"reference": "727af7c7b661031bc8c04ad176d4f24b862e3402",
|
2757 |
+
"shasum": ""
|
2758 |
+
},
|
2759 |
+
"require-dev": {
|
2760 |
+
"behat/behat": "~2.5",
|
2761 |
+
"wp-cli/wp-cli": "*"
|
2762 |
+
},
|
2763 |
+
"type": "wp-cli-package",
|
2764 |
+
"extra": {
|
2765 |
+
"branch-alias": {
|
2766 |
+
"dev-master": "1.x-dev"
|
2767 |
+
},
|
2768 |
+
"commands": [
|
2769 |
+
"widget add",
|
2770 |
+
"widget deactivate",
|
2771 |
+
"widget delete",
|
2772 |
+
"widget list",
|
2773 |
+
"widget move",
|
2774 |
+
"widget reset",
|
2775 |
+
"widget update",
|
2776 |
+
"sidebar list"
|
2777 |
+
],
|
2778 |
+
"bundled": true
|
2779 |
+
},
|
2780 |
+
"autoload": {
|
2781 |
+
"psr-4": {
|
2782 |
+
"": "src/"
|
2783 |
+
},
|
2784 |
+
"files": [
|
2785 |
+
"widget-command.php"
|
2786 |
+
]
|
2787 |
+
},
|
2788 |
+
"notification-url": "https://packagist.org/downloads/",
|
2789 |
+
"license": [
|
2790 |
+
"MIT"
|
2791 |
+
],
|
2792 |
+
"authors": [
|
2793 |
+
{
|
2794 |
+
"name": "Daniel Bachhuber",
|
2795 |
+
"email": "daniel@runcommand.io",
|
2796 |
+
"homepage": "https://runcommand.io"
|
2797 |
+
}
|
2798 |
+
],
|
2799 |
+
"description": "Manage widgets and sidebars.",
|
2800 |
+
"homepage": "https://github.com/wp-cli/widget-command",
|
2801 |
+
"time": "2017-08-04T15:24:29+00:00"
|
2802 |
+
},
|
2803 |
+
{
|
2804 |
+
"name": "wp-cli/wp-cli",
|
2805 |
+
"version": "v1.3.0",
|
2806 |
+
"source": {
|
2807 |
+
"type": "git",
|
2808 |
+
"url": "https://github.com/wp-cli/wp-cli.git",
|
2809 |
+
"reference": "4ab0d99da0ad5e6ca39453ff5c82d4f06aecb086"
|
2810 |
+
},
|
2811 |
+
"dist": {
|
2812 |
+
"type": "zip",
|
2813 |
+
"url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/4ab0d99da0ad5e6ca39453ff5c82d4f06aecb086",
|
2814 |
+
"reference": "4ab0d99da0ad5e6ca39453ff5c82d4f06aecb086",
|
2815 |
+
"shasum": ""
|
2816 |
+
},
|
2817 |
+
"require": {
|
2818 |
+
"composer/composer": "^1.2.0",
|
2819 |
+
"composer/semver": "~1.0",
|
2820 |
+
"mustache/mustache": "~2.4",
|
2821 |
+
"php": ">=5.3.29",
|
2822 |
+
"ramsey/array_column": "~1.1",
|
2823 |
+
"rmccue/requests": "~1.6",
|
2824 |
+
"symfony/config": "^2.7|^3.0",
|
2825 |
+
"symfony/console": "^2.7|^3.0",
|
2826 |
+
"symfony/debug": "^2.7|^3.0",
|
2827 |
+
"symfony/dependency-injection": "^2.7|^3.0",
|
2828 |
+
"symfony/event-dispatcher": "^2.7|^3.0",
|
2829 |
+
"symfony/filesystem": "^2.7|^3.0",
|
2830 |
+
"symfony/finder": "^2.7|^3.0",
|
2831 |
+
"symfony/process": "^2.1|^3.0",
|
2832 |
+
"symfony/translation": "^2.7|^3.0",
|
2833 |
+
"symfony/yaml": "^2.7|^3.0",
|
2834 |
+
"wp-cli/autoload-splitter": "^0.1.5",
|
2835 |
+
"wp-cli/cache-command": "^1.0",
|
2836 |
+
"wp-cli/checksum-command": "^1.0",
|
2837 |
+
"wp-cli/config-command": "^1.0",
|
2838 |
+
"wp-cli/core-command": "^1.0",
|
2839 |
+
"wp-cli/cron-command": "^1.0",
|
2840 |
+
"wp-cli/db-command": "^1.0",
|
2841 |
+
"wp-cli/entity-command": "^1.0",
|
2842 |
+
"wp-cli/eval-command": "^1.0",
|
2843 |
+
"wp-cli/export-command": "^1.0",
|
2844 |
+
"wp-cli/extension-command": "^1.0",
|
2845 |
+
"wp-cli/import-command": "^1.0",
|
2846 |
+
"wp-cli/language-command": "^1.0",
|
2847 |
+
"wp-cli/media-command": "^1.0",
|
2848 |
+
"wp-cli/mustangostang-spyc": "^0.6.3",
|
2849 |
+
"wp-cli/package-command": "^1.0",
|
2850 |
+
"wp-cli/php-cli-tools": "~0.11.2",
|
2851 |
+
"wp-cli/rewrite-command": "^1.0",
|
2852 |
+
"wp-cli/role-command": "^1.0",
|
2853 |
+
"wp-cli/scaffold-command": "^1.0",
|
2854 |
+
"wp-cli/search-replace-command": "^1.0",
|
2855 |
+
"wp-cli/server-command": "^1.0",
|
2856 |
+
"wp-cli/shell-command": "^1.0",
|
2857 |
+
"wp-cli/super-admin-command": "^1.0",
|
2858 |
+
"wp-cli/widget-command": "^1.0"
|
2859 |
+
},
|
2860 |
+
"require-dev": {
|
2861 |
+
"behat/behat": "2.5.*",
|
2862 |
+
"phpunit/phpunit": "3.7.*",
|
2863 |
+
"roave/security-advisories": "dev-master"
|
2864 |
+
},
|
2865 |
+
"suggest": {
|
2866 |
+
"psy/psysh": "Enhanced `wp shell` functionality"
|
2867 |
+
},
|
2868 |
+
"bin": [
|
2869 |
+
"bin/wp.bat",
|
2870 |
+
"bin/wp"
|
2871 |
+
],
|
2872 |
+
"type": "library",
|
2873 |
+
"extra": {
|
2874 |
+
"autoload-splitter": {
|
2875 |
+
"splitter-logic": "WP_CLI\\AutoloadSplitter",
|
2876 |
+
"splitter-location": "php/WP_CLI/AutoloadSplitter.php",
|
2877 |
+
"split-target-prefix-true": "autoload_commands",
|
2878 |
+
"split-target-prefix-false": "autoload_framework"
|
2879 |
+
}
|
2880 |
+
},
|
2881 |
+
"autoload": {
|
2882 |
+
"psr-0": {
|
2883 |
+
"WP_CLI": "php"
|
2884 |
+
},
|
2885 |
+
"psr-4": {
|
2886 |
+
"": "php/commands/src"
|
2887 |
+
}
|
2888 |
+
},
|
2889 |
+
"notification-url": "https://packagist.org/downloads/",
|
2890 |
+
"license": [
|
2891 |
+
"MIT"
|
2892 |
+
],
|
2893 |
+
"description": "A command line interface for WordPress",
|
2894 |
+
"homepage": "http://wp-cli.org",
|
2895 |
+
"keywords": [
|
2896 |
+
"cli",
|
2897 |
+
"wordpress"
|
2898 |
+
],
|
2899 |
+
"time": "2017-08-08T14:28:58+00:00"
|
2900 |
+
}
|
2901 |
+
],
|
2902 |
+
"aliases": [],
|
2903 |
+
"minimum-stability": "dev",
|
2904 |
+
"stability-flags": [],
|
2905 |
+
"prefer-stable": false,
|
2906 |
+
"prefer-lowest": false,
|
2907 |
+
"platform": [],
|
2908 |
+
"platform-dev": []
|
2909 |
+
}
|
trunk/includes/lib/action-scheduler/deprecated/ActionScheduler_Abstract_QueueRunner_Deprecated.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Abstract class with common Queue Cleaner functionality.
|
5 |
+
*/
|
6 |
+
abstract class ActionScheduler_Abstract_QueueRunner_Deprecated {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Get the maximum number of seconds a batch can run for.
|
10 |
+
*
|
11 |
+
* @deprecated 2.1.1
|
12 |
+
* @return int The number of seconds.
|
13 |
+
*/
|
14 |
+
protected function get_maximum_execution_time() {
|
15 |
+
_deprecated_function( __METHOD__, '2.1.1', 'ActionScheduler_Abstract_QueueRunner::get_time_limit()' );
|
16 |
+
|
17 |
+
$maximum_execution_time = 30;
|
18 |
+
|
19 |
+
// Apply deprecated filter
|
20 |
+
if ( has_filter( 'action_scheduler_maximum_execution_time' ) ) {
|
21 |
+
_deprecated_function( 'action_scheduler_maximum_execution_time', '2.1.1', 'action_scheduler_queue_runner_time_limit' );
|
22 |
+
$maximum_execution_time = apply_filters( 'action_scheduler_maximum_execution_time', $maximum_execution_time );
|
23 |
+
}
|
24 |
+
|
25 |
+
return absint( $maximum_execution_time );
|
26 |
+
}
|
27 |
+
}
|
trunk/includes/lib/action-scheduler/deprecated/ActionScheduler_AdminView_Deprecated.php
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_AdminView_Deprecated
|
5 |
+
*
|
6 |
+
* Store deprecated public functions previously found in the ActionScheduler_AdminView class.
|
7 |
+
* Keeps them out of the way of the main class.
|
8 |
+
*
|
9 |
+
* @codeCoverageIgnore
|
10 |
+
*/
|
11 |
+
class ActionScheduler_AdminView_Deprecated {
|
12 |
+
|
13 |
+
public function action_scheduler_post_type_args( $args ) {
|
14 |
+
_deprecated_function( __METHOD__, '2.0.0' );
|
15 |
+
return $args;
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Customise the post status related views displayed on the Scheduled Actions administration screen.
|
20 |
+
*
|
21 |
+
* @param array $views An associative array of views and view labels which can be used to filter the 'scheduled-action' posts displayed on the Scheduled Actions administration screen.
|
22 |
+
* @return array $views An associative array of views and view labels which can be used to filter the 'scheduled-action' posts displayed on the Scheduled Actions administration screen.
|
23 |
+
*/
|
24 |
+
public function list_table_views( $views ) {
|
25 |
+
_deprecated_function( __METHOD__, '2.0.0' );
|
26 |
+
return $views;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Do not include the "Edit" action for the Scheduled Actions administration screen.
|
31 |
+
*
|
32 |
+
* Hooked to the 'bulk_actions-edit-action-scheduler' filter.
|
33 |
+
*
|
34 |
+
* @param array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
|
35 |
+
* @return array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
|
36 |
+
*/
|
37 |
+
public function bulk_actions( $actions ) {
|
38 |
+
_deprecated_function( __METHOD__, '2.0.0' );
|
39 |
+
return $actions;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Completely customer the columns displayed on the Scheduled Actions administration screen.
|
44 |
+
*
|
45 |
+
* Because we can't filter the content of the default title and date columns, we need to recreate our own
|
46 |
+
* custom columns for displaying those post fields. For the column content, @see self::list_table_column_content().
|
47 |
+
*
|
48 |
+
* @param array $columns An associative array of columns that are use for the table on the Scheduled Actions administration screen.
|
49 |
+
* @return array $columns An associative array of columns that are use for the table on the Scheduled Actions administration screen.
|
50 |
+
*/
|
51 |
+
public function list_table_columns( $columns ) {
|
52 |
+
_deprecated_function( __METHOD__, '2.0.0' );
|
53 |
+
return $columns;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Make our custom title & date columns use defaulting title & date sorting.
|
58 |
+
*
|
59 |
+
* @param array $columns An associative array of columns that can be used to sort the table on the Scheduled Actions administration screen.
|
60 |
+
* @return array $columns An associative array of columns that can be used to sort the table on the Scheduled Actions administration screen.
|
61 |
+
*/
|
62 |
+
public static function list_table_sortable_columns( $columns ) {
|
63 |
+
_deprecated_function( __METHOD__, '2.0.0' );
|
64 |
+
return $columns;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Print the content for our custom columns.
|
69 |
+
*
|
70 |
+
* @param string $column_name The key for the column for which we should output our content.
|
71 |
+
* @param int $post_id The ID of the 'scheduled-action' post for which this row relates.
|
72 |
+
*/
|
73 |
+
public static function list_table_column_content( $column_name, $post_id ) {
|
74 |
+
_deprecated_function( __METHOD__, '2.0.0' );
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Hide the inline "Edit" action for all 'scheduled-action' posts.
|
79 |
+
*
|
80 |
+
* Hooked to the 'post_row_actions' filter.
|
81 |
+
*
|
82 |
+
* @param array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
|
83 |
+
* @return array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
|
84 |
+
*/
|
85 |
+
public static function row_actions( $actions, $post ) {
|
86 |
+
_deprecated_function( __METHOD__, '2.0.0' );
|
87 |
+
return $actions;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Run an action when triggered from the Action Scheduler administration screen.
|
92 |
+
*
|
93 |
+
* @codeCoverageIgnore
|
94 |
+
*/
|
95 |
+
public static function maybe_execute_action() {
|
96 |
+
_deprecated_function( __METHOD__, '2.0.0' );
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Convert an interval of seconds into a two part human friendly string.
|
101 |
+
*
|
102 |
+
* The WordPress human_time_diff() function only calculates the time difference to one degree, meaning
|
103 |
+
* even if an action is 1 day and 11 hours away, it will display "1 day". This funciton goes one step
|
104 |
+
* further to display two degrees of accuracy.
|
105 |
+
*
|
106 |
+
* Based on Crontrol::interval() function by Edward Dale: https://wordpress.org/plugins/wp-crontrol/
|
107 |
+
*
|
108 |
+
* @param int $interval A interval in seconds.
|
109 |
+
* @return string A human friendly string representation of the interval.
|
110 |
+
*/
|
111 |
+
public static function admin_notices() {
|
112 |
+
_deprecated_function( __METHOD__, '2.0.0' );
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Filter search queries to allow searching by Claim ID (i.e. post_password).
|
117 |
+
*
|
118 |
+
* @param string $orderby MySQL orderby string.
|
119 |
+
* @param WP_Query $query Instance of a WP_Query object
|
120 |
+
* @return string MySQL orderby string.
|
121 |
+
*/
|
122 |
+
public function custom_orderby( $orderby, $query ){
|
123 |
+
_deprecated_function( __METHOD__, '2.0.0' );
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Filter search queries to allow searching by Claim ID (i.e. post_password).
|
128 |
+
*
|
129 |
+
* @param string $search MySQL search string.
|
130 |
+
* @param WP_Query $query Instance of a WP_Query object
|
131 |
+
* @return string MySQL search string.
|
132 |
+
*/
|
133 |
+
public function search_post_password( $search, $query ) {
|
134 |
+
_deprecated_function( __METHOD__, '2.0.0' );
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Change messages when a scheduled action is updated.
|
139 |
+
*
|
140 |
+
* @param array $messages
|
141 |
+
* @return array
|
142 |
+
*/
|
143 |
+
public function post_updated_messages( $messages ) {
|
144 |
+
_deprecated_function( __METHOD__, '2.0.0' );
|
145 |
+
return $messages;
|
146 |
+
}
|
147 |
+
}
|
trunk/includes/lib/action-scheduler/deprecated/functions.php
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Deprecated API functions for scheduling actions
|
5 |
+
*
|
6 |
+
* Functions with the wc prefix were deprecated to avoid confusion with
|
7 |
+
* Action Scheduler being included in WooCommerce core, and it providing
|
8 |
+
* a different set of APIs for working with the action queue.
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Schedule an action to run one time
|
13 |
+
*
|
14 |
+
* @param int $timestamp When the job will run
|
15 |
+
* @param string $hook The hook to trigger
|
16 |
+
* @param array $args Arguments to pass when the hook triggers
|
17 |
+
* @param string $group The group to assign this job to
|
18 |
+
*
|
19 |
+
* @return string The job ID
|
20 |
+
*/
|
21 |
+
function wc_schedule_single_action( $timestamp, $hook, $args = array(), $group = '' ) {
|
22 |
+
_deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_single_action()' );
|
23 |
+
return as_schedule_single_action( $timestamp, $hook, $args, $group );
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Schedule a recurring action
|
28 |
+
*
|
29 |
+
* @param int $timestamp When the first instance of the job will run
|
30 |
+
* @param int $interval_in_seconds How long to wait between runs
|
31 |
+
* @param string $hook The hook to trigger
|
32 |
+
* @param array $args Arguments to pass when the hook triggers
|
33 |
+
* @param string $group The group to assign this job to
|
34 |
+
*
|
35 |
+
* @deprecated 2.1.0
|
36 |
+
*
|
37 |
+
* @return string The job ID
|
38 |
+
*/
|
39 |
+
function wc_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '' ) {
|
40 |
+
_deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_recurring_action()' );
|
41 |
+
return as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args, $group );
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Schedule an action that recurs on a cron-like schedule.
|
46 |
+
*
|
47 |
+
* @param int $timestamp The schedule will start on or after this time
|
48 |
+
* @param string $schedule A cron-link schedule string
|
49 |
+
* @see http://en.wikipedia.org/wiki/Cron
|
50 |
+
* * * * * * *
|
51 |
+
* ┬ ┬ ┬ ┬ ┬ ┬
|
52 |
+
* | | | | | |
|
53 |
+
* | | | | | + year [optional]
|
54 |
+
* | | | | +----- day of week (0 - 7) (Sunday=0 or 7)
|
55 |
+
* | | | +---------- month (1 - 12)
|
56 |
+
* | | +--------------- day of month (1 - 31)
|
57 |
+
* | +-------------------- hour (0 - 23)
|
58 |
+
* +------------------------- min (0 - 59)
|
59 |
+
* @param string $hook The hook to trigger
|
60 |
+
* @param array $args Arguments to pass when the hook triggers
|
61 |
+
* @param string $group The group to assign this job to
|
62 |
+
*
|
63 |
+
* @deprecated 2.1.0
|
64 |
+
*
|
65 |
+
* @return string The job ID
|
66 |
+
*/
|
67 |
+
function wc_schedule_cron_action( $timestamp, $schedule, $hook, $args = array(), $group = '' ) {
|
68 |
+
_deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_cron_action()' );
|
69 |
+
return as_schedule_cron_action( $timestamp, $schedule, $hook, $args, $group );
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Cancel the next occurrence of a job.
|
74 |
+
*
|
75 |
+
* @param string $hook The hook that the job will trigger
|
76 |
+
* @param array $args Args that would have been passed to the job
|
77 |
+
* @param string $group
|
78 |
+
*
|
79 |
+
* @deprecated 2.1.0
|
80 |
+
*/
|
81 |
+
function wc_unschedule_action( $hook, $args = array(), $group = '' ) {
|
82 |
+
_deprecated_function( __FUNCTION__, '2.1.0', 'as_unschedule_action()' );
|
83 |
+
as_unschedule_action( $hook, $args, $group );
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* @param string $hook
|
88 |
+
* @param array $args
|
89 |
+
* @param string $group
|
90 |
+
*
|
91 |
+
* @deprecated 2.1.0
|
92 |
+
*
|
93 |
+
* @return int|bool The timestamp for the next occurrence, or false if nothing was found
|
94 |
+
*/
|
95 |
+
function wc_next_scheduled_action( $hook, $args = NULL, $group = '' ) {
|
96 |
+
_deprecated_function( __FUNCTION__, '2.1.0', 'as_next_scheduled_action()' );
|
97 |
+
return as_next_scheduled_action( $hook, $args, $group );
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Find scheduled actions
|
102 |
+
*
|
103 |
+
* @param array $args Possible arguments, with their default values:
|
104 |
+
* 'hook' => '' - the name of the action that will be triggered
|
105 |
+
* 'args' => NULL - the args array that will be passed with the action
|
106 |
+
* 'date' => NULL - the scheduled date of the action. Expects a DateTime object, a unix timestamp, or a string that can parsed with strtotime(). Used in UTC timezone.
|
107 |
+
* 'date_compare' => '<=' - operator for testing "date". accepted values are '!=', '>', '>=', '<', '<=', '='
|
108 |
+
* 'modified' => NULL - the date the action was last updated. Expects a DateTime object, a unix timestamp, or a string that can parsed with strtotime(). Used in UTC timezone.
|
109 |
+
* 'modified_compare' => '<=' - operator for testing "modified". accepted values are '!=', '>', '>=', '<', '<=', '='
|
110 |
+
* 'group' => '' - the group the action belongs to
|
111 |
+
* 'status' => '' - ActionScheduler_Store::STATUS_COMPLETE or ActionScheduler_Store::STATUS_PENDING
|
112 |
+
* 'claimed' => NULL - TRUE to find claimed actions, FALSE to find unclaimed actions, a string to find a specific claim ID
|
113 |
+
* 'per_page' => 5 - Number of results to return
|
114 |
+
* 'offset' => 0
|
115 |
+
* 'orderby' => 'date' - accepted values are 'hook', 'group', 'modified', or 'date'
|
116 |
+
* 'order' => 'ASC'
|
117 |
+
* @param string $return_format OBJECT, ARRAY_A, or ids
|
118 |
+
*
|
119 |
+
* @deprecated 2.1.0
|
120 |
+
*
|
121 |
+
* @return array
|
122 |
+
*/
|
123 |
+
function wc_get_scheduled_actions( $args = array(), $return_format = OBJECT ) {
|
124 |
+
_deprecated_function( __FUNCTION__, '2.1.0', 'as_get_scheduled_actions()' );
|
125 |
+
return as_get_scheduled_actions( $args, $return_format );
|
126 |
+
}
|
trunk/includes/lib/action-scheduler/docs/CNAME
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
actionscheduler.org
|
trunk/includes/lib/action-scheduler/docs/_config.yml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
title: Action Scheduler - Job Queue for WordPress
|
2 |
+
description: A scalable, traceable job queue for background processing large queues of tasks in WordPress. Designed for distribution in WordPress plugins - no server access required.
|
3 |
+
theme: jekyll-theme-hacker
|
4 |
+
permalink: /:slug/
|
5 |
+
plugins:
|
6 |
+
- jekyll-seo-tag
|
7 |
+
- jekyll-sitemap
|
trunk/includes/lib/action-scheduler/docs/_layouts/default.html
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="{{ site.lang | default: "en-US" }}">
|
3 |
+
<head>
|
4 |
+
<meta charset='utf-8'>
|
5 |
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
7 |
+
<link rel="stylesheet" href="{{ '/assets/css/style.css?v=' | append: site.github.build_revision | relative_url }}">
|
8 |
+
|
9 |
+
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
10 |
+
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
11 |
+
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
12 |
+
<link rel="manifest" href="/site.webmanifest">
|
13 |
+
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#63c0f5">
|
14 |
+
<meta name="msapplication-TileColor" content="#151515">
|
15 |
+
<meta name="theme-color" content="#ffffff">
|
16 |
+
|
17 |
+
|
18 |
+
{% seo %}
|
19 |
+
</head>
|
20 |
+
|
21 |
+
<body>
|
22 |
+
|
23 |
+
<header>
|
24 |
+
<div class="container">
|
25 |
+
<p><a href="/usage/">Usage</a> | <a href="/admin/">Admin</a> | <a href="/wp-cli/">WP-CLI</a> | <a href="/perf/">Background Processing at Scale</a> | <a href="/api/">API</a> | <a href="/faq/">FAQ</a>
|
26 |
+
<h1><a href="/">action-scheduler</a></h1>
|
27 |
+
<h2>A scalable, traceable job queue for background processing large queues of tasks in WordPress. Designed for distribution in WordPress plugins - no server access required.</h2>
|
28 |
+
</div>
|
29 |
+
</header>
|
30 |
+
|
31 |
+
<div class="container">
|
32 |
+
<section id="main_content">
|
33 |
+
{{ content }}
|
34 |
+
</section>
|
35 |
+
</div>
|
36 |
+
|
37 |
+
<footer>
|
38 |
+
<div class="container">
|
39 |
+
<p><a href="/usage/">Usage</a> | <a href="/admin/">Admin</a> | <a href="/wp-cli/">WP-CLI</a> | <a href="/perf/">Background Processing at Scale</a> | <a href="/api/">API</a> | <a href="/faq/">FAQ</a>
|
40 |
+
<p class="footer-image">
|
41 |
+
<a href="https://prospress.com"><img src="http://pic.pros.pr/eb8dcec9bd54/prospress-hacker-green-logo.png" width="120"></a>
|
42 |
+
</p>
|
43 |
+
</div>
|
44 |
+
</footer>
|
45 |
+
|
46 |
+
{% if site.google_analytics %}
|
47 |
+
<script>
|
48 |
+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
49 |
+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
50 |
+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
51 |
+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
52 |
+
ga('create', '{{ site.google_analytics }}', 'auto');
|
53 |
+
ga('send', 'pageview');
|
54 |
+
</script>
|
55 |
+
{% endif %}
|
56 |
+
</body>
|
57 |
+
</html>
|
trunk/includes/lib/action-scheduler/docs/admin.md
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
description: Learn how to administer background jobs with the Action Scheduler job queue for WordPress.
|
3 |
+
---
|
4 |
+
# Scheduled Actions Administration Screen
|
5 |
+
|
6 |
+
Action Scheduler has a built in administration screen for monitoring, debugging and manually triggering scheduled actions.
|
7 |
+
|
8 |
+
The administration interface is accesible through both:
|
9 |
+
|
10 |
+
1. **Tools > Scheduled Actions**
|
11 |
+
1. **WooCommerce > Status > Scheduled Actions**, when WooCommerce is installed.
|
12 |
+
|
13 |
+
Among other tasks, from the admin screen you can:
|
14 |
+
|
15 |
+
* run a pending action
|
16 |
+
* view the scheduled actions with a specific status, like the all actions which have failed or are in-progress (https://cldup.com/NNTwE88Xl8.png).
|
17 |
+
* view the log entries for a specific action to find out why it failed.
|
18 |
+
* sort scheduled actions by hook name, scheduled date, claim ID or group name.
|
19 |
+
|
20 |
+
Still have questions? Check out the [FAQ](/faq).
|
21 |
+
|
22 |
+
![](https://cldup.com/5BA2BNB1sw.png)
|
trunk/includes/lib/action-scheduler/docs/android-chrome-192x192.png
ADDED
Binary file
|
trunk/includes/lib/action-scheduler/docs/android-chrome-256x256.png
ADDED
Binary file
|
trunk/includes/lib/action-scheduler/docs/api.md
ADDED
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
description: Reference guide for background processing functions provided by the Action Scheduler job queue for WordPress.
|
3 |
+
---
|
4 |
+
# API Reference
|
5 |
+
|
6 |
+
Action Scheduler provides a range of functions for scheduling hooks to run at some time in the future on one or more occassions.
|
7 |
+
|
8 |
+
To understand the scheduling functoins, it can help to think of them as extensions to WordPress' `do_action()` function that add the ability to delay and repeat when the hook will be triggered.
|
9 |
+
|
10 |
+
## WP-Cron APIs vs. Action Scheduler APIs
|
11 |
+
|
12 |
+
The Action Scheduler API functions are designed to mirror the WordPress [WP-Cron API functions](http://codex.wordpress.org/Category:WP-Cron_Functions).
|
13 |
+
|
14 |
+
Functions return similar values and accept similar arguments to their WP-Cron counterparts. The notable differences are:
|
15 |
+
|
16 |
+
* `as_schedule_single_action()` & `as_schedule_recurring_action()` will return the post ID of the scheduled action rather than boolean indicating whether the event was scheduled
|
17 |
+
* `as_schedule_recurring_action()` takes an interval in seconds as the recurring interval rather than an arbitrary string
|
18 |
+
* `as_schedule_single_action()` & `as_schedule_recurring_action()` can accept a `$group` parameter to group different actions for the one plugin together.
|
19 |
+
* the `wp_` prefix is substituted with `as_` and the term `event` is replaced with `action`
|
20 |
+
|
21 |
+
## API Function Availability
|
22 |
+
|
23 |
+
As mentioned in the [Usage - Load Order](/usage/#load-order) section, Action Scheduler will initialize itself on the `'init'` hook with priority `1`. While API functions are loaded prior to this and call be called, they should not be called until after `'init'` with priority `1`, because each component, like the data store, has not yet been initialized.
|
24 |
+
|
25 |
+
Do not use Action Scheduler API functions prior to `'init'` hook with priority `1`. Doing so could lead to unexpected results, like data being stored in the incorrect location.
|
26 |
+
|
27 |
+
## Function Reference / `as_schedule_single_action()`
|
28 |
+
|
29 |
+
### Description
|
30 |
+
|
31 |
+
Schedule an action to run one time.
|
32 |
+
|
33 |
+
### Usage
|
34 |
+
|
35 |
+
```php
|
36 |
+
as_schedule_single_action( $timestamp, $hook, $args, $group )
|
37 |
+
````
|
38 |
+
|
39 |
+
### Parameters
|
40 |
+
|
41 |
+
- **$timestamp** (integer)(required) The Unix timestamp representing the date you want the action to run. Default: _none_.
|
42 |
+
- **$hook** (string)(required) Name of the action hook. Default: _none_.
|
43 |
+
- **$args** (array) Arguments to pass to callbacks when the hook triggers. Default: _`array()`_.
|
44 |
+
- **$group** (array) The group to assign this job to. Default: _''_.
|
45 |
+
|
46 |
+
### Return value
|
47 |
+
|
48 |
+
(integer) the action's ID in the [posts](http://codex.wordpress.org/Database_Description#Table_Overview) table.
|
49 |
+
|
50 |
+
|
51 |
+
## Function Reference / `as_schedule_recurring_action()`
|
52 |
+
|
53 |
+
### Description
|
54 |
+
|
55 |
+
Schedule an action to run repeatedly with a specified interval in seconds.
|
56 |
+
|
57 |
+
### Usage
|
58 |
+
|
59 |
+
```php
|
60 |
+
as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args, $group )
|
61 |
+
````
|
62 |
+
|
63 |
+
### Parameters
|
64 |
+
|
65 |
+
- **$timestamp** (integer)(required) The Unix timestamp representing the date you want the action to run. Default: _none_.
|
66 |
+
- **$interval_in_seconds** (integer)(required) How long to wait between runs. Default: _none_.
|
67 |
+
- **$hook** (string)(required) Name of the action hook. Default: _none_.
|
68 |
+
- **$args** (array) Arguments to pass to callbacks when the hook triggers. Default: _`array()`_.
|
69 |
+
- **$group** (array) The group to assign this job to. Default: _''_.
|
70 |
+
|
71 |
+
### Return value
|
72 |
+
|
73 |
+
(integer) the action's ID in the [posts](http://codex.wordpress.org/Database_Description#Table_Overview) table.
|
74 |
+
|
75 |
+
|
76 |
+
## Function Reference / `as_schedule_cron_action()`
|
77 |
+
|
78 |
+
### Description
|
79 |
+
|
80 |
+
Schedule an action that recurs on a cron-like schedule.
|
81 |
+
|
82 |
+
### Usage
|
83 |
+
|
84 |
+
```php
|
85 |
+
as_schedule_cron_action( $timestamp, $schedule, $hook, $args, $group )
|
86 |
+
````
|
87 |
+
|
88 |
+
### Parameters
|
89 |
+
|
90 |
+
- **$timestamp** (integer)(required) The Unix timestamp representing the date you want the action to run. Default: _none_.
|
91 |
+
- **$schedule** (string)(required) $schedule A cron-link schedule string, see http://en.wikipedia.org/wiki/Cron. Default: _none_.
|
92 |
+
- **$hook** (string)(required) Name of the action hook. Default: _none_.
|
93 |
+
- **$args** (array) Arguments to pass to callbacks when the hook triggers. Default: _`array()`_.
|
94 |
+
- **$group** (array) The group to assign this job to. Default: _''_.
|
95 |
+
|
96 |
+
### Return value
|
97 |
+
|
98 |
+
(integer) the action's ID in the [posts](http://codex.wordpress.org/Database_Description#Table_Overview) table.
|
99 |
+
|
100 |
+
|
101 |
+
## Function Reference / `as_unschedule_action()`
|
102 |
+
|
103 |
+
### Description
|
104 |
+
|
105 |
+
Cancel the next occurrence of a job.
|
106 |
+
|
107 |
+
### Usage
|
108 |
+
|
109 |
+
```php
|
110 |
+
as_unschedule_action( $hook, $args, $group )
|
111 |
+
````
|
112 |
+
|
113 |
+
### Parameters
|
114 |
+
|
115 |
+
- **$hook** (string)(required) Name of the action hook. Default: _none_.
|
116 |
+
- **$args** (array) Arguments to pass to callbacks when the hook triggers. Default: _`array()`_.
|
117 |
+
- **$group** (array) The group to assign this job to. Default: _''_.
|
118 |
+
|
119 |
+
### Return value
|
120 |
+
|
121 |
+
(null)
|
122 |
+
|
123 |
+
|
124 |
+
## Function Reference / `as_next_scheduled_action()`
|
125 |
+
|
126 |
+
### Description
|
127 |
+
|
128 |
+
Returns the next timestamp for a scheduled action.
|
129 |
+
|
130 |
+
### Usage
|
131 |
+
|
132 |
+
```php
|
133 |
+
as_next_scheduled_action( $hook, $args, $group )
|
134 |
+
````
|
135 |
+
|
136 |
+
### Parameters
|
137 |
+
|
138 |
+
- **$hook** (string)(required) Name of the action hook. Default: _none_.
|
139 |
+
- **$args** (array) Arguments to pass to callbacks when the hook triggers. Default: _`array()`_.
|
140 |
+
- **$group** (array) The group to assign this job to. Default: _''_.
|
141 |
+
|
142 |
+
### Return value
|
143 |
+
|
144 |
+
(integer|boolean) The timestamp for the next occurrence, or false if nothing was found.
|
145 |
+
|
146 |
+
|
147 |
+
## Function Reference / `as_get_scheduled_actions()`
|
148 |
+
|
149 |
+
### Description
|
150 |
+
|
151 |
+
Find scheduled actions.
|
152 |
+
|
153 |
+
### Usage
|
154 |
+
|
155 |
+
```php
|
156 |
+
as_get_scheduled_actions( $args, $return_format )
|
157 |
+
````
|
158 |
+
|
159 |
+
### Parameters
|
160 |
+
|
161 |
+
- **$args** (array) Arguments to search and filter results by. Possible arguments, with their default values:
|
162 |
+
* `'hook' => ''` - the name of the action that will be triggered
|
163 |
+
* `'args' => NULL` - the args array that will be passed with the action
|
164 |
+
* `'date' => NULL` - the scheduled date of the action. Expects a DateTime object, a unix timestamp, or a string that can parsed with strtotime().
|
165 |
+
* `'date_compare' => '<=`' - operator for testing "date". accepted values are '!=', '>', '>=', '<', '<=', '='
|
166 |
+
* `'modified' => NULL` - the date the action was last updated. Expects a DateTime object, a unix timestamp, or a string that can parsed with strtotime().
|
167 |
+
* `'modified_compare' => '<='` - operator for testing "modified". accepted values are '!=', '>', '>=', '<', '<=', '='
|
168 |
+
* `'group' => ''` - the group the action belongs to
|
169 |
+
* `'status' => ''` - ActionScheduler_Store::STATUS_COMPLETE or ActionScheduler_Store::STATUS_PENDING
|
170 |
+
* `'claimed' => NULL` - TRUE to find claimed actions, FALSE to find unclaimed actions, a string to find a specific claim ID
|
171 |
+
* `'per_page' => 5` - Number of results to return
|
172 |
+
* `'offset' => 0`
|
173 |
+
* `'orderby' => 'date'` - accepted values are 'hook', 'group', 'modified', or 'date'
|
174 |
+
* `'order' => 'ASC'`
|
175 |
+
- **$return_format** (string) The format in which to return the scheduled actions: 'OBJECT', 'ARRAY_A', or 'ids'. Default: _'OBJECT'_.
|
176 |
+
|
177 |
+
### Return value
|
178 |
+
|
179 |
+
(array) Array of the actions matching the criteria specified with `$args`.
|
trunk/includes/lib/action-scheduler/docs/apple-touch-icon.png
ADDED
Binary file
|
trunk/includes/lib/action-scheduler/docs/assets/css/style.scss
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
---
|
3 |
+
|
4 |
+
@import "{{ site.theme }}";
|
5 |
+
|
6 |
+
a {
|
7 |
+
text-shadow: none;
|
8 |
+
text-decoration: none;
|
9 |
+
}
|
10 |
+
|
11 |
+
a:hover {
|
12 |
+
text-decoration: underline;
|
13 |
+
}
|
14 |
+
|
15 |
+
header h1 a {
|
16 |
+
color: #b5e853;
|
17 |
+
}
|
18 |
+
|
19 |
+
.container {
|
20 |
+
max-width: 700px;
|
21 |
+
}
|
22 |
+
|
23 |
+
footer {
|
24 |
+
margin-top: 6em;
|
25 |
+
padding: 1.6em 0;
|
26 |
+
border-top: 1px dashed #b5e853;
|
27 |
+
}
|
28 |
+
|
29 |
+
.footer-image {
|
30 |
+
text-align: center;
|
31 |
+
padding-top: 1em;
|
32 |
+
}
|
trunk/includes/lib/action-scheduler/docs/browserconfig.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
2 |
+
<browserconfig>
|
3 |
+
<msapplication>
|
4 |
+
<tile>
|
5 |
+
<square150x150logo src="/mstile-150x150.png"/>
|
6 |
+
<TileColor>#151515</TileColor>
|
7 |
+
</tile>
|
8 |
+
</msapplication>
|
9 |
+
</browserconfig>
|
trunk/includes/lib/action-scheduler/docs/faq.md
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## FAQ
|
2 |
+
|
3 |
+
### Is it safe to release Action Scheduler in my plugin? Won't its functions conflict with another copy of the library?
|
4 |
+
|
5 |
+
Action Scheduler is designed to be used and released in plugins. It avoids redeclaring public API functions when more than one copy of the library is being loaded by different plugins. It will also load only the most recent version of itself (by checking registered versions after all plugins are loaded on the `'plugins_loaded'` hook).
|
6 |
+
|
7 |
+
To use it in your plugin, simply require the `action-scheduler/action-scheduler.php` file. Action Scheduler will take care of the rest.
|
8 |
+
|
9 |
+
### I don't want to use WP-Cron. Does Action Scheduler depend on WP-Cron?
|
10 |
+
|
11 |
+
By default, Action Scheduler is initiated by WP-Cron. However, it has no dependency on the WP-Cron system. You can initiate the Action Scheduler queue in other ways with just one or two lines of code.
|
12 |
+
|
13 |
+
For example, you can start a queue directly by calling:
|
14 |
+
|
15 |
+
```php
|
16 |
+
ActionScheduler::runner()->run();
|
17 |
+
```
|
18 |
+
|
19 |
+
Or trigger the `'action_scheduler_run_queue'` hook and let Action Scheduler do it for you:
|
20 |
+
|
21 |
+
```php
|
22 |
+
do_action( 'action_scheduler_run_queue' );
|
23 |
+
```
|
24 |
+
|
25 |
+
Further customization can be done by extending the `ActionScheduler_Abstract_QueueRunner` class to create a custom Queue Runner. For an example of a customized queue runner, see the [`ActionScheduler_WPCLI_QueueRunner`](https://github.com/Prospress/action-scheduler/blob/master/classes/ActionScheduler_WPCLI_QueueRunner.php), which is used when running WP CLI.
|
26 |
+
|
27 |
+
Want to create some other method for initiating Action Scheduler? [Open a new issue](https://github.com/Prospress/action-scheduler/issues/new), we'd love to help you with it.
|
28 |
+
|
29 |
+
### I don't want to use WP-Cron, ever. Does Action Scheduler replace WP-Cron?
|
30 |
+
|
31 |
+
By default, Action Scheduler is designed to work alongside WP-Cron and not change any of its behaviour. This helps avoid unexpectedly overriding WP-Cron on sites installing your plugin, which may have nothing to do with WP-Cron.
|
32 |
+
|
33 |
+
However, we can understand why you might want to replace WP-Cron completely in environments within you control, especially as it gets you the advantages of Action Scheduler. This should be possible without too much code.
|
34 |
+
|
35 |
+
You could use the `'schedule_event'` hook in WordPress to use Action Scheduler for only newly scheduled WP-Cron jobs and map the `$event` param to Action Scheduler API functions.
|
36 |
+
|
37 |
+
Alternatively, you can use a combination of the `'pre_update_option_cron'` and `'pre_option_cron'` hooks to override all new and previously scheduled WP-Cron jobs (similar to the way [Cavalcade](https://github.com/humanmade/Cavalcade) does it).
|
38 |
+
|
39 |
+
If you'd like to create a plugin to do this automatically and want to share your work with others, [open a new issue to let us know](https://github.com/Prospress/action-scheduler/issues/new), we'd love to help you with it.
|
40 |
+
|
41 |
+
### Eww gross, Custom Post Types! That's _so_ 2010. Can I use a different storage scheme?
|
42 |
+
|
43 |
+
Of course! Action Scheduler data storage is completely swappable, and always has been.
|
44 |
+
|
45 |
+
You can store scheduled actions in custom tables in the WordPress site's database. Some sites using it already are. You can actually store them anywhere for that matter, like in a remote storage service from Amazon Web Services.
|
46 |
+
|
47 |
+
To implement a custom store:
|
48 |
+
|
49 |
+
1. extend the abstract `ActionScheduler_Store` class, being careful to implement each of its methods
|
50 |
+
2. attach a callback to `'action_scheduler_store_class'` to tell Action Scheduler your class is the one which should be used to manage storage, e.g.
|
51 |
+
|
52 |
+
```
|
53 |
+
function eg_define_custom_store( $existing_storage_class ) {
|
54 |
+
return 'My_Radical_Action_Scheduler_Store';
|
55 |
+
}
|
56 |
+
add_filter( 'action_scheduler_store_class', 'eg_define_custom_store', 10, 1 );
|
57 |
+
```
|
58 |
+
|
59 |
+
Take a look at the `ActionScheduler_wpPostStore` class for an example implementation of `ActionScheduler_Store`.
|
60 |
+
|
61 |
+
If you'd like to create a plugin to do this automatically and release it publicly to help others, [open a new issue to let us know](https://github.com/Prospress/action-scheduler/issues/new), we'd love to help you with it.
|
62 |
+
|
63 |
+
> Note: we're also moving Action Scheduler itself to use [custom tables for better scalability](https://github.com/Prospress/action-scheduler/issues/77).
|
64 |
+
|
65 |
+
### Can I use a different storage scheme just for logging?
|
66 |
+
|
67 |
+
Of course! Action Scheduler's logger is completely swappable, and always has been. You can also customise where logs are stored, and the storage mechanism.
|
68 |
+
|
69 |
+
To implement a custom logger:
|
70 |
+
|
71 |
+
1. extend the abstract `ActionScheduler_Logger` class, being careful to implement each of its methods
|
72 |
+
2. attach a callback to `'action_scheduler_logger_class'` to tell Action Scheduler your class is the one which should be used to manage logging, e.g.
|
73 |
+
|
74 |
+
```
|
75 |
+
function eg_define_custom_logger( $existing_storage_class ) {
|
76 |
+
return 'My_Radical_Action_Scheduler_Logger';
|
77 |
+
}
|
78 |
+
add_filter( 'action_scheduler_logger_class', 'eg_define_custom_logger', 10, 1 );
|
79 |
+
```
|
80 |
+
|
81 |
+
Take a look at the `ActionScheduler_wpCommentLogger` class for an example implementation of `ActionScheduler_Logger`.
|
82 |
+
|
83 |
+
### I want to run Action Scheduler only on a dedicated application server in my cluster. Can I do that?
|
84 |
+
|
85 |
+
Wow, now you're really asking the tough questions. In theory, yes, this is possible. The `ActionScheduler_QueueRunner` class, which is responsible for running queues, is swappable via the `'action_scheduler_queue_runner_class'` filter.
|
86 |
+
|
87 |
+
Because of this, you can effectively customise queue running however you need. Whether that means tweaking minor things, like not using WP-Cron at all to initiate queues by overriding `ActionScheduler_QueueRunner::init()`, or completely changing how and where queues are run, by overriding `ActionScheduler_QueueRunner::run()`.
|
88 |
+
|
89 |
+
### Is Action Scheduler safe to use on my production site?
|
90 |
+
|
91 |
+
Yes, absolutely! Action Scheduler is actively used on tens of thousands of production sites already. Right now it's responsible for scheduling everything from emails to payments.
|
92 |
+
|
93 |
+
In fact, every month, Action Scheduler processes millions of payments as part of the [WooCommerce Subscriptions](https://woocommerce.com/products/woocommerce-subscriptions/) extension.
|
94 |
+
|
95 |
+
It requires no setup, and won't override any WordPress APIs (unless you want it to).
|
96 |
+
|
97 |
+
### How does Action Scheduler work on WordPress Multisite?
|
98 |
+
|
99 |
+
Action Scheduler is designed to manage the scheduled actions on a single site. It has no special handling for running queues across multiple sites in a multisite network. That said, because it's storage and Queue Runner are completely swappable, it would be possible to write multisite handling classes to use with it.
|
100 |
+
|
101 |
+
If you'd like to create a multisite plugin to do this and release it publicly to help others, [open a new issue to let us know](https://github.com/Prospress/action-scheduler/issues/new), we'd love to help you with it.
|
trunk/includes/lib/action-scheduler/docs/favicon-16x16.png
ADDED
Binary file
|
trunk/includes/lib/action-scheduler/docs/favicon-32x32.png
ADDED
Binary file
|
trunk/includes/lib/action-scheduler/docs/favicon.ico
ADDED
Binary file
|
trunk/includes/lib/action-scheduler/docs/google14ef723abb376cd3.html
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
google-site-verification: google14ef723abb376cd3.html
|
trunk/includes/lib/action-scheduler/docs/index.md
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Action Scheduler - Background Processing Job Queue for WordPress
|
3 |
+
---
|
4 |
+
## WordPress Job Queue with Background Processing
|
5 |
+
|
6 |
+
Action Scheduler is a library for triggering a WordPress hook to run at some time in the future. Each hook can be scheduled with unique data, to allow callbacks to perform operations on that data. The hook can also be scheduled to run on one or more occassions.
|
7 |
+
|
8 |
+
Think of it like an extension to `do_action()` which adds the ability to delay and repeat a hook.
|
9 |
+
|
10 |
+
It just so happens, this functionality also creates a robust job queue for background processing large queues of tasks in WordPress. With the additional of logging and an [administration interface](/admin/), that also provide tracability on your tasks processed in the background.
|
11 |
+
|
12 |
+
### Battle-Tested Background Processing
|
13 |
+
|
14 |
+
Every month, Action Scheduler processes millions of payments for [Subscriptions](https://woocommerce.com/products/woocommerce-subscriptions/), webhooks for [WooCommerce](https://wordpress.org/plugins/woocommerce/), as well as emails and other events for a range of other plugins.
|
15 |
+
|
16 |
+
It's been seen on live sites processing queues in excess of 50,000 jobs and doing resource intensive operations, like processing payments and creating orders, in 10 concurrent queues at a rate of over 10,000 actions / hour without negatively impacting normal site operations.
|
17 |
+
|
18 |
+
This is all possible on infrastructure and WordPress sites outside the control of the plugin author.
|
19 |
+
|
20 |
+
Action Scheduler is specifically designed for distribution in WordPress plugins (and themes) - no server access required. If your plugin needs background processing, especially of large sets of tasks, Action Scheduler can help.
|
21 |
+
|
22 |
+
### How it Works
|
23 |
+
|
24 |
+
Action Scheduler uses a WordPress [custom post type](http://codex.wordpress.org/Post_Types), creatively named `scheduled-action`, to store the hook name, arguments and scheduled date for an action that should be triggered at some time in the future.
|
25 |
+
|
26 |
+
The scheduler will attempt to run every minute by attaching itself as a callback to the `'action_scheduler_run_schedule'` hook, which is scheduled using WordPress's built-in [WP-Cron](http://codex.wordpress.org/Function_Reference/wp_cron) system.
|
27 |
+
|
28 |
+
When triggered, Action Scheduler will check for posts of the `scheduled-action` type that have a `post_date` at or before this point in time i.e. actions scheduled to run now or at sometime in the past.
|
29 |
+
|
30 |
+
### Batch Processing Background Jobs
|
31 |
+
|
32 |
+
If there are actions to be processed, Action Scheduler will stake a unique claim for a batch of 20 actions and begin processing that batch. The PHP process spawned to run the batch will then continue processing batches of 20 actions until it times out or exhausts available memory.
|
33 |
+
|
34 |
+
If your site has a large number of actions scheduled to run at the same time, Action Scheduler will process more than one batch at a time. Specifically, when the `'action_scheduler_run_schedule'` hook is triggered approximately one minute after the first batch began processing, a new PHP process will stake a new claim to a batch of actions which were not claimed by the previous process. It will then begin to process that batch.
|
35 |
+
|
36 |
+
This will continue until all actions are processed using a maximum of 5 concurrent queues.
|
37 |
+
|
38 |
+
### Housekeeping
|
39 |
+
|
40 |
+
Before processing a batch, the scheduler will remove any existing claims on actions which have been sitting in a queue for more than five minutes.
|
41 |
+
|
42 |
+
Action Scheduler will also trash any actions which were completed more than a month ago.
|
43 |
+
|
44 |
+
If an action runs for more than 5 minutes, Action Scheduler will assume the action has timed out and will mark it as failed. However, if all callbacks attached to the action were to successfully complete sometime after that 5 minute timeout, its status would later be updated to completed.
|
45 |
+
|
46 |
+
### Traceable Background Processing
|
47 |
+
|
48 |
+
Did your background job run?
|
49 |
+
|
50 |
+
Never be left wondering with Action Scheduler's built-in record keeping.
|
51 |
+
|
52 |
+
All events for each action are logged in the [comments table](http://codex.wordpress.org/Database_Description#Table_Overview) and displayed in the [administration interface](/admin/).
|
53 |
+
|
54 |
+
The events logged by default include when an action:
|
55 |
+
* is created
|
56 |
+
* starts
|
57 |
+
* completes
|
58 |
+
* fails
|
59 |
+
|
60 |
+
If it fails with an error that can be recorded, that error will be recorded in the log and visible in administration interface, making it possible to trace what went wrong at some point in the past on a site you didn't have access to in the past.
|
61 |
+
|
62 |
+
Actions can also be grouped together using a custom taxonomy named `action-group`.
|
63 |
+
|
64 |
+
## Credits
|
65 |
+
|
66 |
+
Developed and maintained by [Prospress](http://prospress.com/) in collaboration with [Flightless](https://flightless.us/).
|
67 |
+
|
68 |
+
Collaboration is cool. We'd love to work with you to improve Action Scheduler. [Pull Requests](https://github.com/prospress/action-scheduler/pulls) welcome.
|
trunk/includes/lib/action-scheduler/docs/mstile-150x150.png
ADDED
Binary file
|
trunk/includes/lib/action-scheduler/docs/perf.md
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: WordPress Background Processing at Scale - Action Scheduler Job Queue
|
3 |
+
description: Learn how to do WordPress background processing at scale by tuning the Action Scheduler job queue's default WP Cron runner.
|
4 |
+
---
|
5 |
+
# Background Processing at Scale
|
6 |
+
|
7 |
+
Action Scheduler's default processing is designed to work reliably across all different hosting environments. In order to achieve that, the default processing thresholds are very conservative.
|
8 |
+
|
9 |
+
Specifically, Action Scheduler will only process actions until:
|
10 |
+
|
11 |
+
* 90% of available memory is used
|
12 |
+
* processing another 3 actions would exceed 30 seconds of total request time, based on the average processing time for the current batch
|
13 |
+
|
14 |
+
On sites with large queues, this can result in very slow processing time.
|
15 |
+
|
16 |
+
While using [WP CLI to process queues](/wp-cli/) is the best approach to increasing processing speed, on occasion, that is not a viable option. In these cases, it's also possible to increase the processing thresholds in Action Scheduler to increase the rate at which actions are processed by the default WP Cron queue runner.
|
17 |
+
|
18 |
+
## Increasing Time Limit
|
19 |
+
|
20 |
+
By default, Action Scheduler will only process actions for a maximum of 30 seconds. This time limit minimises the risk of a script timeout on unknown hosting environments, some of which enforce 30 second timeouts.
|
21 |
+
|
22 |
+
If you know your host supports longer than this time limit for web requests, you can increase this time limit. This allows more actions to be processed in each request and reduces the lag between processing each queue, greating speeding up the processing rate of scheduled actions.
|
23 |
+
|
24 |
+
For example, the following snippet will increase the timelimit to 2 minutes (120 seconds):
|
25 |
+
|
26 |
+
```php
|
27 |
+
function eg_increase_time_limit( $time_limit ) {
|
28 |
+
return 120;
|
29 |
+
}
|
30 |
+
add_filter( 'action_scheduler_queue_runner_time_limit', 'eg_increase_time_limit' );
|
31 |
+
```
|
32 |
+
|
33 |
+
Some of the known host time limits are:
|
34 |
+
|
35 |
+
* 60 second on WP Engine
|
36 |
+
* 120 seconds on Pantheon
|
37 |
+
* 120 seconds on SiteGround
|
38 |
+
|
39 |
+
## Increasing Batch Size
|
40 |
+
|
41 |
+
By default, Action Scheduler will claim a batch of 25 actions. This small batch size is because the default time limit is only 30 seconds; however, if you know your actions are processing very quickly, e.g. taking microseconds not seconds, or that you have more than 30 second available to process each batch, increasing the batch size can improve performance.
|
42 |
+
|
43 |
+
This is because claiming a batch has some overhead, so the less often a batch needs to be claimed, the faster actions can be processed.
|
44 |
+
|
45 |
+
For example, to increase the batch size to 100, we can use the following function:
|
46 |
+
|
47 |
+
```php
|
48 |
+
function eg_increase_action_scheduler_batch_size( $batch_size ) {
|
49 |
+
return 100;
|
50 |
+
}
|
51 |
+
add_filter( 'action_scheduler_queue_runner_batch_size', 'eg_increase_action_scheduler_batch_size' );
|
52 |
+
```
|
53 |
+
|
54 |
+
## Increasing Concurrent Batches
|
55 |
+
|
56 |
+
By default, Action Scheduler will run up to 5 concurrent batches of actions. This is to prevent consuming all the available connections or processes on your webserver.
|
57 |
+
|
58 |
+
However, your server may allow a large number of connection, for example, because it has a high value for Apache's `MaxClients` setting or PHP-FPM's `pm.max_children` setting.
|
59 |
+
|
60 |
+
If this is the case, you can use the `'action_scheduler_queue_runner_concurrent_batches'` filter to increase the number of conncurrent batches allowed, and therefore speed up processing large numbers of actions scheduled to be processed simultaneously.
|
61 |
+
|
62 |
+
For example, to increase the allowed number of concurrent queues to 10, we can use the following code:
|
63 |
+
|
64 |
+
```php
|
65 |
+
function eg_increase_action_scheduler_concurrent_batches( $concurrent_batches ) {
|
66 |
+
return 10;
|
67 |
+
}
|
68 |
+
add_filter( 'action_scheduler_queue_runner_concurrent_batches', 'eg_increase_action_scheduler_concurrent_batches' );
|
69 |
+
```
|
70 |
+
|
71 |
+
## Increasing Initialisation Rate of Runners
|
72 |
+
|
73 |
+
By default, Action scheduler initiates at most, one queue runner every time the `'action_scheduler_run_queue'` action is triggered by WP Cron.
|
74 |
+
|
75 |
+
Because this action is only triggered at most once every minute, if a queue is only allowed to process for one minute, then there will never be more than one queue processing actions, greatly reducing the processing rate.
|
76 |
+
|
77 |
+
To handle larger queues on more powerful servers, it's a good idea to initiate additional queue runners whenever the `'action_scheduler_run_queue'` action is run.
|
78 |
+
|
79 |
+
That can be done by initiated additional secure requests to our server via loopback requests.
|
80 |
+
|
81 |
+
The code below demonstrates how to create 5 loopback requests each time a queue begins
|
82 |
+
|
83 |
+
```php
|
84 |
+
/**
|
85 |
+
* Trigger 5 additional loopback requests with unique URL params.
|
86 |
+
*/
|
87 |
+
function eg_request_additional_runners() {
|
88 |
+
|
89 |
+
// allow self-signed SSL certificates
|
90 |
+
add_filter( 'https_local_ssl_verify', '__return_false', 100 );
|
91 |
+
|
92 |
+
for ( $i = 0; $i < 5; $i++ ) {
|
93 |
+
$response = wp_remote_post( admin_url( 'admin-ajax.php' ), array(
|
94 |
+
'method' => 'POST',
|
95 |
+
'timeout' => 45,
|
96 |
+
'redirection' => 5,
|
97 |
+
'httpversion' => '1.0',
|
98 |
+
'blocking' => false,
|
99 |
+
'headers' => array(),
|
100 |
+
'body' => array(
|
101 |
+
'action' => 'eg_create_additional_runners',
|
102 |
+
'instance' => $i,
|
103 |
+
'eg_nonce' => wp_create_nonce( 'eg_additional_runner_' . $i ),
|
104 |
+
),
|
105 |
+
'cookies' => array(),
|
106 |
+
) );
|
107 |
+
}
|
108 |
+
}
|
109 |
+
add_action( 'action_scheduler_run_queue', 'eg_request_additional_runners', 0 );
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Handle requests initiated by eg_request_additional_runners() and start a queue runner if the request is valid.
|
113 |
+
*/
|
114 |
+
function eg_create_additional_runners() {
|
115 |
+
|
116 |
+
if ( isset( $_POST['eg_nonce'] ) && isset( $_POST['instance'] ) && wp_verify_nonce( $_POST['eg_nonce'], 'eg_additional_runner_' . $_POST['instance'] ) ) {
|
117 |
+
ActionScheduler_QueueRunner::instance()->run();
|
118 |
+
}
|
119 |
+
|
120 |
+
wp_die();
|
121 |
+
}
|
122 |
+
add_action( 'wp_ajax_nopriv_eg_create_additional_runners', 'eg_create_additional_runners', 0 );
|
123 |
+
```
|
124 |
+
|
125 |
+
## High Volume Plugin
|
126 |
+
|
127 |
+
It's not necessary to add all of this code yourself, the folks at [Prospress](https://prospress.com) have created a handy plugin to get access to each of these increases - the [Action Scheduler - High Volume](https://github.com/prospress/action-scheduler-high-volume) plugin.
|
trunk/includes/lib/action-scheduler/docs/safari-pinned-tab.svg
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" standalone="no"?>
|
2 |
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
3 |
+
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
4 |
+
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
5 |
+
width="312.000000pt" height="312.000000pt" viewBox="0 0 312.000000 312.000000"
|
6 |
+
preserveAspectRatio="xMidYMid meet">
|
7 |
+
<metadata>
|
8 |
+
Created by potrace 1.11, written by Peter Selinger 2001-2013
|
9 |
+
</metadata>
|
10 |
+
<g transform="translate(0.000000,312.000000) scale(0.100000,-0.100000)"
|
11 |
+
fill="#000000" stroke="none">
|
12 |
+
<path d="M1837 2924 c-1 -1 -54 -5 -117 -8 -63 -4 -128 -9 -145 -11 -16 -2
|
13 |
+
-46 -6 -65 -9 -19 -3 -57 -8 -85 -11 -27 -3 -70 -10 -95 -16 -25 -5 -58 -11
|
14 |
+
-75 -13 -98 -13 -360 -73 -565 -130 -236 -65 -584 -172 -609 -187 -105 -67 24
|
15 |
+
-294 221 -387 77 -37 152 -61 206 -65 16 -1 22 -8 22 -23 0 -34 35 -107 70
|
16 |
+
-147 62 -71 161 -119 265 -130 34 -4 40 -8 46 -33 25 -122 151 -205 301 -198
|
17 |
+
122 5 254 44 270 80 6 13 8 27 5 30 -3 4 -41 1 -84 -5 -119 -18 -155 -19 -217
|
18 |
+
-9 -74 11 -123 47 -132 94 -7 40 -4 46 28 49 94 12 238 52 260 72 35 32 23 46
|
19 |
+
-34 38 -29 -4 -62 -9 -73 -11 -45 -10 -255 -11 -320 -2 -81 11 -154 40 -185
|
20 |
+
73 -24 26 -52 97 -42 106 4 4 45 9 92 12 93 7 90 6 269 43 69 14 134 30 145
|
21 |
+
36 29 15 56 39 56 50 0 10 -74 3 -144 -12 -22 -5 -144 -8 -270 -6 -251 3 -327
|
22 |
+
15 -443 71 -47 23 -133 97 -133 115 0 6 150 49 225 64 11 3 83 20 160 39 77
|
23 |
+
19 154 38 170 41 17 4 39 8 50 10 11 3 56 12 100 21 98 21 104 22 146 29 19 3
|
24 |
+
43 7 54 10 28 5 94 16 130 20 17 3 44 7 60 10 17 2 50 7 75 11 41 5 87 11 150
|
25 |
+
20 111 16 452 23 509 11 14 -3 47 -8 75 -11 28 -3 78 -13 111 -21 365 -92 513
|
26 |
+
-289 509 -679 -1 -102 -35 -265 -56 -265 -5 0 -7 -4 -4 -9 3 -4 -12 -41 -33
|
27 |
+
-81 -144 -277 -468 -551 -794 -671 -107 -39 -317 -88 -317 -73 0 2 50 118 111
|
28 |
+
257 61 138 131 299 156 357 25 58 49 114 54 125 5 11 52 119 104 240 90 208
|
29 |
+
94 221 84 255 -19 58 -67 147 -99 183 -33 38 -86 65 -99 51 -5 -5 -23 -43 -41
|
30 |
+
-84 -50 -116 -179 -408 -211 -478 -16 -35 -29 -65 -29 -67 0 -2 -18 -43 -40
|
31 |
+
-90 -22 -47 -40 -88 -40 -90 0 -4 -92 -211 -156 -353 -13 -29 -24 -55 -24 -57
|
32 |
+
0 -2 -15 -37 -34 -77 -18 -40 -46 -102 -61 -138 -16 -36 -45 -102 -67 -148
|
33 |
+
-21 -46 -38 -85 -38 -87 0 -2 -34 -81 -76 -175 -55 -124 -74 -178 -70 -196 16
|
34 |
+
-62 116 -134 207 -148 36 -5 37 -5 63 53 14 32 51 112 82 177 31 66 74 160 96
|
35 |
+
209 22 50 43 93 47 98 7 7 19 10 82 21 19 3 44 8 55 10 12 2 38 7 57 10 480
|
36 |
+
76 883 299 1117 618 100 135 202 363 224 498 1 8 5 35 9 60 16 95 13 216 -7
|
37 |
+
340 -10 59 -60 190 -97 252 -45 76 -151 190 -219 235 -127 85 -324 159 -475
|
38 |
+
179 -27 3 -53 8 -56 9 -12 8 -344 25 -352 19z"/>
|
39 |
+
</g>
|
40 |
+
</svg>
|
trunk/includes/lib/action-scheduler/docs/site.webmanifest
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "",
|
3 |
+
"short_name": "",
|
4 |
+
"icons": [
|
5 |
+
{
|
6 |
+
"src": "/android-chrome-192x192.png",
|
7 |
+
"sizes": "192x192",
|
8 |
+
"type": "image/png"
|
9 |
+
},
|
10 |
+
{
|
11 |
+
"src": "/android-chrome-256x256.png",
|
12 |
+
"sizes": "256x256",
|
13 |
+
"type": "image/png"
|
14 |
+
}
|
15 |
+
],
|
16 |
+
"theme_color": "#ffffff",
|
17 |
+
"background_color": "#ffffff",
|
18 |
+
"display": "standalone"
|
19 |
+
}
|
trunk/includes/lib/action-scheduler/docs/usage.md
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
description: Learn how to use the Action Scheduler background processing job queue for WordPress in your WordPress plugin.
|
3 |
+
---
|
4 |
+
# Usage
|
5 |
+
|
6 |
+
Using Action Scheduler requires:
|
7 |
+
|
8 |
+
1. installing the library
|
9 |
+
1. scheduling and action
|
10 |
+
1. attaching a callback to that action
|
11 |
+
|
12 |
+
## Scheduling an Action
|
13 |
+
|
14 |
+
To schedule an action, call the [API function](/api/) for the desired schedule type passing in the required parameters.
|
15 |
+
|
16 |
+
The example code below shows everything needed to schedule a function to run at midnight, if it's not already scheduled:
|
17 |
+
|
18 |
+
```php
|
19 |
+
require_once( plugin_dir_path( __FILE__ ) . '/libraries/action-scheduler/action-scheduler.php' );
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Schedule an action with the hook 'eg_midnight_log' to run at midnight each day
|
23 |
+
* so that our callback is run then.
|
24 |
+
*/
|
25 |
+
function eg_log_action_data() {
|
26 |
+
if ( false === as_next_scheduled_action( 'eg_midnight_log' ) ) {
|
27 |
+
as_schedule_recurring_action( strtotime( 'midnight tonight' ), DAY_IN_SECONDS, 'eg_midnight_log' );
|
28 |
+
}
|
29 |
+
}
|
30 |
+
add_action( 'init', 'eg_log_action_data' );
|
31 |
+
|
32 |
+
/**
|
33 |
+
* A callback to run when the 'eg_midnight_log' scheduled action is run.
|
34 |
+
*/
|
35 |
+
function eg_log_action_data() {
|
36 |
+
error_log( 'It is just after midnight on ' . date( 'Y-m-d' ) );
|
37 |
+
}
|
38 |
+
add_action( 'eg_midnight_log', 'eg_log_action_data' );
|
39 |
+
```
|
40 |
+
|
41 |
+
For more details on all available API functions, and the data they accept, refer to the [API Reference](/api/).
|
42 |
+
|
43 |
+
## Installation
|
44 |
+
|
45 |
+
There are two ways to install Action Scheduler:
|
46 |
+
|
47 |
+
1. regular WordPress plugin; or
|
48 |
+
1. a library within your plugin's codebase.
|
49 |
+
|
50 |
+
### Usage as a Plugin
|
51 |
+
|
52 |
+
Action Scheduler includes the necessary file headers to be used as a standard WordPress plugin.
|
53 |
+
|
54 |
+
To install it as a plugin:
|
55 |
+
|
56 |
+
1. Download the .zip archive of the latest [stable release](https://github.com/Prospress/action-scheduler/releases)
|
57 |
+
1. Go to the **Plugins > Add New > Upload** administration screen on your WordPress site
|
58 |
+
1. Select the archive file you just downloaded
|
59 |
+
1. Click **Install Now**
|
60 |
+
1. Click **Activate**
|
61 |
+
|
62 |
+
Or clone the Git repository into your site's `wp-content/plugins` folder.
|
63 |
+
|
64 |
+
Using Action Scheduler as a plugin can be handy for developing against newer versions, rather than having to update the subtree in your codebase. **When installed as a plugin, Action Scheduler does not provide any user interfaces for scheduling actions**. The only way to interact with Action Scheduler is via code.
|
65 |
+
|
66 |
+
### Usage as a Library
|
67 |
+
|
68 |
+
To use Action Scheduler as a library:
|
69 |
+
|
70 |
+
1. include the Action Scheduler codebase
|
71 |
+
1. load the library by including the `action-scheduler.php` file
|
72 |
+
|
73 |
+
Using a [subtree in your plugin, theme or site's Git repository](https://www.atlassian.com/blog/git/alternatives-to-git-submodule-git-subtree) to include Action Scheduler is the recommended method. Composer can also be used.
|
74 |
+
|
75 |
+
To include Action Scheduler as a git subtree:
|
76 |
+
|
77 |
+
#### Step 1. Add the Repository as a Remote
|
78 |
+
|
79 |
+
```
|
80 |
+
git remote add -f subtree-action-scheduler https://github.com/Prospress/action-scheduler.git
|
81 |
+
```
|
82 |
+
|
83 |
+
Adding the subtree as a remote allows us to refer to it in short from via the name `subtree-action-scheduler`, instead of the full GitHub URL.
|
84 |
+
|
85 |
+
#### Step 2. Add the Repo as a Subtree
|
86 |
+
|
87 |
+
```
|
88 |
+
git subtree add --prefix libraries/action-scheduler subtree-action-scheduler master --squash
|
89 |
+
```
|
90 |
+
|
91 |
+
This will add the `master` branch of Action Scheduler to your repository in the folder `libraries/action-scheduler`.
|
92 |
+
|
93 |
+
You can change the `--prefix` to change where the code is included. Or change the `master` branch to a tag, like `2.1.0` to include only a stable version.
|
94 |
+
|
95 |
+
#### Step 3. Update the Subtree
|
96 |
+
|
97 |
+
To update Action Scheduler to a new version, use the commands:
|
98 |
+
|
99 |
+
```
|
100 |
+
git fetch subtree-action-scheduler master
|
101 |
+
git subtree pull --prefix libraries/action-scheduler subtree-action-scheduler master --squash
|
102 |
+
```
|
103 |
+
|
104 |
+
### Loading Action Scheduler
|
105 |
+
|
106 |
+
Regardless of how it is installed, to load Action Scheduler, you only need to include the `action-scheduler.php` file, e.g.
|
107 |
+
|
108 |
+
```php
|
109 |
+
<?php
|
110 |
+
require_once( plugin_dir_path( __FILE__ ) . '/libraries/action-scheduler/action-scheduler.php' );
|
111 |
+
```
|
112 |
+
|
113 |
+
There is no need to call any functions or do else to initialize Action Scheduler.
|
114 |
+
|
115 |
+
When the `action-scheduler.php` file is included, Action Scheduler will register the version in that file and then load the most recent version of itself on the site. It will also load the most recent version of [all API functions](https://github.com/prospress/action-scheduler#api-functions).
|
116 |
+
|
117 |
+
### Load Order
|
118 |
+
|
119 |
+
Action Scheduler will register its version on `'plugins_loaded'` with priority `0` - after all other plugin codebases has been loaded. Therefore **the `action-scheduler.php` file must be included before `'plugins_loaded'` priority `0`**.
|
120 |
+
|
121 |
+
It is recommended to load it _when the file including it is included_. However, if you need to load it on a hook, then the hook must occur before `'plugins_loaded'`, or you can use `'plugins_loaded'` with negative priority, like `-10`.
|
122 |
+
|
123 |
+
Action Scheduler will later initialize itself on `'init'` with priority `1`. Action Scheduler APIs should not be used until after `'init'` with priority `1`.
|
trunk/includes/lib/action-scheduler/docs/wp-cli.md
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
description: Learn how to do WordPress background processing at scale with WP CLI and the Action Scheduler job queue.
|
3 |
+
---
|
4 |
+
# WP CLI
|
5 |
+
|
6 |
+
Action Scheduler has custom [WP CLI](http://wp-cli.org) commands available for processing actions.
|
7 |
+
|
8 |
+
For large sites, WP CLI is a much better choice for running queues of actions than the default WP Cron runner. These are some common cases where WP CLI is a better option:
|
9 |
+
|
10 |
+
* long-running tasks - Tasks that take a significant amount of time to run
|
11 |
+
* large queues - A large number of tasks will naturally take a longer time
|
12 |
+
* other plugins with extensive WP Cron usage - WP Cron's limited resources are spread across more tasks
|
13 |
+
|
14 |
+
With a regular web request, you may have to deal with script timeouts enforced by hosts, or other restraints that make it more challenging to run Action Scheduler tasks. Utilizing WP CLI to run commands directly on the server give you more freedom. This means that you typically don't have the same constraints of a normal web request.
|
15 |
+
|
16 |
+
If you choose to utilize WP CLI exclusively, you can disable the normal WP CLI queue runner by installing the [Action Scheduler - Disable Default Queue Runner](https://github.com/Prospress/action-scheduler-disable-default-runner) plugin. Note that if you do this, you **must** run Action Scheduler via WP CLI or another method, otherwise no scheduled actions will be processed.
|
17 |
+
|
18 |
+
## Commands
|
19 |
+
|
20 |
+
These are the commands available to use with Action Scheduler:
|
21 |
+
|
22 |
+
* `action-scheduler run`
|
23 |
+
|
24 |
+
Options:
|
25 |
+
* `--batch-size` - This is the number of actions to run in a single batch. The default is `100`.
|
26 |
+
* `--batches` - This is the number of batches to run. Using 0 means that batches will continue running until there are no more actions to run.
|
27 |
+
* `--hooks` - Process only actions with specific hook or hooks, like `'woocommerce_scheduled_subscription_payment'`. By default, actions with any hook will be processed. Define multiple hooks as a comma separated string (without spaces), e.g. `--hooks=woocommerce_scheduled_subscription_trial_end,woocommerce_scheduled_subscription_payment,woocommerce_scheduled_subscription_expiration`
|
28 |
+
* `--group` - Process only actions in a specific group, like `'woocommerce-memberships'`. By default, actions in any group (or no group) will be processed.
|
29 |
+
* `--force` - By default, Action Scheduler limits the number of concurrent batches that can be run at once to ensure the server does not get overwhelmed. Using the `--force` flag overrides this behavior to force the WP CLI queue to run.
|
30 |
+
|
31 |
+
The best way to get a full list of commands and their available options is to use WP CLI itself. This can be done by running `wp action-scheduler` to list all Action Scheduler commands, or by including the `--help` flag with any of the individual commands. This will provide all relevant parameters and flags for the command.
|
32 |
+
|
33 |
+
## Cautionary Note on Action Dependencies when using `--group` or `--hooks` Options
|
34 |
+
|
35 |
+
The `--group` and `--hooks` options should be used with caution if you have an implicit dependency between scheduled actions based on their schedule.
|
36 |
+
|
37 |
+
For example, consider two scheduled actions for the same subscription:
|
38 |
+
|
39 |
+
* `scheduled_payment` scheduled for `2015-11-13 00:00:00` and
|
40 |
+
* `scheduled_expiration` scheduled for `2015-11-13 00:01:00`.
|
41 |
+
|
42 |
+
Under normal conditions, Action Scheduler will ensure the `scheduled_payment` action is run before the `scheduled_expiration` action. Becuase that's how they are scheduled.
|
43 |
+
|
44 |
+
However, when using the `--hooks` option, the `scheduled_payment` and `scheduled_expiration` actions will be processed in separate queues. As a result, this dependency is not guaranteed.
|
45 |
+
|
46 |
+
For example, consider a site with both:
|
47 |
+
|
48 |
+
* 100,000 `scheduled_payment` actions, scheduled for `2015-11-13 00:00:00`
|
49 |
+
* 100 `scheduled_expiration` actions, scheduled for `2015-11-13 00:01:00`
|
50 |
+
|
51 |
+
If two queue runners are running alongside each other with each runner dedicated to just one of these hooks, the queue runner handling expiration hooks will complete the processing of the expiration hooks more quickly than the queue runner handling all the payment actions.
|
52 |
+
|
53 |
+
**Because of this, the `--group` and `--hooks` options should be used with caution to avoid processing actions with an implicit dependency based on their schedule in separate queues.**
|
54 |
+
|
55 |
+
## Improving Performance with `--group` or `--hooks`
|
56 |
+
|
57 |
+
Being able to run queues for specific hooks or groups of actions is valuable at scale. Why? Because it means you can restrict the concurrency for similar actions.
|
58 |
+
|
59 |
+
For example, let's say you have 300,000 actions queued up comprised of:
|
60 |
+
|
61 |
+
* 100,000 renewals payments
|
62 |
+
* 100,000 email notifications
|
63 |
+
* 100,000 membership status updates
|
64 |
+
|
65 |
+
Action Scheduler's default WP Cron queue runner will process them all together. e.g. when it claims a batch of actions, some may be emails, some membership updates and some renewals.
|
66 |
+
|
67 |
+
When you add concurrency to that, you can end up with issues. For example, if you have 3 queues running, they may all be attempting to process similar actions at the same time, which can lead to querying the same database tables with similar queries. Depending on the code/queries running, this can lead to database locks or other issues.
|
68 |
+
|
69 |
+
If you can batch based on each action's group, then you can improve performance by processing like actions consecutively, but still processing the full set of actions concurrently.
|
70 |
+
|
71 |
+
For example, if one queue is created to process emails, another to process membership updates, and another to process renewal payments, then the same queries won't be run at the same time, and 3 separate queues will be able to run more efficiently.
|
72 |
+
|
73 |
+
The WP CLI runner can achieve this using the `--group` option.
|
trunk/includes/lib/action-scheduler/functions.php
ADDED
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* General API functions for scheduling actions
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Schedule an action to run one time
|
9 |
+
*
|
10 |
+
* @param int $timestamp When the job will run
|
11 |
+
* @param string $hook The hook to trigger
|
12 |
+
* @param array $args Arguments to pass when the hook triggers
|
13 |
+
* @param string $group The group to assign this job to
|
14 |
+
*
|
15 |
+
* @return string The job ID
|
16 |
+
*/
|
17 |
+
function as_schedule_single_action( $timestamp, $hook, $args = array(), $group = '' ) {
|
18 |
+
return ActionScheduler::factory()->single( $hook, $args, $timestamp, $group );
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Schedule a recurring action
|
23 |
+
*
|
24 |
+
* @param int $timestamp When the first instance of the job will run
|
25 |
+
* @param int $interval_in_seconds How long to wait between runs
|
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 string The job ID
|
31 |
+
*/
|
32 |
+
function as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '' ) {
|
33 |
+
return ActionScheduler::factory()->recurring( $hook, $args, $timestamp, $interval_in_seconds, $group );
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Schedule an action that recurs on a cron-like schedule.
|
38 |
+
*
|
39 |
+
* @param int $timestamp The schedule will start on or after this time
|
40 |
+
* @param string $schedule A cron-link schedule string
|
41 |
+
* @see http://en.wikipedia.org/wiki/Cron
|
42 |
+
* * * * * * *
|
43 |
+
* ┬ ┬ ┬ ┬ ┬ ┬
|
44 |
+
* | | | | | |
|
45 |
+
* | | | | | + year [optional]
|
46 |
+
* | | | | +----- day of week (0 - 7) (Sunday=0 or 7)
|
47 |
+
* | | | +---------- month (1 - 12)
|
48 |
+
* | | +--------------- day of month (1 - 31)
|
49 |
+
* | +-------------------- hour (0 - 23)
|
50 |
+
* +------------------------- min (0 - 59)
|
51 |
+
* @param string $hook The hook to trigger
|
52 |
+
* @param array $args Arguments to pass when the hook triggers
|
53 |
+
* @param string $group The group to assign this job to
|
54 |
+
*
|
55 |
+
* @return string The job ID
|
56 |
+
*/
|
57 |
+
function as_schedule_cron_action( $timestamp, $schedule, $hook, $args = array(), $group = '' ) {
|
58 |
+
return ActionScheduler::factory()->cron( $hook, $args, $timestamp, $schedule, $group );
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Cancel the next occurrence of a scheduled action.
|
63 |
+
*
|
64 |
+
* While only the next instance of a recurring or cron action is unscheduled by this method, that will also prevent
|
65 |
+
* all future instances of that recurring or cron action from being run. Recurring and cron actions are scheduled in
|
66 |
+
* a sequence instead of all being scheduled at once. Each successive occurrence of a recurring action is scheduled
|
67 |
+
* only after the former action is run. If the next instance is never run, because it's unscheduled by this function,
|
68 |
+
* then the following instance will never be scheduled (or exist), which is effectively the same as being unscheduled
|
69 |
+
* by this method also.
|
70 |
+
*
|
71 |
+
* @param string $hook The hook that the job will trigger
|
72 |
+
* @param array $args Args that would have been passed to the job
|
73 |
+
* @param string $group
|
74 |
+
*
|
75 |
+
* @return string The scheduled action ID if a scheduled action was found, or empty string if no matching action found.
|
76 |
+
*/
|
77 |
+
function as_unschedule_action( $hook, $args = array(), $group = '' ) {
|
78 |
+
$params = array();
|
79 |
+
if ( is_array($args) ) {
|
80 |
+
$params['args'] = $args;
|
81 |
+
}
|
82 |
+
if ( !empty($group) ) {
|
83 |
+
$params['group'] = $group;
|
84 |
+
}
|
85 |
+
$job_id = ActionScheduler::store()->find_action( $hook, $params );
|
86 |
+
|
87 |
+
if ( ! empty( $job_id ) ) {
|
88 |
+
ActionScheduler::store()->cancel_action( $job_id );
|
89 |
+
}
|
90 |
+
|
91 |
+
return $job_id;
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Cancel all occurrences of a scheduled action.
|
96 |
+
*
|
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
|
100 |
+
*/
|
101 |
+
function as_unschedule_all_actions( $hook, $args = array(), $group = '' ) {
|
102 |
+
do {
|
103 |
+
$unscheduled_action = as_unschedule_action( $hook, $args, $group );
|
104 |
+
} while ( ! empty( $unscheduled_action ) );
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* @param string $hook
|
109 |
+
* @param array $args
|
110 |
+
* @param string $group
|
111 |
+
*
|
112 |
+
* @return int|bool The timestamp for the next occurrence, or false if nothing was found
|
113 |
+
*/
|
114 |
+
function as_next_scheduled_action( $hook, $args = NULL, $group = '' ) {
|
115 |
+
$params = array();
|
116 |
+
if ( is_array($args) ) {
|
117 |
+
$params['args'] = $args;
|
118 |
+
}
|
119 |
+
if ( !empty($group) ) {
|
120 |
+
$params['group'] = $group;
|
121 |
+
}
|
122 |
+
$job_id = ActionScheduler::store()->find_action( $hook, $params );
|
123 |
+
if ( empty($job_id) ) {
|
124 |
+
return false;
|
125 |
+
}
|
126 |
+
$job = ActionScheduler::store()->fetch_action( $job_id );
|
127 |
+
$next = $job->get_schedule()->next();
|
128 |
+
if ( $next ) {
|
129 |
+
return (int)($next->format('U'));
|
130 |
+
}
|
131 |
+
return false;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Find scheduled actions
|
136 |
+
*
|
137 |
+
* @param array $args Possible arguments, with their default values:
|
138 |
+
* 'hook' => '' - the name of the action that will be triggered
|
139 |
+
* 'args' => NULL - the args array that will be passed with the action
|
140 |
+
* 'date' => NULL - the scheduled date of the action. Expects a DateTime object, a unix timestamp, or a string that can parsed with strtotime(). Used in UTC timezone.
|
141 |
+
* 'date_compare' => '<=' - operator for testing "date". accepted values are '!=', '>', '>=', '<', '<=', '='
|
142 |
+
* 'modified' => NULL - the date the action was last updated. Expects a DateTime object, a unix timestamp, or a string that can parsed with strtotime(). Used in UTC timezone.
|
143 |
+
* 'modified_compare' => '<=' - operator for testing "modified". accepted values are '!=', '>', '>=', '<', '<=', '='
|
144 |
+
* 'group' => '' - the group the action belongs to
|
145 |
+
* 'status' => '' - ActionScheduler_Store::STATUS_COMPLETE or ActionScheduler_Store::STATUS_PENDING
|
146 |
+
* 'claimed' => NULL - TRUE to find claimed actions, FALSE to find unclaimed actions, a string to find a specific claim ID
|
147 |
+
* 'per_page' => 5 - Number of results to return
|
148 |
+
* 'offset' => 0
|
149 |
+
* 'orderby' => 'date' - accepted values are 'hook', 'group', 'modified', or 'date'
|
150 |
+
* 'order' => 'ASC'
|
151 |
+
*
|
152 |
+
* @param string $return_format OBJECT, ARRAY_A, or ids
|
153 |
+
*
|
154 |
+
* @return array
|
155 |
+
*/
|
156 |
+
function as_get_scheduled_actions( $args = array(), $return_format = OBJECT ) {
|
157 |
+
$store = ActionScheduler::store();
|
158 |
+
foreach ( array('date', 'modified') as $key ) {
|
159 |
+
if ( isset($args[$key]) ) {
|
160 |
+
$args[$key] = as_get_datetime_object($args[$key]);
|
161 |
+
}
|
162 |
+
}
|
163 |
+
$ids = $store->query_actions( $args );
|
164 |
+
|
165 |
+
if ( $return_format == 'ids' || $return_format == 'int' ) {
|
166 |
+
return $ids;
|
167 |
+
}
|
168 |
+
|
169 |
+
$actions = array();
|
170 |
+
foreach ( $ids as $action_id ) {
|
171 |
+
$actions[$action_id] = $store->fetch_action( $action_id );
|
172 |
+
}
|
173 |
+
|
174 |
+
if ( $return_format == ARRAY_A ) {
|
175 |
+
foreach ( $actions as $action_id => $action_object ) {
|
176 |
+
$actions[$action_id] = get_object_vars($action_object);
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
return $actions;
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Helper function to create an instance of DateTime based on a given
|
185 |
+
* string and timezone. By default, will return the current date/time
|
186 |
+
* in the UTC timezone.
|
187 |
+
*
|
188 |
+
* Needed because new DateTime() called without an explicit timezone
|
189 |
+
* will create a date/time in PHP's timezone, but we need to have
|
190 |
+
* assurance that a date/time uses the right timezone (which we almost
|
191 |
+
* always want to be UTC), which means we need to always include the
|
192 |
+
* timezone when instantiating datetimes rather than leaving it up to
|
193 |
+
* the PHP default.
|
194 |
+
*
|
195 |
+
* @param mixed $date_string A date/time string. Valid formats are explained in http://php.net/manual/en/datetime.formats.php
|
196 |
+
* @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
|
197 |
+
*
|
198 |
+
* @return ActionScheduler_DateTime
|
199 |
+
*/
|
200 |
+
function as_get_datetime_object( $date_string = null, $timezone = 'UTC' ) {
|
201 |
+
if ( is_object( $date_string ) && $date_string instanceof DateTime ) {
|
202 |
+
$date = new ActionScheduler_DateTime( $date_string->format( 'Y-m-d H:i:s' ), new DateTimeZone( $timezone ) );
|
203 |
+
} elseif ( is_numeric( $date_string ) ) {
|
204 |
+
$date = new ActionScheduler_DateTime( '@' . $date_string, new DateTimeZone( $timezone ) );
|
205 |
+
} else {
|
206 |
+
$date = new ActionScheduler_DateTime( $date_string, new DateTimeZone( $timezone ) );
|
207 |
+
}
|
208 |
+
return $date;
|
209 |
+
}
|
trunk/includes/lib/action-scheduler/lib/cron-expression/CronExpression.php
ADDED
@@ -0,0 +1,318 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* CRON expression parser that can determine whether or not a CRON expression is
|
5 |
+
* due to run, the next run date and previous run date of a CRON expression.
|
6 |
+
* The determinations made by this class are accurate if checked run once per
|
7 |
+
* minute (seconds are dropped from date time comparisons).
|
8 |
+
*
|
9 |
+
* Schedule parts must map to:
|
10 |
+
* minute [0-59], hour [0-23], day of month, month [1-12|JAN-DEC], day of week
|
11 |
+
* [1-7|MON-SUN], and an optional year.
|
12 |
+
*
|
13 |
+
* @author Michael Dowling <mtdowling@gmail.com>
|
14 |
+
* @link http://en.wikipedia.org/wiki/Cron
|
15 |
+
*/
|
16 |
+
class CronExpression
|
17 |
+
{
|
18 |
+
const MINUTE = 0;
|
19 |
+
const HOUR = 1;
|
20 |
+
const DAY = 2;
|
21 |
+
const MONTH = 3;
|
22 |
+
const WEEKDAY = 4;
|
23 |
+
const YEAR = 5;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @var array CRON expression parts
|
27 |
+
*/
|
28 |
+
private $cronParts;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @var CronExpression_FieldFactory CRON field factory
|
32 |
+
*/
|
33 |
+
private $fieldFactory;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @var array Order in which to test of cron parts
|
37 |
+
*/
|
38 |
+
private static $order = array(self::YEAR, self::MONTH, self::DAY, self::WEEKDAY, self::HOUR, self::MINUTE);
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Factory method to create a new CronExpression.
|
42 |
+
*
|
43 |
+
* @param string $expression The CRON expression to create. There are
|
44 |
+
* several special predefined values which can be used to substitute the
|
45 |
+
* CRON expression:
|
46 |
+
*
|
47 |
+
* @yearly, @annually) - Run once a year, midnight, Jan. 1 - 0 0 1 1 *
|
48 |
+
* @monthly - Run once a month, midnight, first of month - 0 0 1 * *
|
49 |
+
* @weekly - Run once a week, midnight on Sun - 0 0 * * 0
|
50 |
+
* @daily - Run once a day, midnight - 0 0 * * *
|
51 |
+
* @hourly - Run once an hour, first minute - 0 * * * *
|
52 |
+
*
|
53 |
+
*@param CronExpression_FieldFactory $fieldFactory (optional) Field factory to use
|
54 |
+
*
|
55 |
+
* @return CronExpression
|
56 |
+
*/
|
57 |
+
public static function factory($expression, CronExpression_FieldFactory $fieldFactory = null)
|
58 |
+
{
|
59 |
+
$mappings = array(
|
60 |
+
'@yearly' => '0 0 1 1 *',
|
61 |
+
'@annually' => '0 0 1 1 *',
|
62 |
+
'@monthly' => '0 0 1 * *',
|
63 |
+
'@weekly' => '0 0 * * 0',
|
64 |
+
'@daily' => '0 0 * * *',
|
65 |
+
'@hourly' => '0 * * * *'
|
66 |
+
);
|
67 |
+
|
68 |
+
if (isset($mappings[$expression])) {
|
69 |
+
$expression = $mappings[$expression];
|
70 |
+
}
|
71 |
+
|
72 |
+
return new self($expression, $fieldFactory ? $fieldFactory : new CronExpression_FieldFactory());
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Parse a CRON expression
|
77 |
+
*
|
78 |
+
* @param string $expression CRON expression (e.g. '8 * * * *')
|
79 |
+
* @param CronExpression_FieldFactory $fieldFactory Factory to create cron fields
|
80 |
+
*/
|
81 |
+
public function __construct($expression, CronExpression_FieldFactory $fieldFactory)
|
82 |
+
{
|
83 |
+
$this->fieldFactory = $fieldFactory;
|
84 |
+
$this->setExpression($expression);
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Set or change the CRON expression
|
89 |
+
*
|
90 |
+
* @param string $value CRON expression (e.g. 8 * * * *)
|
91 |
+
*
|
92 |
+
* @return CronExpression
|
93 |
+
* @throws InvalidArgumentException if not a valid CRON expression
|
94 |
+
*/
|
95 |
+
public function setExpression($value)
|
96 |
+
{
|
97 |
+
$this->cronParts = preg_split('/\s/', $value, -1, PREG_SPLIT_NO_EMPTY);
|
98 |
+
if (count($this->cronParts) < 5) {
|
99 |
+
throw new InvalidArgumentException(
|
100 |
+
$value . ' is not a valid CRON expression'
|
101 |
+
);
|
102 |
+
}
|
103 |
+
|
104 |
+
foreach ($this->cronParts as $position => $part) {
|
105 |
+
$this->setPart($position, $part);
|
106 |
+
}
|
107 |
+
|
108 |
+
return $this;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Set part of the CRON expression
|
113 |
+
*
|
114 |
+
* @param int $position The position of the CRON expression to set
|
115 |
+
* @param string $value The value to set
|
116 |
+
*
|
117 |
+
* @return CronExpression
|
118 |
+
* @throws InvalidArgumentException if the value is not valid for the part
|
119 |
+
*/
|
120 |
+
public function setPart($position, $value)
|
121 |
+
{
|
122 |
+
if (!$this->fieldFactory->getField($position)->validate($value)) {
|
123 |
+
throw new InvalidArgumentException(
|
124 |
+
'Invalid CRON field value ' . $value . ' as position ' . $position
|
125 |
+
);
|
126 |
+
}
|
127 |
+
|
128 |
+
$this->cronParts[$position] = $value;
|
129 |
+
|
130 |
+
return $this;
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Get a next run date relative to the current date or a specific date
|
135 |
+
*
|
136 |
+
* @param string|DateTime $currentTime (optional) Relative calculation date
|
137 |
+
* @param int $nth (optional) Number of matches to skip before returning a
|
138 |
+
* matching next run date. 0, the default, will return the current
|
139 |
+
* date and time if the next run date falls on the current date and
|
140 |
+
* time. Setting this value to 1 will skip the first match and go to
|
141 |
+
* the second match. Setting this value to 2 will skip the first 2
|
142 |
+
* matches and so on.
|
143 |
+
* @param bool $allowCurrentDate (optional) Set to TRUE to return the
|
144 |
+
* current date if it matches the cron expression
|
145 |
+
*
|
146 |
+
* @return DateTime
|
147 |
+
* @throws RuntimeException on too many iterations
|
148 |
+
*/
|
149 |
+
public function getNextRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false)
|
150 |
+
{
|
151 |
+
return $this->getRunDate($currentTime, $nth, false, $allowCurrentDate);
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Get a previous run date relative to the current date or a specific date
|
156 |
+
*
|
157 |
+
* @param string|DateTime $currentTime (optional) Relative calculation date
|
158 |
+
* @param int $nth (optional) Number of matches to skip before returning
|
159 |
+
* @param bool $allowCurrentDate (optional) Set to TRUE to return the
|
160 |
+
* current date if it matches the cron expression
|
161 |
+
*
|
162 |
+
* @return DateTime
|
163 |
+
* @throws RuntimeException on too many iterations
|
164 |
+
* @see CronExpression::getNextRunDate
|
165 |
+
*/
|
166 |
+
public function getPreviousRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false)
|
167 |
+
{
|
168 |
+
return $this->getRunDate($currentTime, $nth, true, $allowCurrentDate);
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Get multiple run dates starting at the current date or a specific date
|
173 |
+
*
|
174 |
+
* @param int $total Set the total number of dates to calculate
|
175 |
+
* @param string|DateTime $currentTime (optional) Relative calculation date
|
176 |
+
* @param bool $invert (optional) Set to TRUE to retrieve previous dates
|
177 |
+
* @param bool $allowCurrentDate (optional) Set to TRUE to return the
|
178 |
+
* current date if it matches the cron expression
|
179 |
+
*
|
180 |
+
* @return array Returns an array of run dates
|
181 |
+
*/
|
182 |
+
public function getMultipleRunDates($total, $currentTime = 'now', $invert = false, $allowCurrentDate = false)
|
183 |
+
{
|
184 |
+
$matches = array();
|
185 |
+
for ($i = 0; $i < max(0, $total); $i++) {
|
186 |
+
$matches[] = $this->getRunDate($currentTime, $i, $invert, $allowCurrentDate);
|
187 |
+
}
|
188 |
+
|
189 |
+
return $matches;
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Get all or part of the CRON expression
|
194 |
+
*
|
195 |
+
* @param string $part (optional) Specify the part to retrieve or NULL to
|
196 |
+
* get the full cron schedule string.
|
197 |
+
*
|
198 |
+
* @return string|null Returns the CRON expression, a part of the
|
199 |
+
* CRON expression, or NULL if the part was specified but not found
|
200 |
+
*/
|
201 |
+
public function getExpression($part = null)
|
202 |
+
{
|
203 |
+
if (null === $part) {
|
204 |
+
return implode(' ', $this->cronParts);
|
205 |
+
} elseif (array_key_exists($part, $this->cronParts)) {
|
206 |
+
return $this->cronParts[$part];
|
207 |
+
}
|
208 |
+
|
209 |
+
return null;
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Helper method to output the full expression.
|
214 |
+
*
|
215 |
+
* @return string Full CRON expression
|
216 |
+
*/
|
217 |
+
public function __toString()
|
218 |
+
{
|
219 |
+
return $this->getExpression();
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Determine if the cron is due to run based on the current date or a
|
224 |
+
* specific date. This method assumes that the current number of
|
225 |
+
* seconds are irrelevant, and should be called once per minute.
|
226 |
+
*
|
227 |
+
* @param string|DateTime $currentTime (optional) Relative calculation date
|
228 |
+
*
|
229 |
+
* @return bool Returns TRUE if the cron is due to run or FALSE if not
|
230 |
+
*/
|
231 |
+
public function isDue($currentTime = 'now')
|
232 |
+
{
|
233 |
+
if ('now' === $currentTime) {
|
234 |
+
$currentDate = date('Y-m-d H:i');
|
235 |
+
$currentTime = strtotime($currentDate);
|
236 |
+
} elseif ($currentTime instanceof DateTime) {
|
237 |
+
$currentDate = $currentTime->format('Y-m-d H:i');
|
238 |
+
$currentTime = strtotime($currentDate);
|
239 |
+
} else {
|
240 |
+
$currentTime = new DateTime($currentTime);
|
241 |
+
$currentTime->setTime($currentTime->format('H'), $currentTime->format('i'), 0);
|
242 |
+
$currentDate = $currentTime->format('Y-m-d H:i');
|
243 |
+
$currentTime = (int)($currentTime->getTimestamp());
|
244 |
+
}
|
245 |
+
|
246 |
+
return $this->getNextRunDate($currentDate, 0, true)->getTimestamp() == $currentTime;
|
247 |
+
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
* Get the next or previous run date of the expression relative to a date
|
251 |
+
*
|
252 |
+
* @param string|DateTime $currentTime (optional) Relative calculation date
|
253 |
+
* @param int $nth (optional) Number of matches to skip before returning
|
254 |
+
* @param bool $invert (optional) Set to TRUE to go backwards in time
|
255 |
+
* @param bool $allowCurrentDate (optional) Set to TRUE to return the
|
256 |
+
* current date if it matches the cron expression
|
257 |
+
*
|
258 |
+
* @return DateTime
|
259 |
+
* @throws RuntimeException on too many iterations
|
260 |
+
*/
|
261 |
+
protected function getRunDate($currentTime = null, $nth = 0, $invert = false, $allowCurrentDate = false)
|
262 |
+
{
|
263 |
+
if ($currentTime instanceof DateTime) {
|
264 |
+
$currentDate = $currentTime;
|
265 |
+
} else {
|
266 |
+
$currentDate = new DateTime($currentTime ? $currentTime : 'now');
|
267 |
+
$currentDate->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
268 |
+
}
|
269 |
+
|
270 |
+
$currentDate->setTime($currentDate->format('H'), $currentDate->format('i'), 0);
|
271 |
+
$nextRun = clone $currentDate;
|
272 |
+
$nth = (int) $nth;
|
273 |
+
|
274 |
+
// Set a hard limit to bail on an impossible date
|
275 |
+
for ($i = 0; $i < 1000; $i++) {
|
276 |
+
|
277 |
+
foreach (self::$order as $position) {
|
278 |
+
$part = $this->getExpression($position);
|
279 |
+
if (null === $part) {
|
280 |
+
continue;
|
281 |
+
}
|
282 |
+
|
283 |
+
$satisfied = false;
|
284 |
+
// Get the field object used to validate this part
|
285 |
+
$field = $this->fieldFactory->getField($position);
|
286 |
+
// Check if this is singular or a list
|
287 |
+
if (strpos($part, ',') === false) {
|
288 |
+
$satisfied = $field->isSatisfiedBy($nextRun, $part);
|
289 |
+
} else {
|
290 |
+
foreach (array_map('trim', explode(',', $part)) as $listPart) {
|
291 |
+
if ($field->isSatisfiedBy($nextRun, $listPart)) {
|
292 |
+
$satisfied = true;
|
293 |
+
break;
|
294 |
+
}
|
295 |
+
}
|
296 |
+
}
|
297 |
+
|
298 |
+
// If the field is not satisfied, then start over
|
299 |
+
if (!$satisfied) {
|
300 |
+
$field->increment($nextRun, $invert);
|
301 |
+
continue 2;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
305 |
+
// Skip this match if needed
|
306 |
+
if ((!$allowCurrentDate && $nextRun == $currentDate) || --$nth > -1) {
|
307 |
+
$this->fieldFactory->getField(0)->increment($nextRun, $invert);
|
308 |
+
continue;
|
309 |
+
}
|
310 |
+
|
311 |
+
return $nextRun;
|
312 |
+
}
|
313 |
+
|
314 |
+
// @codeCoverageIgnoreStart
|
315 |
+
throw new RuntimeException('Impossible CRON expression');
|
316 |
+
// @codeCoverageIgnoreEnd
|
317 |
+
}
|
318 |
+
}
|
trunk/includes/lib/action-scheduler/lib/cron-expression/CronExpression_AbstractField.php
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Abstract CRON expression field
|
5 |
+
*
|
6 |
+
* @author Michael Dowling <mtdowling@gmail.com>
|
7 |
+
*/
|
8 |
+
abstract class CronExpression_AbstractField implements CronExpression_FieldInterface
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Check to see if a field is satisfied by a value
|
12 |
+
*
|
13 |
+
* @param string $dateValue Date value to check
|
14 |
+
* @param string $value Value to test
|
15 |
+
*
|
16 |
+
* @return bool
|
17 |
+
*/
|
18 |
+
public function isSatisfied($dateValue, $value)
|
19 |
+
{
|
20 |
+
if ($this->isIncrementsOfRanges($value)) {
|
21 |
+
return $this->isInIncrementsOfRanges($dateValue, $value);
|
22 |
+
} elseif ($this->isRange($value)) {
|
23 |
+
return $this->isInRange($dateValue, $value);
|
24 |
+
}
|
25 |
+
|
26 |
+
return $value == '*' || $dateValue == $value;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Check if a value is a range
|
31 |
+
*
|
32 |
+
* @param string $value Value to test
|
33 |
+
*
|
34 |
+
* @return bool
|
35 |
+
*/
|
36 |
+
public function isRange($value)
|
37 |
+
{
|
38 |
+
return strpos($value, '-') !== false;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Check if a value is an increments of ranges
|
43 |
+
*
|
44 |
+
* @param string $value Value to test
|
45 |
+
*
|
46 |
+
* @return bool
|
47 |
+
*/
|
48 |
+
public function isIncrementsOfRanges($value)
|
49 |
+
{
|
50 |
+
return strpos($value, '/') !== false;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Test if a value is within a range
|
55 |
+
*
|
56 |
+
* @param string $dateValue Set date value
|
57 |
+
* @param string $value Value to test
|
58 |
+
*
|
59 |
+
* @return bool
|
60 |
+
*/
|
61 |
+
public function isInRange($dateValue, $value)
|
62 |
+
{
|
63 |
+
$parts = array_map('trim', explode('-', $value, 2));
|
64 |
+
|
65 |
+
return $dateValue >= $parts[0] && $dateValue <= $parts[1];
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Test if a value is within an increments of ranges (offset[-to]/step size)
|
70 |
+
*
|
71 |
+
* @param string $dateValue Set date value
|
72 |
+
* @param string $value Value to test
|
73 |
+
*
|
74 |
+
* @return bool
|
75 |
+
*/
|
76 |
+
public function isInIncrementsOfRanges($dateValue, $value)
|
77 |
+
{
|
78 |
+
$parts = array_map('trim', explode('/', $value, 2));
|
79 |
+
$stepSize = isset($parts[1]) ? $parts[1] : 0;
|
80 |
+
if ($parts[0] == '*' || $parts[0] === '0') {
|
81 |
+
return (int) $dateValue % $stepSize == 0;
|
82 |
+
}
|
83 |
+
|
84 |
+
$range = explode('-', $parts[0], 2);
|
85 |
+
$offset = $range[0];
|
86 |
+
$to = isset($range[1]) ? $range[1] : $dateValue;
|
87 |
+
// Ensure that the date value is within the range
|
88 |
+
if ($dateValue < $offset || $dateValue > $to) {
|
89 |
+
return false;
|
90 |
+
}
|
91 |
+
|
92 |
+
for ($i = $offset; $i <= $to; $i+= $stepSize) {
|
93 |
+
if ($i == $dateValue) {
|
94 |
+
return true;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
return false;
|
99 |
+
}
|
100 |
+
}
|
trunk/includes/lib/action-scheduler/lib/cron-expression/CronExpression_DayOfMonthField.php
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Day of month field. Allows: * , / - ? L W
|
5 |
+
*
|
6 |
+
* 'L' stands for "last" and specifies the last day of the month.
|
7 |
+
*
|
8 |
+
* The 'W' character is used to specify the weekday (Monday-Friday) nearest the
|
9 |
+
* given day. As an example, if you were to specify "15W" as the value for the
|
10 |
+
* day-of-month field, the meaning is: "the nearest weekday to the 15th of the
|
11 |
+
* month". So if the 15th is a Saturday, the trigger will fire on Friday the
|
12 |
+
* 14th. If the 15th is a Sunday, the trigger will fire on Monday the 16th. If
|
13 |
+
* the 15th is a Tuesday, then it will fire on Tuesday the 15th. However if you
|
14 |
+
* specify "1W" as the value for day-of-month, and the 1st is a Saturday, the
|
15 |
+
* trigger will fire on Monday the 3rd, as it will not 'jump' over the boundary
|
16 |
+
* of a month's days. The 'W' character can only be specified when the
|
17 |
+
* day-of-month is a single day, not a range or list of days.
|
18 |
+
*
|
19 |
+
* @author Michael Dowling <mtdowling@gmail.com>
|
20 |
+
*/
|
21 |
+
class CronExpression_DayOfMonthField extends CronExpression_AbstractField
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* Get the nearest day of the week for a given day in a month
|
25 |
+
*
|
26 |
+
* @param int $currentYear Current year
|
27 |
+
* @param int $currentMonth Current month
|
28 |
+
* @param int $targetDay Target day of the month
|
29 |
+
*
|
30 |
+
* @return DateTime Returns the nearest date
|
31 |
+
*/
|
32 |
+
private static function getNearestWeekday($currentYear, $currentMonth, $targetDay)
|
33 |
+
{
|
34 |
+
$tday = str_pad($targetDay, 2, '0', STR_PAD_LEFT);
|
35 |
+
$target = new DateTime("$currentYear-$currentMonth-$tday");
|
36 |
+
$currentWeekday = (int) $target->format('N');
|
37 |
+
|
38 |
+
if ($currentWeekday < 6) {
|
39 |
+
return $target;
|
40 |
+
}
|
41 |
+
|
42 |
+
$lastDayOfMonth = $target->format('t');
|
43 |
+
|
44 |
+
foreach (array(-1, 1, -2, 2) as $i) {
|
45 |
+
$adjusted = $targetDay + $i;
|
46 |
+
if ($adjusted > 0 && $adjusted <= $lastDayOfMonth) {
|
47 |
+
$target->setDate($currentYear, $currentMonth, $adjusted);
|
48 |
+
if ($target->format('N') < 6 && $target->format('m') == $currentMonth) {
|
49 |
+
return $target;
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* {@inheritdoc}
|
57 |
+
*/
|
58 |
+
public function isSatisfiedBy(DateTime $date, $value)
|
59 |
+
{
|
60 |
+
// ? states that the field value is to be skipped
|
61 |
+
if ($value == '?') {
|
62 |
+
return true;
|
63 |
+
}
|
64 |
+
|
65 |
+
$fieldValue = $date->format('d');
|
66 |
+
|
67 |
+
// Check to see if this is the last day of the month
|
68 |
+
if ($value == 'L') {
|
69 |
+
return $fieldValue == $date->format('t');
|
70 |
+
}
|
71 |
+
|
72 |
+
// Check to see if this is the nearest weekday to a particular value
|
73 |
+
if (strpos($value, 'W')) {
|
74 |
+
// Parse the target day
|
75 |
+
$targetDay = substr($value, 0, strpos($value, 'W'));
|
76 |
+
// Find out if the current day is the nearest day of the week
|
77 |
+
return $date->format('j') == self::getNearestWeekday(
|
78 |
+
$date->format('Y'),
|
79 |
+
$date->format('m'),
|
80 |
+
$targetDay
|
81 |
+
)->format('j');
|
82 |
+
}
|
83 |
+
|
84 |
+
return $this->isSatisfied($date->format('d'), $value);
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* {@inheritdoc}
|
89 |
+
*/
|
90 |
+
public function increment(DateTime $date, $invert = false)
|
91 |
+
{
|
92 |
+
if ($invert) {
|
93 |
+
$date->modify('previous day');
|
94 |
+
$date->setTime(23, 59);
|
95 |
+
} else {
|
96 |
+
$date->modify('next day');
|
97 |
+
$date->setTime(0, 0);
|
98 |
+
}
|
99 |
+
|
100 |
+
return $this;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* {@inheritdoc}
|
105 |
+
*/
|
106 |
+
public function validate($value)
|
107 |
+
{
|
108 |
+
return (bool) preg_match('/[\*,\/\-\?LW0-9A-Za-z]+/', $value);
|
109 |
+
}
|
110 |
+
}
|
trunk/includes/lib/action-scheduler/lib/cron-expression/CronExpression_DayOfWeekField.php
ADDED
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Day of week field. Allows: * / , - ? L #
|
5 |
+
*
|
6 |
+
* Days of the week can be represented as a number 0-7 (0|7 = Sunday)
|
7 |
+
* or as a three letter string: SUN, MON, TUE, WED, THU, FRI, SAT.
|
8 |
+
*
|
9 |
+
* 'L' stands for "last". It allows you to specify constructs such as
|
10 |
+
* "the last Friday" of a given month.
|
11 |
+
*
|
12 |
+
* '#' is allowed for the day-of-week field, and must be followed by a
|
13 |
+
* number between one and five. It allows you to specify constructs such as
|
14 |
+
* "the second Friday" of a given month.
|
15 |
+
*
|
16 |
+
* @author Michael Dowling <mtdowling@gmail.com>
|
17 |
+
*/
|
18 |
+
class CronExpression_DayOfWeekField extends CronExpression_AbstractField
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* {@inheritdoc}
|
22 |
+
*/
|
23 |
+
public function isSatisfiedBy(DateTime $date, $value)
|
24 |
+
{
|
25 |
+
if ($value == '?') {
|
26 |
+
return true;
|
27 |
+
}
|
28 |
+
|
29 |
+
// Convert text day of the week values to integers
|
30 |
+
$value = str_ireplace(
|
31 |
+
array('SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'),
|
32 |
+
range(0, 6),
|
33 |
+
$value
|
34 |
+
);
|
35 |
+
|
36 |
+
$currentYear = $date->format('Y');
|
37 |
+
$currentMonth = $date->format('m');
|
38 |
+
$lastDayOfMonth = $date->format('t');
|
39 |
+
|
40 |
+
// Find out if this is the last specific weekday of the month
|
41 |
+
if (strpos($value, 'L')) {
|
42 |
+
$weekday = str_replace('7', '0', substr($value, 0, strpos($value, 'L')));
|
43 |
+
$tdate = clone $date;
|
44 |
+
$tdate->setDate($currentYear, $currentMonth, $lastDayOfMonth);
|
45 |
+
while ($tdate->format('w') != $weekday) {
|
46 |
+
$tdate->setDate($currentYear, $currentMonth, --$lastDayOfMonth);
|
47 |
+
}
|
48 |
+
|
49 |
+
return $date->format('j') == $lastDayOfMonth;
|
50 |
+
}
|
51 |
+
|
52 |
+
// Handle # hash tokens
|
53 |
+
if (strpos($value, '#')) {
|
54 |
+
list($weekday, $nth) = explode('#', $value);
|
55 |
+
// Validate the hash fields
|
56 |
+
if ($weekday < 1 || $weekday > 5) {
|
57 |
+
throw new InvalidArgumentException("Weekday must be a value between 1 and 5. {$weekday} given");
|
58 |
+
}
|
59 |
+
if ($nth > 5) {
|
60 |
+
throw new InvalidArgumentException('There are never more than 5 of a given weekday in a month');
|
61 |
+
}
|
62 |
+
// The current weekday must match the targeted weekday to proceed
|
63 |
+
if ($date->format('N') != $weekday) {
|
64 |
+
return false;
|
65 |
+
}
|
66 |
+
|
67 |
+
$tdate = clone $date;
|
68 |
+
$tdate->setDate($currentYear, $currentMonth, 1);
|
69 |
+
$dayCount = 0;
|
70 |
+
$currentDay = 1;
|
71 |
+
while ($currentDay < $lastDayOfMonth + 1) {
|
72 |
+
if ($tdate->format('N') == $weekday) {
|
73 |
+
if (++$dayCount >= $nth) {
|
74 |
+
break;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
$tdate->setDate($currentYear, $currentMonth, ++$currentDay);
|
78 |
+
}
|
79 |
+
|
80 |
+
return $date->format('j') == $currentDay;
|
81 |
+
}
|
82 |
+
|
83 |
+
// Handle day of the week values
|
84 |
+
if (strpos($value, '-')) {
|
85 |
+
$parts = explode('-', $value);
|
86 |
+
if ($parts[0] == '7') {
|
87 |
+
$parts[0] = '0';
|
88 |
+
} elseif ($parts[1] == '0') {
|
89 |
+
$parts[1] = '7';
|
90 |
+
}
|
91 |
+
$value = implode('-', $parts);
|
92 |
+
}
|
93 |
+
|
94 |
+
// Test to see which Sunday to use -- 0 == 7 == Sunday
|
95 |
+
$format = in_array(7, str_split($value)) ? 'N' : 'w';
|
96 |
+
$fieldValue = $date->format($format);
|
97 |
+
|
98 |
+
return $this->isSatisfied($fieldValue, $value);
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* {@inheritdoc}
|
103 |
+
*/
|
104 |
+
public function increment(DateTime $date, $invert = false)
|
105 |
+
{
|
106 |
+
if ($invert) {
|
107 |
+
$date->modify('-1 day');
|
108 |
+
$date->setTime(23, 59, 0);
|
109 |
+
} else {
|
110 |
+
$date->modify('+1 day');
|
111 |
+
$date->setTime(0, 0, 0);
|
112 |
+
}
|
113 |
+
|
114 |
+
return $this;
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* {@inheritdoc}
|
119 |
+
*/
|
120 |
+
public function validate($value)
|
121 |
+
{
|
122 |
+
return (bool) preg_match('/[\*,\/\-0-9A-Z]+/', $value);
|
123 |
+
}
|
124 |
+
}
|
trunk/includes/lib/action-scheduler/lib/cron-expression/CronExpression_FieldFactory.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* CRON field factory implementing a flyweight factory
|
5 |
+
*
|
6 |
+
* @author Michael Dowling <mtdowling@gmail.com>
|
7 |
+
* @link http://en.wikipedia.org/wiki/Cron
|
8 |
+
*/
|
9 |
+
class CronExpression_FieldFactory
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* @var array Cache of instantiated fields
|
13 |
+
*/
|
14 |
+
private $fields = array();
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Get an instance of a field object for a cron expression position
|
18 |
+
*
|
19 |
+
* @param int $position CRON expression position value to retrieve
|
20 |
+
*
|
21 |
+
* @return CronExpression_FieldInterface
|
22 |
+
* @throws InvalidArgumentException if a position is not valid
|
23 |
+
*/
|
24 |
+
public function getField($position)
|
25 |
+
{
|
26 |
+
if (!isset($this->fields[$position])) {
|
27 |
+
switch ($position) {
|
28 |
+
case 0:
|
29 |
+
$this->fields[$position] = new CronExpression_MinutesField();
|
30 |
+
break;
|
31 |
+
case 1:
|
32 |
+
$this->fields[$position] = new CronExpression_HoursField();
|
33 |
+
break;
|
34 |
+
case 2:
|
35 |
+
$this->fields[$position] = new CronExpression_DayOfMonthField();
|
36 |
+
break;
|
37 |
+
case 3:
|
38 |
+
$this->fields[$position] = new CronExpression_MonthField();
|
39 |
+
break;
|
40 |
+
case 4:
|
41 |
+
$this->fields[$position] = new CronExpression_DayOfWeekField();
|
42 |
+
break;
|
43 |
+
case 5:
|
44 |
+
$this->fields[$position] = new CronExpression_YearField();
|
45 |
+
break;
|
46 |
+
default:
|
47 |
+
throw new InvalidArgumentException(
|
48 |
+
$position . ' is not a valid position'
|
49 |
+
);
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
return $this->fields[$position];
|
54 |
+
}
|
55 |
+
}
|
trunk/includes/lib/action-scheduler/lib/cron-expression/CronExpression_FieldInterface.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* CRON field interface
|
5 |
+
*
|
6 |
+
* @author Michael Dowling <mtdowling@gmail.com>
|
7 |
+
*/
|
8 |
+
interface CronExpression_FieldInterface
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Check if the respective value of a DateTime field satisfies a CRON exp
|
12 |
+
*
|
13 |
+
* @param DateTime $date DateTime object to check
|
14 |
+
* @param string $value CRON expression to test against
|
15 |
+
*
|
16 |
+
* @return bool Returns TRUE if satisfied, FALSE otherwise
|
17 |
+
*/
|
18 |
+
public function isSatisfiedBy(DateTime $date, $value);
|
19 |
+
|
20 |
+
/**
|
21 |
+
* When a CRON expression is not satisfied, this method is used to increment
|
22 |
+
* or decrement a DateTime object by the unit of the cron field
|
23 |
+
*
|
24 |
+
* @param DateTime $date DateTime object to change
|
25 |
+
* @param bool $invert (optional) Set to TRUE to decrement
|
26 |
+
*
|
27 |
+
* @return CronExpression_FieldInterface
|
28 |
+
*/
|
29 |
+
public function increment(DateTime $date, $invert = false);
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Validates a CRON expression for a given field
|
33 |
+
*
|
34 |
+
* @param string $value CRON expression value to validate
|
35 |
+
*
|
36 |
+
* @return bool Returns TRUE if valid, FALSE otherwise
|
37 |
+
*/
|
38 |
+
public function validate($value);
|
39 |
+
}
|
trunk/includes/lib/action-scheduler/lib/cron-expression/CronExpression_HoursField.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Hours field. Allows: * , / -
|
5 |
+
*
|
6 |
+
* @author Michael Dowling <mtdowling@gmail.com>
|
7 |
+
*/
|
8 |
+
class CronExpression_HoursField extends CronExpression_AbstractField
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* {@inheritdoc}
|
12 |
+
*/
|
13 |
+
public function isSatisfiedBy(DateTime $date, $value)
|
14 |
+
{
|
15 |
+
return $this->isSatisfied($date->format('H'), $value);
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* {@inheritdoc}
|
20 |
+
*/
|
21 |
+
public function increment(DateTime $date, $invert = false)
|
22 |
+
{
|
23 |
+
// Change timezone to UTC temporarily. This will
|
24 |
+
// allow us to go back or forwards and hour even
|
25 |
+
// if DST will be changed between the hours.
|
26 |
+
$timezone = $date->getTimezone();
|
27 |
+
$date->setTimezone(new DateTimeZone('UTC'));
|
28 |
+
if ($invert) {
|
29 |
+
$date->modify('-1 hour');
|
30 |
+
$date->setTime($date->format('H'), 59);
|
31 |
+
} else {
|
32 |
+
$date->modify('+1 hour');
|
33 |
+
$date->setTime($date->format('H'), 0);
|
34 |
+
}
|
35 |
+
$date->setTimezone($timezone);
|
36 |
+
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* {@inheritdoc}
|
42 |
+
*/
|
43 |
+
public function validate($value)
|
44 |
+
{
|
45 |
+
return (bool) preg_match('/[\*,\/\-0-9]+/', $value);
|
46 |
+
}
|
47 |
+
}
|
trunk/includes/lib/action-scheduler/lib/cron-expression/CronExpression_MinutesField.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Minutes field. Allows: * , / -
|
5 |
+
*
|
6 |
+
* @author Michael Dowling <mtdowling@gmail.com>
|
7 |
+
*/
|
8 |
+
class CronExpression_MinutesField extends CronExpression_AbstractField
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* {@inheritdoc}
|
12 |
+
*/
|
13 |
+
public function isSatisfiedBy(DateTime $date, $value)
|
14 |
+
{
|
15 |
+
return $this->isSatisfied($date->format('i'), $value);
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* {@inheritdoc}
|
20 |
+
*/
|
21 |
+
public function increment(DateTime $date, $invert = false)
|
22 |
+
{
|
23 |
+
if ($invert) {
|
24 |
+
$date->modify('-1 minute');
|
25 |
+
} else {
|
26 |
+
$date->modify('+1 minute');
|
27 |
+
}
|
28 |
+
|
29 |
+
return $this;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* {@inheritdoc}
|
34 |
+
*/
|
35 |
+
public function validate($value)
|
36 |
+
{
|
37 |
+
return (bool) preg_match('/[\*,\/\-0-9]+/', $value);
|
38 |
+
}
|
39 |
+
}
|
trunk/includes/lib/action-scheduler/lib/cron-expression/CronExpression_MonthField.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Month field. Allows: * , / -
|
5 |
+
*
|
6 |
+
* @author Michael Dowling <mtdowling@gmail.com>
|
7 |
+
*/
|
8 |
+
class CronExpression_MonthField extends CronExpression_AbstractField
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* {@inheritdoc}
|
12 |
+
*/
|
13 |
+
public function isSatisfiedBy(DateTime $date, $value)
|
14 |
+
{
|
15 |
+
// Convert text month values to integers
|
16 |
+
$value = str_ireplace(
|
17 |
+
array(
|
18 |
+
'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN',
|
19 |
+
'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'
|
20 |
+
),
|
21 |
+
range(1, 12),
|
22 |
+
$value
|
23 |
+
);
|
24 |
+
|
25 |
+
return $this->isSatisfied($date->format('m'), $value);
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* {@inheritdoc}
|
30 |
+
*/
|
31 |
+
public function increment(DateTime $date, $invert = false)
|
32 |
+
{
|
33 |
+
if ($invert) {
|
34 |
+
// $date->modify('last day of previous month'); // remove for php 5.2 compat
|
35 |
+
$date->modify('previous month');
|
36 |
+
$date->modify($date->format('Y-m-t'));
|
37 |
+
$date->setTime(23, 59);
|
38 |
+
} else {
|
39 |
+
//$date->modify('first day of next month'); // remove for php 5.2 compat
|
40 |
+
$date->modify('next month');
|
41 |
+
$date->modify($date->format('Y-m-01'));
|
42 |
+
$date->setTime(0, 0);
|
43 |
+
}
|
44 |
+
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* {@inheritdoc}
|
50 |
+
*/
|
51 |
+
public function validate($value)
|
52 |
+
{
|
53 |
+
return (bool) preg_match('/[\*,\/\-0-9A-Z]+/', $value);
|
54 |
+
}
|
55 |
+
}
|
trunk/includes/lib/action-scheduler/lib/cron-expression/CronExpression_YearField.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Year field. Allows: * , / -
|
5 |
+
*
|
6 |
+
* @author Michael Dowling <mtdowling@gmail.com>
|
7 |
+
*/
|
8 |
+
class CronExpression_YearField extends CronExpression_AbstractField
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* {@inheritdoc}
|
12 |
+
*/
|
13 |
+
public function isSatisfiedBy(DateTime $date, $value)
|
14 |
+
{
|
15 |
+
return $this->isSatisfied($date->format('Y'), $value);
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* {@inheritdoc}
|
20 |
+
*/
|
21 |
+
public function increment(DateTime $date, $invert = false)
|
22 |
+
{
|
23 |
+
if ($invert) {
|
24 |
+
$date->modify('-1 year');
|
25 |
+
$date->setDate($date->format('Y'), 12, 31);
|
26 |
+
$date->setTime(23, 59, 0);
|
27 |
+
} else {
|
28 |
+
$date->modify('+1 year');
|
29 |
+
$date->setDate($date->format('Y'), 1, 1);
|
30 |
+
$date->setTime(0, 0, 0);
|
31 |
+
}
|
32 |
+
|
33 |
+
return $this;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* {@inheritdoc}
|
38 |
+
*/
|
39 |
+
public function validate($value)
|
40 |
+
{
|
41 |
+
return (bool) preg_match('/[\*,\/\-0-9]+/', $value);
|
42 |
+
}
|
43 |
+
}
|
trunk/includes/lib/action-scheduler/lib/cron-expression/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Copyright (c) 2011 Michael Dowling <mtdowling@gmail.com> and contributors
|
2 |
+
|
3 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
+
of this software and associated documentation files (the "Software"), to deal
|
5 |
+
in the Software without restriction, including without limitation the rights
|
6 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7 |
+
copies of the Software, and to permit persons to whom the Software is
|
8 |
+
furnished to do so, subject to the following conditions:
|
9 |
+
|
10 |
+
The above copyright notice and this permission notice shall be included in
|
11 |
+
all copies or substantial portions of the Software.
|
12 |
+
|
13 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19 |
+
THE SOFTWARE.
|
trunk/includes/lib/action-scheduler/lib/cron-expression/README.md
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
PHP Cron Expression Parser
|
2 |
+
==========================
|
3 |
+
|
4 |
+
[![Latest Stable Version](https://poser.pugx.org/mtdowling/cron-expression/v/stable.png)](https://packagist.org/packages/mtdowling/cron-expression) [![Total Downloads](https://poser.pugx.org/mtdowling/cron-expression/downloads.png)](https://packagist.org/packages/mtdowling/cron-expression) [![Build Status](https://secure.travis-ci.org/mtdowling/cron-expression.png)](http://travis-ci.org/mtdowling/cron-expression)
|
5 |
+
|
6 |
+
The PHP cron expression parser can parse a CRON expression, determine if it is
|
7 |
+
due to run, calculate the next run date of the expression, and calculate the previous
|
8 |
+
run date of the expression. You can calculate dates far into the future or past by
|
9 |
+
skipping n number of matching dates.
|
10 |
+
|
11 |
+
The parser can handle increments of ranges (e.g. */12, 2-59/3), intervals (e.g. 0-9),
|
12 |
+
lists (e.g. 1,2,3), W to find the nearest weekday for a given day of the month, L to
|
13 |
+
find the last day of the month, L to find the last given weekday of a month, and hash
|
14 |
+
(#) to find the nth weekday of a given month.
|
15 |
+
|
16 |
+
Credits
|
17 |
+
==========
|
18 |
+
|
19 |
+
Created by Micheal Dowling. Ported to PHP 5.2 by Flightless, Inc.
|
20 |
+
Based on version 1.0.3: https://github.com/mtdowling/cron-expression/tree/v1.0.3
|
21 |
+
|
22 |
+
Installing
|
23 |
+
==========
|
24 |
+
|
25 |
+
Add the following to your project's composer.json:
|
26 |
+
|
27 |
+
```javascript
|
28 |
+
{
|
29 |
+
"require": {
|
30 |
+
"mtdowling/cron-expression": "1.0.*"
|
31 |
+
}
|
32 |
+
}
|
33 |
+
```
|
34 |
+
|
35 |
+
Usage
|
36 |
+
=====
|
37 |
+
```php
|
38 |
+
<?php
|
39 |
+
|
40 |
+
require_once '/vendor/autoload.php';
|
41 |
+
|
42 |
+
// Works with predefined scheduling definitions
|
43 |
+
$cron = Cron\CronExpression::factory('@daily');
|
44 |
+
$cron->isDue();
|
45 |
+
echo $cron->getNextRunDate()->format('Y-m-d H:i:s');
|
46 |
+
echo $cron->getPreviousRunDate()->format('Y-m-d H:i:s');
|
47 |
+
|
48 |
+
// Works with complex expressions
|
49 |
+
$cron = Cron\CronExpression::factory('3-59/15 2,6-12 */15 1 2-5');
|
50 |
+
echo $cron->getNextRunDate()->format('Y-m-d H:i:s');
|
51 |
+
|
52 |
+
// Calculate a run date two iterations into the future
|
53 |
+
$cron = Cron\CronExpression::factory('@daily');
|
54 |
+
echo $cron->getNextRunDate(null, 2)->format('Y-m-d H:i:s');
|
55 |
+
|
56 |
+
// Calculate a run date relative to a specific time
|
57 |
+
$cron = Cron\CronExpression::factory('@monthly');
|
58 |
+
echo $cron->getNextRunDate('2010-01-12 00:00:00')->format('Y-m-d H:i:s');
|
59 |
+
```
|
60 |
+
|
61 |
+
CRON Expressions
|
62 |
+
================
|
63 |
+
|
64 |
+
A CRON expression is a string representing the schedule for a particular command to execute. The parts of a CRON schedule are as follows:
|
65 |
+
|
66 |
+
* * * * * *
|
67 |
+
- - - - - -
|
68 |
+
| | | | | |
|
69 |
+
| | | | | + year [optional]
|
70 |
+
| | | | +----- day of week (0 - 7) (Sunday=0 or 7)
|
71 |
+
| | | +---------- month (1 - 12)
|
72 |
+
| | +--------------- day of month (1 - 31)
|
73 |
+
| +-------------------- hour (0 - 23)
|
74 |
+
+------------------------- min (0 - 59)
|
75 |
+
|
76 |
+
Requirements
|
77 |
+
============
|
78 |
+
|
79 |
+
- PHP 5.3+
|
80 |
+
- PHPUnit is required to run the unit tests
|
81 |
+
- Composer is required to run the unit tests
|
82 |
+
|
83 |
+
CHANGELOG
|
84 |
+
=========
|
85 |
+
|
86 |
+
1.0.3 (2013-11-23)
|
87 |
+
------------------
|
88 |
+
|
89 |
+
* Only set default timezone if the given $currentTime is not a DateTime instance (#34)
|
90 |
+
* Fixes issue #28 where PHP increments of ranges were failing due to PHP casting hyphens to 0
|
91 |
+
* Now supports expressions with any number of extra spaces, tabs, or newlines
|
92 |
+
* Using static instead of self in `CronExpression::factory`
|
trunk/includes/lib/action-scheduler/license.txt
ADDED
@@ -0,0 +1,674 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 3, 29 June 2007
|
3 |
+
|
4 |
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5 |
+
Everyone is permitted to copy and distribute verbatim copies
|
6 |
+
of this license document, but changing it is not allowed.
|
7 |
+
|
8 |
+
Preamble
|
9 |
+
|
10 |
+
The GNU General Public License is a free, copyleft license for
|
11 |
+
software and other kinds of works.
|
12 |
+
|
13 |
+
The licenses for most software and other practical works are designed
|
14 |
+
to take away your freedom to share and change the works. By contrast,
|
15 |
+
the GNU General Public License is intended to guarantee your freedom to
|
16 |
+
share and change all versions of a program--to make sure it remains free
|
17 |
+
software for all its users. We, the Free Software Foundation, use the
|
18 |
+
GNU General Public License for most of our software; it applies also to
|
19 |
+
any other work released this way by its authors. You can apply it to
|
20 |
+
your programs, too.
|
21 |
+
|
22 |
+
When we speak of free software, we are referring to freedom, not
|
23 |
+
price. Our General Public Licenses are designed to make sure that you
|
24 |
+
have the freedom to distribute copies of free software (and charge for
|
25 |
+
them if you wish), that you receive source code or can get it if you
|
26 |
+
want it, that you can change the software or use pieces of it in new
|
27 |
+
free programs, and that you know you can do these things.
|
28 |
+
|
29 |
+
To protect your rights, we need to prevent others from denying you
|
30 |
+
these rights or asking you to surrender the rights. Therefore, you have
|
31 |
+
certain responsibilities if you distribute copies of the software, or if
|
32 |
+
you modify it: responsibilities to respect the freedom of others.
|
33 |
+
|
34 |
+
For example, if you distribute copies of such a program, whether
|
35 |
+
gratis or for a fee, you must pass on to the recipients the same
|
36 |
+
freedoms that you received. You must make sure that they, too, receive
|
37 |
+
or can get the source code. And you must show them these terms so they
|
38 |
+
know their rights.
|
39 |
+
|
40 |
+
Developers that use the GNU GPL protect your rights with two steps:
|
41 |
+
(1) assert copyright on the software, and (2) offer you this License
|
42 |
+
giving you legal permission to copy, distribute and/or modify it.
|
43 |
+
|
44 |
+
For the developers' and authors' protection, the GPL clearly explains
|
45 |
+
that there is no warranty for this free software. For both users' and
|
46 |
+
authors' sake, the GPL requires that modified versions be marked as
|
47 |
+
changed, so that their problems will not be attributed erroneously to
|
48 |
+
authors of previous versions.
|
49 |
+
|
50 |
+
Some devices are designed to deny users access to install or run
|
51 |
+
modified versions of the software inside them, although the manufacturer
|
52 |
+
can do so. This is fundamentally incompatible with the aim of
|
53 |
+
protecting users' freedom to change the software. The systematic
|
54 |
+
pattern of such abuse occurs in the area of products for individuals to
|
55 |
+
use, which is precisely where it is most unacceptable. Therefore, we
|
56 |
+
have designed this version of the GPL to prohibit the practice for those
|
57 |
+
products. If such problems arise substantially in other domains, we
|
58 |
+
stand ready to extend this provision to those domains in future versions
|
59 |
+
of the GPL, as needed to protect the freedom of users.
|
60 |
+
|
61 |
+
Finally, every program is threatened constantly by software patents.
|
62 |
+
States should not allow patents to restrict development and use of
|
63 |
+
software on general-purpose computers, but in those that do, we wish to
|
64 |
+
avoid the special danger that patents applied to a free program could
|
65 |
+
make it effectively proprietary. To prevent this, the GPL assures that
|
66 |
+
patents cannot be used to render the program non-free.
|
67 |
+
|
68 |
+
The precise terms and conditions for copying, distribution and
|
69 |
+
modification follow.
|
70 |
+
|
71 |
+
TERMS AND CONDITIONS
|
72 |
+
|
73 |
+
0. Definitions.
|
74 |
+
|
75 |
+
"This License" refers to version 3 of the GNU General Public License.
|
76 |
+
|
77 |
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
78 |
+
works, such as semiconductor masks.
|
79 |
+
|
80 |
+
"The Program" refers to any copyrightable work licensed under this
|
81 |
+
License. Each licensee is addressed as "you". "Licensees" and
|
82 |
+
"recipients" may be individuals or organizations.
|
83 |
+
|
84 |
+
To "modify" a work means to copy from or adapt all or part of the work
|
85 |
+
in a fashion requiring copyright permission, other than the making of an
|
86 |
+
exact copy. The resulting work is called a "modified version" of the
|
87 |
+
earlier work or a work "based on" the earlier work.
|
88 |
+
|
89 |
+
A "covered work" means either the unmodified Program or a work based
|
90 |
+
on the Program.
|
91 |
+
|
92 |
+
To "propagate" a work means to do anything with it that, without
|
93 |
+
permission, would make you directly or secondarily liable for
|
94 |
+
infringement under applicable copyright law, except executing it on a
|
95 |
+
computer or modifying a private copy. Propagation includes copying,
|
96 |
+
distribution (with or without modification), making available to the
|
97 |
+
public, and in some countries other activities as well.
|
98 |
+
|
99 |
+
To "convey" a work means any kind of propagation that enables other
|
100 |
+
parties to make or receive copies. Mere interaction with a user through
|
101 |
+
a computer network, with no transfer of a copy, is not conveying.
|
102 |
+
|
103 |
+
An interactive user interface displays "Appropriate Legal Notices"
|
104 |
+
to the extent that it includes a convenient and prominently visible
|
105 |
+
feature that (1) displays an appropriate copyright notice, and (2)
|
106 |
+
tells the user that there is no warranty for the work (except to the
|
107 |
+
extent that warranties are provided), that licensees may convey the
|
108 |
+
work under this License, and how to view a copy of this License. If
|
109 |
+
the interface presents a list of user commands or options, such as a
|
110 |
+
menu, a prominent item in the list meets this criterion.
|
111 |
+
|
112 |
+
1. Source Code.
|
113 |
+
|
114 |
+
The "source code" for a work means the preferred form of the work
|
115 |
+
for making modifications to it. "Object code" means any non-source
|
116 |
+
form of a work.
|
117 |
+
|
118 |
+
A "Standard Interface" means an interface that either is an official
|
119 |
+
standard defined by a recognized standards body, or, in the case of
|
120 |
+
interfaces specified for a particular programming language, one that
|
121 |
+
is widely used among developers working in that language.
|
122 |
+
|
123 |
+
The "System Libraries" of an executable work include anything, other
|
124 |
+
than the work as a whole, that (a) is included in the normal form of
|
125 |
+
packaging a Major Component, but which is not part of that Major
|
126 |
+
Component, and (b) serves only to enable use of the work with that
|
127 |
+
Major Component, or to implement a Standard Interface for which an
|
128 |
+
implementation is available to the public in source code form. A
|
129 |
+
"Major Component", in this context, means a major essential component
|
130 |
+
(kernel, window system, and so on) of the specific operating system
|
131 |
+
(if any) on which the executable work runs, or a compiler used to
|
132 |
+
produce the work, or an object code interpreter used to run it.
|
133 |
+
|
134 |
+
The "Corresponding Source" for a work in object code form means all
|
135 |
+
the source code needed to generate, install, and (for an executable
|
136 |
+
work) run the object code and to modify the work, including scripts to
|
137 |
+
control those activities. However, it does not include the work's
|
138 |
+
System Libraries, or general-purpose tools or generally available free
|
139 |
+
programs which are used unmodified in performing those activities but
|
140 |
+
which are not part of the work. For example, Corresponding Source
|
141 |
+
includes interface definition files associated with source files for
|
142 |
+
the work, and the source code for shared libraries and dynamically
|
143 |
+
linked subprograms that the work is specifically designed to require,
|
144 |
+
such as by intimate data communication or control flow between those
|
145 |
+
subprograms and other parts of the work.
|
146 |
+
|
147 |
+
The Corresponding Source need not include anything that users
|
148 |
+
can regenerate automatically from other parts of the Corresponding
|
149 |
+
Source.
|
150 |
+
|
151 |
+
The Corresponding Source for a work in source code form is that
|
152 |
+
same work.
|
153 |
+
|
154 |
+
2. Basic Permissions.
|
155 |
+
|
156 |
+
All rights granted under this License are granted for the term of
|
157 |
+
copyright on the Program, and are irrevocable provided the stated
|
158 |
+
conditions are met. This License explicitly affirms your unlimited
|
159 |
+
permission to run the unmodified Program. The output from running a
|
160 |
+
covered work is covered by this License only if the output, given its
|
161 |
+
content, constitutes a covered work. This License acknowledges your
|
162 |
+
rights of fair use or other equivalent, as provided by copyright law.
|
163 |
+
|
164 |
+
You may make, run and propagate covered works that you do not
|
165 |
+
convey, without conditions so long as your license otherwise remains
|
166 |
+
in force. You may convey covered works to others for the sole purpose
|
167 |
+
of having them make modifications exclusively for you, or provide you
|
168 |
+
with facilities for running those works, provided that you comply with
|
169 |
+
the terms of this License in conveying all material for which you do
|
170 |
+
not control copyright. Those thus making or running the covered works
|
171 |
+
for you must do so exclusively on your behalf, under your direction
|
172 |
+
and control, on terms that prohibit them from making any copies of
|
173 |
+
your copyrighted material outside their relationship with you.
|
174 |
+
|
175 |
+
Conveying under any other circumstances is permitted solely under
|
176 |
+
the conditions stated below. Sublicensing is not allowed; section 10
|
177 |
+
makes it unnecessary.
|
178 |
+
|
179 |
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
180 |
+
|
181 |
+
No covered work shall be deemed part of an effective technological
|
182 |
+
measure under any applicable law fulfilling obligations under article
|
183 |
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
184 |
+
similar laws prohibiting or restricting circumvention of such
|
185 |
+
measures.
|
186 |
+
|
187 |
+
When you convey a covered work, you waive any legal power to forbid
|
188 |
+
circumvention of technological measures to the extent such circumvention
|
189 |
+
is effected by exercising rights under this License with respect to
|
190 |
+
the covered work, and you disclaim any intention to limit operation or
|
191 |
+
modification of the work as a means of enforcing, against the work's
|
192 |
+
users, your or third parties' legal rights to forbid circumvention of
|
193 |
+
technological measures.
|
194 |
+
|
195 |
+
4. Conveying Verbatim Copies.
|
196 |
+
|
197 |
+
You may convey verbatim copies of the Program's source code as you
|
198 |
+
receive it, in any medium, provided that you conspicuously and
|
199 |
+
appropriately publish on each copy an appropriate copyright notice;
|
200 |
+
keep intact all notices stating that this License and any
|
201 |
+
non-permissive terms added in accord with section 7 apply to the code;
|
202 |
+
keep intact all notices of the absence of any warranty; and give all
|
203 |
+
recipients a copy of this License along with the Program.
|
204 |
+
|
205 |
+
You may charge any price or no price for each copy that you convey,
|
206 |
+
and you may offer support or warranty protection for a fee.
|
207 |
+
|
208 |
+
5. Conveying Modified Source Versions.
|
209 |
+
|
210 |
+
You may convey a work based on the Program, or the modifications to
|
211 |
+
produce it from the Program, in the form of source code under the
|
212 |
+
terms of section 4, provided that you also meet all of these conditions:
|
213 |
+
|
214 |
+
a) The work must carry prominent notices stating that you modified
|
215 |
+
it, and giving a relevant date.
|
216 |
+
|
217 |
+
b) The work must carry prominent notices stating that it is
|
218 |
+
released under this License and any conditions added under section
|
219 |
+
7. This requirement modifies the requirement in section 4 to
|
220 |
+
"keep intact all notices".
|
221 |
+
|
222 |
+
c) You must license the entire work, as a whole, under this
|
223 |
+
License to anyone who comes into possession of a copy. This
|
224 |
+
License will therefore apply, along with any applicable section 7
|
225 |
+
additional terms, to the whole of the work, and all its parts,
|
226 |
+
regardless of how they are packaged. This License gives no
|
227 |
+
permission to license the work in any other way, but it does not
|
228 |
+
invalidate such permission if you have separately received it.
|
229 |
+
|
230 |
+
d) If the work has interactive user interfaces, each must display
|
231 |
+
Appropriate Legal Notices; however, if the Program has interactive
|
232 |
+
interfaces that do not display Appropriate Legal Notices, your
|
233 |
+
work need not make them do so.
|
234 |
+
|
235 |
+
A compilation of a covered work with other separate and independent
|
236 |
+
works, which are not by their nature extensions of the covered work,
|
237 |
+
and which are not combined with it such as to form a larger program,
|
238 |
+
in or on a volume of a storage or distribution medium, is called an
|
239 |
+
"aggregate" if the compilation and its resulting copyright are not
|
240 |
+
used to limit the access or legal rights of the compilation's users
|
241 |
+
beyond what the individual works permit. Inclusion of a covered work
|
242 |
+
in an aggregate does not cause this License to apply to the other
|
243 |
+
parts of the aggregate.
|
244 |
+
|
245 |
+
6. Conveying Non-Source Forms.
|
246 |
+
|
247 |
+
You may convey a covered work in object code form under the terms
|
248 |
+
of sections 4 and 5, provided that you also convey the
|
249 |
+
machine-readable Corresponding Source under the terms of this License,
|
250 |
+
in one of these ways:
|
251 |
+
|
252 |
+
a) Convey the object code in, or embodied in, a physical product
|
253 |
+
(including a physical distribution medium), accompanied by the
|
254 |
+
Corresponding Source fixed on a durable physical medium
|
255 |
+
customarily used for software interchange.
|
256 |
+
|
257 |
+
b) Convey the object code in, or embodied in, a physical product
|
258 |
+
(including a physical distribution medium), accompanied by a
|
259 |
+
written offer, valid for at least three years and valid for as
|
260 |
+
long as you offer spare parts or customer support for that product
|
261 |
+
model, to give anyone who possesses the object code either (1) a
|
262 |
+
copy of the Corresponding Source for all the software in the
|
263 |
+
product that is covered by this License, on a durable physical
|
264 |
+
medium customarily used for software interchange, for a price no
|
265 |
+
more than your reasonable cost of physically performing this
|
266 |
+
conveying of source, or (2) access to copy the
|
267 |
+
Corresponding Source from a network server at no charge.
|
268 |
+
|
269 |
+
c) Convey individual copies of the object code with a copy of the
|
270 |
+
written offer to provide the Corresponding Source. This
|
271 |
+
alternative is allowed only occasionally and noncommercially, and
|
272 |
+
only if you received the object code with such an offer, in accord
|
273 |
+
with subsection 6b.
|
274 |
+
|
275 |
+
d) Convey the object code by offering access from a designated
|
276 |
+
place (gratis or for a charge), and offer equivalent access to the
|
277 |
+
Corresponding Source in the same way through the same place at no
|
278 |
+
further charge. You need not require recipients to copy the
|
279 |
+
Corresponding Source along with the object code. If the place to
|
280 |
+
copy the object code is a network server, the Corresponding Source
|
281 |
+
may be on a different server (operated by you or a third party)
|
282 |
+
that supports equivalent copying facilities, provided you maintain
|
283 |
+
clear directions next to the object code saying where to find the
|
284 |
+
Corresponding Source. Regardless of what server hosts the
|
285 |
+
Corresponding Source, you remain obligated to ensure that it is
|
286 |
+
available for as long as needed to satisfy these requirements.
|
287 |
+
|
288 |
+
e) Convey the object code using peer-to-peer transmission, provided
|
289 |
+
you inform other peers where the object code and Corresponding
|
290 |
+
Source of the work are being offered to the general public at no
|
291 |
+
charge under subsection 6d.
|
292 |
+
|
293 |
+
A separable portion of the object code, whose source code is excluded
|
294 |
+
from the Corresponding Source as a System Library, need not be
|
295 |
+
included in conveying the object code work.
|
296 |
+
|
297 |
+
A "User Product" is either (1) a "consumer product", which means any
|
298 |
+
tangible personal property which is normally used for personal, family,
|
299 |
+
or household purposes, or (2) anything designed or sold for incorporation
|
300 |
+
into a dwelling. In determining whether a product is a consumer product,
|
301 |
+
doubtful cases shall be resolved in favor of coverage. For a particular
|
302 |
+
product received by a particular user, "normally used" refers to a
|
303 |
+
typical or common use of that class of product, regardless of the status
|
304 |
+
of the particular user or of the way in which the particular user
|
305 |
+
actually uses, or expects or is expected to use, the product. A product
|
306 |
+
is a consumer product regardless of whether the product has substantial
|
307 |
+
commercial, industrial or non-consumer uses, unless such uses represent
|
308 |
+
the only significant mode of use of the product.
|
309 |
+
|
310 |
+
"Installation Information" for a User Product means any methods,
|
311 |
+
procedures, authorization keys, or other information required to install
|
312 |
+
and execute modified versions of a covered work in that User Product from
|
313 |
+
a modified version of its Corresponding Source. The information must
|
314 |
+
suffice to ensure that the continued functioning of the modified object
|
315 |
+
code is in no case prevented or interfered with solely because
|
316 |
+
modification has been made.
|
317 |
+
|
318 |
+
If you convey an object code work under this section in, or with, or
|
319 |
+
specifically for use in, a User Product, and the conveying occurs as
|
320 |
+
part of a transaction in which the right of possession and use of the
|
321 |
+
User Product is transferred to the recipient in perpetuity or for a
|
322 |
+
fixed term (regardless of how the transaction is characterized), the
|
323 |
+
Corresponding Source conveyed under this section must be accompanied
|
324 |
+
by the Installation Information. But this requirement does not apply
|
325 |
+
if neither you nor any third party retains the ability to install
|
326 |
+
modified object code on the User Product (for example, the work has
|
327 |
+
been installed in ROM).
|
328 |
+
|
329 |
+
The requirement to provide Installation Information does not include a
|
330 |
+
requirement to continue to provide support service, warranty, or updates
|
331 |
+
for a work that has been modified or installed by the recipient, or for
|
332 |
+
the User Product in which it has been modified or installed. Access to a
|
333 |
+
network may be denied when the modification itself materially and
|
334 |
+
adversely affects the operation of the network or violates the rules and
|
335 |
+
protocols for communication across the network.
|
336 |
+
|
337 |
+
Corresponding Source conveyed, and Installation Information provided,
|
338 |
+
in accord with this section must be in a format that is publicly
|
339 |
+
documented (and with an implementation available to the public in
|
340 |
+
source code form), and must require no special password or key for
|
341 |
+
unpacking, reading or copying.
|
342 |
+
|
343 |
+
7. Additional Terms.
|
344 |
+
|
345 |
+
"Additional permissions" are terms that supplement the terms of this
|
346 |
+
License by making exceptions from one or more of its conditions.
|
347 |
+
Additional permissions that are applicable to the entire Program shall
|
348 |
+
be treated as though they were included in this License, to the extent
|
349 |
+
that they are valid under applicable law. If additional permissions
|
350 |
+
apply only to part of the Program, that part may be used separately
|
351 |
+
under those permissions, but the entire Program remains governed by
|
352 |
+
this License without regard to the additional permissions.
|
353 |
+
|
354 |
+
When you convey a copy of a covered work, you may at your option
|
355 |
+
remove any additional permissions from that copy, or from any part of
|
356 |
+
it. (Additional permissions may be written to require their own
|
357 |
+
removal in certain cases when you modify the work.) You may place
|
358 |
+
additional permissions on material, added by you to a covered work,
|
359 |
+
for which you have or can give appropriate copyright permission.
|
360 |
+
|
361 |
+
Notwithstanding any other provision of this License, for material you
|
362 |
+
add to a covered work, you may (if authorized by the copyright holders of
|
363 |
+
that material) supplement the terms of this License with terms:
|
364 |
+
|
365 |
+
a) Disclaiming warranty or limiting liability differently from the
|
366 |
+
terms of sections 15 and 16 of this License; or
|
367 |
+
|
368 |
+
b) Requiring preservation of specified reasonable legal notices or
|
369 |
+
author attributions in that material or in the Appropriate Legal
|
370 |
+
Notices displayed by works containing it; or
|
371 |
+
|
372 |
+
c) Prohibiting misrepresentation of the origin of that material, or
|
373 |
+
requiring that modified versions of such material be marked in
|
374 |
+
reasonable ways as different from the original version; or
|
375 |
+
|
376 |
+
d) Limiting the use for publicity purposes of names of licensors or
|
377 |
+
authors of the material; or
|
378 |
+
|
379 |
+
e) Declining to grant rights under trademark law for use of some
|
380 |
+
trade names, trademarks, or service marks; or
|
381 |
+
|
382 |
+
f) Requiring indemnification of licensors and authors of that
|
383 |
+
material by anyone who conveys the material (or modified versions of
|
384 |
+
it) with contractual assumptions of liability to the recipient, for
|
385 |
+
any liability that these contractual assumptions directly impose on
|
386 |
+
those licensors and authors.
|
387 |
+
|
388 |
+
All other non-permissive additional terms are considered "further
|
389 |
+
restrictions" within the meaning of section 10. If the Program as you
|
390 |
+
received it, or any part of it, contains a notice stating that it is
|
391 |
+
governed by this License along with a term that is a further
|
392 |
+
restriction, you may remove that term. If a license document contains
|
393 |
+
a further restriction but permits relicensing or conveying under this
|
394 |
+
License, you may add to a covered work material governed by the terms
|
395 |
+
of that license document, provided that the further restriction does
|
396 |
+
not survive such relicensing or conveying.
|
397 |
+
|
398 |
+
If you add terms to a covered work in accord with this section, you
|
399 |
+
must place, in the relevant source files, a statement of the
|
400 |
+
additional terms that apply to those files, or a notice indicating
|
401 |
+
where to find the applicable terms.
|
402 |
+
|
403 |
+
Additional terms, permissive or non-permissive, may be stated in the
|
404 |
+
form of a separately written license, or stated as exceptions;
|
405 |
+
the above requirements apply either way.
|
406 |
+
|
407 |
+
8. Termination.
|
408 |
+
|
409 |
+
You may not propagate or modify a covered work except as expressly
|
410 |
+
provided under this License. Any attempt otherwise to propagate or
|
411 |
+
modify it is void, and will automatically terminate your rights under
|
412 |
+
this License (including any patent licenses granted under the third
|
413 |
+
paragraph of section 11).
|
414 |
+
|
415 |
+
However, if you cease all violation of this License, then your
|
416 |
+
license from a particular copyright holder is reinstated (a)
|
417 |
+
provisionally, unless and until the copyright holder explicitly and
|
418 |
+
finally terminates your license, and (b) permanently, if the copyright
|
419 |
+
holder fails to notify you of the violation by some reasonable means
|
420 |
+
prior to 60 days after the cessation.
|
421 |
+
|
422 |
+
Moreover, your license from a particular copyright holder is
|
423 |
+
reinstated permanently if the copyright holder notifies you of the
|
424 |
+
violation by some reasonable means, this is the first time you have
|
425 |
+
received notice of violation of this License (for any work) from that
|
426 |
+
copyright holder, and you cure the violation prior to 30 days after
|
427 |
+
your receipt of the notice.
|
428 |
+
|
429 |
+
Termination of your rights under this section does not terminate the
|
430 |
+
licenses of parties who have received copies or rights from you under
|
431 |
+
this License. If your rights have been terminated and not permanently
|
432 |
+
reinstated, you do not qualify to receive new licenses for the same
|
433 |
+
material under section 10.
|
434 |
+
|
435 |
+
9. Acceptance Not Required for Having Copies.
|
436 |
+
|
437 |
+
You are not required to accept this License in order to receive or
|
438 |
+
run a copy of the Program. Ancillary propagation of a covered work
|
439 |
+
occurring solely as a consequence of using peer-to-peer transmission
|
440 |
+
to receive a copy likewise does not require acceptance. However,
|
441 |
+
nothing other than this License grants you permission to propagate or
|
442 |
+
modify any covered work. These actions infringe copyright if you do
|
443 |
+
not accept this License. Therefore, by modifying or propagating a
|
444 |
+
covered work, you indicate your acceptance of this License to do so.
|
445 |
+
|
446 |
+
10. Automatic Licensing of Downstream Recipients.
|
447 |
+
|
448 |
+
Each time you convey a covered work, the recipient automatically
|
449 |
+
receives a license from the original licensors, to run, modify and
|
450 |
+
propagate that work, subject to this License. You are not responsible
|
451 |
+
for enforcing compliance by third parties with this License.
|
452 |
+
|
453 |
+
An "entity transaction" is a transaction transferring control of an
|
454 |
+
organization, or substantially all assets of one, or subdividing an
|
455 |
+
organization, or merging organizations. If propagation of a covered
|
456 |
+
work results from an entity transaction, each party to that
|
457 |
+
transaction who receives a copy of the work also receives whatever
|
458 |
+
licenses to the work the party's predecessor in interest had or could
|
459 |
+
give under the previous paragraph, plus a right to possession of the
|
460 |
+
Corresponding Source of the work from the predecessor in interest, if
|
461 |
+
the predecessor has it or can get it with reasonable efforts.
|
462 |
+
|
463 |
+
You may not impose any further restrictions on the exercise of the
|
464 |
+
rights granted or affirmed under this License. For example, you may
|
465 |
+
not impose a license fee, royalty, or other charge for exercise of
|
466 |
+
rights granted under this License, and you may not initiate litigation
|
467 |
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
468 |
+
any patent claim is infringed by making, using, selling, offering for
|
469 |
+
sale, or importing the Program or any portion of it.
|
470 |
+
|
471 |
+
11. Patents.
|
472 |
+
|
473 |
+
A "contributor" is a copyright holder who authorizes use under this
|
474 |
+
License of the Program or a work on which the Program is based. The
|
475 |
+
work thus licensed is called the contributor's "contributor version".
|
476 |
+
|
477 |
+
A contributor's "essential patent claims" are all patent claims
|
478 |
+
owned or controlled by the contributor, whether already acquired or
|
479 |
+
hereafter acquired, that would be infringed by some manner, permitted
|
480 |
+
by this License, of making, using, or selling its contributor version,
|
481 |
+
but do not include claims that would be infringed only as a
|
482 |
+
consequence of further modification of the contributor version. For
|
483 |
+
purposes of this definition, "control" includes the right to grant
|
484 |
+
patent sublicenses in a manner consistent with the requirements of
|
485 |
+
this License.
|
486 |
+
|
487 |
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
488 |
+
patent license under the contributor's essential patent claims, to
|
489 |
+
make, use, sell, offer for sale, import and otherwise run, modify and
|
490 |
+
propagate the contents of its contributor version.
|
491 |
+
|
492 |
+
In the following three paragraphs, a "patent license" is any express
|
493 |
+
agreement or commitment, however denominated, not to enforce a patent
|
494 |
+
(such as an express permission to practice a patent or covenant not to
|
495 |
+
sue for patent infringement). To "grant" such a patent license to a
|
496 |
+
party means to make such an agreement or commitment not to enforce a
|
497 |
+
patent against the party.
|
498 |
+
|
499 |
+
If you convey a covered work, knowingly relying on a patent license,
|
500 |
+
and the Corresponding Source of the work is not available for anyone
|
501 |
+
to copy, free of charge and under the terms of this License, through a
|
502 |
+
publicly available network server or other readily accessible means,
|
503 |
+
then you must either (1) cause the Corresponding Source to be so
|
504 |
+
available, or (2) arrange to deprive yourself of the benefit of the
|
505 |
+
patent license for this particular work, or (3) arrange, in a manner
|
506 |
+
consistent with the requirements of this License, to extend the patent
|
507 |
+
license to downstream recipients. "Knowingly relying" means you have
|
508 |
+
actual knowledge that, but for the patent license, your conveying the
|
509 |
+
covered work in a country, or your recipient's use of the covered work
|
510 |
+
in a country, would infringe one or more identifiable patents in that
|
511 |
+
country that you have reason to believe are valid.
|
512 |
+
|
513 |
+
If, pursuant to or in connection with a single transaction or
|
514 |
+
arrangement, you convey, or propagate by procuring conveyance of, a
|
515 |
+
covered work, and grant a patent license to some of the parties
|
516 |
+
receiving the covered work authorizing them to use, propagate, modify
|
517 |
+
or convey a specific copy of the covered work, then the patent license
|
518 |
+
you grant is automatically extended to all recipients of the covered
|
519 |
+
work and works based on it.
|
520 |
+
|
521 |
+
A patent license is "discriminatory" if it does not include within
|
522 |
+
the scope of its coverage, prohibits the exercise of, or is
|
523 |
+
conditioned on the non-exercise of one or more of the rights that are
|
524 |
+
specifically granted under this License. You may not convey a covered
|
525 |
+
work if you are a party to an arrangement with a third party that is
|
526 |
+
in the business of distributing software, under which you make payment
|
527 |
+
to the third party based on the extent of your activity of conveying
|
528 |
+
the work, and under which the third party grants, to any of the
|
529 |
+
parties who would receive the covered work from you, a discriminatory
|
530 |
+
patent license (a) in connection with copies of the covered work
|
531 |
+
conveyed by you (or copies made from those copies), or (b) primarily
|
532 |
+
for and in connection with specific products or compilations that
|
533 |
+
contain the covered work, unless you entered into that arrangement,
|
534 |
+
or that patent license was granted, prior to 28 March 2007.
|
535 |
+
|
536 |
+
Nothing in this License shall be construed as excluding or limiting
|
537 |
+
any implied license or other defenses to infringement that may
|
538 |
+
otherwise be available to you under applicable patent law.
|
539 |
+
|
540 |
+
12. No Surrender of Others' Freedom.
|
541 |
+
|
542 |
+
If conditions are imposed on you (whether by court order, agreement or
|
543 |
+
otherwise) that contradict the conditions of this License, they do not
|
544 |
+
excuse you from the conditions of this License. If you cannot convey a
|
545 |
+
covered work so as to satisfy simultaneously your obligations under this
|
546 |
+
License and any other pertinent obligations, then as a consequence you may
|
547 |
+
not convey it at all. For example, if you agree to terms that obligate you
|
548 |
+
to collect a royalty for further conveying from those to whom you convey
|
549 |
+
the Program, the only way you could satisfy both those terms and this
|
550 |
+
License would be to refrain entirely from conveying the Program.
|
551 |
+
|
552 |
+
13. Use with the GNU Affero General Public License.
|
553 |
+
|
554 |
+
Notwithstanding any other provision of this License, you have
|
555 |
+
permission to link or combine any covered work with a work licensed
|
556 |
+
under version 3 of the GNU Affero General Public License into a single
|
557 |
+
combined work, and to convey the resulting work. The terms of this
|
558 |
+
License will continue to apply to the part which is the covered work,
|
559 |
+
but the special requirements of the GNU Affero General Public License,
|
560 |
+
section 13, concerning interaction through a network will apply to the
|
561 |
+
combination as such.
|
562 |
+
|
563 |
+
14. Revised Versions of this License.
|
564 |
+
|
565 |
+
The Free Software Foundation may publish revised and/or new versions of
|
566 |
+
the GNU General Public License from time to time. Such new versions will
|
567 |
+
be similar in spirit to the present version, but may differ in detail to
|
568 |
+
address new problems or concerns.
|
569 |
+
|
570 |
+
Each version is given a distinguishing version number. If the
|
571 |
+
Program specifies that a certain numbered version of the GNU General
|
572 |
+
Public License "or any later version" applies to it, you have the
|
573 |
+
option of following the terms and conditions either of that numbered
|
574 |
+
version or of any later version published by the Free Software
|
575 |
+
Foundation. If the Program does not specify a version number of the
|
576 |
+
GNU General Public License, you may choose any version ever published
|
577 |
+
by the Free Software Foundation.
|
578 |
+
|
579 |
+
If the Program specifies that a proxy can decide which future
|
580 |
+
versions of the GNU General Public License can be used, that proxy's
|
581 |
+
public statement of acceptance of a version permanently authorizes you
|
582 |
+
to choose that version for the Program.
|
583 |
+
|
584 |
+
Later license versions may give you additional or different
|
585 |
+
permissions. However, no additional obligations are imposed on any
|
586 |
+
author or copyright holder as a result of your choosing to follow a
|
587 |
+
later version.
|
588 |
+
|
589 |
+
15. Disclaimer of Warranty.
|
590 |
+
|
591 |
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
592 |
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
593 |
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
594 |
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
595 |
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
596 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
597 |
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
598 |
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
599 |
+
|
600 |
+
16. Limitation of Liability.
|
601 |
+
|
602 |
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
603 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
604 |
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
605 |
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
606 |
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
607 |
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
608 |
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
609 |
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
610 |
+
SUCH DAMAGES.
|
611 |
+
|
612 |
+
17. Interpretation of Sections 15 and 16.
|
613 |
+
|
614 |
+
If the disclaimer of warranty and limitation of liability provided
|
615 |
+
above cannot be given local legal effect according to their terms,
|
616 |
+
reviewing courts shall apply local law that most closely approximates
|
617 |
+
an absolute waiver of all civil liability in connection with the
|
618 |
+
Program, unless a warranty or assumption of liability accompanies a
|
619 |
+
copy of the Program in return for a fee.
|
620 |
+
|
621 |
+
END OF TERMS AND CONDITIONS
|
622 |
+
|
623 |
+
How to Apply These Terms to Your New Programs
|
624 |
+
|
625 |
+
If you develop a new program, and you want it to be of the greatest
|
626 |
+
possible use to the public, the best way to achieve this is to make it
|
627 |
+
free software which everyone can redistribute and change under these terms.
|
628 |
+
|
629 |
+
To do so, attach the following notices to the program. It is safest
|
630 |
+
to attach them to the start of each source file to most effectively
|
631 |
+
state the exclusion of warranty; and each file should have at least
|
632 |
+
the "copyright" line and a pointer to where the full notice is found.
|
633 |
+
|
634 |
+
<one line to give the program's name and a brief idea of what it does.>
|
635 |
+
Copyright (C) <year> <name of author>
|
636 |
+
|
637 |
+
This program is free software: you can redistribute it and/or modify
|
638 |
+
it under the terms of the GNU General Public License as published by
|
639 |
+
the Free Software Foundation, either version 3 of the License, or
|
640 |
+
(at your option) any later version.
|
641 |
+
|
642 |
+
This program is distributed in the hope that it will be useful,
|
643 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
644 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
645 |
+
GNU General Public License for more details.
|
646 |
+
|
647 |
+
You should have received a copy of the GNU General Public License
|
648 |
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
649 |
+
|
650 |
+
Also add information on how to contact you by electronic and paper mail.
|
651 |
+
|
652 |
+
If the program does terminal interaction, make it output a short
|
653 |
+
notice like this when it starts in an interactive mode:
|
654 |
+
|
655 |
+
<program> Copyright (C) <year> <name of author>
|
656 |
+
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
657 |
+
This is free software, and you are welcome to redistribute it
|
658 |
+
under certain conditions; type `show c' for details.
|
659 |
+
|
660 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
661 |
+
parts of the General Public License. Of course, your program's commands
|
662 |
+
might be different; for a GUI interface, you would use an "about box".
|
663 |
+
|
664 |
+
You should also get your employer (if you work as a programmer) or school,
|
665 |
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
666 |
+
For more information on this, and how to apply and follow the GNU GPL, see
|
667 |
+
<http://www.gnu.org/licenses/>.
|
668 |
+
|
669 |
+
The GNU General Public License does not permit incorporating your program
|
670 |
+
into proprietary programs. If your program is a subroutine library, you
|
671 |
+
may consider it more useful to permit linking proprietary applications with
|
672 |
+
the library. If this is what you want to do, use the GNU Lesser General
|
673 |
+
Public License instead of this License. But first, please read
|
674 |
+
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
trunk/includes/lib/action-scheduler/tests/ActionScheduler_UnitTestCase.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_UnitTestCase
|
5 |
+
*/
|
6 |
+
class ActionScheduler_UnitTestCase extends WP_UnitTestCase {
|
7 |
+
|
8 |
+
protected $existing_timezone;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Counts the number of test cases executed by run(TestResult result).
|
12 |
+
*
|
13 |
+
* @return int
|
14 |
+
*/
|
15 |
+
public function count() {
|
16 |
+
return 'UTC' == date_default_timezone_get() ? 2 : 3;
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* We want to run every test multiple times using a different timezone to make sure
|
21 |
+
* that they are unaffected by changes to PHP's timezone.
|
22 |
+
*/
|
23 |
+
public function run( PHPUnit\Framework\TestResult $result = NULL ){
|
24 |
+
|
25 |
+
if ($result === NULL) {
|
26 |
+
$result = $this->createResult();
|
27 |
+
}
|
28 |
+
|
29 |
+
if ( 'UTC' != ( $this->existing_timezone = date_default_timezone_get() ) ) {
|
30 |
+
date_default_timezone_set( 'UTC' );
|
31 |
+
$result->run( $this );
|
32 |
+
}
|
33 |
+
|
34 |
+
date_default_timezone_set( 'Pacific/Fiji' ); // UTC+12
|
35 |
+
$result->run( $this );
|
36 |
+
|
37 |
+
date_default_timezone_set( 'Pacific/Tahiti' ); // UTC-10: it's a magical place
|
38 |
+
$result->run( $this );
|
39 |
+
|
40 |
+
date_default_timezone_set( $this->existing_timezone );
|
41 |
+
|
42 |
+
return $result;
|
43 |
+
}
|
44 |
+
}
|
trunk/includes/lib/action-scheduler/tests/bootstrap.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$GLOBALS['wp_tests_options'][ 'template' ] = 'twentyseventeen';
|
4 |
+
$GLOBALS['wp_tests_options'][ 'stylesheet' ] = 'twentyseventeen';
|
5 |
+
$GLOBALS['wp_tests_options'][ 'active_plugins' ][] = basename( dirname( __DIR__ ) ) .'/action-scheduler.php';
|
6 |
+
|
7 |
+
// Check for select constants defined as environment variables
|
8 |
+
foreach ( array('WP_CONTENT_DIR', 'WP_CONTENT_URL', 'WP_PLUGIN_DIR', 'WP_PLUGIN_URL', 'WPMU_PLUGIN_DIR') as $env_constant ) {
|
9 |
+
if ( false !== getenv( $env_constant ) && !defined( $env_constant ) ) {
|
10 |
+
define( $env_constant, getenv( $env_constant ));
|
11 |
+
}
|
12 |
+
}
|
13 |
+
|
14 |
+
// If the wordpress-tests repo location has been customized (and specified
|
15 |
+
// with WP_TESTS_DIR), use that location. This will most commonly be the case
|
16 |
+
// when configured for use with Travis CI.
|
17 |
+
|
18 |
+
// Otherwise, we'll just assume that this plugin is installed in the WordPress
|
19 |
+
// SVN external checkout configured in the wordpress-tests repo.
|
20 |
+
|
21 |
+
if( false !== getenv( 'WP_TESTS_DIR' ) ) {
|
22 |
+
require getenv( 'WP_TESTS_DIR' ) . '/includes/bootstrap.php';
|
23 |
+
} else {
|
24 |
+
require dirname( dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ) ) . '/tests/phpunit/includes/bootstrap.php';
|
25 |
+
}
|
26 |
+
|
27 |
+
if ( class_exists( 'PHPUnit\Framework\TestResult' ) ) { // PHPUnit 6.0 or newer
|
28 |
+
include_once('ActionScheduler_UnitTestCase.php');
|
29 |
+
} else {
|
30 |
+
include_once('phpunit/deprecated/ActionScheduler_UnitTestCase.php');
|
31 |
+
}
|
trunk/includes/lib/action-scheduler/tests/phpunit.xml.dist
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
|
3 |
+
<phpunit backupGlobals="false"
|
4 |
+
backupStaticAttributes="false"
|
5 |
+
colors="true"
|
6 |
+
convertErrorsToExceptions="true"
|
7 |
+
convertNoticesToExceptions="true"
|
8 |
+
convertWarningsToExceptions="true"
|
9 |
+
processIsolation="false"
|
10 |
+
stopOnFailure="false"
|
11 |
+
syntaxCheck="false"
|
12 |
+
bootstrap="bootstrap.php"
|
13 |
+
>
|
14 |
+
<testsuites>
|
15 |
+
<testsuite name="Action Scheduler">
|
16 |
+
<directory>./phpunit</directory>
|
17 |
+
</testsuite>
|
18 |
+
</testsuites>
|
19 |
+
<groups>
|
20 |
+
<exclude>
|
21 |
+
<group>ignore</group>
|
22 |
+
</exclude>
|
23 |
+
</groups>
|
24 |
+
<filter>
|
25 |
+
<whitelist processsUncoveredFilesFromWhitelist="true">
|
26 |
+
<directory suffix=".php">..</directory>
|
27 |
+
<exclude>
|
28 |
+
<directory>.</directory>
|
29 |
+
</exclude>
|
30 |
+
</whitelist>
|
31 |
+
</filter>
|
32 |
+
</phpunit>
|
trunk/includes/lib/action-scheduler/tests/phpunit/deprecated/ActionScheduler_UnitTestCase.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_UnitTestCase
|
5 |
+
*/
|
6 |
+
class ActionScheduler_UnitTestCase extends WP_UnitTestCase {
|
7 |
+
|
8 |
+
protected $existing_timezone;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Counts the number of test cases executed by run(TestResult result).
|
12 |
+
*
|
13 |
+
* @return int
|
14 |
+
*/
|
15 |
+
public function count() {
|
16 |
+
return 'UTC' == date_default_timezone_get() ? 2 : 3;
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* We want to run every test multiple times using a different timezone to make sure
|
21 |
+
* that they are unaffected by changes to PHP's timezone.
|
22 |
+
*/
|
23 |
+
public function run( PHPUnit_Framework_TestResult $result = NULL ){
|
24 |
+
|
25 |
+
if ($result === NULL) {
|
26 |
+
$result = $this->createResult();
|
27 |
+
}
|
28 |
+
|
29 |
+
if ( 'UTC' != ( $this->existing_timezone = date_default_timezone_get() ) ) {
|
30 |
+
date_default_timezone_set( 'UTC' );
|
31 |
+
$result->run( $this );
|
32 |
+
}
|
33 |
+
|
34 |
+
date_default_timezone_set( 'Pacific/Fiji' ); // UTC+12
|
35 |
+
$result->run( $this );
|
36 |
+
|
37 |
+
date_default_timezone_set( 'Pacific/Tahiti' ); // UTC-10: it's a magical place
|
38 |
+
$result->run( $this );
|
39 |
+
|
40 |
+
date_default_timezone_set( $this->existing_timezone );
|
41 |
+
|
42 |
+
return $result;
|
43 |
+
}
|
44 |
+
}
|
trunk/includes/lib/action-scheduler/tests/phpunit/helpers/ActionScheduler_TimezoneHelper_Test.php
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @group timezone
|
5 |
+
*/
|
6 |
+
class ActionScheduler_TimezoneHelper_Test extends ActionScheduler_UnitTestCase {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Ensure that the timezone string we expect works properly.
|
10 |
+
*
|
11 |
+
* @dataProvider local_timezone_provider
|
12 |
+
*
|
13 |
+
* @param $timezone_string
|
14 |
+
*/
|
15 |
+
public function test_local_timezone_strings( $timezone_string ) {
|
16 |
+
$timezone_filter = function ( $tz ) use ( $timezone_string ) {
|
17 |
+
return $timezone_string;
|
18 |
+
};
|
19 |
+
|
20 |
+
add_filter( 'option_timezone_string', $timezone_filter );
|
21 |
+
|
22 |
+
$date = new ActionScheduler_DateTime();
|
23 |
+
$timezone = ActionScheduler_TimezoneHelper::set_local_timezone( $date )->getTimezone();
|
24 |
+
$this->assertInstanceOf( 'DateTimeZone', $timezone );
|
25 |
+
$this->assertEquals( $timezone_string, $timezone->getName() );
|
26 |
+
|
27 |
+
remove_filter( 'option_timezone_string', $timezone_filter );
|
28 |
+
}
|
29 |
+
|
30 |
+
public function local_timezone_provider() {
|
31 |
+
return array(
|
32 |
+
array( 'America/New_York' ),
|
33 |
+
array( 'Australia/Melbourne' ),
|
34 |
+
array( 'UTC' ),
|
35 |
+
);
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Ensure that most GMT offsets don't return UTC as the timezone.
|
40 |
+
*
|
41 |
+
* @dataProvider local_timezone_offsets_provider
|
42 |
+
*
|
43 |
+
* @param $gmt_offset
|
44 |
+
*/
|
45 |
+
public function test_local_timezone_offsets( $gmt_offset ) {
|
46 |
+
$gmt_filter = function ( $gmt ) use ( $gmt_offset ) {
|
47 |
+
return $gmt_offset;
|
48 |
+
};
|
49 |
+
|
50 |
+
$date = new ActionScheduler_DateTime();
|
51 |
+
|
52 |
+
add_filter( 'option_gmt_offset', $gmt_filter );
|
53 |
+
ActionScheduler_TimezoneHelper::set_local_timezone( $date );
|
54 |
+
remove_filter( 'option_gmt_offset', $gmt_filter );
|
55 |
+
|
56 |
+
$offset_in_seconds = $gmt_offset * HOUR_IN_SECONDS;
|
57 |
+
|
58 |
+
$this->assertEquals( $offset_in_seconds, $date->getOffset() );
|
59 |
+
$this->assertEquals( $offset_in_seconds, $date->getOffsetTimestamp() - $date->getTimestamp() );
|
60 |
+
}
|
61 |
+
|
62 |
+
public function local_timezone_offsets_provider() {
|
63 |
+
return array(
|
64 |
+
array( '-11' ),
|
65 |
+
array( '-10.5' ),
|
66 |
+
array( '-10' ),
|
67 |
+
array( '-9' ),
|
68 |
+
array( '-8' ),
|
69 |
+
array( '-7' ),
|
70 |
+
array( '-6' ),
|
71 |
+
array( '-5' ),
|
72 |
+
array( '-4.5' ),
|
73 |
+
array( '-4' ),
|
74 |
+
array( '-3.5' ),
|
75 |
+
array( '-3' ),
|
76 |
+
array( '-2' ),
|
77 |
+
array( '-1' ),
|
78 |
+
array( '1' ),
|
79 |
+
array( '1.5' ),
|
80 |
+
array( '2' ),
|
81 |
+
array( '3' ),
|
82 |
+
array( '4' ),
|
83 |
+
array( '5' ),
|
84 |
+
array( '5.5' ),
|
85 |
+
array( '5.75' ),
|
86 |
+
array( '6' ),
|
87 |
+
array( '7' ),
|
88 |
+
array( '8' ),
|
89 |
+
array( '8.5' ),
|
90 |
+
array( '9' ),
|
91 |
+
array( '9.5' ),
|
92 |
+
array( '10' ),
|
93 |
+
array( '10.5' ),
|
94 |
+
array( '11' ),
|
95 |
+
array( '11.5' ),
|
96 |
+
array( '12' ),
|
97 |
+
array( '13' ),
|
98 |
+
);
|
99 |
+
}
|
100 |
+
}
|
trunk/includes/lib/action-scheduler/tests/phpunit/jobs/ActionScheduler_Action_Test.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_Action_Test
|
5 |
+
* @group actions
|
6 |
+
*/
|
7 |
+
class ActionScheduler_Action_Test extends ActionScheduler_UnitTestCase {
|
8 |
+
public function test_set_schedule() {
|
9 |
+
$time = as_get_datetime_object();
|
10 |
+
$schedule = new ActionScheduler_SimpleSchedule($time);
|
11 |
+
$action = new ActionScheduler_Action('my_hook', array(), $schedule);
|
12 |
+
$this->assertEquals( $schedule, $action->get_schedule() );
|
13 |
+
}
|
14 |
+
|
15 |
+
public function test_null_schedule() {
|
16 |
+
$action = new ActionScheduler_Action('my_hook');
|
17 |
+
$this->assertInstanceOf( 'ActionScheduler_NullSchedule', $action->get_schedule() );
|
18 |
+
}
|
19 |
+
|
20 |
+
public function test_set_hook() {
|
21 |
+
$action = new ActionScheduler_Action('my_hook');
|
22 |
+
$this->assertEquals( 'my_hook', $action->get_hook() );
|
23 |
+
}
|
24 |
+
|
25 |
+
public function test_args() {
|
26 |
+
$action = new ActionScheduler_Action('my_hook');
|
27 |
+
$this->assertEmpty($action->get_args());
|
28 |
+
|
29 |
+
$action = new ActionScheduler_Action('my_hook', array(5,10,15));
|
30 |
+
$this->assertEqualSets(array(5,10,15), $action->get_args());
|
31 |
+
}
|
32 |
+
|
33 |
+
public function test_set_group() {
|
34 |
+
$action = new ActionScheduler_Action('my_hook', array(), NULL, 'my_group');
|
35 |
+
$this->assertEquals('my_group', $action->get_group());
|
36 |
+
}
|
37 |
+
|
38 |
+
public function test_execute() {
|
39 |
+
$mock = new MockAction();
|
40 |
+
|
41 |
+
$random = md5(rand());
|
42 |
+
add_action( $random, array( $mock, 'action' ) );
|
43 |
+
|
44 |
+
$action = new ActionScheduler_Action( $random, array($random) );
|
45 |
+
$action->execute();
|
46 |
+
|
47 |
+
remove_action( $random, array( $mock, 'action' ) );
|
48 |
+
|
49 |
+
$this->assertEquals( 1, $mock->get_call_count() );
|
50 |
+
$events = $mock->get_events();
|
51 |
+
$event = reset($events);
|
52 |
+
$this->assertEquals( $random, reset($event['args']) );
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
trunk/includes/lib/action-scheduler/tests/phpunit/jobs/ActionScheduler_NullAction_Test.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_NullAction_Test
|
5 |
+
* @group actions
|
6 |
+
*/
|
7 |
+
class ActionScheduler_NullAction_Test extends ActionScheduler_UnitTestCase {
|
8 |
+
public function test_null_action() {
|
9 |
+
$action = new ActionScheduler_NullAction();
|
10 |
+
|
11 |
+
$this->assertEmpty($action->get_hook());
|
12 |
+
$this->assertEmpty($action->get_args());
|
13 |
+
$this->assertNull($action->get_schedule()->next());
|
14 |
+
}
|
15 |
+
}
|
16 |
+
|
trunk/includes/lib/action-scheduler/tests/phpunit/jobstore/ActionScheduler_wpPostStore_Test.php
ADDED
@@ -0,0 +1,375 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_wpPostStore_Test
|
5 |
+
* @group stores
|
6 |
+
*/
|
7 |
+
class ActionScheduler_wpPostStore_Test extends ActionScheduler_UnitTestCase {
|
8 |
+
|
9 |
+
public function test_create_action() {
|
10 |
+
$time = as_get_datetime_object();
|
11 |
+
$schedule = new ActionScheduler_SimpleSchedule($time);
|
12 |
+
$action = new ActionScheduler_Action('my_hook', array(), $schedule);
|
13 |
+
$store = new ActionScheduler_wpPostStore();
|
14 |
+
$action_id = $store->save_action($action);
|
15 |
+
|
16 |
+
$this->assertNotEmpty($action_id);
|
17 |
+
}
|
18 |
+
|
19 |
+
public function test_create_action_with_scheduled_date() {
|
20 |
+
$time = as_get_datetime_object( strtotime( '-1 week' ) );
|
21 |
+
$action = new ActionScheduler_Action( 'my_hook', array(), new ActionScheduler_SimpleSchedule( $time ) );
|
22 |
+
$store = new ActionScheduler_wpPostStore();
|
23 |
+
|
24 |
+
$action_id = $store->save_action( $action, $time );
|
25 |
+
$action_date = $store->get_date( $action_id );
|
26 |
+
|
27 |
+
$this->assertEquals( $time->getTimestamp(), $action_date->getTimestamp() );
|
28 |
+
}
|
29 |
+
|
30 |
+
public function test_retrieve_action() {
|
31 |
+
$time = as_get_datetime_object();
|
32 |
+
$schedule = new ActionScheduler_SimpleSchedule($time);
|
33 |
+
$action = new ActionScheduler_Action('my_hook', array(), $schedule, 'my_group');
|
34 |
+
$store = new ActionScheduler_wpPostStore();
|
35 |
+
$action_id = $store->save_action($action);
|
36 |
+
|
37 |
+
$retrieved = $store->fetch_action($action_id);
|
38 |
+
$this->assertEquals($action->get_hook(), $retrieved->get_hook());
|
39 |
+
$this->assertEqualSets($action->get_args(), $retrieved->get_args());
|
40 |
+
$this->assertEquals($action->get_schedule()->next()->getTimestamp(), $retrieved->get_schedule()->next()->getTimestamp());
|
41 |
+
$this->assertEquals($action->get_group(), $retrieved->get_group());
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @expectedException ActionScheduler_InvalidActionException
|
46 |
+
* @dataProvider provide_bad_args
|
47 |
+
*
|
48 |
+
* @param string $content
|
49 |
+
*/
|
50 |
+
public function test_action_bad_args( $content ) {
|
51 |
+
$store = new ActionScheduler_wpPostStore();
|
52 |
+
$post_id = wp_insert_post( array(
|
53 |
+
'post_type' => ActionScheduler_wpPostStore::POST_TYPE,
|
54 |
+
'post_status' => ActionScheduler_Store::STATUS_PENDING,
|
55 |
+
'post_content' => $content,
|
56 |
+
) );
|
57 |
+
|
58 |
+
$store->fetch_action( $post_id );
|
59 |
+
}
|
60 |
+
|
61 |
+
public function provide_bad_args() {
|
62 |
+
return array(
|
63 |
+
array( '{"bad_json":true}}' ),
|
64 |
+
);
|
65 |
+
}
|
66 |
+
|
67 |
+
public function test_cancel_action() {
|
68 |
+
$time = as_get_datetime_object();
|
69 |
+
$schedule = new ActionScheduler_SimpleSchedule($time);
|
70 |
+
$action = new ActionScheduler_Action('my_hook', array(), $schedule, 'my_group');
|
71 |
+
$store = new ActionScheduler_wpPostStore();
|
72 |
+
$action_id = $store->save_action($action);
|
73 |
+
$store->cancel_action( $action_id );
|
74 |
+
|
75 |
+
$fetched = $store->fetch_action( $action_id );
|
76 |
+
$this->assertInstanceOf( 'ActionScheduler_CanceledAction', $fetched );
|
77 |
+
}
|
78 |
+
|
79 |
+
public function test_claim_actions() {
|
80 |
+
$created_actions = array();
|
81 |
+
$store = new ActionScheduler_wpPostStore();
|
82 |
+
for ( $i = 3 ; $i > -3 ; $i-- ) {
|
83 |
+
$time = as_get_datetime_object($i.' hours');
|
84 |
+
$schedule = new ActionScheduler_SimpleSchedule($time);
|
85 |
+
$action = new ActionScheduler_Action('my_hook', array($i), $schedule, 'my_group');
|
86 |
+
$created_actions[] = $store->save_action($action);
|
87 |
+
}
|
88 |
+
|
89 |
+
$claim = $store->stake_claim();
|
90 |
+
$this->assertInstanceof( 'ActionScheduler_ActionClaim', $claim );
|
91 |
+
|
92 |
+
$this->assertCount( 3, $claim->get_actions() );
|
93 |
+
$this->assertEqualSets( array_slice( $created_actions, 3, 3 ), $claim->get_actions() );
|
94 |
+
}
|
95 |
+
|
96 |
+
public function test_claim_actions_order() {
|
97 |
+
$store = new ActionScheduler_wpPostStore();
|
98 |
+
$schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '-1 hour' ) );
|
99 |
+
$created_actions = array(
|
100 |
+
$store->save_action( new ActionScheduler_Action( 'my_hook', array( 1 ), $schedule, 'my_group' ) ),
|
101 |
+
$store->save_action( new ActionScheduler_Action( 'my_hook', array( 1 ), $schedule, 'my_group' ) ),
|
102 |
+
);
|
103 |
+
|
104 |
+
$claim = $store->stake_claim();
|
105 |
+
$this->assertInstanceof( 'ActionScheduler_ActionClaim', $claim );
|
106 |
+
|
107 |
+
// Verify uniqueness of action IDs.
|
108 |
+
$this->assertEquals( 2, count( array_unique( $created_actions ) ) );
|
109 |
+
|
110 |
+
// Verify the count and order of the actions.
|
111 |
+
$claimed_actions = $claim->get_actions();
|
112 |
+
$this->assertCount( 2, $claimed_actions );
|
113 |
+
$this->assertEquals( $created_actions, $claimed_actions );
|
114 |
+
|
115 |
+
// Verify the reversed order doesn't pass.
|
116 |
+
$reversed_actions = array_reverse( $created_actions );
|
117 |
+
$this->assertNotEquals( $reversed_actions, $claimed_actions );
|
118 |
+
}
|
119 |
+
|
120 |
+
public function test_duplicate_claim() {
|
121 |
+
$created_actions = array();
|
122 |
+
$store = new ActionScheduler_wpPostStore();
|
123 |
+
for ( $i = 0 ; $i > -3 ; $i-- ) {
|
124 |
+
$time = as_get_datetime_object($i.' hours');
|
125 |
+
$schedule = new ActionScheduler_SimpleSchedule($time);
|
126 |
+
$action = new ActionScheduler_Action('my_hook', array($i), $schedule, 'my_group');
|
127 |
+
$created_actions[] = $store->save_action($action);
|
128 |
+
}
|
129 |
+
|
130 |
+
$claim1 = $store->stake_claim();
|
131 |
+
$claim2 = $store->stake_claim();
|
132 |
+
$this->assertCount( 3, $claim1->get_actions() );
|
133 |
+
$this->assertCount( 0, $claim2->get_actions() );
|
134 |
+
}
|
135 |
+
|
136 |
+
public function test_release_claim() {
|
137 |
+
$created_actions = array();
|
138 |
+
$store = new ActionScheduler_wpPostStore();
|
139 |
+
for ( $i = 0 ; $i > -3 ; $i-- ) {
|
140 |
+
$time = as_get_datetime_object($i.' hours');
|
141 |
+
$schedule = new ActionScheduler_SimpleSchedule($time);
|
142 |
+
$action = new ActionScheduler_Action('my_hook', array($i), $schedule, 'my_group');
|
143 |
+
$created_actions[] = $store->save_action($action);
|
144 |
+
}
|
145 |
+
|
146 |
+
$claim1 = $store->stake_claim();
|
147 |
+
|
148 |
+
$store->release_claim( $claim1 );
|
149 |
+
|
150 |
+
$claim2 = $store->stake_claim();
|
151 |
+
$this->assertCount( 3, $claim2->get_actions() );
|
152 |
+
}
|
153 |
+
|
154 |
+
public function test_search() {
|
155 |
+
$created_actions = array();
|
156 |
+
$store = new ActionScheduler_wpPostStore();
|
157 |
+
for ( $i = -3 ; $i <= 3 ; $i++ ) {
|
158 |
+
$time = as_get_datetime_object($i.' hours');
|
159 |
+
$schedule = new ActionScheduler_SimpleSchedule($time);
|
160 |
+
$action = new ActionScheduler_Action('my_hook', array($i), $schedule, 'my_group');
|
161 |
+
$created_actions[] = $store->save_action($action);
|
162 |
+
}
|
163 |
+
|
164 |
+
$next_no_args = $store->find_action( 'my_hook' );
|
165 |
+
$this->assertEquals( $created_actions[0], $next_no_args );
|
166 |
+
|
167 |
+
$next_with_args = $store->find_action( 'my_hook', array( 'args' => array( 1 ) ) );
|
168 |
+
$this->assertEquals( $created_actions[4], $next_with_args );
|
169 |
+
|
170 |
+
$non_existent = $store->find_action( 'my_hook', array( 'args' => array( 17 ) ) );
|
171 |
+
$this->assertNull( $non_existent );
|
172 |
+
}
|
173 |
+
|
174 |
+
public function test_search_by_group() {
|
175 |
+
$store = new ActionScheduler_wpPostStore();
|
176 |
+
$schedule = new ActionScheduler_SimpleSchedule(as_get_datetime_object('tomorrow'));
|
177 |
+
$abc = $store->save_action(new ActionScheduler_Action('my_hook', array(1), $schedule, 'abc'));
|
178 |
+
$def = $store->save_action(new ActionScheduler_Action('my_hook', array(1), $schedule, 'def'));
|
179 |
+
$ghi = $store->save_action(new ActionScheduler_Action('my_hook', array(1), $schedule, 'ghi'));
|
180 |
+
|
181 |
+
$this->assertEquals( $abc, $store->find_action('my_hook', array('group' => 'abc')));
|
182 |
+
$this->assertEquals( $def, $store->find_action('my_hook', array('group' => 'def')));
|
183 |
+
$this->assertEquals( $ghi, $store->find_action('my_hook', array('group' => 'ghi')));
|
184 |
+
}
|
185 |
+
|
186 |
+
public function test_post_author() {
|
187 |
+
$current_user = get_current_user_id();
|
188 |
+
|
189 |
+
$time = as_get_datetime_object();
|
190 |
+
$schedule = new ActionScheduler_SimpleSchedule($time);
|
191 |
+
$action = new ActionScheduler_Action('my_hook', array(), $schedule);
|
192 |
+
$store = new ActionScheduler_wpPostStore();
|
193 |
+
$action_id = $store->save_action($action);
|
194 |
+
|
195 |
+
$post = get_post($action_id);
|
196 |
+
$this->assertEquals(0, $post->post_author);
|
197 |
+
|
198 |
+
$new_user = $this->factory->user->create_object(array(
|
199 |
+
'user_login' => __FUNCTION__,
|
200 |
+
'user_pass' => md5(rand()),
|
201 |
+
));
|
202 |
+
wp_set_current_user( $new_user );
|
203 |
+
|
204 |
+
|
205 |
+
$schedule = new ActionScheduler_SimpleSchedule($time);
|
206 |
+
$action = new ActionScheduler_Action('my_hook', array(), $schedule);
|
207 |
+
$action_id = $store->save_action($action);
|
208 |
+
$post = get_post($action_id);
|
209 |
+
$this->assertEquals(0, $post->post_author);
|
210 |
+
|
211 |
+
wp_set_current_user($current_user);
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* @issue 13
|
216 |
+
*/
|
217 |
+
public function test_post_status_for_recurring_action() {
|
218 |
+
$time = as_get_datetime_object('10 minutes');
|
219 |
+
$schedule = new ActionScheduler_IntervalSchedule($time, HOUR_IN_SECONDS);
|
220 |
+
$action = new ActionScheduler_Action('my_hook', array(), $schedule);
|
221 |
+
$store = new ActionScheduler_wpPostStore();
|
222 |
+
$action_id = $store->save_action($action);
|
223 |
+
|
224 |
+
$action = $store->fetch_action($action_id);
|
225 |
+
$action->execute();
|
226 |
+
$store->mark_complete( $action_id );
|
227 |
+
|
228 |
+
$next = $action->get_schedule()->next( as_get_datetime_object() );
|
229 |
+
$new_action_id = $store->save_action( $action, $next );
|
230 |
+
|
231 |
+
$this->assertEquals('publish', get_post_status($action_id));
|
232 |
+
$this->assertEquals('pending', get_post_status($new_action_id));
|
233 |
+
}
|
234 |
+
|
235 |
+
public function test_get_run_date() {
|
236 |
+
$time = as_get_datetime_object('-10 minutes');
|
237 |
+
$schedule = new ActionScheduler_IntervalSchedule($time, HOUR_IN_SECONDS);
|
238 |
+
$action = new ActionScheduler_Action('my_hook', array(), $schedule);
|
239 |
+
$store = new ActionScheduler_wpPostStore();
|
240 |
+
$action_id = $store->save_action($action);
|
241 |
+
|
242 |
+
$this->assertEquals( $store->get_date($action_id)->getTimestamp(), $time->getTimestamp() );
|
243 |
+
|
244 |
+
$action = $store->fetch_action($action_id);
|
245 |
+
$action->execute();
|
246 |
+
$now = as_get_datetime_object();
|
247 |
+
$store->mark_complete( $action_id );
|
248 |
+
|
249 |
+
$this->assertEquals( $store->get_date($action_id)->getTimestamp(), $now->getTimestamp() );
|
250 |
+
|
251 |
+
$next = $action->get_schedule()->next( $now );
|
252 |
+
$new_action_id = $store->save_action( $action, $next );
|
253 |
+
|
254 |
+
$this->assertEquals( (int)($now->getTimestamp()) + HOUR_IN_SECONDS, $store->get_date($new_action_id)->getTimestamp() );
|
255 |
+
}
|
256 |
+
|
257 |
+
public function test_get_status() {
|
258 |
+
$time = as_get_datetime_object('-10 minutes');
|
259 |
+
$schedule = new ActionScheduler_IntervalSchedule($time, HOUR_IN_SECONDS);
|
260 |
+
$action = new ActionScheduler_Action('my_hook', array(), $schedule);
|
261 |
+
$store = new ActionScheduler_wpPostStore();
|
262 |
+
$action_id = $store->save_action($action);
|
263 |
+
|
264 |
+
$this->assertEquals( ActionScheduler_Store::STATUS_PENDING, $store->get_status( $action_id ) );
|
265 |
+
|
266 |
+
$store->mark_complete( $action_id );
|
267 |
+
$this->assertEquals( ActionScheduler_Store::STATUS_COMPLETE, $store->get_status( $action_id ) );
|
268 |
+
|
269 |
+
$store->mark_failure( $action_id );
|
270 |
+
$this->assertEquals( ActionScheduler_Store::STATUS_FAILED, $store->get_status( $action_id ) );
|
271 |
+
}
|
272 |
+
|
273 |
+
public function test_claim_actions_by_hooks() {
|
274 |
+
$hook1 = __FUNCTION__ . '_hook_1';
|
275 |
+
$hook2 = __FUNCTION__ . '_hook_2';
|
276 |
+
$store = new ActionScheduler_wpPostStore();
|
277 |
+
$schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '-1 hour' ) );
|
278 |
+
|
279 |
+
$action1 = $store->save_action( new ActionScheduler_Action( $hook1, array(), $schedule ) );
|
280 |
+
$action2 = $store->save_action( new ActionScheduler_Action( $hook2, array(), $schedule ) );
|
281 |
+
|
282 |
+
// Claiming no hooks should include all actions.
|
283 |
+
$claim = $store->stake_claim( 10 );
|
284 |
+
$this->assertEquals( 2, count( $claim->get_actions() ) );
|
285 |
+
$this->assertTrue( in_array( $action1, $claim->get_actions() ) );
|
286 |
+
$this->assertTrue( in_array( $action2, $claim->get_actions() ) );
|
287 |
+
$store->release_claim( $claim );
|
288 |
+
|
289 |
+
// Claiming a hook should claim only actions with that hook
|
290 |
+
$claim = $store->stake_claim( 10, null, array( $hook1 ) );
|
291 |
+
$this->assertEquals( 1, count( $claim->get_actions() ) );
|
292 |
+
$this->assertTrue( in_array( $action1, $claim->get_actions() ) );
|
293 |
+
$store->release_claim( $claim );
|
294 |
+
|
295 |
+
// Claiming two hooks should claim actions with either of those hooks
|
296 |
+
$claim = $store->stake_claim( 10, null, array( $hook1, $hook2 ) );
|
297 |
+
$this->assertEquals( 2, count( $claim->get_actions() ) );
|
298 |
+
$this->assertTrue( in_array( $action1, $claim->get_actions() ) );
|
299 |
+
$this->assertTrue( in_array( $action2, $claim->get_actions() ) );
|
300 |
+
$store->release_claim( $claim );
|
301 |
+
|
302 |
+
// Claiming two hooks should claim actions with either of those hooks
|
303 |
+
$claim = $store->stake_claim( 10, null, array( __METHOD__ . '_hook_3' ) );
|
304 |
+
$this->assertEquals( 0, count( $claim->get_actions() ) );
|
305 |
+
$this->assertFalse( in_array( $action1, $claim->get_actions() ) );
|
306 |
+
$this->assertFalse( in_array( $action2, $claim->get_actions() ) );
|
307 |
+
$store->release_claim( $claim );
|
308 |
+
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
* @issue 121
|
312 |
+
*/
|
313 |
+
public function test_claim_actions_by_group() {
|
314 |
+
$group1 = md5( rand() );
|
315 |
+
$store = new ActionScheduler_wpPostStore();
|
316 |
+
$schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '-1 hour' ) );
|
317 |
+
|
318 |
+
$action1 = $store->save_action( new ActionScheduler_Action( __METHOD__, array(), $schedule, $group1 ) );
|
319 |
+
$action2 = $store->save_action( new ActionScheduler_Action( __METHOD__, array(), $schedule ) );
|
320 |
+
|
321 |
+
// Claiming no group should include all actions.
|
322 |
+
$claim = $store->stake_claim( 10 );
|
323 |
+
$this->assertEquals( 2, count( $claim->get_actions() ) );
|
324 |
+
$this->assertTrue( in_array( $action1, $claim->get_actions() ) );
|
325 |
+
$this->assertTrue( in_array( $action2, $claim->get_actions() ) );
|
326 |
+
$store->release_claim( $claim );
|
327 |
+
|
328 |
+
// Claiming a group should claim only actions in that group.
|
329 |
+
$claim = $store->stake_claim( 10, null, array(), $group1 );
|
330 |
+
$this->assertEquals( 1, count( $claim->get_actions() ) );
|
331 |
+
$this->assertTrue( in_array( $action1, $claim->get_actions() ) );
|
332 |
+
$store->release_claim( $claim );
|
333 |
+
}
|
334 |
+
|
335 |
+
public function test_claim_actions_by_hook_and_group() {
|
336 |
+
$hook1 = __FUNCTION__ . '_hook_1';
|
337 |
+
$hook2 = __FUNCTION__ . '_hook_2';
|
338 |
+
$hook3 = __FUNCTION__ . '_hook_3';
|
339 |
+
$group1 = 'group_' . md5( rand() );
|
340 |
+
$group2 = 'group_' . md5( rand() );
|
341 |
+
$store = new ActionScheduler_wpPostStore();
|
342 |
+
$schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( '-1 hour' ) );
|
343 |
+
|
344 |
+
$action1 = $store->save_action( new ActionScheduler_Action( $hook1, array(), $schedule, $group1 ) );
|
345 |
+
$action2 = $store->save_action( new ActionScheduler_Action( $hook2, array(), $schedule ) );
|
346 |
+
$action3 = $store->save_action( new ActionScheduler_Action( $hook3, array(), $schedule, $group2 ) );
|
347 |
+
|
348 |
+
// Claiming no hooks or group should include all actions.
|
349 |
+
$claim = $store->stake_claim( 10 );
|
350 |
+
$this->assertEquals( 3, count( $claim->get_actions() ) );
|
351 |
+
$this->assertTrue( in_array( $action1, $claim->get_actions() ) );
|
352 |
+
$this->assertTrue( in_array( $action2, $claim->get_actions() ) );
|
353 |
+
$store->release_claim( $claim );
|
354 |
+
|
355 |
+
// Claiming a group and hook should claim only actions in that group.
|
356 |
+
$claim = $store->stake_claim( 10, null, array( $hook1 ), $group1 );
|
357 |
+
$this->assertEquals( 1, count( $claim->get_actions() ) );
|
358 |
+
$this->assertTrue( in_array( $action1, $claim->get_actions() ) );
|
359 |
+
$store->release_claim( $claim );
|
360 |
+
|
361 |
+
// Claiming a group and hook should claim only actions with that hook in that group.
|
362 |
+
$claim = $store->stake_claim( 10, null, array( $hook2 ), $group1 );
|
363 |
+
$this->assertEquals( 0, count( $claim->get_actions() ) );
|
364 |
+
$this->assertFalse( in_array( $action1, $claim->get_actions() ) );
|
365 |
+
$this->assertFalse( in_array( $action2, $claim->get_actions() ) );
|
366 |
+
$store->release_claim( $claim );
|
367 |
+
|
368 |
+
// Claiming a group and hook should claim only actions with that hook in that group.
|
369 |
+
$claim = $store->stake_claim( 10, null, array( $hook1, $hook2 ), $group2 );
|
370 |
+
$this->assertEquals( 0, count( $claim->get_actions() ) );
|
371 |
+
$this->assertFalse( in_array( $action1, $claim->get_actions() ) );
|
372 |
+
$this->assertFalse( in_array( $action2, $claim->get_actions() ) );
|
373 |
+
$store->release_claim( $claim );
|
374 |
+
}
|
375 |
+
}
|
trunk/includes/lib/action-scheduler/tests/phpunit/logging/ActionScheduler_wpCommentLogger_Test.php
ADDED
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_wpCommentLogger_Test
|
5 |
+
* @package test_cases\logging
|
6 |
+
*/
|
7 |
+
class ActionScheduler_wpCommentLogger_Test extends ActionScheduler_UnitTestCase {
|
8 |
+
public function test_default_logger() {
|
9 |
+
$logger = ActionScheduler::logger();
|
10 |
+
$this->assertInstanceOf( 'ActionScheduler_Logger', $logger );
|
11 |
+
$this->assertInstanceOf( 'ActionScheduler_wpCommentLogger', $logger );
|
12 |
+
}
|
13 |
+
|
14 |
+
public function test_add_log_entry() {
|
15 |
+
$action_id = as_schedule_single_action( time(), 'a hook' );
|
16 |
+
$logger = ActionScheduler::logger();
|
17 |
+
$message = 'Logging that something happened';
|
18 |
+
$log_id = $logger->log( $action_id, $message );
|
19 |
+
$entry = $logger->get_entry( $log_id );
|
20 |
+
|
21 |
+
$this->assertEquals( $action_id, $entry->get_action_id() );
|
22 |
+
$this->assertEquals( $message, $entry->get_message() );
|
23 |
+
}
|
24 |
+
|
25 |
+
public function test_add_log_datetime() {
|
26 |
+
$action_id = as_schedule_single_action( time(), 'a hook' );
|
27 |
+
$logger = ActionScheduler::logger();
|
28 |
+
$message = 'Logging that something happened';
|
29 |
+
$date = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
|
30 |
+
$log_id = $logger->log( $action_id, $message, $date );
|
31 |
+
$entry = $logger->get_entry( $log_id );
|
32 |
+
|
33 |
+
$this->assertEquals( $action_id, $entry->get_action_id() );
|
34 |
+
$this->assertEquals( $message, $entry->get_message() );
|
35 |
+
|
36 |
+
$date = new ActionScheduler_DateTime( 'now', new DateTimeZone( 'UTC' ) );
|
37 |
+
$log_id = $logger->log( $action_id, $message, $date );
|
38 |
+
$entry = $logger->get_entry( $log_id );
|
39 |
+
|
40 |
+
$this->assertEquals( $action_id, $entry->get_action_id() );
|
41 |
+
$this->assertEquals( $message, $entry->get_message() );
|
42 |
+
}
|
43 |
+
|
44 |
+
public function test_null_log_entry() {
|
45 |
+
$logger = ActionScheduler::logger();
|
46 |
+
$entry = $logger->get_entry( 1 );
|
47 |
+
$this->assertEquals( '', $entry->get_action_id() );
|
48 |
+
$this->assertEquals( '', $entry->get_message() );
|
49 |
+
}
|
50 |
+
|
51 |
+
public function test_erroneous_entry_id() {
|
52 |
+
$comment = wp_insert_comment(array(
|
53 |
+
'comment_post_ID' => 1,
|
54 |
+
'comment_author' => 'test',
|
55 |
+
'comment_content' => 'this is not a log entry',
|
56 |
+
));
|
57 |
+
$logger = ActionScheduler::logger();
|
58 |
+
$entry = $logger->get_entry( $comment );
|
59 |
+
$this->assertEquals( '', $entry->get_action_id() );
|
60 |
+
$this->assertEquals( '', $entry->get_message() );
|
61 |
+
}
|
62 |
+
|
63 |
+
public function test_storage_comments() {
|
64 |
+
$action_id = as_schedule_single_action( time(), 'a hook' );
|
65 |
+
$logger = ActionScheduler::logger();
|
66 |
+
$logs = $logger->get_logs( $action_id );
|
67 |
+
$expected = new ActionScheduler_LogEntry( $action_id, 'action created' );
|
68 |
+
$this->assertTrue( in_array( $this->log_entry_to_array( $expected ) , $this->log_entry_to_array( $logs ) ) );
|
69 |
+
}
|
70 |
+
|
71 |
+
protected function log_entry_to_array( $logs ) {
|
72 |
+
if ( $logs instanceof ActionScheduler_LogEntry ) {
|
73 |
+
return array( 'action_id' => $logs->get_action_id(), 'message' => $logs->get_message() );
|
74 |
+
}
|
75 |
+
|
76 |
+
foreach ( $logs as $id => $log) {
|
77 |
+
$logs[ $id ] = array( 'action_id' => $log->get_action_id(), 'message' => $log->get_message() );
|
78 |
+
}
|
79 |
+
|
80 |
+
return $logs;
|
81 |
+
}
|
82 |
+
|
83 |
+
public function test_execution_comments() {
|
84 |
+
$action_id = as_schedule_single_action( time(), 'a hook' );
|
85 |
+
$logger = ActionScheduler::logger();
|
86 |
+
$started = new ActionScheduler_LogEntry( $action_id, 'action started' );
|
87 |
+
$finished = new ActionScheduler_LogEntry( $action_id, 'action complete' );
|
88 |
+
|
89 |
+
$runner = new ActionScheduler_QueueRunner();
|
90 |
+
$runner->run();
|
91 |
+
|
92 |
+
$logs = $logger->get_logs( $action_id );
|
93 |
+
$this->assertTrue( in_array( $this->log_entry_to_array( $started ), $this->log_entry_to_array( $logs ) ) );
|
94 |
+
$this->assertTrue( in_array( $this->log_entry_to_array( $finished ), $this->log_entry_to_array( $logs ) ) );
|
95 |
+
}
|
96 |
+
|
97 |
+
public function test_failed_execution_comments() {
|
98 |
+
$hook = md5(rand());
|
99 |
+
add_action( $hook, array( $this, '_a_hook_callback_that_throws_an_exception' ) );
|
100 |
+
$action_id = as_schedule_single_action( time(), $hook );
|
101 |
+
$logger = ActionScheduler::logger();
|
102 |
+
$started = new ActionScheduler_LogEntry( $action_id, 'action started' );
|
103 |
+
$finished = new ActionScheduler_LogEntry( $action_id, 'action complete' );
|
104 |
+
$failed = new ActionScheduler_LogEntry( $action_id, 'action failed: Execution failed' );
|
105 |
+
|
106 |
+
$runner = new ActionScheduler_QueueRunner();
|
107 |
+
$runner->run();
|
108 |
+
|
109 |
+
$logs = $logger->get_logs( $action_id );
|
110 |
+
$this->assertTrue( in_array( $this->log_entry_to_array( $started ), $this->log_entry_to_array( $logs ) ) );
|
111 |
+
$this->assertFalse( in_array( $this->log_entry_to_array( $finished ), $this->log_entry_to_array( $logs ) ) );
|
112 |
+
$this->assertTrue( in_array( $this->log_entry_to_array( $failed ), $this->log_entry_to_array( $logs ) ) );
|
113 |
+
}
|
114 |
+
|
115 |
+
public function test_fatal_error_comments() {
|
116 |
+
$hook = md5(rand());
|
117 |
+
$action_id = as_schedule_single_action( time(), $hook );
|
118 |
+
$logger = ActionScheduler::logger();
|
119 |
+
do_action( 'action_scheduler_unexpected_shutdown', $action_id, array(
|
120 |
+
'type' => E_ERROR,
|
121 |
+
'message' => 'Test error',
|
122 |
+
'file' => __FILE__,
|
123 |
+
'line' => __LINE__,
|
124 |
+
));
|
125 |
+
|
126 |
+
$logs = $logger->get_logs( $action_id );
|
127 |
+
$found_log = FALSE;
|
128 |
+
foreach ( $logs as $l ) {
|
129 |
+
if ( strpos( $l->get_message(), 'unexpected shutdown' ) === 0 ) {
|
130 |
+
$found_log = TRUE;
|
131 |
+
}
|
132 |
+
}
|
133 |
+
$this->assertTrue( $found_log, 'Unexpected shutdown log not found' );
|
134 |
+
}
|
135 |
+
|
136 |
+
public function test_canceled_action_comments() {
|
137 |
+
$action_id = as_schedule_single_action( time(), 'a hook' );
|
138 |
+
as_unschedule_action( 'a hook' );
|
139 |
+
$logger = ActionScheduler::logger();
|
140 |
+
$logs = $logger->get_logs( $action_id );
|
141 |
+
$expected = new ActionScheduler_LogEntry( $action_id, 'action canceled' );
|
142 |
+
$this->assertTrue( in_array( $this->log_entry_to_array( $expected ), $this->log_entry_to_array( $logs ) ) );
|
143 |
+
}
|
144 |
+
|
145 |
+
public function _a_hook_callback_that_throws_an_exception() {
|
146 |
+
throw new RuntimeException('Execution failed');
|
147 |
+
}
|
148 |
+
|
149 |
+
public function test_filtering_of_get_comments() {
|
150 |
+
$post_id = $this->factory->post->create_object(array(
|
151 |
+
'post_title' => __FUNCTION__,
|
152 |
+
));
|
153 |
+
$comment_id = $this->factory->comment->create_object(array(
|
154 |
+
'comment_post_ID' => $post_id,
|
155 |
+
'comment_author' => __CLASS__,
|
156 |
+
'comment_content' => __FUNCTION__,
|
157 |
+
));
|
158 |
+
|
159 |
+
// Verify that we're getting the expected comment before we add logging comments
|
160 |
+
$comments = get_comments();
|
161 |
+
$this->assertCount( 1, $comments );
|
162 |
+
$this->assertEquals( $comment_id, $comments[0]->comment_ID );
|
163 |
+
|
164 |
+
|
165 |
+
$action_id = as_schedule_single_action( time(), 'a hook' );
|
166 |
+
$logger = ActionScheduler::logger();
|
167 |
+
$message = 'Logging that something happened';
|
168 |
+
$log_id = $logger->log( $action_id, $message );
|
169 |
+
|
170 |
+
|
171 |
+
// Verify that logging comments are excluded from general comment queries
|
172 |
+
$comments = get_comments();
|
173 |
+
$this->assertCount( 1, $comments );
|
174 |
+
$this->assertEquals( $comment_id, $comments[0]->comment_ID );
|
175 |
+
|
176 |
+
// Verify that logging comments are returned when asking for them specifically
|
177 |
+
$comments = get_comments(array(
|
178 |
+
'type' => ActionScheduler_wpCommentLogger::TYPE,
|
179 |
+
));
|
180 |
+
// Expecting two: one when the action is created, another when we added our custom log
|
181 |
+
$this->assertCount( 2, $comments );
|
182 |
+
$this->assertContains( $log_id, wp_list_pluck($comments, 'comment_ID'));
|
183 |
+
}
|
184 |
+
}
|
185 |
+
|
trunk/includes/lib/action-scheduler/tests/phpunit/procedural_api/procedural_api_Test.php
ADDED
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class procedural_api_Test
|
5 |
+
*/
|
6 |
+
class procedural_api_Test extends ActionScheduler_UnitTestCase {
|
7 |
+
|
8 |
+
public function test_schedule_action() {
|
9 |
+
$time = time();
|
10 |
+
$hook = md5(rand());
|
11 |
+
$action_id = as_schedule_single_action( $time, $hook );
|
12 |
+
|
13 |
+
$store = ActionScheduler::store();
|
14 |
+
$action = $store->fetch_action($action_id);
|
15 |
+
$this->assertEquals( $time, $action->get_schedule()->next()->getTimestamp() );
|
16 |
+
$this->assertEquals( $hook, $action->get_hook() );
|
17 |
+
}
|
18 |
+
|
19 |
+
public function test_recurring_action() {
|
20 |
+
$time = time();
|
21 |
+
$hook = md5(rand());
|
22 |
+
$action_id = as_schedule_recurring_action( $time, HOUR_IN_SECONDS, $hook );
|
23 |
+
|
24 |
+
$store = ActionScheduler::store();
|
25 |
+
$action = $store->fetch_action($action_id);
|
26 |
+
$this->assertEquals( $time, $action->get_schedule()->next()->getTimestamp() );
|
27 |
+
$this->assertEquals( $time + HOUR_IN_SECONDS + 2, $action->get_schedule()->next(as_get_datetime_object($time + 2))->getTimestamp());
|
28 |
+
$this->assertEquals( $hook, $action->get_hook() );
|
29 |
+
}
|
30 |
+
|
31 |
+
public function test_cron_schedule() {
|
32 |
+
$time = as_get_datetime_object('2014-01-01');
|
33 |
+
$hook = md5(rand());
|
34 |
+
$action_id = as_schedule_cron_action( $time->getTimestamp(), '0 0 10 10 *', $hook );
|
35 |
+
|
36 |
+
$store = ActionScheduler::store();
|
37 |
+
$action = $store->fetch_action($action_id);
|
38 |
+
$expected_date = as_get_datetime_object('2014-10-10');
|
39 |
+
$this->assertEquals( $expected_date->getTimestamp(), $action->get_schedule()->next()->getTimestamp() );
|
40 |
+
$this->assertEquals( $hook, $action->get_hook() );
|
41 |
+
}
|
42 |
+
|
43 |
+
public function test_get_next() {
|
44 |
+
$time = as_get_datetime_object('tomorrow');
|
45 |
+
$hook = md5(rand());
|
46 |
+
as_schedule_recurring_action( $time->getTimestamp(), HOUR_IN_SECONDS, $hook );
|
47 |
+
|
48 |
+
$next = as_next_scheduled_action( $hook );
|
49 |
+
|
50 |
+
$this->assertEquals( $time->getTimestamp(), $next );
|
51 |
+
}
|
52 |
+
|
53 |
+
public function provider_time_hook_args_group() {
|
54 |
+
$time = time() + 60 * 2;
|
55 |
+
$hook = md5( rand() );
|
56 |
+
$args = array( rand(), rand() );
|
57 |
+
$group = 'test_group';
|
58 |
+
|
59 |
+
return array(
|
60 |
+
|
61 |
+
// Test with no args or group
|
62 |
+
array(
|
63 |
+
'time' => $time,
|
64 |
+
'hook' => $hook,
|
65 |
+
'args' => array(),
|
66 |
+
'group' => '',
|
67 |
+
),
|
68 |
+
|
69 |
+
// Test with args but no group
|
70 |
+
array(
|
71 |
+
'time' => $time,
|
72 |
+
'hook' => $hook,
|
73 |
+
'args' => $args,
|
74 |
+
'group' => '',
|
75 |
+
),
|
76 |
+
|
77 |
+
// Test with group but no args
|
78 |
+
array(
|
79 |
+
'time' => $time,
|
80 |
+
'hook' => $hook,
|
81 |
+
'args' => array(),
|
82 |
+
'group' => $group,
|
83 |
+
),
|
84 |
+
|
85 |
+
// Test with args & group
|
86 |
+
array(
|
87 |
+
'time' => $time,
|
88 |
+
'hook' => $hook,
|
89 |
+
'args' => $args,
|
90 |
+
'group' => $group,
|
91 |
+
),
|
92 |
+
);
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* @dataProvider provider_time_hook_args_group
|
97 |
+
*/
|
98 |
+
public function test_unschedule( $time, $hook, $args, $group ) {
|
99 |
+
|
100 |
+
$action_id_unscheduled = as_schedule_single_action( $time, $hook, $args, $group );
|
101 |
+
$action_scheduled_time = $time + 1;
|
102 |
+
$action_id_scheduled = as_schedule_single_action( $action_scheduled_time, $hook, $args, $group );
|
103 |
+
|
104 |
+
as_unschedule_action( $hook, $args, $group );
|
105 |
+
|
106 |
+
$next = as_next_scheduled_action( $hook, $args, $group );
|
107 |
+
$this->assertEquals( $action_scheduled_time, $next );
|
108 |
+
|
109 |
+
$store = ActionScheduler::store();
|
110 |
+
$unscheduled_action = $store->fetch_action( $action_id_unscheduled );
|
111 |
+
|
112 |
+
// Make sure the next scheduled action is unscheduled
|
113 |
+
$this->assertEquals( $hook, $unscheduled_action->get_hook() );
|
114 |
+
$this->assertNull( $unscheduled_action->get_schedule()->next() );
|
115 |
+
|
116 |
+
// Make sure other scheduled actions are not unscheduled
|
117 |
+
$scheduled_action = $store->fetch_action( $action_id_scheduled );
|
118 |
+
|
119 |
+
$this->assertEquals( $hook, $scheduled_action->get_hook() );
|
120 |
+
$this->assertEquals( $action_scheduled_time, $scheduled_action->get_schedule()->next()->getTimestamp() );
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* @dataProvider provider_time_hook_args_group
|
125 |
+
*/
|
126 |
+
public function test_unschedule_all( $time, $hook, $args, $group ) {
|
127 |
+
|
128 |
+
$hook = md5( $hook );
|
129 |
+
$action_ids = array();
|
130 |
+
|
131 |
+
for ( $i = 0; $i < 3; $i++ ) {
|
132 |
+
$action_ids[] = as_schedule_single_action( $time, $hook, $args, $group );
|
133 |
+
}
|
134 |
+
|
135 |
+
as_unschedule_all_actions( $hook, $args, $group );
|
136 |
+
|
137 |
+
$next = as_next_scheduled_action( $hook );
|
138 |
+
$this->assertFalse($next);
|
139 |
+
|
140 |
+
$store = ActionScheduler::store();
|
141 |
+
|
142 |
+
foreach ( $action_ids as $action_id ) {
|
143 |
+
$action = $store->fetch_action($action_id);
|
144 |
+
|
145 |
+
$this->assertNull($action->get_schedule()->next());
|
146 |
+
$this->assertEquals($hook, $action->get_hook() );
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
public function test_as_get_datetime_object_default() {
|
151 |
+
|
152 |
+
$utc_now = new ActionScheduler_DateTime(null, new DateTimeZone('UTC'));
|
153 |
+
$as_now = as_get_datetime_object();
|
154 |
+
|
155 |
+
// Don't want to use 'U' as timestamps will always be in UTC
|
156 |
+
$this->assertEquals($utc_now->format('Y-m-d H:i:s'),$as_now->format('Y-m-d H:i:s'));
|
157 |
+
}
|
158 |
+
|
159 |
+
public function test_as_get_datetime_object_relative() {
|
160 |
+
|
161 |
+
$utc_tomorrow = new ActionScheduler_DateTime('tomorrow', new DateTimeZone('UTC'));
|
162 |
+
$as_tomorrow = as_get_datetime_object('tomorrow');
|
163 |
+
|
164 |
+
$this->assertEquals($utc_tomorrow->format('Y-m-d H:i:s'),$as_tomorrow->format('Y-m-d H:i:s'));
|
165 |
+
|
166 |
+
$utc_tomorrow = new ActionScheduler_DateTime('yesterday', new DateTimeZone('UTC'));
|
167 |
+
$as_tomorrow = as_get_datetime_object('yesterday');
|
168 |
+
|
169 |
+
$this->assertEquals($utc_tomorrow->format('Y-m-d H:i:s'),$as_tomorrow->format('Y-m-d H:i:s'));
|
170 |
+
}
|
171 |
+
|
172 |
+
public function test_as_get_datetime_object_fixed() {
|
173 |
+
|
174 |
+
$utc_tomorrow = new ActionScheduler_DateTime('29 February 2016', new DateTimeZone('UTC'));
|
175 |
+
$as_tomorrow = as_get_datetime_object('29 February 2016');
|
176 |
+
|
177 |
+
$this->assertEquals($utc_tomorrow->format('Y-m-d H:i:s'),$as_tomorrow->format('Y-m-d H:i:s'));
|
178 |
+
|
179 |
+
$utc_tomorrow = new ActionScheduler_DateTime('1st January 2024', new DateTimeZone('UTC'));
|
180 |
+
$as_tomorrow = as_get_datetime_object('1st January 2024');
|
181 |
+
|
182 |
+
$this->assertEquals($utc_tomorrow->format('Y-m-d H:i:s'),$as_tomorrow->format('Y-m-d H:i:s'));
|
183 |
+
}
|
184 |
+
|
185 |
+
public function test_as_get_datetime_object_timezone() {
|
186 |
+
|
187 |
+
$timezone_au = 'Australia/Brisbane';
|
188 |
+
$timezone_default = date_default_timezone_get();
|
189 |
+
|
190 |
+
date_default_timezone_set( $timezone_au );
|
191 |
+
|
192 |
+
$au_now = new ActionScheduler_DateTime(null);
|
193 |
+
$as_now = as_get_datetime_object();
|
194 |
+
|
195 |
+
// Make sure they're for the same time
|
196 |
+
$this->assertEquals($au_now->getTimestamp(),$as_now->getTimestamp());
|
197 |
+
|
198 |
+
// But not in the same timezone, as $as_now should be using UTC
|
199 |
+
$this->assertNotEquals($au_now->format('Y-m-d H:i:s'),$as_now->format('Y-m-d H:i:s'));
|
200 |
+
|
201 |
+
$au_now = new ActionScheduler_DateTime(null);
|
202 |
+
$as_au_now = as_get_datetime_object();
|
203 |
+
|
204 |
+
$this->assertEquals($au_now->getTimestamp(),$as_now->getTimestamp());
|
205 |
+
|
206 |
+
// But not in the same timezone, as $as_now should be using UTC
|
207 |
+
$this->assertNotEquals($au_now->format('Y-m-d H:i:s'),$as_now->format('Y-m-d H:i:s'));
|
208 |
+
|
209 |
+
// Just in cases
|
210 |
+
date_default_timezone_set( $timezone_default );
|
211 |
+
}
|
212 |
+
|
213 |
+
public function test_as_get_datetime_object_type() {
|
214 |
+
$f = 'Y-m-d H:i:s';
|
215 |
+
$now = as_get_datetime_object();
|
216 |
+
$this->assertInstanceOf( 'ActionScheduler_DateTime', $now );
|
217 |
+
|
218 |
+
$dateTime = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
|
219 |
+
$asDateTime = as_get_datetime_object( $dateTime );
|
220 |
+
$this->assertEquals( $dateTime->format( $f ), $asDateTime->format( $f ) );
|
221 |
+
}
|
222 |
+
}
|
trunk/includes/lib/action-scheduler/tests/phpunit/procedural_api/wc_get_scheduled_actions_Test.php
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class as_get_scheduled_actions_Test
|
5 |
+
*/
|
6 |
+
class as_get_scheduled_actions_Test extends ActionScheduler_UnitTestCase {
|
7 |
+
private $hooks = array();
|
8 |
+
private $args = array();
|
9 |
+
private $groups = array();
|
10 |
+
|
11 |
+
public function setUp() {
|
12 |
+
parent::setUp();
|
13 |
+
|
14 |
+
$store = ActionScheduler::store();
|
15 |
+
|
16 |
+
for ( $i = 0 ; $i < 10 ; $i++ ) {
|
17 |
+
$this->hooks[$i] = md5(rand());
|
18 |
+
$this->args[$i] = md5(rand());
|
19 |
+
$this->groups[$i] = md5(rand());
|
20 |
+
}
|
21 |
+
|
22 |
+
for ( $i = 0 ; $i < 10 ; $i++ ) {
|
23 |
+
for ( $j = 0 ; $j < 10 ; $j++ ) {
|
24 |
+
$schedule = new ActionScheduler_SimpleSchedule( as_get_datetime_object( $j - 3 . 'days') );
|
25 |
+
$group = $this->groups[ ( $i + $j ) % 10 ];
|
26 |
+
$action = new ActionScheduler_Action( $this->hooks[$i], array($this->args[$j]), $schedule, $group );
|
27 |
+
$store->save_action( $action );
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
public function test_date_queries() {
|
33 |
+
$actions = as_get_scheduled_actions(array(
|
34 |
+
'date' => as_get_datetime_object(gmdate('Y-m-d 00:00:00')),
|
35 |
+
'per_page' => -1,
|
36 |
+
), 'ids');
|
37 |
+
$this->assertCount(30, $actions);
|
38 |
+
|
39 |
+
$actions = as_get_scheduled_actions(array(
|
40 |
+
'date' => as_get_datetime_object(gmdate('Y-m-d 00:00:00')),
|
41 |
+
'date_compare' => '>=',
|
42 |
+
'per_page' => -1,
|
43 |
+
), 'ids');
|
44 |
+
$this->assertCount(70, $actions);
|
45 |
+
}
|
46 |
+
|
47 |
+
public function test_hook_queries() {
|
48 |
+
$actions = as_get_scheduled_actions(array(
|
49 |
+
'hook' => $this->hooks[2],
|
50 |
+
'per_page' => -1,
|
51 |
+
), 'ids');
|
52 |
+
$this->assertCount(10, $actions);
|
53 |
+
|
54 |
+
$actions = as_get_scheduled_actions(array(
|
55 |
+
'hook' => $this->hooks[2],
|
56 |
+
'date' => as_get_datetime_object(gmdate('Y-m-d 00:00:00')),
|
57 |
+
'per_page' => -1,
|
58 |
+
), 'ids');
|
59 |
+
$this->assertCount(3, $actions);
|
60 |
+
}
|
61 |
+
|
62 |
+
public function test_args_queries() {
|
63 |
+
$actions = as_get_scheduled_actions(array(
|
64 |
+
'args' => array($this->args[5]),
|
65 |
+
'per_page' => -1,
|
66 |
+
), 'ids');
|
67 |
+
$this->assertCount(10, $actions);
|
68 |
+
|
69 |
+
$actions = as_get_scheduled_actions(array(
|
70 |
+
'args' => array($this->args[5]),
|
71 |
+
'hook' => $this->hooks[3],
|
72 |
+
'per_page' => -1,
|
73 |
+
), 'ids');
|
74 |
+
$this->assertCount(1, $actions);
|
75 |
+
|
76 |
+
$actions = as_get_scheduled_actions(array(
|
77 |
+
'args' => array($this->args[5]),
|
78 |
+
'hook' => $this->hooks[3],
|
79 |
+
'date' => as_get_datetime_object(gmdate('Y-m-d 00:00:00')),
|
80 |
+
'per_page' => -1,
|
81 |
+
), 'ids');
|
82 |
+
$this->assertCount(0, $actions);
|
83 |
+
}
|
84 |
+
|
85 |
+
public function test_group_queries() {
|
86 |
+
$actions = as_get_scheduled_actions(array(
|
87 |
+
'group' => $this->groups[1],
|
88 |
+
'per_page' => -1,
|
89 |
+
), 'ids');
|
90 |
+
$this->assertCount(10, $actions);
|
91 |
+
|
92 |
+
$actions = as_get_scheduled_actions(array(
|
93 |
+
'group' => $this->groups[1],
|
94 |
+
'hook' => $this->hooks[9],
|
95 |
+
'per_page' => -1,
|
96 |
+
), 'ids');
|
97 |
+
$this->assertCount(1, $actions);
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
trunk/includes/lib/action-scheduler/tests/phpunit/runner/ActionScheduler_QueueCleaner_Test.php
ADDED
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_QueueCleaner_Test
|
5 |
+
*/
|
6 |
+
class ActionScheduler_QueueCleaner_Test extends ActionScheduler_UnitTestCase {
|
7 |
+
|
8 |
+
public function test_delete_old_actions() {
|
9 |
+
$store = ActionScheduler::store();
|
10 |
+
$runner = new ActionScheduler_QueueRunner( $store );
|
11 |
+
|
12 |
+
$random = md5(rand());
|
13 |
+
$schedule = new ActionScheduler_SimpleSchedule(as_get_datetime_object('1 day ago'));
|
14 |
+
|
15 |
+
$created_actions = array();
|
16 |
+
for ( $i = 0 ; $i < 5 ; $i++ ) {
|
17 |
+
$action = new ActionScheduler_Action( $random, array($random), $schedule );
|
18 |
+
$created_actions[] = $store->save_action( $action );
|
19 |
+
}
|
20 |
+
|
21 |
+
$runner->run();
|
22 |
+
|
23 |
+
add_filter( 'action_scheduler_retention_period', '__return_zero' ); // delete any finished job
|
24 |
+
$cleaner = new ActionScheduler_QueueCleaner( $store );
|
25 |
+
$cleaner->delete_old_actions();
|
26 |
+
remove_filter( 'action_scheduler_retention_period', '__return_zero' );
|
27 |
+
|
28 |
+
foreach ( $created_actions as $action_id ) {
|
29 |
+
$action = $store->fetch_action($action_id);
|
30 |
+
$this->assertFalse($action->is_finished()); // it's a NullAction
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
public function test_delete_canceled_actions() {
|
35 |
+
$store = ActionScheduler::store();
|
36 |
+
|
37 |
+
$random = md5(rand());
|
38 |
+
$schedule = new ActionScheduler_SimpleSchedule(as_get_datetime_object('1 day ago'));
|
39 |
+
|
40 |
+
$created_actions = array();
|
41 |
+
for ( $i = 0 ; $i < 5 ; $i++ ) {
|
42 |
+
$action = new ActionScheduler_Action( $random, array($random), $schedule );
|
43 |
+
$action_id = $store->save_action( $action );
|
44 |
+
$store->cancel_action( $action_id );
|
45 |
+
$created_actions[] = $action_id;
|
46 |
+
}
|
47 |
+
|
48 |
+
// track the actions that are deleted
|
49 |
+
$mock_action = new MockAction();
|
50 |
+
add_action( 'action_scheduler_deleted_action', array( $mock_action, 'action' ), 10, 1 );
|
51 |
+
add_filter( 'action_scheduler_retention_period', '__return_zero' ); // delete any finished job
|
52 |
+
|
53 |
+
$cleaner = new ActionScheduler_QueueCleaner( $store );
|
54 |
+
$cleaner->delete_old_actions();
|
55 |
+
|
56 |
+
remove_filter( 'action_scheduler_retention_period', '__return_zero' );
|
57 |
+
remove_action( 'action_scheduler_deleted_action', array( $mock_action, 'action' ), 10 );
|
58 |
+
|
59 |
+
$deleted_actions = array_map( 'reset', $mock_action->get_args() );
|
60 |
+
$this->assertEqualSets( $created_actions, $deleted_actions );
|
61 |
+
}
|
62 |
+
|
63 |
+
public function test_do_not_delete_recent_actions() {
|
64 |
+
$store = ActionScheduler::store();
|
65 |
+
$runner = new ActionScheduler_QueueRunner( $store );
|
66 |
+
|
67 |
+
$random = md5(rand());
|
68 |
+
$schedule = new ActionScheduler_SimpleSchedule(as_get_datetime_object('1 day ago'));
|
69 |
+
|
70 |
+
$created_actions = array();
|
71 |
+
for ( $i = 0 ; $i < 5 ; $i++ ) {
|
72 |
+
$action = new ActionScheduler_Action( $random, array($random), $schedule );
|
73 |
+
$created_actions[] = $store->save_action( $action );
|
74 |
+
}
|
75 |
+
|
76 |
+
$runner->run();
|
77 |
+
|
78 |
+
$cleaner = new ActionScheduler_QueueCleaner( $store );
|
79 |
+
$cleaner->delete_old_actions();
|
80 |
+
|
81 |
+
foreach ( $created_actions as $action_id ) {
|
82 |
+
$action = $store->fetch_action($action_id);
|
83 |
+
$this->assertTrue($action->is_finished()); // It's a FinishedAction
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
public function test_reset_unrun_actions() {
|
88 |
+
$store = ActionScheduler::store();
|
89 |
+
|
90 |
+
$random = md5(rand());
|
91 |
+
$schedule = new ActionScheduler_SimpleSchedule(as_get_datetime_object('1 day ago'));
|
92 |
+
|
93 |
+
$created_actions = array();
|
94 |
+
for ( $i = 0 ; $i < 5 ; $i++ ) {
|
95 |
+
$action = new ActionScheduler_Action( $random, array($random), $schedule );
|
96 |
+
$created_actions[] = $store->save_action( $action );
|
97 |
+
}
|
98 |
+
|
99 |
+
$store->stake_claim(10);
|
100 |
+
|
101 |
+
// don't actually process the jobs, to simulate a request that timed out
|
102 |
+
|
103 |
+
add_filter( 'action_scheduler_timeout_period', '__return_zero' ); // delete any finished job
|
104 |
+
$cleaner = new ActionScheduler_QueueCleaner( $store );
|
105 |
+
$cleaner->reset_timeouts();
|
106 |
+
|
107 |
+
remove_filter( 'action_scheduler_timeout_period', '__return_zero' );
|
108 |
+
|
109 |
+
$claim = $store->stake_claim(10);
|
110 |
+
$this->assertEqualSets($created_actions, $claim->get_actions());
|
111 |
+
}
|
112 |
+
|
113 |
+
public function test_do_not_reset_failed_action() {
|
114 |
+
$store = ActionScheduler::store();
|
115 |
+
|
116 |
+
$random = md5(rand());
|
117 |
+
$schedule = new ActionScheduler_SimpleSchedule(as_get_datetime_object('1 day ago'));
|
118 |
+
|
119 |
+
$created_actions = array();
|
120 |
+
for ( $i = 0 ; $i < 5 ; $i++ ) {
|
121 |
+
$action = new ActionScheduler_Action( $random, array($random), $schedule );
|
122 |
+
$created_actions[] = $store->save_action( $action );
|
123 |
+
}
|
124 |
+
|
125 |
+
$claim = $store->stake_claim(10);
|
126 |
+
foreach ( $claim->get_actions() as $action_id ) {
|
127 |
+
// simulate the first action interrupted by an uncatchable fatal error
|
128 |
+
$store->log_execution( $action_id );
|
129 |
+
break;
|
130 |
+
}
|
131 |
+
|
132 |
+
add_filter( 'action_scheduler_timeout_period', '__return_zero' ); // delete any finished job
|
133 |
+
$cleaner = new ActionScheduler_QueueCleaner( $store );
|
134 |
+
$cleaner->reset_timeouts();
|
135 |
+
remove_filter( 'action_scheduler_timeout_period', '__return_zero' );
|
136 |
+
|
137 |
+
$new_claim = $store->stake_claim(10);
|
138 |
+
$this->assertCount( 4, $new_claim->get_actions() );
|
139 |
+
|
140 |
+
add_filter( 'action_scheduler_failure_period', '__return_zero' );
|
141 |
+
$cleaner->mark_failures();
|
142 |
+
remove_filter( 'action_scheduler_failure_period', '__return_zero' );
|
143 |
+
|
144 |
+
$failed = $store->query_actions(array('status' => ActionScheduler_Store::STATUS_FAILED));
|
145 |
+
$this->assertEquals( $created_actions[0], $failed[0] );
|
146 |
+
$this->assertCount( 1, $failed );
|
147 |
+
|
148 |
+
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
trunk/includes/lib/action-scheduler/tests/phpunit/runner/ActionScheduler_QueueRunner_Test.php
ADDED
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_QueueRunner_Test
|
5 |
+
* @group runners
|
6 |
+
*/
|
7 |
+
class ActionScheduler_QueueRunner_Test extends ActionScheduler_UnitTestCase {
|
8 |
+
public function test_create_runner() {
|
9 |
+
$store = ActionScheduler::store();
|
10 |
+
$runner = new ActionScheduler_QueueRunner( $store );
|
11 |
+
$actions_run = $runner->run();
|
12 |
+
|
13 |
+
$this->assertEquals( 0, $actions_run );
|
14 |
+
}
|
15 |
+
|
16 |
+
public function test_run() {
|
17 |
+
$store = ActionScheduler::store();
|
18 |
+
$runner = new ActionScheduler_QueueRunner( $store );
|
19 |
+
|
20 |
+
$mock = new MockAction();
|
21 |
+
$random = md5(rand());
|
22 |
+
add_action( $random, array( $mock, 'action' ) );
|
23 |
+
$schedule = new ActionScheduler_SimpleSchedule(as_get_datetime_object('1 day ago'));
|
24 |
+
|
25 |
+
for ( $i = 0 ; $i < 5 ; $i++ ) {
|
26 |
+
$action = new ActionScheduler_Action( $random, array($random), $schedule );
|
27 |
+
$store->save_action( $action );
|
28 |
+
}
|
29 |
+
|
30 |
+
$actions_run = $runner->run();
|
31 |
+
|
32 |
+
remove_action( $random, array( $mock, 'action' ) );
|
33 |
+
|
34 |
+
$this->assertEquals( 5, $mock->get_call_count() );
|
35 |
+
$this->assertEquals( 5, $actions_run );
|
36 |
+
}
|
37 |
+
|
38 |
+
public function test_run_with_future_actions() {
|
39 |
+
$store = ActionScheduler::store();
|
40 |
+
$runner = new ActionScheduler_QueueRunner( $store );
|
41 |
+
|
42 |
+
$mock = new MockAction();
|
43 |
+
$random = md5(rand());
|
44 |
+
add_action( $random, array( $mock, 'action' ) );
|
45 |
+
$schedule = new ActionScheduler_SimpleSchedule(as_get_datetime_object('1 day ago'));
|
46 |
+
|
47 |
+
for ( $i = 0 ; $i < 3 ; $i++ ) {
|
48 |
+
$action = new ActionScheduler_Action( $random, array($random), $schedule );
|
49 |
+
$store->save_action( $action );
|
50 |
+
}
|
51 |
+
|
52 |
+
$schedule = new ActionScheduler_SimpleSchedule(as_get_datetime_object('tomorrow'));
|
53 |
+
for ( $i = 0 ; $i < 3 ; $i++ ) {
|
54 |
+
$action = new ActionScheduler_Action( $random, array($random), $schedule );
|
55 |
+
$store->save_action( $action );
|
56 |
+
}
|
57 |
+
|
58 |
+
$actions_run = $runner->run();
|
59 |
+
|
60 |
+
remove_action( $random, array( $mock, 'action' ) );
|
61 |
+
|
62 |
+
$this->assertEquals( 3, $mock->get_call_count() );
|
63 |
+
$this->assertEquals( 3, $actions_run );
|
64 |
+
}
|
65 |
+
|
66 |
+
public function test_completed_action_status() {
|
67 |
+
$store = ActionScheduler::store();
|
68 |
+
$runner = new ActionScheduler_QueueRunner( $store );
|
69 |
+
|
70 |
+
$random = md5(rand());
|
71 |
+
$schedule = new ActionScheduler_SimpleSchedule(as_get_datetime_object('12 hours ago'));
|
72 |
+
|
73 |
+
$action = new ActionScheduler_Action( $random, array(), $schedule );
|
74 |
+
$action_id = $store->save_action( $action );
|
75 |
+
|
76 |
+
$runner->run();
|
77 |
+
|
78 |
+
$finished_action = $store->fetch_action( $action_id );
|
79 |
+
|
80 |
+
$this->assertTrue( $finished_action->is_finished() );
|
81 |
+
}
|
82 |
+
|
83 |
+
public function test_next_instance_of_action() {
|
84 |
+
$store = ActionScheduler::store();
|
85 |
+
$runner = new ActionScheduler_QueueRunner( $store );
|
86 |
+
|
87 |
+
$random = md5(rand());
|
88 |
+
$schedule = new ActionScheduler_IntervalSchedule(as_get_datetime_object('12 hours ago'), DAY_IN_SECONDS);
|
89 |
+
|
90 |
+
$action = new ActionScheduler_Action( $random, array(), $schedule );
|
91 |
+
$store->save_action( $action );
|
92 |
+
|
93 |
+
$runner->run();
|
94 |
+
|
95 |
+
$claim = $store->stake_claim(10, as_get_datetime_object((DAY_IN_SECONDS - 60).' seconds'));
|
96 |
+
$this->assertCount(0, $claim->get_actions());
|
97 |
+
|
98 |
+
$claim = $store->stake_claim(10, as_get_datetime_object(DAY_IN_SECONDS.' seconds'));
|
99 |
+
$actions = $claim->get_actions();
|
100 |
+
$this->assertCount(1, $actions);
|
101 |
+
|
102 |
+
$action_id = reset($actions);
|
103 |
+
$new_action = $store->fetch_action($action_id);
|
104 |
+
|
105 |
+
|
106 |
+
$this->assertEquals( $random, $new_action->get_hook() );
|
107 |
+
$this->assertEquals( $schedule->next(as_get_datetime_object())->getTimestamp(), $new_action->get_schedule()->next(as_get_datetime_object())->getTimestamp() );
|
108 |
+
}
|
109 |
+
|
110 |
+
public function test_hooked_into_wp_cron() {
|
111 |
+
$next = wp_next_scheduled( ActionScheduler_QueueRunner::WP_CRON_HOOK );
|
112 |
+
$this->assertNotEmpty($next);
|
113 |
+
}
|
114 |
+
|
115 |
+
public function test_batch_count_limit() {
|
116 |
+
$store = ActionScheduler::store();
|
117 |
+
$runner = new ActionScheduler_QueueRunner( $store );
|
118 |
+
|
119 |
+
$mock = new MockAction();
|
120 |
+
$random = md5(rand());
|
121 |
+
add_action( $random, array( $mock, 'action' ) );
|
122 |
+
$schedule = new ActionScheduler_SimpleSchedule(new ActionScheduler_DateTime('1 day ago'));
|
123 |
+
|
124 |
+
for ( $i = 0 ; $i < 30 ; $i++ ) {
|
125 |
+
$action = new ActionScheduler_Action( $random, array($random), $schedule );
|
126 |
+
$store->save_action( $action );
|
127 |
+
}
|
128 |
+
|
129 |
+
$claims = array();
|
130 |
+
|
131 |
+
for ( $i = 0 ; $i < 5 ; $i++ ) {
|
132 |
+
$claims[] = $store->stake_claim( 5 );
|
133 |
+
}
|
134 |
+
|
135 |
+
$actions_run = $runner->run();
|
136 |
+
|
137 |
+
|
138 |
+
$this->assertEquals( 0, $mock->get_call_count() );
|
139 |
+
$this->assertEquals( 0, $actions_run );
|
140 |
+
|
141 |
+
$first = reset($claims);
|
142 |
+
$store->release_claim( $first );
|
143 |
+
|
144 |
+
$actions_run = $runner->run();
|
145 |
+
$this->assertEquals( 10, $mock->get_call_count() );
|
146 |
+
$this->assertEquals( 10, $actions_run );
|
147 |
+
|
148 |
+
remove_action( $random, array( $mock, 'action' ) );
|
149 |
+
}
|
150 |
+
|
151 |
+
public function test_changing_batch_count_limit() {
|
152 |
+
$store = ActionScheduler::store();
|
153 |
+
$runner = new ActionScheduler_QueueRunner( $store );
|
154 |
+
|
155 |
+
$random = md5(rand());
|
156 |
+
$schedule = new ActionScheduler_SimpleSchedule(new ActionScheduler_DateTime('1 day ago'));
|
157 |
+
|
158 |
+
for ( $i = 0 ; $i < 30 ; $i++ ) {
|
159 |
+
$action = new ActionScheduler_Action( $random, array($random), $schedule );
|
160 |
+
$store->save_action( $action );
|
161 |
+
}
|
162 |
+
|
163 |
+
$claims = array();
|
164 |
+
|
165 |
+
for ( $i = 0 ; $i < 5 ; $i++ ) {
|
166 |
+
$claims[] = $store->stake_claim( 5 );
|
167 |
+
}
|
168 |
+
|
169 |
+
$mock1 = new MockAction();
|
170 |
+
add_action( $random, array( $mock1, 'action' ) );
|
171 |
+
$actions_run = $runner->run();
|
172 |
+
remove_action( $random, array( $mock1, 'action' ) );
|
173 |
+
|
174 |
+
$this->assertEquals( 0, $mock1->get_call_count() );
|
175 |
+
$this->assertEquals( 0, $actions_run );
|
176 |
+
|
177 |
+
|
178 |
+
add_filter( 'action_scheduler_queue_runner_concurrent_batches', array( $this, 'return_6' ) );
|
179 |
+
|
180 |
+
$mock2 = new MockAction();
|
181 |
+
add_action( $random, array( $mock2, 'action' ) );
|
182 |
+
$actions_run = $runner->run();
|
183 |
+
remove_action( $random, array( $mock2, 'action' ) );
|
184 |
+
|
185 |
+
$this->assertEquals( 5, $mock2->get_call_count() );
|
186 |
+
$this->assertEquals( 5, $actions_run );
|
187 |
+
|
188 |
+
remove_filter( 'action_scheduler_queue_runner_concurrent_batches', array( $this, 'return_6' ) );
|
189 |
+
|
190 |
+
for ( $i = 0 ; $i < 5 ; $i++ ) { // to make up for the actions we just processed
|
191 |
+
$action = new ActionScheduler_Action( $random, array($random), $schedule );
|
192 |
+
$store->save_action( $action );
|
193 |
+
}
|
194 |
+
|
195 |
+
$mock3 = new MockAction();
|
196 |
+
add_action( $random, array( $mock3, 'action' ) );
|
197 |
+
$actions_run = $runner->run();
|
198 |
+
remove_action( $random, array( $mock3, 'action' ) );
|
199 |
+
|
200 |
+
$this->assertEquals( 0, $mock3->get_call_count() );
|
201 |
+
$this->assertEquals( 0, $actions_run );
|
202 |
+
|
203 |
+
remove_filter( 'action_scheduler_queue_runner_concurrent_batches', array( $this, 'return_6' ) );
|
204 |
+
}
|
205 |
+
|
206 |
+
public function return_6() {
|
207 |
+
return 6;
|
208 |
+
}
|
209 |
+
}
|
trunk/includes/lib/action-scheduler/tests/phpunit/schedules/ActionScheduler_CronSchedule_Test.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_CronSchedule_Test
|
5 |
+
* @group schedules
|
6 |
+
*/
|
7 |
+
class ActionScheduler_CronSchedule_Test extends ActionScheduler_UnitTestCase {
|
8 |
+
public function test_creation() {
|
9 |
+
$time = as_get_datetime_object('tomorrow');
|
10 |
+
$cron = CronExpression::factory('@daily');
|
11 |
+
$schedule = new ActionScheduler_CronSchedule(as_get_datetime_object(), $cron);
|
12 |
+
$this->assertEquals( $time, $schedule->next() );
|
13 |
+
}
|
14 |
+
|
15 |
+
public function test_next() {
|
16 |
+
$time = as_get_datetime_object('2013-06-14');
|
17 |
+
$cron = CronExpression::factory('@daily');
|
18 |
+
$schedule = new ActionScheduler_CronSchedule($time, $cron);
|
19 |
+
$this->assertEquals( as_get_datetime_object('tomorrow'), $schedule->next( as_get_datetime_object() ) );
|
20 |
+
}
|
21 |
+
|
22 |
+
public function test_is_recurring() {
|
23 |
+
$schedule = new ActionScheduler_CronSchedule(as_get_datetime_object('2013-06-14'), CronExpression::factory('@daily'));
|
24 |
+
$this->assertTrue( $schedule->is_recurring() );
|
25 |
+
}
|
26 |
+
|
27 |
+
public function test_cron_format() {
|
28 |
+
$time = as_get_datetime_object('2014-01-01');
|
29 |
+
$cron = CronExpression::factory('0 0 10 10 *');
|
30 |
+
$schedule = new ActionScheduler_CronSchedule($time, $cron);
|
31 |
+
$this->assertEquals( as_get_datetime_object('2014-10-10'), $schedule->next() );
|
32 |
+
|
33 |
+
$cron = CronExpression::factory('0 0 L 1/2 *');
|
34 |
+
$schedule = new ActionScheduler_CronSchedule($time, $cron);
|
35 |
+
$this->assertEquals( as_get_datetime_object('2014-01-31'), $schedule->next() );
|
36 |
+
$this->assertEquals( as_get_datetime_object('2014-07-31'), $schedule->next( as_get_datetime_object('2014-06-01') ) );
|
37 |
+
$this->assertEquals( as_get_datetime_object('2028-11-30'), $schedule->next( as_get_datetime_object('2028-11-01') ) );
|
38 |
+
|
39 |
+
$cron = CronExpression::factory('30 14 * * MON#3 *');
|
40 |
+
$schedule = new ActionScheduler_CronSchedule($time, $cron);
|
41 |
+
$this->assertEquals( as_get_datetime_object('2014-01-20 14:30:00'), $schedule->next() );
|
42 |
+
$this->assertEquals( as_get_datetime_object('2014-05-19 14:30:00'), $schedule->next( as_get_datetime_object('2014-05-01') ) );
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
trunk/includes/lib/action-scheduler/tests/phpunit/schedules/ActionScheduler_IntervalSchedule_Test.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_IntervalSchedule_Test
|
5 |
+
* @group schedules
|
6 |
+
*/
|
7 |
+
class ActionScheduler_IntervalSchedule_Test extends ActionScheduler_UnitTestCase {
|
8 |
+
public function test_creation() {
|
9 |
+
$time = as_get_datetime_object();
|
10 |
+
$schedule = new ActionScheduler_IntervalSchedule($time, HOUR_IN_SECONDS);
|
11 |
+
$this->assertEquals( $time, $schedule->next() );
|
12 |
+
}
|
13 |
+
|
14 |
+
public function test_next() {
|
15 |
+
$now = time();
|
16 |
+
$start = $now - 30;
|
17 |
+
$schedule = new ActionScheduler_IntervalSchedule( as_get_datetime_object("@$start"), MINUTE_IN_SECONDS );
|
18 |
+
$this->assertEquals( $start, $schedule->next()->getTimestamp() );
|
19 |
+
$this->assertEquals( $now + MINUTE_IN_SECONDS, $schedule->next(as_get_datetime_object())->getTimestamp() );
|
20 |
+
$this->assertEquals( $start, $schedule->next(as_get_datetime_object("@$start"))->getTimestamp() );
|
21 |
+
}
|
22 |
+
|
23 |
+
public function test_is_recurring() {
|
24 |
+
$start = time() - 30;
|
25 |
+
$schedule = new ActionScheduler_IntervalSchedule( as_get_datetime_object("@$start"), MINUTE_IN_SECONDS );
|
26 |
+
$this->assertTrue( $schedule->is_recurring() );
|
27 |
+
}
|
28 |
+
}
|
trunk/includes/lib/action-scheduler/tests/phpunit/schedules/ActionScheduler_NullSchedule_Test.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_NullSchedule_Test
|
5 |
+
* @group schedules
|
6 |
+
*/
|
7 |
+
class ActionScheduler_NullSchedule_Test extends ActionScheduler_UnitTestCase {
|
8 |
+
public function test_null_schedule() {
|
9 |
+
$schedule = new ActionScheduler_NullSchedule();
|
10 |
+
$this->assertNull( $schedule->next() );
|
11 |
+
}
|
12 |
+
|
13 |
+
public function test_is_recurring() {
|
14 |
+
$schedule = new ActionScheduler_NullSchedule();
|
15 |
+
$this->assertFalse( $schedule->is_recurring() );
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
trunk/includes/lib/action-scheduler/tests/phpunit/schedules/ActionScheduler_SimpleSchedule_Test.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_SimpleSchedule_Test
|
5 |
+
* @group schedules
|
6 |
+
*/
|
7 |
+
class ActionScheduler_SimpleSchedule_Test extends ActionScheduler_UnitTestCase {
|
8 |
+
public function test_creation() {
|
9 |
+
$time = as_get_datetime_object();
|
10 |
+
$schedule = new ActionScheduler_SimpleSchedule($time);
|
11 |
+
$this->assertEquals( $time, $schedule->next() );
|
12 |
+
}
|
13 |
+
|
14 |
+
public function test_past_date() {
|
15 |
+
$time = as_get_datetime_object('-1 day');
|
16 |
+
$schedule = new ActionScheduler_SimpleSchedule($time);
|
17 |
+
$this->assertEquals( $time, $schedule->next() );
|
18 |
+
}
|
19 |
+
|
20 |
+
public function test_future_date() {
|
21 |
+
$time = as_get_datetime_object('+1 day');
|
22 |
+
$schedule = new ActionScheduler_SimpleSchedule($time);
|
23 |
+
$this->assertEquals( $time, $schedule->next() );
|
24 |
+
}
|
25 |
+
|
26 |
+
public function test_grace_period_for_next() {
|
27 |
+
$time = as_get_datetime_object('3 seconds ago');
|
28 |
+
$schedule = new ActionScheduler_SimpleSchedule($time);
|
29 |
+
$this->assertEquals( $time, $schedule->next() );
|
30 |
+
}
|
31 |
+
|
32 |
+
public function test_is_recurring() {
|
33 |
+
$schedule = new ActionScheduler_SimpleSchedule(as_get_datetime_object('+1 day'));
|
34 |
+
$this->assertFalse( $schedule->is_recurring() );
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
trunk/includes/lib/action-scheduler/tests/phpunit/versioning/ActionScheduler_Versions_Test.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_Versions_Test
|
5 |
+
*/
|
6 |
+
class ActionScheduler_Versions_Test extends ActionScheduler_UnitTestCase {
|
7 |
+
public function test_register_version() {
|
8 |
+
$versions = new ActionScheduler_Versions();
|
9 |
+
$versions->register('1.0-dev', 'callback_1_dot_0_dev');
|
10 |
+
$versions->register('1.0', 'callback_1_dot_0');
|
11 |
+
|
12 |
+
$registered = $versions->get_versions();
|
13 |
+
|
14 |
+
$this->assertArrayHasKey( '1.0-dev', $registered );
|
15 |
+
$this->assertArrayHasKey( '1.0', $registered );
|
16 |
+
$this->assertCount( 2, $registered );
|
17 |
+
|
18 |
+
$this->assertEquals( 'callback_1_dot_0_dev', $registered['1.0-dev'] );
|
19 |
+
}
|
20 |
+
|
21 |
+
public function test_duplicate_version() {
|
22 |
+
$versions = new ActionScheduler_Versions();
|
23 |
+
$versions->register('1.0', 'callback_1_dot_0_a');
|
24 |
+
$versions->register('1.0', 'callback_1_dot_0_b');
|
25 |
+
|
26 |
+
$registered = $versions->get_versions();
|
27 |
+
|
28 |
+
$this->assertArrayHasKey( '1.0', $registered );
|
29 |
+
$this->assertCount( 1, $registered );
|
30 |
+
}
|
31 |
+
|
32 |
+
public function test_latest_version() {
|
33 |
+
$versions = new ActionScheduler_Versions();
|
34 |
+
$this->assertEquals('__return_null', $versions->latest_version_callback() );
|
35 |
+
$versions->register('1.2', 'callback_1_dot_2');
|
36 |
+
$versions->register('1.3', 'callback_1_dot_3');
|
37 |
+
$versions->register('1.0', 'callback_1_dot_0');
|
38 |
+
|
39 |
+
$this->assertEquals( '1.3', $versions->latest_version() );
|
40 |
+
$this->assertEquals( 'callback_1_dot_3', $versions->latest_version_callback() );
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
trunk/includes/lib/action-scheduler/tests/travis/setup.sh
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/sh
|
2 |
+
|
3 |
+
# WordPress test setup script for Travis CI
|
4 |
+
#
|
5 |
+
# Author: Benjamin J. Balter ( ben@balter.com | ben.balter.com )
|
6 |
+
# License: GPL3
|
7 |
+
|
8 |
+
export WP_CORE_DIR=/tmp/wordpress
|
9 |
+
export WP_TESTS_DIR=/tmp/wordpress-tests/tests/phpunit
|
10 |
+
|
11 |
+
if [[ "$1" = "5.6" || "$1" > "5.6" ]]
|
12 |
+
then
|
13 |
+
wget -c https://phar.phpunit.de/phpunit-5.7.phar
|
14 |
+
chmod +x phpunit-5.7.phar
|
15 |
+
mv phpunit-5.7.phar `which phpunit`
|
16 |
+
fi
|
17 |
+
|
18 |
+
plugin_slug=$(basename $(pwd))
|
19 |
+
plugin_dir=$WP_CORE_DIR/wp-content/plugins/$plugin_slug
|
20 |
+
|
21 |
+
# Init database
|
22 |
+
mysql -e 'CREATE DATABASE wordpress_test;' -uroot
|
23 |
+
|
24 |
+
# Grab specified version of WordPress from github
|
25 |
+
wget -nv -O /tmp/wordpress.tar.gz https://github.com/WordPress/WordPress/tarball/$WP_VERSION
|
26 |
+
mkdir -p $WP_CORE_DIR
|
27 |
+
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
|
28 |
+
|
29 |
+
# Grab testing framework
|
30 |
+
svn co --quiet https://develop.svn.wordpress.org/tags/$WP_VERSION/ /tmp/wordpress-tests
|
31 |
+
|
32 |
+
# Put various components in proper folders
|
33 |
+
cp tests/travis/wp-tests-config.php $WP_TESTS_DIR/wp-tests-config.php
|
34 |
+
|
35 |
+
cd ..
|
36 |
+
mv $plugin_slug $plugin_dir
|
37 |
+
|
38 |
+
cd $plugin_dir
|
trunk/includes/lib/action-scheduler/tests/travis/wp-tests-config.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* Path to the WordPress codebase you'd like to test. Add a backslash in the end. */
|
4 |
+
define( 'ABSPATH', getenv( 'WP_CORE_DIR' ) . '/' );
|
5 |
+
|
6 |
+
// Test with multisite enabled
|
7 |
+
define( 'WP_TESTS_MULTISITE', (bool) getenv( 'WP_MULTISITE' ) );
|
8 |
+
|
9 |
+
// Force known bugs
|
10 |
+
// define( 'WP_TESTS_FORCE_KNOWN_BUGS', true );
|
11 |
+
|
12 |
+
// Test with WordPress debug mode on
|
13 |
+
define( 'WP_DEBUG', true );
|
14 |
+
|
15 |
+
// ** MySQL settings ** //
|
16 |
+
|
17 |
+
// This configuration file will be used by the copy of WordPress being tested.
|
18 |
+
// wordpress/wp-config.php will be ignored.
|
19 |
+
|
20 |
+
// WARNING WARNING WARNING!
|
21 |
+
// These tests will DROP ALL TABLES in the database with the prefix named below.
|
22 |
+
// DO NOT use a production database or one that is shared with something else.
|
23 |
+
|
24 |
+
define( 'DB_NAME', 'wordpress_test' );
|
25 |
+
define( 'DB_USER', 'root' );
|
26 |
+
define( 'DB_PASSWORD', '' );
|
27 |
+
define( 'DB_HOST', 'localhost' );
|
28 |
+
define( 'DB_CHARSET', 'utf8' );
|
29 |
+
define( 'DB_COLLATE', '' );
|
30 |
+
|
31 |
+
define( 'WP_TESTS_DOMAIN', 'example.org' );
|
32 |
+
define( 'WP_TESTS_EMAIL', 'admin@example.org' );
|
33 |
+
define( 'WP_TESTS_TITLE', 'Test Blog' );
|
34 |
+
|
35 |
+
define( 'WP_PHP_BINARY', 'php' );
|
36 |
+
|
37 |
+
define( 'WPLANG', '' );
|
38 |
+
$table_prefix = 'wptests_';
|
trunk/includes/lib/class-ss-system-info.php
ADDED
@@ -0,0 +1,239 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
4 |
+
|
5 |
+
if ( ! class_exists( 'SS_System_Info' ) ) {
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Helper class for generating system information on WordPress installations
|
9 |
+
*/
|
10 |
+
final class SS_System_Info {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Get system info
|
14 |
+
*
|
15 |
+
* @since 2.0
|
16 |
+
* @access public
|
17 |
+
* @global object $wpdb Used to query the database using the WordPress Database API
|
18 |
+
* @return string $return A string containing the info to output
|
19 |
+
*/
|
20 |
+
public static function get_system_info() {
|
21 |
+
global $wpdb;
|
22 |
+
|
23 |
+
// Get theme info
|
24 |
+
$theme_data = wp_get_theme();
|
25 |
+
$theme = $theme_data->Name . ' ' . $theme_data->Version;
|
26 |
+
|
27 |
+
// Try to identify the hosting provider
|
28 |
+
$host = self::get_host();
|
29 |
+
|
30 |
+
$return = '### Begin System Info ###' . "\n\n";
|
31 |
+
|
32 |
+
// Start with the basics...
|
33 |
+
$return .= '-- Site Info' . "\n\n";
|
34 |
+
$return .= 'Site URL: ' . site_url() . "\n";
|
35 |
+
$return .= 'Home URL: ' . home_url() . "\n";
|
36 |
+
$return .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n";
|
37 |
+
|
38 |
+
// Can we determine the site's host?
|
39 |
+
if( $host ) {
|
40 |
+
$return .= "\n" . '-- Hosting Provider' . "\n\n";
|
41 |
+
$return .= 'Host: ' . $host . "\n";
|
42 |
+
}
|
43 |
+
|
44 |
+
// WordPress configuration
|
45 |
+
$return .= "\n" . '-- WordPress Configuration' . "\n\n";
|
46 |
+
$return .= 'Version: ' . get_bloginfo( 'version' ) . "\n";
|
47 |
+
$return .= 'Language: ' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ) . "\n";
|
48 |
+
$return .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n";
|
49 |
+
$return .= 'Active Theme: ' . $theme . "\n";
|
50 |
+
$return .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n";
|
51 |
+
|
52 |
+
// Only show page specs if frontpage is set to 'page'
|
53 |
+
if( get_option( 'show_on_front' ) == 'page' ) {
|
54 |
+
$front_page_id = get_option( 'page_on_front' );
|
55 |
+
$blog_page_id = get_option( 'page_for_posts' );
|
56 |
+
|
57 |
+
$return .= 'Page On Front: ' . ( $front_page_id != 0 ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n";
|
58 |
+
$return .= 'Page For Posts: ' . ( $blog_page_id != 0 ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n";
|
59 |
+
}
|
60 |
+
|
61 |
+
$return .= 'ABSPATH: ' . ABSPATH . "\n";
|
62 |
+
|
63 |
+
// Make sure wp_remote_post() is working
|
64 |
+
$request['cmd'] = '_notify-validate';
|
65 |
+
|
66 |
+
$params = array(
|
67 |
+
'sslverify' => false,
|
68 |
+
'timeout' => 60,
|
69 |
+
'user-agent' => 'SS_System_Info/',
|
70 |
+
'body' => $request
|
71 |
+
);
|
72 |
+
|
73 |
+
$response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
|
74 |
+
|
75 |
+
if( !is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
|
76 |
+
$WP_REMOTE_POST = 'wp_remote_post() works';
|
77 |
+
} else {
|
78 |
+
$WP_REMOTE_POST = 'wp_remote_post() does not work';
|
79 |
+
}
|
80 |
+
|
81 |
+
$return .= 'Remote Post: ' . $WP_REMOTE_POST . "\n";
|
82 |
+
$return .= 'Table Prefix: ' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n";
|
83 |
+
|
84 |
+
$return .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n";
|
85 |
+
$return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n";
|
86 |
+
$return .= 'Registered Post Stati: ' . implode( ', ', get_post_stati() ) . "\n";
|
87 |
+
|
88 |
+
// Get plugins that have an update
|
89 |
+
$updates = get_plugin_updates();
|
90 |
+
|
91 |
+
// Must-use plugins
|
92 |
+
// NOTE: MU plugins can't show updates!
|
93 |
+
$muplugins = get_mu_plugins();
|
94 |
+
if( count( $muplugins ) > 0 ) {
|
95 |
+
$return .= "\n" . '-- Must-Use Plugins' . "\n\n";
|
96 |
+
|
97 |
+
foreach( $muplugins as $plugin => $plugin_data ) {
|
98 |
+
$return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n";
|
99 |
+
}
|
100 |
+
|
101 |
+
$return = apply_filters( 'edd_sysinfo_after_wordpress_mu_plugins', $return );
|
102 |
+
}
|
103 |
+
|
104 |
+
// WordPress active plugins
|
105 |
+
$return .= "\n" . '-- WordPress Active Plugins' . "\n\n";
|
106 |
+
|
107 |
+
$plugins = get_plugins();
|
108 |
+
$active_plugins = get_option( 'active_plugins', array() );
|
109 |
+
|
110 |
+
foreach( $plugins as $plugin_path => $plugin ) {
|
111 |
+
if( !in_array( $plugin_path, $active_plugins ) )
|
112 |
+
continue;
|
113 |
+
|
114 |
+
$update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
|
115 |
+
$return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
|
116 |
+
}
|
117 |
+
|
118 |
+
// WordPress inactive plugins
|
119 |
+
$return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
|
120 |
+
|
121 |
+
foreach( $plugins as $plugin_path => $plugin ) {
|
122 |
+
if( in_array( $plugin_path, $active_plugins ) )
|
123 |
+
continue;
|
124 |
+
|
125 |
+
$update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
|
126 |
+
$return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
|
127 |
+
}
|
128 |
+
|
129 |
+
if( is_multisite() ) {
|
130 |
+
// WordPress Multisite active plugins
|
131 |
+
$return .= "\n" . '-- Network Active Plugins' . "\n\n";
|
132 |
+
|
133 |
+
$plugins = wp_get_active_network_plugins();
|
134 |
+
$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
|
135 |
+
|
136 |
+
foreach( $plugins as $plugin_path ) {
|
137 |
+
$plugin_base = plugin_basename( $plugin_path );
|
138 |
+
|
139 |
+
if( !array_key_exists( $plugin_base, $active_plugins ) )
|
140 |
+
continue;
|
141 |
+
|
142 |
+
$update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
|
143 |
+
$plugin = get_plugin_data( $plugin_path );
|
144 |
+
$return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
|
145 |
+
}
|
146 |
+
|
147 |
+
}
|
148 |
+
|
149 |
+
// Server configuration (really just versioning)
|
150 |
+
$return .= "\n" . '-- Webserver Configuration' . "\n\n";
|
151 |
+
$return .= 'PHP Version: ' . PHP_VERSION . "\n";
|
152 |
+
$return .= 'MySQL Version: ' . $wpdb->db_version() . "\n";
|
153 |
+
$return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n";
|
154 |
+
|
155 |
+
// PHP configs... now we're getting to the important stuff
|
156 |
+
$return .= "\n" . '-- PHP Configuration' . "\n\n";
|
157 |
+
$return .= 'Safe Mode: ' . ( ini_get( 'safe_mode' ) ? 'Enabled' : 'Disabled' . "\n" );
|
158 |
+
$return .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n";
|
159 |
+
$return .= 'Upload Max Size: ' . ini_get( 'upload_max_filesize' ) . "\n";
|
160 |
+
$return .= 'Post Max Size: ' . ini_get( 'post_max_size' ) . "\n";
|
161 |
+
$return .= 'Upload Max Filesize: ' . ini_get( 'upload_max_filesize' ) . "\n";
|
162 |
+
$return .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n";
|
163 |
+
$return .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n";
|
164 |
+
$return .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n";
|
165 |
+
$return .= 'PHP Arg Separator: ' . ini_get( 'arg_separator.output' ) . "\n";
|
166 |
+
|
167 |
+
// PHP extensions and such
|
168 |
+
$return .= "\n" . '-- PHP Extensions' . "\n\n";
|
169 |
+
$return .= 'cURL: ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n";
|
170 |
+
$return .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n";
|
171 |
+
$return .= 'SOAP Client: ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n";
|
172 |
+
$return .= 'Suhosin: ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n";
|
173 |
+
|
174 |
+
$return = apply_filters( 'edd_sysinfo_after_php_ext', $return );
|
175 |
+
|
176 |
+
// Session stuff
|
177 |
+
$return .= "\n" . '-- Session Configuration' . "\n\n";
|
178 |
+
$return .= 'Session: ' . ( isset( $_SESSION ) ? 'Enabled' : 'Disabled' ) . "\n";
|
179 |
+
|
180 |
+
// The rest of this is only relevant is session is enabled
|
181 |
+
if( isset( $_SESSION ) ) {
|
182 |
+
$return .= 'Session Name: ' . esc_html( ini_get( 'session.name' ) ) . "\n";
|
183 |
+
$return .= 'Cookie Path: ' . esc_html( ini_get( 'session.cookie_path' ) ) . "\n";
|
184 |
+
$return .= 'Save Path: ' . esc_html( ini_get( 'session.save_path' ) ) . "\n";
|
185 |
+
$return .= 'Use Cookies: ' . ( ini_get( 'session.use_cookies' ) ? 'On' : 'Off' ) . "\n";
|
186 |
+
$return .= 'Use Only Cookies: ' . ( ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off' ) . "\n";
|
187 |
+
}
|
188 |
+
|
189 |
+
$return .= "\n" . '### End System Info ###';
|
190 |
+
|
191 |
+
return $return;
|
192 |
+
|
193 |
+
} //end function sysinfo_get
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Get user host
|
197 |
+
*
|
198 |
+
* Returns the webhost this site is using if possible
|
199 |
+
*
|
200 |
+
* @since 2.0
|
201 |
+
* @return mixed string $host if detected, false otherwise
|
202 |
+
*/
|
203 |
+
public static function get_host() {
|
204 |
+
$host = false;
|
205 |
+
|
206 |
+
if( defined( 'WPE_APIKEY' ) ) {
|
207 |
+
$host = 'WP Engine';
|
208 |
+
} elseif( defined( 'PAGELYBIN' ) ) {
|
209 |
+
$host = 'Pagely';
|
210 |
+
} elseif( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
|
211 |
+
$host = 'ICDSoft';
|
212 |
+
} elseif( DB_HOST == 'mysqlv5' ) {
|
213 |
+
$host = 'NetworkSolutions';
|
214 |
+
} elseif( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
|
215 |
+
$host = 'iPage';
|
216 |
+
} elseif( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
|
217 |
+
$host = 'IPower';
|
218 |
+
} elseif( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
|
219 |
+
$host = 'MediaTemple Grid';
|
220 |
+
} elseif( strpos( DB_HOST, '.pair.com' ) !== false ) {
|
221 |
+
$host = 'pair Networks';
|
222 |
+
} elseif( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
|
223 |
+
$host = 'Rackspace Cloud';
|
224 |
+
} elseif( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
|
225 |
+
$host = 'SysFix.eu Power Hosting';
|
226 |
+
} elseif( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
|
227 |
+
$host = 'Flywheel';
|
228 |
+
} else {
|
229 |
+
// Adding a general fallback for data gathering
|
230 |
+
$host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
|
231 |
+
}
|
232 |
+
|
233 |
+
return $host;
|
234 |
+
|
235 |
+
} //end function get_host
|
236 |
+
|
237 |
+
}
|
238 |
+
|
239 |
+
}
|
trunk/includes/migrations/class-ss-wc-migration-from-1.3.X-to-2.0.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
final class SS_WC_MailChimp_Migration_From_1_3_X_To_2_0 extends SS_WC_MailChimp_Migration {
|
4 |
+
|
5 |
+
protected $interest_groupings;
|
6 |
+
|
7 |
+
public function __construct( $current_version, $target_version ) {
|
8 |
+
parent::__construct( $current_version, $target_version );
|
9 |
+
}
|
10 |
+
|
11 |
+
/**
|
12 |
+
* [up description]
|
13 |
+
* @return [type] [description]
|
14 |
+
*/
|
15 |
+
public function up() {
|
16 |
+
|
17 |
+
$interest_groupings_key = 'interest_groupings';
|
18 |
+
$groups_key = 'groups';
|
19 |
+
|
20 |
+
try {
|
21 |
+
|
22 |
+
if ( !array_key_exists( $interest_groupings_key, $this->settings ) || !array_key_exists( $groups_key, $this->settings ) ) return;
|
23 |
+
|
24 |
+
$list = $this->settings['list'];
|
25 |
+
$this->interest_groupings = $this->settings[$interest_groupings_key];
|
26 |
+
$groups = $this->settings[$groups_key];
|
27 |
+
|
28 |
+
if ( empty( $this->interest_groupings ) || empty( $groups ) || empty( $list ) ) return;
|
29 |
+
|
30 |
+
$interest_categories = $this->mailchimp->get_interest_categories( $list );
|
31 |
+
|
32 |
+
$selected_interest_category = array_filter( $interest_categories, array( $this, 'filter_interest_groups' ) );
|
33 |
+
|
34 |
+
$selected_interest_category_id = key( $selected_interest_category );
|
35 |
+
|
36 |
+
$interest_category_interests = $this->mailchimp->get_interest_category_interests( $list, $selected_interest_category_id );
|
37 |
+
|
38 |
+
$groups = explode( ',', $groups );
|
39 |
+
|
40 |
+
$selected_interest_category_interests = array_intersect( $interest_category_interests, $groups );
|
41 |
+
|
42 |
+
$interest_groups = array_keys($selected_interest_category_interests);
|
43 |
+
|
44 |
+
$this->settings['interest_groups'] = $interest_groups;
|
45 |
+
|
46 |
+
unset($this->settings[$interest_groupings_key]);
|
47 |
+
unset($this->settings[$groups_key]);
|
48 |
+
|
49 |
+
$this->save_settings();
|
50 |
+
} catch (Exception $e) {
|
51 |
+
// If all else fails, finish the upgrade and the user will have to reselect the interest groups.
|
52 |
+
unset($this->settings[$interest_groupings_key]);
|
53 |
+
unset($this->settings[$groups_key]);
|
54 |
+
|
55 |
+
$this->save_settings();
|
56 |
+
}
|
57 |
+
|
58 |
+
return true;
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
public function filter_interest_groups( $interest_group ) {
|
63 |
+
return $interest_group == $this->interest_groupings;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* [down description]
|
68 |
+
* @return [type] [description]
|
69 |
+
*/
|
70 |
+
public function down() {
|
71 |
+
|
72 |
+
throw new Exception('Cannot rollback to versions prior to 2.0');
|
73 |
+
|
74 |
+
}
|
75 |
+
|
76 |
+
}
|
trunk/includes/migrations/class-ss-wc-migration-from-2.0-to-2.0.15.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
final class SS_WC_MailChimp_Migration_From_2_0_To_2_0_15 extends SS_WC_MailChimp_Migration {
|
4 |
+
|
5 |
+
public function __construct( $current_version, $target_version ) {
|
6 |
+
parent::__construct( $current_version, $target_version );
|
7 |
+
}
|
8 |
+
|
9 |
+
/**
|
10 |
+
* [up description]
|
11 |
+
* @return [type] [description]
|
12 |
+
*/
|
13 |
+
public function up() {
|
14 |
+
|
15 |
+
try {
|
16 |
+
|
17 |
+
$wrong_double_optin_setting_name = $this->namespace_prefixed('double_optin' );
|
18 |
+
|
19 |
+
if ( !$wrong_double_optin_setting = get_option( $wrong_double_optin_setting_name ) ) {
|
20 |
+
// we didn't find the wrong double optin setting (ss_wc_mailchimp_double_optin) saved in the database, so nothing to do
|
21 |
+
return true;
|
22 |
+
}
|
23 |
+
|
24 |
+
// Let's set the correct double opt in setting
|
25 |
+
$this->settings['double_opt_in'] = $wrong_double_optin_setting;
|
26 |
+
|
27 |
+
// Save the settings
|
28 |
+
$this->save_settings();
|
29 |
+
|
30 |
+
// Finally, let's delete the wrong setting so we don't cause any confusion
|
31 |
+
delete_option( $wrong_double_optin_setting_name );
|
32 |
+
|
33 |
+
} catch (Exception $e) {
|
34 |
+
return false;
|
35 |
+
}
|
36 |
+
|
37 |
+
return true;
|
38 |
+
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* [down description]
|
43 |
+
* @return [type] [description]
|
44 |
+
*/
|
45 |
+
public function down() {
|
46 |
+
|
47 |
+
throw new Exception('Cannot rollback to versions prior to 2.0.15');
|
48 |
+
|
49 |
+
}
|
50 |
+
|
51 |
+
}
|
trunk/includes/migrations/class-ss-wc-migration.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
abstract class SS_WC_MailChimp_Migration {
|
4 |
+
|
5 |
+
protected $mailchimp;
|
6 |
+
|
7 |
+
protected $settings;
|
8 |
+
|
9 |
+
protected $namespace = 'ss_wc_mailchimp';
|
10 |
+
|
11 |
+
protected $current_version;
|
12 |
+
protected $target_version;
|
13 |
+
|
14 |
+
protected $setting_keys;
|
15 |
+
|
16 |
+
protected $settings_key = 'woocommerce_mailchimp_settings';
|
17 |
+
|
18 |
+
public function __construct( $current_version, $target_version ) {
|
19 |
+
|
20 |
+
$this->setting_keys = array(
|
21 |
+
'api_key',
|
22 |
+
'enabled',
|
23 |
+
'list',
|
24 |
+
'interest_groups',
|
25 |
+
'display_opt_in',
|
26 |
+
'occurs',
|
27 |
+
'double_opt_in',
|
28 |
+
'opt_in_label',
|
29 |
+
'opt_in_checkbox_default_status',
|
30 |
+
'opt_in_checkbox_display_location',
|
31 |
+
);
|
32 |
+
|
33 |
+
$this->settings = array();
|
34 |
+
|
35 |
+
$this->current_version = $current_version;
|
36 |
+
$this->target_version = $target_version;
|
37 |
+
|
38 |
+
if ( ! $this->load_settings() ) return;
|
39 |
+
|
40 |
+
if ( empty( $this->settings['api_key'] ) ) return;
|
41 |
+
|
42 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp.php' );
|
43 |
+
$this->mailchimp = new SS_WC_MailChimp( $this->settings['api_key'] );
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* [save_settings description]
|
48 |
+
* @return [type] [description]
|
49 |
+
*/
|
50 |
+
public function load_settings() {
|
51 |
+
|
52 |
+
if ( $this->current_version === '1.3.X' ) {
|
53 |
+
|
54 |
+
if ( ! $this->settings = get_option( $this->settings_key ) ) {
|
55 |
+
return false;
|
56 |
+
}
|
57 |
+
|
58 |
+
if ( !is_array( $this->settings ) ) {
|
59 |
+
return false;
|
60 |
+
}
|
61 |
+
|
62 |
+
} else {
|
63 |
+
|
64 |
+
foreach ( $this->setting_keys as $key ) {
|
65 |
+
$this->settings[ $key ] = get_option( $this->namespace_prefixed( $key ) );
|
66 |
+
}
|
67 |
+
|
68 |
+
}
|
69 |
+
|
70 |
+
return true;
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* [save_settings description]
|
76 |
+
* @return [type] [description]
|
77 |
+
*/
|
78 |
+
public function save_settings() {
|
79 |
+
|
80 |
+
if ( $this->target_version === '1.3.X' ) {
|
81 |
+
|
82 |
+
update_option( $this->settings_key , $this->settings );
|
83 |
+
|
84 |
+
} else {
|
85 |
+
|
86 |
+
foreach ( $this->settings as $key => $value ) {
|
87 |
+
update_option( $this->namespace_prefixed( $key ), $value );
|
88 |
+
}
|
89 |
+
|
90 |
+
}
|
91 |
+
|
92 |
+
}
|
93 |
+
|
94 |
+
protected function namespace_prefixed( $suffix ) {
|
95 |
+
return $this->namespace . '_' . $suffix;
|
96 |
+
}
|
97 |
+
|
98 |
+
}
|
trunk/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
trunk/languages/woocommerce-mailchimp-fr_FR.mo
ADDED
Binary file
|
trunk/languages/woocommerce-mailchimp-fr_FR.po
ADDED
@@ -0,0 +1,273 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2014 WooCommerce MailChimp
|
2 |
+
# This file is distributed under the same license as the WooCommerce MailChimp package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: WooCommerce MailChimp 1.1.3\n"
|
6 |
+
"Report-Msgid-Bugs-To: http://wordpress.org/tag/woocommerce-mailchimp\n"
|
7 |
+
"POT-Creation-Date: 2015-02-06 15:05+0200\n"
|
8 |
+
"PO-Revision-Date: 2015-02-06 09:54-0600\n"
|
9 |
+
"Last-Translator: Vincent Pintat <vincent@walliecreation.com>\n"
|
10 |
+
"Language-Team: \n"
|
11 |
+
"Language: fr_FR\n"
|
12 |
+
"MIME-Version: 1.0\n"
|
13 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
14 |
+
"Content-Transfer-Encoding: 8bit\n"
|
15 |
+
"X-Generator: Poedit 1.7.4\n"
|
16 |
+
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
17 |
+
|
18 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:31
|
19 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:518
|
20 |
+
msgid "MailChimp"
|
21 |
+
msgstr "MailChimp"
|
22 |
+
|
23 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:32
|
24 |
+
msgid "MailChimp is a popular email marketing service."
|
25 |
+
msgstr "MailChimp est un service d'emailing marketing très populaire."
|
26 |
+
|
27 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:82
|
28 |
+
#, php-format
|
29 |
+
msgid ""
|
30 |
+
"WooCommerce MailChimp error: Plugin is enabled but no api key provided. Please enter "
|
31 |
+
"your api key <a href=\"%s\">here</a>."
|
32 |
+
msgstr ""
|
33 |
+
"Erreur WooCommerce MailChimp : Le plugin est activé mais la clé d'API n'a pas été "
|
34 |
+
"renseignée. Entrez votre clé d'API <a href=\"%s\">ici</a>"
|
35 |
+
|
36 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:101
|
37 |
+
#, php-format
|
38 |
+
msgid "Order Opt-In Value: %s"
|
39 |
+
msgstr ""
|
40 |
+
|
41 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:107
|
42 |
+
#, php-format
|
43 |
+
msgid "Subscribe customer (%s) to list %s"
|
44 |
+
msgstr ""
|
45 |
+
|
46 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:177
|
47 |
+
msgid "Select a list..."
|
48 |
+
msgstr "Sélectionnez une liste..."
|
49 |
+
|
50 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:180
|
51 |
+
msgid "Enter your key and save to see your lists"
|
52 |
+
msgstr "Entrez votre clé et enregistrez pour voir vos listes"
|
53 |
+
|
54 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:185
|
55 |
+
msgid "Enable/Disable"
|
56 |
+
msgstr "Activer/Désactiver"
|
57 |
+
|
58 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:186
|
59 |
+
msgid "Enable MailChimp"
|
60 |
+
msgstr "Activer MailChimp"
|
61 |
+
|
62 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:192
|
63 |
+
msgid "Subscribe Event"
|
64 |
+
msgstr "Evénément d'inscription"
|
65 |
+
|
66 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:194
|
67 |
+
msgid "When should customers be subscribed to lists?"
|
68 |
+
msgstr "Quand les abonnés doivent-ils être inscrits aux listes ?"
|
69 |
+
|
70 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:197
|
71 |
+
msgid "Order Created"
|
72 |
+
msgstr "Commande crée"
|
73 |
+
|
74 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:198
|
75 |
+
msgid "Order Processing"
|
76 |
+
msgstr "Commande"
|
77 |
+
|
78 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:199
|
79 |
+
msgid "Order Completed"
|
80 |
+
msgstr "Commande terminée"
|
81 |
+
|
82 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:203
|
83 |
+
msgid "API Key"
|
84 |
+
msgstr "Clé d'API"
|
85 |
+
|
86 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:205
|
87 |
+
msgid ""
|
88 |
+
"<a href=\"https://us2.admin.mailchimp.com/account/api/\" target=\"_blank\">Login to "
|
89 |
+
"mailchimp</a> to look up your api key."
|
90 |
+
msgstr ""
|
91 |
+
"<a href=\"https://us2.admin.mailchimp.com/account/api/\" target=\"_blank\">Connectez-"
|
92 |
+
"vous à MailChimp</a> pour voir votre clé d'API."
|
93 |
+
|
94 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:209
|
95 |
+
msgid "Main List"
|
96 |
+
msgstr "Liste principale"
|
97 |
+
|
98 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:211
|
99 |
+
msgid "All customers will be added to this list."
|
100 |
+
msgstr "Tous les clients seront ajoutés à cette liste."
|
101 |
+
|
102 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:216
|
103 |
+
msgid "Group Name"
|
104 |
+
msgstr "Nom du groupe"
|
105 |
+
|
106 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:218
|
107 |
+
msgid ""
|
108 |
+
"Optional: Enter the name of the group. Learn more about <a href=\"http://mailchimp."
|
109 |
+
"com/features/groups\" target=\"_blank\">Groups</a>"
|
110 |
+
msgstr ""
|
111 |
+
"Optionnel : Entrez le nom du groupe. Apprenez-en plus au sujet des <a href=\"http://"
|
112 |
+
"mailchimp.com/features/groups\" target=\"_blank\">Groupes</a>"
|
113 |
+
|
114 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:222
|
115 |
+
msgid "Groups"
|
116 |
+
msgstr "Groupes"
|
117 |
+
|
118 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:224
|
119 |
+
msgid ""
|
120 |
+
"Optional: Comma separated list of interest groups to which subscribers should be "
|
121 |
+
"added."
|
122 |
+
msgstr ""
|
123 |
+
"Optionnel : Liste des groupes d'intérêt auxquels ajouter les nouveaux inscrits, "
|
124 |
+
"séparés par des virgules."
|
125 |
+
|
126 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:228
|
127 |
+
msgid "Double Opt-In"
|
128 |
+
msgstr "Double validation"
|
129 |
+
|
130 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:229
|
131 |
+
msgid "Enable Double Opt-In"
|
132 |
+
msgstr "Activer la double validation"
|
133 |
+
|
134 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:231
|
135 |
+
msgid ""
|
136 |
+
"If enabled, customers will receive an email prompting them to confirm their "
|
137 |
+
"subscription to the list above."
|
138 |
+
msgstr ""
|
139 |
+
"Si activé, les clients recevront un email les incitant à confirmer leur inscription "
|
140 |
+
"à la liste ci-dessus."
|
141 |
+
|
142 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:235
|
143 |
+
msgid "Display Opt-In Field"
|
144 |
+
msgstr "Afficher le champs choix d'inscription"
|
145 |
+
|
146 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:236
|
147 |
+
msgid "Display an Opt-In Field on Checkout"
|
148 |
+
msgstr "Afficher un champs de choix d'inscription sur la page Commande (checkout)"
|
149 |
+
|
150 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:238
|
151 |
+
msgid ""
|
152 |
+
"If enabled, customers will be presented with a \"Opt-in\" checkbox during checkout "
|
153 |
+
"and will only be added to the list above if they opt-in."
|
154 |
+
msgstr ""
|
155 |
+
"Si activé, une case à cocher de choix d'inscription sera affichée aux clients "
|
156 |
+
"pendant le processus de commande. Les clients choisissant de s'inscrire seront "
|
157 |
+
"ajoutés à la liste ce-dessus s'ils cochent la case."
|
158 |
+
|
159 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:242
|
160 |
+
msgid "Opt-In Field Label"
|
161 |
+
msgstr "Label du champs \"choix d'inscription\""
|
162 |
+
|
163 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:244
|
164 |
+
msgid "Optional: customize the label displayed next to the opt-in checkbox."
|
165 |
+
msgstr "Optionnel : personnalisez le label affiché à côté de la case à cocher."
|
166 |
+
|
167 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:245
|
168 |
+
msgid "Add me to the newsletter (we will never share your email)."
|
169 |
+
msgstr "M'inscrire à la newsletter (votre email restera confidentiel)"
|
170 |
+
|
171 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:248
|
172 |
+
msgid "Opt-In Checkbox Default Status"
|
173 |
+
msgstr "Etat par défaut de la case à cocher"
|
174 |
+
|
175 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:250
|
176 |
+
msgid "The default state of the opt-in checkbox."
|
177 |
+
msgstr "L'état par défaut de la case à cocher"
|
178 |
+
|
179 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:253
|
180 |
+
msgid "Checked"
|
181 |
+
msgstr "Coché"
|
182 |
+
|
183 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:254
|
184 |
+
msgid "Unchecked"
|
185 |
+
msgstr "Non coché"
|
186 |
+
|
187 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:258
|
188 |
+
msgid "Opt-In Checkbox Display Location"
|
189 |
+
msgstr "Localisation de la case à cocher d'inscription"
|
190 |
+
|
191 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:260
|
192 |
+
msgid ""
|
193 |
+
"Where to display the opt-in checkbox on the checkout page (under Billing info or "
|
194 |
+
"Order info)."
|
195 |
+
msgstr ""
|
196 |
+
"Où afficher la case à cocher sur la page de commande (en dessous de Facturation ou "
|
197 |
+
"Récapitulatif de commande). "
|
198 |
+
|
199 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:263
|
200 |
+
msgid "Billing"
|
201 |
+
msgstr "Facturation"
|
202 |
+
|
203 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:264
|
204 |
+
msgid "Order"
|
205 |
+
msgstr "Commande"
|
206 |
+
|
207 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:378
|
208 |
+
#, php-format
|
209 |
+
msgid "Unable to load lists from MailChimp: (%s) %s. "
|
210 |
+
msgstr ""
|
211 |
+
|
212 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:379
|
213 |
+
#, php-format
|
214 |
+
msgid "Please check your %s <a href=\"%s\">settings</a>."
|
215 |
+
msgstr ""
|
216 |
+
|
217 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:399
|
218 |
+
#, php-format
|
219 |
+
msgid "Unable to load listInterestGroupings() from MailChimp: (%s) %s"
|
220 |
+
msgstr "Impossible de charger listInterestGroupings() depuis MailChimp: (%s) %s"
|
221 |
+
|
222 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:483
|
223 |
+
#, php-format
|
224 |
+
msgid "Calling MailChimp API listSubscribe method with the following: %s"
|
225 |
+
msgstr ""
|
226 |
+
|
227 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:489
|
228 |
+
#, php-format
|
229 |
+
msgid "MailChimp API response: %s"
|
230 |
+
msgstr ""
|
231 |
+
|
232 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:493
|
233 |
+
#, php-format
|
234 |
+
msgid "WooCommerce MailChimp subscription failed: %s (%s)"
|
235 |
+
msgstr ""
|
236 |
+
|
237 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:505
|
238 |
+
msgid "WooCommerce MailChimp subscription failed"
|
239 |
+
msgstr "L'inscription à WooCommerce MailChimp a échoué"
|
240 |
+
|
241 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:519
|
242 |
+
msgid ""
|
243 |
+
"Enter your MailChimp settings below to control how WooCommerce integrates with your "
|
244 |
+
"MailChimp lists."
|
245 |
+
msgstr ""
|
246 |
+
"Entrez vos paramètres MailChimp ci-dessous pour contrôler comment WooCommerce "
|
247 |
+
"s'intègre à vos listes MailChimp."
|
248 |
+
|
249 |
+
#: ../woocommerce-mailchimp.php:60
|
250 |
+
msgid "Settings"
|
251 |
+
msgstr "Paramètres"
|
252 |
+
|
253 |
+
#~ msgid "Unable to load lists from MailChimp: (%s) %s."
|
254 |
+
#~ msgstr "Impossible de charger les listes depuis MailChimp : (%s) %s"
|
255 |
+
|
256 |
+
#~ msgid "WooCommerce MailChimp"
|
257 |
+
#~ msgstr "WooCommerce MailChimp"
|
258 |
+
|
259 |
+
#~ msgid "http://anderly.com/woocommerce-mailchimp"
|
260 |
+
#~ msgstr "http://anderly.com/woocommerce-mailchimp"
|
261 |
+
|
262 |
+
#~ msgid "WooCommerce MailChimp provides simple MailChimp integration for WooCommerce."
|
263 |
+
#~ msgstr ""
|
264 |
+
#~ "WooCommerce MailChimp fourni une intégration simple de MailChimp dans WooCommerce."
|
265 |
+
|
266 |
+
#~ msgid "Adam Anderly"
|
267 |
+
#~ msgstr "Adam Anderly"
|
268 |
+
|
269 |
+
#~ msgid "http://anderly.com"
|
270 |
+
#~ msgstr "http://anderly.com"
|
271 |
+
|
272 |
+
#~ msgid "Email subscription failed (Mailchimp)"
|
273 |
+
#~ msgstr "Inscription de cet email échouée (MailChimp)"
|
trunk/languages/woocommerce-mailchimp.pot
ADDED
@@ -0,0 +1,404 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#, fuzzy
|
2 |
+
msgid ""
|
3 |
+
msgstr ""
|
4 |
+
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
5 |
+
"Project-Id-Version: WooCommerce MailChimp\n"
|
6 |
+
"POT-Creation-Date: 2016-09-20 10:27-0500\n"
|
7 |
+
"PO-Revision-Date: 2016-09-20 10:27-0500\n"
|
8 |
+
"Last-Translator: Adam Anderly <adam.anderly@saintsystems.com>\n"
|
9 |
+
"Language-Team: Adam Anderly <adam.anderly@saintsystems.com>\n"
|
10 |
+
"MIME-Version: 1.0\n"
|
11 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
12 |
+
"Content-Transfer-Encoding: 8bit\n"
|
13 |
+
"X-Generator: Poedit 1.8.9\n"
|
14 |
+
"X-Poedit-Basepath: ..\n"
|
15 |
+
"X-Poedit-WPHeader: woocommerce-mailchimp.php\n"
|
16 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
17 |
+
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
|
18 |
+
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
|
19 |
+
"_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
|
20 |
+
"X-Poedit-SearchPath-0: .\n"
|
21 |
+
"X-Poedit-SearchPathExcluded-0: *.js\n"
|
22 |
+
|
23 |
+
#: config/default-settings.php:10
|
24 |
+
#: includes/class-ss-wc-settings-mailchimp.php:421
|
25 |
+
msgid "Subscribe to our newsletter"
|
26 |
+
msgstr ""
|
27 |
+
|
28 |
+
#: includes/class-ss-wc-mailchimp-admin-notices.php:166
|
29 |
+
msgid "Dismiss"
|
30 |
+
msgstr ""
|
31 |
+
|
32 |
+
#: includes/class-ss-wc-mailchimp-compatibility.php:158
|
33 |
+
msgid ""
|
34 |
+
"You are seeing this notice because you are an administrator. Other users of "
|
35 |
+
"the site will see nothing."
|
36 |
+
msgstr ""
|
37 |
+
|
38 |
+
#: includes/class-ss-wc-mailchimp-compatibility.php:179
|
39 |
+
#, php-format
|
40 |
+
msgid ""
|
41 |
+
"%sWooCommerce MailChimp requires PHP Version %s or newer.%s \n"
|
42 |
+
"\n"
|
43 |
+
"You're using Version %s. Please ask your host to upgrade your server's PHP."
|
44 |
+
msgstr ""
|
45 |
+
|
46 |
+
#: includes/class-ss-wc-mailchimp-compatibility.php:201
|
47 |
+
#, php-format
|
48 |
+
msgid ""
|
49 |
+
"%sWooCommerce MailChimp requires WordPress %s or newer.%s \n"
|
50 |
+
"\n"
|
51 |
+
"You're using Version %s. Please upgrade your WordPress installation."
|
52 |
+
msgstr ""
|
53 |
+
|
54 |
+
#: includes/class-ss-wc-mailchimp-compatibility.php:253
|
55 |
+
#, php-format
|
56 |
+
msgid ""
|
57 |
+
"%sWooCommerce MailChimp requires WooCommerce Version %s or newer.%s You're "
|
58 |
+
"using Version %s. %sUpdate WooCommerce%s to use the WooCommerce MailChimp "
|
59 |
+
"plugin."
|
60 |
+
msgstr ""
|
61 |
+
|
62 |
+
#: includes/class-ss-wc-mailchimp-compatibility.php:288
|
63 |
+
#, php-format
|
64 |
+
msgid ""
|
65 |
+
"%sWooCommerce MailChimp requires WooCommerce to be active. %sActivate "
|
66 |
+
"WooCommerce%s to use the WooCommerce MailChimp plugin."
|
67 |
+
msgstr ""
|
68 |
+
|
69 |
+
#: includes/class-ss-wc-mailchimp-compatibility.php:293
|
70 |
+
#, php-format
|
71 |
+
msgid ""
|
72 |
+
"%sWooCommerce MailChimp requires WooCommerce to be installed in order to run "
|
73 |
+
"properly. %sInstall WooCommerce%s to use the WooCommerce MailChimp plugin."
|
74 |
+
msgstr ""
|
75 |
+
|
76 |
+
#: includes/class-ss-wc-mailchimp-handler.php:35
|
77 |
+
#: includes/class-ss-wc-settings-mailchimp.php:46
|
78 |
+
#: includes/class-ss-wc-settings-mailchimp.php:313
|
79 |
+
msgid "MailChimp"
|
80 |
+
msgstr ""
|
81 |
+
|
82 |
+
#: includes/class-ss-wc-mailchimp-handler.php:213
|
83 |
+
#, php-format
|
84 |
+
msgid "(): Subscribing customer (%s) to list %s"
|
85 |
+
msgstr ""
|
86 |
+
|
87 |
+
#: includes/class-ss-wc-mailchimp-handler.php:285
|
88 |
+
msgid "Please enter an api key."
|
89 |
+
msgstr ""
|
90 |
+
|
91 |
+
#: includes/class-ss-wc-mailchimp-handler.php:318
|
92 |
+
#: includes/class-ss-wc-mailchimp-handler.php:351
|
93 |
+
msgid "Enter your api key above to see your lists"
|
94 |
+
msgstr ""
|
95 |
+
|
96 |
+
#: includes/class-ss-wc-mailchimp-handler.php:357
|
97 |
+
msgid "Please select a list from above."
|
98 |
+
msgstr ""
|
99 |
+
|
100 |
+
#: includes/class-ss-wc-mailchimp-handler.php:490
|
101 |
+
#, php-format
|
102 |
+
msgid "(): Subscribing customer to MailChimp: %s"
|
103 |
+
msgstr ""
|
104 |
+
|
105 |
+
#: includes/class-ss-wc-mailchimp-handler.php:496
|
106 |
+
#, php-format
|
107 |
+
msgid "(): MailChimp API response: %s"
|
108 |
+
msgstr ""
|
109 |
+
|
110 |
+
#: includes/class-ss-wc-mailchimp-handler.php:500
|
111 |
+
#, php-format
|
112 |
+
msgid "(): WooCommerce MailChimp subscription failed: %s (%s)"
|
113 |
+
msgstr ""
|
114 |
+
|
115 |
+
#: includes/class-ss-wc-mailchimp-handler.php:509
|
116 |
+
msgid "WooCommerce MailChimp subscription failed"
|
117 |
+
msgstr ""
|
118 |
+
|
119 |
+
#: includes/class-ss-wc-mailchimp-plugin.php:281
|
120 |
+
msgid "Settings"
|
121 |
+
msgstr ""
|
122 |
+
|
123 |
+
#: includes/class-ss-wc-mailchimp-plugin.php:313
|
124 |
+
msgid "Connecting to MailChimp"
|
125 |
+
msgstr ""
|
126 |
+
|
127 |
+
#: includes/class-ss-wc-mailchimp-plugin.php:314
|
128 |
+
msgid "Error. Please check your api key."
|
129 |
+
msgstr ""
|
130 |
+
|
131 |
+
#: includes/class-ss-wc-mailchimp-plugin.php:315
|
132 |
+
msgid ""
|
133 |
+
"Error loading groups. Please check your MailChimp Interest Groups for the "
|
134 |
+
"selected list."
|
135 |
+
msgstr ""
|
136 |
+
|
137 |
+
#: includes/class-ss-wc-mailchimp-plugin.php:316
|
138 |
+
msgid "Select one or more groups (optional)"
|
139 |
+
msgstr ""
|
140 |
+
|
141 |
+
#: includes/class-ss-wc-mailchimp-plugin.php:317
|
142 |
+
msgid "This list does not have interest groups enabled"
|
143 |
+
msgstr ""
|
144 |
+
|
145 |
+
#: includes/class-ss-wc-settings-mailchimp.php:201
|
146 |
+
#, php-format
|
147 |
+
msgid ""
|
148 |
+
"WooCommerce MailChimp error: Plugin is enabled but no api key provided. "
|
149 |
+
"Please enter your api key <a href=\"%s\">here</a>."
|
150 |
+
msgstr ""
|
151 |
+
|
152 |
+
#: includes/class-ss-wc-settings-mailchimp.php:250
|
153 |
+
msgid "General"
|
154 |
+
msgstr ""
|
155 |
+
|
156 |
+
#: includes/class-ss-wc-settings-mailchimp.php:253
|
157 |
+
#: includes/class-ss-wc-settings-mailchimp.php:477
|
158 |
+
msgid "Troubleshooting"
|
159 |
+
msgstr ""
|
160 |
+
|
161 |
+
#: includes/class-ss-wc-settings-mailchimp.php:315
|
162 |
+
msgid ""
|
163 |
+
"Enter your MailChimp settings below to control how WooCommerce integrates "
|
164 |
+
"with your MailChimp account."
|
165 |
+
msgstr ""
|
166 |
+
|
167 |
+
#: includes/class-ss-wc-settings-mailchimp.php:322
|
168 |
+
msgid "API Key"
|
169 |
+
msgstr ""
|
170 |
+
|
171 |
+
#: includes/class-ss-wc-settings-mailchimp.php:324
|
172 |
+
#, php-format
|
173 |
+
msgid "%sLogin to MailChimp%s to look up your api key."
|
174 |
+
msgstr ""
|
175 |
+
|
176 |
+
#: includes/class-ss-wc-settings-mailchimp.php:326
|
177 |
+
msgid "Paste your MailChimp API key here"
|
178 |
+
msgstr ""
|
179 |
+
|
180 |
+
#: includes/class-ss-wc-settings-mailchimp.php:334
|
181 |
+
msgid "Enable/Disable"
|
182 |
+
msgstr ""
|
183 |
+
|
184 |
+
#: includes/class-ss-wc-settings-mailchimp.php:335
|
185 |
+
msgid "Enable MailChimp Integration"
|
186 |
+
msgstr ""
|
187 |
+
|
188 |
+
#: includes/class-ss-wc-settings-mailchimp.php:337
|
189 |
+
msgid "Enable/disable the plugin functionality."
|
190 |
+
msgstr ""
|
191 |
+
|
192 |
+
#: includes/class-ss-wc-settings-mailchimp.php:351
|
193 |
+
msgid "Main List"
|
194 |
+
msgstr ""
|
195 |
+
|
196 |
+
#: includes/class-ss-wc-settings-mailchimp.php:353
|
197 |
+
msgid "All customers will be added to this list."
|
198 |
+
msgstr ""
|
199 |
+
|
200 |
+
#: includes/class-ss-wc-settings-mailchimp.php:363
|
201 |
+
msgid "Interest Groups"
|
202 |
+
msgstr ""
|
203 |
+
|
204 |
+
#: includes/class-ss-wc-settings-mailchimp.php:365
|
205 |
+
msgid "Optional: Interest groups to assign to subscribers."
|
206 |
+
msgstr ""
|
207 |
+
|
208 |
+
#: includes/class-ss-wc-settings-mailchimp.php:370
|
209 |
+
msgid "Select interest groups..."
|
210 |
+
msgstr ""
|
211 |
+
|
212 |
+
#: includes/class-ss-wc-settings-mailchimp.php:378
|
213 |
+
msgid "Subscribe Event"
|
214 |
+
msgstr ""
|
215 |
+
|
216 |
+
#: includes/class-ss-wc-settings-mailchimp.php:380
|
217 |
+
msgid ""
|
218 |
+
"Choose whether to subscribe customers as soon as an order is placed or after "
|
219 |
+
"the order is processing or completed."
|
220 |
+
msgstr ""
|
221 |
+
|
222 |
+
#: includes/class-ss-wc-settings-mailchimp.php:384
|
223 |
+
msgid "Order Created"
|
224 |
+
msgstr ""
|
225 |
+
|
226 |
+
#: includes/class-ss-wc-settings-mailchimp.php:385
|
227 |
+
msgid "Order Processing"
|
228 |
+
msgstr ""
|
229 |
+
|
230 |
+
#: includes/class-ss-wc-settings-mailchimp.php:386
|
231 |
+
msgid "Order Completed"
|
232 |
+
msgstr ""
|
233 |
+
|
234 |
+
#: includes/class-ss-wc-settings-mailchimp.php:393
|
235 |
+
msgid "Double Opt-In"
|
236 |
+
msgstr ""
|
237 |
+
|
238 |
+
#: includes/class-ss-wc-settings-mailchimp.php:394
|
239 |
+
msgid "Enable Double Opt-In"
|
240 |
+
msgstr ""
|
241 |
+
|
242 |
+
#: includes/class-ss-wc-settings-mailchimp.php:397
|
243 |
+
msgid ""
|
244 |
+
"If enabled, customers will receive an email prompting them to confirm their "
|
245 |
+
"subscription to the list above."
|
246 |
+
msgstr ""
|
247 |
+
|
248 |
+
#: includes/class-ss-wc-settings-mailchimp.php:402
|
249 |
+
msgid "Subscribe Customers"
|
250 |
+
msgstr ""
|
251 |
+
|
252 |
+
#: includes/class-ss-wc-settings-mailchimp.php:403
|
253 |
+
msgid ""
|
254 |
+
"<p>Choose <strong>Ask for permission</strong> to show an \"Opt-in\" checkbox "
|
255 |
+
"during checkout. Customers will only be subscribed to the list above if they "
|
256 |
+
"opt-in. <p>Choose <strong>Automatically</strong> to subscribe customers "
|
257 |
+
"silently upon checkout. Caution, this is without the customer's consent.</p>"
|
258 |
+
msgstr ""
|
259 |
+
|
260 |
+
#: includes/class-ss-wc-settings-mailchimp.php:411
|
261 |
+
msgid "Ask for permission"
|
262 |
+
msgstr ""
|
263 |
+
|
264 |
+
#: includes/class-ss-wc-settings-mailchimp.php:412
|
265 |
+
msgid "Automatically"
|
266 |
+
msgstr ""
|
267 |
+
|
268 |
+
#: includes/class-ss-wc-settings-mailchimp.php:418
|
269 |
+
msgid "Opt-In Field Label"
|
270 |
+
msgstr ""
|
271 |
+
|
272 |
+
#: includes/class-ss-wc-settings-mailchimp.php:420
|
273 |
+
msgid "Optional: customize the label displayed next to the opt-in checkbox."
|
274 |
+
msgstr ""
|
275 |
+
|
276 |
+
#: includes/class-ss-wc-settings-mailchimp.php:428
|
277 |
+
msgid "Opt-In Checkbox Default"
|
278 |
+
msgstr ""
|
279 |
+
|
280 |
+
#: includes/class-ss-wc-settings-mailchimp.php:430
|
281 |
+
msgid "The default state of the opt-in checkbox."
|
282 |
+
msgstr ""
|
283 |
+
|
284 |
+
#: includes/class-ss-wc-settings-mailchimp.php:434
|
285 |
+
msgid "Checked"
|
286 |
+
msgstr ""
|
287 |
+
|
288 |
+
#: includes/class-ss-wc-settings-mailchimp.php:435
|
289 |
+
msgid "Unchecked"
|
290 |
+
msgstr ""
|
291 |
+
|
292 |
+
#: includes/class-ss-wc-settings-mailchimp.php:442
|
293 |
+
msgid "Opt-In Checkbox Location"
|
294 |
+
msgstr ""
|
295 |
+
|
296 |
+
#: includes/class-ss-wc-settings-mailchimp.php:444
|
297 |
+
msgid "Where to display the opt-in checkbox on the checkout page."
|
298 |
+
msgstr ""
|
299 |
+
|
300 |
+
#: includes/class-ss-wc-settings-mailchimp.php:448
|
301 |
+
msgid "Above customer details"
|
302 |
+
msgstr ""
|
303 |
+
|
304 |
+
#: includes/class-ss-wc-settings-mailchimp.php:449
|
305 |
+
msgid "Below customer details"
|
306 |
+
msgstr ""
|
307 |
+
|
308 |
+
#: includes/class-ss-wc-settings-mailchimp.php:450
|
309 |
+
msgid "Order review above submit"
|
310 |
+
msgstr ""
|
311 |
+
|
312 |
+
#: includes/class-ss-wc-settings-mailchimp.php:451
|
313 |
+
msgid "Order review below submit"
|
314 |
+
msgstr ""
|
315 |
+
|
316 |
+
#: includes/class-ss-wc-settings-mailchimp.php:452
|
317 |
+
msgid "Order review above total"
|
318 |
+
msgstr ""
|
319 |
+
|
320 |
+
#: includes/class-ss-wc-settings-mailchimp.php:453
|
321 |
+
msgid "Above billing details"
|
322 |
+
msgstr ""
|
323 |
+
|
324 |
+
#: includes/class-ss-wc-settings-mailchimp.php:454
|
325 |
+
msgid "Above shipping details"
|
326 |
+
msgstr ""
|
327 |
+
|
328 |
+
#: includes/class-ss-wc-settings-mailchimp.php:455
|
329 |
+
msgid "Below Checkout billing form"
|
330 |
+
msgstr ""
|
331 |
+
|
332 |
+
#: includes/class-ss-wc-settings-mailchimp.php:466
|
333 |
+
msgid "Enable Logging"
|
334 |
+
msgstr ""
|
335 |
+
|
336 |
+
#: includes/class-ss-wc-settings-mailchimp.php:473
|
337 |
+
#, php-format
|
338 |
+
msgid "%1$sView Log%2$s"
|
339 |
+
msgstr ""
|
340 |
+
|
341 |
+
#: includes/class-ss-wc-settings-mailchimp.php:485
|
342 |
+
msgid "Debug Log"
|
343 |
+
msgstr ""
|
344 |
+
|
345 |
+
#: includes/class-ss-wc-settings-mailchimp.php:489
|
346 |
+
msgid ""
|
347 |
+
"Enable logging MailChimp API calls. Only enable for troubleshooting purposes."
|
348 |
+
msgstr ""
|
349 |
+
|
350 |
+
#: includes/class-ss-wc-settings-mailchimp.php:494
|
351 |
+
msgid "System Info"
|
352 |
+
msgstr ""
|
353 |
+
|
354 |
+
#: includes/class-ss-wc-settings-mailchimp.php:496
|
355 |
+
msgid ""
|
356 |
+
"Copy the information below and send it to us when reporting an issue with "
|
357 |
+
"the plugin."
|
358 |
+
msgstr ""
|
359 |
+
|
360 |
+
#: includes/class-ss-wc-settings-mailchimp.php:584
|
361 |
+
msgid "Oops! No lists in your MailChimp account..."
|
362 |
+
msgstr ""
|
363 |
+
|
364 |
+
#: includes/class-ss-wc-settings-mailchimp.php:589
|
365 |
+
msgid "Select a list..."
|
366 |
+
msgstr ""
|
367 |
+
|
368 |
+
#: includes/class-ss-wc-settings-mailchimp.php:629
|
369 |
+
#, php-format
|
370 |
+
msgid ""
|
371 |
+
"Oops! There are no lists in your MailChimp account. %sClick here%s to create "
|
372 |
+
"one."
|
373 |
+
msgstr ""
|
374 |
+
|
375 |
+
#: includes/class-ss-wc-settings-mailchimp.php:641
|
376 |
+
#, php-format
|
377 |
+
msgid "Unable to load lists from MailChimp: (%s) %s. "
|
378 |
+
msgstr ""
|
379 |
+
|
380 |
+
#: includes/class-ss-wc-settings-mailchimp.php:642
|
381 |
+
#, php-format
|
382 |
+
msgid "Please check your Settings %ssettings%s."
|
383 |
+
msgstr ""
|
384 |
+
|
385 |
+
#. Plugin Name of the plugin/theme
|
386 |
+
msgid "WooCommerce MailChimp"
|
387 |
+
msgstr ""
|
388 |
+
|
389 |
+
#. Plugin URI of the plugin/theme
|
390 |
+
msgid "https://www.saintsystems.com/products/woocommerce-mailchimp/"
|
391 |
+
msgstr ""
|
392 |
+
|
393 |
+
#. Description of the plugin/theme
|
394 |
+
msgid ""
|
395 |
+
"WooCommerce MailChimp provides simple MailChimp integration for WooCommerce."
|
396 |
+
msgstr ""
|
397 |
+
|
398 |
+
#. Author of the plugin/theme
|
399 |
+
msgid "Saint Systems"
|
400 |
+
msgstr ""
|
401 |
+
|
402 |
+
#. Author URI of the plugin/theme
|
403 |
+
msgid "https://www.saintsystems.com"
|
404 |
+
msgstr ""
|
trunk/readme.txt
ADDED
@@ -0,0 +1,404 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== WooCommerce MailChimp ===
|
2 |
+
Contributors: saintsystems, anderly
|
3 |
+
Donate link: http://ssms.us/hVdk
|
4 |
+
Tags: woocommerce, mailchimp
|
5 |
+
Requires at least: 3.5.1
|
6 |
+
Tested up to: 5.0.3
|
7 |
+
WC tested up to: 3.5.4
|
8 |
+
Stable tag: 2.1.15
|
9 |
+
License: GPLv3
|
10 |
+
|
11 |
+
Simple and flexible MailChimp integration for WooCommerce.
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
WooCommerce MailChimp provides simple and flexible MailChimp integration for WooCommerce.
|
16 |
+
|
17 |
+
Automatically subscribe customers to a designated MailChimp list and, optionally, MailChimp interest groups upon order creation or order completion. This can be done quietly or based on the user's consent with several opt-in settings that support international opt-in laws.
|
18 |
+
|
19 |
+
= Features =
|
20 |
+
|
21 |
+
**WooCommerce Event Selection**
|
22 |
+
|
23 |
+
- Subscribe customers to MailChimp after order creation
|
24 |
+
- Subscribe customers to MailChimp after order processing
|
25 |
+
- Subscribe customers to MailChimp after order completion
|
26 |
+
|
27 |
+
**Works with MailChimp Interest Groups**
|
28 |
+
|
29 |
+
- Set one or more interest groups to add users to based on the selected MailChimp list.
|
30 |
+
|
31 |
+
**Opt-In Settings**
|
32 |
+
|
33 |
+
- MailChimp double opt-in support (control whether a double opt-in email is sent to the customer)
|
34 |
+
- Optionally, display an opt-in checkbox on the checkout page (this is required in some countries)
|
35 |
+
- Control the label displayed next to the opt-in checkbox
|
36 |
+
- Control whether or not the opt-in checkbox is checked or unchecked by default
|
37 |
+
- Control the placement of the opt-in checkbox on the checkout page
|
38 |
+
|
39 |
+
= Translation Support =
|
40 |
+
|
41 |
+
Would you like to help translate the plugin into more languages? Join our Translations Community at https://translate.wordpress.org/projects/wp-plugins/woocommerce-mailchimp.
|
42 |
+
|
43 |
+
WooCommerce MailChimp translation is managed through WordPress language packs here: https://translate.wordpress.org. This allows WooCommerce MailChimp to be translated into other languages. The preferred tool for translating plugins is called [GlotPress](https://make.wordpress.org/polyglots/handbook/tools/glotpress-translate-wordpress-org/). You can [read about how GlotPress works in the WordPress Translator's Handbook](https://make.wordpress.org/polyglots/handbook/tools/glotpress-translate-wordpress-org/).
|
44 |
+
|
45 |
+
Thanks in advance for your help on any translation efforts!
|
46 |
+
|
47 |
+
We also support bundled translations via:
|
48 |
+
|
49 |
+
- Included woocommerce-mailchimp.pot file
|
50 |
+
- WPML support via wpml-config.xml
|
51 |
+
|
52 |
+
**Included Translations:**
|
53 |
+
|
54 |
+
- English (US) (default)
|
55 |
+
- French.
|
56 |
+
|
57 |
+
**Custom Translations**
|
58 |
+
|
59 |
+
If you don't want to use WordPress language packs or bundled translations, you can use your own custom translations.
|
60 |
+
|
61 |
+
- Place custom translations in `/wp-content/languages/woocommerce-mailchimp/woocommerce-mailchimp_{lang}_{country}.mo`. This ensures they won't get overwritten by plugin updates.
|
62 |
+
|
63 |
+
**Translation Loading**
|
64 |
+
|
65 |
+
If no custom translations are present, languages will be loaded in the following order:
|
66 |
+
|
67 |
+
- From WordPress language packs in: `/wp-content/languages/plugins/woocommerce-mailchimp/woocommerce-mailchimp_{lang}_{country}.mo`
|
68 |
+
- From the plugin bundled in: `/wp-content/plugins/woocommerce-mailchimp/languages/woocommerce-mailchimp_{lang}_{country}.mo`
|
69 |
+
|
70 |
+
= Multisite =
|
71 |
+
|
72 |
+
- All features should work for each blog in multisite installations.
|
73 |
+
|
74 |
+
= Requirements =
|
75 |
+
|
76 |
+
WooCommerce MailChimp requires PHP 5.4+ (PHP 7.0+ recommended). You'll also need to be running WordPress 3.5.1+ and have WooCommerce 2.2+.
|
77 |
+
|
78 |
+
= Documentation & Support =
|
79 |
+
|
80 |
+
Online documentation and code samples are available via our [Help Center](https://support.saintsystems.com/hc/en-us/sections/201959566).
|
81 |
+
|
82 |
+
Please visit the
|
83 |
+
[WooCommerce MailChimp support forum on WordPress.org](https://wordpress.org/support/plugin/woocommerce-mailchimp) for basic support and help from other users. Since this is a free plugin, we respond to these as we have time.
|
84 |
+
|
85 |
+
Dedicated support will be available with the upcoming [WooCommerce MailChimp Pro](https://www.saintsystems.com/products/woocommerce-mailchimp-pro/).
|
86 |
+
|
87 |
+
= Contribute =
|
88 |
+
All development for WooCommerce MailChimp is [handled via GitHub](https://github.com/anderly/woocommerce-mailchimp). Opening new issues and submitting pull requests are welcome.
|
89 |
+
|
90 |
+
[Our public roadmap is available on Trello](https://trello.com/b/VWBdLVuI/woocommerce-mailchimp-development). We'd love it if you vote and comment on your favorite ideas.
|
91 |
+
|
92 |
+
You can also keep up to date with [WooCommerce MailChimp Pro](https://www.saintsystems.com/products/woocommerce-mailchimp-pro/) development by [subscribing to our newsletter](http://eepurl.com/bxcewL).
|
93 |
+
|
94 |
+
Also, if you enjoy using the software [we'd love it if you could give us a review](https://wordpress.org/support/plugin/woocommerce-mailchimp/reviews/)!
|
95 |
+
|
96 |
+
== Installation ==
|
97 |
+
|
98 |
+
1. Upload or extract the `woocommerce-mailchimp` folder to your site's `/wp-content/plugins/` directory. You can also use the *Add new- option found in the *Plugins- menu in WordPress.
|
99 |
+
2. Enable the plugin from the *Plugins- menu in WordPress.
|
100 |
+
|
101 |
+
= Usage =
|
102 |
+
|
103 |
+
1. Go to WooCommerce > Settings > MailChimp
|
104 |
+
2. First, paste your MailChimp API Key to get started.
|
105 |
+
3. Select whether you want customers to be subscribed to your MailChimp list after order creation, order processing or order completion (there's a difference in WooCommerce).
|
106 |
+
4. Next, select your MailChimp list and select any interest groups (optional).
|
107 |
+
5. Select your opt-in, double opt-in settings and hit `Save changes`.
|
108 |
+
6. That's it, your WooCommerce store is now integrated with MailChimp!
|
109 |
+
|
110 |
+
== Screenshots ==
|
111 |
+
|
112 |
+
1. WooCommerce MailChimp general settings screen.
|
113 |
+
2. WooCommerce MailChimp troubleshooting screen.
|
114 |
+
|
115 |
+
== Changelog ==
|
116 |
+
|
117 |
+
#### 2.1.15 - February 5, 2019
|
118 |
+
- Fix fatal error.
|
119 |
+
|
120 |
+
#### 2.1.14 - February 5, 2019
|
121 |
+
- Fix MailChimp interest group limit
|
122 |
+
|
123 |
+
#### 2.1.13 - January 29, 2019
|
124 |
+
- WooCommerce tested up to 3.5.4
|
125 |
+
- WP tested up to 5.0.3
|
126 |
+
|
127 |
+
#### 2.1.12 - May 22, 2018
|
128 |
+
- WPML Opt-in label fix.
|
129 |
+
- Plugin now loads after `plugins_loaded` action hook.
|
130 |
+
|
131 |
+
#### 2.1.11 - April 27, 2018
|
132 |
+
- Fix erroneous error saying can't load lists when no interest groups for list.
|
133 |
+
|
134 |
+
#### 2.1.10 - February 12, 2018
|
135 |
+
- Added WooCommerce tested up to header
|
136 |
+
|
137 |
+
#### 2.1.9 - February 1, 2018
|
138 |
+
- Added new opt-in checkbox location for order review above cart/product table.
|
139 |
+
|
140 |
+
#### 2.1.8 - February 1, 2018
|
141 |
+
- Fix "Invalid argument supplied for foreach" warning in settings (Issue #21)
|
142 |
+
|
143 |
+
#### 2.1.6 - January 26, 2018
|
144 |
+
- Restore opt-in checkbox location and add params to filter to allow easier adjustment of its placement.
|
145 |
+
|
146 |
+
#### 2.1.5 - January 25, 2018
|
147 |
+
- Move opt-in checkbox before associated label
|
148 |
+
|
149 |
+
#### 2.1.4 - December 20, 2017
|
150 |
+
- Tested up to WordPres 4.9.1
|
151 |
+
|
152 |
+
#### 2.1.3 - December 19, 2017
|
153 |
+
- Small fix to show MailChimp API error message in UI.
|
154 |
+
|
155 |
+
#### 2.1.2 - August 25, 2017
|
156 |
+
- Fix retrieval of mailchimp lists with numeric ids.
|
157 |
+
|
158 |
+
#### 2.1.1 - July 24, 2017
|
159 |
+
- Fix settings default for older PHP versions.
|
160 |
+
|
161 |
+
#### 2.1.0 - April 26, 2017
|
162 |
+
- Added support for WooCommerce 3.0 changes.
|
163 |
+
- Added additional options for opt-in checkbox placement.
|
164 |
+
|
165 |
+
#### 2.0.20 - February 1, 2017
|
166 |
+
|
167 |
+
- Added `woocommerce_mailchimp_admin_email` filter to allow hooking into and overriding email where error messages are sent (defaults to `get_option( 'admin_email' )` ).
|
168 |
+
|
169 |
+
**IMPORTANT:** You must upgrade to version 2.X by December 31, 2016 as prior versions of the MailChimp API will stop working at that point.
|
170 |
+
|
171 |
+
#### 2.0.19 - October 4, 2016
|
172 |
+
|
173 |
+
- Fix to not send double opt-in email to existing subscribers.
|
174 |
+
|
175 |
+
#### 2.0.18 - September 23, 2016
|
176 |
+
|
177 |
+
- Fix for array_filter not working with lamda for some users.
|
178 |
+
|
179 |
+
#### 2.0.15 - 2.0.17 - September 22, 2016
|
180 |
+
|
181 |
+
- Fix for activation error running migrations.
|
182 |
+
- Double opt-in fix.
|
183 |
+
- Added additional hooks and filters.
|
184 |
+
- Code cleanup.
|
185 |
+
|
186 |
+
#### 2.0.13 - 2.0.14 - September 20, 2016
|
187 |
+
|
188 |
+
- Added plugin compatibility checks for minimum supported versions of WooCommerce, WordPress and PHP.
|
189 |
+
- Added explicit plugin directory to require_once calls.
|
190 |
+
|
191 |
+
#### 2.0.9 - 2.0.12 - September 19, 2016
|
192 |
+
|
193 |
+
- Small fix for double-loading of lists on api key change.
|
194 |
+
- Small fix for lists not loading after initial save on new installs.
|
195 |
+
- Small fix for new installs not loading interest groups.
|
196 |
+
- Removed functions.php file (no longer used).
|
197 |
+
|
198 |
+
#### 2.0.7 - 2.0.8 - September 17, 2016
|
199 |
+
|
200 |
+
- Fix for new installs to prevent trying to run upgrade process.
|
201 |
+
- Small fix to not end WooCommerce Settings section with no api key or list is present.
|
202 |
+
|
203 |
+
#### 2.0 - 2.0.6 - September 16, 2016
|
204 |
+
|
205 |
+
**WARNING:** This release contains breaking changes to the plugin's action hooks and filters. If you have custom code that hooks into the plugins action hooks and filters, please review the breaking changes below to know how to update your code appropriately.
|
206 |
+
|
207 |
+
**Breaking Changes**
|
208 |
+
|
209 |
+
- Action filter `ss_wc_mailchimp_subscribe_merge_vars` is now `ss_wc_mailchimp_subscribe_merge_tags`
|
210 |
+
- The filter no longer contains the `GROUPINGS` sub-key for [MailChimp Groups](http://kb.mailchimp.com/groups) due to a change with the MailChimp API v3.0.
|
211 |
+
- The filter now only contains the [MailChimp Merge Tags](http://kb.mailchimp.com/merge-tags).
|
212 |
+
- [MailChimp Groups](http://kb.mailchimp.com/groups) now have their own action filter `ss_wc_mailchimp_subscribe_interest_groups`
|
213 |
+
- Action filter `ss_wc_mailchimp_subscribe_options` has changed due to changes with the MailChimp API v3.0.
|
214 |
+
- The key `listid` has been changed to `list_id` in the `$subscribe_options` parameter
|
215 |
+
- The `vars` key has been removed from the `$subscribe_options` parameter (this key previously contained the merge tags and groups together).
|
216 |
+
- The `update_existing`, `replace_interests` and `send_welcome` keys have been removed from the `$subscribe_options` parameter since they are no longer supported by the API.
|
217 |
+
- The plugin now always updates existing subscribers if they exist.
|
218 |
+
- The plugin now always appends interest groups and does not affect existing groups on subscribers.
|
219 |
+
- The send welcome email can be configured on the target list and is not required to be sent through the API.
|
220 |
+
- A new key `merge_tags` has been added and includes the `$merge_tags` array to be sent to the MailChimp API
|
221 |
+
- A new key `interest_groups` has been added and includes the `$interest_groups` array to be sent to the MailChimp API
|
222 |
+
|
223 |
+
|
224 |
+
**Improvements**
|
225 |
+
|
226 |
+
- Added ability to pick MailChimp Interest Groups from drop-down list.
|
227 |
+
- Upgraded MailChimp API to v3.0
|
228 |
+
|
229 |
+
**Additions**
|
230 |
+
|
231 |
+
- Added `Debug Log` setting to enable/disable logging for troubleshooting purposes.
|
232 |
+
- Added `System Info` setting for troubleshooting purposes.
|
233 |
+
- New action hook `ss_wc_mailchimp_loaded` fired after the plugin has loaded.
|
234 |
+
- New action hook `ss_wc_mailchimp_before_opt_in_checkbox` fired before opt in checkbox is rendered.
|
235 |
+
- New action filter `ss_wc_mailchimp_opt_in_checkbox` allows for overriding opt in checkbox rendering
|
236 |
+
- New action hook `ss_wc_mailchimp_after_opt_in_checkbox` fired after opt in checkbox is rendered.
|
237 |
+
|
238 |
+
**Fixes**
|
239 |
+
|
240 |
+
- Fixed issues with translations and text domains not loading properly.
|
241 |
+
- Change `list` function to `get_list` to prevent PHP error
|
242 |
+
- Fix issues with PHP version < 5.5
|
243 |
+
|
244 |
+
#### 1.3.9 - September 13, 2016
|
245 |
+
|
246 |
+
**Fixes**
|
247 |
+
|
248 |
+
- Rename MCAPI class to prevent collisions with other plugins.
|
249 |
+
|
250 |
+
#### 1.3.8 - September 9, 2016
|
251 |
+
|
252 |
+
**Improvements**
|
253 |
+
|
254 |
+
- Tested up to WordPress 4.6.1
|
255 |
+
- Tested up to WooCommerce 2.6.4
|
256 |
+
- More flexible opt_in checkbox placement
|
257 |
+
- Pass $order_id to `ss_wc_mailchimp_subscribe_options` hook
|
258 |
+
|
259 |
+
**Fixes**
|
260 |
+
|
261 |
+
- Use only one instance of MCAPI
|
262 |
+
- Fixed Issue #14 MCAPI constructor style
|
263 |
+
- Fixed Issue #15 `mailchimp_api_error_msg`
|
264 |
+
- Fixed Issue #16 where lists wouldn't show up until you saved the settings twice
|
265 |
+
|
266 |
+
#### 1.3.7 - December 16, 2015
|
267 |
+
|
268 |
+
**Improvements**
|
269 |
+
|
270 |
+
- WordPress 4.4 Compatible
|
271 |
+
- WooCommerce 2.4.12 Compatible
|
272 |
+
|
273 |
+
**Fixes**
|
274 |
+
|
275 |
+
- API response not shown in debug log
|
276 |
+
- Use only one instance of MCAPI
|
277 |
+
|
278 |
+
#### 1.3.6 - February 9, 2015
|
279 |
+
|
280 |
+
**Fixes**
|
281 |
+
|
282 |
+
- Backout of change to use WC_Logger due to fatal error
|
283 |
+
|
284 |
+
#### 1.3.5 - February 6, 2015
|
285 |
+
|
286 |
+
**Improvements**
|
287 |
+
|
288 |
+
- Change to use WC_Logger instead of error_log
|
289 |
+
- Updated pot file
|
290 |
+
- Added French translation
|
291 |
+
- General code syntax cleanup
|
292 |
+
|
293 |
+
**Fixes**
|
294 |
+
|
295 |
+
- Fix for undefined variable list and array_merge issue.
|
296 |
+
|
297 |
+
#### 1.3.3 & 1.3.4 - January 16, 2016
|
298 |
+
|
299 |
+
**Fixes**
|
300 |
+
|
301 |
+
- Fix enabled check. Issue #6.
|
302 |
+
- Fix for transient key length.
|
303 |
+
|
304 |
+
**Improvements**
|
305 |
+
|
306 |
+
- Tested with WordPress 4.1
|
307 |
+
|
308 |
+
#### 1.3.2 - November 4, 2014
|
309 |
+
|
310 |
+
**Fixes*
|
311 |
+
|
312 |
+
- Fix for headers already sent message. Tested with WordPress 4.0 and WooCommerce 2.2.*
|
313 |
+
|
314 |
+
#### 1.3.1 - April 3, 2014
|
315 |
+
|
316 |
+
**Fixes**
|
317 |
+
|
318 |
+
- Fix for MailChimp merge vars bug introduced in v1.3
|
319 |
+
|
320 |
+
#### 1.3 - April 1, 2014
|
321 |
+
|
322 |
+
**Breaking Changes**
|
323 |
+
|
324 |
+
- Action filer `ss_wc_mailchimp_subscribe_merge_vars` now passes $order_id param to enable retrieving additional order info/meta to use in MailChimp merge vars
|
325 |
+
|
326 |
+
**Fixes**
|
327 |
+
|
328 |
+
- Small fix to order_created subscribe event to work with PayPal Payment Gateway
|
329 |
+
|
330 |
+
#### 1.2.6 - February 28, 2014
|
331 |
+
|
332 |
+
**Improvements**
|
333 |
+
|
334 |
+
- Added additional debug logging when WP_DEBUG is enabled
|
335 |
+
|
336 |
+
#### 1.2.5 - February 27, 2014
|
337 |
+
|
338 |
+
**Fixes**
|
339 |
+
|
340 |
+
- Bug fix for subscribe when not using opt-in display field
|
341 |
+
|
342 |
+
#### 1.2.2, 1.2.3 & 1.2.4 - February 22, 2014
|
343 |
+
|
344 |
+
**Fixes**
|
345 |
+
|
346 |
+
- WooCommerce 2.1 fix for order custom fields
|
347 |
+
- Fixed plugin settings link for WooCommerce 2.1
|
348 |
+
- Bug fix for subscribe
|
349 |
+
|
350 |
+
#### 1.2.1 - February 13, 2014
|
351 |
+
|
352 |
+
**Improvements**
|
353 |
+
|
354 |
+
- WooCommerce 2.1 integration: Change to use wc_enqueue_js instead of add_inline_js
|
355 |
+
- WooCommerce 2.1 integration: Change to support new default checkout field filter for default opt-in checkbox status
|
356 |
+
|
357 |
+
#### 1.2 - January 10, 2014
|
358 |
+
|
359 |
+
**Improvements**
|
360 |
+
|
361 |
+
- Added new setting to control whether or not the double opt-in checkbox is checked/unchecked by default on the checkout page.
|
362 |
+
- Added new setting to control display location of the double opt-in checkbox (under billing info or order info)
|
363 |
+
- Small modification to append to MailChimp interest groups for existing users so that group settings are not lost for users who were already subscribed.
|
364 |
+
- Preparations for i18n (Internationalization) support. Several users have already asked and offered to translate the plugin into other languages. We had always planned on that, but now are making that a reality.
|
365 |
+
|
366 |
+
### 1.1.2 & 1.1.3 - January 2, 2014
|
367 |
+
|
368 |
+
**Fixes**
|
369 |
+
|
370 |
+
- Update to REALLY address issue with subscriptions not occurring on order create "pending"
|
371 |
+
|
372 |
+
**Additions**
|
373 |
+
|
374 |
+
- Minor action hook change since order meta (needed for MailChimp API call) is not yet available on 'woocommerce_new_order' hook
|
375 |
+
|
376 |
+
### - January 2, 2014
|
377 |
+
|
378 |
+
### 1.1.1 - December 31, 2013
|
379 |
+
|
380 |
+
**Fixes**
|
381 |
+
|
382 |
+
- Update to address issue with subscriptions not occurring on order create "pending"
|
383 |
+
|
384 |
+
### 1.1 - November 12, 2013
|
385 |
+
|
386 |
+
**Improvements**
|
387 |
+
|
388 |
+
- Add the option to display an opt-in field on checkout
|
389 |
+
|
390 |
+
### 1.0.2 - October 16, 2013
|
391 |
+
|
392 |
+
**Additions**
|
393 |
+
|
394 |
+
- Minor text and comment changes
|
395 |
+
|
396 |
+
### 1.0.1 - October 11, 2013
|
397 |
+
|
398 |
+
**Improvements**
|
399 |
+
|
400 |
+
- Added "Settings" link on the Plugins administration screen
|
401 |
+
|
402 |
+
### 1.0 - October 10, 2013
|
403 |
+
|
404 |
+
- This is the first public release.
|
trunk/woocommerce-mailchimp.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: WooCommerce MailChimp
|
4 |
+
* Plugin URI: https://www.saintsystems.com/products/woocommerce-mailchimp/
|
5 |
+
* Description: WooCommerce MailChimp provides simple MailChimp integration for WooCommerce.
|
6 |
+
* Author: Saint Systems
|
7 |
+
* Author URI: https://www.saintsystems.com
|
8 |
+
* Version: 2.1.15
|
9 |
+
* WC tested up to: 3.5.4
|
10 |
+
* Text Domain: woocommerce-mailchimp
|
11 |
+
* Domain Path: languages
|
12 |
+
*
|
13 |
+
* Copyright: � 2019 Saint Systems
|
14 |
+
* License: GNU General Public License v3.0
|
15 |
+
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
16 |
+
*/
|
17 |
+
|
18 |
+
/** If this file is called directly, abort. */
|
19 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
20 |
+
die;
|
21 |
+
}
|
22 |
+
|
23 |
+
/** Constants */
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Full path to the WooCommerce MailChimp file
|
27 |
+
* @define "SS_WC_MAILCHIMP_FILE" "./woocommmerce-mailchimp.php"
|
28 |
+
*/
|
29 |
+
define( 'SS_WC_MAILCHIMP_FILE', __FILE__ );
|
30 |
+
|
31 |
+
/**
|
32 |
+
* The main plugin class (SS_WC_MailChimp_Plugin)
|
33 |
+
*/
|
34 |
+
require_once( 'includes/class-ss-wc-mailchimp-plugin.php' );
|
35 |
+
|
36 |
+
// Include Action Scheduler Library.
|
37 |
+
require_once( 'includes/lib/action-scheduler/action-scheduler.php' );
|
38 |
+
|
39 |
+
function SSWCMC() {
|
40 |
+
return SS_WC_MailChimp_Plugin::get_instance();
|
41 |
+
}
|
42 |
+
|
43 |
+
// Get WooCommerce Mailchimp Running.
|
44 |
+
add_action( 'plugins_loaded', 'SSWCMC', 11 );
|
trunk/wpml-config.xml
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<wpml-config>
|
2 |
+
<admin-texts>
|
3 |
+
<key name="ss_wc_mailchimp_opt_in_label" />
|
4 |
+
</admin-texts>
|
5 |
+
</wpml-config>
|