Version Description
- adds action scheduler queue system
- documentation for Custom Merge Tags
- adds more specific installation requirements
- fixes PHP Error in class-mailchimp-order.php
- fixes pop up blocks on connection
- fixes unable to sync without accepting to auto subscribe existing customers
- documentation for wp-cli class queue-command
Download this release
Release Info
Developer | ryanhungate |
Plugin | MailChimp for WooCommerce |
Version | 2.3 |
Comparing to | |
See all releases |
Code changes from version 2.2.4 to 2.3
- .idea/.name +1 -0
- .idea/misc.xml +6 -0
- .idea/modules.xml +8 -0
- .idea/svn.mailchimp-woocommerce.iml +8 -0
- .idea/workspace.xml +82 -0
- README.txt +13 -5
- admin/class-mailchimp-woocommerce-admin.php +51 -11
- admin/css/mailchimp-woocommerce-admin-settings.css +2 -1
- admin/css/mailchimp-woocommerce-admin.css +5 -1
- admin/js/mailchimp-woocommerce-admin.js +95 -87
- admin/partials/mailchimp-woocommerce-admin-tabs.php +0 -3
- admin/partials/tabs/api_key.php +1 -0
- admin/partials/tabs/newsletter_settings.php +9 -9
- admin/partials/tabs/store_sync.php +2 -2
- bootstrap.php +104 -402
- includes/api/assets/class-mailchimp-order.php +1 -1
- includes/api/class-mailchimp-api.php +21 -41
- includes/api/class-mailchimp-woocommerce-transform-products.php +1 -1
- includes/class-mailchimp-woocommerce-activator.php +50 -23
- includes/class-mailchimp-woocommerce-cli.php +122 -0
- includes/class-mailchimp-woocommerce-rest-api.php +14 -182
- includes/class-mailchimp-woocommerce-service.php +36 -4
- includes/class-mailchimp-woocommerce.php +15 -8
- includes/processes/class-mailchimp-woocommerce-abstract-sync.php +5 -14
- includes/processes/class-mailchimp-woocommerce-cart-update.php +8 -8
- includes/processes/class-mailchimp-woocommerce-job.php +28 -0
- includes/processes/class-mailchimp-woocommerce-process-coupons-initial-sync.php +1 -1
- includes/processes/class-mailchimp-woocommerce-process-products.php +1 -1
- includes/processes/class-mailchimp-woocommerce-single-coupon.php +21 -10
- includes/processes/class-mailchimp-woocommerce-single-order.php +23 -12
- includes/processes/class-mailchimp-woocommerce-single-product.php +24 -15
- includes/processes/class-mailchimp-woocommerce-user-submit.php +12 -12
- includes/vendor/action-scheduler/.gitattributes +9 -0
- includes/vendor/action-scheduler/.github/release-drafter.yml +15 -0
- includes/vendor/action-scheduler/.gitignore +3 -0
- includes/vendor/action-scheduler/.travis.yml +37 -0
- includes/vendor/action-scheduler/README.md +41 -0
- includes/vendor/action-scheduler/action-scheduler.php +47 -0
- includes/vendor/action-scheduler/classes/ActionScheduler.php +133 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_Abstract_ListTable.php +656 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_Abstract_QueueRunner.php +219 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_Action.php +75 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_ActionClaim.php +23 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_ActionFactory.php +111 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_AdminView.php +83 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_CanceledAction.php +21 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_Compatibility.php +99 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_CronSchedule.php +57 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_DateTime.php +76 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_Exception.php +11 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_FatalErrorMonitor.php +55 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_FinishedAction.php +16 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_IntervalSchedule.php +60 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_InvalidActionException.php +28 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_ListTable.php +533 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_LogEntry.php +67 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_Logger.php +102 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_NullAction.php +16 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_NullLogEntry.php +11 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_NullSchedule.php +19 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_QueueCleaner.php +155 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_QueueRunner.php +115 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_Schedule.php +18 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_SimpleSchedule.php +44 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_Store.php +212 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_TimezoneHelper.php +152 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_Versions.php +62 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_WPCLI_QueueRunner.php +217 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_WPCLI_Scheduler_command.php +145 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_wcSystemStatus.php +147 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_wpCommentLogger.php +240 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_wpPostStore.php +821 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_wpPostStore_PostStatusRegistrar.php +57 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_wpPostStore_PostTypeRegistrar.php +50 -0
- includes/vendor/action-scheduler/classes/ActionScheduler_wpPostStore_TaxonomyRegistrar.php +26 -0
- includes/vendor/action-scheduler/codecov.yml +13 -0
- includes/vendor/action-scheduler/composer.json +11 -0
- includes/vendor/action-scheduler/composer.lock +2909 -0
- includes/vendor/action-scheduler/deprecated/ActionScheduler_Abstract_QueueRunner_Deprecated.php +27 -0
- includes/vendor/action-scheduler/deprecated/ActionScheduler_AdminView_Deprecated.php +147 -0
- includes/vendor/action-scheduler/deprecated/functions.php +126 -0
- includes/vendor/action-scheduler/docs/CNAME +1 -0
- includes/vendor/action-scheduler/docs/_config.yml +7 -0
- includes/vendor/action-scheduler/docs/_layouts/default.html +62 -0
- includes/vendor/action-scheduler/docs/admin.md +22 -0
- includes/vendor/action-scheduler/docs/android-chrome-192x192.png +0 -0
- includes/vendor/action-scheduler/docs/android-chrome-256x256.png +0 -0
- includes/vendor/action-scheduler/docs/api.md +179 -0
- includes/vendor/action-scheduler/docs/apple-touch-icon.png +0 -0
- includes/vendor/action-scheduler/docs/assets/css/style.scss +57 -0
- includes/vendor/action-scheduler/docs/browserconfig.xml +9 -0
- includes/vendor/action-scheduler/docs/faq.md +101 -0
- includes/vendor/action-scheduler/docs/favicon-16x16.png +0 -0
- includes/vendor/action-scheduler/docs/favicon-32x32.png +0 -0
- includes/vendor/action-scheduler/docs/favicon.ico +0 -0
- includes/vendor/action-scheduler/docs/google14ef723abb376cd3.html +1 -0
- includes/vendor/action-scheduler/docs/index.md +68 -0
- includes/vendor/action-scheduler/docs/mstile-150x150.png +0 -0
- includes/vendor/action-scheduler/docs/perf.md +127 -0
- includes/vendor/action-scheduler/docs/safari-pinned-tab.svg +40 -0
- includes/vendor/action-scheduler/docs/site.webmanifest +19 -0
- includes/vendor/action-scheduler/docs/usage.md +123 -0
- includes/vendor/action-scheduler/docs/wp-cli.md +73 -0
- includes/vendor/action-scheduler/functions.php +209 -0
- includes/vendor/action-scheduler/lib/cron-expression/CronExpression.php +318 -0
- includes/vendor/action-scheduler/lib/cron-expression/CronExpression_AbstractField.php +100 -0
- includes/vendor/action-scheduler/lib/cron-expression/CronExpression_DayOfMonthField.php +110 -0
- includes/vendor/action-scheduler/lib/cron-expression/CronExpression_DayOfWeekField.php +124 -0
- includes/vendor/action-scheduler/lib/cron-expression/CronExpression_FieldFactory.php +55 -0
- includes/vendor/action-scheduler/lib/cron-expression/CronExpression_FieldInterface.php +39 -0
- includes/vendor/action-scheduler/lib/cron-expression/CronExpression_HoursField.php +47 -0
- includes/vendor/action-scheduler/lib/cron-expression/CronExpression_MinutesField.php +39 -0
- includes/vendor/action-scheduler/lib/cron-expression/CronExpression_MonthField.php +55 -0
- includes/vendor/action-scheduler/lib/cron-expression/CronExpression_YearField.php +43 -0
- includes/vendor/action-scheduler/lib/cron-expression/LICENSE +19 -0
- includes/vendor/action-scheduler/lib/cron-expression/README.md +92 -0
- includes/vendor/action-scheduler/license.txt +674 -0
- includes/vendor/action-scheduler/tests/ActionScheduler_UnitTestCase.php +44 -0
- includes/vendor/action-scheduler/tests/bootstrap.php +31 -0
- includes/vendor/action-scheduler/tests/phpunit.xml.dist +32 -0
- includes/vendor/action-scheduler/tests/phpunit/deprecated/ActionScheduler_UnitTestCase.php +44 -0
- includes/vendor/action-scheduler/tests/phpunit/helpers/ActionScheduler_TimezoneHelper_Test.php +100 -0
- includes/vendor/action-scheduler/tests/phpunit/jobs/ActionScheduler_Action_Test.php +55 -0
- includes/vendor/action-scheduler/tests/phpunit/jobs/ActionScheduler_NullAction_Test.php +16 -0
- includes/vendor/action-scheduler/tests/phpunit/jobstore/ActionScheduler_wpPostStore_Test.php +375 -0
- includes/vendor/action-scheduler/tests/phpunit/logging/ActionScheduler_wpCommentLogger_Test.php +185 -0
- includes/vendor/action-scheduler/tests/phpunit/procedural_api/procedural_api_Test.php +222 -0
- includes/vendor/action-scheduler/tests/phpunit/procedural_api/wc_get_scheduled_actions_Test.php +100 -0
- includes/vendor/action-scheduler/tests/phpunit/runner/ActionScheduler_QueueCleaner_Test.php +151 -0
- includes/vendor/action-scheduler/tests/phpunit/runner/ActionScheduler_QueueRunner_Test.php +262 -0
- includes/vendor/action-scheduler/tests/phpunit/schedules/ActionScheduler_CronSchedule_Test.php +45 -0
- includes/vendor/action-scheduler/tests/phpunit/schedules/ActionScheduler_IntervalSchedule_Test.php +28 -0
- includes/vendor/action-scheduler/tests/phpunit/schedules/ActionScheduler_NullSchedule_Test.php +18 -0
- includes/vendor/action-scheduler/tests/phpunit/schedules/ActionScheduler_SimpleSchedule_Test.php +37 -0
- includes/vendor/action-scheduler/tests/phpunit/versioning/ActionScheduler_Versions_Test.php +43 -0
- includes/vendor/action-scheduler/tests/travis/setup.sh +38 -0
- includes/vendor/action-scheduler/tests/travis/wp-tests-config.php +38 -0
- languages/mc-woocommerce-pt_BR.mo +0 -0
- languages/mc-woocommerce-pt_BR.po +69 -52
- languages/mc-woocommerce.pot +48 -47
- mailchimp-woocommerce.php +3 -7
- plugin_overview.md +3 -1
- public/class-mailchimp-woocommerce-public.php +0 -11
- public/js/mailchimp-woocommerce-public.js +0 -16
- public/js/mailchimp-woocommerce-public.min.js +1 -1
.idea/.name
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
svn.mailchimp-woocommerce
|
.idea/misc.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="JavaScriptSettings">
|
4 |
+
<option name="languageLevel" value="ES6" />
|
5 |
+
</component>
|
6 |
+
</project>
|
.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ProjectModuleManager">
|
4 |
+
<modules>
|
5 |
+
<module fileurl="file://$PROJECT_DIR$/.idea/svn.mailchimp-woocommerce.iml" filepath="$PROJECT_DIR$/.idea/svn.mailchimp-woocommerce.iml" />
|
6 |
+
</modules>
|
7 |
+
</component>
|
8 |
+
</project>
|
.idea/svn.mailchimp-woocommerce.iml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<module type="WEB_MODULE" version="4">
|
3 |
+
<component name="NewModuleRootManager">
|
4 |
+
<content url="file://$MODULE_DIR$" />
|
5 |
+
<orderEntry type="inheritedJdk" />
|
6 |
+
<orderEntry type="sourceFolder" forTests="false" />
|
7 |
+
</component>
|
8 |
+
</module>
|
.idea/workspace.xml
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ChangeListManager">
|
4 |
+
<list default="true" id="658d276d-bb11-426c-bf41-b1de1f52d7f6" name="Default Changelist" comment="" />
|
5 |
+
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
6 |
+
<option name="SHOW_DIALOG" value="false" />
|
7 |
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
8 |
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
9 |
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
10 |
+
</component>
|
11 |
+
<component name="ComposerSettings">
|
12 |
+
<execution>
|
13 |
+
<executable />
|
14 |
+
</execution>
|
15 |
+
</component>
|
16 |
+
<component name="DatabaseView">
|
17 |
+
<option name="SHOW_INTERMEDIATE" value="true" />
|
18 |
+
<option name="GROUP_DATA_SOURCES" value="true" />
|
19 |
+
<option name="GROUP_SCHEMA" value="true" />
|
20 |
+
<option name="GROUP_CONTENTS" value="false" />
|
21 |
+
<option name="SORT_POSITIONED" value="false" />
|
22 |
+
<option name="SHOW_EMPTY_GROUPS" value="false" />
|
23 |
+
<option name="AUTO_SCROLL_FROM_SOURCE" value="false" />
|
24 |
+
<option name="HIDDEN_KINDS">
|
25 |
+
<set />
|
26 |
+
</option>
|
27 |
+
<expand />
|
28 |
+
<select />
|
29 |
+
</component>
|
30 |
+
<component name="ProjectId" id="1Q3jb4hpa0g4BTVCOUZwMdXhH6b" />
|
31 |
+
<component name="PropertiesComponent">
|
32 |
+
<property name="WebServerToolWindowFactoryState" value="true" />
|
33 |
+
<property name="WebServerToolWindowPanel.toolwindow.highlight.mappings" value="true" />
|
34 |
+
<property name="WebServerToolWindowPanel.toolwindow.highlight.symlinks" value="true" />
|
35 |
+
<property name="WebServerToolWindowPanel.toolwindow.show.date" value="false" />
|
36 |
+
<property name="WebServerToolWindowPanel.toolwindow.show.permissions" value="false" />
|
37 |
+
<property name="WebServerToolWindowPanel.toolwindow.show.size" value="false" />
|
38 |
+
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
39 |
+
<property name="node.js.detected.package.eslint" value="true" />
|
40 |
+
<property name="node.js.detected.package.tslint" value="true" />
|
41 |
+
<property name="node.js.path.for.package.eslint" value="project" />
|
42 |
+
<property name="node.js.path.for.package.tslint" value="project" />
|
43 |
+
<property name="node.js.selected.package.eslint" value="(autodetect)" />
|
44 |
+
<property name="node.js.selected.package.tslint" value="(autodetect)" />
|
45 |
+
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
|
46 |
+
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
|
47 |
+
</component>
|
48 |
+
<component name="RunDashboard">
|
49 |
+
<option name="ruleStates">
|
50 |
+
<list>
|
51 |
+
<RuleState>
|
52 |
+
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
|
53 |
+
</RuleState>
|
54 |
+
<RuleState>
|
55 |
+
<option name="name" value="StatusDashboardGroupingRule" />
|
56 |
+
</RuleState>
|
57 |
+
</list>
|
58 |
+
</option>
|
59 |
+
</component>
|
60 |
+
<component name="SvnConfiguration">
|
61 |
+
<configuration />
|
62 |
+
</component>
|
63 |
+
<component name="TaskManager">
|
64 |
+
<task active="true" id="Default" summary="Default task">
|
65 |
+
<changelist id="658d276d-bb11-426c-bf41-b1de1f52d7f6" name="Default Changelist" comment="" />
|
66 |
+
<created>1567006241287</created>
|
67 |
+
<option name="number" value="Default" />
|
68 |
+
<option name="presentableId" value="Default" />
|
69 |
+
<updated>1567006241287</updated>
|
70 |
+
<workItem from="1567006242850" duration="1872000" />
|
71 |
+
<workItem from="1569337570169" duration="4253000" />
|
72 |
+
<workItem from="1571843104065" duration="1508000" />
|
73 |
+
<workItem from="1572463332457" duration="478000" />
|
74 |
+
<workItem from="1572538474503" duration="6301000" />
|
75 |
+
<workItem from="1572550103057" duration="691000" />
|
76 |
+
</task>
|
77 |
+
<servers />
|
78 |
+
</component>
|
79 |
+
<component name="TypeScriptGeneratedFilesManager">
|
80 |
+
<option name="version" value="1" />
|
81 |
+
</component>
|
82 |
+
</project>
|
README.txt
CHANGED
@@ -3,11 +3,11 @@ Contributors: ryanhungate, Mailchimp
|
|
3 |
Tags: ecommerce,email,workflows,mailchimp
|
4 |
Donate link: https://mailchimp.com
|
5 |
Requires at least: 4.9
|
6 |
-
Tested up to: 5.2.
|
7 |
-
Stable tag: 2.
|
8 |
Requires PHP: 7.0
|
9 |
WC requires at least: 3.5
|
10 |
-
WC tested up to: 3.7
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
Connect your store to your Mailchimp audience to track sales, create targeted emails, send abandoned cart emails, and more.
|
@@ -63,14 +63,22 @@ The Mailchimp for WooCommerce supports Wordpress Multi Sites and below are a few
|
|
63 |
- Deleting removes the connection between Mailchimp and WooCommerce, and uninstalls the plugin from your site.
|
64 |
Refer to the Wordpress Codex for more information about [Multisite Network Administration](https://codex.wordpress.org/Multisite_Network_Administration)
|
65 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
= 2.2 =
|
67 |
* plugin reskin
|
68 |
* support for oauth to Mailchimp
|
69 |
* fixes sync issues with altered order IDs
|
70 |
* fixes issues with trashed coupons
|
71 |
= 2.1.17 =
|
72 |
-
*
|
73 |
-
*
|
74 |
* fixes issues with cloudflare
|
75 |
* honors woo currency settings
|
76 |
* fix for failing custom coupon type
|
3 |
Tags: ecommerce,email,workflows,mailchimp
|
4 |
Donate link: https://mailchimp.com
|
5 |
Requires at least: 4.9
|
6 |
+
Tested up to: 5.2.5
|
7 |
+
Stable tag: 2.3
|
8 |
Requires PHP: 7.0
|
9 |
WC requires at least: 3.5
|
10 |
+
WC tested up to: 3.7.1
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
Connect your store to your Mailchimp audience to track sales, create targeted emails, send abandoned cart emails, and more.
|
63 |
- Deleting removes the connection between Mailchimp and WooCommerce, and uninstalls the plugin from your site.
|
64 |
Refer to the Wordpress Codex for more information about [Multisite Network Administration](https://codex.wordpress.org/Multisite_Network_Administration)
|
65 |
== Changelog ==
|
66 |
+
= 2.3 =
|
67 |
+
* adds action scheduler queue system
|
68 |
+
* documentation for Custom Merge Tags
|
69 |
+
* adds more specific installation requirements
|
70 |
+
* fixes PHP Error in class-mailchimp-order.php
|
71 |
+
* fixes pop up blocks on connection
|
72 |
+
* fixes unable to sync without accepting to auto subscribe existing customers
|
73 |
+
* documentation for wp-cli class queue-command
|
74 |
= 2.2 =
|
75 |
* plugin reskin
|
76 |
* support for oauth to Mailchimp
|
77 |
* fixes sync issues with altered order IDs
|
78 |
* fixes issues with trashed coupons
|
79 |
= 2.1.17 =
|
80 |
+
* re add resync button to sync tab, after sync finishes
|
81 |
+
* renamed 'merge_vars' to 'merge_fields' as per new Mailchimp naming convention
|
82 |
* fixes issues with cloudflare
|
83 |
* honors woo currency settings
|
84 |
* fix for failing custom coupon type
|
admin/class-mailchimp-woocommerce-admin.php
CHANGED
@@ -67,6 +67,12 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
|
|
67 |
update_option('mailchimp-woocommerce-sync.completed_at', false);
|
68 |
update_option('mailchimp-woocommerce-resource-last-updated', false);
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
return $options;
|
71 |
}
|
72 |
|
@@ -221,6 +227,47 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
|
|
221 |
update_option( $this->plugin_name.'_woo_currency_update', true);
|
222 |
}
|
223 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
}
|
225 |
|
226 |
/**
|
@@ -400,14 +447,6 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
|
|
400 |
'mailchimp_account_info_username' => null,
|
401 |
);
|
402 |
|
403 |
-
if (($failure = mailchimp_woocommerce_check_if_http_worker_fails())) {
|
404 |
-
unset($data['mailchimp_api_key']);
|
405 |
-
$data['active_tab'] = 'api_key';
|
406 |
-
$data['api_ping_error'] = $failure;
|
407 |
-
mailchimp_error('admin@validateCanUseHttpWorker', $failure);
|
408 |
-
return $data;
|
409 |
-
}
|
410 |
-
|
411 |
$api = new MailChimp_WooCommerce_MailChimpApi($data['mailchimp_api_key']);
|
412 |
|
413 |
try {
|
@@ -689,8 +728,8 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
|
|
689 |
$data = array(
|
690 |
'mailchimp_list' => isset($input['mailchimp_list']) ? $input['mailchimp_list'] : $this->getOption('mailchimp_list', ''),
|
691 |
'newsletter_label' => (isset($input['newsletter_label']) && $input['newsletter_label'] != '') ? wp_kses($input['newsletter_label'], $allowed_html) : $this->getOption('newsletter_label', __('Subscribe to our newsletter', 'mc-woocommerce')),
|
692 |
-
|
693 |
-
|
694 |
'mailchimp_checkbox_action' => isset($input['mailchimp_checkbox_action']) ? $input['mailchimp_checkbox_action'] : $this->getOption('mailchimp_checkbox_action', 'woocommerce_after_checkout_billing_form'),
|
695 |
'mailchimp_user_tags' => isset($input['mailchimp_user_tags']) ? implode(",",$sanitized_tags) : $this->getOption('mailchimp_user_tags'),
|
696 |
'mailchimp_product_image_key' => isset($input['mailchimp_product_image_key']) ? $input['mailchimp_product_image_key'] : 'medium',
|
@@ -721,6 +760,7 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
|
|
721 |
$this->setData('sync.config.resync', false);
|
722 |
$this->setData('sync.orders.current_page', 1);
|
723 |
$this->setData('sync.products.current_page', 1);
|
|
|
724 |
$this->setData('sync.syncing', true);
|
725 |
$this->setData('sync.started_at', time());
|
726 |
|
@@ -1251,7 +1291,7 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
|
|
1251 |
$coupon_sync->flagStartSync();
|
1252 |
|
1253 |
// queue up the jobs
|
1254 |
-
mailchimp_handle_or_queue($coupon_sync, 0
|
1255 |
}
|
1256 |
|
1257 |
/**
|
67 |
update_option('mailchimp-woocommerce-sync.completed_at', false);
|
68 |
update_option('mailchimp-woocommerce-resource-last-updated', false);
|
69 |
|
70 |
+
if (($store_id = mailchimp_get_store_id()) && ($mc = mailchimp_get_api())) {
|
71 |
+
if ($mc->deleteStore($store_id)) {
|
72 |
+
mailchimp_log('store.disconnected', 'Store id ' . mailchimp_get_store_id() . ' has been disconnected');
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
return $options;
|
77 |
}
|
78 |
|
227 |
update_option( $this->plugin_name.'_woo_currency_update', true);
|
228 |
}
|
229 |
}
|
230 |
+
|
231 |
+
if($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}mailchimp_jobs';") != $wpdb->prefix.'mailchimp_jobs') {
|
232 |
+
MailChimp_WooCommerce_Activator::create_queue_tables();
|
233 |
+
MailChimp_WooCommerce_Activator::migrate_jobs();
|
234 |
+
}
|
235 |
+
|
236 |
+
if (defined( 'DISABLE_WP_HTTP_WORKER' ) || defined( 'MAILCHIMP_USE_CURL' ) || defined( 'MAILCHIMP_REST_LOCALHOST' ) || defined( 'MAILCHIMP_REST_IP' ) || defined( 'MAILCHIMP_DISABLE_QUEUE') && true === MAILCHIMP_DISABLE_QUEUE) {
|
237 |
+
$constants_used = array();
|
238 |
+
|
239 |
+
if (defined( 'DISABLE_WP_HTTP_WORKER')) {
|
240 |
+
$constants_used[] = 'DISABLE_WP_HTTP_WORKER';
|
241 |
+
}
|
242 |
+
|
243 |
+
if (defined( 'MAILCHIMP_DISABLE_QUEUE')) {
|
244 |
+
$constants_used[] = 'MAILCHIMP_DISABLE_QUEUE';
|
245 |
+
}
|
246 |
+
|
247 |
+
if (defined( 'MAILCHIMP_USE_CURL')) {
|
248 |
+
$constants_used[] = 'MAILCHIMP_USE_CURL';
|
249 |
+
}
|
250 |
+
|
251 |
+
if (defined( 'MAILCHIMP_REST_LOCALHOST')) {
|
252 |
+
$constants_used[] = 'MAILCHIMP_REST_LOCALHOST';
|
253 |
+
}
|
254 |
+
|
255 |
+
if (defined( 'MAILCHIMP_REST_IP')) {
|
256 |
+
$constants_used[] = 'MAILCHIMP_REST_IP';
|
257 |
+
}
|
258 |
+
|
259 |
+
$text = __('Mailchimp for Woocommerce','mc-woocommerce').'<br/>'.
|
260 |
+
'<p id="http-worker-deprecated-message">'.__('We dectected that this site has the following constants defined, likely at wp-config.php file' ,'mc-woocommerce').': '.
|
261 |
+
implode(' | ', $constants_used).'<br/>'.
|
262 |
+
__('These constants are deprecated since Mailchimp for Woocommerce version 2.3. Please refer to the <a href="https://github.com/mailchimp/mc-woocommerce/wiki/">plugin official wiki</a> for further details.' ,'mc-woocommerce').'</p>';
|
263 |
+
|
264 |
+
add_settings_error('mailchimp-woocommerce_notice', $this->plugin_name, $text, 'notice-info');
|
265 |
+
|
266 |
+
if (!isset($_GET['page']) || $_GET['page'] != 'mailchimp-woocommerce') {
|
267 |
+
settings_errors();
|
268 |
+
}
|
269 |
+
}
|
270 |
+
|
271 |
}
|
272 |
|
273 |
/**
|
447 |
'mailchimp_account_info_username' => null,
|
448 |
);
|
449 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
450 |
$api = new MailChimp_WooCommerce_MailChimpApi($data['mailchimp_api_key']);
|
451 |
|
452 |
try {
|
728 |
$data = array(
|
729 |
'mailchimp_list' => isset($input['mailchimp_list']) ? $input['mailchimp_list'] : $this->getOption('mailchimp_list', ''),
|
730 |
'newsletter_label' => (isset($input['newsletter_label']) && $input['newsletter_label'] != '') ? wp_kses($input['newsletter_label'], $allowed_html) : $this->getOption('newsletter_label', __('Subscribe to our newsletter', 'mc-woocommerce')),
|
731 |
+
'mailchimp_auto_subscribe' => isset($input['mailchimp_auto_subscribe']) ? (bool) $input['mailchimp_auto_subscribe'] : $this->getOption('mailchimp_auto_subscribe', '0'),
|
732 |
+
'mailchimp_checkbox_defaults' => $checkbox,
|
733 |
'mailchimp_checkbox_action' => isset($input['mailchimp_checkbox_action']) ? $input['mailchimp_checkbox_action'] : $this->getOption('mailchimp_checkbox_action', 'woocommerce_after_checkout_billing_form'),
|
734 |
'mailchimp_user_tags' => isset($input['mailchimp_user_tags']) ? implode(",",$sanitized_tags) : $this->getOption('mailchimp_user_tags'),
|
735 |
'mailchimp_product_image_key' => isset($input['mailchimp_product_image_key']) ? $input['mailchimp_product_image_key'] : 'medium',
|
760 |
$this->setData('sync.config.resync', false);
|
761 |
$this->setData('sync.orders.current_page', 1);
|
762 |
$this->setData('sync.products.current_page', 1);
|
763 |
+
$this->setData('sync.coupons.current_page', 1);
|
764 |
$this->setData('sync.syncing', true);
|
765 |
$this->setData('sync.started_at', time());
|
766 |
|
1291 |
$coupon_sync->flagStartSync();
|
1292 |
|
1293 |
// queue up the jobs
|
1294 |
+
mailchimp_handle_or_queue($coupon_sync, 0);
|
1295 |
}
|
1296 |
|
1297 |
/**
|
admin/css/mailchimp-woocommerce-admin-settings.css
CHANGED
@@ -654,7 +654,8 @@
|
|
654 |
|
655 |
/* Old styles from tabs.php */
|
656 |
|
657 |
-
#sync-status-message strong
|
|
|
658 |
font-weight:inherit;
|
659 |
}
|
660 |
|
654 |
|
655 |
/* Old styles from tabs.php */
|
656 |
|
657 |
+
#sync-status-message strong,
|
658 |
+
#http-worker-deprecated-message strong {
|
659 |
font-weight:inherit;
|
660 |
}
|
661 |
|
admin/css/mailchimp-woocommerce-admin.css
CHANGED
@@ -1,4 +1,8 @@
|
|
1 |
/**
|
2 |
* All of the CSS for your admin-specific functionality should be
|
3 |
* included in this file.
|
4 |
-
*/
|
|
|
|
|
|
|
|
1 |
/**
|
2 |
* All of the CSS for your admin-specific functionality should be
|
3 |
* included in this file.
|
4 |
+
*/
|
5 |
+
|
6 |
+
#http-worker-deprecated-message strong {
|
7 |
+
font-weight:inherit;
|
8 |
+
}
|
admin/js/mailchimp-woocommerce-admin.js
CHANGED
@@ -1,33 +1,6 @@
|
|
1 |
(function( $ ) {
|
2 |
'use strict';
|
3 |
|
4 |
-
/**
|
5 |
-
* All of the code for your admin-facing JavaScript source
|
6 |
-
* should reside in this file.
|
7 |
-
*
|
8 |
-
* Note: It has been assumed you will write jQuery code here, so the
|
9 |
-
* $ function reference has been prepared for usage within the scope
|
10 |
-
* of this function.
|
11 |
-
*
|
12 |
-
* This enables you to define handlers, for when the DOM is ready:
|
13 |
-
*
|
14 |
-
* $(function() {
|
15 |
-
*
|
16 |
-
* });
|
17 |
-
*
|
18 |
-
* When the window is loaded:
|
19 |
-
*
|
20 |
-
* $( window ).load(function() {
|
21 |
-
*
|
22 |
-
* });
|
23 |
-
*
|
24 |
-
* ...and/or other possibilities.
|
25 |
-
*
|
26 |
-
* Ideally, it is not considered best practise to attach more than a
|
27 |
-
* single DOM-ready or window-load handler for a particular page.
|
28 |
-
* Although scripts in the WordPress core, Plugins and Themes may be
|
29 |
-
* practising this, we should strive to set a better example in our own work.
|
30 |
-
*/
|
31 |
$( window ).load(function() {
|
32 |
// show/hide wizard tabs tooltips
|
33 |
$('a.wizard-tab').hover(function (e) {
|
@@ -144,10 +117,20 @@
|
|
144 |
var startData = {action:'mailchimp_woocommerce_oauth_start'};
|
145 |
$('#mailchimp-oauth-api-key-valid').hide();
|
146 |
$('#mailchimp-oauth-waiting').show();
|
|
|
147 |
$.post(ajaxurl, startData, function(startResponse) {
|
148 |
if (startResponse.success) {
|
149 |
token = JSON.parse(startResponse.data.body).token;
|
150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
var options = {
|
152 |
path: domain+'/auth/start/'+token,
|
153 |
windowName: 'Mailchimp For WooCommerce OAuth',
|
@@ -161,69 +144,94 @@
|
|
161 |
'copyhistory=no, width=' + options.width +
|
162 |
', height=' + options.height + ', top=' + top + ', left=' + left +
|
163 |
'domain='+domain.replace('https://', '');
|
|
|
|
|
|
|
164 |
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
|
188 |
-
|
189 |
-
if (
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
// get access_token from finishResponse and fill api-key field value including data_center
|
195 |
-
var accessToken = JSON.parse(finishResponse.data.body).access_token + '-' + JSON.parse(finishResponse.data.body).data_center
|
196 |
-
$('#mailchimp-woocommerce-mailchimp-api-key').val(accessToken);
|
197 |
-
|
198 |
-
// always go to next step on success, so change url of wp_http_referer
|
199 |
-
if ($('input[name=mailchimp_woocommerce_wizard_on]').val() == 1) {
|
200 |
-
var query = window.location.href.match(/^(.*)\&/);
|
201 |
-
if (query){
|
202 |
-
history.replaceState({}, "", query[1]);
|
203 |
-
$('input[name=_wp_http_referer]').val(query[1]);
|
204 |
-
}
|
205 |
}
|
206 |
-
// submit api_key/access_token form
|
207 |
-
$('#mailchimp_woocommerce_options').submit();
|
208 |
}
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
}
|
225 |
-
}
|
226 |
-
|
|
|
227 |
});
|
228 |
|
229 |
})( jQuery );
|
1 |
(function( $ ) {
|
2 |
'use strict';
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
$( window ).load(function() {
|
5 |
// show/hide wizard tabs tooltips
|
6 |
$('a.wizard-tab').hover(function (e) {
|
117 |
var startData = {action:'mailchimp_woocommerce_oauth_start'};
|
118 |
$('#mailchimp-oauth-api-key-valid').hide();
|
119 |
$('#mailchimp-oauth-waiting').show();
|
120 |
+
|
121 |
$.post(ajaxurl, startData, function(startResponse) {
|
122 |
if (startResponse.success) {
|
123 |
token = JSON.parse(startResponse.data.body).token;
|
124 |
+
openOAuthPopup(token);
|
125 |
+
}
|
126 |
+
else {
|
127 |
+
console.log("Error: start response:",startResponse);
|
128 |
+
}
|
129 |
+
});
|
130 |
+
});
|
131 |
+
|
132 |
+
function openOAuthPopup(token) {
|
133 |
+
var domain = 'https://woocommerce.mailchimpapp.com';
|
134 |
var options = {
|
135 |
path: domain+'/auth/start/'+token,
|
136 |
windowName: 'Mailchimp For WooCommerce OAuth',
|
144 |
'copyhistory=no, width=' + options.width +
|
145 |
', height=' + options.height + ', top=' + top + ', left=' + left +
|
146 |
'domain='+domain.replace('https://', '');
|
147 |
+
|
148 |
+
// open Mailchimp OAuth popup
|
149 |
+
var popup = window.open(options.path, options.windowName, window_options);
|
150 |
|
151 |
+
if (popup == null) {
|
152 |
+
window.clearInterval(oauthInterval);
|
153 |
+
const swalWithBootstrapButtons = Swal.mixin({
|
154 |
+
customClass: {
|
155 |
+
confirmButton: 'button button-primary tab-content-submit disconnect-button',
|
156 |
+
cancelButton: 'button button-default mc-woocommerce-resync-button disconnect-button'
|
157 |
+
},
|
158 |
+
buttonsStyling: false,
|
159 |
+
})
|
160 |
+
|
161 |
+
swalWithBootstrapButtons.fire({
|
162 |
+
type : 'error',
|
163 |
+
title: 'Login Popup is blocked!',
|
164 |
+
text: 'Please allow your browser to show popups for this page',
|
165 |
+
footer: '<a href="https://mailchimp.com/help/enable-pop-ups-in-your-browser/">How to Enable Pop-ups in Your Browser</a>',
|
166 |
+
showCancelButton: true,
|
167 |
+
cancelButtonColor: '#d33',
|
168 |
+
confirmButtonColor: '#7fad45',
|
169 |
+
cancelButtonText: 'Cancel',
|
170 |
+
confirmButtonText: 'Try again',
|
171 |
+
reverseButtons: true
|
172 |
+
}).then((result) => {
|
173 |
+
if (result.value) {
|
174 |
+
openOAuthPopup(token);
|
175 |
+
}
|
176 |
+
});
|
177 |
+
}
|
178 |
+
else {
|
179 |
+
var oauthInterval = window.setInterval(function(){
|
180 |
+
if (popup.closed) {
|
181 |
+
// clear interval
|
182 |
+
window.clearInterval(oauthInterval);
|
183 |
+
|
184 |
+
// hide/show messages
|
185 |
+
$('#mailchimp-oauth-error').hide();
|
186 |
+
$('#mailchimp-oauth-waiting').hide();
|
187 |
+
$('#mailchimp-oauth-connecting').show();
|
188 |
+
|
189 |
+
// ping status to check if auth was accepted
|
190 |
+
$.post(domain + '/api/status/' + token).done(function(statusData){
|
191 |
+
if (statusData.status == "accepted") {
|
192 |
+
// call for finish endpoint to retrieve access_token
|
193 |
+
var finishData = {
|
194 |
+
action: 'mailchimp_woocommerce_oauth_finish',
|
195 |
+
token: token
|
196 |
+
}
|
197 |
+
$.post(ajaxurl, finishData, function(finishResponse) {
|
198 |
+
if (finishResponse.success) {
|
199 |
+
// hide/show messages
|
200 |
+
$('#mailchimp-oauth-error').hide();
|
201 |
+
$('#mailchimp-oauth-connecting').hide();
|
202 |
+
$('#mailchimp-oauth-connected').show();
|
203 |
+
|
204 |
+
// get access_token from finishResponse and fill api-key field value including data_center
|
205 |
+
var accessToken = JSON.parse(finishResponse.data.body).access_token + '-' + JSON.parse(finishResponse.data.body).data_center
|
206 |
+
$('#mailchimp-woocommerce-mailchimp-api-key').val(accessToken);
|
207 |
|
208 |
+
// always go to next step on success, so change url of wp_http_referer
|
209 |
+
if ($('input[name=mailchimp_woocommerce_wizard_on]').val() == 1) {
|
210 |
+
var query = window.location.href.match(/^(.*)\&/);
|
211 |
+
if (query){
|
212 |
+
history.replaceState({}, "", query[1]);
|
213 |
+
$('input[name=_wp_http_referer]').val(query[1]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
}
|
|
|
|
|
215 |
}
|
216 |
+
// submit api_key/access_token form
|
217 |
+
$('#mailchimp_woocommerce_options').submit();
|
218 |
+
}
|
219 |
+
else {
|
220 |
+
console.log('Error calling OAuth finish endpoint. Data:', finishResponse);
|
221 |
+
}
|
222 |
+
});
|
223 |
+
}
|
224 |
+
else {
|
225 |
+
$('#mailchimp-oauth-connecting').hide();
|
226 |
+
$('#mailchimp-oauth-error').show();
|
227 |
+
console.log('Error calling OAuth status endpoint. No credentials provided at login popup? Data:', statusData);
|
228 |
+
}
|
229 |
+
});
|
230 |
+
}
|
231 |
+
}, 250);
|
232 |
+
}
|
233 |
+
// While the popup is open, wait. when closed, try to get status=accepted
|
234 |
+
}
|
235 |
});
|
236 |
|
237 |
})( jQuery );
|
admin/partials/mailchimp-woocommerce-admin-tabs.php
CHANGED
@@ -57,9 +57,6 @@ if (isset($options['mailchimp_api_key'])) {
|
|
57 |
else {
|
58 |
$active_tab = 'api_key';
|
59 |
}
|
60 |
-
if (mailchimp_should_init_rest_queue() && !get_site_transient('http_worker_queue_listen')) {
|
61 |
-
mailchimp_call_rest_api_queue_manually();
|
62 |
-
}
|
63 |
|
64 |
?>
|
65 |
|
57 |
else {
|
58 |
$active_tab = 'api_key';
|
59 |
}
|
|
|
|
|
|
|
60 |
|
61 |
?>
|
62 |
|
admin/partials/tabs/api_key.php
CHANGED
@@ -14,6 +14,7 @@
|
|
14 |
<p id="mailchimp-oauth-api-key-valid"><?php esc_html_e('Already connected. You can reconnect with another Mailchimp account if you want.' , 'mc-woocommerce');?></p>
|
15 |
<?php endif;?>
|
16 |
<p id="mailchimp-oauth-waiting" class="oauth-description"><?php esc_html_e('Connecting. A new window will open with Mailchimp\'s OAuth service. Please log-in an we will take care of the rest.' , 'mc-woocommerce');?></p>
|
|
|
17 |
<p id="mailchimp-oauth-connecting" class="oauth-description"><?php esc_html_e('Connection in progress' , 'mc-woocommerce');?></p>
|
18 |
<p id="mailchimp-oauth-connected" class="oauth-description "><?php esc_html_e('Connected! Please wait while loading next step', 'mc-woocommerce');?></p>
|
19 |
</fieldset>
|
14 |
<p id="mailchimp-oauth-api-key-valid"><?php esc_html_e('Already connected. You can reconnect with another Mailchimp account if you want.' , 'mc-woocommerce');?></p>
|
15 |
<?php endif;?>
|
16 |
<p id="mailchimp-oauth-waiting" class="oauth-description"><?php esc_html_e('Connecting. A new window will open with Mailchimp\'s OAuth service. Please log-in an we will take care of the rest.' , 'mc-woocommerce');?></p>
|
17 |
+
<p id="mailchimp-oauth-error" class="oauth-description"><?php esc_html_e('Error, can\'t login.' , 'mc-woocommerce');?></p>
|
18 |
<p id="mailchimp-oauth-connecting" class="oauth-description"><?php esc_html_e('Connection in progress' , 'mc-woocommerce');?></p>
|
19 |
<p id="mailchimp-oauth-connected" class="oauth-description "><?php esc_html_e('Connected! Please wait while loading next step', 'mc-woocommerce');?></p>
|
20 |
</fieldset>
|
admin/partials/tabs/newsletter_settings.php
CHANGED
@@ -44,7 +44,7 @@ $list_is_configured = isset($options['mailchimp_list']) && (!empty($options['mai
|
|
44 |
<select name="<?php echo $this->plugin_name; ?>[mailchimp_list]" required <?php if($list_is_configured): ?> disabled <?php endif; ?>>
|
45 |
|
46 |
<?php if(!isset($allow_new_list) || $allow_new_list === true): ?>
|
47 |
-
|
48 |
<?php endif ?>
|
49 |
|
50 |
<?php if(isset($allow_new_list) && $allow_new_list === false): ?>
|
@@ -62,16 +62,16 @@ $list_is_configured = isset($options['mailchimp_list']) && (!empty($options['mai
|
|
62 |
</select>
|
63 |
</div>
|
64 |
</div>
|
65 |
-
|
66 |
<div class="box" >
|
67 |
<?php $enable_auto_subscribe = (array_key_exists('mailchimp_auto_subscribe', $options) && !is_null($options['mailchimp_auto_subscribe'])) ? $options['mailchimp_auto_subscribe'] : '1'; ?>
|
68 |
<label>
|
69 |
-
<input
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
<?= $list_is_configured ? 'disabled': '' ?>
|
74 |
-
|
75 |
<?= $enable_auto_subscribe ? 'checked' : ''?>>
|
76 |
<strong><?php esc_html_e('During initial sync, auto subscribe the existing customers.', 'mc-woocommerce'); ?></strong>
|
77 |
</label>
|
@@ -128,7 +128,7 @@ $list_is_configured = isset($options['mailchimp_list']) && (!empty($options['mai
|
|
128 |
</div>
|
129 |
|
130 |
<div class="box box-half margin-large">
|
131 |
-
<input type="text" id="<?php echo $this->plugin_name; ?>-newsletter-checkbox-action" name="<?php echo $this->plugin_name; ?>[mailchimp_checkbox_action]" value="<?php echo isset($options['mailchimp_checkbox_action']) ? $options['mailchimp_checkbox_action'] : 'woocommerce_after_checkout_billing_form' ?>" />
|
132 |
<p class="description"><?php esc_html_e('Enter a WooCommerce form action', 'mc-woocommerce'); ?></p>
|
133 |
</div>
|
134 |
|
@@ -158,7 +158,7 @@ $list_is_configured = isset($options['mailchimp_list']) && (!empty($options['mai
|
|
158 |
<p><?= __( 'Define the product image size used by abandoned carts, order notifications, and product recommendations.', 'mc-woocommerce' ); ?></p>
|
159 |
</label>
|
160 |
</div>
|
161 |
-
|
162 |
<div class="box box-half" >
|
163 |
<label for="<?php echo $this->plugin_name; ?>-mailchimp-product_image_key">
|
164 |
<span><?php esc_html_e('Size', 'mc-woocommerce'); ?></span>
|
44 |
<select name="<?php echo $this->plugin_name; ?>[mailchimp_list]" required <?php if($list_is_configured): ?> disabled <?php endif; ?>>
|
45 |
|
46 |
<?php if(!isset($allow_new_list) || $allow_new_list === true): ?>
|
47 |
+
<option value="create_new"><?php esc_html_e('Create New Audience', 'mc-woocommerce');?></option>
|
48 |
<?php endif ?>
|
49 |
|
50 |
<?php if(isset($allow_new_list) && $allow_new_list === false): ?>
|
62 |
</select>
|
63 |
</div>
|
64 |
</div>
|
65 |
+
|
66 |
<div class="box" >
|
67 |
<?php $enable_auto_subscribe = (array_key_exists('mailchimp_auto_subscribe', $options) && !is_null($options['mailchimp_auto_subscribe'])) ? $options['mailchimp_auto_subscribe'] : '1'; ?>
|
68 |
<label>
|
69 |
+
<input
|
70 |
+
type="checkbox"
|
71 |
+
name="<?php echo $this->plugin_name; ?>[mailchimp_auto_subscribe]"
|
72 |
+
id="<?php echo $this->plugin_name; ?>[mailchimp_auto_subscribe]"
|
73 |
<?= $list_is_configured ? 'disabled': '' ?>
|
74 |
+
value=1
|
75 |
<?= $enable_auto_subscribe ? 'checked' : ''?>>
|
76 |
<strong><?php esc_html_e('During initial sync, auto subscribe the existing customers.', 'mc-woocommerce'); ?></strong>
|
77 |
</label>
|
128 |
</div>
|
129 |
|
130 |
<div class="box box-half margin-large">
|
131 |
+
<input type="text" id="<?php echo $this->plugin_name; ?>-newsletter-checkbox-action" name="<?php echo $this->plugin_name; ?>[mailchimp_checkbox_action]" value="<?php echo isset($options['mailchimp_checkbox_action']) ? $options['mailchimp_checkbox_action'] : 'woocommerce_after_checkout_billing_form' ?>" />
|
132 |
<p class="description"><?php esc_html_e('Enter a WooCommerce form action', 'mc-woocommerce'); ?></p>
|
133 |
</div>
|
134 |
|
158 |
<p><?= __( 'Define the product image size used by abandoned carts, order notifications, and product recommendations.', 'mc-woocommerce' ); ?></p>
|
159 |
</label>
|
160 |
</div>
|
161 |
+
|
162 |
<div class="box box-half" >
|
163 |
<label for="<?php echo $this->plugin_name; ?>-mailchimp-product_image_key">
|
164 |
<span><?php esc_html_e('Size', 'mc-woocommerce'); ?></span>
|
admin/partials/tabs/store_sync.php
CHANGED
@@ -49,7 +49,7 @@ if (($mailchimp_api = mailchimp_get_api()) && ($store = $mailchimp_api->getStore
|
|
49 |
try {
|
50 |
$promo_rules = $mailchimp_api->getPromoRules($store_id, 1, 1, 1);
|
51 |
$mailchimp_total_promo_rules = $promo_rules['total_items'];
|
52 |
-
if ($mailchimp_total_promo_rules > $promo_rules_count['publish']) $mailchimp_total_promo_rules = $promo_rules_count['publish'];
|
53 |
} catch (\Exception $e) { $mailchimp_total_promo_rules = 0; }
|
54 |
try {
|
55 |
$products = $mailchimp_api->products($store_id, 1, 1);
|
@@ -188,9 +188,9 @@ if (($mailchimp_api = mailchimp_get_api()) && ($store = $mailchimp_api->getStore
|
|
188 |
|
189 |
<h2 style="padding-top: 1em;"><?php esc_html_e('More Information', 'mc-woocommerce'); ?></h2>
|
190 |
<ul>
|
|
|
191 |
<li><?= sprintf(/* translators: %s - WP-CLI URL. */wp_kses( __( 'Have a larger store or having issues syncing? Consider using <a href=%s target=_blank>WP-CLI</a>.', 'mc-woocommerce' ), array( 'a' => array( 'href' => array(), 'target'=> '_blank' ) ) ), esc_url( 'https://github.com/mailchimp/mc-woocommerce/issues/158' ) );?></li>
|
192 |
<li><?= esc_html__('Order and customer information will not sync if they contain an Amazon or generic email address.', 'mc-woocommerce');?></li>
|
193 |
<li><?= sprintf(/* translators: %s - Mailchimp Support URL. */wp_kses( __( 'Need help to connect your store? Visit the Mailchimp <a href=%s target=_blank>Knowledge Base</a>.', 'mc-woocommerce' ), array( 'a' => array( 'href' => array(), 'target'=> '_blank' ) ) ), esc_url( 'https://mailchimp.com/help/connect-or-disconnect-mailchimp-for-woocommerce/' ) );?></li>
|
194 |
-
<li><?= sprintf(/* translators: %s - Plugin review URL. */wp_kses( __( 'Want to tell us how we\'re doing? <a href=%s target=_blank>Leave a review on Wordpress.org</a>.', 'mc-woocommerce' ), array( 'a' => array( 'href' => array(), 'target'=> '_blank' ) ) ), esc_url( 'https://wordpress.org/support/plugin/mailchimp-for-woocommerce/reviews/' ) );?></li>
|
195 |
<li><?= sprintf(/* translators: %s - Mailchimp Privacy Policy URL. */wp_kses( __( 'By using this plugin, Mailchimp will process customer information in accordance with their <a href=%s target=_blank>Privacy Policy</a>.', 'mc-woocommerce' ), array( 'a' => array( 'href' => array(), 'target'=> '_blank' ) ) ), esc_url( 'https://mailchimp.com/legal/privacy/' ) );?></li>
|
196 |
</ul>
|
49 |
try {
|
50 |
$promo_rules = $mailchimp_api->getPromoRules($store_id, 1, 1, 1);
|
51 |
$mailchimp_total_promo_rules = $promo_rules['total_items'];
|
52 |
+
if (isset($promo_rules_count['publish']) && $mailchimp_total_promo_rules > $promo_rules_count['publish']) $mailchimp_total_promo_rules = $promo_rules_count['publish'];
|
53 |
} catch (\Exception $e) { $mailchimp_total_promo_rules = 0; }
|
54 |
try {
|
55 |
$products = $mailchimp_api->products($store_id, 1, 1);
|
188 |
|
189 |
<h2 style="padding-top: 1em;"><?php esc_html_e('More Information', 'mc-woocommerce'); ?></h2>
|
190 |
<ul>
|
191 |
+
<li><?= sprintf(/* translators: %s - Plugin review URL. */wp_kses( __( 'Is this plugin helping your e-commerce business? <a href=%s target=_blank>Please leave us a ★★★★★ review!</a>.', 'mc-woocommerce' ), array( 'a' => array( 'href' => array(), 'target'=> '_blank' ) ) ), esc_url( 'https://wordpress.org/support/plugin/mailchimp-for-woocommerce/reviews/' ) );?></li>
|
192 |
<li><?= sprintf(/* translators: %s - WP-CLI URL. */wp_kses( __( 'Have a larger store or having issues syncing? Consider using <a href=%s target=_blank>WP-CLI</a>.', 'mc-woocommerce' ), array( 'a' => array( 'href' => array(), 'target'=> '_blank' ) ) ), esc_url( 'https://github.com/mailchimp/mc-woocommerce/issues/158' ) );?></li>
|
193 |
<li><?= esc_html__('Order and customer information will not sync if they contain an Amazon or generic email address.', 'mc-woocommerce');?></li>
|
194 |
<li><?= sprintf(/* translators: %s - Mailchimp Support URL. */wp_kses( __( 'Need help to connect your store? Visit the Mailchimp <a href=%s target=_blank>Knowledge Base</a>.', 'mc-woocommerce' ), array( 'a' => array( 'href' => array(), 'target'=> '_blank' ) ) ), esc_url( 'https://mailchimp.com/help/connect-or-disconnect-mailchimp-for-woocommerce/' ) );?></li>
|
|
|
195 |
<li><?= sprintf(/* translators: %s - Mailchimp Privacy Policy URL. */wp_kses( __( 'By using this plugin, Mailchimp will process customer information in accordance with their <a href=%s target=_blank>Privacy Policy</a>.', 'mc-woocommerce' ), array( 'a' => array( 'href' => array(), 'target'=> '_blank' ) ) ), esc_url( 'https://mailchimp.com/legal/privacy/' ) );?></li>
|
196 |
</ul>
|
bootstrap.php
CHANGED
@@ -20,8 +20,8 @@ spl_autoload_register(function($class) {
|
|
20 |
'MailChimp_WooCommerce' => 'includes/class-mailchimp-woocommerce.php',
|
21 |
'MailChimp_WooCommerce_Privacy' => 'includes/class-mailchimp-woocommerce-privacy.php',
|
22 |
'Mailchimp_Woocommerce_Deactivation_Survey' => 'includes/class-mailchimp-woocommerce-deactivation-survey.php',
|
23 |
-
'MailChimp_WooCommerce_Queue' => 'includes/class-mailchimp-woocommerce-queue.php',
|
24 |
'MailChimp_WooCommerce_Rest_Api' => 'includes/class-mailchimp-woocommerce-rest-api.php',
|
|
|
25 |
|
26 |
// includes/api/assets
|
27 |
'MailChimp_WooCommerce_Address' => 'includes/api/assets/class-mailchimp-address.php',
|
@@ -53,6 +53,7 @@ spl_autoload_register(function($class) {
|
|
53 |
'MailChimp_WooCommerce_Transform_Products' => 'includes/api/class-mailchimp-woocommerce-transform-products.php',
|
54 |
|
55 |
// includes/processes
|
|
|
56 |
'MailChimp_WooCommerce_Abstract_Sync' => 'includes/processes/class-mailchimp-woocommerce-abstract-sync.php',
|
57 |
'MailChimp_WooCommerce_Cart_Update' => 'includes/processes/class-mailchimp-woocommerce-cart-update.php',
|
58 |
'MailChimp_WooCommerce_Process_Coupons' => 'includes/processes/class-mailchimp-woocommerce-process-coupons.php',
|
@@ -63,15 +64,12 @@ spl_autoload_register(function($class) {
|
|
63 |
'MailChimp_WooCommerce_Single_Order' => 'includes/processes/class-mailchimp-woocommerce-single-order.php',
|
64 |
'MailChimp_WooCommerce_Single_Product' => 'includes/processes/class-mailchimp-woocommerce-single-product.php',
|
65 |
'MailChimp_WooCommerce_User_Submit' => 'includes/processes/class-mailchimp-woocommerce-user-submit.php',
|
66 |
-
|
67 |
-
|
68 |
'MailChimp_WooCommerce_Public' => 'public/class-mailchimp-woocommerce-public.php',
|
69 |
'MailChimp_WooCommerce_Admin' => 'admin/class-mailchimp-woocommerce-admin.php',
|
70 |
-
|
71 |
-
|
72 |
-
'
|
73 |
-
'WP_Worker' => 'includes/vendor/queue/classes/worker/wp-worker.php',
|
74 |
-
'Queue_Command' => 'includes/vendor/queue/classes/cli/queue-command.php',
|
75 |
);
|
76 |
|
77 |
// if the file exists, require it
|
@@ -92,7 +90,7 @@ function mailchimp_environment_variables() {
|
|
92 |
return (object) array(
|
93 |
'repo' => 'master',
|
94 |
'environment' => 'production', // staging or production
|
95 |
-
'version' => '2.
|
96 |
'php_version' => phpversion(),
|
97 |
'wp_version' => (empty($wp_version) ? 'Unknown' : $wp_version),
|
98 |
'wc_version' => function_exists('WC') ? WC()->version : null,
|
@@ -142,103 +140,96 @@ if (defined( 'WP_CLI' ) && WP_CLI) {
|
|
142 |
}
|
143 |
};
|
144 |
WP_CLI::add_command( 'mailchimp_push', 'mailchimp_cli_push_command');
|
145 |
-
WP_CLI::add_command( 'queue', '
|
146 |
} catch (\Exception $e) {}
|
147 |
}
|
148 |
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
}
|
161 |
-
$wp_queue->push( $job, $delay );
|
162 |
-
do_action( 'wp_queue_job_pushed', $job );
|
163 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
}
|
165 |
|
|
|
166 |
/**
|
167 |
-
* @param
|
168 |
* @param int $delay
|
169 |
* @param bool $force_now
|
170 |
*/
|
171 |
-
function mailchimp_handle_or_queue(
|
172 |
{
|
173 |
-
if ($job instanceof \MailChimp_WooCommerce_Single_Order && isset($job->
|
174 |
// if this is a order process already queued - just skip this
|
175 |
-
if (get_site_transient("mailchimp_order_being_processed_{$job->
|
176 |
-
mailchimp_debug('order_sync.skip', "Order {$job->order_id} already added successfully to queue. Skipping.");
|
177 |
return;
|
178 |
}
|
179 |
// tell the system the order is already queued for processing in this saving process - and we don't need to process it again.
|
180 |
-
set_site_transient( "mailchimp_order_being_processed_{$job->
|
181 |
-
mailchimp_debug('order_sync.transient', "transient set for order {$job->order_id}");
|
182 |
}
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
mailchimp_call_rest_api_queue_manually();
|
189 |
}
|
190 |
}
|
191 |
|
192 |
-
/**
|
193 |
-
* @param bool $job_check
|
194 |
-
* @return bool
|
195 |
-
*/
|
196 |
-
function mailchimp_should_init_rest_queue($job_check = false) {
|
197 |
-
if (mailchimp_running_in_console()) return false;
|
198 |
-
if (mailchimp_queue_is_disabled()) return false;
|
199 |
-
if (!mailchimp_is_configured()) return false;
|
200 |
-
if (mailchimp_http_worker_is_running()) return false;
|
201 |
-
return !$job_check ? true : MailChimp_WooCommerce_Queue::instance()->available_jobs() > 0;
|
202 |
-
}
|
203 |
-
|
204 |
-
/**
|
205 |
-
* @param int $max
|
206 |
-
* @return bool|DateTime
|
207 |
-
*/
|
208 |
-
function mailchimp_get_http_lock_expiration($max = 300) {
|
209 |
-
try {
|
210 |
-
if (($lock_time = (string) get_site_transient('http_worker_lock')) && !empty($lock_time)) {
|
211 |
-
$parts = str_getcsv($lock_time, ' ');
|
212 |
-
if (count($parts) >= 2 && is_numeric($parts[1])) {
|
213 |
-
$lock_duration = apply_filters('http_worker_lock_time', 60);
|
214 |
-
if (empty($lock_duration) || !is_numeric($lock_duration) || ($lock_duration >= $max)) {
|
215 |
-
$lock_duration = $max;
|
216 |
-
}
|
217 |
-
// craft a new date time object
|
218 |
-
$date = new \DateTime();
|
219 |
-
// set the timestamp with the lock duration
|
220 |
-
$date->setTimestamp(((int) $parts[1] + $lock_duration));
|
221 |
-
return $date;
|
222 |
-
}
|
223 |
-
}
|
224 |
-
} catch (\Exception $e) {}
|
225 |
-
return false;
|
226 |
-
}
|
227 |
-
|
228 |
-
/**
|
229 |
-
* @return bool
|
230 |
-
*/
|
231 |
-
function mailchimp_should_reset_http_lock() {
|
232 |
-
return ($lock = mailchimp_get_http_lock_expiration()) && $lock->getTimestamp() < time();
|
233 |
-
}
|
234 |
-
|
235 |
-
/**
|
236 |
-
* @return bool
|
237 |
-
*/
|
238 |
-
function mailchimp_reset_http_lock() {
|
239 |
-
return delete_site_transient( 'http_worker_lock' );
|
240 |
-
}
|
241 |
-
|
242 |
/**
|
243 |
* @param bool $force
|
244 |
* @return bool
|
@@ -754,16 +745,6 @@ function mailchimpi_refresh_connected_site_script(MailChimp_WooCommerce_Store $s
|
|
754 |
return false;
|
755 |
}
|
756 |
|
757 |
-
/**
|
758 |
-
* @return bool
|
759 |
-
*/
|
760 |
-
function mailchimp_detect_admin_ajax() {
|
761 |
-
if (defined('DOING_CRON') && DOING_CRON) return true;
|
762 |
-
if (!is_admin()) return false;
|
763 |
-
if (!defined('DOING_AJAX')) return false;
|
764 |
-
return DOING_AJAX;
|
765 |
-
}
|
766 |
-
|
767 |
/**
|
768 |
* @return string|false
|
769 |
*/
|
@@ -778,32 +759,6 @@ function mailchimp_get_connected_site_script_fragment() {
|
|
778 |
return get_option('mailchimp-woocommerce-script_fragment', false);
|
779 |
}
|
780 |
|
781 |
-
/**
|
782 |
-
* @return bool
|
783 |
-
*/
|
784 |
-
function mailchimp_running_in_console() {
|
785 |
-
return (bool) (defined( 'DISABLE_WP_HTTP_WORKER' ) && true === DISABLE_WP_HTTP_WORKER);
|
786 |
-
}
|
787 |
-
|
788 |
-
/**
|
789 |
-
* @return bool
|
790 |
-
*/
|
791 |
-
function mailchimp_queue_is_disabled() {
|
792 |
-
return (bool) (defined( 'MAILCHIMP_DISABLE_QUEUE' ) && true === MAILCHIMP_DISABLE_QUEUE);
|
793 |
-
}
|
794 |
-
|
795 |
-
/**
|
796 |
-
* @return bool
|
797 |
-
*/
|
798 |
-
function mailchimp_http_worker_is_running() {
|
799 |
-
if (mailchimp_should_reset_http_lock()) {
|
800 |
-
mailchimp_reset_http_lock();
|
801 |
-
mailchimp_log('http_worker_lock', "HTTP worker lock needed to be deleted to initiate the queue.");
|
802 |
-
return false;
|
803 |
-
}
|
804 |
-
return (bool) get_site_transient('http_worker_lock');
|
805 |
-
}
|
806 |
-
|
807 |
/**
|
808 |
* @param $email
|
809 |
* @return bool
|
@@ -815,7 +770,6 @@ function mailchimp_email_is_allowed($email) {
|
|
815 |
return true;
|
816 |
}
|
817 |
|
818 |
-
|
819 |
/**
|
820 |
* @param $email
|
821 |
* @return bool
|
@@ -840,268 +794,6 @@ function mailchimp_hash_trim_lower($str) {
|
|
840 |
return md5(trim(strtolower($str)));
|
841 |
}
|
842 |
|
843 |
-
/**
|
844 |
-
* @return array|WP_Error
|
845 |
-
*/
|
846 |
-
function mailchimp_call_rest_api_queue_manually() {
|
847 |
-
return MailChimp_WooCommerce_Rest_Api::work();
|
848 |
-
}
|
849 |
-
|
850 |
-
/**
|
851 |
-
* @return array|WP_Error
|
852 |
-
*/
|
853 |
-
function mailchimp_call_rest_api_test() {
|
854 |
-
return MailChimp_WooCommerce_Rest_Api::test();
|
855 |
-
}
|
856 |
-
|
857 |
-
/**
|
858 |
-
* @return bool
|
859 |
-
*/
|
860 |
-
function mailchimp_should_use_local_curl_for_rest_api() {
|
861 |
-
return defined('MAILCHIMP_USE_CURL') && MAILCHIMP_USE_CURL;
|
862 |
-
}
|
863 |
-
|
864 |
-
/**
|
865 |
-
* @return int
|
866 |
-
*/
|
867 |
-
function mailchimp_get_local_curl_http_version() {
|
868 |
-
return defined('MAILCHIMP_USE_LOCAL_CURL_VERSION') ? MAILCHIMP_USE_LOCAL_CURL_VERSION : CURL_HTTP_VERSION_1_1;
|
869 |
-
}
|
870 |
-
|
871 |
-
/**
|
872 |
-
* @return bool|string
|
873 |
-
*/
|
874 |
-
function mailchimp_get_curlopt_interface_ip() {
|
875 |
-
return defined('MAILCHIMP_USE_OUTBOUND_IP') ? MAILCHIMP_USE_OUTBOUND_IP : false;
|
876 |
-
}
|
877 |
-
|
878 |
-
/**
|
879 |
-
* @return bool|string domain name
|
880 |
-
*/
|
881 |
-
function mailchimp_get_local_rest_domain_or_ip() {
|
882 |
-
if (defined('MAILCHIMP_REST_IP')) {
|
883 |
-
return MAILCHIMP_REST_IP;
|
884 |
-
} else if (defined('MAILCHIMP_REST_LOCALHOST')) {
|
885 |
-
return 'localhost';
|
886 |
-
} else {
|
887 |
-
return false;
|
888 |
-
}
|
889 |
-
}
|
890 |
-
|
891 |
-
/**
|
892 |
-
* @return string url
|
893 |
-
*/
|
894 |
-
function mailchimp_apply_local_rest_api_override($url, $alternate_host) {
|
895 |
-
$parsed_url = parse_url($url);
|
896 |
-
$p = array();
|
897 |
-
$p['scheme'] = isset( $parsed_url['scheme'] ) ? $parsed_url['scheme'] . '://' : '';
|
898 |
-
$p['host'] = $alternate_host;
|
899 |
-
$p['port'] = isset( $parsed_url['port'] ) ? ':' . $parsed_url['port'] : '';
|
900 |
-
$p['user'] = isset( $parsed_url['user'] ) ? $parsed_url['user'] : '';
|
901 |
-
$p['pass'] = isset( $parsed_url['pass'] ) ? ':' . $parsed_url['pass'] : '';
|
902 |
-
$p['pass'] = ( $p['user'] || $p['pass'] ) ? $p['pass']."@" : '';
|
903 |
-
$p['path'] = isset( $parsed_url['path'] ) ? $parsed_url['path'] : '';
|
904 |
-
$p['query'] = isset( $parsed_url['query'] ) ? '?' . $parsed_url['query'] : '';
|
905 |
-
$p['fragment'] = isset( $parsed_url['fragment'] ) ? '#' . $parsed_url['fragment'] : '';
|
906 |
-
|
907 |
-
return $url = $p['scheme'].$p['user'].$p['pass'].$p['host'].$p['port'].$p['path'].$p['query'].$p['fragment'];
|
908 |
-
}
|
909 |
-
|
910 |
-
|
911 |
-
/**
|
912 |
-
* @return bool|string
|
913 |
-
*/
|
914 |
-
function mailchimp_woocommerce_check_if_http_worker_fails() {
|
915 |
-
|
916 |
-
// if the user has defined that they are going to use the queue from the console, we can just return false here.
|
917 |
-
// this means they've agreed to run the queue from a CLI version instead.
|
918 |
-
if (mailchimp_running_in_console()) {
|
919 |
-
return false;
|
920 |
-
}
|
921 |
-
|
922 |
-
// if the function doesn't exist we can't do anything.
|
923 |
-
if (!mailchimp_should_use_local_curl_for_rest_api() && !function_exists('wp_remote_post')) {
|
924 |
-
mailchimp_set_data('test.can.remote_post', false);
|
925 |
-
mailchimp_set_data('test.can.remote_post.error', 'function "wp_remote_post" does not exist');
|
926 |
-
return __('function "wp_remote_post" does not exist', 'mc-woocommerce');
|
927 |
-
}
|
928 |
-
|
929 |
-
// apply a blocking call to make sure we get the response back
|
930 |
-
$response = mailchimp_call_rest_api_test();
|
931 |
-
|
932 |
-
if (is_wp_error($response)) {
|
933 |
-
// nope, we have problems
|
934 |
-
mailchimp_set_data('test.can.remote_post', false);
|
935 |
-
mailchimp_set_data('test.can.remote_post.error', $response->get_error_message());
|
936 |
-
return $response->get_error_message();
|
937 |
-
} elseif (is_array($response) && isset($response['http_response']) && ($r = $response['http_response'])) {
|
938 |
-
/** @var \WP_HTTP_Requests_Response $r */
|
939 |
-
if ((int) $r->get_status() !== 200) {
|
940 |
-
$message = __('The REST API seems to be disabled on this wordpress site. Please enable to sync data.', 'mc-woocommerce');
|
941 |
-
mailchimp_set_data('test.can.remote_post', false);
|
942 |
-
mailchimp_set_data('test.can.remote_post.error', $message);
|
943 |
-
mailchimp_error('test.rest_api', '', array(
|
944 |
-
'status' => $r->get_status(),
|
945 |
-
'body' => $r->get_data(),
|
946 |
-
));
|
947 |
-
return $message;
|
948 |
-
}
|
949 |
-
}
|
950 |
-
|
951 |
-
// yep all good.
|
952 |
-
mailchimp_set_data('test.can.remote_post', true);
|
953 |
-
mailchimp_set_data('test.can.remote_post.error', false);
|
954 |
-
return false;
|
955 |
-
}
|
956 |
-
|
957 |
-
/**
|
958 |
-
* @param $url
|
959 |
-
* @param array $params
|
960 |
-
* @param array $headers
|
961 |
-
* @return array|mixed|object|WP_Error|null
|
962 |
-
*/
|
963 |
-
function mailchimp_woocommerce_rest_api_get($url, $params = array(), $headers = array()) {
|
964 |
-
$alternate_host = mailchimp_get_local_rest_domain_or_ip();
|
965 |
-
if ($alternate_host) {
|
966 |
-
$url = mailchimp_apply_local_rest_api_override($url, $alternate_host);
|
967 |
-
}
|
968 |
-
|
969 |
-
if (mailchimp_should_use_local_curl_for_rest_api()) {
|
970 |
-
try {
|
971 |
-
$curl = curl_init();
|
972 |
-
curl_setopt_array($curl, mailchimp_apply_local_curl_options('GET', $url, $params, $headers));
|
973 |
-
return mailchimp_process_local_curl_response($curl);
|
974 |
-
} catch (\Exception $e) {
|
975 |
-
mailchimp_error("mailchimp_woocommerce_rest_api_get", $e->getMessage());
|
976 |
-
return new WP_Error( 'http_request_failed', $e->getMessage());
|
977 |
-
}
|
978 |
-
}
|
979 |
-
|
980 |
-
$params['headers'] = $headers;
|
981 |
-
|
982 |
-
return wp_remote_get($url, $params);
|
983 |
-
}
|
984 |
-
|
985 |
-
/**
|
986 |
-
* @param $method
|
987 |
-
* @param $url
|
988 |
-
* @param array $params
|
989 |
-
* @param array $headers
|
990 |
-
* @return array
|
991 |
-
*/
|
992 |
-
function mailchimp_apply_local_curl_options($method, $url, $params = array(), $headers = array()) {
|
993 |
-
|
994 |
-
$headers = (array) $headers;
|
995 |
-
|
996 |
-
$curl_options = array(
|
997 |
-
CURLOPT_CUSTOMREQUEST => strtoupper($method),
|
998 |
-
CURLOPT_URL => mailchimp_rest_api_url($url, '', $params),
|
999 |
-
CURLOPT_RETURNTRANSFER => true,
|
1000 |
-
CURLOPT_ENCODING => "",
|
1001 |
-
CURLOPT_MAXREDIRS => 10,
|
1002 |
-
CURLOPT_TIMEOUT => $params['timeout'],
|
1003 |
-
CURLOPT_HTTP_VERSION => mailchimp_get_local_curl_http_version(),
|
1004 |
-
CURLINFO_HEADER_OUT => true,
|
1005 |
-
CURLOPT_HTTPHEADER => array_merge(mailchimp_get_http_local_json_header(), $headers)
|
1006 |
-
);
|
1007 |
-
|
1008 |
-
// if we have a dedicated IP address, and have set a configuration for it, we'll use it here.
|
1009 |
-
if (($interface = mailchimp_get_curlopt_interface_ip())) {
|
1010 |
-
$curl_options[CURLOPT_INTERFACE] = $interface;
|
1011 |
-
}
|
1012 |
-
|
1013 |
-
return $curl_options;
|
1014 |
-
}
|
1015 |
-
|
1016 |
-
/**
|
1017 |
-
* @param $curl
|
1018 |
-
* @return array|mixed|object|null
|
1019 |
-
* @throws MailChimp_WooCommerce_Error
|
1020 |
-
* @throws MailChimp_WooCommerce_ServerError
|
1021 |
-
*/
|
1022 |
-
function mailchimp_process_local_curl_response($curl)
|
1023 |
-
{
|
1024 |
-
$response = curl_exec($curl);
|
1025 |
-
$err = curl_error($curl);
|
1026 |
-
$info = curl_getinfo($curl);
|
1027 |
-
curl_close($curl);
|
1028 |
-
if ($err) {
|
1029 |
-
throw new MailChimp_WooCommerce_Error('CURL error :: '.$err, 500);
|
1030 |
-
}
|
1031 |
-
$data = json_decode($response, true);
|
1032 |
-
if (empty($info) || ($info['http_code'] >= 200 && $info['http_code'] <= 400)) {
|
1033 |
-
if (is_array($data)) {
|
1034 |
-
mailchimp_rest_check_for_errors($data);
|
1035 |
-
}
|
1036 |
-
return $data;
|
1037 |
-
}
|
1038 |
-
if ($info['http_code'] >= 400 && $info['http_code'] < 500) {
|
1039 |
-
throw new MailChimp_WooCommerce_Error($data['title'] .' :: '.$data['detail'], $data['status']);
|
1040 |
-
} else if ($info['http_code'] >= 500) {
|
1041 |
-
throw new MailChimp_WooCommerce_ServerError($data['detail'], $data['status']);
|
1042 |
-
}
|
1043 |
-
return json_encode(array('info' => $info, 'response' => $response));
|
1044 |
-
}
|
1045 |
-
|
1046 |
-
/**
|
1047 |
-
* @param array $data
|
1048 |
-
* @return bool
|
1049 |
-
* @throws MailChimp_WooCommerce_Error
|
1050 |
-
*/
|
1051 |
-
function mailchimp_rest_check_for_errors(array $data)
|
1052 |
-
{
|
1053 |
-
// if we have an array of error data push it into a message
|
1054 |
-
if (isset($data['errors'])) {
|
1055 |
-
$message = '';
|
1056 |
-
foreach ($data['errors'] as $error) {
|
1057 |
-
$message .= '<p>'.$error['field'].': '.$error['message'].'</p>';
|
1058 |
-
}
|
1059 |
-
throw new MailChimp_WooCommerce_Error($message, $data['status']);
|
1060 |
-
}
|
1061 |
-
// make sure the response is correct from the data in the response array
|
1062 |
-
if (isset($data['status']) && $data['status'] >= 400) {
|
1063 |
-
throw new MailChimp_WooCommerce_Error($data['detail'], $data['status']);
|
1064 |
-
}
|
1065 |
-
return false;
|
1066 |
-
}
|
1067 |
-
|
1068 |
-
/**
|
1069 |
-
* @param $url
|
1070 |
-
* @param string $extra
|
1071 |
-
* @param null $params
|
1072 |
-
* @return string
|
1073 |
-
*/
|
1074 |
-
function mailchimp_rest_api_url($url, $extra = '', $params = null)
|
1075 |
-
{
|
1076 |
-
if (!empty($extra)) {
|
1077 |
-
$url .= $extra;
|
1078 |
-
}
|
1079 |
-
if (!empty($params)) {
|
1080 |
-
$url .= '?'.(is_array($params) ? http_build_query($params) : $params);
|
1081 |
-
}
|
1082 |
-
return $url;
|
1083 |
-
}
|
1084 |
-
|
1085 |
-
/**
|
1086 |
-
* @return array
|
1087 |
-
*/
|
1088 |
-
function mailchimp_get_http_local_json_header() {
|
1089 |
-
$env = mailchimp_environment_variables();
|
1090 |
-
$server_user_agent = "MailChimp for WooCommerce/{$env->version} PHP/{$env->php_version} WordPress/{$env->wp_version} Woo/{$env->wc_version}";
|
1091 |
-
return array(
|
1092 |
-
'Content-Type' => 'application/json; charset=' . get_option( 'blog_charset' ),
|
1093 |
-
'Accept' => 'application/json',
|
1094 |
-
'User-Agent' => $server_user_agent
|
1095 |
-
);
|
1096 |
-
}
|
1097 |
-
|
1098 |
-
/**
|
1099 |
-
* @return string
|
1100 |
-
*/
|
1101 |
-
function mailchimp_test_http_worker_ajax() {
|
1102 |
-
wp_send_json(array('success' => true), 200);
|
1103 |
-
}
|
1104 |
-
|
1105 |
/**
|
1106 |
* @param $key
|
1107 |
* @param null $default
|
@@ -1209,16 +901,37 @@ function mailchimp_check_if_on_sync_tab() {
|
|
1209 |
return false;
|
1210 |
}
|
1211 |
|
1212 |
-
function
|
1213 |
try {
|
1214 |
/** @var \ */
|
1215 |
global $wpdb;
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
|
|
|
|
1219 |
} catch (\Exception $e) {}
|
1220 |
}
|
1221 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1222 |
function mailchimp_flush_sync_pointers() {
|
1223 |
// clean up the initial sync pointers
|
1224 |
foreach (array('orders', 'products', 'coupons') as $resource_type) {
|
@@ -1232,7 +945,8 @@ function mailchimp_flush_sync_pointers() {
|
|
1232 |
* To be used when running clean up for uninstalls or re-installs.
|
1233 |
*/
|
1234 |
function mailchimp_clean_database() {
|
1235 |
-
|
|
|
1236 |
|
1237 |
// clean up the initial sync pointers
|
1238 |
mailchimp_flush_sync_pointers();
|
@@ -1248,18 +962,6 @@ function mailchimp_clean_database() {
|
|
1248 |
delete_option('mailchimp-woocommerce-errors.store_info');
|
1249 |
}
|
1250 |
|
1251 |
-
/**
|
1252 |
-
* @param array $data
|
1253 |
-
* @param int $status
|
1254 |
-
* @return WP_REST_Response
|
1255 |
-
*/
|
1256 |
-
function mailchimp_rest_response($data, $status = 200) {
|
1257 |
-
if (!is_array($data)) $data = array();
|
1258 |
-
$response = new WP_REST_Response($data);
|
1259 |
-
$response->set_status($status);
|
1260 |
-
return $response;
|
1261 |
-
}
|
1262 |
-
|
1263 |
/**
|
1264 |
* @return bool
|
1265 |
*/
|
20 |
'MailChimp_WooCommerce' => 'includes/class-mailchimp-woocommerce.php',
|
21 |
'MailChimp_WooCommerce_Privacy' => 'includes/class-mailchimp-woocommerce-privacy.php',
|
22 |
'Mailchimp_Woocommerce_Deactivation_Survey' => 'includes/class-mailchimp-woocommerce-deactivation-survey.php',
|
|
|
23 |
'MailChimp_WooCommerce_Rest_Api' => 'includes/class-mailchimp-woocommerce-rest-api.php',
|
24 |
+
'Mailchimp_Wocoomerce_CLI' => 'includes/class-mailchimp-woocommerce-cli.php',
|
25 |
|
26 |
// includes/api/assets
|
27 |
'MailChimp_WooCommerce_Address' => 'includes/api/assets/class-mailchimp-address.php',
|
53 |
'MailChimp_WooCommerce_Transform_Products' => 'includes/api/class-mailchimp-woocommerce-transform-products.php',
|
54 |
|
55 |
// includes/processes
|
56 |
+
'Mailchimp_Woocommerce_Job' => 'includes/processes/class-mailchimp-woocommerce-job.php',
|
57 |
'MailChimp_WooCommerce_Abstract_Sync' => 'includes/processes/class-mailchimp-woocommerce-abstract-sync.php',
|
58 |
'MailChimp_WooCommerce_Cart_Update' => 'includes/processes/class-mailchimp-woocommerce-cart-update.php',
|
59 |
'MailChimp_WooCommerce_Process_Coupons' => 'includes/processes/class-mailchimp-woocommerce-process-coupons.php',
|
64 |
'MailChimp_WooCommerce_Single_Order' => 'includes/processes/class-mailchimp-woocommerce-single-order.php',
|
65 |
'MailChimp_WooCommerce_Single_Product' => 'includes/processes/class-mailchimp-woocommerce-single-product.php',
|
66 |
'MailChimp_WooCommerce_User_Submit' => 'includes/processes/class-mailchimp-woocommerce-user-submit.php',
|
67 |
+
|
|
|
68 |
'MailChimp_WooCommerce_Public' => 'public/class-mailchimp-woocommerce-public.php',
|
69 |
'MailChimp_WooCommerce_Admin' => 'admin/class-mailchimp-woocommerce-admin.php',
|
70 |
+
|
71 |
+
// Queue system Action Scheduler
|
72 |
+
'ActionScheduler' => 'includes/vendor/action-scheduler/action-scheduler.php',
|
|
|
|
|
73 |
);
|
74 |
|
75 |
// if the file exists, require it
|
90 |
return (object) array(
|
91 |
'repo' => 'master',
|
92 |
'environment' => 'production', // staging or production
|
93 |
+
'version' => '2.3',
|
94 |
'php_version' => phpversion(),
|
95 |
'wp_version' => (empty($wp_version) ? 'Unknown' : $wp_version),
|
96 |
'wc_version' => function_exists('WC') ? WC()->version : null,
|
140 |
}
|
141 |
};
|
142 |
WP_CLI::add_command( 'mailchimp_push', 'mailchimp_cli_push_command');
|
143 |
+
WP_CLI::add_command( 'queue', 'Mailchimp_Wocoomerce_CLI' );
|
144 |
} catch (\Exception $e) {}
|
145 |
}
|
146 |
|
147 |
+
/**
|
148 |
+
* Push a job onto the Action Scheduler queue.
|
149 |
+
*
|
150 |
+
* @param Mailchimp_Woocommerce_Job $job
|
151 |
+
* @param int $delay
|
152 |
+
*
|
153 |
+
* @return true
|
154 |
+
*/
|
155 |
+
function mailchimp_as_push( Mailchimp_Woocommerce_Job $job, $delay = 0 ) {
|
156 |
+
global $wpdb;
|
157 |
+
$job_id = isset($job->id) ? $job->id : get_class($job);
|
158 |
+
|
159 |
+
$args = array(
|
160 |
+
'job' => maybe_serialize($job),
|
161 |
+
'obj_id' => $job_id,
|
162 |
+
'created_at' => gmdate( 'Y-m-d H:i:s', time() )
|
163 |
+
);
|
164 |
+
|
165 |
+
$existing_actions = as_get_scheduled_actions(array(
|
166 |
+
'hook' => get_class($job),
|
167 |
+
'status' => ActionScheduler_Store::STATUS_PENDING,
|
168 |
+
'args' => array(
|
169 |
+
'obj_id' => isset($job->id) ? $job->id : null),
|
170 |
+
'group' => 'mc-woocommerce'
|
171 |
+
)
|
172 |
+
);
|
173 |
+
|
174 |
+
if (!empty($existing_actions)) {
|
175 |
+
as_unschedule_action(get_class($job), array('obj_id' => $job->id), 'mc-woocommerce');
|
176 |
+
}
|
177 |
+
else {
|
178 |
+
$inserted = $wpdb->insert($wpdb->prefix."mailchimp_jobs", $args);
|
179 |
+
if (!$inserted) {
|
180 |
+
try {
|
181 |
+
if (mailchimp_string_contains($wpdb->last_error, 'Table')) {
|
182 |
+
mailchimp_debug('DB Issue: `mailchimp_job` table was not found!', 'Creating Tables');
|
183 |
+
install_mailchimp_queue();
|
184 |
+
$inserted = $wpdb->insert($wpdb->prefix."mailchimp_jobs", $args);
|
185 |
+
if (!$inserted) {
|
186 |
+
mailchimp_debug('Queue Job '.get_class($job), $wpdb->last_error);
|
187 |
+
}
|
188 |
+
}
|
189 |
+
} catch (\Exception $e) {
|
190 |
+
mailchimp_error_trace($e, 'trying to create queue tables');
|
191 |
+
}
|
192 |
}
|
|
|
|
|
193 |
}
|
194 |
+
|
195 |
+
// TODO: deal with errors
|
196 |
+
$action = as_schedule_single_action( strtotime( '+'.$delay.' seconds' ), get_class($job), array('obj_id' => $job_id), "mc-woocommerce");
|
197 |
+
|
198 |
+
$message = ($job_id != get_class($job)) ? ' :: obj_id '.$job_id : '';
|
199 |
+
if (!empty($existing_actions)) {
|
200 |
+
mailchimp_debug('action_scheduler.reschedule_job', get_class($job) . ($delay > 0 ? ' restarts in '.$delay. ' seconds' : ' restarts in the next minute' ) . $message);
|
201 |
+
}
|
202 |
+
else {
|
203 |
+
mailchimp_log('action_scheduler.queue_job', get_class($job) . ($delay > 0 ? ' starts in '.$delay. ' seconds' : ' starts in the next minute' ) .$message);
|
204 |
+
}
|
205 |
+
|
206 |
+
return $action;
|
207 |
}
|
208 |
|
209 |
+
|
210 |
/**
|
211 |
+
* @param Mailchimp_Woocommerce_Job $job
|
212 |
* @param int $delay
|
213 |
* @param bool $force_now
|
214 |
*/
|
215 |
+
function mailchimp_handle_or_queue(Mailchimp_Woocommerce_Job $job, $delay = 0)
|
216 |
{
|
217 |
+
if ($job instanceof \MailChimp_WooCommerce_Single_Order && isset($job->id)) {
|
218 |
// if this is a order process already queued - just skip this
|
219 |
+
if (get_site_transient("mailchimp_order_being_processed_{$job->id}") == true) {
|
|
|
220 |
return;
|
221 |
}
|
222 |
// tell the system the order is already queued for processing in this saving process - and we don't need to process it again.
|
223 |
+
set_site_transient( "mailchimp_order_being_processed_{$job->id}", true, 30);
|
|
|
224 |
}
|
225 |
+
|
226 |
+
$as_job_id = mailchimp_as_push($job, $delay);
|
227 |
+
|
228 |
+
if (!is_int($as_job_id)) {
|
229 |
+
mailchimp_log('action_scheduler.queue_fail', get_class($job) .' FAILED :: as_job_id: '.$as_job_id);
|
|
|
230 |
}
|
231 |
}
|
232 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
/**
|
234 |
* @param bool $force
|
235 |
* @return bool
|
745 |
return false;
|
746 |
}
|
747 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
748 |
/**
|
749 |
* @return string|false
|
750 |
*/
|
759 |
return get_option('mailchimp-woocommerce-script_fragment', false);
|
760 |
}
|
761 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
762 |
/**
|
763 |
* @param $email
|
764 |
* @return bool
|
770 |
return true;
|
771 |
}
|
772 |
|
|
|
773 |
/**
|
774 |
* @param $email
|
775 |
* @return bool
|
794 |
return md5(trim(strtolower($str)));
|
795 |
}
|
796 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
797 |
/**
|
798 |
* @param $key
|
799 |
* @param null $default
|
901 |
return false;
|
902 |
}
|
903 |
|
904 |
+
function mailchimp_flush_database_tables() {
|
905 |
try {
|
906 |
/** @var \ */
|
907 |
global $wpdb;
|
908 |
+
|
909 |
+
mailchimp_delete_as_jobs();
|
910 |
+
|
911 |
+
$wpdb->query("TRUNCATE `{$wpdb->prefix}mailchimp_carts`");
|
912 |
+
$wpdb->query("TRUNCATE `{$wpdb->prefix}mailchimp_jobs`");
|
913 |
} catch (\Exception $e) {}
|
914 |
}
|
915 |
|
916 |
+
function mailchimp_delete_as_jobs() {
|
917 |
+
|
918 |
+
$existing_as_actions = as_get_scheduled_actions(
|
919 |
+
array(
|
920 |
+
'status' => ActionScheduler_Store::STATUS_PENDING,
|
921 |
+
'group' => 'mc-woocommerce',
|
922 |
+
'per_page' => -1,
|
923 |
+
)
|
924 |
+
);
|
925 |
+
|
926 |
+
if (!empty($existing_as_actions)) {
|
927 |
+
foreach ($existing_as_actions as $as_action) {
|
928 |
+
as_unschedule_action($as_action->get_hook(), $as_action->get_args(), 'mc-woocommerce'); # code...
|
929 |
+
}
|
930 |
+
return true;
|
931 |
+
}
|
932 |
+
return false;
|
933 |
+
|
934 |
+
}
|
935 |
function mailchimp_flush_sync_pointers() {
|
936 |
// clean up the initial sync pointers
|
937 |
foreach (array('orders', 'products', 'coupons') as $resource_type) {
|
945 |
* To be used when running clean up for uninstalls or re-installs.
|
946 |
*/
|
947 |
function mailchimp_clean_database() {
|
948 |
+
// delete custom tables data
|
949 |
+
mailchimp_flush_database_tables();
|
950 |
|
951 |
// clean up the initial sync pointers
|
952 |
mailchimp_flush_sync_pointers();
|
962 |
delete_option('mailchimp-woocommerce-errors.store_info');
|
963 |
}
|
964 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
965 |
/**
|
966 |
* @return bool
|
967 |
*/
|
includes/api/assets/class-mailchimp-order.php
CHANGED
@@ -212,7 +212,7 @@ class MailChimp_WooCommerce_Order
|
|
212 |
{
|
213 |
$api = MailChimp_WooCommerce_MailChimpApi::getInstance();
|
214 |
$cid = trim($id);
|
215 |
-
if (($campaign = $api->getCampaign($cid, false))
|
216 |
$this->campaign_id = $campaign['id'];
|
217 |
}
|
218 |
return $this;
|
212 |
{
|
213 |
$api = MailChimp_WooCommerce_MailChimpApi::getInstance();
|
214 |
$cid = trim($id);
|
215 |
+
if (!empty($cid) && $campaign = $api->getCampaign($cid, false)) {
|
216 |
$this->campaign_id = $campaign['id'];
|
217 |
}
|
218 |
return $this;
|
includes/api/class-mailchimp-api.php
CHANGED
@@ -182,7 +182,7 @@ class MailChimp_WooCommerce_MailChimpApi
|
|
182 |
public function deleteMember($list_id, $email)
|
183 |
{
|
184 |
$hash = md5(strtolower(trim($email)));
|
185 |
-
return $this->delete("lists/$list_id/members/$hash", array());
|
186 |
}
|
187 |
|
188 |
/**
|
@@ -315,9 +315,9 @@ class MailChimp_WooCommerce_MailChimpApi
|
|
315 |
{
|
316 |
$hash = md5(strtolower(trim($email)));
|
317 |
$tags = mailchimp_get_user_tags_to_update();
|
318 |
-
|
319 |
if (empty($tags)) return false;
|
320 |
-
|
321 |
$data = array(
|
322 |
'tags' => $tags
|
323 |
);
|
@@ -459,7 +459,7 @@ class MailChimp_WooCommerce_MailChimpApi
|
|
459 |
*/
|
460 |
public function deleteList($id)
|
461 |
{
|
462 |
-
return $this->delete('lists/'.$id);
|
463 |
}
|
464 |
|
465 |
/**
|
@@ -593,7 +593,7 @@ class MailChimp_WooCommerce_MailChimpApi
|
|
593 |
set_site_transient('mailchimp-woocommerce-has-campaign-id-'.$campaign_id, $data, 60 * 30);
|
594 |
return $data;
|
595 |
} catch (\Exception $e) {
|
596 |
-
|
597 |
set_site_transient('mailchimp-woocommerce-no-campaign-id-'.$campaign_id, true, 60 * 30);
|
598 |
|
599 |
if (!$throw_if_invalid) {
|
@@ -730,8 +730,7 @@ class MailChimp_WooCommerce_MailChimpApi
|
|
730 |
public function deleteStore($store_id)
|
731 |
{
|
732 |
try {
|
733 |
-
$this->delete("ecommerce/stores/$store_id");
|
734 |
-
return true;
|
735 |
} catch (MailChimp_WooCommerce_Error $e) {
|
736 |
return false;
|
737 |
} catch (\Exception $e) {
|
@@ -883,8 +882,7 @@ class MailChimp_WooCommerce_MailChimpApi
|
|
883 |
public function deleteCartByID($store_id, $id)
|
884 |
{
|
885 |
try {
|
886 |
-
$this->delete("ecommerce/stores/$store_id/carts/$id");
|
887 |
-
return true;
|
888 |
} catch (MailChimp_WooCommerce_Error $e) {
|
889 |
return false;
|
890 |
} catch (\Exception $e) {
|
@@ -924,8 +922,7 @@ class MailChimp_WooCommerce_MailChimpApi
|
|
924 |
public function deleteCustomer($store_id, $customer_id)
|
925 |
{
|
926 |
try {
|
927 |
-
$this->delete("ecommerce/stores/$store_id/customers/$customer_id");
|
928 |
-
return true;
|
929 |
} catch (MailChimp_WooCommerce_Error $e) {
|
930 |
return false;
|
931 |
}
|
@@ -984,7 +981,7 @@ class MailChimp_WooCommerce_MailChimpApi
|
|
984 |
}
|
985 |
$order_id = $order->getId();
|
986 |
$data = $this->patch("ecommerce/stores/{$store_id}/orders/{$order_id}", $order->toArray());
|
987 |
-
|
988 |
//update user tags
|
989 |
$email_address = $order->getCustomer()->getEmailAddress();
|
990 |
|
@@ -1041,8 +1038,7 @@ class MailChimp_WooCommerce_MailChimpApi
|
|
1041 |
public function deleteStoreOrder($store_id, $order_id)
|
1042 |
{
|
1043 |
try {
|
1044 |
-
$this->delete("ecommerce/stores/$store_id/orders/$order_id");
|
1045 |
-
return true;
|
1046 |
} catch (MailChimp_WooCommerce_Error $e) {
|
1047 |
return false;
|
1048 |
}
|
@@ -1058,8 +1054,7 @@ class MailChimp_WooCommerce_MailChimpApi
|
|
1058 |
public function deleteStoreOrderLine($store_id, $order_id, $line_id)
|
1059 |
{
|
1060 |
try {
|
1061 |
-
$this->delete("ecommerce/stores/{$store_id}/orders/{$order_id}/lines/{$line_id}");
|
1062 |
-
return true;
|
1063 |
} catch (MailChimp_WooCommerce_Error $e) {
|
1064 |
return false;
|
1065 |
}
|
@@ -1161,7 +1156,7 @@ class MailChimp_WooCommerce_MailChimpApi
|
|
1161 |
/** @var \MailChimp_WooCommerce_LineItem $order_item */
|
1162 |
$job = new MailChimp_WooCommerce_Single_Product($order_item->getId());
|
1163 |
if ($missing_products[$order_item->getId()] = $job->createModeOnly()->handle()) {
|
1164 |
-
|
1165 |
}
|
1166 |
}
|
1167 |
return $missing_products;
|
@@ -1176,8 +1171,7 @@ class MailChimp_WooCommerce_MailChimpApi
|
|
1176 |
public function deleteStoreProduct($store_id, $product_id)
|
1177 |
{
|
1178 |
try {
|
1179 |
-
$this->delete("ecommerce/stores/$store_id/products/$product_id");
|
1180 |
-
return true;
|
1181 |
} catch (MailChimp_WooCommerce_Error $e) {
|
1182 |
return false;
|
1183 |
}
|
@@ -1585,24 +1579,6 @@ class MailChimp_WooCommerce_MailChimpApi
|
|
1585 |
return $url;
|
1586 |
}
|
1587 |
|
1588 |
-
/**
|
1589 |
-
* @param $method
|
1590 |
-
* @param $url
|
1591 |
-
* @param $body
|
1592 |
-
* @return array|WP_Error
|
1593 |
-
*/
|
1594 |
-
protected function sendWithHttpClient($method, $url, $body)
|
1595 |
-
{
|
1596 |
-
return _wp_http_get_object()->request($this->url($url), array(
|
1597 |
-
'method' => strtoupper($method),
|
1598 |
-
'headers' => array(
|
1599 |
-
'Authorization' => 'Basic ' . base64_encode('mailchimp:'.$this->api_key),
|
1600 |
-
'Content-Type' => 'application/json',
|
1601 |
-
),
|
1602 |
-
'body' => json_encode($body),
|
1603 |
-
));
|
1604 |
-
}
|
1605 |
-
|
1606 |
/**
|
1607 |
* @param $method
|
1608 |
* @param $url
|
@@ -1626,6 +1602,7 @@ class MailChimp_WooCommerce_MailChimpApi
|
|
1626 |
CURLINFO_HEADER_OUT => true,
|
1627 |
CURLOPT_HTTPHEADER => array_merge(array(
|
1628 |
'content-type: application/json',
|
|
|
1629 |
"user-agent: MailChimp for WooCommerce/{$env->version}; PHP/{$env->php_version}; WordPress/{$env->wp_version}; Woo/{$env->wc_version};",
|
1630 |
), $headers)
|
1631 |
);
|
@@ -1640,7 +1617,7 @@ class MailChimp_WooCommerce_MailChimpApi
|
|
1640 |
|
1641 |
/**
|
1642 |
* @param $curl
|
1643 |
-
* @return array|mixed|null|object
|
1644 |
* @throws Exception
|
1645 |
* @throws MailChimp_WooCommerce_Error
|
1646 |
* @throws MailChimp_WooCommerce_ServerError
|
@@ -1660,6 +1637,10 @@ class MailChimp_WooCommerce_MailChimpApi
|
|
1660 |
$data = json_decode($response, true);
|
1661 |
|
1662 |
if (empty($info) || ($info['http_code'] >= 200 && $info['http_code'] <= 400)) {
|
|
|
|
|
|
|
|
|
1663 |
if (is_array($data)) {
|
1664 |
try {
|
1665 |
$this->checkForErrors($data);
|
@@ -1672,12 +1653,11 @@ class MailChimp_WooCommerce_MailChimpApi
|
|
1672 |
|
1673 |
if ($info['http_code'] >= 400 && $info['http_code'] <= 500) {
|
1674 |
if ($info['http_code'] == 404) {
|
1675 |
-
mailchimp_error('api', 'processCurlResponse', array('info' => $info, 'data' => $data));
|
1676 |
}
|
1677 |
if ($info['http_code'] == 403) {
|
1678 |
throw new MailChimp_WooCommerce_RateLimitError();
|
1679 |
}
|
1680 |
-
|
1681 |
throw new MailChimp_WooCommerce_Error($data['title'] .' :: '.$data['detail'], $data['status']);
|
1682 |
}
|
1683 |
|
@@ -1706,7 +1686,7 @@ class MailChimp_WooCommerce_MailChimpApi
|
|
1706 |
|
1707 |
// make sure the response is correct from the data in the response array
|
1708 |
if (isset($data['status']) && $data['status'] >= 400) {
|
1709 |
-
if ($data['http_code'] == 403) {
|
1710 |
throw new MailChimp_WooCommerce_RateLimitError();
|
1711 |
}
|
1712 |
throw new MailChimp_WooCommerce_Error($data['detail'], $data['status']);
|
182 |
public function deleteMember($list_id, $email)
|
183 |
{
|
184 |
$hash = md5(strtolower(trim($email)));
|
185 |
+
return (bool) $this->delete("lists/$list_id/members/$hash", array());
|
186 |
}
|
187 |
|
188 |
/**
|
315 |
{
|
316 |
$hash = md5(strtolower(trim($email)));
|
317 |
$tags = mailchimp_get_user_tags_to_update();
|
318 |
+
|
319 |
if (empty($tags)) return false;
|
320 |
+
|
321 |
$data = array(
|
322 |
'tags' => $tags
|
323 |
);
|
459 |
*/
|
460 |
public function deleteList($id)
|
461 |
{
|
462 |
+
return (bool) $this->delete('lists/'.$id);
|
463 |
}
|
464 |
|
465 |
/**
|
593 |
set_site_transient('mailchimp-woocommerce-has-campaign-id-'.$campaign_id, $data, 60 * 30);
|
594 |
return $data;
|
595 |
} catch (\Exception $e) {
|
596 |
+
mailchimp_debug('campaign_get.error', 'No campaign with provided ID: '. $campaign_id. ' :: '. $e->getMessage(). ' :: in '.$e->getFile().' :: on '.$e->getLine());
|
597 |
set_site_transient('mailchimp-woocommerce-no-campaign-id-'.$campaign_id, true, 60 * 30);
|
598 |
|
599 |
if (!$throw_if_invalid) {
|
730 |
public function deleteStore($store_id)
|
731 |
{
|
732 |
try {
|
733 |
+
return (bool) $this->delete("ecommerce/stores/$store_id");
|
|
|
734 |
} catch (MailChimp_WooCommerce_Error $e) {
|
735 |
return false;
|
736 |
} catch (\Exception $e) {
|
882 |
public function deleteCartByID($store_id, $id)
|
883 |
{
|
884 |
try {
|
885 |
+
return (bool) $this->delete("ecommerce/stores/$store_id/carts/$id");
|
|
|
886 |
} catch (MailChimp_WooCommerce_Error $e) {
|
887 |
return false;
|
888 |
} catch (\Exception $e) {
|
922 |
public function deleteCustomer($store_id, $customer_id)
|
923 |
{
|
924 |
try {
|
925 |
+
return (bool) $this->delete("ecommerce/stores/$store_id/customers/$customer_id");
|
|
|
926 |
} catch (MailChimp_WooCommerce_Error $e) {
|
927 |
return false;
|
928 |
}
|
981 |
}
|
982 |
$order_id = $order->getId();
|
983 |
$data = $this->patch("ecommerce/stores/{$store_id}/orders/{$order_id}", $order->toArray());
|
984 |
+
|
985 |
//update user tags
|
986 |
$email_address = $order->getCustomer()->getEmailAddress();
|
987 |
|
1038 |
public function deleteStoreOrder($store_id, $order_id)
|
1039 |
{
|
1040 |
try {
|
1041 |
+
return (bool) $this->delete("ecommerce/stores/$store_id/orders/$order_id");
|
|
|
1042 |
} catch (MailChimp_WooCommerce_Error $e) {
|
1043 |
return false;
|
1044 |
}
|
1054 |
public function deleteStoreOrderLine($store_id, $order_id, $line_id)
|
1055 |
{
|
1056 |
try {
|
1057 |
+
return (bool) $this->delete("ecommerce/stores/{$store_id}/orders/{$order_id}/lines/{$line_id}");
|
|
|
1058 |
} catch (MailChimp_WooCommerce_Error $e) {
|
1059 |
return false;
|
1060 |
}
|
1156 |
/** @var \MailChimp_WooCommerce_LineItem $order_item */
|
1157 |
$job = new MailChimp_WooCommerce_Single_Product($order_item->getId());
|
1158 |
if ($missing_products[$order_item->getId()] = $job->createModeOnly()->handle()) {
|
1159 |
+
mailchimp_debug("missing_products.fallback", "Product {$order_item->getId()} had to be re-pushed into Mailchimp");
|
1160 |
}
|
1161 |
}
|
1162 |
return $missing_products;
|
1171 |
public function deleteStoreProduct($store_id, $product_id)
|
1172 |
{
|
1173 |
try {
|
1174 |
+
return (bool) $this->delete("ecommerce/stores/$store_id/products/$product_id");
|
|
|
1175 |
} catch (MailChimp_WooCommerce_Error $e) {
|
1176 |
return false;
|
1177 |
}
|
1579 |
return $url;
|
1580 |
}
|
1581 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1582 |
/**
|
1583 |
* @param $method
|
1584 |
* @param $url
|
1602 |
CURLINFO_HEADER_OUT => true,
|
1603 |
CURLOPT_HTTPHEADER => array_merge(array(
|
1604 |
'content-type: application/json',
|
1605 |
+
'accept' => 'application/json',
|
1606 |
"user-agent: MailChimp for WooCommerce/{$env->version}; PHP/{$env->php_version}; WordPress/{$env->wp_version}; Woo/{$env->wc_version};",
|
1607 |
), $headers)
|
1608 |
);
|
1617 |
|
1618 |
/**
|
1619 |
* @param $curl
|
1620 |
+
* @return array|mixed|bool|null|object
|
1621 |
* @throws Exception
|
1622 |
* @throws MailChimp_WooCommerce_Error
|
1623 |
* @throws MailChimp_WooCommerce_ServerError
|
1637 |
$data = json_decode($response, true);
|
1638 |
|
1639 |
if (empty($info) || ($info['http_code'] >= 200 && $info['http_code'] <= 400)) {
|
1640 |
+
if ($info['http_code'] == 204) {
|
1641 |
+
// possibily a successful DELETE operation
|
1642 |
+
return true;
|
1643 |
+
}
|
1644 |
if (is_array($data)) {
|
1645 |
try {
|
1646 |
$this->checkForErrors($data);
|
1653 |
|
1654 |
if ($info['http_code'] >= 400 && $info['http_code'] <= 500) {
|
1655 |
if ($info['http_code'] == 404) {
|
1656 |
+
// mailchimp_error('api', 'processCurlResponse', array('info' => $info, 'data' => $data));
|
1657 |
}
|
1658 |
if ($info['http_code'] == 403) {
|
1659 |
throw new MailChimp_WooCommerce_RateLimitError();
|
1660 |
}
|
|
|
1661 |
throw new MailChimp_WooCommerce_Error($data['title'] .' :: '.$data['detail'], $data['status']);
|
1662 |
}
|
1663 |
|
1686 |
|
1687 |
// make sure the response is correct from the data in the response array
|
1688 |
if (isset($data['status']) && $data['status'] >= 400) {
|
1689 |
+
if (isset($data['http_code']) && $data['http_code'] == 403) {
|
1690 |
throw new MailChimp_WooCommerce_RateLimitError();
|
1691 |
}
|
1692 |
throw new MailChimp_WooCommerce_Error($data['detail'], $data['status']);
|
includes/api/class-mailchimp-woocommerce-transform-products.php
CHANGED
@@ -138,7 +138,7 @@ class MailChimp_WooCommerce_Transform_Products
|
|
138 |
$title = array($variation_title);
|
139 |
|
140 |
foreach ($woo->get_variation_attributes() as $attribute => $value) {
|
141 |
-
if (is_string($value)) {
|
142 |
$name = ucfirst(str_replace(array('attribute_pa_', 'attribute_'), '', $attribute));
|
143 |
$title[] = "$name = $value";
|
144 |
}
|
138 |
$title = array($variation_title);
|
139 |
|
140 |
foreach ($woo->get_variation_attributes() as $attribute => $value) {
|
141 |
+
if (is_string($value) && !empty($value)) {
|
142 |
$name = ucfirst(str_replace(array('attribute_pa_', 'attribute_'), '', $attribute));
|
143 |
$title[] = "$name = $value";
|
144 |
}
|
includes/class-mailchimp-woocommerce-activator.php
CHANGED
@@ -20,9 +20,12 @@ class MailChimp_WooCommerce_Activator {
|
|
20 |
*/
|
21 |
public static function activate() {
|
22 |
|
23 |
-
//
|
24 |
static::create_queue_tables();
|
25 |
|
|
|
|
|
|
|
26 |
// update the settings so we have them for use.
|
27 |
$saved_options = get_option('mailchimp-woocommerce', false);
|
28 |
|
@@ -62,28 +65,6 @@ class MailChimp_WooCommerce_Activator {
|
|
62 |
|
63 |
$charset_collate = $wpdb->get_charset_collate();
|
64 |
|
65 |
-
$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}queue (
|
66 |
-
id bigint(20) NOT NULL AUTO_INCREMENT,
|
67 |
-
job text NOT NULL,
|
68 |
-
attempts tinyint(1) NOT NULL DEFAULT 0,
|
69 |
-
locked tinyint(1) NOT NULL DEFAULT 0,
|
70 |
-
locked_at datetime DEFAULT NULL,
|
71 |
-
available_at datetime NOT NULL,
|
72 |
-
created_at datetime NOT NULL,
|
73 |
-
PRIMARY KEY (id)
|
74 |
-
) $charset_collate;";
|
75 |
-
|
76 |
-
dbDelta( $sql );
|
77 |
-
|
78 |
-
$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}failed_jobs (
|
79 |
-
id bigint(20) NOT NULL AUTO_INCREMENT,
|
80 |
-
job text NOT NULL,
|
81 |
-
failed_at datetime NOT NULL,
|
82 |
-
PRIMARY KEY (id)
|
83 |
-
) $charset_collate;";
|
84 |
-
|
85 |
-
dbDelta( $sql );
|
86 |
-
|
87 |
$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}mailchimp_carts (
|
88 |
id VARCHAR (255) NOT NULL,
|
89 |
email VARCHAR (100) NOT NULL,
|
@@ -94,8 +75,54 @@ class MailChimp_WooCommerce_Activator {
|
|
94 |
) $charset_collate;";
|
95 |
|
96 |
dbDelta( $sql );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
// set the Mailchimp woocommerce version at the time of install
|
99 |
update_site_option('mailchimp_woocommerce_version', mailchimp_environment_variables()->version);
|
100 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
}
|
20 |
*/
|
21 |
public static function activate() {
|
22 |
|
23 |
+
// Create the queue tables
|
24 |
static::create_queue_tables();
|
25 |
|
26 |
+
// Remove legacy queue tables
|
27 |
+
static::migrate_jobs();
|
28 |
+
|
29 |
// update the settings so we have them for use.
|
30 |
$saved_options = get_option('mailchimp-woocommerce', false);
|
31 |
|
65 |
|
66 |
$charset_collate = $wpdb->get_charset_collate();
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}mailchimp_carts (
|
69 |
id VARCHAR (255) NOT NULL,
|
70 |
email VARCHAR (100) NOT NULL,
|
75 |
) $charset_collate;";
|
76 |
|
77 |
dbDelta( $sql );
|
78 |
+
|
79 |
+
$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}mailchimp_jobs (
|
80 |
+
id bigint(20) NOT NULL AUTO_INCREMENT,
|
81 |
+
obj_id text,
|
82 |
+
job text NOT NULL,
|
83 |
+
created_at datetime NOT NULL,
|
84 |
+
PRIMARY KEY (id)
|
85 |
+
) $charset_collate;";
|
86 |
+
|
87 |
+
dbDelta( $sql );
|
88 |
|
89 |
// set the Mailchimp woocommerce version at the time of install
|
90 |
update_site_option('mailchimp_woocommerce_version', mailchimp_environment_variables()->version);
|
91 |
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Migrate wp_queue jobs to Action Scheduler
|
95 |
+
*
|
96 |
+
* @param string $code
|
97 |
+
* @return array $options
|
98 |
+
*/
|
99 |
+
public static function migrate_jobs() {
|
100 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
101 |
+
global $wpdb;
|
102 |
+
if($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}queue';") == $wpdb->prefix.'queue') {
|
103 |
+
mailchimp_log('update.db','Migrating job to Action Scheduler');
|
104 |
+
$sql = "SELECT * FROM {$wpdb->prefix}queue;";
|
105 |
+
$queue_jobs = $wpdb->get_results($sql);
|
106 |
+
foreach ($queue_jobs as $queue_job) {
|
107 |
+
$job = unserialize($queue_job->job);
|
108 |
+
$job->job = $job;
|
109 |
+
$job->id = static::get_possible_job_ids($job);
|
110 |
+
mailchimp_as_push($job, 90);
|
111 |
+
}
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
private static function get_possible_job_ids($job) {
|
116 |
+
$id = null;
|
117 |
+
|
118 |
+
if (isset($job->id)) $id = $job->id;
|
119 |
+
if (isset($job->product_id)) $id = $job->product_id;
|
120 |
+
if (isset($job->order_id)) $id = $job->order_id;
|
121 |
+
if (isset($job->unique_id)) $id = $job->unique_id;
|
122 |
+
if (isset($job->user_id)) $id = $job->user_id;
|
123 |
+
if (isset($job->post_id)) $id = $job->post_id;
|
124 |
+
|
125 |
+
return $id;
|
126 |
+
}
|
127 |
+
|
128 |
}
|
includes/class-mailchimp-woocommerce-cli.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Manage Mailchimp for Woocommerce syncronization jobs.
|
5 |
+
*
|
6 |
+
* @package wp-cli
|
7 |
+
*/
|
8 |
+
class Mailchimp_Wocoomerce_CLI extends WP_CLI_Command {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Timestamp of when this worker started processing the queue.
|
12 |
+
*
|
13 |
+
* @var int
|
14 |
+
*/
|
15 |
+
protected $start_time;
|
16 |
+
protected $pid;
|
17 |
+
protected $command_called;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Mailchimp_Wocoomerce_CLI constructor.
|
21 |
+
*/
|
22 |
+
public function __construct()
|
23 |
+
{
|
24 |
+
$this->pid = getmypid();
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Flush all of the records in the queue.
|
29 |
+
*/
|
30 |
+
public function flush($args, $assoc_args = array())
|
31 |
+
{
|
32 |
+
global $wpdb;
|
33 |
+
WP_CLI::confirm( "This will delete all current queued sync jobs, and entries from {$wpdb->prefix}mailchimp_jobs table. Are you sure?", $assoc_args );
|
34 |
+
mailchimp_delete_as_jobs();
|
35 |
+
$wpdb->query("DELETE FROM {$wpdb->prefix}mailchimp_jobs");
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Show all the records in the queue.
|
40 |
+
*/
|
41 |
+
public function show()
|
42 |
+
{
|
43 |
+
global $wpdb;
|
44 |
+
WP_CLI::log("Showing contents of {$wpdb->prefix}mailchimp_jobs");
|
45 |
+
print_r($wpdb->get_results("SELECT * FROM {$wpdb->prefix}mailchimp_jobs"));
|
46 |
+
exit;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Creates the queue tables.
|
51 |
+
*
|
52 |
+
* @subcommand create-tables
|
53 |
+
*/
|
54 |
+
public function create_tables( $args, $assoc_args = array() ) {
|
55 |
+
install_mailchimp_queue();
|
56 |
+
WP_CLI::success( "Table {$wpdb->prefix}queue created." );
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Run the queue listener to process jobs
|
61 |
+
*
|
62 |
+
* ## OPTIONS
|
63 |
+
*
|
64 |
+
* [--force=<0>]
|
65 |
+
* : Whether to force execution despite the maximum number of concurrent processes being exceeded.
|
66 |
+
*
|
67 |
+
* ---
|
68 |
+
*
|
69 |
+
* ## EXAMPLES
|
70 |
+
*
|
71 |
+
* wp queue listen --force=1
|
72 |
+
*
|
73 |
+
* ---
|
74 |
+
*
|
75 |
+
* @subcommand listen
|
76 |
+
* @param $args
|
77 |
+
* @param array $assoc_args
|
78 |
+
*/
|
79 |
+
public function listen( $args, $assoc_args = array() ) {
|
80 |
+
mailchimp_debug('cli.queue.listen.process','Starting command `action-scheduler run`');
|
81 |
+
WP_CLI::warning(WP_CLI::colorize('%Wqueue listen%n').' command is deprecated since Mailchimp for Woocommerce version 2.3. Please use '.WP_CLI::colorize('%ywp action-scheduler run --group="mc-woocommerce%n"').' instead');
|
82 |
+
WP_CLI::log('Starting sync');
|
83 |
+
|
84 |
+
$force_arg = '';
|
85 |
+
|
86 |
+
$force = (isset($assoc_args['force']) ? (bool) $assoc_args['force'] : null) === true;
|
87 |
+
if ($force) {
|
88 |
+
$force_arg = " --force=1 ";
|
89 |
+
}
|
90 |
+
|
91 |
+
$options = array(
|
92 |
+
'return' => true, // Return 'STDOUT'; use 'all' for full object.
|
93 |
+
//'parse' => 'json', // Parse captured STDOUT to JSON array.
|
94 |
+
'launch' => true, // Reuse the current process.
|
95 |
+
'exit_error' => true, // Halt script execution on error.
|
96 |
+
);
|
97 |
+
|
98 |
+
$command = 'action-scheduler run --group=mc-woocommerce'.$force_arg;
|
99 |
+
$output = WP_CLI::runcommand( $command, $options );
|
100 |
+
WP_CLI::log($output);
|
101 |
+
exit;
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Deprecated commands
|
106 |
+
*/
|
107 |
+
public function work( $args, $assoc_args = array() ) {
|
108 |
+
WP_CLI::warning(WP_CLI::colorize('%Wqueue work%n').' command is deprecated since Mailchimp for Woocommerce version 2.3. Please use '.WP_CLI::colorize('%ywp action-scheduler run --group="mc-woocommerce%n"').' instead');
|
109 |
+
exit;
|
110 |
+
}
|
111 |
+
|
112 |
+
public function status( $args, $assoc_args = array() ) {
|
113 |
+
WP_CLI::warning(WP_CLI::colorize('%Wqueue status%n').' command is deprecated since Mailchimp for Woocommerce version 2.3.');
|
114 |
+
exit;
|
115 |
+
}
|
116 |
+
|
117 |
+
public function restart_failed( $args, $assoc_args = array() ) {
|
118 |
+
WP_CLI::warning(WP_CLI::colorize('%Wqueue restart_failed%n').' command is deprecated since Mailchimp for Woocommerce version 2.3.');
|
119 |
+
exit;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
includes/class-mailchimp-woocommerce-rest-api.php
CHANGED
@@ -3,7 +3,6 @@
|
|
3 |
class MailChimp_WooCommerce_Rest_Api
|
4 |
{
|
5 |
protected static $namespace = 'mailchimp-for-woocommerce/v1';
|
6 |
-
protected $http_worker_listen = false;
|
7 |
|
8 |
/**
|
9 |
* @param $path
|
@@ -13,65 +12,12 @@ class MailChimp_WooCommerce_Rest_Api
|
|
13 |
{
|
14 |
return esc_url_raw(rest_url(static::$namespace.'/'.ltrim($path, '/')));
|
15 |
}
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @return array|mixed|object|WP_Error|null
|
19 |
-
* @throws MailChimp_WooCommerce_Error
|
20 |
-
* @throws MailChimp_WooCommerce_RateLimitError
|
21 |
-
* @throws MailChimp_WooCommerce_ServerError
|
22 |
-
*/
|
23 |
-
public static function test()
|
24 |
-
{
|
25 |
-
add_filter( 'https_local_ssl_verify', '__return_false', 1 );
|
26 |
-
|
27 |
-
// allow people to change this value just in case, but default to a sensible 10 second timeout.
|
28 |
-
$timeout = apply_filters('mailchimp_woocommerce_test_rest_api_timeout', 10);
|
29 |
-
|
30 |
-
// just in case someone didn't return a valid timeout value, go back to the default
|
31 |
-
if (!is_numeric($timeout)) {
|
32 |
-
$timeout = 10;
|
33 |
-
}
|
34 |
-
|
35 |
-
return mailchimp_woocommerce_rest_api_get(
|
36 |
-
static::url('ping'),
|
37 |
-
array(
|
38 |
-
'timeout' => $timeout,
|
39 |
-
'blocking' => true,
|
40 |
-
),
|
41 |
-
mailchimp_get_http_local_json_header()
|
42 |
-
);
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* @param bool $force
|
47 |
-
* @return array|mixed|object|WP_Error|null
|
48 |
-
* @throws MailChimp_WooCommerce_Error
|
49 |
-
* @throws MailChimp_WooCommerce_RateLimitError
|
50 |
-
* @throws MailChimp_WooCommerce_ServerError
|
51 |
-
*/
|
52 |
-
public static function work($force = false)
|
53 |
-
{
|
54 |
-
add_filter( 'https_local_ssl_verify', '__return_false', 1 );
|
55 |
-
|
56 |
-
$path = $force ? 'queue/work/force' : 'queue/work';
|
57 |
-
// this is the new rest API version
|
58 |
-
return mailchimp_woocommerce_rest_api_get(
|
59 |
-
static::url($path),
|
60 |
-
array(
|
61 |
-
'timeout' => 0.01,
|
62 |
-
'blocking' => false,
|
63 |
-
),
|
64 |
-
mailchimp_get_http_local_json_header()
|
65 |
-
);
|
66 |
-
}
|
67 |
-
|
68 |
/**
|
69 |
* Register all Mailchimp API routes.
|
70 |
*/
|
71 |
public function register_routes()
|
72 |
{
|
73 |
$this->register_ping();
|
74 |
-
$this->register_routes_for_queue();
|
75 |
$this->register_survey_routes();
|
76 |
$this->register_sync_stats();
|
77 |
}
|
@@ -98,31 +44,6 @@ class MailChimp_WooCommerce_Rest_Api
|
|
98 |
));
|
99 |
}
|
100 |
|
101 |
-
/**
|
102 |
-
* These are the routes for the queue and testing the functionality of the REST API during setup.
|
103 |
-
*/
|
104 |
-
protected function register_routes_for_queue()
|
105 |
-
{
|
106 |
-
register_rest_route(static::$namespace, "/queue/work", array(
|
107 |
-
'methods' => 'GET',
|
108 |
-
'callback' => array($this, 'queue_work'),
|
109 |
-
));
|
110 |
-
|
111 |
-
register_rest_route(static::$namespace, "/queue/work/force", array(
|
112 |
-
'methods' => 'GET',
|
113 |
-
'callback' => array($this, 'queue_work_force'),
|
114 |
-
));
|
115 |
-
|
116 |
-
register_rest_route(static::$namespace, "/queue/stats", array(
|
117 |
-
'methods' => 'GET',
|
118 |
-
'callback' => array($this, 'queue_stats'),
|
119 |
-
));
|
120 |
-
|
121 |
-
// if we have available jobs, it will handle async
|
122 |
-
if ($this->maybe_fire_manually()) {
|
123 |
-
static::work();
|
124 |
-
}
|
125 |
-
}
|
126 |
|
127 |
/**
|
128 |
* @param WP_REST_Request $request
|
@@ -130,7 +51,7 @@ class MailChimp_WooCommerce_Rest_Api
|
|
130 |
*/
|
131 |
public function ping(WP_REST_Request $request)
|
132 |
{
|
133 |
-
return mailchimp_rest_response(array('success' => true));
|
134 |
}
|
135 |
|
136 |
/**
|
@@ -146,79 +67,6 @@ class MailChimp_WooCommerce_Rest_Api
|
|
146 |
}
|
147 |
}
|
148 |
|
149 |
-
/**
|
150 |
-
* @return WP_REST_Response
|
151 |
-
*/
|
152 |
-
public function queue_stats()
|
153 |
-
{
|
154 |
-
return mailchimp_rest_response(array(
|
155 |
-
'mailchimp_is_configured' => mailchimp_is_configured(),
|
156 |
-
'queue_type' => mailchimp_running_in_console() ? 'console' : 'rest',
|
157 |
-
'one_at_at_time' => mailchimp_queue_is_disabled(),
|
158 |
-
'queue_is_running' => mailchimp_http_worker_is_running(),
|
159 |
-
'should_init_queue' => mailchimp_should_init_rest_queue(),
|
160 |
-
'jobs_in_queue' => number_format(MailChimp_WooCommerce_Queue::instance()->available_jobs()),
|
161 |
-
));
|
162 |
-
}
|
163 |
-
|
164 |
-
/**
|
165 |
-
* This is the new HTTP queue handler - which should only fire when the rest API route has been called.
|
166 |
-
* Replacing admin-ajax.php
|
167 |
-
*
|
168 |
-
* @param WP_REST_Request $request
|
169 |
-
* @return WP_Error|WP_REST_Response
|
170 |
-
*/
|
171 |
-
public function queue_work(WP_REST_Request $request)
|
172 |
-
{
|
173 |
-
// if we're going to dispatch the manual request on this process, just return a "spawning" reason.
|
174 |
-
if ($this->http_worker_listen === true) {
|
175 |
-
return mailchimp_rest_response(array('success' => false, 'reason' => 'spawning'));
|
176 |
-
}
|
177 |
-
|
178 |
-
// if the queue is running in the console - we need to say tell the response why it's not going to fire this way.
|
179 |
-
if (mailchimp_running_in_console()) {
|
180 |
-
return mailchimp_rest_response(array('success' => false, 'reason' => 'cli enabled'));
|
181 |
-
}
|
182 |
-
|
183 |
-
// if the worker is already running - just respond with a reason of "running"
|
184 |
-
if (mailchimp_http_worker_is_running()) {
|
185 |
-
return mailchimp_rest_response(array('success' => false, 'reason' => 'running'));
|
186 |
-
}
|
187 |
-
|
188 |
-
// using the singleton - handle the jobs if we have things to do - will return a count
|
189 |
-
$jobs_processed = MailChimp_WooCommerce_Rest_Queue::instance()->handle();
|
190 |
-
|
191 |
-
// chances are this will never be returned to JS at all just because we're using a 0.01 second timeout
|
192 |
-
// but we need to do it just in case.
|
193 |
-
return mailchimp_rest_response(array('success' => true, 'processed' => $jobs_processed));
|
194 |
-
}
|
195 |
-
|
196 |
-
/**
|
197 |
-
* @param WP_REST_Request $request
|
198 |
-
* @return WP_REST_Response
|
199 |
-
*/
|
200 |
-
public function queue_work_force(WP_REST_Request $request)
|
201 |
-
{
|
202 |
-
// if we're going to dispatch the manual request on this process, just return a "spawning" reason.
|
203 |
-
if ($this->http_worker_listen === true) {
|
204 |
-
return mailchimp_rest_response(array('success' => false, 'reason' => 'spawning'));
|
205 |
-
}
|
206 |
-
|
207 |
-
// if the queue is running in the console - we need to say tell the response why it's not going to fire this way.
|
208 |
-
if (mailchimp_running_in_console()) {
|
209 |
-
return mailchimp_rest_response(array('success' => false, 'reason' => 'cli enabled'));
|
210 |
-
}
|
211 |
-
|
212 |
-
// reset the lock
|
213 |
-
mailchimp_reset_http_lock();
|
214 |
-
|
215 |
-
// using the singleton - handle the jobs if we have things to do - will return a count
|
216 |
-
$jobs_processed = MailChimp_WooCommerce_Rest_Queue::instance()->handle();
|
217 |
-
|
218 |
-
// chances are this will never be returned to JS at all just because we're using a 0.01 second timeout
|
219 |
-
// but we need to do it just in case.
|
220 |
-
return mailchimp_rest_response(array('success' => true, 'processed' => $jobs_processed));
|
221 |
-
}
|
222 |
|
223 |
/**
|
224 |
* @param WP_REST_Request $request
|
@@ -241,7 +89,7 @@ class MailChimp_WooCommerce_Rest_Api
|
|
241 |
'body' => json_encode($request->get_params()),
|
242 |
));
|
243 |
|
244 |
-
return mailchimp_rest_response($result);
|
245 |
}
|
246 |
|
247 |
/**
|
@@ -252,7 +100,7 @@ class MailChimp_WooCommerce_Rest_Api
|
|
252 |
{
|
253 |
// if the queue is running in the console - we need to say tell the response why it's not going to fire this way.
|
254 |
if (!mailchimp_is_configured() || !($api = mailchimp_get_api())) {
|
255 |
-
return mailchimp_rest_response(array('success' => false, 'reason' => 'not configured'));
|
256 |
}
|
257 |
|
258 |
$store_id = mailchimp_get_store_id();
|
@@ -263,7 +111,7 @@ class MailChimp_WooCommerce_Rest_Api
|
|
263 |
try {
|
264 |
$promo_rules = $api->getPromoRules($store_id, 1, 1, 1);
|
265 |
$mailchimp_total_promo_rules = $promo_rules['total_items'];
|
266 |
-
if ($mailchimp_total_promo_rules > $promo_rules_count['publish']) $mailchimp_total_promo_rules = $promo_rules_count['publish'];
|
267 |
} catch (\Exception $e) { $mailchimp_total_promo_rules = 0; }
|
268 |
try {
|
269 |
$products = $api->products($store_id, 1, 1);
|
@@ -279,9 +127,9 @@ class MailChimp_WooCommerce_Rest_Api
|
|
279 |
$date = mailchimp_date_local('now');
|
280 |
|
281 |
// but we need to do it just in case.
|
282 |
-
return mailchimp_rest_response(array(
|
283 |
'success' => true,
|
284 |
-
'promo_rules_in_store' => (int) $promo_rules_count['publish'],
|
285 |
'promo_rules_in_mailchimp' => $mailchimp_total_promo_rules,
|
286 |
'products_in_store' => $product_count,
|
287 |
'products_in_mailchimp' => $mailchimp_total_products,
|
@@ -297,30 +145,14 @@ class MailChimp_WooCommerce_Rest_Api
|
|
297 |
}
|
298 |
|
299 |
/**
|
300 |
-
* @
|
|
|
|
|
301 |
*/
|
302 |
-
|
303 |
-
|
304 |
-
$
|
305 |
-
$
|
306 |
-
|
307 |
-
// if we're not running in the console, and the http_worker is not running
|
308 |
-
if (mailchimp_should_init_rest_queue(false)) {
|
309 |
-
try {
|
310 |
-
// if we do not have a site transient for the queue listener
|
311 |
-
if (!get_site_transient($transient)) {
|
312 |
-
// set the site transient to expire in X seconds so this will not happen too many times
|
313 |
-
// but still work for cron scripts on the minute mark.
|
314 |
-
set_site_transient($transient, microtime(), $transient_expiration);
|
315 |
-
|
316 |
-
// tell the site we're firing off a worker process now.
|
317 |
-
return $this->http_worker_listen = true;
|
318 |
-
}
|
319 |
-
} catch (\Exception $e) {
|
320 |
-
mailchimp_error('maybe_fire_manually', mailchimp_error_trace($e, "maybe_fire_manually"));
|
321 |
-
}
|
322 |
-
}
|
323 |
-
|
324 |
-
return false;
|
325 |
}
|
326 |
}
|
3 |
class MailChimp_WooCommerce_Rest_Api
|
4 |
{
|
5 |
protected static $namespace = 'mailchimp-for-woocommerce/v1';
|
|
|
6 |
|
7 |
/**
|
8 |
* @param $path
|
12 |
{
|
13 |
return esc_url_raw(rest_url(static::$namespace.'/'.ltrim($path, '/')));
|
14 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
/**
|
16 |
* Register all Mailchimp API routes.
|
17 |
*/
|
18 |
public function register_routes()
|
19 |
{
|
20 |
$this->register_ping();
|
|
|
21 |
$this->register_survey_routes();
|
22 |
$this->register_sync_stats();
|
23 |
}
|
44 |
));
|
45 |
}
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
/**
|
49 |
* @param WP_REST_Request $request
|
51 |
*/
|
52 |
public function ping(WP_REST_Request $request)
|
53 |
{
|
54 |
+
return $this->mailchimp_rest_response(array('success' => true));
|
55 |
}
|
56 |
|
57 |
/**
|
67 |
}
|
68 |
}
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
/**
|
72 |
* @param WP_REST_Request $request
|
89 |
'body' => json_encode($request->get_params()),
|
90 |
));
|
91 |
|
92 |
+
return $this->mailchimp_rest_response($result);
|
93 |
}
|
94 |
|
95 |
/**
|
100 |
{
|
101 |
// if the queue is running in the console - we need to say tell the response why it's not going to fire this way.
|
102 |
if (!mailchimp_is_configured() || !($api = mailchimp_get_api())) {
|
103 |
+
return $this->mailchimp_rest_response(array('success' => false, 'reason' => 'not configured'));
|
104 |
}
|
105 |
|
106 |
$store_id = mailchimp_get_store_id();
|
111 |
try {
|
112 |
$promo_rules = $api->getPromoRules($store_id, 1, 1, 1);
|
113 |
$mailchimp_total_promo_rules = $promo_rules['total_items'];
|
114 |
+
if (isset($promo_rules_count['publish']) && $mailchimp_total_promo_rules > $promo_rules_count['publish']) $mailchimp_total_promo_rules = $promo_rules_count['publish'];
|
115 |
} catch (\Exception $e) { $mailchimp_total_promo_rules = 0; }
|
116 |
try {
|
117 |
$products = $api->products($store_id, 1, 1);
|
127 |
$date = mailchimp_date_local('now');
|
128 |
|
129 |
// but we need to do it just in case.
|
130 |
+
return $this->mailchimp_rest_response(array(
|
131 |
'success' => true,
|
132 |
+
'promo_rules_in_store' => isset($promo_rules_count['publish']) ? (int) $promo_rules_count['publish'] : 0,
|
133 |
'promo_rules_in_mailchimp' => $mailchimp_total_promo_rules,
|
134 |
'products_in_store' => $product_count,
|
135 |
'products_in_mailchimp' => $mailchimp_total_products,
|
145 |
}
|
146 |
|
147 |
/**
|
148 |
+
* @param array $data
|
149 |
+
* @param int $status
|
150 |
+
* @return WP_REST_Response
|
151 |
*/
|
152 |
+
private function mailchimp_rest_response($data, $status = 200) {
|
153 |
+
if (!is_array($data)) $data = array();
|
154 |
+
$response = new WP_REST_Response($data);
|
155 |
+
$response->set_status($status);
|
156 |
+
return $response;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
}
|
158 |
}
|
includes/class-mailchimp-woocommerce-service.php
CHANGED
@@ -285,16 +285,18 @@ class MailChimp_Service extends MailChimp_WooCommerce_Options
|
|
285 |
switch (get_post_type($post_id)) {
|
286 |
case 'shop_coupon':
|
287 |
try {
|
288 |
-
mailchimp_get_api()->deletePromoRule(mailchimp_get_store_id(), $post_id);
|
289 |
-
mailchimp_log('promo_code.deleted', "deleted promo code {$post_id}");
|
|
|
290 |
} catch (\Exception $e) {
|
291 |
mailchimp_error('delete promo code', $e->getMessage());
|
292 |
}
|
293 |
break;
|
294 |
case 'product':
|
295 |
try {
|
296 |
-
mailchimp_get_api()->deleteStoreProduct(mailchimp_get_store_id(), $post_id);
|
297 |
-
mailchimp_log('product.deleted', "deleted product {$post_id}");
|
|
|
298 |
} catch (\Exception $e) {
|
299 |
mailchimp_error('delete product', $e->getMessage());
|
300 |
}
|
@@ -801,4 +803,34 @@ class MailChimp_Service extends MailChimp_WooCommerce_Options
|
|
801 |
exit;
|
802 |
}
|
803 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
804 |
}
|
285 |
switch (get_post_type($post_id)) {
|
286 |
case 'shop_coupon':
|
287 |
try {
|
288 |
+
$deleted = mailchimp_get_api()->deletePromoRule(mailchimp_get_store_id(), $post_id);
|
289 |
+
if ($deleted) mailchimp_log('promo_code.deleted', "deleted promo code {$post_id}");
|
290 |
+
else mailchimp_log('promo_code.delete_fail', "Unable to delete promo code {$post_id}");
|
291 |
} catch (\Exception $e) {
|
292 |
mailchimp_error('delete promo code', $e->getMessage());
|
293 |
}
|
294 |
break;
|
295 |
case 'product':
|
296 |
try {
|
297 |
+
$deleted = mailchimp_get_api()->deleteStoreProduct(mailchimp_get_store_id(), $post_id);
|
298 |
+
if ($deleted) mailchimp_log('product.deleted', "deleted product {$post_id}");
|
299 |
+
else mailchimp_log('product.delete_fail', "Unable to deleted product {$post_id}");
|
300 |
} catch (\Exception $e) {
|
301 |
mailchimp_error('delete product', $e->getMessage());
|
302 |
}
|
803 |
exit;
|
804 |
}
|
805 |
|
806 |
+
public function mailchimp_process_single_job($obj_id) {
|
807 |
+
try {
|
808 |
+
// get job row from db
|
809 |
+
global $wpdb;
|
810 |
+
$sql = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}mailchimp_jobs WHERE obj_id = %s", $obj_id );
|
811 |
+
$job_row = $wpdb->get_row( $sql );
|
812 |
+
|
813 |
+
if (is_null($job_row) || !is_object($job_row)) {
|
814 |
+
mailchimp_error('action_scheduler.process_job.fail','Job '.current_action().' not found at '.$wpdb->prefix.'_mailchimp_jobs database table :: obj_id '.$obj_id);
|
815 |
+
return false;
|
816 |
+
}
|
817 |
+
// get variables
|
818 |
+
$job = unserialize($job_row->job);
|
819 |
+
|
820 |
+
$job_id =$job_row->id;
|
821 |
+
|
822 |
+
// process job
|
823 |
+
//mailchimp_debug('action_scheduler.process_job', get_class($job) . ' :: obj_id '.$job->id);
|
824 |
+
$job->handle();
|
825 |
+
|
826 |
+
// delete processed job
|
827 |
+
$sql = $wpdb->prepare("DELETE FROM {$wpdb->prefix}mailchimp_jobs WHERE id = %s AND obj_id = %s", array($job_id, $obj_id));
|
828 |
+
$wpdb->query($sql);
|
829 |
+
|
830 |
+
} catch (\Exception $e) {
|
831 |
+
mailchimp_debug('action_scheduler.process_job.fail', get_class($job) . ' :: obj_id '.$obj_id, $e->message);
|
832 |
+
}
|
833 |
+
return true;
|
834 |
+
}
|
835 |
+
|
836 |
}
|
includes/class-mailchimp-woocommerce.php
CHANGED
@@ -174,12 +174,6 @@ class MailChimp_WooCommerce
|
|
174 |
*/
|
175 |
private function load_dependencies()
|
176 |
{
|
177 |
-
global $wp_queue;
|
178 |
-
|
179 |
-
if (empty($wp_queue)) {
|
180 |
-
$wp_queue = new WP_Queue();
|
181 |
-
}
|
182 |
-
|
183 |
// fire up the loader
|
184 |
$this->loader = new MailChimp_WooCommerce_Loader();
|
185 |
|
@@ -269,8 +263,6 @@ class MailChimp_WooCommerce
|
|
269 |
private function define_public_hooks() {
|
270 |
|
271 |
$plugin_public = new MailChimp_WooCommerce_Public( $this->get_plugin_name(), $this->get_version() );
|
272 |
-
|
273 |
-
$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
|
274 |
$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
|
275 |
}
|
276 |
|
@@ -360,6 +352,21 @@ class MailChimp_WooCommerce
|
|
360 |
// set user by email hash ( public and private )
|
361 |
$this->loader->add_action('wp_ajax_mailchimp_set_user_by_email', $service, 'set_user_by_email');
|
362 |
$this->loader->add_action('wp_ajax_nopriv_mailchimp_set_user_by_email', $service, 'set_user_by_email');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
363 |
}
|
364 |
}
|
365 |
|
174 |
*/
|
175 |
private function load_dependencies()
|
176 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
// fire up the loader
|
178 |
$this->loader = new MailChimp_WooCommerce_Loader();
|
179 |
|
263 |
private function define_public_hooks() {
|
264 |
|
265 |
$plugin_public = new MailChimp_WooCommerce_Public( $this->get_plugin_name(), $this->get_version() );
|
|
|
|
|
266 |
$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
|
267 |
}
|
268 |
|
352 |
// set user by email hash ( public and private )
|
353 |
$this->loader->add_action('wp_ajax_mailchimp_set_user_by_email', $service, 'set_user_by_email');
|
354 |
$this->loader->add_action('wp_ajax_nopriv_mailchimp_set_user_by_email', $service, 'set_user_by_email');
|
355 |
+
|
356 |
+
$jobs_classes = array(
|
357 |
+
"MailChimp_WooCommerce_Single_Order",
|
358 |
+
"MailChimp_WooCommerce_SingleCoupon",
|
359 |
+
"MailChimp_WooCommerce_Single_Product",
|
360 |
+
"MailChimp_WooCommerce_Cart_Update",
|
361 |
+
"MailChimp_WooCommerce_User_Submit",
|
362 |
+
"MailChimp_WooCommerce_Process_Coupons",
|
363 |
+
"MailChimp_WooCommerce_Process_Coupons_Initial_Sync",
|
364 |
+
"MailChimp_WooCommerce_Process_Orders",
|
365 |
+
"MailChimp_WooCommerce_Process_Products"
|
366 |
+
);
|
367 |
+
foreach ($jobs_classes as $job_class) {
|
368 |
+
$this->loader->add_action($job_class, $service, 'mailchimp_process_single_job', 10, 1);
|
369 |
+
}
|
370 |
}
|
371 |
}
|
372 |
|
includes/processes/class-mailchimp-woocommerce-abstract-sync.php
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
* Date: 7/14/16
|
9 |
* Time: 11:54 AM
|
10 |
*/
|
11 |
-
abstract class MailChimp_WooCommerce_Abstract_Sync extends
|
12 |
{
|
13 |
/**
|
14 |
* @var MailChimp_WooCommerce_Api
|
@@ -88,7 +88,6 @@ abstract class MailChimp_WooCommerce_Abstract_Sync extends WP_Job
|
|
88 |
|
89 |
if (!($this->store_id = $this->getStoreID())) {
|
90 |
mailchimp_debug(get_called_class().'@handle', 'store id not loaded');
|
91 |
-
$this->delete();
|
92 |
return false;
|
93 |
}
|
94 |
|
@@ -108,7 +107,6 @@ abstract class MailChimp_WooCommerce_Abstract_Sync extends WP_Job
|
|
108 |
// don't let recursion happen.
|
109 |
if ($this->getResourceType() === 'orders' && $this->getResourceCompleteTime()) {
|
110 |
mailchimp_log('sync.stop', "halting the sync for :: {$this->getResourceType()}");
|
111 |
-
$this->delete();
|
112 |
return false;
|
113 |
}
|
114 |
|
@@ -119,7 +117,6 @@ abstract class MailChimp_WooCommerce_Abstract_Sync extends WP_Job
|
|
119 |
// call the completed event to process further
|
120 |
$this->resourceComplete($this->getResourceType());
|
121 |
$this->complete();
|
122 |
-
$this->delete();
|
123 |
|
124 |
return false;
|
125 |
}
|
@@ -137,7 +134,6 @@ abstract class MailChimp_WooCommerce_Abstract_Sync extends WP_Job
|
|
137 |
// call the completed event to process further
|
138 |
$this->complete();
|
139 |
|
140 |
-
$this->delete();
|
141 |
|
142 |
return false;
|
143 |
}
|
@@ -190,13 +186,14 @@ abstract class MailChimp_WooCommerce_Abstract_Sync extends WP_Job
|
|
190 |
$this->setData('sync.config.resync', false);
|
191 |
$this->setData('sync.orders.current_page', 1);
|
192 |
$this->setData('sync.products.current_page', 1);
|
|
|
193 |
$this->setData('sync.syncing', true);
|
194 |
$this->setData('sync.started_at', time());
|
195 |
|
196 |
global $wpdb;
|
197 |
try {
|
198 |
$wpdb->show_errors(false);
|
199 |
-
|
200 |
$wpdb->show_errors(true);
|
201 |
} catch (\Exception $e) {}
|
202 |
|
@@ -220,6 +217,7 @@ abstract class MailChimp_WooCommerce_Abstract_Sync extends WP_Job
|
|
220 |
// set the current sync pages back to 1 if the user hits resync.
|
221 |
$this->setData('sync.orders.current_page', 1);
|
222 |
$this->setData('sync.products.current_page', 1);
|
|
|
223 |
|
224 |
mailchimp_log('sync.completed', "Finished Sync :: ".date('D, M j, Y g:i A'));
|
225 |
|
@@ -463,15 +461,8 @@ abstract class MailChimp_WooCommerce_Abstract_Sync extends WP_Job
|
|
463 |
*/
|
464 |
protected function next()
|
465 |
{
|
466 |
-
global $wpdb;
|
467 |
-
|
468 |
-
$this->delete();
|
469 |
-
|
470 |
-
$class_name = get_called_class();
|
471 |
-
$wpdb->query("DELETE FROM {$wpdb->prefix}queue WHERE job LIKE '%{$class_name}%'");
|
472 |
-
|
473 |
// this will paginate through all records for the resource type until they return no records.
|
474 |
-
mailchimp_handle_or_queue(new static(), 0
|
475 |
mailchimp_debug(get_called_class().'@handle', 'queuing up the next job');
|
476 |
}
|
477 |
}
|
8 |
* Date: 7/14/16
|
9 |
* Time: 11:54 AM
|
10 |
*/
|
11 |
+
abstract class MailChimp_WooCommerce_Abstract_Sync extends Mailchimp_Woocommerce_Job
|
12 |
{
|
13 |
/**
|
14 |
* @var MailChimp_WooCommerce_Api
|
88 |
|
89 |
if (!($this->store_id = $this->getStoreID())) {
|
90 |
mailchimp_debug(get_called_class().'@handle', 'store id not loaded');
|
|
|
91 |
return false;
|
92 |
}
|
93 |
|
107 |
// don't let recursion happen.
|
108 |
if ($this->getResourceType() === 'orders' && $this->getResourceCompleteTime()) {
|
109 |
mailchimp_log('sync.stop', "halting the sync for :: {$this->getResourceType()}");
|
|
|
110 |
return false;
|
111 |
}
|
112 |
|
117 |
// call the completed event to process further
|
118 |
$this->resourceComplete($this->getResourceType());
|
119 |
$this->complete();
|
|
|
120 |
|
121 |
return false;
|
122 |
}
|
134 |
// call the completed event to process further
|
135 |
$this->complete();
|
136 |
|
|
|
137 |
|
138 |
return false;
|
139 |
}
|
186 |
$this->setData('sync.config.resync', false);
|
187 |
$this->setData('sync.orders.current_page', 1);
|
188 |
$this->setData('sync.products.current_page', 1);
|
189 |
+
$this->setData('sync.coupons.current_page', 1);
|
190 |
$this->setData('sync.syncing', true);
|
191 |
$this->setData('sync.started_at', time());
|
192 |
|
193 |
global $wpdb;
|
194 |
try {
|
195 |
$wpdb->show_errors(false);
|
196 |
+
mailchimp_delete_as_jobs();
|
197 |
$wpdb->show_errors(true);
|
198 |
} catch (\Exception $e) {}
|
199 |
|
217 |
// set the current sync pages back to 1 if the user hits resync.
|
218 |
$this->setData('sync.orders.current_page', 1);
|
219 |
$this->setData('sync.products.current_page', 1);
|
220 |
+
$this->setData('sync.coupons.current_page', 1);
|
221 |
|
222 |
mailchimp_log('sync.completed', "Finished Sync :: ".date('D, M j, Y g:i A'));
|
223 |
|
461 |
*/
|
462 |
protected function next()
|
463 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
464 |
// this will paginate through all records for the resource type until they return no records.
|
465 |
+
mailchimp_handle_or_queue(new static(), 0);
|
466 |
mailchimp_debug(get_called_class().'@handle', 'queuing up the next job');
|
467 |
}
|
468 |
}
|
includes/processes/class-mailchimp-woocommerce-cart-update.php
CHANGED
@@ -8,9 +8,9 @@
|
|
8 |
* Date: 7/15/16
|
9 |
* Time: 11:42 AM
|
10 |
*/
|
11 |
-
class MailChimp_WooCommerce_Cart_Update extends
|
12 |
{
|
13 |
-
public $
|
14 |
public $email;
|
15 |
public $previous_email;
|
16 |
public $campaign_id;
|
@@ -28,7 +28,7 @@ class MailChimp_WooCommerce_Cart_Update extends WP_Job
|
|
28 |
public function __construct($uid = null, $email = null, $campaign_id = null, array $cart_data = array())
|
29 |
{
|
30 |
if ($uid) {
|
31 |
-
$this->
|
32 |
}
|
33 |
if ($email) {
|
34 |
$this->email = $email;
|
@@ -89,7 +89,7 @@ class MailChimp_WooCommerce_Cart_Update extends WP_Job
|
|
89 |
$this->cart_data = json_decode($this->cart_data, true);
|
90 |
|
91 |
// delete it and the add it back.
|
92 |
-
$api->deleteCartByID($store_id, $this->
|
93 |
|
94 |
// if they emptied the cart ignore it.
|
95 |
if (!is_array($this->cart_data) || empty($this->cart_data)) {
|
@@ -99,18 +99,18 @@ class MailChimp_WooCommerce_Cart_Update extends WP_Job
|
|
99 |
$checkout_url = wc_get_checkout_url();
|
100 |
|
101 |
if (mailchimp_string_contains($checkout_url, '?')) {
|
102 |
-
$checkout_url .= '&mc_cart_id='.$this->
|
103 |
} else {
|
104 |
-
$checkout_url .= '?mc_cart_id='.$this->
|
105 |
}
|
106 |
|
107 |
$customer = new MailChimp_WooCommerce_Customer();
|
108 |
-
$customer->setId($this->
|
109 |
$customer->setEmailAddress($this->email);
|
110 |
$customer->setOptInStatus(false);
|
111 |
|
112 |
$cart = new MailChimp_WooCommerce_Cart();
|
113 |
-
$cart->setId($this->
|
114 |
|
115 |
// if we have a campaign id let's set it now.
|
116 |
if (!empty($this->campaign_id)) {
|
8 |
* Date: 7/15/16
|
9 |
* Time: 11:42 AM
|
10 |
*/
|
11 |
+
class MailChimp_WooCommerce_Cart_Update extends Mailchimp_Woocommerce_Job
|
12 |
{
|
13 |
+
public $id;
|
14 |
public $email;
|
15 |
public $previous_email;
|
16 |
public $campaign_id;
|
28 |
public function __construct($uid = null, $email = null, $campaign_id = null, array $cart_data = array())
|
29 |
{
|
30 |
if ($uid) {
|
31 |
+
$this->id = $uid;
|
32 |
}
|
33 |
if ($email) {
|
34 |
$this->email = $email;
|
89 |
$this->cart_data = json_decode($this->cart_data, true);
|
90 |
|
91 |
// delete it and the add it back.
|
92 |
+
$api->deleteCartByID($store_id, $this->id);
|
93 |
|
94 |
// if they emptied the cart ignore it.
|
95 |
if (!is_array($this->cart_data) || empty($this->cart_data)) {
|
99 |
$checkout_url = wc_get_checkout_url();
|
100 |
|
101 |
if (mailchimp_string_contains($checkout_url, '?')) {
|
102 |
+
$checkout_url .= '&mc_cart_id='.$this->id;
|
103 |
} else {
|
104 |
+
$checkout_url .= '?mc_cart_id='.$this->id;
|
105 |
}
|
106 |
|
107 |
$customer = new MailChimp_WooCommerce_Customer();
|
108 |
+
$customer->setId($this->id);
|
109 |
$customer->setEmailAddress($this->email);
|
110 |
$customer->setOptInStatus(false);
|
111 |
|
112 |
$cart = new MailChimp_WooCommerce_Cart();
|
113 |
+
$cart->setId($this->id);
|
114 |
|
115 |
// if we have a campaign id let's set it now.
|
116 |
if (!empty($this->campaign_id)) {
|
includes/processes/class-mailchimp-woocommerce-job.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! class_exists( 'Mailchimp_Woocommerce_Job' ) ) {
|
4 |
+
abstract class Mailchimp_Woocommerce_Job {
|
5 |
+
|
6 |
+
public $should_kill_queue_listener = false;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* @var stdClass
|
10 |
+
*/
|
11 |
+
private $job;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Set job
|
15 |
+
*
|
16 |
+
* @param $job
|
17 |
+
*/
|
18 |
+
public function set_job( $job ) {
|
19 |
+
$this->job = $job;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Handle the job.
|
24 |
+
*/
|
25 |
+
abstract public function handle();
|
26 |
+
|
27 |
+
}
|
28 |
+
}
|
includes/processes/class-mailchimp-woocommerce-process-coupons-initial-sync.php
CHANGED
@@ -16,6 +16,6 @@ class MailChimp_WooCommerce_Process_Coupons_Initial_Sync extends MailChimp_WooCo
|
|
16 |
$this->setResourceCompleteTime();
|
17 |
|
18 |
$product_sync = new MailChimp_WooCommerce_Process_Products();
|
19 |
-
mailchimp_handle_or_queue($product_sync, 0
|
20 |
}
|
21 |
}
|
16 |
$this->setResourceCompleteTime();
|
17 |
|
18 |
$product_sync = new MailChimp_WooCommerce_Process_Products();
|
19 |
+
mailchimp_handle_or_queue($product_sync, 0);
|
20 |
}
|
21 |
}
|
includes/processes/class-mailchimp-woocommerce-process-products.php
CHANGED
@@ -20,7 +20,7 @@ class MailChimp_WooCommerce_Process_Products extends MailChimp_WooCommerce_Abstr
|
|
20 |
{
|
21 |
$job = new MailChimp_WooCommerce_Process_Products();
|
22 |
$job->flagStartSync();
|
23 |
-
mailchimp_handle_or_queue($job, 0
|
24 |
}
|
25 |
|
26 |
|
20 |
{
|
21 |
$job = new MailChimp_WooCommerce_Process_Products();
|
22 |
$job->flagStartSync();
|
23 |
+
mailchimp_handle_or_queue($job, 0);
|
24 |
}
|
25 |
|
26 |
|
includes/processes/class-mailchimp-woocommerce-single-coupon.php
CHANGED
@@ -8,20 +8,31 @@
|
|
8 |
* Date: 10/6/17
|
9 |
* Time: 11:14 AM
|
10 |
*/
|
11 |
-
class MailChimp_WooCommerce_SingleCoupon extends
|
12 |
{
|
13 |
public $coupon_data;
|
14 |
-
public $
|
15 |
|
16 |
/**
|
17 |
* MailChimp_WooCommerce_Coupon_Sync constructor.
|
18 |
-
* @param $
|
19 |
*/
|
20 |
-
public function __construct($
|
21 |
{
|
22 |
-
$this->
|
23 |
}
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
/**
|
26 |
* @return null
|
27 |
*/
|
@@ -34,8 +45,8 @@ class MailChimp_WooCommerce_SingleCoupon extends WP_Job
|
|
34 |
return false;
|
35 |
}
|
36 |
|
37 |
-
if (empty($this->
|
38 |
-
mailchimp_error('promo_code.failure', "could not process coupon {$this->
|
39 |
return;
|
40 |
}
|
41 |
|
@@ -43,7 +54,7 @@ class MailChimp_WooCommerce_SingleCoupon extends WP_Job
|
|
43 |
$store_id = mailchimp_get_store_id();
|
44 |
|
45 |
$transformer = new MailChimp_WooCommerce_Transform_Coupons();
|
46 |
-
$code = $transformer->transform($this->
|
47 |
|
48 |
$api->addPromoRule($store_id, $code->getAttachedPromoRule(), true);
|
49 |
$api->addPromoCodeForRule($store_id, $code->getAttachedPromoRule(), $code, true);
|
@@ -52,10 +63,10 @@ class MailChimp_WooCommerce_SingleCoupon extends WP_Job
|
|
52 |
} catch (MailChimp_WooCommerce_RateLimitError $e) {
|
53 |
sleep(3);
|
54 |
$this->release();
|
55 |
-
$promo_code = isset($code) ? "code {$code->getCode()}" : "id {$this->
|
56 |
mailchimp_error('promo_code.error', mailchimp_error_trace($e, "RateLimited :: #{$promo_code}"));
|
57 |
} catch (\Exception $e) {
|
58 |
-
$promo_code = isset($code) ? "code {$code->getCode()}" : "id {$this->
|
59 |
mailchimp_error('promo_code.error', mailchimp_error_trace($e, "error updating promo {$promo_code}"));
|
60 |
}
|
61 |
}
|
8 |
* Date: 10/6/17
|
9 |
* Time: 11:14 AM
|
10 |
*/
|
11 |
+
class MailChimp_WooCommerce_SingleCoupon extends Mailchimp_Woocommerce_Job
|
12 |
{
|
13 |
public $coupon_data;
|
14 |
+
public $id;
|
15 |
|
16 |
/**
|
17 |
* MailChimp_WooCommerce_Coupon_Sync constructor.
|
18 |
+
* @param $id
|
19 |
*/
|
20 |
+
public function __construct($id = null)
|
21 |
{
|
22 |
+
$this->setId($id);
|
23 |
}
|
24 |
|
25 |
+
/**
|
26 |
+
* @param null $id
|
27 |
+
* @return MailChimp_WooCommerce_SingleCoupon
|
28 |
+
*/
|
29 |
+
public function setId($id)
|
30 |
+
{
|
31 |
+
if (!empty($id)) {
|
32 |
+
$this->id = $id instanceof WP_Post ? $id->ID : $id;
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
/**
|
37 |
* @return null
|
38 |
*/
|
45 |
return false;
|
46 |
}
|
47 |
|
48 |
+
if (empty($this->id)) {
|
49 |
+
mailchimp_error('promo_code.failure', "could not process coupon {$this->id}");
|
50 |
return;
|
51 |
}
|
52 |
|
54 |
$store_id = mailchimp_get_store_id();
|
55 |
|
56 |
$transformer = new MailChimp_WooCommerce_Transform_Coupons();
|
57 |
+
$code = $transformer->transform($this->id);
|
58 |
|
59 |
$api->addPromoRule($store_id, $code->getAttachedPromoRule(), true);
|
60 |
$api->addPromoCodeForRule($store_id, $code->getAttachedPromoRule(), $code, true);
|
63 |
} catch (MailChimp_WooCommerce_RateLimitError $e) {
|
64 |
sleep(3);
|
65 |
$this->release();
|
66 |
+
$promo_code = isset($code) ? "code {$code->getCode()}" : "id {$this->id}";
|
67 |
mailchimp_error('promo_code.error', mailchimp_error_trace($e, "RateLimited :: #{$promo_code}"));
|
68 |
} catch (\Exception $e) {
|
69 |
+
$promo_code = isset($code) ? "code {$code->getCode()}" : "id {$this->id}";
|
70 |
mailchimp_error('promo_code.error', mailchimp_error_trace($e, "error updating promo {$promo_code}"));
|
71 |
}
|
72 |
}
|
includes/processes/class-mailchimp-woocommerce-single-order.php
CHANGED
@@ -8,9 +8,9 @@
|
|
8 |
* Date: 7/15/16
|
9 |
* Time: 11:42 AM
|
10 |
*/
|
11 |
-
class MailChimp_WooCommerce_Single_Order extends
|
12 |
{
|
13 |
-
public $
|
14 |
public $cart_session_id;
|
15 |
public $campaign_id;
|
16 |
public $landing_site;
|
@@ -23,19 +23,30 @@ class MailChimp_WooCommerce_Single_Order extends WP_Job
|
|
23 |
|
24 |
/**
|
25 |
* MailChimp_WooCommerce_Single_Order constructor.
|
26 |
-
* @param null $
|
27 |
* @param null $cart_session_id
|
28 |
* @param null $campaign_id
|
29 |
* @param null $landing_site
|
30 |
*/
|
31 |
-
public function __construct($
|
32 |
{
|
33 |
-
if (!empty($
|
34 |
if (!empty($cart_session_id)) $this->cart_session_id = $cart_session_id;
|
35 |
if (!empty($campaign_id)) $this->campaign_id = $campaign_id;
|
36 |
if (!empty($landing_site)) $this->landing_site = $landing_site;
|
37 |
}
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
/**
|
40 |
* @return bool
|
41 |
*/
|
@@ -93,7 +104,7 @@ class MailChimp_WooCommerce_Single_Order extends WP_Job
|
|
93 |
// will either add or update the order
|
94 |
try {
|
95 |
|
96 |
-
if (!($order_post = get_post($this->
|
97 |
return false;
|
98 |
}
|
99 |
|
@@ -235,13 +246,13 @@ class MailChimp_WooCommerce_Single_Order extends WP_Job
|
|
235 |
} catch (MailChimp_WooCommerce_RateLimitError $e) {
|
236 |
sleep(3);
|
237 |
$this->release();
|
238 |
-
mailchimp_error('order_submit.error', mailchimp_error_trace($e, "RateLimited :: #{$this->
|
239 |
} catch (\Exception $e) {
|
240 |
$message = strtolower($e->getMessage());
|
241 |
mailchimp_error('order_submit.tracing_error', $e);
|
242 |
if (!isset($order)) {
|
243 |
// transform the order
|
244 |
-
$order = $job->transform(get_post($this->
|
245 |
$this->cart_session_id = $order->getCustomer()->getId();
|
246 |
}
|
247 |
// this can happen when a customer changes their email.
|
@@ -263,7 +274,7 @@ class MailChimp_WooCommerce_Single_Order extends WP_Job
|
|
263 |
}
|
264 |
return $api_response;
|
265 |
} catch (\Exception $e) {
|
266 |
-
mailchimp_error('order_submit.error', mailchimp_error_trace($e, 'deleting-customer-re-add :: #'.$this->
|
267 |
}
|
268 |
}
|
269 |
}
|
@@ -277,14 +288,14 @@ class MailChimp_WooCommerce_Single_Order extends WP_Job
|
|
277 |
public function getRealOrderNumber()
|
278 |
{
|
279 |
try {
|
280 |
-
if (empty($this->
|
281 |
return false;
|
282 |
}
|
283 |
$woo = new WC_Order($order_post);
|
284 |
return $this->woo_order_number = $woo->get_order_number();
|
285 |
} catch (\Exception $e) {
|
286 |
$this->woo_order_number = false;
|
287 |
-
mailchimp_error('order_sync.failure', mailchimp_error_trace($e, "{$this->
|
288 |
return false;
|
289 |
}
|
290 |
}
|
@@ -295,7 +306,7 @@ class MailChimp_WooCommerce_Single_Order extends WP_Job
|
|
295 |
public function shouldPreventSubmission()
|
296 |
{
|
297 |
try {
|
298 |
-
if (empty($this->
|
299 |
return false;
|
300 |
}
|
301 |
$woo = new WC_Order($order_post);
|
8 |
* Date: 7/15/16
|
9 |
* Time: 11:42 AM
|
10 |
*/
|
11 |
+
class MailChimp_WooCommerce_Single_Order extends Mailchimp_Woocommerce_Job
|
12 |
{
|
13 |
+
public $id;
|
14 |
public $cart_session_id;
|
15 |
public $campaign_id;
|
16 |
public $landing_site;
|
23 |
|
24 |
/**
|
25 |
* MailChimp_WooCommerce_Single_Order constructor.
|
26 |
+
* @param null $id
|
27 |
* @param null $cart_session_id
|
28 |
* @param null $campaign_id
|
29 |
* @param null $landing_site
|
30 |
*/
|
31 |
+
public function __construct($id = null, $cart_session_id = null, $campaign_id = null, $landing_site = null)
|
32 |
{
|
33 |
+
if (!empty($id)) $this->id = $id;
|
34 |
if (!empty($cart_session_id)) $this->cart_session_id = $cart_session_id;
|
35 |
if (!empty($campaign_id)) $this->campaign_id = $campaign_id;
|
36 |
if (!empty($landing_site)) $this->landing_site = $landing_site;
|
37 |
}
|
38 |
|
39 |
+
/**
|
40 |
+
* @param null $id
|
41 |
+
* @return MailChimp_WooCommerce_Single_Order
|
42 |
+
*/
|
43 |
+
public function setId($id)
|
44 |
+
{
|
45 |
+
$this->id = $id;
|
46 |
+
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
|
50 |
/**
|
51 |
* @return bool
|
52 |
*/
|
104 |
// will either add or update the order
|
105 |
try {
|
106 |
|
107 |
+
if (!($order_post = get_post($this->id))) {
|
108 |
return false;
|
109 |
}
|
110 |
|
246 |
} catch (MailChimp_WooCommerce_RateLimitError $e) {
|
247 |
sleep(3);
|
248 |
$this->release();
|
249 |
+
mailchimp_error('order_submit.error', mailchimp_error_trace($e, "RateLimited :: #{$this->id}"));
|
250 |
} catch (\Exception $e) {
|
251 |
$message = strtolower($e->getMessage());
|
252 |
mailchimp_error('order_submit.tracing_error', $e);
|
253 |
if (!isset($order)) {
|
254 |
// transform the order
|
255 |
+
$order = $job->transform(get_post($this->id));
|
256 |
$this->cart_session_id = $order->getCustomer()->getId();
|
257 |
}
|
258 |
// this can happen when a customer changes their email.
|
274 |
}
|
275 |
return $api_response;
|
276 |
} catch (\Exception $e) {
|
277 |
+
mailchimp_error('order_submit.error', mailchimp_error_trace($e, 'deleting-customer-re-add :: #'.$this->id));
|
278 |
}
|
279 |
}
|
280 |
}
|
288 |
public function getRealOrderNumber()
|
289 |
{
|
290 |
try {
|
291 |
+
if (empty($this->id) || !($order_post = get_post($this->id))) {
|
292 |
return false;
|
293 |
}
|
294 |
$woo = new WC_Order($order_post);
|
295 |
return $this->woo_order_number = $woo->get_order_number();
|
296 |
} catch (\Exception $e) {
|
297 |
$this->woo_order_number = false;
|
298 |
+
mailchimp_error('order_sync.failure', mailchimp_error_trace($e, "{$this->id} could not be loaded"));
|
299 |
return false;
|
300 |
}
|
301 |
}
|
306 |
public function shouldPreventSubmission()
|
307 |
{
|
308 |
try {
|
309 |
+
if (empty($this->id) || !($order_post = get_post($this->id))) {
|
310 |
return false;
|
311 |
}
|
312 |
$woo = new WC_Order($order_post);
|
includes/processes/class-mailchimp-woocommerce-single-product.php
CHANGED
@@ -8,22 +8,31 @@
|
|
8 |
* Date: 7/15/16
|
9 |
* Time: 11:42 AM
|
10 |
*/
|
11 |
-
class MailChimp_WooCommerce_Single_Product extends
|
12 |
{
|
13 |
-
public $
|
14 |
protected $store_id;
|
15 |
protected $api;
|
16 |
protected $service;
|
17 |
protected $mode = 'update_or_create';
|
18 |
|
19 |
/**
|
20 |
-
*
|
21 |
-
* @param null|int $
|
22 |
*/
|
23 |
-
public function __construct($
|
24 |
{
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
28 |
}
|
29 |
|
@@ -71,7 +80,7 @@ class MailChimp_WooCommerce_Single_Product extends WP_Job
|
|
71 |
*/
|
72 |
public function process()
|
73 |
{
|
74 |
-
if (empty($this->
|
75 |
return false;
|
76 |
}
|
77 |
|
@@ -84,12 +93,12 @@ class MailChimp_WooCommerce_Single_Product extends WP_Job
|
|
84 |
|
85 |
try {
|
86 |
|
87 |
-
if (!($product_post = get_post($this->
|
88 |
return false;
|
89 |
}
|
90 |
|
91 |
// pull the product from Mailchimp first to see what method we need to call next.
|
92 |
-
$mailchimp_product = $this->api()->getStoreProduct($this->store_id, $this->
|
93 |
|
94 |
// depending on if it's existing or not - we change the method call
|
95 |
$method = $mailchimp_product ? 'updateStoreProduct' : 'addStoreProduct';
|
@@ -106,7 +115,7 @@ class MailChimp_WooCommerce_Single_Product extends WP_Job
|
|
106 |
|
107 |
$product = $this->transformer()->transform($product_post);
|
108 |
|
109 |
-
mailchimp_debug('product_submit.debug', "#{$this->
|
110 |
|
111 |
// either updating or creating the product
|
112 |
$this->api()->{$method}($this->store_id, $product, false);
|
@@ -120,13 +129,13 @@ class MailChimp_WooCommerce_Single_Product extends WP_Job
|
|
120 |
} catch (MailChimp_WooCommerce_RateLimitError $e) {
|
121 |
sleep(3);
|
122 |
$this->release();
|
123 |
-
mailchimp_error('product_submit.error', mailchimp_error_trace($e, "RateLimited :: #{$this->
|
124 |
} catch (MailChimp_WooCommerce_ServerError $e) {
|
125 |
-
mailchimp_error('product_submit.error', mailchimp_error_trace($e, "{$method} :: #{$this->
|
126 |
} catch (MailChimp_WooCommerce_Error $e) {
|
127 |
-
mailchimp_log('product_submit.error', mailchimp_error_trace($e, "{$method} :: #{$this->
|
128 |
} catch (Exception $e) {
|
129 |
-
mailchimp_log('product_submit.error', mailchimp_error_trace($e, "{$method} :: #{$this->
|
130 |
}
|
131 |
|
132 |
return false;
|
8 |
* Date: 7/15/16
|
9 |
* Time: 11:42 AM
|
10 |
*/
|
11 |
+
class MailChimp_WooCommerce_Single_Product extends Mailchimp_Woocommerce_Job
|
12 |
{
|
13 |
+
public $id;
|
14 |
protected $store_id;
|
15 |
protected $api;
|
16 |
protected $service;
|
17 |
protected $mode = 'update_or_create';
|
18 |
|
19 |
/**
|
20 |
+
* MailChimp_WooCommerce_Single_product constructor.
|
21 |
+
* @param null|int $id
|
22 |
*/
|
23 |
+
public function __construct($id = null)
|
24 |
{
|
25 |
+
$this->setId($id);
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @param null $id
|
30 |
+
* @return MailChimp_WooCommerce_Single_Product
|
31 |
+
*/
|
32 |
+
public function setId($id)
|
33 |
+
{
|
34 |
+
if (!empty($id)) {
|
35 |
+
$this->id = $id instanceof WP_Post ? $id->ID : $id;
|
36 |
}
|
37 |
}
|
38 |
|
80 |
*/
|
81 |
public function process()
|
82 |
{
|
83 |
+
if (empty($this->id)) {
|
84 |
return false;
|
85 |
}
|
86 |
|
93 |
|
94 |
try {
|
95 |
|
96 |
+
if (!($product_post = get_post($this->id))) {
|
97 |
return false;
|
98 |
}
|
99 |
|
100 |
// pull the product from Mailchimp first to see what method we need to call next.
|
101 |
+
$mailchimp_product = $this->api()->getStoreProduct($this->store_id, $this->id);
|
102 |
|
103 |
// depending on if it's existing or not - we change the method call
|
104 |
$method = $mailchimp_product ? 'updateStoreProduct' : 'addStoreProduct';
|
115 |
|
116 |
$product = $this->transformer()->transform($product_post);
|
117 |
|
118 |
+
mailchimp_debug('product_submit.debug', "#{$this->id}", $product->toArray());
|
119 |
|
120 |
// either updating or creating the product
|
121 |
$this->api()->{$method}($this->store_id, $product, false);
|
129 |
} catch (MailChimp_WooCommerce_RateLimitError $e) {
|
130 |
sleep(3);
|
131 |
$this->release();
|
132 |
+
mailchimp_error('product_submit.error', mailchimp_error_trace($e, "RateLimited :: #{$this->id}"));
|
133 |
} catch (MailChimp_WooCommerce_ServerError $e) {
|
134 |
+
mailchimp_error('product_submit.error', mailchimp_error_trace($e, "{$method} :: #{$this->id}"));
|
135 |
} catch (MailChimp_WooCommerce_Error $e) {
|
136 |
+
mailchimp_log('product_submit.error', mailchimp_error_trace($e, "{$method} :: #{$this->id}"));
|
137 |
} catch (Exception $e) {
|
138 |
+
mailchimp_log('product_submit.error', mailchimp_error_trace($e, "{$method} :: #{$this->id}"));
|
139 |
}
|
140 |
|
141 |
return false;
|
includes/processes/class-mailchimp-woocommerce-user-submit.php
CHANGED
@@ -8,30 +8,30 @@
|
|
8 |
* Date: 11/14/16
|
9 |
* Time: 9:38 AM
|
10 |
*/
|
11 |
-
class MailChimp_WooCommerce_User_Submit extends
|
12 |
{
|
13 |
public static $handling_for = null;
|
14 |
|
15 |
-
public $
|
16 |
public $subscribed;
|
17 |
public $updated_data;
|
18 |
public $should_ignore = false;
|
19 |
|
20 |
/**
|
21 |
* MailChimp_WooCommerce_User_Submit constructor.
|
22 |
-
* @param null $
|
23 |
* @param null $subscribed
|
24 |
* @param WP_User|null $updated_data
|
25 |
*/
|
26 |
-
public function __construct($
|
27 |
{
|
28 |
-
if (!empty($
|
29 |
// if we're passing in another user with the same id during the same php process we need to ignore it.
|
30 |
-
if (static::$handling_for === $
|
31 |
$this->should_ignore = true;
|
32 |
}
|
33 |
// set the user id and the current 'handling_for' to this user id so we don't duplicate jobs.
|
34 |
-
static::$handling_for = $this->
|
35 |
}
|
36 |
|
37 |
if (is_bool($subscribed)) {
|
@@ -55,7 +55,7 @@ class MailChimp_WooCommerce_User_Submit extends WP_Job
|
|
55 |
}
|
56 |
|
57 |
if ($this->should_ignore) {
|
58 |
-
mailchimp_debug(get_called_class(), "{$this->
|
59 |
static::$handling_for = null;
|
60 |
return false;
|
61 |
}
|
@@ -64,7 +64,7 @@ class MailChimp_WooCommerce_User_Submit extends WP_Job
|
|
64 |
$store_id = mailchimp_get_store_id();
|
65 |
|
66 |
// load up the user.
|
67 |
-
$user = new WP_User($this->
|
68 |
|
69 |
// we need a valid user, a valid store id and options to continue
|
70 |
if ($user->ID <= 0 || empty($store_id) || !is_array($options)) {
|
@@ -77,7 +77,7 @@ class MailChimp_WooCommerce_User_Submit extends WP_Job
|
|
77 |
$store_id = mailchimp_get_store_id();
|
78 |
|
79 |
// load up the user.
|
80 |
-
$user = new WP_User($this->
|
81 |
|
82 |
if ($user->ID <= 0 || empty($store_id) || !is_array($options)) {
|
83 |
mailchimp_log('member.sync', "Invalid Data For Submission :: {$user->ID}");
|
@@ -96,7 +96,7 @@ class MailChimp_WooCommerce_User_Submit extends WP_Job
|
|
96 |
|
97 |
// if we have a null value, we need to grab the correct user meta for is_subscribed
|
98 |
if (is_null($this->subscribed)) {
|
99 |
-
$user_subscribed = get_user_meta($this->
|
100 |
if ($user_subscribed === '' || $user_subscribed === null) {
|
101 |
mailchimp_log('member.sync', "Skipping sync for {$email} because no subscriber status has been set");
|
102 |
static::$handling_for = null;
|
@@ -218,7 +218,7 @@ class MailChimp_WooCommerce_User_Submit extends WP_Job
|
|
218 |
} catch (MailChimp_WooCommerce_RateLimitError $e) {
|
219 |
sleep(3);
|
220 |
$this->release();
|
221 |
-
mailchimp_error('member.sync.error', mailchimp_error_trace($e, "RateLimited :: user #{$this->
|
222 |
} catch (\Exception $e) {
|
223 |
// if we have a 404 not found, we can create the member
|
224 |
if ($e->getCode() == 404) {
|
8 |
* Date: 11/14/16
|
9 |
* Time: 9:38 AM
|
10 |
*/
|
11 |
+
class MailChimp_WooCommerce_User_Submit extends Mailchimp_Woocommerce_Job
|
12 |
{
|
13 |
public static $handling_for = null;
|
14 |
|
15 |
+
public $id;
|
16 |
public $subscribed;
|
17 |
public $updated_data;
|
18 |
public $should_ignore = false;
|
19 |
|
20 |
/**
|
21 |
* MailChimp_WooCommerce_User_Submit constructor.
|
22 |
+
* @param null $id
|
23 |
* @param null $subscribed
|
24 |
* @param WP_User|null $updated_data
|
25 |
*/
|
26 |
+
public function __construct($id = null, $subscribed = null, $updated_data = null)
|
27 |
{
|
28 |
+
if (!empty($id)) {
|
29 |
// if we're passing in another user with the same id during the same php process we need to ignore it.
|
30 |
+
if (static::$handling_for === $id) {
|
31 |
$this->should_ignore = true;
|
32 |
}
|
33 |
// set the user id and the current 'handling_for' to this user id so we don't duplicate jobs.
|
34 |
+
static::$handling_for = $this->id = $id;
|
35 |
}
|
36 |
|
37 |
if (is_bool($subscribed)) {
|
55 |
}
|
56 |
|
57 |
if ($this->should_ignore) {
|
58 |
+
mailchimp_debug(get_called_class(), "{$this->id} is currently in motion - skipping this one.");
|
59 |
static::$handling_for = null;
|
60 |
return false;
|
61 |
}
|
64 |
$store_id = mailchimp_get_store_id();
|
65 |
|
66 |
// load up the user.
|
67 |
+
$user = new WP_User($this->id);
|
68 |
|
69 |
// we need a valid user, a valid store id and options to continue
|
70 |
if ($user->ID <= 0 || empty($store_id) || !is_array($options)) {
|
77 |
$store_id = mailchimp_get_store_id();
|
78 |
|
79 |
// load up the user.
|
80 |
+
$user = new WP_User($this->id);
|
81 |
|
82 |
if ($user->ID <= 0 || empty($store_id) || !is_array($options)) {
|
83 |
mailchimp_log('member.sync', "Invalid Data For Submission :: {$user->ID}");
|
96 |
|
97 |
// if we have a null value, we need to grab the correct user meta for is_subscribed
|
98 |
if (is_null($this->subscribed)) {
|
99 |
+
$user_subscribed = get_user_meta($this->id, 'mailchimp_woocommerce_is_subscribed', true);
|
100 |
if ($user_subscribed === '' || $user_subscribed === null) {
|
101 |
mailchimp_log('member.sync', "Skipping sync for {$email} because no subscriber status has been set");
|
102 |
static::$handling_for = null;
|
218 |
} catch (MailChimp_WooCommerce_RateLimitError $e) {
|
219 |
sleep(3);
|
220 |
$this->release();
|
221 |
+
mailchimp_error('member.sync.error', mailchimp_error_trace($e, "RateLimited :: user #{$this->id}"));
|
222 |
} catch (\Exception $e) {
|
223 |
// if we have a 404 not found, we can create the member
|
224 |
if ($e->getCode() == 404) {
|
includes/vendor/action-scheduler/.gitattributes
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
docs export-ignore
|
2 |
+
tests export-ignore
|
3 |
+
codecov.yml export-ignore
|
4 |
+
.github export-ignore
|
5 |
+
.travis.yml export-ignore
|
6 |
+
.gitattributes export-ignore
|
7 |
+
.gitignore export-ignore
|
8 |
+
phpunit.xml.dist export-ignore
|
9 |
+
|
includes/vendor/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)'
|
includes/vendor/action-scheduler/.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
phpunit.xml
|
2 |
+
vendor
|
3 |
+
.idea
|
includes/vendor/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)
|
includes/vendor/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>
|
includes/vendor/action-scheduler/action-scheduler.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Plugin Name: Action Scheduler
|
4 |
+
* Plugin URI: https://actionscheduler.org
|
5 |
+
* Description: A robust scheduling library for use in WordPress plugins.
|
6 |
+
* Author: Prospress
|
7 |
+
* Author URI: https://prospress.com/
|
8 |
+
* Version: 2.2.5
|
9 |
+
* License: GPLv3
|
10 |
+
*
|
11 |
+
* Copyright 2019 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_2_dot_5' ) ) {
|
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_2_dot_5', 0, 0 );
|
36 |
+
|
37 |
+
function action_scheduler_register_2_dot_2_dot_5() {
|
38 |
+
$versions = ActionScheduler_Versions::instance();
|
39 |
+
$versions->register( '2.2.5', 'action_scheduler_initialize_2_dot_2_dot_5' );
|
40 |
+
}
|
41 |
+
|
42 |
+
function action_scheduler_initialize_2_dot_2_dot_5() {
|
43 |
+
require_once( 'classes/ActionScheduler.php' );
|
44 |
+
ActionScheduler::init( __FILE__ );
|
45 |
+
}
|
46 |
+
|
47 |
+
}
|
includes/vendor/action-scheduler/classes/ActionScheduler.php
ADDED
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
89 |
+
* Fires in the early stages of Action Scheduler init hook.
|
90 |
+
*/
|
91 |
+
do_action( 'action_scheduler_pre_init' );
|
92 |
+
|
93 |
+
$store = self::store();
|
94 |
+
add_action( 'init', array( $store, 'init' ), 1, 0 );
|
95 |
+
|
96 |
+
$logger = self::logger();
|
97 |
+
add_action( 'init', array( $logger, 'init' ), 1, 0 );
|
98 |
+
|
99 |
+
$runner = self::runner();
|
100 |
+
add_action( 'init', array( $runner, 'init' ), 1, 0 );
|
101 |
+
|
102 |
+
$admin_view = self::admin_view();
|
103 |
+
add_action( 'init', array( $admin_view, 'init' ), 0, 0 ); // run before $store::init()
|
104 |
+
|
105 |
+
require_once( self::plugin_path('functions.php') );
|
106 |
+
|
107 |
+
if ( apply_filters( 'action_scheduler_load_deprecated_functions', true ) ) {
|
108 |
+
require_once( self::plugin_path('deprecated/functions.php') );
|
109 |
+
}
|
110 |
+
|
111 |
+
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
112 |
+
WP_CLI::add_command( 'action-scheduler', 'ActionScheduler_WPCLI_Scheduler_command' );
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
|
117 |
+
final public function __clone() {
|
118 |
+
trigger_error("Singleton. No cloning allowed!", E_USER_ERROR);
|
119 |
+
}
|
120 |
+
|
121 |
+
final public function __wakeup() {
|
122 |
+
trigger_error("Singleton. No serialization allowed!", E_USER_ERROR);
|
123 |
+
}
|
124 |
+
|
125 |
+
final private function __construct() {}
|
126 |
+
|
127 |
+
/** Deprecated **/
|
128 |
+
|
129 |
+
public static function get_datetime_object( $when = null, $timezone = 'UTC' ) {
|
130 |
+
_deprecated_function( __METHOD__, '2.0', 'wcs_add_months()' );
|
131 |
+
return as_get_datetime_object( $when, $timezone );
|
132 |
+
}
|
133 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/action-scheduler/classes/ActionScheduler_Abstract_QueueRunner.php
ADDED
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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, $action );
|
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 |
+
|
67 |
+
if ( isset( $action ) && is_a( $action, 'ActionScheduler_Action' ) ) {
|
68 |
+
$this->schedule_next_instance( $action );
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Schedule the next instance of the action if necessary.
|
74 |
+
*
|
75 |
+
* @param ActionScheduler_Action $action
|
76 |
+
*/
|
77 |
+
protected function schedule_next_instance( ActionScheduler_Action $action ) {
|
78 |
+
$schedule = $action->get_schedule();
|
79 |
+
$next = $schedule->next( as_get_datetime_object() );
|
80 |
+
|
81 |
+
if ( ! is_null( $next ) && $schedule->is_recurring() ) {
|
82 |
+
$this->store->save_action( $action, $next );
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Run the queue cleaner.
|
88 |
+
*
|
89 |
+
* @author Jeremy Pry
|
90 |
+
*/
|
91 |
+
protected function run_cleanup() {
|
92 |
+
$this->cleaner->clean( 10 * $this->get_time_limit() );
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Get the number of concurrent batches a runner allows.
|
97 |
+
*
|
98 |
+
* @return int
|
99 |
+
*/
|
100 |
+
public function get_allowed_concurrent_batches() {
|
101 |
+
return apply_filters( 'action_scheduler_queue_runner_concurrent_batches', 5 );
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Get the maximum number of seconds a batch can run for.
|
106 |
+
*
|
107 |
+
* @return int The number of seconds.
|
108 |
+
*/
|
109 |
+
protected function get_time_limit() {
|
110 |
+
|
111 |
+
$time_limit = 30;
|
112 |
+
|
113 |
+
// Apply deprecated filter from deprecated get_maximum_execution_time() method
|
114 |
+
if ( has_filter( 'action_scheduler_maximum_execution_time' ) ) {
|
115 |
+
_deprecated_function( 'action_scheduler_maximum_execution_time', '2.1.1', 'action_scheduler_queue_runner_time_limit' );
|
116 |
+
$time_limit = apply_filters( 'action_scheduler_maximum_execution_time', $time_limit );
|
117 |
+
}
|
118 |
+
|
119 |
+
return absint( apply_filters( 'action_scheduler_queue_runner_time_limit', $time_limit ) );
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Get the number of seconds the process has been running.
|
124 |
+
*
|
125 |
+
* @return int The number of seconds.
|
126 |
+
*/
|
127 |
+
protected function get_execution_time() {
|
128 |
+
$execution_time = microtime( true ) - $this->created_time;
|
129 |
+
|
130 |
+
// Get the CPU time if the hosting environment uses it rather than wall-clock time to calculate a process's execution time.
|
131 |
+
if ( function_exists( 'getrusage' ) && apply_filters( 'action_scheduler_use_cpu_execution_time', defined( 'PANTHEON_ENVIRONMENT' ) ) ) {
|
132 |
+
$resource_usages = getrusage();
|
133 |
+
|
134 |
+
if ( isset( $resource_usages['ru_stime.tv_usec'], $resource_usages['ru_stime.tv_usec'] ) ) {
|
135 |
+
$execution_time = $resource_usages['ru_stime.tv_sec'] + ( $resource_usages['ru_stime.tv_usec'] / 1000000 );
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
return $execution_time;
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Check if the host's max execution time is (likely) to be exceeded if processing more actions.
|
144 |
+
*
|
145 |
+
* @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
|
146 |
+
* @return bool
|
147 |
+
*/
|
148 |
+
protected function time_likely_to_be_exceeded( $processed_actions ) {
|
149 |
+
|
150 |
+
$execution_time = $this->get_execution_time();
|
151 |
+
$max_execution_time = $this->get_time_limit();
|
152 |
+
$time_per_action = $execution_time / $processed_actions;
|
153 |
+
$estimated_time = $execution_time + ( $time_per_action * 3 );
|
154 |
+
$likely_to_be_exceeded = $estimated_time > $max_execution_time;
|
155 |
+
|
156 |
+
return apply_filters( 'action_scheduler_maximum_execution_time_likely_to_be_exceeded', $likely_to_be_exceeded, $this, $processed_actions, $execution_time, $max_execution_time );
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Get memory limit
|
161 |
+
*
|
162 |
+
* Based on WP_Background_Process::get_memory_limit()
|
163 |
+
*
|
164 |
+
* @return int
|
165 |
+
*/
|
166 |
+
protected function get_memory_limit() {
|
167 |
+
if ( function_exists( 'ini_get' ) ) {
|
168 |
+
$memory_limit = ini_get( 'memory_limit' );
|
169 |
+
} else {
|
170 |
+
$memory_limit = '128M'; // Sensible default, and minimum required by WooCommerce
|
171 |
+
}
|
172 |
+
|
173 |
+
if ( ! $memory_limit || -1 === $memory_limit || '-1' === $memory_limit ) {
|
174 |
+
// Unlimited, set to 32GB.
|
175 |
+
$memory_limit = '32G';
|
176 |
+
}
|
177 |
+
|
178 |
+
return ActionScheduler_Compatibility::convert_hr_to_bytes( $memory_limit );
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Memory exceeded
|
183 |
+
*
|
184 |
+
* Ensures the batch process never exceeds 90% of the maximum WordPress memory.
|
185 |
+
*
|
186 |
+
* Based on WP_Background_Process::memory_exceeded()
|
187 |
+
*
|
188 |
+
* @return bool
|
189 |
+
*/
|
190 |
+
protected function memory_exceeded() {
|
191 |
+
|
192 |
+
$memory_limit = $this->get_memory_limit() * 0.90;
|
193 |
+
$current_memory = memory_get_usage( true );
|
194 |
+
$memory_exceeded = $current_memory >= $memory_limit;
|
195 |
+
|
196 |
+
return apply_filters( 'action_scheduler_memory_exceeded', $memory_exceeded, $this );
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* See if the batch limits have been exceeded, which is when memory usage is almost at
|
201 |
+
* the maximum limit, or the time to process more actions will exceed the max time limit.
|
202 |
+
*
|
203 |
+
* Based on WC_Background_Process::batch_limits_exceeded()
|
204 |
+
*
|
205 |
+
* @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
|
206 |
+
* @return bool
|
207 |
+
*/
|
208 |
+
protected function batch_limits_exceeded( $processed_actions ) {
|
209 |
+
return $this->memory_exceeded() || $this->time_likely_to_be_exceeded( $processed_actions );
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Process actions in the queue.
|
214 |
+
*
|
215 |
+
* @author Jeremy Pry
|
216 |
+
* @return int The number of actions processed.
|
217 |
+
*/
|
218 |
+
abstract public function run();
|
219 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
|
includes/vendor/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 |
+
}
|
includes/vendor/action-scheduler/classes/ActionScheduler_AdminView.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_action( 'woocommerce_system_status_report', array( $this, 'system_status_report' ) );
|
34 |
+
add_filter( 'woocommerce_admin_status_tabs', array( $this, 'register_system_status_tab' ) );
|
35 |
+
}
|
36 |
+
|
37 |
+
add_action( 'admin_menu', array( $this, 'register_menu' ) );
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
public function system_status_report() {
|
42 |
+
$table = new ActionScheduler_wcSystemStatus( ActionScheduler::store() );
|
43 |
+
$table->render();
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Registers action-scheduler into WooCommerce > System status.
|
48 |
+
*
|
49 |
+
* @param array $tabs An associative array of tab key => label.
|
50 |
+
* @return array $tabs An associative array of tab key => label, including Action Scheduler's tabs
|
51 |
+
*/
|
52 |
+
public function register_system_status_tab( array $tabs ) {
|
53 |
+
$tabs['action-scheduler'] = __( 'Scheduled Actions', 'action-scheduler' );
|
54 |
+
|
55 |
+
return $tabs;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Include Action Scheduler's administration under the Tools menu.
|
60 |
+
*
|
61 |
+
* A menu under the Tools menu is important for backward compatibility (as that's
|
62 |
+
* where it started), and also provides more convenient access than the WooCommerce
|
63 |
+
* System Status page, and for sites where WooCommerce isn't active.
|
64 |
+
*/
|
65 |
+
public function register_menu() {
|
66 |
+
add_submenu_page(
|
67 |
+
'tools.php',
|
68 |
+
__( 'Scheduled Actions', 'action-scheduler' ),
|
69 |
+
__( 'Scheduled Actions', 'action-scheduler' ),
|
70 |
+
'manage_options',
|
71 |
+
'action-scheduler',
|
72 |
+
array( $this, 'render_admin_ui' )
|
73 |
+
);
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Renders the Admin UI
|
78 |
+
*/
|
79 |
+
public function render_admin_ui() {
|
80 |
+
$table = new ActionScheduler_ListTable( ActionScheduler::store(), ActionScheduler::logger(), ActionScheduler::runner() );
|
81 |
+
$table->display_page();
|
82 |
+
}
|
83 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/action-scheduler/classes/ActionScheduler_CronSchedule.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* @return string
|
36 |
+
*/
|
37 |
+
public function get_recurrence() {
|
38 |
+
return strval($this->cron);
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* For PHP 5.2 compat, since DateTime objects can't be serialized
|
43 |
+
* @return array
|
44 |
+
*/
|
45 |
+
public function __sleep() {
|
46 |
+
$this->start_timestamp = $this->start->getTimestamp();
|
47 |
+
return array(
|
48 |
+
'start_timestamp',
|
49 |
+
'cron'
|
50 |
+
);
|
51 |
+
}
|
52 |
+
|
53 |
+
public function __wakeup() {
|
54 |
+
$this->start = as_get_datetime_object($this->start_timestamp);
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
includes/vendor/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 |
+
}
|
includes/vendor/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 {}
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
|
includes/vendor/action-scheduler/classes/ActionScheduler_IntervalSchedule.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* @return int
|
40 |
+
*/
|
41 |
+
public function interval_in_seconds() {
|
42 |
+
return $this->interval_in_seconds;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* For PHP 5.2 compat, since DateTime objects can't be serialized
|
47 |
+
* @return array
|
48 |
+
*/
|
49 |
+
public function __sleep() {
|
50 |
+
$this->start_timestamp = $this->start->getTimestamp();
|
51 |
+
return array(
|
52 |
+
'start_timestamp',
|
53 |
+
'interval_in_seconds'
|
54 |
+
);
|
55 |
+
}
|
56 |
+
|
57 |
+
public function __wakeup() {
|
58 |
+
$this->start = as_get_datetime_object($this->start_timestamp);
|
59 |
+
}
|
60 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/action-scheduler/classes/ActionScheduler_ListTable.php
ADDED
@@ -0,0 +1,533 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 ( $recurrence->is_recurring() ) {
|
226 |
+
if ( method_exists( $recurrence, 'interval_in_seconds' ) ) {
|
227 |
+
return sprintf( __( 'Every %s', 'action-scheduler' ), self::human_interval( $recurrence->interval_in_seconds() ) );
|
228 |
+
}
|
229 |
+
|
230 |
+
if ( method_exists( $recurrence, 'get_recurrence' ) ) {
|
231 |
+
return sprintf( __( 'Cron %s', 'action-scheduler' ), $recurrence->get_recurrence() );
|
232 |
+
}
|
233 |
+
}
|
234 |
+
|
235 |
+
return __( 'Non-repeating', 'action-scheduler' );
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Serializes the argument of an action to render it in a human friendly format.
|
240 |
+
*
|
241 |
+
* @param array $row The array representation of the current row of the table
|
242 |
+
*
|
243 |
+
* @return string
|
244 |
+
*/
|
245 |
+
public function column_args( array $row ) {
|
246 |
+
if ( empty( $row['args'] ) ) {
|
247 |
+
return '';
|
248 |
+
}
|
249 |
+
|
250 |
+
$row_html = '<ul>';
|
251 |
+
foreach ( $row['args'] as $key => $value ) {
|
252 |
+
$row_html .= sprintf( '<li><code>%s => %s</code></li>', esc_html( var_export( $key, true ) ), esc_html( var_export( $value, true ) ) );
|
253 |
+
}
|
254 |
+
$row_html .= '</ul>';
|
255 |
+
|
256 |
+
return apply_filters( 'action_scheduler_list_table_column_args', $row_html, $row );
|
257 |
+
}
|
258 |
+
|
259 |
+
/**
|
260 |
+
* Prints the logs entries inline. We do so to avoid loading Javascript and other hacks to show it in a modal.
|
261 |
+
*
|
262 |
+
* @param array $row Action array.
|
263 |
+
* @return string
|
264 |
+
*/
|
265 |
+
public function column_log_entries( array $row ) {
|
266 |
+
|
267 |
+
$log_entries_html = '<ol>';
|
268 |
+
|
269 |
+
$timezone = new DateTimezone( 'UTC' );
|
270 |
+
|
271 |
+
foreach ( $row['log_entries'] as $log_entry ) {
|
272 |
+
$log_entries_html .= $this->get_log_entry_html( $log_entry, $timezone );
|
273 |
+
}
|
274 |
+
|
275 |
+
$log_entries_html .= '</ol>';
|
276 |
+
|
277 |
+
return $log_entries_html;
|
278 |
+
}
|
279 |
+
|
280 |
+
/**
|
281 |
+
* Prints the logs entries inline. We do so to avoid loading Javascript and other hacks to show it in a modal.
|
282 |
+
*
|
283 |
+
* @param ActionScheduler_LogEntry $log_entry
|
284 |
+
* @param DateTimezone $timezone
|
285 |
+
* @return string
|
286 |
+
*/
|
287 |
+
protected function get_log_entry_html( ActionScheduler_LogEntry $log_entry, DateTimezone $timezone ) {
|
288 |
+
$date = $log_entry->get_date();
|
289 |
+
$date->setTimezone( $timezone );
|
290 |
+
return sprintf( '<li><strong>%s</strong><br/>%s</li>', esc_html( $date->format( 'Y-m-d H:i:s O' ) ), esc_html( $log_entry->get_message() ) );
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* Only display row actions for pending actions.
|
295 |
+
*
|
296 |
+
* @param array $row Row to render
|
297 |
+
* @param string $column_name Current row
|
298 |
+
*
|
299 |
+
* @return string
|
300 |
+
*/
|
301 |
+
protected function maybe_render_actions( $row, $column_name ) {
|
302 |
+
if ( 'pending' === strtolower( $row['status'] ) ) {
|
303 |
+
return parent::maybe_render_actions( $row, $column_name );
|
304 |
+
}
|
305 |
+
|
306 |
+
return '';
|
307 |
+
}
|
308 |
+
|
309 |
+
/**
|
310 |
+
* Renders admin notifications
|
311 |
+
*
|
312 |
+
* Notifications:
|
313 |
+
* 1. When the maximum number of tasks are being executed simultaneously
|
314 |
+
* 2. Notifications when a task us manually executed
|
315 |
+
*/
|
316 |
+
public function display_admin_notices() {
|
317 |
+
|
318 |
+
if ( $this->store->get_claim_count() >= $this->runner->get_allowed_concurrent_batches() ) {
|
319 |
+
$this->admin_notices[] = array(
|
320 |
+
'class' => 'updated',
|
321 |
+
'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() ),
|
322 |
+
);
|
323 |
+
}
|
324 |
+
|
325 |
+
$notification = get_transient( 'action_scheduler_admin_notice' );
|
326 |
+
|
327 |
+
if ( is_array( $notification ) ) {
|
328 |
+
delete_transient( 'action_scheduler_admin_notice' );
|
329 |
+
|
330 |
+
$action = $this->store->fetch_action( $notification['action_id'] );
|
331 |
+
$action_hook_html = '<strong><code>' . $action->get_hook() . '</code></strong>';
|
332 |
+
if ( 1 == $notification['success'] ) {
|
333 |
+
$class = 'updated';
|
334 |
+
switch ( $notification['row_action_type'] ) {
|
335 |
+
case 'run' :
|
336 |
+
$action_message_html = sprintf( __( 'Successfully executed action: %s', 'action-scheduler' ), $action_hook_html );
|
337 |
+
break;
|
338 |
+
case 'cancel' :
|
339 |
+
$action_message_html = sprintf( __( 'Successfully canceled action: %s', 'action-scheduler' ), $action_hook_html );
|
340 |
+
break;
|
341 |
+
default :
|
342 |
+
$action_message_html = sprintf( __( 'Successfully processed change for action: %s', 'action-scheduler' ), $action_hook_html );
|
343 |
+
break;
|
344 |
+
}
|
345 |
+
} else {
|
346 |
+
$class = 'error';
|
347 |
+
$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'] ) );
|
348 |
+
}
|
349 |
+
|
350 |
+
$action_message_html = apply_filters( 'action_scheduler_admin_notice_html', $action_message_html, $action, $notification );
|
351 |
+
|
352 |
+
$this->admin_notices[] = array(
|
353 |
+
'class' => $class,
|
354 |
+
'message' => $action_message_html,
|
355 |
+
);
|
356 |
+
}
|
357 |
+
|
358 |
+
parent::display_admin_notices();
|
359 |
+
}
|
360 |
+
|
361 |
+
/**
|
362 |
+
* Prints the scheduled date in a human friendly format.
|
363 |
+
*
|
364 |
+
* @param array $row The array representation of the current row of the table
|
365 |
+
*
|
366 |
+
* @return string
|
367 |
+
*/
|
368 |
+
public function column_schedule( $row ) {
|
369 |
+
return $this->get_schedule_display_string( $row['schedule'] );
|
370 |
+
}
|
371 |
+
|
372 |
+
/**
|
373 |
+
* Get the scheduled date in a human friendly format.
|
374 |
+
*
|
375 |
+
* @param ActionScheduler_Schedule $schedule
|
376 |
+
* @return string
|
377 |
+
*/
|
378 |
+
protected function get_schedule_display_string( ActionScheduler_Schedule $schedule ) {
|
379 |
+
|
380 |
+
$schedule_display_string = '';
|
381 |
+
|
382 |
+
if ( ! $schedule->next() ) {
|
383 |
+
return $schedule_display_string;
|
384 |
+
}
|
385 |
+
|
386 |
+
$next_timestamp = $schedule->next()->getTimestamp();
|
387 |
+
|
388 |
+
$schedule_display_string .= $schedule->next()->format( 'Y-m-d H:i:s O' );
|
389 |
+
$schedule_display_string .= '<br/>';
|
390 |
+
|
391 |
+
if ( gmdate( 'U' ) > $next_timestamp ) {
|
392 |
+
$schedule_display_string .= sprintf( __( ' (%s ago)', 'action-scheduler' ), self::human_interval( gmdate( 'U' ) - $next_timestamp ) );
|
393 |
+
} else {
|
394 |
+
$schedule_display_string .= sprintf( __( ' (%s)', 'action-scheduler' ), self::human_interval( $next_timestamp - gmdate( 'U' ) ) );
|
395 |
+
}
|
396 |
+
|
397 |
+
return $schedule_display_string;
|
398 |
+
}
|
399 |
+
|
400 |
+
/**
|
401 |
+
* Bulk delete
|
402 |
+
*
|
403 |
+
* Deletes actions based on their ID. This is the handler for the bulk delete. It assumes the data
|
404 |
+
* properly validated by the callee and it will delete the actions without any extra validation.
|
405 |
+
*
|
406 |
+
* @param array $ids
|
407 |
+
* @param string $ids_sql Inherited and unused
|
408 |
+
*/
|
409 |
+
protected function bulk_delete( array $ids, $ids_sql ) {
|
410 |
+
foreach ( $ids as $id ) {
|
411 |
+
$this->store->delete_action( $id );
|
412 |
+
}
|
413 |
+
}
|
414 |
+
|
415 |
+
/**
|
416 |
+
* Implements the logic behind running an action. ActionScheduler_Abstract_ListTable validates the request and their
|
417 |
+
* parameters are valid.
|
418 |
+
*
|
419 |
+
* @param int $action_id
|
420 |
+
*/
|
421 |
+
protected function row_action_cancel( $action_id ) {
|
422 |
+
$this->process_row_action( $action_id, 'cancel' );
|
423 |
+
}
|
424 |
+
|
425 |
+
/**
|
426 |
+
* Implements the logic behind running an action. ActionScheduler_Abstract_ListTable validates the request and their
|
427 |
+
* parameters are valid.
|
428 |
+
*
|
429 |
+
* @param int $action_id
|
430 |
+
*/
|
431 |
+
protected function row_action_run( $action_id ) {
|
432 |
+
$this->process_row_action( $action_id, 'run' );
|
433 |
+
}
|
434 |
+
|
435 |
+
/**
|
436 |
+
* Implements the logic behind processing an action once an action link is clicked on the list table.
|
437 |
+
*
|
438 |
+
* @param int $action_id
|
439 |
+
* @param string $row_action_type The type of action to perform on the action.
|
440 |
+
*/
|
441 |
+
protected function process_row_action( $action_id, $row_action_type ) {
|
442 |
+
try {
|
443 |
+
switch ( $row_action_type ) {
|
444 |
+
case 'run' :
|
445 |
+
$this->runner->process_action( $action_id );
|
446 |
+
break;
|
447 |
+
case 'cancel' :
|
448 |
+
$this->store->cancel_action( $action_id );
|
449 |
+
break;
|
450 |
+
}
|
451 |
+
$success = 1;
|
452 |
+
$error_message = '';
|
453 |
+
} catch ( Exception $e ) {
|
454 |
+
$success = 0;
|
455 |
+
$error_message = $e->getMessage();
|
456 |
+
}
|
457 |
+
|
458 |
+
set_transient( 'action_scheduler_admin_notice', compact( 'action_id', 'success', 'error_message', 'row_action_type' ), 30 );
|
459 |
+
}
|
460 |
+
|
461 |
+
/**
|
462 |
+
* {@inheritDoc}
|
463 |
+
*/
|
464 |
+
public function prepare_items() {
|
465 |
+
$this->process_bulk_action();
|
466 |
+
|
467 |
+
$this->process_row_actions();
|
468 |
+
|
469 |
+
if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
|
470 |
+
// _wp_http_referer is used only on bulk actions, we remove it to keep the $_GET shorter
|
471 |
+
wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
|
472 |
+
exit;
|
473 |
+
}
|
474 |
+
|
475 |
+
$this->prepare_column_headers();
|
476 |
+
|
477 |
+
$per_page = $this->get_items_per_page( $this->package . '_items_per_page', $this->items_per_page );
|
478 |
+
$query = array(
|
479 |
+
'per_page' => $per_page,
|
480 |
+
'offset' => $this->get_items_offset(),
|
481 |
+
'status' => $this->get_request_status(),
|
482 |
+
'orderby' => $this->get_request_orderby(),
|
483 |
+
'order' => $this->get_request_order(),
|
484 |
+
'search' => $this->get_request_search_query(),
|
485 |
+
);
|
486 |
+
|
487 |
+
$this->items = array();
|
488 |
+
|
489 |
+
$total_items = $this->store->query_actions( $query, 'count' );
|
490 |
+
|
491 |
+
$status_labels = $this->store->get_status_labels();
|
492 |
+
|
493 |
+
foreach ( $this->store->query_actions( $query ) as $action_id ) {
|
494 |
+
try {
|
495 |
+
$action = $this->store->fetch_action( $action_id );
|
496 |
+
} catch ( Exception $e ) {
|
497 |
+
continue;
|
498 |
+
}
|
499 |
+
$this->items[ $action_id ] = array(
|
500 |
+
'ID' => $action_id,
|
501 |
+
'hook' => $action->get_hook(),
|
502 |
+
'status' => $status_labels[ $this->store->get_status( $action_id ) ],
|
503 |
+
'args' => $action->get_args(),
|
504 |
+
'group' => $action->get_group(),
|
505 |
+
'log_entries' => $this->logger->get_logs( $action_id ),
|
506 |
+
'claim_id' => $this->store->get_claim_id( $action_id ),
|
507 |
+
'recurrence' => $this->get_recurrence( $action ),
|
508 |
+
'schedule' => $action->get_schedule(),
|
509 |
+
);
|
510 |
+
}
|
511 |
+
|
512 |
+
$this->set_pagination_args( array(
|
513 |
+
'total_items' => $total_items,
|
514 |
+
'per_page' => $per_page,
|
515 |
+
'total_pages' => ceil( $total_items / $per_page ),
|
516 |
+
) );
|
517 |
+
}
|
518 |
+
|
519 |
+
/**
|
520 |
+
* Prints the available statuses so the user can click to filter.
|
521 |
+
*/
|
522 |
+
protected function display_filter_by_status() {
|
523 |
+
$this->status_counts = $this->store->action_counts();
|
524 |
+
parent::display_filter_by_status();
|
525 |
+
}
|
526 |
+
|
527 |
+
/**
|
528 |
+
* Get the text to display in the search box on the list table.
|
529 |
+
*/
|
530 |
+
protected function get_search_box_button_text() {
|
531 |
+
return __( 'Search hook, args and claim ID', 'action-scheduler' );
|
532 |
+
}
|
533 |
+
}
|
includes/vendor/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 |
+
|
includes/vendor/action-scheduler/classes/ActionScheduler_Logger.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
add_action( 'action_scheduler_failed_fetch_action', array( $this, 'log_failed_fetch_action' ), 10, 1 );
|
59 |
+
}
|
60 |
+
|
61 |
+
public function log_stored_action( $action_id ) {
|
62 |
+
$this->log( $action_id, __( 'action created', 'action-scheduler' ) );
|
63 |
+
}
|
64 |
+
|
65 |
+
public function log_canceled_action( $action_id ) {
|
66 |
+
$this->log( $action_id, __( 'action canceled', 'action-scheduler' ) );
|
67 |
+
}
|
68 |
+
|
69 |
+
public function log_started_action( $action_id ) {
|
70 |
+
$this->log( $action_id, __( 'action started', 'action-scheduler' ) );
|
71 |
+
}
|
72 |
+
|
73 |
+
public function log_completed_action( $action_id ) {
|
74 |
+
$this->log( $action_id, __( 'action complete', 'action-scheduler' ) );
|
75 |
+
}
|
76 |
+
|
77 |
+
public function log_failed_action( $action_id, Exception $exception ) {
|
78 |
+
$this->log( $action_id, sprintf( __( 'action failed: %s', 'action-scheduler' ), $exception->getMessage() ) );
|
79 |
+
}
|
80 |
+
|
81 |
+
public function log_timed_out_action( $action_id, $timeout ) {
|
82 |
+
$this->log( $action_id, sprintf( __( 'action timed out after %s seconds', 'action-scheduler' ), $timeout ) );
|
83 |
+
}
|
84 |
+
|
85 |
+
public function log_unexpected_shutdown( $action_id, $error ) {
|
86 |
+
if ( ! empty( $error ) ) {
|
87 |
+
$this->log( $action_id, sprintf( __( 'unexpected shutdown: PHP Fatal error %s in %s on line %s', 'action-scheduler' ), $error['message'], $error['file'], $error['line'] ) );
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
public function log_reset_action( $action_id ) {
|
92 |
+
$this->log( $action_id, __( 'action reset', 'action_scheduler' ) );
|
93 |
+
}
|
94 |
+
|
95 |
+
public function log_ignored_action( $action_id ) {
|
96 |
+
$this->log( $action_id, __( 'action ignored', 'action-scheduler' ) );
|
97 |
+
}
|
98 |
+
|
99 |
+
public function log_failed_fetch_action( $action_id ) {
|
100 |
+
$this->log( $action_id, __( 'There was a failure fetching this action', 'action-scheduler' ) );
|
101 |
+
}
|
102 |
+
}
|
includes/vendor/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 |
+
|
includes/vendor/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 |
+
|
includes/vendor/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 |
+
|
includes/vendor/action-scheduler/classes/ActionScheduler_QueueCleaner.php
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* ActionScheduler_QueueCleaner constructor.
|
23 |
+
*
|
24 |
+
* @param ActionScheduler_Store $store The store instance.
|
25 |
+
* @param int $batch_size The batch size.
|
26 |
+
*/
|
27 |
+
public function __construct( ActionScheduler_Store $store = null, $batch_size = 20 ) {
|
28 |
+
$this->store = $store ? $store : ActionScheduler_Store::instance();
|
29 |
+
$this->batch_size = $batch_size;
|
30 |
+
}
|
31 |
+
|
32 |
+
public function delete_old_actions() {
|
33 |
+
$lifespan = apply_filters( 'action_scheduler_retention_period', $this->month_in_seconds );
|
34 |
+
$cutoff = as_get_datetime_object($lifespan.' seconds ago');
|
35 |
+
|
36 |
+
$statuses_to_purge = array(
|
37 |
+
ActionScheduler_Store::STATUS_COMPLETE,
|
38 |
+
ActionScheduler_Store::STATUS_CANCELED,
|
39 |
+
);
|
40 |
+
|
41 |
+
foreach ( $statuses_to_purge as $status ) {
|
42 |
+
$actions_to_delete = $this->store->query_actions( array(
|
43 |
+
'status' => $status,
|
44 |
+
'modified' => $cutoff,
|
45 |
+
'modified_compare' => '<=',
|
46 |
+
'per_page' => $this->get_batch_size(),
|
47 |
+
) );
|
48 |
+
|
49 |
+
foreach ( $actions_to_delete as $action_id ) {
|
50 |
+
try {
|
51 |
+
$this->store->delete_action( $action_id );
|
52 |
+
} catch ( Exception $e ) {
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Notify 3rd party code of exceptions when deleting a completed action older than the retention period
|
56 |
+
*
|
57 |
+
* This hook provides a way for 3rd party code to log or otherwise handle exceptions relating to their
|
58 |
+
* actions.
|
59 |
+
*
|
60 |
+
* @since 2.0.0
|
61 |
+
*
|
62 |
+
* @param int $action_id The scheduled actions ID in the data store
|
63 |
+
* @param Exception $e The exception thrown when attempting to delete the action from the data store
|
64 |
+
* @param int $lifespan The retention period, in seconds, for old actions
|
65 |
+
* @param int $count_of_actions_to_delete The number of old actions being deleted in this batch
|
66 |
+
*/
|
67 |
+
do_action( 'action_scheduler_failed_old_action_deletion', $action_id, $e, $lifespan, count( $actions_to_delete ) );
|
68 |
+
}
|
69 |
+
}
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Unclaim pending actions that have not been run within a given time limit.
|
75 |
+
*
|
76 |
+
* When called by ActionScheduler_Abstract_QueueRunner::run_cleanup(), the time limit passed
|
77 |
+
* as a parameter is 10x the time limit used for queue processing.
|
78 |
+
*
|
79 |
+
* @param int $time_limit The number of seconds to allow a queue to run before unclaiming its pending actions. Default 300 (5 minutes).
|
80 |
+
*/
|
81 |
+
public function reset_timeouts( $time_limit = 300 ) {
|
82 |
+
$timeout = apply_filters( 'action_scheduler_timeout_period', $time_limit );
|
83 |
+
if ( $timeout < 0 ) {
|
84 |
+
return;
|
85 |
+
}
|
86 |
+
$cutoff = as_get_datetime_object($timeout.' seconds ago');
|
87 |
+
$actions_to_reset = $this->store->query_actions( array(
|
88 |
+
'status' => ActionScheduler_Store::STATUS_PENDING,
|
89 |
+
'modified' => $cutoff,
|
90 |
+
'modified_compare' => '<=',
|
91 |
+
'claimed' => true,
|
92 |
+
'per_page' => $this->get_batch_size(),
|
93 |
+
) );
|
94 |
+
|
95 |
+
foreach ( $actions_to_reset as $action_id ) {
|
96 |
+
$this->store->unclaim_action( $action_id );
|
97 |
+
do_action( 'action_scheduler_reset_action', $action_id );
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Mark actions that have been running for more than a given time limit as failed, based on
|
103 |
+
* the assumption some uncatachable and unloggable fatal error occurred during processing.
|
104 |
+
*
|
105 |
+
* When called by ActionScheduler_Abstract_QueueRunner::run_cleanup(), the time limit passed
|
106 |
+
* as a parameter is 10x the time limit used for queue processing.
|
107 |
+
*
|
108 |
+
* @param int $time_limit The number of seconds to allow an action to run before it is considered to have failed. Default 300 (5 minutes).
|
109 |
+
*/
|
110 |
+
public function mark_failures( $time_limit = 300 ) {
|
111 |
+
$timeout = apply_filters( 'action_scheduler_failure_period', $time_limit );
|
112 |
+
if ( $timeout < 0 ) {
|
113 |
+
return;
|
114 |
+
}
|
115 |
+
$cutoff = as_get_datetime_object($timeout.' seconds ago');
|
116 |
+
$actions_to_reset = $this->store->query_actions( array(
|
117 |
+
'status' => ActionScheduler_Store::STATUS_RUNNING,
|
118 |
+
'modified' => $cutoff,
|
119 |
+
'modified_compare' => '<=',
|
120 |
+
'per_page' => $this->get_batch_size(),
|
121 |
+
) );
|
122 |
+
|
123 |
+
foreach ( $actions_to_reset as $action_id ) {
|
124 |
+
$this->store->mark_failure( $action_id );
|
125 |
+
do_action( 'action_scheduler_failed_action', $action_id, $timeout );
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Do all of the cleaning actions.
|
131 |
+
*
|
132 |
+
* @param int $time_limit The number of seconds to use as the timeout and failure period. Default 300 (5 minutes).
|
133 |
+
* @author Jeremy Pry
|
134 |
+
*/
|
135 |
+
public function clean( $time_limit = 300 ) {
|
136 |
+
$this->delete_old_actions();
|
137 |
+
$this->reset_timeouts( $time_limit );
|
138 |
+
$this->mark_failures( $time_limit );
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Get the batch size for cleaning the queue.
|
143 |
+
*
|
144 |
+
* @author Jeremy Pry
|
145 |
+
* @return int
|
146 |
+
*/
|
147 |
+
protected function get_batch_size() {
|
148 |
+
/**
|
149 |
+
* Filter the batch size when cleaning the queue.
|
150 |
+
*
|
151 |
+
* @param int $batch_size The number of actions to clean in one batch.
|
152 |
+
*/
|
153 |
+
return absint( apply_filters( 'action_scheduler_cleanup_batch_size', $this->batch_size ) );
|
154 |
+
}
|
155 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
|
includes/vendor/action-scheduler/classes/ActionScheduler_WPCLI_QueueRunner.php
ADDED
@@ -0,0 +1,217 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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' ), 10, 2 );
|
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 |
+
$this->maybe_stop_the_insanity();
|
116 |
+
}
|
117 |
+
|
118 |
+
$completed = $this->progress_bar->current();
|
119 |
+
$this->progress_bar->finish();
|
120 |
+
$this->store->release_claim( $this->claim );
|
121 |
+
do_action( 'action_scheduler_after_process_queue' );
|
122 |
+
|
123 |
+
return $completed;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Handle WP CLI message when the action is starting.
|
128 |
+
*
|
129 |
+
* @author Jeremy Pry
|
130 |
+
*
|
131 |
+
* @param $action_id
|
132 |
+
*/
|
133 |
+
public function before_execute( $action_id ) {
|
134 |
+
/* translators: %s refers to the action ID */
|
135 |
+
WP_CLI::log( sprintf( __( 'Started processing action %s', 'action-scheduler' ), $action_id ) );
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Handle WP CLI message when the action has completed.
|
140 |
+
*
|
141 |
+
* @author Jeremy Pry
|
142 |
+
*
|
143 |
+
* @param int $action_id
|
144 |
+
* @param null|ActionScheduler_Action $action The instance of the action. Default to null for backward compatibility.
|
145 |
+
*/
|
146 |
+
public function after_execute( $action_id, $action = null ) {
|
147 |
+
// backward compatibility
|
148 |
+
if ( null === $action ) {
|
149 |
+
$action = $this->store->fetch_action( $action_id );
|
150 |
+
}
|
151 |
+
/* translators: %s refers to the action ID */
|
152 |
+
WP_CLI::log( sprintf( __( 'Completed processing action %s with hook: %s', 'action-scheduler' ), $action_id, $action->get_hook() ) );
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Handle WP CLI message when the action has failed.
|
157 |
+
*
|
158 |
+
* @author Jeremy Pry
|
159 |
+
*
|
160 |
+
* @param int $action_id
|
161 |
+
* @param Exception $exception
|
162 |
+
* @throws \WP_CLI\ExitException With failure message.
|
163 |
+
*/
|
164 |
+
public function action_failed( $action_id, $exception ) {
|
165 |
+
WP_CLI::error(
|
166 |
+
/* translators: %1$s refers to the action ID, %2$s refers to the Exception message */
|
167 |
+
sprintf( __( 'Error processing action %1$s: %2$s', 'action-scheduler' ), $action_id, $exception->getMessage() ),
|
168 |
+
false
|
169 |
+
);
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Sleep and help avoid hitting memory limit
|
174 |
+
*
|
175 |
+
* @param int $sleep_time Amount of seconds to sleep
|
176 |
+
*/
|
177 |
+
protected function stop_the_insanity( $sleep_time = 0 ) {
|
178 |
+
if ( 0 < $sleep_time ) {
|
179 |
+
WP_CLI::warning( sprintf( 'Stopped the insanity for %d %s', $sleep_time, _n( 'second', 'seconds', $sleep_time ) ) );
|
180 |
+
sleep( $sleep_time );
|
181 |
+
}
|
182 |
+
|
183 |
+
WP_CLI::warning( __( 'Attempting to reduce used memory...', 'action-scheduler' ) );
|
184 |
+
|
185 |
+
/**
|
186 |
+
* @var $wpdb \wpdb
|
187 |
+
* @var $wp_object_cache \WP_Object_Cache
|
188 |
+
*/
|
189 |
+
global $wpdb, $wp_object_cache;
|
190 |
+
|
191 |
+
$wpdb->queries = array();
|
192 |
+
|
193 |
+
if ( ! is_object( $wp_object_cache ) ) {
|
194 |
+
return;
|
195 |
+
}
|
196 |
+
|
197 |
+
$wp_object_cache->group_ops = array();
|
198 |
+
$wp_object_cache->stats = array();
|
199 |
+
$wp_object_cache->memcache_debug = array();
|
200 |
+
$wp_object_cache->cache = array();
|
201 |
+
|
202 |
+
if ( is_callable( array( $wp_object_cache, '__remoteset' ) ) ) {
|
203 |
+
call_user_func( array( $wp_object_cache, '__remoteset' ) ); // important
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Maybe trigger the stop_the_insanity() method to free up memory.
|
209 |
+
*/
|
210 |
+
protected function maybe_stop_the_insanity() {
|
211 |
+
// The value returned by progress_bar->current() might be padded. Remove padding, and convert to int.
|
212 |
+
$current_iteration = intval( trim( $this->progress_bar->current() ) );
|
213 |
+
if ( 0 === $current_iteration % 50 ) {
|
214 |
+
$this->stop_the_insanity();
|
215 |
+
}
|
216 |
+
}
|
217 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/action-scheduler/classes/ActionScheduler_wcSystemStatus.php
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ActionScheduler_wcSystemStatus
|
5 |
+
*/
|
6 |
+
class ActionScheduler_wcSystemStatus {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* The active data stores
|
10 |
+
*
|
11 |
+
* @var ActionScheduler_Store
|
12 |
+
*/
|
13 |
+
protected $store;
|
14 |
+
|
15 |
+
function __construct( $store ) {
|
16 |
+
$this->store = $store;
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Display action data, including number of actions grouped by status and the oldest & newest action in each status.
|
21 |
+
*
|
22 |
+
* Helpful to identify issues, like a clogged queue.
|
23 |
+
*/
|
24 |
+
public function render() {
|
25 |
+
$action_counts = $this->store->action_counts();
|
26 |
+
$status_labels = $this->store->get_status_labels();
|
27 |
+
$oldest_and_newest = $this->get_oldest_and_newest( array_keys( $status_labels ) );
|
28 |
+
|
29 |
+
$this->get_template( $status_labels, $action_counts, $oldest_and_newest );
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Get oldest and newest scheduled dates for a given set of statuses.
|
34 |
+
*
|
35 |
+
* @param array $status_keys Set of statuses to find oldest & newest action for.
|
36 |
+
* @return array
|
37 |
+
*/
|
38 |
+
protected function get_oldest_and_newest( $status_keys ) {
|
39 |
+
|
40 |
+
$oldest_and_newest = array();
|
41 |
+
|
42 |
+
foreach ( $status_keys as $status ) {
|
43 |
+
$oldest_and_newest[ $status ] = array(
|
44 |
+
'oldest' => '–',
|
45 |
+
'newest' => '–',
|
46 |
+
);
|
47 |
+
|
48 |
+
if ( 'in-progress' === $status ) {
|
49 |
+
continue;
|
50 |
+
}
|
51 |
+
|
52 |
+
$oldest_and_newest[ $status ]['oldest'] = $this->get_action_status_date( $status, 'oldest' );
|
53 |
+
$oldest_and_newest[ $status ]['newest'] = $this->get_action_status_date( $status, 'newest' );
|
54 |
+
}
|
55 |
+
|
56 |
+
return $oldest_and_newest;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Get oldest or newest scheduled date for a given status.
|
61 |
+
*
|
62 |
+
* @param string $status Action status label/name string.
|
63 |
+
* @param string $date_type Oldest or Newest.
|
64 |
+
* @return DateTime
|
65 |
+
*/
|
66 |
+
protected function get_action_status_date( $status, $date_type = 'oldest' ) {
|
67 |
+
|
68 |
+
$order = 'oldest' === $date_type ? 'ASC' : 'DESC';
|
69 |
+
|
70 |
+
$action = $this->store->query_actions( array(
|
71 |
+
'claimed' => false,
|
72 |
+
'status' => $status,
|
73 |
+
'per_page' => 1,
|
74 |
+
'order' => $order,
|
75 |
+
) );
|
76 |
+
|
77 |
+
if ( ! empty( $action ) ) {
|
78 |
+
$date_object = $this->store->get_date( $action[0] );
|
79 |
+
$action_date = $date_object->format( 'Y-m-d H:i:s O' );
|
80 |
+
} else {
|
81 |
+
$action_date = '–';
|
82 |
+
}
|
83 |
+
|
84 |
+
return $action_date;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Get oldest or newest scheduled date for a given status.
|
89 |
+
*
|
90 |
+
* @param array $status_labels Set of statuses to find oldest & newest action for.
|
91 |
+
* @param array $action_counts Number of actions grouped by status.
|
92 |
+
* @param array $oldest_and_newest Date of the oldest and newest action with each status.
|
93 |
+
*/
|
94 |
+
protected function get_template( $status_labels, $action_counts, $oldest_and_newest ) {
|
95 |
+
?>
|
96 |
+
|
97 |
+
<table class="wc_status_table widefat" cellspacing="0">
|
98 |
+
<thead>
|
99 |
+
<tr>
|
100 |
+
<th colspan="5" data-export-label="Action Scheduler"><h2><?php esc_html_e( 'Action Scheduler', 'action-scheduler' ); ?><?php echo wc_help_tip( esc_html__( 'This section shows scheduled action counts.', 'action-scheduler' ) ); ?></h2></th>
|
101 |
+
</tr>
|
102 |
+
<tr>
|
103 |
+
<td><strong><?php esc_html_e( 'Action Status', 'action-scheduler' ); ?></strong></td>
|
104 |
+
<td class="help"> </td>
|
105 |
+
<td><strong><?php esc_html_e( 'Count', 'action-scheduler' ); ?></strong></td>
|
106 |
+
<td><strong><?php esc_html_e( 'Oldest Scheduled Date', 'action-scheduler' ); ?></strong></td>
|
107 |
+
<td><strong><?php esc_html_e( 'Newest Scheduled Date', 'action-scheduler' ); ?></strong></td>
|
108 |
+
</tr>
|
109 |
+
</thead>
|
110 |
+
<tbody>
|
111 |
+
<?php
|
112 |
+
foreach ( $action_counts as $status => $count ) {
|
113 |
+
// WC uses the 3rd column for export, so we need to display more data in that (hidden when viewed as part of the table) and add an empty 2nd column.
|
114 |
+
printf(
|
115 |
+
'<tr><td>%1$s</td><td> </td><td>%2$s<span style="display: none;">, Oldest: %3$s, Newest: %4$s</span></td><td>%3$s</td><td>%4$s</td></tr>',
|
116 |
+
esc_html( $status_labels[ $status ] ),
|
117 |
+
number_format_i18n( $count ),
|
118 |
+
$oldest_and_newest[ $status ]['oldest'],
|
119 |
+
$oldest_and_newest[ $status ]['newest']
|
120 |
+
);
|
121 |
+
}
|
122 |
+
?>
|
123 |
+
</tbody>
|
124 |
+
</table>
|
125 |
+
|
126 |
+
<?php
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* is triggered when invoking inaccessible methods in an object context.
|
131 |
+
*
|
132 |
+
* @param $name string
|
133 |
+
* @param $arguments array
|
134 |
+
*
|
135 |
+
* @return mixed
|
136 |
+
* @link https://php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.methods
|
137 |
+
*/
|
138 |
+
public function __call( $name, $arguments ) {
|
139 |
+
switch ( $name ) {
|
140 |
+
case 'print':
|
141 |
+
_deprecated_function( __CLASS__ . '::print()', '2.2.4', __CLASS__ . '::render()' );
|
142 |
+
return call_user_func_array( array( $this, 'render' ), $arguments );
|
143 |
+
}
|
144 |
+
|
145 |
+
return null;
|
146 |
+
}
|
147 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/action-scheduler/classes/ActionScheduler_wpPostStore.php
ADDED
@@ -0,0 +1,821 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
$schedule = $action->get_schedule();
|
23 |
+
|
24 |
+
if ( ! is_null( $scheduled_date ) && $schedule->is_recurring() ) {
|
25 |
+
$schedule = new ActionScheduler_IntervalSchedule( $scheduled_date, $schedule->interval_in_seconds() );
|
26 |
+
}
|
27 |
+
|
28 |
+
$this->save_post_schedule( $post_id, $schedule );
|
29 |
+
$this->save_action_group( $post_id, $action->get_group() );
|
30 |
+
do_action( 'action_scheduler_stored_action', $post_id );
|
31 |
+
return $post_id;
|
32 |
+
} catch ( Exception $e ) {
|
33 |
+
throw new RuntimeException( sprintf( __('Error saving action: %s', 'action-scheduler'), $e->getMessage() ), 0 );
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
protected function create_post_array( ActionScheduler_Action $action, DateTime $scheduled_date = NULL ) {
|
38 |
+
$post = array(
|
39 |
+
'post_type' => self::POST_TYPE,
|
40 |
+
'post_title' => $action->get_hook(),
|
41 |
+
'post_content' => json_encode($action->get_args()),
|
42 |
+
'post_status' => ( $action->is_finished() ? 'publish' : 'pending' ),
|
43 |
+
'post_date_gmt' => $this->get_scheduled_date_string( $action, $scheduled_date ),
|
44 |
+
'post_date' => $this->get_scheduled_date_string_local( $action, $scheduled_date ),
|
45 |
+
);
|
46 |
+
return $post;
|
47 |
+
}
|
48 |
+
|
49 |
+
protected function save_post_array( $post_array ) {
|
50 |
+
add_filter( 'wp_insert_post_data', array( $this, 'filter_insert_post_data' ), 10, 1 );
|
51 |
+
add_filter( 'pre_wp_unique_post_slug', array( $this, 'set_unique_post_slug' ), 10, 5 );
|
52 |
+
$post_id = wp_insert_post($post_array);
|
53 |
+
remove_filter( 'wp_insert_post_data', array( $this, 'filter_insert_post_data' ), 10 );
|
54 |
+
remove_filter( 'pre_wp_unique_post_slug', array( $this, 'set_unique_post_slug' ), 10 );
|
55 |
+
|
56 |
+
if ( is_wp_error($post_id) || empty($post_id) ) {
|
57 |
+
throw new RuntimeException(__('Unable to save action.', 'action-scheduler'));
|
58 |
+
}
|
59 |
+
return $post_id;
|
60 |
+
}
|
61 |
+
|
62 |
+
public function filter_insert_post_data( $postdata ) {
|
63 |
+
if ( $postdata['post_type'] == self::POST_TYPE ) {
|
64 |
+
$postdata['post_author'] = 0;
|
65 |
+
if ( $postdata['post_status'] == 'future' ) {
|
66 |
+
$postdata['post_status'] = 'publish';
|
67 |
+
}
|
68 |
+
}
|
69 |
+
return $postdata;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Create a (probably unique) post name for scheduled actions in a more performant manner than wp_unique_post_slug().
|
74 |
+
*
|
75 |
+
* When an action's post status is transitioned to something other than 'draft', 'pending' or 'auto-draft, like 'publish'
|
76 |
+
* or 'failed' or 'trash', WordPress will find a unique slug (stored in post_name column) using the wp_unique_post_slug()
|
77 |
+
* function. This is done to ensure URL uniqueness. The approach taken by wp_unique_post_slug() is to iterate over existing
|
78 |
+
* post_name values that match, and append a number 1 greater than the largest. This makes sense when manually creating a
|
79 |
+
* post from the Edit Post screen. It becomes a bottleneck when automatically processing thousands of actions, with a
|
80 |
+
* database containing thousands of related post_name values.
|
81 |
+
*
|
82 |
+
* WordPress 5.1 introduces the 'pre_wp_unique_post_slug' filter for plugins to address this issue.
|
83 |
+
*
|
84 |
+
* We can short-circuit WordPress's wp_unique_post_slug() approach using the 'pre_wp_unique_post_slug' filter. This
|
85 |
+
* method is available to be used as a callback on that filter. It provides a more scalable approach to generating a
|
86 |
+
* post_name/slug that is probably unique. Because Action Scheduler never actually uses the post_name field, or an
|
87 |
+
* action's slug, being probably unique is good enough.
|
88 |
+
*
|
89 |
+
* For more backstory on this issue, see:
|
90 |
+
* - https://github.com/Prospress/action-scheduler/issues/44 and
|
91 |
+
* - https://core.trac.wordpress.org/ticket/21112
|
92 |
+
*
|
93 |
+
* @param string $override_slug Short-circuit return value.
|
94 |
+
* @param string $slug The desired slug (post_name).
|
95 |
+
* @param int $post_ID Post ID.
|
96 |
+
* @param string $post_status The post status.
|
97 |
+
* @param string $post_type Post type.
|
98 |
+
* @return string
|
99 |
+
*/
|
100 |
+
public function set_unique_post_slug( $override_slug, $slug, $post_ID, $post_status, $post_type ) {
|
101 |
+
if ( self::POST_TYPE == $post_type ) {
|
102 |
+
$override_slug = uniqid( self::POST_TYPE . '-', true ) . '-' . wp_generate_password( 32, false );
|
103 |
+
}
|
104 |
+
return $override_slug;
|
105 |
+
}
|
106 |
+
|
107 |
+
protected function save_post_schedule( $post_id, $schedule ) {
|
108 |
+
update_post_meta( $post_id, self::SCHEDULE_META_KEY, $schedule );
|
109 |
+
}
|
110 |
+
|
111 |
+
protected function save_action_group( $post_id, $group ) {
|
112 |
+
if ( empty($group) ) {
|
113 |
+
wp_set_object_terms( $post_id, array(), self::GROUP_TAXONOMY, FALSE );
|
114 |
+
} else {
|
115 |
+
wp_set_object_terms( $post_id, array($group), self::GROUP_TAXONOMY, FALSE );
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
119 |
+
public function fetch_action( $action_id ) {
|
120 |
+
$post = $this->get_post( $action_id );
|
121 |
+
if ( empty($post) || $post->post_type != self::POST_TYPE ) {
|
122 |
+
return $this->get_null_action();
|
123 |
+
}
|
124 |
+
return $this->make_action_from_post($post);
|
125 |
+
}
|
126 |
+
|
127 |
+
protected function get_post( $action_id ) {
|
128 |
+
if ( empty($action_id) ) {
|
129 |
+
return NULL;
|
130 |
+
}
|
131 |
+
return get_post($action_id);
|
132 |
+
}
|
133 |
+
|
134 |
+
protected function get_null_action() {
|
135 |
+
return new ActionScheduler_NullAction();
|
136 |
+
}
|
137 |
+
|
138 |
+
protected function make_action_from_post( $post ) {
|
139 |
+
$hook = $post->post_title;
|
140 |
+
|
141 |
+
try {
|
142 |
+
$args = json_decode( $post->post_content, true );
|
143 |
+
$this->validate_args( $args, $post->ID );
|
144 |
+
|
145 |
+
$schedule = get_post_meta( $post->ID, self::SCHEDULE_META_KEY, true );
|
146 |
+
if ( empty( $schedule ) || ! is_a( $schedule, 'ActionScheduler_Schedule' ) ) {
|
147 |
+
throw ActionScheduler_InvalidActionException::from_decoding_args( $post->ID );
|
148 |
+
}
|
149 |
+
} catch ( ActionScheduler_InvalidActionException $exception ) {
|
150 |
+
$schedule = new ActionScheduler_NullSchedule();
|
151 |
+
$args = array();
|
152 |
+
do_action( 'action_scheduler_failed_fetch_action', $post->ID );
|
153 |
+
}
|
154 |
+
|
155 |
+
$group = wp_get_object_terms( $post->ID, self::GROUP_TAXONOMY, array('fields' => 'names') );
|
156 |
+
$group = empty( $group ) ? '' : reset($group);
|
157 |
+
|
158 |
+
return ActionScheduler::factory()->get_stored_action( $this->get_action_status_by_post_status( $post->post_status ), $hook, $args, $schedule, $group );
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* @param string $post_status
|
163 |
+
*
|
164 |
+
* @throws InvalidArgumentException if $post_status not in known status fields returned by $this->get_status_labels()
|
165 |
+
* @return string
|
166 |
+
*/
|
167 |
+
protected function get_action_status_by_post_status( $post_status ) {
|
168 |
+
|
169 |
+
switch ( $post_status ) {
|
170 |
+
case 'publish' :
|
171 |
+
$action_status = self::STATUS_COMPLETE;
|
172 |
+
break;
|
173 |
+
case 'trash' :
|
174 |
+
$action_status = self::STATUS_CANCELED;
|
175 |
+
break;
|
176 |
+
default :
|
177 |
+
if ( ! array_key_exists( $post_status, $this->get_status_labels() ) ) {
|
178 |
+
throw new InvalidArgumentException( sprintf( 'Invalid post status: "%s". No matching action status available.', $post_status ) );
|
179 |
+
}
|
180 |
+
$action_status = $post_status;
|
181 |
+
break;
|
182 |
+
}
|
183 |
+
|
184 |
+
return $action_status;
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* @param string $action_status
|
189 |
+
* @throws InvalidArgumentException if $post_status not in known status fields returned by $this->get_status_labels()
|
190 |
+
* @return string
|
191 |
+
*/
|
192 |
+
protected function get_post_status_by_action_status( $action_status ) {
|
193 |
+
|
194 |
+
switch ( $action_status ) {
|
195 |
+
case self::STATUS_COMPLETE :
|
196 |
+
$post_status = 'publish';
|
197 |
+
break;
|
198 |
+
case self::STATUS_CANCELED :
|
199 |
+
$post_status = 'trash';
|
200 |
+
break;
|
201 |
+
default :
|
202 |
+
if ( ! array_key_exists( $action_status, $this->get_status_labels() ) ) {
|
203 |
+
throw new InvalidArgumentException( sprintf( 'Invalid action status: "%s".', $action_status ) );
|
204 |
+
}
|
205 |
+
$post_status = $action_status;
|
206 |
+
break;
|
207 |
+
}
|
208 |
+
|
209 |
+
return $post_status;
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* @param string $hook
|
214 |
+
* @param array $params
|
215 |
+
*
|
216 |
+
* @return string ID of the next action matching the criteria or NULL if not found
|
217 |
+
*/
|
218 |
+
public function find_action( $hook, $params = array() ) {
|
219 |
+
$params = wp_parse_args( $params, array(
|
220 |
+
'args' => NULL,
|
221 |
+
'status' => ActionScheduler_Store::STATUS_PENDING,
|
222 |
+
'group' => '',
|
223 |
+
));
|
224 |
+
/** @var wpdb $wpdb */
|
225 |
+
global $wpdb;
|
226 |
+
$query = "SELECT p.ID FROM {$wpdb->posts} p";
|
227 |
+
$args = array();
|
228 |
+
if ( !empty($params['group']) ) {
|
229 |
+
$query .= " INNER JOIN {$wpdb->term_relationships} tr ON tr.object_id=p.ID";
|
230 |
+
$query .= " INNER JOIN {$wpdb->term_taxonomy} tt ON tr.term_taxonomy_id=tt.term_taxonomy_id";
|
231 |
+
$query .= " INNER JOIN {$wpdb->terms} t ON tt.term_id=t.term_id AND t.slug=%s";
|
232 |
+
$args[] = $params['group'];
|
233 |
+
}
|
234 |
+
$query .= " WHERE p.post_title=%s";
|
235 |
+
$args[] = $hook;
|
236 |
+
$query .= " AND p.post_type=%s";
|
237 |
+
$args[] = self::POST_TYPE;
|
238 |
+
if ( !is_null($params['args']) ) {
|
239 |
+
$query .= " AND p.post_content=%s";
|
240 |
+
$args[] = json_encode($params['args']);
|
241 |
+
}
|
242 |
+
|
243 |
+
if ( ! empty( $params['status'] ) ) {
|
244 |
+
$query .= " AND p.post_status=%s";
|
245 |
+
$args[] = $this->get_post_status_by_action_status( $params['status'] );
|
246 |
+
}
|
247 |
+
|
248 |
+
switch ( $params['status'] ) {
|
249 |
+
case self::STATUS_COMPLETE:
|
250 |
+
case self::STATUS_RUNNING:
|
251 |
+
case self::STATUS_FAILED:
|
252 |
+
$order = 'DESC'; // Find the most recent action that matches
|
253 |
+
break;
|
254 |
+
case self::STATUS_PENDING:
|
255 |
+
default:
|
256 |
+
$order = 'ASC'; // Find the next action that matches
|
257 |
+
break;
|
258 |
+
}
|
259 |
+
$query .= " ORDER BY post_date_gmt $order LIMIT 1";
|
260 |
+
|
261 |
+
$query = $wpdb->prepare( $query, $args );
|
262 |
+
|
263 |
+
$id = $wpdb->get_var($query);
|
264 |
+
return $id;
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Returns the SQL statement to query (or count) actions.
|
269 |
+
*
|
270 |
+
* @param array $query Filtering options
|
271 |
+
* @param string $select_or_count Whether the SQL should select and return the IDs or just the row count
|
272 |
+
* @throws InvalidArgumentException if $select_or_count not count or select
|
273 |
+
* @return string SQL statement. The returned SQL is already properly escaped.
|
274 |
+
*/
|
275 |
+
protected function get_query_actions_sql( array $query, $select_or_count = 'select' ) {
|
276 |
+
|
277 |
+
if ( ! in_array( $select_or_count, array( 'select', 'count' ) ) ) {
|
278 |
+
throw new InvalidArgumentException(__('Invalid schedule. Cannot save action.', 'action-scheduler'));
|
279 |
+
}
|
280 |
+
|
281 |
+
$query = wp_parse_args( $query, array(
|
282 |
+
'hook' => '',
|
283 |
+
'args' => NULL,
|
284 |
+
'date' => NULL,
|
285 |
+
'date_compare' => '<=',
|
286 |
+
'modified' => NULL,
|
287 |
+
'modified_compare' => '<=',
|
288 |
+
'group' => '',
|
289 |
+
'status' => '',
|
290 |
+
'claimed' => NULL,
|
291 |
+
'per_page' => 5,
|
292 |
+
'offset' => 0,
|
293 |
+
'orderby' => 'date',
|
294 |
+
'order' => 'ASC',
|
295 |
+
'search' => '',
|
296 |
+
) );
|
297 |
+
|
298 |
+
/** @var wpdb $wpdb */
|
299 |
+
global $wpdb;
|
300 |
+
$sql = ( 'count' === $select_or_count ) ? 'SELECT count(p.ID)' : 'SELECT p.ID ';
|
301 |
+
$sql .= "FROM {$wpdb->posts} p";
|
302 |
+
$sql_params = array();
|
303 |
+
if ( ! empty( $query['group'] ) || 'group' === $query['orderby'] ) {
|
304 |
+
$sql .= " INNER JOIN {$wpdb->term_relationships} tr ON tr.object_id=p.ID";
|
305 |
+
$sql .= " INNER JOIN {$wpdb->term_taxonomy} tt ON tr.term_taxonomy_id=tt.term_taxonomy_id";
|
306 |
+
$sql .= " INNER JOIN {$wpdb->terms} t ON tt.term_id=t.term_id";
|
307 |
+
|
308 |
+
if ( ! empty( $query['group'] ) ) {
|
309 |
+
$sql .= " AND t.slug=%s";
|
310 |
+
$sql_params[] = $query['group'];
|
311 |
+
}
|
312 |
+
}
|
313 |
+
$sql .= " WHERE post_type=%s";
|
314 |
+
$sql_params[] = self::POST_TYPE;
|
315 |
+
if ( $query['hook'] ) {
|
316 |
+
$sql .= " AND p.post_title=%s";
|
317 |
+
$sql_params[] = $query['hook'];
|
318 |
+
}
|
319 |
+
if ( !is_null($query['args']) ) {
|
320 |
+
$sql .= " AND p.post_content=%s";
|
321 |
+
$sql_params[] = json_encode($query['args']);
|
322 |
+
}
|
323 |
+
|
324 |
+
if ( ! empty( $query['status'] ) ) {
|
325 |
+
$sql .= " AND p.post_status=%s";
|
326 |
+
$sql_params[] = $this->get_post_status_by_action_status( $query['status'] );
|
327 |
+
}
|
328 |
+
|
329 |
+
if ( $query['date'] instanceof DateTime ) {
|
330 |
+
$date = clone $query['date'];
|
331 |
+
$date->setTimezone( new DateTimeZone('UTC') );
|
332 |
+
$date_string = $date->format('Y-m-d H:i:s');
|
333 |
+
$comparator = $this->validate_sql_comparator($query['date_compare']);
|
334 |
+
$sql .= " AND p.post_date_gmt $comparator %s";
|
335 |
+
$sql_params[] = $date_string;
|
336 |
+
}
|
337 |
+
|
338 |
+
if ( $query['modified'] instanceof DateTime ) {
|
339 |
+
$modified = clone $query['modified'];
|
340 |
+
$modified->setTimezone( new DateTimeZone('UTC') );
|
341 |
+
$date_string = $modified->format('Y-m-d H:i:s');
|
342 |
+
$comparator = $this->validate_sql_comparator($query['modified_compare']);
|
343 |
+
$sql .= " AND p.post_modified_gmt $comparator %s";
|
344 |
+
$sql_params[] = $date_string;
|
345 |
+
}
|
346 |
+
|
347 |
+
if ( $query['claimed'] === TRUE ) {
|
348 |
+
$sql .= " AND p.post_password != ''";
|
349 |
+
} elseif ( $query['claimed'] === FALSE ) {
|
350 |
+
$sql .= " AND p.post_password = ''";
|
351 |
+
} elseif ( !is_null($query['claimed']) ) {
|
352 |
+
$sql .= " AND p.post_password = %s";
|
353 |
+
$sql_params[] = $query['claimed'];
|
354 |
+
}
|
355 |
+
|
356 |
+
if ( ! empty( $query['search'] ) ) {
|
357 |
+
$sql .= " AND (p.post_title LIKE %s OR p.post_content LIKE %s OR p.post_password LIKE %s)";
|
358 |
+
for( $i = 0; $i < 3; $i++ ) {
|
359 |
+
$sql_params[] = sprintf( '%%%s%%', $query['search'] );
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
if ( 'select' === $select_or_count ) {
|
364 |
+
switch ( $query['orderby'] ) {
|
365 |
+
case 'hook':
|
366 |
+
$orderby = 'p.post_title';
|
367 |
+
break;
|
368 |
+
case 'group':
|
369 |
+
$orderby = 't.name';
|
370 |
+
break;
|
371 |
+
case 'status':
|
372 |
+
$orderby = 'p.post_status';
|
373 |
+
break;
|
374 |
+
case 'modified':
|
375 |
+
$orderby = 'p.post_modified';
|
376 |
+
break;
|
377 |
+
case 'claim_id':
|
378 |
+
$orderby = 'p.post_password';
|
379 |
+
break;
|
380 |
+
case 'schedule':
|
381 |
+
case 'date':
|
382 |
+
default:
|
383 |
+
$orderby = 'p.post_date_gmt';
|
384 |
+
break;
|
385 |
+
}
|
386 |
+
if ( 'ASC' === strtoupper( $query['order'] ) ) {
|
387 |
+
$order = 'ASC';
|
388 |
+
} else {
|
389 |
+
$order = 'DESC';
|
390 |
+
}
|
391 |
+
$sql .= " ORDER BY $orderby $order";
|
392 |
+
if ( $query['per_page'] > 0 ) {
|
393 |
+
$sql .= " LIMIT %d, %d";
|
394 |
+
$sql_params[] = $query['offset'];
|
395 |
+
$sql_params[] = $query['per_page'];
|
396 |
+
}
|
397 |
+
}
|
398 |
+
|
399 |
+
return $wpdb->prepare( $sql, $sql_params );
|
400 |
+
}
|
401 |
+
|
402 |
+
/**
|
403 |
+
* @param array $query
|
404 |
+
* @param string $query_type Whether to select or count the results. Default, select.
|
405 |
+
* @return string|array The IDs of actions matching the query
|
406 |
+
*/
|
407 |
+
public function query_actions( $query = array(), $query_type = 'select' ) {
|
408 |
+
/** @var wpdb $wpdb */
|
409 |
+
global $wpdb;
|
410 |
+
|
411 |
+
$sql = $this->get_query_actions_sql( $query, $query_type );
|
412 |
+
|
413 |
+
return ( 'count' === $query_type ) ? $wpdb->get_var( $sql ) : $wpdb->get_col( $sql );
|
414 |
+
}
|
415 |
+
|
416 |
+
/**
|
417 |
+
* Get a count of all actions in the store, grouped by status
|
418 |
+
*
|
419 |
+
* @return array
|
420 |
+
*/
|
421 |
+
public function action_counts() {
|
422 |
+
|
423 |
+
$action_counts_by_status = array();
|
424 |
+
$action_stati_and_labels = $this->get_status_labels();
|
425 |
+
$posts_count_by_status = (array) wp_count_posts( self::POST_TYPE, 'readable' );
|
426 |
+
|
427 |
+
foreach ( $posts_count_by_status as $post_status_name => $count ) {
|
428 |
+
|
429 |
+
try {
|
430 |
+
$action_status_name = $this->get_action_status_by_post_status( $post_status_name );
|
431 |
+
} catch ( Exception $e ) {
|
432 |
+
// Ignore any post statuses that aren't for actions
|
433 |
+
continue;
|
434 |
+
}
|
435 |
+
if ( array_key_exists( $action_status_name, $action_stati_and_labels ) ) {
|
436 |
+
$action_counts_by_status[ $action_status_name ] = $count;
|
437 |
+
}
|
438 |
+
}
|
439 |
+
|
440 |
+
return $action_counts_by_status;
|
441 |
+
}
|
442 |
+
|
443 |
+
/**
|
444 |
+
* @param string $action_id
|
445 |
+
*
|
446 |
+
* @throws InvalidArgumentException
|
447 |
+
*/
|
448 |
+
public function cancel_action( $action_id ) {
|
449 |
+
$post = get_post($action_id);
|
450 |
+
if ( empty($post) || ($post->post_type != self::POST_TYPE) ) {
|
451 |
+
throw new InvalidArgumentException(sprintf(__('Unidentified action %s', 'action-scheduler'), $action_id));
|
452 |
+
}
|
453 |
+
do_action( 'action_scheduler_canceled_action', $action_id );
|
454 |
+
add_filter( 'pre_wp_unique_post_slug', array( $this, 'set_unique_post_slug' ), 10, 5 );
|
455 |
+
wp_trash_post($action_id);
|
456 |
+
remove_filter( 'pre_wp_unique_post_slug', array( $this, 'set_unique_post_slug' ), 10 );
|
457 |
+
}
|
458 |
+
|
459 |
+
public function delete_action( $action_id ) {
|
460 |
+
$post = get_post($action_id);
|
461 |
+
if ( empty($post) || ($post->post_type != self::POST_TYPE) ) {
|
462 |
+
throw new InvalidArgumentException(sprintf(__('Unidentified action %s', 'action-scheduler'), $action_id));
|
463 |
+
}
|
464 |
+
do_action( 'action_scheduler_deleted_action', $action_id );
|
465 |
+
wp_delete_post($action_id, TRUE);
|
466 |
+
}
|
467 |
+
|
468 |
+
/**
|
469 |
+
* @param string $action_id
|
470 |
+
*
|
471 |
+
* @throws InvalidArgumentException
|
472 |
+
* @return ActionScheduler_DateTime The date the action is schedule to run, or the date that it ran.
|
473 |
+
*/
|
474 |
+
public function get_date( $action_id ) {
|
475 |
+
$next = $this->get_date_gmt( $action_id );
|
476 |
+
return ActionScheduler_TimezoneHelper::set_local_timezone( $next );
|
477 |
+
}
|
478 |
+
|
479 |
+
/**
|
480 |
+
* @param string $action_id
|
481 |
+
*
|
482 |
+
* @throws InvalidArgumentException
|
483 |
+
* @return ActionScheduler_DateTime The date the action is schedule to run, or the date that it ran.
|
484 |
+
*/
|
485 |
+
public function get_date_gmt( $action_id ) {
|
486 |
+
$post = get_post($action_id);
|
487 |
+
if ( empty($post) || ($post->post_type != self::POST_TYPE) ) {
|
488 |
+
throw new InvalidArgumentException(sprintf(__('Unidentified action %s', 'action-scheduler'), $action_id));
|
489 |
+
}
|
490 |
+
if ( $post->post_status == 'publish' ) {
|
491 |
+
return as_get_datetime_object($post->post_modified_gmt);
|
492 |
+
} else {
|
493 |
+
return as_get_datetime_object($post->post_date_gmt);
|
494 |
+
}
|
495 |
+
}
|
496 |
+
|
497 |
+
/**
|
498 |
+
* @param int $max_actions
|
499 |
+
* @param DateTime $before_date Jobs must be schedule before this date. Defaults to now.
|
500 |
+
* @param array $hooks Claim only actions with a hook or hooks.
|
501 |
+
* @param string $group Claim only actions in the given group.
|
502 |
+
*
|
503 |
+
* @return ActionScheduler_ActionClaim
|
504 |
+
* @throws RuntimeException When there is an error staking a claim.
|
505 |
+
* @throws InvalidArgumentException When the given group is not valid.
|
506 |
+
*/
|
507 |
+
public function stake_claim( $max_actions = 10, DateTime $before_date = null, $hooks = array(), $group = '' ) {
|
508 |
+
$claim_id = $this->generate_claim_id();
|
509 |
+
$this->claim_actions( $claim_id, $max_actions, $before_date, $hooks, $group );
|
510 |
+
$action_ids = $this->find_actions_by_claim_id( $claim_id );
|
511 |
+
|
512 |
+
return new ActionScheduler_ActionClaim( $claim_id, $action_ids );
|
513 |
+
}
|
514 |
+
|
515 |
+
/**
|
516 |
+
* @return int
|
517 |
+
*/
|
518 |
+
public function get_claim_count(){
|
519 |
+
global $wpdb;
|
520 |
+
|
521 |
+
$sql = "SELECT COUNT(DISTINCT post_password) FROM {$wpdb->posts} WHERE post_password != '' AND post_type = %s AND post_status IN ('in-progress','pending')";
|
522 |
+
$sql = $wpdb->prepare( $sql, array( self::POST_TYPE ) );
|
523 |
+
|
524 |
+
return $wpdb->get_var( $sql );
|
525 |
+
}
|
526 |
+
|
527 |
+
protected function generate_claim_id() {
|
528 |
+
$claim_id = md5(microtime(true) . rand(0,1000));
|
529 |
+
return substr($claim_id, 0, 20); // to fit in db field with 20 char limit
|
530 |
+
}
|
531 |
+
|
532 |
+
/**
|
533 |
+
* @param string $claim_id
|
534 |
+
* @param int $limit
|
535 |
+
* @param DateTime $before_date Should use UTC timezone.
|
536 |
+
* @param array $hooks Claim only actions with a hook or hooks.
|
537 |
+
* @param string $group Claim only actions in the given group.
|
538 |
+
*
|
539 |
+
* @return int The number of actions that were claimed
|
540 |
+
* @throws RuntimeException When there is a database error.
|
541 |
+
* @throws InvalidArgumentException When the group is invalid.
|
542 |
+
*/
|
543 |
+
protected function claim_actions( $claim_id, $limit, DateTime $before_date = null, $hooks = array(), $group = '' ) {
|
544 |
+
// Set up initial variables.
|
545 |
+
$date = null === $before_date ? as_get_datetime_object() : clone $before_date;
|
546 |
+
$limit_ids = ! empty( $group );
|
547 |
+
$ids = $limit_ids ? $this->get_actions_by_group( $group, $limit, $date ) : array();
|
548 |
+
|
549 |
+
// If limiting by IDs and no posts found, then return early since we have nothing to update.
|
550 |
+
if ( $limit_ids && 0 === count( $ids ) ) {
|
551 |
+
return 0;
|
552 |
+
}
|
553 |
+
|
554 |
+
/** @var wpdb $wpdb */
|
555 |
+
global $wpdb;
|
556 |
+
|
557 |
+
/*
|
558 |
+
* Build up custom query to update the affected posts. Parameters are built as a separate array
|
559 |
+
* to make it easier to identify where they are in the query.
|
560 |
+
*
|
561 |
+
* We can't use $wpdb->update() here because of the "ID IN ..." clause.
|
562 |
+
*/
|
563 |
+
$update = "UPDATE {$wpdb->posts} SET post_password = %s, post_modified_gmt = %s, post_modified = %s";
|
564 |
+
$params = array(
|
565 |
+
$claim_id,
|
566 |
+
current_time( 'mysql', true ),
|
567 |
+
current_time( 'mysql' ),
|
568 |
+
);
|
569 |
+
|
570 |
+
// Build initial WHERE clause.
|
571 |
+
$where = "WHERE post_type = %s AND post_status = %s AND post_password = ''";
|
572 |
+
$params[] = self::POST_TYPE;
|
573 |
+
$params[] = ActionScheduler_Store::STATUS_PENDING;
|
574 |
+
|
575 |
+
if ( ! empty( $hooks ) ) {
|
576 |
+
$placeholders = array_fill( 0, count( $hooks ), '%s' );
|
577 |
+
$where .= ' AND post_title IN (' . join( ', ', $placeholders ) . ')';
|
578 |
+
$params = array_merge( $params, array_values( $hooks ) );
|
579 |
+
}
|
580 |
+
|
581 |
+
/*
|
582 |
+
* Add the IDs to the WHERE clause. IDs not escaped because they came directly from a prior DB query.
|
583 |
+
*
|
584 |
+
* If we're not limiting by IDs, then include the post_date_gmt clause.
|
585 |
+
*/
|
586 |
+
if ( $limit_ids ) {
|
587 |
+
$where .= ' AND ID IN (' . join( ',', $ids ) . ')';
|
588 |
+
} else {
|
589 |
+
$where .= ' AND post_date_gmt <= %s';
|
590 |
+
$params[] = $date->format( 'Y-m-d H:i:s' );
|
591 |
+
}
|
592 |
+
|
593 |
+
// Add the ORDER BY clause and,ms limit.
|
594 |
+
$order = 'ORDER BY menu_order ASC, post_date_gmt ASC, ID ASC LIMIT %d';
|
595 |
+
$params[] = $limit;
|
596 |
+
|
597 |
+
// Run the query and gather results.
|
598 |
+
$rows_affected = $wpdb->query( $wpdb->prepare( "{$update} {$where} {$order}", $params ) );
|
599 |
+
if ( $rows_affected === false ) {
|
600 |
+
throw new RuntimeException( __( 'Unable to claim actions. Database error.', 'action-scheduler' ) );
|
601 |
+
}
|
602 |
+
|
603 |
+
return (int) $rows_affected;
|
604 |
+
}
|
605 |
+
|
606 |
+
/**
|
607 |
+
* Get IDs of actions within a certain group and up to a certain date/time.
|
608 |
+
*
|
609 |
+
* @param string $group The group to use in finding actions.
|
610 |
+
* @param int $limit The number of actions to retrieve.
|
611 |
+
* @param DateTime $date DateTime object representing cutoff time for actions. Actions retrieved will be
|
612 |
+
* up to and including this DateTime.
|
613 |
+
*
|
614 |
+
* @return array IDs of actions in the appropriate group and before the appropriate time.
|
615 |
+
* @throws InvalidArgumentException When the group does not exist.
|
616 |
+
*/
|
617 |
+
protected function get_actions_by_group( $group, $limit, DateTime $date ) {
|
618 |
+
// Ensure the group exists before continuing.
|
619 |
+
if ( ! term_exists( $group, self::GROUP_TAXONOMY )) {
|
620 |
+
throw new InvalidArgumentException( sprintf( __( 'The group "%s" does not exist.', 'action-scheduler' ), $group ) );
|
621 |
+
}
|
622 |
+
|
623 |
+
// Set up a query for post IDs to use later.
|
624 |
+
$query = new WP_Query();
|
625 |
+
$query_args = array(
|
626 |
+
'fields' => 'ids',
|
627 |
+
'post_type' => self::POST_TYPE,
|
628 |
+
'post_status' => ActionScheduler_Store::STATUS_PENDING,
|
629 |
+
'has_password' => false,
|
630 |
+
'posts_per_page' => $limit * 3,
|
631 |
+
'suppress_filters' => true,
|
632 |
+
'no_found_rows' => true,
|
633 |
+
'orderby' => array(
|
634 |
+
'menu_order' => 'ASC',
|
635 |
+
'date' => 'ASC',
|
636 |
+
'ID' => 'ASC',
|
637 |
+
),
|
638 |
+
'date_query' => array(
|
639 |
+
'column' => 'post_date_gmt',
|
640 |
+
'before' => $date->format( 'Y-m-d H:i' ),
|
641 |
+
'inclusive' => true,
|
642 |
+
),
|
643 |
+
'tax_query' => array(
|
644 |
+
array(
|
645 |
+
'taxonomy' => self::GROUP_TAXONOMY,
|
646 |
+
'field' => 'slug',
|
647 |
+
'terms' => $group,
|
648 |
+
'include_children' => false,
|
649 |
+
),
|
650 |
+
),
|
651 |
+
);
|
652 |
+
|
653 |
+
return $query->query( $query_args );
|
654 |
+
}
|
655 |
+
|
656 |
+
/**
|
657 |
+
* @param string $claim_id
|
658 |
+
* @return array
|
659 |
+
*/
|
660 |
+
public function find_actions_by_claim_id( $claim_id ) {
|
661 |
+
/** @var wpdb $wpdb */
|
662 |
+
global $wpdb;
|
663 |
+
$sql = "SELECT ID FROM {$wpdb->posts} WHERE post_type = %s AND post_password = %s";
|
664 |
+
$sql = $wpdb->prepare( $sql, array( self::POST_TYPE, $claim_id ) );
|
665 |
+
$action_ids = $wpdb->get_col( $sql );
|
666 |
+
return $action_ids;
|
667 |
+
}
|
668 |
+
|
669 |
+
public function release_claim( ActionScheduler_ActionClaim $claim ) {
|
670 |
+
$action_ids = $this->find_actions_by_claim_id( $claim->get_id() );
|
671 |
+
if ( empty($action_ids) ) {
|
672 |
+
return; // nothing to do
|
673 |
+
}
|
674 |
+
$action_id_string = implode(',', array_map('intval', $action_ids));
|
675 |
+
/** @var wpdb $wpdb */
|
676 |
+
global $wpdb;
|
677 |
+
$sql = "UPDATE {$wpdb->posts} SET post_password = '' WHERE ID IN ($action_id_string) AND post_password = %s";
|
678 |
+
$sql = $wpdb->prepare( $sql, array( $claim->get_id() ) );
|
679 |
+
$result = $wpdb->query($sql);
|
680 |
+
if ( $result === false ) {
|
681 |
+
throw new RuntimeException( sprintf( __('Unable to unlock claim %s. Database error.', 'action-scheduler'), $claim->get_id() ) );
|
682 |
+
}
|
683 |
+
}
|
684 |
+
|
685 |
+
/**
|
686 |
+
* @param string $action_id
|
687 |
+
*/
|
688 |
+
public function unclaim_action( $action_id ) {
|
689 |
+
/** @var wpdb $wpdb */
|
690 |
+
global $wpdb;
|
691 |
+
$sql = "UPDATE {$wpdb->posts} SET post_password = '' WHERE ID = %d AND post_type = %s";
|
692 |
+
$sql = $wpdb->prepare( $sql, $action_id, self::POST_TYPE );
|
693 |
+
$result = $wpdb->query($sql);
|
694 |
+
if ( $result === false ) {
|
695 |
+
throw new RuntimeException( sprintf( __('Unable to unlock claim on action %s. Database error.', 'action-scheduler'), $action_id ) );
|
696 |
+
}
|
697 |
+
}
|
698 |
+
|
699 |
+
public function mark_failure( $action_id ) {
|
700 |
+
/** @var wpdb $wpdb */
|
701 |
+
global $wpdb;
|
702 |
+
$sql = "UPDATE {$wpdb->posts} SET post_status = %s WHERE ID = %d AND post_type = %s";
|
703 |
+
$sql = $wpdb->prepare( $sql, self::STATUS_FAILED, $action_id, self::POST_TYPE );
|
704 |
+
$result = $wpdb->query($sql);
|
705 |
+
if ( $result === false ) {
|
706 |
+
throw new RuntimeException( sprintf( __('Unable to mark failure on action %s. Database error.', 'action-scheduler'), $action_id ) );
|
707 |
+
}
|
708 |
+
}
|
709 |
+
|
710 |
+
/**
|
711 |
+
* Return an action's claim ID, as stored in the post password column
|
712 |
+
*
|
713 |
+
* @param string $action_id
|
714 |
+
* @return mixed
|
715 |
+
*/
|
716 |
+
public function get_claim_id( $action_id ) {
|
717 |
+
return $this->get_post_column( $action_id, 'post_password' );
|
718 |
+
}
|
719 |
+
|
720 |
+
/**
|
721 |
+
* Return an action's status, as stored in the post status column
|
722 |
+
*
|
723 |
+
* @param string $action_id
|
724 |
+
* @return mixed
|
725 |
+
*/
|
726 |
+
public function get_status( $action_id ) {
|
727 |
+
$status = $this->get_post_column( $action_id, 'post_status' );
|
728 |
+
|
729 |
+
if ( $status === null ) {
|
730 |
+
throw new InvalidArgumentException( __( 'Invalid action ID. No status found.', 'action-scheduler' ) );
|
731 |
+
}
|
732 |
+
|
733 |
+
return $this->get_action_status_by_post_status( $status );
|
734 |
+
}
|
735 |
+
|
736 |
+
private function get_post_column( $action_id, $column_name ) {
|
737 |
+
/** @var \wpdb $wpdb */
|
738 |
+
global $wpdb;
|
739 |
+
return $wpdb->get_var( $wpdb->prepare( "SELECT {$column_name} FROM {$wpdb->posts} WHERE ID=%d AND post_type=%s", $action_id, self::POST_TYPE ) );
|
740 |
+
}
|
741 |
+
|
742 |
+
/**
|
743 |
+
* @param string $action_id
|
744 |
+
*/
|
745 |
+
public function log_execution( $action_id ) {
|
746 |
+
/** @var wpdb $wpdb */
|
747 |
+
global $wpdb;
|
748 |
+
|
749 |
+
$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";
|
750 |
+
$sql = $wpdb->prepare( $sql, self::STATUS_RUNNING, current_time('mysql', true), current_time('mysql'), $action_id, self::POST_TYPE );
|
751 |
+
$wpdb->query($sql);
|
752 |
+
}
|
753 |
+
|
754 |
+
|
755 |
+
public function mark_complete( $action_id ) {
|
756 |
+
$post = get_post($action_id);
|
757 |
+
if ( empty($post) || ($post->post_type != self::POST_TYPE) ) {
|
758 |
+
throw new InvalidArgumentException(sprintf(__('Unidentified action %s', 'action-scheduler'), $action_id));
|
759 |
+
}
|
760 |
+
add_filter( 'wp_insert_post_data', array( $this, 'filter_insert_post_data' ), 10, 1 );
|
761 |
+
add_filter( 'pre_wp_unique_post_slug', array( $this, 'set_unique_post_slug' ), 10, 5 );
|
762 |
+
$result = wp_update_post(array(
|
763 |
+
'ID' => $action_id,
|
764 |
+
'post_status' => 'publish',
|
765 |
+
), TRUE);
|
766 |
+
remove_filter( 'wp_insert_post_data', array( $this, 'filter_insert_post_data' ), 10 );
|
767 |
+
remove_filter( 'pre_wp_unique_post_slug', array( $this, 'set_unique_post_slug' ), 10 );
|
768 |
+
if ( is_wp_error($result) ) {
|
769 |
+
throw new RuntimeException($result->get_error_message());
|
770 |
+
}
|
771 |
+
}
|
772 |
+
|
773 |
+
/**
|
774 |
+
* InnoDB indexes have a maximum size of 767 bytes by default, which is only 191 characters with utf8mb4.
|
775 |
+
*
|
776 |
+
* Previously, AS wasn't concerned about args length, as we used the (unindex) post_content column. However,
|
777 |
+
* as we prepare to move to custom tables, and can use an indexed VARCHAR column instead, we want to warn
|
778 |
+
* developers of this impending requirement.
|
779 |
+
*
|
780 |
+
* @param ActionScheduler_Action $action
|
781 |
+
*/
|
782 |
+
protected function validate_action( ActionScheduler_Action $action ) {
|
783 |
+
if ( strlen( json_encode( $action->get_args() ) ) > self::$max_index_length ) {
|
784 |
+
_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' );
|
785 |
+
}
|
786 |
+
}
|
787 |
+
|
788 |
+
/**
|
789 |
+
* @codeCoverageIgnore
|
790 |
+
*/
|
791 |
+
public function init() {
|
792 |
+
$post_type_registrar = new ActionScheduler_wpPostStore_PostTypeRegistrar();
|
793 |
+
$post_type_registrar->register();
|
794 |
+
|
795 |
+
$post_status_registrar = new ActionScheduler_wpPostStore_PostStatusRegistrar();
|
796 |
+
$post_status_registrar->register();
|
797 |
+
|
798 |
+
$taxonomy_registrar = new ActionScheduler_wpPostStore_TaxonomyRegistrar();
|
799 |
+
$taxonomy_registrar->register();
|
800 |
+
}
|
801 |
+
|
802 |
+
/**
|
803 |
+
* Validate that we could decode action arguments.
|
804 |
+
*
|
805 |
+
* @param mixed $args The decoded arguments.
|
806 |
+
* @param int $action_id The action ID.
|
807 |
+
*
|
808 |
+
* @throws ActionScheduler_InvalidActionException When the decoded arguments are invalid.
|
809 |
+
*/
|
810 |
+
private function validate_args( $args, $action_id ) {
|
811 |
+
// Ensure we have an array of args.
|
812 |
+
if ( ! is_array( $args ) ) {
|
813 |
+
throw ActionScheduler_InvalidActionException::from_decoding_args( $action_id );
|
814 |
+
}
|
815 |
+
|
816 |
+
// Validate JSON decoding if possible.
|
817 |
+
if ( function_exists( 'json_last_error' ) && JSON_ERROR_NONE !== json_last_error() ) {
|
818 |
+
throw ActionScheduler_InvalidActionException::from_decoding_args( $action_id );
|
819 |
+
}
|
820 |
+
}
|
821 |
+
}
|
includes/vendor/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 |
+
|
includes/vendor/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 |
+
|
includes/vendor/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 |
+
|
includes/vendor/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
|
includes/vendor/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.5.1"
|
10 |
+
}
|
11 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/action-scheduler/docs/CNAME
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
actionscheduler.org
|
includes/vendor/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
|
includes/vendor/action-scheduler/docs/_layouts/default.html
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
<a class="github-corner" href="https://github.com/Prospress/action-scheduler/" aria-label="View on GitHub">
|
25 |
+
<svg width="80" height="80" viewBox="0 0 250 250" style="fill:#b5e853; color:#151513; position: fixed; top: 0; border: 0; right: 0;" aria-hidden="true">
|
26 |
+
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path>
|
27 |
+
</svg>
|
28 |
+
</a>
|
29 |
+
<div class="container">
|
30 |
+
<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>
|
31 |
+
<h1><a href="/">action-scheduler</a></h1>
|
32 |
+
<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>
|
33 |
+
</div>
|
34 |
+
</header>
|
35 |
+
|
36 |
+
<div class="container">
|
37 |
+
<section id="main_content">
|
38 |
+
{{ content }}
|
39 |
+
</section>
|
40 |
+
</div>
|
41 |
+
|
42 |
+
<footer>
|
43 |
+
<div class="container">
|
44 |
+
<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>
|
45 |
+
<p class="footer-image">
|
46 |
+
<a href="https://prospress.com"><img src="http://pic.pros.pr/eb8dcec9bd54/prospress-hacker-green-logo.png" width="120"></a>
|
47 |
+
</p>
|
48 |
+
</div>
|
49 |
+
</footer>
|
50 |
+
|
51 |
+
{% if site.google_analytics %}
|
52 |
+
<script>
|
53 |
+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
54 |
+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
55 |
+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
56 |
+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
57 |
+
ga('create', '{{ site.google_analytics }}', 'auto');
|
58 |
+
ga('send', 'pageview');
|
59 |
+
</script>
|
60 |
+
{% endif %}
|
61 |
+
</body>
|
62 |
+
</html>
|
includes/vendor/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)
|
includes/vendor/action-scheduler/docs/android-chrome-192x192.png
ADDED
Binary file
|
includes/vendor/action-scheduler/docs/android-chrome-256x256.png
ADDED
Binary file
|
includes/vendor/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`.
|
includes/vendor/action-scheduler/docs/apple-touch-icon.png
ADDED
Binary file
|
includes/vendor/action-scheduler/docs/assets/css/style.scss
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
}
|
33 |
+
|
34 |
+
.github-corner:hover .octo-arm {
|
35 |
+
animation:octocat-wave 560ms ease-in-out
|
36 |
+
}
|
37 |
+
|
38 |
+
@keyframes octocat-wave{
|
39 |
+
0%,100%{
|
40 |
+
transform:rotate(0)
|
41 |
+
}
|
42 |
+
20%,60%{
|
43 |
+
transform:rotate(-25deg)
|
44 |
+
}
|
45 |
+
40%,80%{
|
46 |
+
transform:rotate(10deg)
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
@media (max-width:500px){
|
51 |
+
.github-corner:hover .octo-arm {
|
52 |
+
animation:none
|
53 |
+
}
|
54 |
+
.github-corner .octo-arm{
|
55 |
+
animation:octocat-wave 560ms ease-in-out
|
56 |
+
}
|
57 |
+
}
|
includes/vendor/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>
|
includes/vendor/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.
|
includes/vendor/action-scheduler/docs/favicon-16x16.png
ADDED
Binary file
|
includes/vendor/action-scheduler/docs/favicon-32x32.png
ADDED
Binary file
|
includes/vendor/action-scheduler/docs/favicon.ico
ADDED
Binary file
|
includes/vendor/action-scheduler/docs/google14ef723abb376cd3.html
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
google-site-verification: google14ef723abb376cd3.html
|
includes/vendor/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.
|
includes/vendor/action-scheduler/docs/mstile-150x150.png
ADDED
Binary file
|
includes/vendor/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.
|
includes/vendor/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>
|
includes/vendor/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 |
+
}
|
includes/vendor/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_schedule_midnight_log() {
|
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_schedule_midnight_log' );
|
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`.
|
includes/vendor/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.
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/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.
|
includes/vendor/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`
|
includes/vendor/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. <https://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 <https://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 |
+
<https://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 |
+
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/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>
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
|
includes/vendor/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 |
+
|
includes/vendor/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 |
+
* @dataProvider provide_bad_args
|
46 |
+
*
|
47 |
+
* @param string $content
|
48 |
+
*/
|
49 |
+
public function test_action_bad_args( $content ) {
|
50 |
+
$store = new ActionScheduler_wpPostStore();
|
51 |
+
$post_id = wp_insert_post( array(
|
52 |
+
'post_type' => ActionScheduler_wpPostStore::POST_TYPE,
|
53 |
+
'post_status' => ActionScheduler_Store::STATUS_PENDING,
|
54 |
+
'post_content' => $content,
|
55 |
+
) );
|
56 |
+
|
57 |
+
$fetched = $store->fetch_action( $post_id );
|
58 |
+
$this->assertInstanceOf( 'ActionScheduler_NullSchedule', $fetched->get_schedule() );
|
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 |
+
}
|
includes/vendor/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 |
+
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
|
includes/vendor/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 |
+
|
includes/vendor/action-scheduler/tests/phpunit/runner/ActionScheduler_QueueRunner_Test.php
ADDED
@@ -0,0 +1,262 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
210 |
+
public function test_store_fetch_action_failure_schedule_next_instance() {
|
211 |
+
$random = md5( rand() );
|
212 |
+
$schedule = new ActionScheduler_IntervalSchedule( as_get_datetime_object( '12 hours ago' ), DAY_IN_SECONDS );
|
213 |
+
$action = new ActionScheduler_Action( $random, array(), $schedule );
|
214 |
+
$action_id = ActionScheduler::store()->save_action( $action );
|
215 |
+
|
216 |
+
// Set up a mock store that will throw an exception when fetching actions.
|
217 |
+
$store = $this
|
218 |
+
->getMockBuilder( 'ActionScheduler_wpPostStore' )
|
219 |
+
->setMethods( array( 'fetch_action' ) )
|
220 |
+
->getMock();
|
221 |
+
$store
|
222 |
+
->method( 'fetch_action' )
|
223 |
+
->with( $action_id )
|
224 |
+
->will( $this->throwException( new Exception() ) );
|
225 |
+
|
226 |
+
// Set up a mock queue runner to verify that schedule_next_instance()
|
227 |
+
// isn't called for an undefined $action.
|
228 |
+
$runner = $this
|
229 |
+
->getMockBuilder( 'ActionScheduler_QueueRunner' )
|
230 |
+
->setConstructorArgs( array( $store ) )
|
231 |
+
->setMethods( array( 'schedule_next_instance' ) )
|
232 |
+
->getMock();
|
233 |
+
$runner
|
234 |
+
->expects( $this->never() )
|
235 |
+
->method( 'schedule_next_instance' );
|
236 |
+
|
237 |
+
$runner->run();
|
238 |
+
|
239 |
+
// Set up a mock store that will throw an exception when fetching actions.
|
240 |
+
$store2 = $this
|
241 |
+
->getMockBuilder( 'ActionScheduler_wpPostStore' )
|
242 |
+
->setMethods( array( 'fetch_action' ) )
|
243 |
+
->getMock();
|
244 |
+
$store2
|
245 |
+
->method( 'fetch_action' )
|
246 |
+
->with( $action_id )
|
247 |
+
->willReturn( null );
|
248 |
+
|
249 |
+
// Set up a mock queue runner to verify that schedule_next_instance()
|
250 |
+
// isn't called for an undefined $action.
|
251 |
+
$runner2 = $this
|
252 |
+
->getMockBuilder( 'ActionScheduler_QueueRunner' )
|
253 |
+
->setConstructorArgs( array( $store ) )
|
254 |
+
->setMethods( array( 'schedule_next_instance' ) )
|
255 |
+
->getMock();
|
256 |
+
$runner2
|
257 |
+
->expects( $this->never() )
|
258 |
+
->method( 'schedule_next_instance' );
|
259 |
+
|
260 |
+
$runner2->run();
|
261 |
+
}
|
262 |
+
}
|
includes/vendor/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 |
+
|
includes/vendor/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 |
+
}
|
includes/vendor/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 |
+
|
includes/vendor/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 |
+
|
includes/vendor/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 |
+
|
includes/vendor/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
|
includes/vendor/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_';
|
languages/mc-woocommerce-pt_BR.mo
CHANGED
Binary file
|
languages/mc-woocommerce-pt_BR.po
CHANGED
@@ -2,8 +2,8 @@ msgid ""
|
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: \n"
|
4 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mc-woocommerce\n"
|
5 |
-
"POT-Creation-Date: 2019-
|
6 |
-
"PO-Revision-Date: 2019-
|
7 |
"Last-Translator: \n"
|
8 |
"Language-Team: \n"
|
9 |
"Language: pt_BR\n"
|
@@ -101,6 +101,7 @@ msgstr ""
|
|
101 |
"Se você tiver um momento, por favor nos diga porque você está desativando %s:"
|
102 |
|
103 |
#: includes/class-mailchimp-woocommerce-deactivation-survey.php:379
|
|
|
104 |
msgid "Mailchimp for Woocommerce"
|
105 |
msgstr "Mailchimp para Woocommerce"
|
106 |
|
@@ -144,33 +145,51 @@ msgid "User ID"
|
|
144 |
msgstr "ID do Usuário"
|
145 |
|
146 |
#: includes/class-mailchimp-woocommerce-newsletter.php:43
|
147 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
148 |
#: admin/partials/tabs/newsletter_settings.php:98
|
149 |
msgid "Subscribe to our newsletter"
|
150 |
msgstr "Inscreva-se em nossa newsletter"
|
151 |
|
152 |
-
#: includes/class-mailchimp-woocommerce-rest-api.php:
|
153 |
#: admin/partials/tabs/store_sync.php:169
|
154 |
msgid "D, M j, Y g:i A"
|
155 |
msgstr "l, d\\/m\\/Y H:i"
|
156 |
|
157 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
158 |
msgid "Mailchimp - WooCommerce Setup"
|
159 |
msgstr "Mailchimp para Woocommerce"
|
160 |
|
161 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
162 |
msgid "Settings"
|
163 |
msgstr "Configurações"
|
164 |
|
165 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
msgid "Store Disconnected"
|
167 |
-
msgstr "
|
168 |
|
169 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
170 |
msgid "Store Disconnect Failed"
|
171 |
msgstr "Falha ao desconectar da Loja"
|
172 |
|
173 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
174 |
msgid ""
|
175 |
"As part of the Mailchimp Terms of Use, we require a contact email and a "
|
176 |
"physical mailing address."
|
@@ -178,7 +197,7 @@ msgstr ""
|
|
178 |
"Como parte dos Termos de Uso do Mailchimp, são mandatórios um email de "
|
179 |
"contato e um endereço físico de correspondência."
|
180 |
|
181 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
182 |
msgid ""
|
183 |
"As part of the Mailchimp Terms of Use, we require a valid phone number for "
|
184 |
"your store."
|
@@ -186,31 +205,31 @@ msgstr ""
|
|
186 |
"Como parte dos Termos de Uso do Mailchimp, é mandatório um número de "
|
187 |
"telefone válido para sua Loja."
|
188 |
|
189 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
190 |
msgid "Mailchimp for WooCommerce requires a Store Name to connect your store."
|
191 |
msgstr ""
|
192 |
"Mailchimp para Woocommerce requer um Nome de Loja para conectar sua Loja."
|
193 |
|
194 |
#. translators: %s - plugin name.
|
195 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
196 |
#: admin/partials/tabs/campaign_defaults.php:68
|
197 |
msgid "You were subscribed to the newsletter from %s"
|
198 |
msgstr "Você foi inscrito na newsletter de %s"
|
199 |
|
200 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
201 |
msgid "One or more fields were not updated"
|
202 |
msgstr "Um ou mais campos não foram atualizados"
|
203 |
|
204 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
205 |
msgid "You must supply your Mailchimp API key to pull the audiences."
|
206 |
msgstr ""
|
207 |
"É necessário fornecer a sua Mailchimp API Key para recuperar as audiências."
|
208 |
|
209 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
210 |
msgid "Starting the sync process..."
|
211 |
msgstr "Iniciando a Sincronização…"
|
212 |
|
213 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
214 |
msgid ""
|
215 |
"The plugin has started the initial sync with your store, and the process "
|
216 |
"will work in the background automatically."
|
@@ -218,7 +237,7 @@ msgstr ""
|
|
218 |
"O plugin iniciou a sincronização inicial com a sua Loja, e o processo "
|
219 |
"executará em segundo plano automaticamente."
|
220 |
|
221 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
222 |
msgid ""
|
223 |
"Sometimes the sync can take a while, especially on sites with lots of orders "
|
224 |
"and/or products. It is safe to navigate away from this screen while it is "
|
@@ -229,8 +248,8 @@ msgstr ""
|
|
229 |
"página."
|
230 |
|
231 |
#: admin/partials/tabs/newsletter_settings.php:36
|
232 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
233 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
234 |
msgid "Audience Settings"
|
235 |
msgstr "Configurações de Audiência"
|
236 |
|
@@ -435,8 +454,8 @@ msgid "Mailchimp says: Your re-sync has been started!"
|
|
435 |
msgstr "Maichimp diz: A ressincronização foi iniciada!"
|
436 |
|
437 |
#: admin/partials/tabs/campaign_defaults.php:19
|
438 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
439 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
440 |
msgid "Audience Defaults"
|
441 |
msgstr "Padrões de Audiência"
|
442 |
|
@@ -599,8 +618,8 @@ msgid "Reconnect"
|
|
599 |
msgstr "Reconectar"
|
600 |
|
601 |
#: admin/partials/tabs/api_key.php:10
|
602 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
603 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
604 |
msgid "Connect"
|
605 |
msgstr "Conectar"
|
606 |
|
@@ -629,8 +648,8 @@ msgid "Connected! Please wait while loading next step"
|
|
629 |
msgstr "Conectado! Por favor aguarde o carregamento do próximo passo"
|
630 |
|
631 |
#: admin/partials/tabs/store_info.php:15
|
632 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
633 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
634 |
msgid "Store Settings"
|
635 |
msgstr "Configurações de Loja"
|
636 |
|
@@ -702,15 +721,15 @@ msgstr "Fuso Horário"
|
|
702 |
msgid "Select store's timezone"
|
703 |
msgstr "Selecione o fuso horário da Loja"
|
704 |
|
705 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
706 |
msgid "Mailchimp says: Please upgrade your PHP version to a minimum of 7.0"
|
707 |
msgstr "Mailchimp diz: Atualize a versão do PHP para no mínimo 7.0"
|
708 |
|
709 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
710 |
msgid "Mailchimp says: API Request Error - "
|
711 |
msgstr "Mailchimp diz: API Request Error - "
|
712 |
|
713 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
714 |
msgid ""
|
715 |
"Add Mailchimp for WooCommerce to build custom segments,<br/>send "
|
716 |
"automations, and track purchase activity in Mailchimp"
|
@@ -718,15 +737,15 @@ msgstr ""
|
|
718 |
"Configure o Mailchimp para Woocommerce para criar segmentações customizadas, "
|
719 |
"<br/> enviar automatizações, e rastrear atividade de compras no Mailchimp"
|
720 |
|
721 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
722 |
msgid "Please provide a bit of information<br/>about your WooCommerce store"
|
723 |
-
msgstr "Insira as informações relativas<br/>à sua loja WooCommerce
|
724 |
|
725 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
726 |
msgid "Please fill out the audience default<br/>campaign information"
|
727 |
-
msgstr "Por favor preencha <br/>as informações padrão da Lista
|
728 |
|
729 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
730 |
msgid ""
|
731 |
"Please apply your audience settings. If you don’t<br/>have an audience, you "
|
732 |
"can choose to create one"
|
@@ -734,7 +753,7 @@ msgstr ""
|
|
734 |
"Configure sua Audiência. Se você não tem <br/>nenhuma audiência, você pode "
|
735 |
"escolher criar uma"
|
736 |
|
737 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
738 |
msgid ""
|
739 |
"Connect your WooCommerce store to a<br/>Mailchimp audience in less than 60 "
|
740 |
"seconds"
|
@@ -742,31 +761,31 @@ msgstr ""
|
|
742 |
"Conecte sua loja Woocommerce a uma<br/>Audiência Mailchimp em menos de 60 "
|
743 |
"segundos"
|
744 |
|
745 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
746 |
msgid "Log events from the <br/>Mailchimp plugin"
|
747 |
msgstr "Grave eventos do<br/>plugin Mailchimp"
|
748 |
|
749 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
750 |
msgid "Overview"
|
751 |
msgstr "Visão Geral"
|
752 |
|
753 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
754 |
msgid "Logs"
|
755 |
msgstr "Logs"
|
756 |
|
757 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
758 |
msgid "Start sync"
|
759 |
msgstr "Iniciar Sincronização"
|
760 |
|
761 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
762 |
msgid "Save all changes"
|
763 |
msgstr "Salvar todas alterações"
|
764 |
|
765 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
766 |
msgid "Next"
|
767 |
msgstr "Próximo"
|
768 |
|
769 |
-
#: bootstrap.php:
|
770 |
msgid ""
|
771 |
"The MailChimp For WooCommerce plugin requires the <a href=\"http://wordpress."
|
772 |
"org/extend/plugins/woocommerce/\">WooCommerce</a> plugin to be active!"
|
@@ -774,17 +793,15 @@ msgstr ""
|
|
774 |
"O plugin Mailchimp para Woocommerce requer que o plugin <a href=“http://"
|
775 |
"wordpress.org/extend/plugins/woocommerce/“>WooCommerce</a> esteja ativo!"
|
776 |
|
777 |
-
|
778 |
-
|
779 |
-
msgstr "a funcão “wp_remote_post” não existe"
|
780 |
|
781 |
-
|
782 |
-
|
783 |
-
"
|
784 |
-
|
785 |
-
|
786 |
-
"
|
787 |
-
"habilite para sincronizar dados."
|
788 |
|
789 |
#~ msgid "Please hang tight while we work our mojo."
|
790 |
#~ msgstr "Por favor aguarde."
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: \n"
|
4 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mc-woocommerce\n"
|
5 |
+
"POT-Creation-Date: 2019-09-12T08:42:01+00:00\n"
|
6 |
+
"PO-Revision-Date: 2019-09-12 10:43+0200\n"
|
7 |
"Last-Translator: \n"
|
8 |
"Language-Team: \n"
|
9 |
"Language: pt_BR\n"
|
101 |
"Se você tiver um momento, por favor nos diga porque você está desativando %s:"
|
102 |
|
103 |
#: includes/class-mailchimp-woocommerce-deactivation-survey.php:379
|
104 |
+
#: admin/class-mailchimp-woocommerce-admin.php:261
|
105 |
msgid "Mailchimp for Woocommerce"
|
106 |
msgstr "Mailchimp para Woocommerce"
|
107 |
|
145 |
msgstr "ID do Usuário"
|
146 |
|
147 |
#: includes/class-mailchimp-woocommerce-newsletter.php:43
|
148 |
+
#: admin/class-mailchimp-woocommerce-admin.php:732
|
149 |
#: admin/partials/tabs/newsletter_settings.php:98
|
150 |
msgid "Subscribe to our newsletter"
|
151 |
msgstr "Inscreva-se em nossa newsletter"
|
152 |
|
153 |
+
#: includes/class-mailchimp-woocommerce-rest-api.php:141
|
154 |
#: admin/partials/tabs/store_sync.php:169
|
155 |
msgid "D, M j, Y g:i A"
|
156 |
msgstr "l, d\\/m\\/Y H:i"
|
157 |
|
158 |
+
#: admin/class-mailchimp-woocommerce-admin.php:118
|
159 |
msgid "Mailchimp - WooCommerce Setup"
|
160 |
msgstr "Mailchimp para Woocommerce"
|
161 |
|
162 |
+
#: admin/class-mailchimp-woocommerce-admin.php:157
|
163 |
msgid "Settings"
|
164 |
msgstr "Configurações"
|
165 |
|
166 |
+
#: admin/class-mailchimp-woocommerce-admin.php:262
|
167 |
+
msgid ""
|
168 |
+
"We dectected that this site has the following constants defined, likely at "
|
169 |
+
"wp-config.php file"
|
170 |
+
msgstr ""
|
171 |
+
"Detectamos que este site tem as seguintes constantes definidas, "
|
172 |
+
"possivelmente no arquivo wp-config.php"
|
173 |
+
|
174 |
+
#: admin/class-mailchimp-woocommerce-admin.php:264
|
175 |
+
msgid ""
|
176 |
+
"These constants are deprecated since Mailchimp for Woocommerce version 2.3. "
|
177 |
+
"Please refer to the <a href=\"https://github.com/mailchimp/mc-woocommerce/"
|
178 |
+
"wiki/\">plugin official wiki</a> for further details."
|
179 |
+
msgstr ""
|
180 |
+
"Estas constantes estão obsoletas desde Mailchimp para Woocommerce versão "
|
181 |
+
"2.3. Leia o <a href=“https://github.com/mailchimp/mc-woocommerce/wiki/“>wiki "
|
182 |
+
"oficial do plugin</a> para maiores detalhes."
|
183 |
+
|
184 |
+
#: admin/class-mailchimp-woocommerce-admin.php:384
|
185 |
msgid "Store Disconnected"
|
186 |
+
msgstr "Loja desconectada"
|
187 |
|
188 |
+
#: admin/class-mailchimp-woocommerce-admin.php:388
|
189 |
msgid "Store Disconnect Failed"
|
190 |
msgstr "Falha ao desconectar da Loja"
|
191 |
|
192 |
+
#: admin/class-mailchimp-woocommerce-admin.php:652
|
193 |
msgid ""
|
194 |
"As part of the Mailchimp Terms of Use, we require a contact email and a "
|
195 |
"physical mailing address."
|
197 |
"Como parte dos Termos de Uso do Mailchimp, são mandatórios um email de "
|
198 |
"contato e um endereço físico de correspondência."
|
199 |
|
200 |
+
#: admin/class-mailchimp-woocommerce-admin.php:660
|
201 |
msgid ""
|
202 |
"As part of the Mailchimp Terms of Use, we require a valid phone number for "
|
203 |
"your store."
|
205 |
"Como parte dos Termos de Uso do Mailchimp, é mandatório um número de "
|
206 |
"telefone válido para sua Loja."
|
207 |
|
208 |
+
#: admin/class-mailchimp-woocommerce-admin.php:668
|
209 |
msgid "Mailchimp for WooCommerce requires a Store Name to connect your store."
|
210 |
msgstr ""
|
211 |
"Mailchimp para Woocommerce requer um Nome de Loja para conectar sua Loja."
|
212 |
|
213 |
#. translators: %s - plugin name.
|
214 |
+
#: admin/class-mailchimp-woocommerce-admin.php:686
|
215 |
#: admin/partials/tabs/campaign_defaults.php:68
|
216 |
msgid "You were subscribed to the newsletter from %s"
|
217 |
msgstr "Você foi inscrito na newsletter de %s"
|
218 |
|
219 |
+
#: admin/class-mailchimp-woocommerce-admin.php:691
|
220 |
msgid "One or more fields were not updated"
|
221 |
msgstr "Um ou mais campos não foram atualizados"
|
222 |
|
223 |
+
#: admin/class-mailchimp-woocommerce-admin.php:842
|
224 |
msgid "You must supply your Mailchimp API key to pull the audiences."
|
225 |
msgstr ""
|
226 |
"É necessário fornecer a sua Mailchimp API Key para recuperar as audiências."
|
227 |
|
228 |
+
#: admin/class-mailchimp-woocommerce-admin.php:1304
|
229 |
msgid "Starting the sync process..."
|
230 |
msgstr "Iniciando a Sincronização…"
|
231 |
|
232 |
+
#: admin/class-mailchimp-woocommerce-admin.php:1306
|
233 |
msgid ""
|
234 |
"The plugin has started the initial sync with your store, and the process "
|
235 |
"will work in the background automatically."
|
237 |
"O plugin iniciou a sincronização inicial com a sua Loja, e o processo "
|
238 |
"executará em segundo plano automaticamente."
|
239 |
|
240 |
+
#: admin/class-mailchimp-woocommerce-admin.php:1308
|
241 |
msgid ""
|
242 |
"Sometimes the sync can take a while, especially on sites with lots of orders "
|
243 |
"and/or products. It is safe to navigate away from this screen while it is "
|
248 |
"página."
|
249 |
|
250 |
#: admin/partials/tabs/newsletter_settings.php:36
|
251 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:162
|
252 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:185
|
253 |
msgid "Audience Settings"
|
254 |
msgstr "Configurações de Audiência"
|
255 |
|
454 |
msgstr "Maichimp diz: A ressincronização foi iniciada!"
|
455 |
|
456 |
#: admin/partials/tabs/campaign_defaults.php:19
|
457 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:150
|
458 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:182
|
459 |
msgid "Audience Defaults"
|
460 |
msgstr "Padrões de Audiência"
|
461 |
|
618 |
msgstr "Reconectar"
|
619 |
|
620 |
#: admin/partials/tabs/api_key.php:10
|
621 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:129
|
622 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:176
|
623 |
msgid "Connect"
|
624 |
msgstr "Conectar"
|
625 |
|
648 |
msgstr "Conectado! Por favor aguarde o carregamento do próximo passo"
|
649 |
|
650 |
#: admin/partials/tabs/store_info.php:15
|
651 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:138
|
652 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:179
|
653 |
msgid "Store Settings"
|
654 |
msgstr "Configurações de Loja"
|
655 |
|
721 |
msgid "Select store's timezone"
|
722 |
msgstr "Selecione o fuso horário da Loja"
|
723 |
|
724 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:65
|
725 |
msgid "Mailchimp says: Please upgrade your PHP version to a minimum of 7.0"
|
726 |
msgstr "Mailchimp diz: Atualize a versão do PHP para no mínimo 7.0"
|
727 |
|
728 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:71
|
729 |
msgid "Mailchimp says: API Request Error - "
|
730 |
msgstr "Mailchimp diz: API Request Error - "
|
731 |
|
732 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:103
|
733 |
msgid ""
|
734 |
"Add Mailchimp for WooCommerce to build custom segments,<br/>send "
|
735 |
"automations, and track purchase activity in Mailchimp"
|
737 |
"Configure o Mailchimp para Woocommerce para criar segmentações customizadas, "
|
738 |
"<br/> enviar automatizações, e rastrear atividade de compras no Mailchimp"
|
739 |
|
740 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:107
|
741 |
msgid "Please provide a bit of information<br/>about your WooCommerce store"
|
742 |
+
msgstr "Insira as informações relativas<br/>à sua loja WooCommerce"
|
743 |
|
744 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:111
|
745 |
msgid "Please fill out the audience default<br/>campaign information"
|
746 |
+
msgstr "Por favor preencha <br/>as informações padrão da Lista"
|
747 |
|
748 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:115
|
749 |
msgid ""
|
750 |
"Please apply your audience settings. If you don’t<br/>have an audience, you "
|
751 |
"can choose to create one"
|
753 |
"Configure sua Audiência. Se você não tem <br/>nenhuma audiência, você pode "
|
754 |
"escolher criar uma"
|
755 |
|
756 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:118
|
757 |
msgid ""
|
758 |
"Connect your WooCommerce store to a<br/>Mailchimp audience in less than 60 "
|
759 |
"seconds"
|
761 |
"Conecte sua loja Woocommerce a uma<br/>Audiência Mailchimp em menos de 60 "
|
762 |
"segundos"
|
763 |
|
764 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:122
|
765 |
msgid "Log events from the <br/>Mailchimp plugin"
|
766 |
msgstr "Grave eventos do<br/>plugin Mailchimp"
|
767 |
|
768 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:178
|
769 |
msgid "Overview"
|
770 |
msgstr "Visão Geral"
|
771 |
|
772 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:188
|
773 |
msgid "Logs"
|
774 |
msgstr "Logs"
|
775 |
|
776 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:202
|
777 |
msgid "Start sync"
|
778 |
msgstr "Iniciar Sincronização"
|
779 |
|
780 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:204
|
781 |
msgid "Save all changes"
|
782 |
msgstr "Salvar todas alterações"
|
783 |
|
784 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:204
|
785 |
msgid "Next"
|
786 |
msgstr "Próximo"
|
787 |
|
788 |
+
#: bootstrap.php:520
|
789 |
msgid ""
|
790 |
"The MailChimp For WooCommerce plugin requires the <a href=\"http://wordpress."
|
791 |
"org/extend/plugins/woocommerce/\">WooCommerce</a> plugin to be active!"
|
793 |
"O plugin Mailchimp para Woocommerce requer que o plugin <a href=“http://"
|
794 |
"wordpress.org/extend/plugins/woocommerce/“>WooCommerce</a> esteja ativo!"
|
795 |
|
796 |
+
#~ msgid "function \"wp_remote_post\" does not exist"
|
797 |
+
#~ msgstr "a funcão “wp_remote_post” não existe"
|
|
|
798 |
|
799 |
+
#~ msgid ""
|
800 |
+
#~ "The REST API seems to be disabled on this wordpress site. Please enable "
|
801 |
+
#~ "to sync data."
|
802 |
+
#~ msgstr ""
|
803 |
+
#~ "A REST API aparenta ester desabilitada nest site WordPress. For favor, "
|
804 |
+
#~ "habilite para sincronizar dados."
|
|
|
805 |
|
806 |
#~ msgid "Please hang tight while we work our mojo."
|
807 |
#~ msgstr "Por favor aguarde."
|
languages/mc-woocommerce.pot
CHANGED
@@ -2,14 +2,14 @@
|
|
2 |
# This file is distributed under the same license as the Mailchimp for WooCommerce plugin.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Mailchimp for WooCommerce 2.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mc-woocommerce\n"
|
7 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"POT-Creation-Date: 2019-
|
13 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
"X-Generator: WP-CLI 2.1.0\n"
|
15 |
|
@@ -95,6 +95,7 @@ msgid "If you have a moment, please share why you are deactivating %s:"
|
|
95 |
msgstr ""
|
96 |
|
97 |
#: includes/class-mailchimp-woocommerce-deactivation-survey.php:379
|
|
|
98 |
msgid "Mailchimp for Woocommerce"
|
99 |
msgstr ""
|
100 |
|
@@ -129,73 +130,81 @@ msgid "User ID"
|
|
129 |
msgstr ""
|
130 |
|
131 |
#: includes/class-mailchimp-woocommerce-newsletter.php:43
|
132 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
133 |
#: admin/partials/tabs/newsletter_settings.php:98
|
134 |
msgid "Subscribe to our newsletter"
|
135 |
msgstr ""
|
136 |
|
137 |
-
#: includes/class-mailchimp-woocommerce-rest-api.php:
|
138 |
#: admin/partials/tabs/store_sync.php:169
|
139 |
msgid "D, M j, Y g:i A"
|
140 |
msgstr ""
|
141 |
|
142 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
143 |
msgid "Mailchimp - WooCommerce Setup"
|
144 |
msgstr ""
|
145 |
|
146 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
147 |
msgid "Settings"
|
148 |
msgstr ""
|
149 |
|
150 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
msgid "Store Disconnected"
|
152 |
msgstr ""
|
153 |
|
154 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
155 |
msgid "Store Disconnect Failed"
|
156 |
msgstr ""
|
157 |
|
158 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
159 |
msgid "As part of the Mailchimp Terms of Use, we require a contact email and a physical mailing address."
|
160 |
msgstr ""
|
161 |
|
162 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
163 |
msgid "As part of the Mailchimp Terms of Use, we require a valid phone number for your store."
|
164 |
msgstr ""
|
165 |
|
166 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
167 |
msgid "Mailchimp for WooCommerce requires a Store Name to connect your store."
|
168 |
msgstr ""
|
169 |
|
170 |
#. translators: %s - plugin name.
|
171 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
172 |
#: admin/partials/tabs/campaign_defaults.php:68
|
173 |
msgid "You were subscribed to the newsletter from %s"
|
174 |
msgstr ""
|
175 |
|
176 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
177 |
msgid "One or more fields were not updated"
|
178 |
msgstr ""
|
179 |
|
180 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
181 |
msgid "You must supply your Mailchimp API key to pull the audiences."
|
182 |
msgstr ""
|
183 |
|
184 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
185 |
msgid "Starting the sync process..."
|
186 |
msgstr ""
|
187 |
|
188 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
189 |
msgid "The plugin has started the initial sync with your store, and the process will work in the background automatically."
|
190 |
msgstr ""
|
191 |
|
192 |
-
#: admin/class-mailchimp-woocommerce-admin.php:
|
193 |
msgid "Sometimes the sync can take a while, especially on sites with lots of orders and/or products. It is safe to navigate away from this screen while it is running."
|
194 |
msgstr ""
|
195 |
|
196 |
#: admin/partials/tabs/newsletter_settings.php:36
|
197 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
198 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
199 |
msgid "Audience Settings"
|
200 |
msgstr ""
|
201 |
|
@@ -363,8 +372,8 @@ msgid "Mailchimp says: Your re-sync has been started!"
|
|
363 |
msgstr ""
|
364 |
|
365 |
#: admin/partials/tabs/campaign_defaults.php:19
|
366 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
367 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
368 |
msgid "Audience Defaults"
|
369 |
msgstr ""
|
370 |
|
@@ -503,8 +512,8 @@ msgid "Reconnect"
|
|
503 |
msgstr ""
|
504 |
|
505 |
#: admin/partials/tabs/api_key.php:10
|
506 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
507 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
508 |
msgid "Connect"
|
509 |
msgstr ""
|
510 |
|
@@ -525,8 +534,8 @@ msgid "Connected! Please wait while loading next step"
|
|
525 |
msgstr ""
|
526 |
|
527 |
#: admin/partials/tabs/store_info.php:15
|
528 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
529 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
530 |
msgid "Store Settings"
|
531 |
msgstr ""
|
532 |
|
@@ -594,66 +603,58 @@ msgstr ""
|
|
594 |
msgid "Select store's timezone"
|
595 |
msgstr ""
|
596 |
|
597 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
598 |
msgid "Mailchimp says: Please upgrade your PHP version to a minimum of 7.0"
|
599 |
msgstr ""
|
600 |
|
601 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
602 |
msgid "Mailchimp says: API Request Error - "
|
603 |
msgstr ""
|
604 |
|
605 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
606 |
msgid "Add Mailchimp for WooCommerce to build custom segments,<br/>send automations, and track purchase activity in Mailchimp"
|
607 |
msgstr ""
|
608 |
|
609 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
610 |
msgid "Please provide a bit of information<br/>about your WooCommerce store"
|
611 |
msgstr ""
|
612 |
|
613 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
614 |
msgid "Please fill out the audience default<br/>campaign information"
|
615 |
msgstr ""
|
616 |
|
617 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
618 |
msgid "Please apply your audience settings. If you don’t<br/>have an audience, you can choose to create one"
|
619 |
msgstr ""
|
620 |
|
621 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
622 |
msgid "Connect your WooCommerce store to a<br/>Mailchimp audience in less than 60 seconds"
|
623 |
msgstr ""
|
624 |
|
625 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
626 |
msgid "Log events from the <br/>Mailchimp plugin"
|
627 |
msgstr ""
|
628 |
|
629 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
630 |
msgid "Overview"
|
631 |
msgstr ""
|
632 |
|
633 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
634 |
msgid "Logs"
|
635 |
msgstr ""
|
636 |
|
637 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
638 |
msgid "Start sync"
|
639 |
msgstr ""
|
640 |
|
641 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
642 |
msgid "Save all changes"
|
643 |
msgstr ""
|
644 |
|
645 |
-
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:
|
646 |
msgid "Next"
|
647 |
msgstr ""
|
648 |
|
649 |
-
#: bootstrap.php:
|
650 |
msgid "The MailChimp For WooCommerce plugin requires the <a href=\"http://wordpress.org/extend/plugins/woocommerce/\">WooCommerce</a> plugin to be active!"
|
651 |
msgstr ""
|
652 |
-
|
653 |
-
#: bootstrap.php:926
|
654 |
-
msgid "function \"wp_remote_post\" does not exist"
|
655 |
-
msgstr ""
|
656 |
-
|
657 |
-
#: bootstrap.php:940
|
658 |
-
msgid "The REST API seems to be disabled on this wordpress site. Please enable to sync data."
|
659 |
-
msgstr ""
|
2 |
# This file is distributed under the same license as the Mailchimp for WooCommerce plugin.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Mailchimp for WooCommerce 2.3\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mc-woocommerce\n"
|
7 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"POT-Creation-Date: 2019-09-12T08:42:01+00:00\n"
|
13 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
"X-Generator: WP-CLI 2.1.0\n"
|
15 |
|
95 |
msgstr ""
|
96 |
|
97 |
#: includes/class-mailchimp-woocommerce-deactivation-survey.php:379
|
98 |
+
#: admin/class-mailchimp-woocommerce-admin.php:261
|
99 |
msgid "Mailchimp for Woocommerce"
|
100 |
msgstr ""
|
101 |
|
130 |
msgstr ""
|
131 |
|
132 |
#: includes/class-mailchimp-woocommerce-newsletter.php:43
|
133 |
+
#: admin/class-mailchimp-woocommerce-admin.php:732
|
134 |
#: admin/partials/tabs/newsletter_settings.php:98
|
135 |
msgid "Subscribe to our newsletter"
|
136 |
msgstr ""
|
137 |
|
138 |
+
#: includes/class-mailchimp-woocommerce-rest-api.php:141
|
139 |
#: admin/partials/tabs/store_sync.php:169
|
140 |
msgid "D, M j, Y g:i A"
|
141 |
msgstr ""
|
142 |
|
143 |
+
#: admin/class-mailchimp-woocommerce-admin.php:118
|
144 |
msgid "Mailchimp - WooCommerce Setup"
|
145 |
msgstr ""
|
146 |
|
147 |
+
#: admin/class-mailchimp-woocommerce-admin.php:157
|
148 |
msgid "Settings"
|
149 |
msgstr ""
|
150 |
|
151 |
+
#: admin/class-mailchimp-woocommerce-admin.php:262
|
152 |
+
msgid "We dectected that this site has the following constants defined, likely at wp-config.php file"
|
153 |
+
msgstr ""
|
154 |
+
|
155 |
+
#: admin/class-mailchimp-woocommerce-admin.php:264
|
156 |
+
msgid "These constants are deprecated since Mailchimp for Woocommerce version 2.3. Please refer to the <a href=\"https://github.com/mailchimp/mc-woocommerce/wiki/\">plugin official wiki</a> for further details."
|
157 |
+
msgstr ""
|
158 |
+
|
159 |
+
#: admin/class-mailchimp-woocommerce-admin.php:384
|
160 |
msgid "Store Disconnected"
|
161 |
msgstr ""
|
162 |
|
163 |
+
#: admin/class-mailchimp-woocommerce-admin.php:388
|
164 |
msgid "Store Disconnect Failed"
|
165 |
msgstr ""
|
166 |
|
167 |
+
#: admin/class-mailchimp-woocommerce-admin.php:652
|
168 |
msgid "As part of the Mailchimp Terms of Use, we require a contact email and a physical mailing address."
|
169 |
msgstr ""
|
170 |
|
171 |
+
#: admin/class-mailchimp-woocommerce-admin.php:660
|
172 |
msgid "As part of the Mailchimp Terms of Use, we require a valid phone number for your store."
|
173 |
msgstr ""
|
174 |
|
175 |
+
#: admin/class-mailchimp-woocommerce-admin.php:668
|
176 |
msgid "Mailchimp for WooCommerce requires a Store Name to connect your store."
|
177 |
msgstr ""
|
178 |
|
179 |
#. translators: %s - plugin name.
|
180 |
+
#: admin/class-mailchimp-woocommerce-admin.php:686
|
181 |
#: admin/partials/tabs/campaign_defaults.php:68
|
182 |
msgid "You were subscribed to the newsletter from %s"
|
183 |
msgstr ""
|
184 |
|
185 |
+
#: admin/class-mailchimp-woocommerce-admin.php:691
|
186 |
msgid "One or more fields were not updated"
|
187 |
msgstr ""
|
188 |
|
189 |
+
#: admin/class-mailchimp-woocommerce-admin.php:842
|
190 |
msgid "You must supply your Mailchimp API key to pull the audiences."
|
191 |
msgstr ""
|
192 |
|
193 |
+
#: admin/class-mailchimp-woocommerce-admin.php:1304
|
194 |
msgid "Starting the sync process..."
|
195 |
msgstr ""
|
196 |
|
197 |
+
#: admin/class-mailchimp-woocommerce-admin.php:1306
|
198 |
msgid "The plugin has started the initial sync with your store, and the process will work in the background automatically."
|
199 |
msgstr ""
|
200 |
|
201 |
+
#: admin/class-mailchimp-woocommerce-admin.php:1308
|
202 |
msgid "Sometimes the sync can take a while, especially on sites with lots of orders and/or products. It is safe to navigate away from this screen while it is running."
|
203 |
msgstr ""
|
204 |
|
205 |
#: admin/partials/tabs/newsletter_settings.php:36
|
206 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:162
|
207 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:185
|
208 |
msgid "Audience Settings"
|
209 |
msgstr ""
|
210 |
|
372 |
msgstr ""
|
373 |
|
374 |
#: admin/partials/tabs/campaign_defaults.php:19
|
375 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:150
|
376 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:182
|
377 |
msgid "Audience Defaults"
|
378 |
msgstr ""
|
379 |
|
512 |
msgstr ""
|
513 |
|
514 |
#: admin/partials/tabs/api_key.php:10
|
515 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:129
|
516 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:176
|
517 |
msgid "Connect"
|
518 |
msgstr ""
|
519 |
|
534 |
msgstr ""
|
535 |
|
536 |
#: admin/partials/tabs/store_info.php:15
|
537 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:138
|
538 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:179
|
539 |
msgid "Store Settings"
|
540 |
msgstr ""
|
541 |
|
603 |
msgid "Select store's timezone"
|
604 |
msgstr ""
|
605 |
|
606 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:65
|
607 |
msgid "Mailchimp says: Please upgrade your PHP version to a minimum of 7.0"
|
608 |
msgstr ""
|
609 |
|
610 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:71
|
611 |
msgid "Mailchimp says: API Request Error - "
|
612 |
msgstr ""
|
613 |
|
614 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:103
|
615 |
msgid "Add Mailchimp for WooCommerce to build custom segments,<br/>send automations, and track purchase activity in Mailchimp"
|
616 |
msgstr ""
|
617 |
|
618 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:107
|
619 |
msgid "Please provide a bit of information<br/>about your WooCommerce store"
|
620 |
msgstr ""
|
621 |
|
622 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:111
|
623 |
msgid "Please fill out the audience default<br/>campaign information"
|
624 |
msgstr ""
|
625 |
|
626 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:115
|
627 |
msgid "Please apply your audience settings. If you don’t<br/>have an audience, you can choose to create one"
|
628 |
msgstr ""
|
629 |
|
630 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:118
|
631 |
msgid "Connect your WooCommerce store to a<br/>Mailchimp audience in less than 60 seconds"
|
632 |
msgstr ""
|
633 |
|
634 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:122
|
635 |
msgid "Log events from the <br/>Mailchimp plugin"
|
636 |
msgstr ""
|
637 |
|
638 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:178
|
639 |
msgid "Overview"
|
640 |
msgstr ""
|
641 |
|
642 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:188
|
643 |
msgid "Logs"
|
644 |
msgstr ""
|
645 |
|
646 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:202
|
647 |
msgid "Start sync"
|
648 |
msgstr ""
|
649 |
|
650 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:204
|
651 |
msgid "Save all changes"
|
652 |
msgstr ""
|
653 |
|
654 |
+
#: admin/partials/mailchimp-woocommerce-admin-tabs.php:204
|
655 |
msgid "Next"
|
656 |
msgstr ""
|
657 |
|
658 |
+
#: bootstrap.php:520
|
659 |
msgid "The MailChimp For WooCommerce plugin requires the <a href=\"http://wordpress.org/extend/plugins/woocommerce/\">WooCommerce</a> plugin to be active!"
|
660 |
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mailchimp-woocommerce.php
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
* Plugin Name: Mailchimp for WooCommerce
|
17 |
* Plugin URI: https://mailchimp.com/connect-your-store/
|
18 |
* Description: Connects WooCommerce to Mailchimp to sync your store data, send targeted campaigns to your customers, and sell more stuff.
|
19 |
-
* Version: 2.
|
20 |
* Author: Mailchimp
|
21 |
* Author URI: https://mailchimp.com
|
22 |
* License: GPL-2.0+
|
@@ -24,9 +24,9 @@
|
|
24 |
* Text Domain: mc-woocommerce
|
25 |
* Domain Path: /languages
|
26 |
* Requires at least: 4.9
|
27 |
-
* Tested up to: 5.2.
|
28 |
* WC requires at least: 3.5
|
29 |
-
* WC tested up to: 3.7
|
30 |
*/
|
31 |
|
32 |
// If this file is called directly, abort.
|
@@ -40,9 +40,5 @@ if (!isset($mailchimp_woocommerce_spl_autoloader) || $mailchimp_woocommerce_spl_
|
|
40 |
|
41 |
register_activation_hook( __FILE__, 'activate_mailchimp_woocommerce');
|
42 |
|
43 |
-
// see if the ajax file is working correctly
|
44 |
-
add_action( 'wp_ajax_http_worker_test', 'mailchimp_test_http_worker_ajax');
|
45 |
-
add_action( 'wp_ajax_nopriv_http_worker_test', 'mailchimp_test_http_worker_ajax');
|
46 |
-
|
47 |
// plugins loaded callback
|
48 |
add_action('plugins_loaded', 'mailchimp_on_all_plugins_loaded', 12);
|
16 |
* Plugin Name: Mailchimp for WooCommerce
|
17 |
* Plugin URI: https://mailchimp.com/connect-your-store/
|
18 |
* Description: Connects WooCommerce to Mailchimp to sync your store data, send targeted campaigns to your customers, and sell more stuff.
|
19 |
+
* Version: 2.3
|
20 |
* Author: Mailchimp
|
21 |
* Author URI: https://mailchimp.com
|
22 |
* License: GPL-2.0+
|
24 |
* Text Domain: mc-woocommerce
|
25 |
* Domain Path: /languages
|
26 |
* Requires at least: 4.9
|
27 |
+
* Tested up to: 5.2.5
|
28 |
* WC requires at least: 3.5
|
29 |
+
* WC tested up to: 3.7.1
|
30 |
*/
|
31 |
|
32 |
// If this file is called directly, abort.
|
40 |
|
41 |
register_activation_hook( __FILE__, 'activate_mailchimp_woocommerce');
|
42 |
|
|
|
|
|
|
|
|
|
43 |
// plugins loaded callback
|
44 |
add_action('plugins_loaded', 'mailchimp_on_all_plugins_loaded', 12);
|
plugin_overview.md
CHANGED
@@ -8,10 +8,12 @@ In this article, you’ll learn how to connect Mailchimp for WooCommerce.
|
|
8 |
|
9 |
- For the most up-to-date install instructions, read [Connect or Disconnect Mailchimp for WooCommerce](http://kb.mailchimp.com/integrations/e-commerce/connect-or-disconnect-mailchimp-for-woocommerce).
|
10 |
|
11 |
-
- This plugin requires you to have the [WooCommerce plugin](https://wordpress.org/plugins/woocommerce) already installed and activated in WordPress.
|
12 |
|
13 |
- Your host environment must meet [WooCommerce's minimum requirements](https://docs.woocommerce.com/document/server-requirements), including PHP 7.0 or greater.
|
14 |
|
|
|
|
|
15 |
- We recommend you use this plugin in a staging environment before installing it on production servers.
|
16 |
|
17 |
- Mailchimp for WooCommerce syncs the customer’s first name, last name, email address, and orders.
|
8 |
|
9 |
- For the most up-to-date install instructions, read [Connect or Disconnect Mailchimp for WooCommerce](http://kb.mailchimp.com/integrations/e-commerce/connect-or-disconnect-mailchimp-for-woocommerce).
|
10 |
|
11 |
+
- This plugin requires you to have the latest [WooCommerce plugin](https://wordpress.org/plugins/woocommerce) already installed and activated in WordPress.
|
12 |
|
13 |
- Your host environment must meet [WooCommerce's minimum requirements](https://docs.woocommerce.com/document/server-requirements), including PHP 7.0 or greater.
|
14 |
|
15 |
+
- WordPress REST API should be enabled in order for this plugin to work.
|
16 |
+
|
17 |
- We recommend you use this plugin in a staging environment before installing it on production servers.
|
18 |
|
19 |
- Mailchimp for WooCommerce syncs the customer’s first name, last name, email address, and orders.
|
public/class-mailchimp-woocommerce-public.php
CHANGED
@@ -53,15 +53,6 @@ class MailChimp_WooCommerce_Public {
|
|
53 |
$this->version = $version;
|
54 |
}
|
55 |
|
56 |
-
/**
|
57 |
-
* Register the stylesheets for the public-facing side of the site.
|
58 |
-
*
|
59 |
-
* @since 1.0.0
|
60 |
-
*/
|
61 |
-
public function enqueue_styles() {
|
62 |
-
//wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/mailchimp-woocommerce-public.css', array(), $this->version, 'all' );
|
63 |
-
}
|
64 |
-
|
65 |
/**
|
66 |
* Register the JavaScript for the public-facing side of the site.
|
67 |
*
|
@@ -72,8 +63,6 @@ class MailChimp_WooCommerce_Public {
|
|
72 |
wp_localize_script($this->plugin_name, 'mailchimp_public_data', array(
|
73 |
'site_url' => site_url(),
|
74 |
'ajax_url' => admin_url('admin-ajax.php'),
|
75 |
-
'queue_url' => MailChimp_WooCommerce_Rest_Api::url('queue/work'),
|
76 |
-
'queue_should_fire' => mailchimp_should_init_rest_queue(),
|
77 |
));
|
78 |
|
79 |
// Enqueued script with localized data.
|
53 |
$this->version = $version;
|
54 |
}
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
/**
|
57 |
* Register the JavaScript for the public-facing side of the site.
|
58 |
*
|
63 |
wp_localize_script($this->plugin_name, 'mailchimp_public_data', array(
|
64 |
'site_url' => site_url(),
|
65 |
'ajax_url' => admin_url('admin-ajax.php'),
|
|
|
|
|
66 |
));
|
67 |
|
68 |
// Enqueued script with localized data.
|
public/js/mailchimp-woocommerce-public.js
CHANGED
@@ -6,19 +6,6 @@ var mailchimp,
|
|
6 |
mailchimp_submitted_email = false,
|
7 |
mailchimpReady = function (a) { /in/.test(document.readyState) ? setTimeout("mailchimpReady(" + a + ")", 9) : a(); };
|
8 |
|
9 |
-
function mailchimpPollQueue() {
|
10 |
-
try {
|
11 |
-
var queue = new XMLHttpRequest;
|
12 |
-
queue.open("GET", mailchimp_public_data.queue_url, true);
|
13 |
-
queue.setRequestHeader("Accept", "application/json");
|
14 |
-
queue.timeout = 4000; // Set timeout to 4 seconds (4000 milliseconds)
|
15 |
-
queue.ontimeout = function () { console.log('queue success'); };
|
16 |
-
queue.send();
|
17 |
-
} catch (a) {
|
18 |
-
console.log("mailchimp.init_queue.error", a)
|
19 |
-
}
|
20 |
-
}
|
21 |
-
|
22 |
function mailchimpGetCurrentUserByHash(a) {
|
23 |
try {
|
24 |
var b = mailchimp_public_data.ajax_url + "?action=mailchimp_get_user_by_hash&hash=" + a, c = new XMLHttpRequest;
|
@@ -213,9 +200,6 @@ mailchimpReady(function () {
|
|
213 |
mailchimp_registration_email.onfocus = function () { mailchimpHandleBillingEmail('#reg_email'); }
|
214 |
}
|
215 |
|
216 |
-
if (mailchimp_public_data.queue_should_fire) {
|
217 |
-
mailchimpPollQueue();
|
218 |
-
}
|
219 |
} catch (e) {
|
220 |
console.log('mailchimp ready error', e);
|
221 |
}
|
6 |
mailchimp_submitted_email = false,
|
7 |
mailchimpReady = function (a) { /in/.test(document.readyState) ? setTimeout("mailchimpReady(" + a + ")", 9) : a(); };
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
function mailchimpGetCurrentUserByHash(a) {
|
10 |
try {
|
11 |
var b = mailchimp_public_data.ajax_url + "?action=mailchimp_get_user_by_hash&hash=" + a, c = new XMLHttpRequest;
|
200 |
mailchimp_registration_email.onfocus = function () { mailchimpHandleBillingEmail('#reg_email'); }
|
201 |
}
|
202 |
|
|
|
|
|
|
|
203 |
} catch (e) {
|
204 |
console.log('mailchimp ready error', e);
|
205 |
}
|
public/js/mailchimp-woocommerce-public.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
var mailchimp,mailchimp_cart,mailchimp_billing_email,mailchimp_username_email,mailchimp_registration_email,mailchimp_submitted_email=!1,mailchimpReady=function(e){/in/.test(document.readyState)?setTimeout("mailchimpReady("+e+")",9):e()};function
|
1 |
+
var mailchimp,mailchimp_cart,mailchimp_billing_email,mailchimp_username_email,mailchimp_registration_email,mailchimp_submitted_email=!1,mailchimpReady=function(e){/in/.test(document.readyState)?setTimeout("mailchimpReady("+e+")",9):e()};function mailchimpGetCurrentUserByHash(e){try{var i=mailchimp_public_data.ajax_url+"?action=mailchimp_get_user_by_hash&hash="+e,a=new XMLHttpRequest;a.open("POST",i,!0),a.onload=function(){if(a.status>=200&&a.status<400){var e=JSON.parse(a.responseText);if(!e)return;mailchimp_cart.valueEmail(e.email)&&mailchimp_cart.setEmail(e.email)}},a.onerror=function(){console.log("mailchimp.get_email_by_hash.request.error",a.responseText)},a.setRequestHeader("Content-Type","application/json"),a.setRequestHeader("Accept","application/json"),a.send()}catch(e){console.log("mailchimp.get_email_by_hash.error",e)}}function mailchimpHandleBillingEmail(e){try{e||(e="#billing_email");var i=document.querySelector(e),a=void 0!==i?i.value:"";if(!mailchimp_cart.valueEmail(a)||mailchimp_submitted_email===a)return!1;mailchimp_cart.setEmail(a);var t=mailchimp_public_data.ajax_url+"?action=mailchimp_set_user_by_email&email="+a,n=new XMLHttpRequest;return n.open("POST",t,!0),n.onload=function(){var e=n.status>=200&&n.status<400,i=e?"mailchimp.handle_billing_email.request.success":"mailchimp.handle_billing_email.request.error";e&&(mailchimp_submitted_email=a),console.log(i,n.responseText)},n.onerror=function(){console.log("mailchimp.handle_billing_email.request.error",n.responseText)},n.setRequestHeader("Content-Type","application/json"),n.setRequestHeader("Accept","application/json"),n.send(),!0}catch(i){console.log("mailchimp.handle_billing_email.error",i),mailchimp_submitted_email=!1}}!function(){"use strict";var e,i,a,t={extend:function(e,i){for(var a in i||{})i.hasOwnProperty(a)&&(e[a]=i[a]);return e},getQueryStringVars:function(){var e=window.location.search||"",i=[],a={};if((e=e.substr(1)).length)for(var t in i=e.split("&")){var n=i[t];if("string"==typeof n){var l=n.split("="),r=l[0],m=l[1];r.length&&(void 0===a[r]&&(a[r]=[]),a[r].push(m))}}return a},unEscape:function(e){return decodeURIComponent(e)},escape:function(e){return encodeURIComponent(e)},createDate:function(e,i){e||(e=0);var a=new Date,t=i?a.getDate()-e:a.getDate()+e;return a.setDate(t),a},arrayUnique:function(e){for(var i=e.concat(),a=0;a<i.length;++a)for(var t=a+1;t<i.length;++t)i[a]===i[t]&&i.splice(t,1);return i},objectCombineUnique:function(e){for(var i=e[0],a=1;a<e.length;a++){var t=e[a];for(var n in t)i[n]=t[n]}return i}},n=(e=document,(a=function(e,i,t){return 1===arguments.length?a.get(e):a.set(e,i,t)}).get=function(i,t){return e.cookie!==a._cacheString&&a._populateCache(),null==a._cache[i]?t:a._cache[i]},a.defaults={path:"/"},a.set=function(t,n,l){switch(l={path:l&&l.path||a.defaults.path,domain:l&&l.domain||a.defaults.domain,expires:l&&l.expires||a.defaults.expires,secure:l&&l.secure!==i?l.secure:a.defaults.secure},n===i&&(l.expires=-1),typeof l.expires){case"number":l.expires=new Date((new Date).getTime()+1e3*l.expires);break;case"string":l.expires=new Date(l.expires)}return t=encodeURIComponent(t)+"="+(n+"").replace(/[^!#-+\--:<-\[\]-~]/g,encodeURIComponent),t+=l.path?";path="+l.path:"",t+=l.domain?";domain="+l.domain:"",t+=l.expires?";expires="+l.expires.toGMTString():"",t+=l.secure?";secure":"",e.cookie=t,a},a.expire=function(e,t){return a.set(e,i,t)},a._populateCache=function(){a._cache={};try{a._cacheString=e.cookie;for(var t=a._cacheString.split("; "),n=0;n<t.length;n++){var l=t[n].indexOf("="),r=decodeURIComponent(t[n].substr(0,l));l=decodeURIComponent(t[n].substr(l+1)),a._cache[r]===i&&(a._cache[r]=l)}}catch(e){console.log(e)}},a.enabled=function(){var e="1"===a.set("cookies.js","1").get("cookies.js");return a.expire("cookies.js"),e}(),a);mailchimp={storage:n,utils:t},mailchimp_cart=new function(){return this.email_types="input[type=email]",this.regex_email=/^([A-Za-z0-9_+\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/,this.current_email=null,this.previous_email=null,this.expireUser=function(){this.current_email=null,mailchimp.storage.expire("mailchimp.cart.current_email")},this.expireSaved=function(){mailchimp.storage.expire("mailchimp.cart.items")},this.setEmail=function(e){if(!this.valueEmail(e))return!1;this.setPreviousEmail(this.getEmail()),mailchimp.storage.set("mailchimp.cart.current_email",this.current_email=e)},this.getEmail=function(){if(this.current_email)return this.current_email;var e=mailchimp.storage.get("mailchimp.cart.current_email",!1);return!(!e||!this.valueEmail(e))&&(this.current_email=e)},this.setPreviousEmail=function(e){if(!this.valueEmail(e))return!1;mailchimp.storage.set("mailchimp.cart.previous_email",this.previous_email=e)},this.valueEmail=function(e){return this.regex_email.test(e)},this}}(),mailchimpReady(function(){if(void 0===e)var e={site_url:document.location.origin,defaulted:!0,ajax_url:document.location.origin+"/wp-admin?admin-ajax.php"};try{var i=mailchimp.utils.getQueryStringVars();void 0!==i.mc_cart_id&&mailchimpGetCurrentUserByHash(i.mc_cart_id),mailchimp_username_email=document.querySelector("#username"),mailchimp_billing_email=document.querySelector("#billing_email"),mailchimp_registration_email=document.querySelector("#reg_email"),mailchimp_billing_email&&(mailchimp_billing_email.onblur=function(){mailchimpHandleBillingEmail("#billing_email")},mailchimp_billing_email.onfocus=function(){mailchimpHandleBillingEmail("#billing_email")}),mailchimp_username_email&&(mailchimp_username_email.onblur=function(){mailchimpHandleBillingEmail("#username")},mailchimp_username_email.onfocus=function(){mailchimpHandleBillingEmail("#username")}),mailchimp_registration_email&&(mailchimp_registration_email.onblur=function(){mailchimpHandleBillingEmail("#reg_email")},mailchimp_registration_email.onfocus=function(){mailchimpHandleBillingEmail("#reg_email")})}catch(e){console.log("mailchimp ready error",e)}});
|