Commit Graph

223 Commits

Author SHA1 Message Date
Nestor Soriano 71462e33f3 Improevements on ExtendedContainer and LegacyProxy documentation.
Also, remove a not really needed `try` block in LegacyProxy::get_instance_of.
2020-07-24 09:25:11 +02:00
Nestor Soriano 6fd84a0401 Add shortcut methods for the LegacyProxy in the WooCommerce class.
The following methods are added and can be invoked using `WC()`,
they just redirect to the same methods in LegacyProxy:

call_function
call_static
get_instance_of
2020-07-24 09:25:11 +02:00
Nestor Soriano 064ae558ab Changes in the overall organization of the dependency injection:
- The `Container` class now implements `Psr\Container\ContainerInterface`
  (and registers itself as such), holding a private instance of the
  real container. This way it's a read-only container from the point
  of view of plugins (which should use their own containers, but
  can still use this to get WooCommerce classes).
- All registrations are now done in the `Container` constructor via
  service providers.
- The container instance is now held in a global variable, set in
  `woocommerce.php`
- Added the `wc_get_container` function for old code.
- Added the `AbstractServiceProvider` class, which inherits with the
  corresponding League's class and adds some utility methods,
  most notably `add/shareWithAutoArguments`.
- Added the `ActionsProxy` and `LegacyProxy` classes, they are
  registered via a dedicated service provider.
- `WC_Queue_Interface` is no longer resolvable via the container
  (which is for classes inside `src` only).
- All the method names in the new classes have the format `fooBarFizz`
  to be PSR4 compliant, so the MethodNameInvalid error has been
  disabled in phpcs.xml for the `src` directory.
- Introduced the `@public` annotation for public API classes
  (classes that plugins can use and whose backwards compatibility
  we guarantee), applied to `ActionsProxy` and to `LegacyProxy` for now.
- Removed the hack for the autoloader as now it doesn't work anyway.
  For the changes in this branch to work, now WP_DEBUG must be false.
2020-07-24 09:23:01 +02:00
Nestor Soriano a7829525eb Changes in the dependency injection container:
- Renamed from `ObjectContainer` to `Container`.
- It now inherits from PHP League's `Container`.
- It has now a `defineAsSharedAutowired` method.
- Initialization moved to the `WooCommerce::init_container` method.
- The static method for object resolution is now `WooCommerce::get_instance_of`.
2020-07-24 09:20:24 +02:00
Nestor Soriano 281ec18158 Undo the registration of old singletons in the DI container.
The container will in principle be used only to register classes
in the `src` directory.

Also, CustomerProvider class removed.
2020-07-24 09:20:24 +02:00
Nestor Soriano 312383ae47 First steps towards introducing a dependency injection framework.
- Add PHP League's Container package via Composer.
- Add an ObjectContainer class that encapsulates all the configuration
  and insulates the codebase from the concrete DI engine used.
- Add an improved ReflectionContainer class that will allow to
  register individual classes as singletons while autowiring.
- Use ObjectContainer to resolve the WooCommerce class, everything
  instantiated with "new" inside it, and all singletons that are
  usually obtained via WC() function.
- Introduce the CustomerProvider class.
- Introduce a service provider to resolve WC_Queue_Interface,
  this replaces the WC_Queue class.
- Mark as obsolete all the replaced "instance()" methods,
  and the entire WC_Queue class.
2020-07-24 09:20:21 +02:00
Ron Rennick 5ee0eccb7b add/update correct deprecated notices on existing deprecations 2020-07-16 17:13:08 -03:00
Peter Fabian 23028a90a1 Schema has not been updated, so revert. 2020-07-13 15:34:54 +02:00
Peter Fabian 6bc0ca724f Update versions and changelog from latest releases. 2020-07-09 13:18:51 +02:00
Peter Fabian dc0d567137
Merge pull request #26775 from woocommerce/update/php7.2
Show notice to update to latest PHP if version is < 7.2
2020-06-16 12:56:15 +02:00
vedanshujain 513b517b5b Show notice to update to latest PHP if version is < 7.2 2020-06-15 21:51:03 +05:30
Vedanshu Jain b45373fe0c Revert "Revert "Introduce a `reserved stock` class and database table to prevent race conditions during checkout"" 2020-06-05 15:18:01 +05:30
vedanshujain e0de059f23 Use seperate db version to better track changes 2020-06-04 22:38:13 +05:30
Claudio Sanches f01c5a3b79 Start 4.3.0 development 2020-05-12 17:49:20 -03:00
Vedanshu Jain ee119e0a7e
Revert "Introduce a `reserved stock` class and database table to prevent race conditions during checkout" 2020-04-21 15:37:21 +05:30
Peter Fabian 5a1ad5daf1 Updated min WP version to 5.2 2020-04-07 11:25:29 +02:00
Mike Jolley 62e099bd84 Add table schema 2020-04-03 15:55:15 +01:00
Rodrigo Primo 83691541c2 Bump WooCommerce version since 4.1.0 development has begun 2020-03-11 11:37:35 -03:00
Peter Fabian 7ec65a1b35 Added the WC Admin enabled db update notice. 2020-02-23 21:59:03 +01:00
Mike Jolley a67ece743d Avoid Automattic\Jetpack\Constants in main woocommerce file 2020-02-18 15:13:30 +00:00
Peter Fabian 68fe4d9f0e Used the final desired version in class WooCommerce. 2020-02-06 21:33:22 +01:00
Peter Fabian 422d8787f5 Updated version to 4.0.0-beta.1 2020-02-06 14:00:43 +01:00
Christopher Allford 57734ca8ce Merge branch 'master' into refactor/add-jetpack-constants 2020-02-04 14:36:35 -08:00
Claudio Sanches 94d1b742ad
Merge pull request #25545 from woocommerce/prep/after-3.9
Bumped versions for the upcoming release.
2020-02-04 13:05:27 -03:00
Peter Fabian e83934edff Bumped versions for the upcoming release. 2020-01-31 17:53:02 +01:00
Christopher Allford 6ad091a9b7 Changed all of the constant accesses into corresponding Automattic\Jetpack\Constants usages 2020-01-28 21:21:29 -08:00
Ron Rennick fda63f4536 move action scheduler to external via composer 2020-01-15 10:31:04 -04:00
Peter Fabian 72925ef41c Centralize check for default themes.
This should make Storefront appear in the Setup Wizard again.
2019-12-11 18:35:04 +01:00
Claudio Sanches 589d8c4591 Updated WooCommerce::$version 2019-12-10 22:55:08 -03:00
Claudio Sanches d7e2a98aaf
Merge pull request #24828 from woocommerce/fix/24695
Adds shared code between Orders and Cart calculation logic.
2019-12-05 12:39:50 -03:00
vedanshujain bee7ea4490 Add trait which contains common total calc logic.
`WC_Abstract_Order` and `WC_Cart_Totals` have their own logic to calculate totals. This means that we would have to fix in two places. This commit adds a trait which can be used to place shared logic between above two classes.
2019-11-25 17:53:14 +05:30
Peter Fabian bc04b8f45b Added basic declaration for WC support to Twentytwenty. 2019-11-19 17:58:16 +01:00
vedanshujain 451139e68e Use MIN_PHP and MIN_WP constants in PHP_MIN_REQUIREMENT value so that we don't have to change it everytime. 2019-10-15 16:07:03 +05:30
vedanshujain 20e1584654 Update `$version` to `3.8.0` because its used for checking DB Upgrades 2019-10-03 12:11:31 +05:30
vedanshujain cd2a63c293 Update version to 3.8-beta.1 2019-10-03 12:07:16 +05:30
Gerhard 414d31d191 Bump PHP recommended version to 7.0 and WP recommended version to 5.0 2019-10-01 12:21:51 +02:00
David Stone 1c47315b89 Fix trying to access array offset on a boolean notice 2019-08-19 20:11:43 -06:00
Akeda Bagus e1743bfadb
Remove extra new line. 2019-07-11 18:22:39 +07:00
Akeda Bagus d51e843190
Move WCCOM Site related files to `/wccom-site` directory.
Also use queue when installing products so API can respond immediately.
2019-07-11 16:01:53 +07:00
Mike Jolley c928188831 Update from master 2019-07-10 12:57:02 +01:00
Rodrigo Primo 2827b57060
Merge pull request #23785 from woocommerce/update/14361
Use WP 5.0 determine_locale() function
2019-07-09 15:46:47 -03:00
Gerhard 7038c73ab4 Merge branch 'master' into update/exclude-compiled-assets-from-git 2019-07-09 10:57:40 +02:00
Claudio Sanches db06d3dbae Merge branch 'master' into update/22164-tax-rate-class-table 2019-07-08 18:12:23 -03:00
Claudio Sanches da99bc8ca0 Merge branch 'master' into feature/feature-plugin-packages 2019-07-08 14:33:21 -03:00
Gerhard 7ff9788450 Use plugin_path instead of plugin_url. 2019-07-03 11:49:51 +02:00
Gerhard 77e8e36f72 Add notice when assets are not built, introduce grunt assets task for compiling and minifying assets. 2019-07-03 11:46:28 +02:00
Peter Fabian 6727fdba62 Updated constants' names to better reflect their usage. 2019-07-02 18:44:43 +02:00
Gerhard Potgieter 698625ce1d WP & PHP Upgrade Notices (#23975)
This commit introduces a banner that notifies and prompts users to upgrade their WordPress and/or PHP if they are outdated and not part of the minimum required versions going into WooCommerce 3.7.

* Add backward compatible function wp_check_php_version for sites running WP version smaller than 5.1

* Refactor some messaging, move widget to top of WC dashboard widgets, add buttons linking out to WP pages with instructions.

* Add missing variables for adding nag class

* Add styling to dashboard widget

* Rework css to use exclamation instead

* Clean up widget, make sure no widget is registered when dismissed. Add banner that links to widget and make it dismissable.

* Update constant to reflect minimum requirements.

* Don't show banner. Fix undefined variable.

* Remove dashboard widget

* Update banner link to docs site

* Add link to docs page where instructions live for updating

* Change button text

* Add UTM params to docs link

* Moved the msg logic from template to php file.

* Bail out early when PHP and WP versions are ok.

* Added missing translation functiog

* Extracted notice function from reset_admin_notices.

To follow suit with other similar functions in the file.

* Synchronize fetching of WP version.

* Removed unused functions.

* Corrected indent.

* Reduce number of variables and fixed coding standards

* Updated wording of the notice.
2019-06-26 14:09:20 -03:00
Mike Jolley 48e1dc5bec Remove init_packages from class-woocommerce 2019-06-25 13:12:14 +01:00
Mike Jolley 6bfe8d63c5 Load Packge files 2019-06-21 19:58:38 +01:00
Mike Jolley d31f6f70a2 Package init method 2019-06-21 17:28:46 +01:00
Mike Jolley e3dc79481d Init the blocks library using autoloading 2019-06-21 15:03:28 +01:00
Mike Jolley 8b41b03f2e Remove blocks files 2019-06-21 12:23:41 +01:00
Mike Jolley 78f9ea59ed Moved auth and exception classes to main includes directory - these are shared between legacy and new API. The package may replace these in the future. 2019-06-19 11:52:50 +01:00
Mike Jolley 038bac16f5 Update paths to legacy API and implement init method. 2019-06-19 11:29:49 +01:00
Gerhard f6d9faa062 Introducde wc_load_cart to dynamically load the cart, this allows for functionality outside of frontend to initialise the cart. 2019-05-22 12:24:31 +02:00
Claudio Sanches bd36434174 Use WP 5.0 determine_locale() function 2019-05-21 17:19:50 -03:00
Gerhard Potgieter 81bfb9cacb
Merge pull request #23529 from woocommerce/update/23512
Define $wpdb tables as early as possible, before init
2019-05-10 10:38:15 +02:00
Rodrigo Primo 84f0f4ebea Bump WC version since 3.7.0 development has begun 2019-05-09 15:14:34 -03:00
Mike Jolley afdd2fe7b1 define wpdb tables as early as possible, before init 2019-04-26 14:03:23 +01:00
Mike Jolley c79e3ad8f1 Detect all rest endpoints, not just wc/ 2019-03-26 14:06:22 +00:00
Mike Jolley a92a67dfca Define table name in wpdb 2019-03-20 14:19:26 +00:00
Mike Jolley f8dded8b49 merge refactor/22762 into master 2019-03-12 13:49:10 +00:00
Mike Jolley 0877e7d8f7
Merge pull request #22954 from woocommerce/add/blocks-rest-api
Merge blocks branch: add 8 product blocks and related API endpoints
2019-03-11 15:18:20 +00:00
Mike Jolley 0e1986df7a Fix include 2019-03-08 13:11:30 +00:00
Mike Jolley 6f35239a26 Move activate/deactivate hooks to main WC class 2019-03-08 12:50:06 +00:00
Mike Jolley a3c2dcd8f2 Update from master 2019-03-08 09:50:56 +00:00
Mike Jolley 5492369fe9
Merge pull request #22857 from woocommerce/feature/marketplace-suggestions
Feature/marketplace suggestions
2019-03-07 16:39:14 +00:00
Kelly Dwan 75b5e78561 Import file to register blocks 2019-03-06 17:28:48 -05:00
Mike Jolley 16a0a3e27e Update from master 2019-03-05 19:03:01 +00:00
Mike Jolley 5af9d968e5 Update from master 2019-03-01 10:29:17 +00:00
Konstantin Kovshenin 1dad53d5e0 Update Marketplace suggestions data using WC_Queue
Schedules an update task to run as soon as possible to fetch the
suggestions data, and cache it for a week. Failures are cached for
a day.
2019-02-22 22:34:18 +03:00
Mike Jolley 07eadfeb72
Merge pull request #22760 from woocommerce/performance/webhook-loading
Performance: webhook loading
2019-02-19 09:58:06 +00:00
Mike Jolley 15bcef85e9
Merge pull request #21090 from woocommerce/fix/20937-v0.1
Added test if request is a REST API request so that cart is not loaded.
2019-02-19 09:54:48 +00:00
Peter Fabian 989fad5a7e Perhaps it does not make much sense to filter empty URI if it's REST request or not. 2019-02-18 22:52:39 +01:00
Peter Fabian 42855592e4 Updated call to reflect function change. 2019-02-18 18:59:37 +01:00
Peter Fabian ba12cf723c Renamed filter and reused the function in auth code. 2019-02-18 18:54:56 +01:00
Mike Jolley 4fd2a9f77e Update from master 2019-02-18 15:04:58 +00:00
Mike Jolley a662934355 phpcs 2019-02-18 12:53:59 +00:00
Mike Jolley d2682170fd Set woocommerce_load_webhooks_limit to no limit 2019-02-18 12:49:07 +00:00
Mike Jolley 3309276e82 Renamed table to wc_product_meta_lookup 2019-02-15 12:37:45 +00:00
Mike Jolley 7b6558e1df Correct table names and updater 2019-02-12 14:04:22 +00:00
Peter Fabian dda4cab70c Updated todo to use the common format. 2019-01-28 13:13:12 +01:00
Mike Jolley 8823559880 get rid of old term meta table 2019-01-25 20:44:25 +00:00
Peter Fabian 33584e767f Renamed function
As legacy REST API will be removed soon anyway.
2019-01-25 10:07:32 +01:00
Peter Fabian d390528d79 Updated check to only cover non-legacy REST API requests.
Updated filter name.
2019-01-24 12:06:47 +01:00
Peter Fabian 2d5fc8ef7d Merge branch 'master' into fix/20937-v0.1 2019-01-24 11:19:46 +01:00
Mike Jolley 59c97539b3 Trigger loaded hook once plugins are loaded. 2019-01-23 16:20:26 +00:00
Brent Shepherd 0708c738b9 Only load 100 webhooks per request
To avoid slowing down page loads on sites with a large numbers of
webhooks.
2019-01-18 14:30:35 +10:00
Brent Shepherd e7a5a2ab2f Only load active webhooks on each request
To avoid slowing down page loads on sites with a large number of
disabled or paused webhooks, which do not need to be loaded or
enqueued.
2019-01-18 14:29:35 +10:00
claudiulodro 3c3894b676 Bump wc_version since 3.6 development has begun 2019-01-02 12:11:35 -08:00
Tiago Noronha 3168f13d9d Skeleton for Twenty Nineteen integration 2018-11-16 16:38:05 +00:00
Peter Fabian cf3f54ec64 Made tax display in cart depend on whether customer is tax exempt. 2018-09-06 17:40:21 +02:00
Peter Fabian 0f7b470167 Added test if request is a REST API request so that cart is not loaded.
Code inspired by WC_REST_Authentication::is_request_to_rest_api, but included also legacy API .
2018-08-17 19:13:44 +02:00
Brent Shepherd d9158a8c0e Add WC_Queue and WC()->queue() wrapper for accessing it
To take care of instantiating a canonical job queue for use across
all of WooCommerce, and by 3rd party code.

Also use this new API for enqueuing webhooks instead of raw Action
Scheduler APIs.
2018-07-31 12:21:07 +10:00
Brent Shepherd 0611ff7665 Add WC_Action_Queue
As a wrapper for Action Scheduler. This implements the WC_Queue_Interface
so it can be used as WC core's job queue. Implementing WC_Queue_Interface
also means this class has more generic and appropriate job queue nomenclature
than Action Scheduler itself. For exsample, it provides a method for
non-delayed jobs, i.e. WC_Queue_Interface::add(), unlike Action Scheduler,
which requires scheduling a job for now(), which while fairly simple, is not
intuitive or immediately obvious to new comers.

This makes it both more clear and convenient to use Action Scheduler
as a simple job queue instead of just a queue for delayed jobs.
2018-07-31 12:21:04 +10:00
Brent Shepherd 8e4466c9c8 Add WC_Queue_Interface
To provide an agreed set of public methods that need to be defined
for any class wanting to act as WooCommerce's queue handler.

The require APIs support both delay jobs, by providing APIs to
schedule an action/job/event for some time in the future, and a
non-delayed job API, to add an event to the queue to run as soon
as possible.
2018-07-31 12:20:30 +10:00
Brent Shepherd e00e728f1f Merge branch 'master' into issue_18003 2018-07-25 14:41:56 +10:00
Brent Shepherd 67744b7768 Add 'woocommerce_shutdown_error' action 2018-07-13 17:08:34 +10:00
Brent Shepherd febea645f9 Log error's file and line number
To help with debugging.
2018-07-13 14:23:17 +10:00