woocommerce/plugins/woocommerce-blocks/woocommerce-gutenberg-produ...

288 lines
9.9 KiB
PHP
Raw Normal View History

<?php
/**
* Plugin Name: WooCommerce Blocks
* Plugin URI: https://github.com/woocommerce/woocommerce-gutenberg-products-block
* Description: WooCommerce blocks for the Gutenberg editor.
2023-12-05 09:58:14 +00:00
* Version: 11.8.0-dev
* Author: Automattic
[Docs] Update links from WooCommerce.com to Woo.com for the Woo Blocks documentation (#43055) * Update woocommerce.com URLs in documentation and code files * Add changelog * Fix github repository link in extend-rest-api-add-custom-fields.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Add github reporter (#42974) * Add github reporter * Add changelog --------- Co-authored-by: Jon Lane <jon.lane@automattic.com> * Fix product task redirect to support grouped and external products (#43051) * Rearrange product redirection logic to better accept grouped and external produc types * Add changelog * Modify feedback modal actions (#43005) * Adapt feedback modal actions * Add changelogs * Modify comments * Fix tests * Fix test * Update class-wc-gateway-bacs.php (#43054) * Update class-wc-gateway-bacs.php Fix typo in textdomain * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: github-actions <github-actions@github.com> * [Product Block Editor]: Add `Linked product` tab (#43009) * add linked-products to group IDs * add Linked Products tab * tweak hideConditions condition * changelog * fix typo in doc comment * Introduce a product type selection within the new experience (#41823) * Create a relation between the product type and the product block template * Add 'patterns' to name the kind of products that can be created for a specific template * Resolve template using its id as a template query param * Rename ProductEditPattern to ProductTemplate * Rename get_patterns hook to woocommerce_product_editor_get_product_templates * Return the list of templates to the client * Set layout template events as array * Register the layout template based on the product template or the post type in case of product variations * Registering non supported product types * Create and register the woocommerce/product-details-section-description block * Add the product type to the section description * Create product type selector * Fix menu item style * Highlight selected menu item * Set the selected product template * Set product template title to lowercase in the content description * Rename blocks by blockTemplates under the AbstractBlockTemplate class * Rename to woocommerce_product_editor_product_templates filter * Remove product_template_ prefix from the supported_product_types map * Rename get_formatted to to_JSON and convert the props to client side like * Refactor get_product_templates * Fix icon resolution * Add a confirmation modal for unsupported product templates * Add changelog files * Remove product types using for testing * Fix redirection when changing to a non supported product template * Set the change button state to busy when it is saving the product * Fix php linter errors * Fix rebase conflict * Move ProductTemplate to Automattic\WooCommerce\Admin\Features\ProductBlockEditor namespace * Add the to_json definition to the BlockTemplateInterface * Create default product template by custom product type if it does not have a template associated yet * Fix some comments and product template creation validation * Add support to load the product template icon from an external resource * Fix php linter * Fix the changelog description * [Experimental] Interactivity Dropdown multi-select mode, ratings filter and introduce each directive (#42981) --------- Co-authored-by: David Arenas <david.arenas@automattic.com> * Introduce the transient files engine (#42877) Co-authored-by: Corey McKrill <916023+coreymckrill@users.noreply.github.com> * Change marketplace install API request to POST instead of GET (#43033) * Change marketplace install API to using POST instead of GET * Fix linting error * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: github-actions <github-actions@github.com> * Prep trunk for 8.6 cycle (#43021) Prep trunk for 8.6 cycle with version bump to 8.6.0-dev Co-authored-by: WooCommerce Bot <no-reply@woo.com> * Add Playwright tests for All Reviews, Reviews by Product and Reviews by Category blocks (#42903) * Remove Reviews blocks Puppeteer tests * Minor code cleanup * Typos * Create publishAndVisitPost() editor util * Fix subcategories when importing products in Playwright and add reviews * Add Reviews blocks tests in Playwright * More typos * Add changefile(s) from automation for the following project(s): woocommerce-blocks * Create a 'reviews' object in data.ts so we can store reviews data in one single place * Update test so instead of creating a new post in each test, we go to the already-created post * Add source comments to reviews data to match it with the script --------- Co-authored-by: github-actions <github-actions@github.com> * Release: Remove 8.5 change files (#43022) Delete changelog files from 8.5 release Co-authored-by: WooCommerce Bot <no-reply@woo.com> Co-authored-by: Alex López <alex.lopez@automattic.com> * Delete changelog files based on PR 43033 (#43079) Delete changelog files for 43033 Co-authored-by: WooCommerce Bot <no-reply@woo.com> * Delete changelog files based on PR 43051 (#43081) Delete changelog files for 43051 Co-authored-by: WooCommerce Bot <no-reply@woo.com> * Interactive Price Filter: use `context` instead of `state` (#42980) * feat: use context instead of state * fix: temporary move the context to inner element for diffing to work * fix: update context before navigation for optimistic UI * Load google analytics gtag script asynchronously in WooCommerce Blocks (#43040) Co-authored-by: github-actions <github-actions@github.com> * set WOOCOMMERCE_BLOCKS_PHASE to 1 for the production build (#43074) * set WOOCOMMERCE_BLOCKS_PHASE to 1 for the production build * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: github-actions <github-actions@github.com> * Revert "Fix schedule sales error" (#43094) Revert "Fix schedule sales error (#42700)" This reverts commit 9b800aa179b25bafebfed0da8c00eec892272cb4. * [Product Block Editor]: add Linked product sections. First approach. (#43013) * add Linked products, Upsell section * changelog * add Cross-lens section * add links to the Upsell sections * changelog * fix lint issues * fix lint issus * fix linting issue :-| * check whether the linked product group is defined * [Product Block Editor]: introduce ShoppingBags component (#43042) * add ShoppingBags component * Add ShoppingBag story * changelog * Fix: Collection data being leaked between Collection Filters blocks (#43044) * fix: CYS - change heading color (#43076) * fix: CYS - change heading color * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com> * Delete changelog files based on PR 43074 (#43118) Delete changelog files for 43074 Co-authored-by: WooCommerce Bot <no-reply@woo.com> * [Product Block Editor]: fix feature flag to hide the Linked products (#43119) * fix flag to hide/show product editor * changelog * Add changelog --------- Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> Co-authored-by: Jonathan Lane <lanej0@users.noreply.github.com> Co-authored-by: Jon Lane <jon.lane@automattic.com> Co-authored-by: louwie17 <lourensschep@gmail.com> Co-authored-by: Fernando Marichal <fernando.marichal@automattic.com> Co-authored-by: Marc Guay <marc.guay@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Damián Suárez <rdsuarez@gmail.com> Co-authored-by: Maikel David Pérez Gómez <maikel.perez@automattic.com> Co-authored-by: Sam Seay <samueljseay@gmail.com> Co-authored-by: Néstor Soriano <konamiman@konamiman.com> Co-authored-by: Corey McKrill <916023+coreymckrill@users.noreply.github.com> Co-authored-by: Kyle Nel <22053773+kdevnel@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: WooCommerce Bot <no-reply@woo.com> Co-authored-by: Alex López <alex.lopez@automattic.com> Co-authored-by: Tung Du <dinhtungdu@gmail.com> Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com> Co-authored-by: Luigi Teschio <gigitux@gmail.com> Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com>
2023-12-29 15:28:11 +00:00
* Author URI: https://woo.com/
* Text Domain: woo-gutenberg-products-block
* Requires at least: 6.4
Backport 11.4.x changes in trunk (https://github.com/woocommerce/woocommerce-blocks/pull/11471) * Empty commit for release pull request * Add changelog entries to readme.txt * Update version numbers * Add testing instructions * Update the changelog with woocommerce/woocommerce-blocks#11421 * Always show the `Enable the shipping calculator on the cart page` option in WC Admin (https://github.com/woocommerce/woocommerce-blocks/pull/11421) * Always show `Enable the shipping calculator ...` Always show the `Enable the shipping calculator on the cart page` option no matter of what is used for the cart page. * Update remove_shipping_settings docblock to accurately describe its purpose. --------- Co-authored-by: Mike Jolley <mike.jolley@me.com> * Add a safe guard that the variable is set before accessing it (https://github.com/woocommerce/woocommerce-blocks/pull/11424) * Update zip package link * Modify the <main> HTML tag in the title to 'main' to ensure the title remains intact * Revert "Use the <header> element for the checkout header (https://github.com/woocommerce/woocommerce-blocks/pull/11222)" This reverts commit 9e9ebc50396cb0358757f908090cbc96e412d445. * Remove woocommerce/woocommerce-blocks#11222 from the Changelog and the Testing Notes * Remove woocommerce/woocommerce-blocks#11190 from the Changelog and Testing Notes as it was never merged * Update .zip file with latest changes * Release: 11.4.2 (https://github.com/woocommerce/woocommerce-blocks/pull/11452) * Empty commit for release pull request * Do a version bump to 11.4.1 * Add Instruction Notes and update the Changelog * Update the testing instructions and the changelog and the .zip link * Empty commit for release pull request * Remove the fontSize for the button (https://github.com/woocommerce/woocommerce-blocks/pull/11433) * [Store Customization MVP] Ensure the AI-generated content in patterns is updated on plugin update (https://github.com/woocommerce/woocommerce-blocks/pull/11210) * Update the patterns content after updating the plugin * Remove unused variable and use statement * Schedule action for updating the patterns content on plugin update (for both WooCommerce and WooCommerce Blocks.) * Update condition to remove the plugin folder name * Remove the update function from bootstrap.php * Remove unused use * Fix the condition, since $options['plugin'] is an array * Remove pattern file This was left empty by mistake in a merge, we need to remove the file or we get an error --------- Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com> * Fix outer space and title (https://github.com/woocommerce/woocommerce-blocks/pull/11434) * Store Customization > Update products with AI generated content (https://github.com/woocommerce/woocommerce-blocks/pull/11155) * Introduce the ProductUpdater class. * Update the image assignment for the default products content. * Update the default products content. * Introduce the generate_content and get_placeholder_products methods. * Update the get_placeholder_products method and introduce the new create_new_product method. * Verify the hash of the product content and compare it with the hash of the ai generated content to ensure we wont override products modified by the store owner. * Add docblocks and update the structure for the ProductUpdater class. * Pass the vertical images as a param for the PatternUpdater and the ProductUpdater. * Update the provided variable to the PatternUpdater class. * Update the ProductUpdater class to include the requirements for usage of the media_sideload_image method outside the wp-admin area (via API) and other adjustments to the products generation and hashes * remove unnecessary calls to post/product images. * Update the loop for generating products. * Further adjustments to the Product Updater. * Provide the business_description as a param for the generate_content ProductUpdates * Update the default timeout for the AI connection; update the path to the default image. Add a limit of 6 when quering the total products created by the store owner. * Add new neutral placeholder images for products and patterns. * Update the prompt and the logic for the placeholder images. * Remove placeholder images. * Increase max execution time * Update the products query. * Move the media_sideload_image function dependencies to outside of the loop and add comment. * Update text content. * Address code review. * bail early if no business description provided. * Add an extra safety check in case of query errors. * Address CR. * Patterns > Upload optimized version of placeholder image (https://github.com/woocommerce/woocommerce-blocks/pull/11441) * Improve vars name and remove duplicated user name (https://github.com/woocommerce/woocommerce-blocks/pull/11430) * Add overlay with 30% opacity (https://github.com/woocommerce/woocommerce-blocks/pull/11428) * [Store Customization] Update the "Footer with 3 Menus" (https://github.com/woocommerce/woocommerce-blocks/pull/11379) * Fix search bar, spacing and show text in one line * Set site log width * Adjust margins and search bar * Make the search bar fill space on mobile * Update column sizes * Remove width from site logo * [CYS Woo Express] Update large footer (https://github.com/woocommerce/woocommerce-blocks/pull/11413) * Update large footer * Update space between icons * Remove with from site logo * update changelog and testing instructions * bump to 11.4.2 version * [CYS Woo Express] Fix essential header (https://github.com/woocommerce/woocommerce-blocks/pull/11449) * Fix essential header * Fix spacing * update testing instructions * Make groups to adapt better to mobile views (https://github.com/woocommerce/woocommerce-blocks/pull/11463) * update testing instructions and changelog * Unify the search bar layout across patterns (https://github.com/woocommerce/woocommerce-blocks/pull/11445) * Unify the search bar layout across patterns * restore changes * [CYS Woo Express] Footer with simple menu and cart (https://github.com/woocommerce/woocommerce-blocks/pull/11409) * Update footer simple menu cart * Change structure to use rows not columns * Make search fill space * Fix spacing and switch mini-cart and menu * Unify the search bar * Remove mini cart * update testing instructions and changelog * Store Customization > Fetch product images from the Pexels API (https://github.com/woocommerce/woocommerce-blocks/pull/11280) * Introduce the ProductUpdater class. * Update the image assignment for the default products content. * Update the default products content. * Introduce the generate_content and get_placeholder_products methods. * Update the get_placeholder_products method and introduce the new create_new_product method. * Verify the hash of the product content and compare it with the hash of the ai generated content to ensure we wont override products modified by the store owner. * Add docblocks and update the structure for the ProductUpdater class. * Pass the vertical images as a param for the PatternUpdater and the ProductUpdater. * Update the provided variable to the PatternUpdater class. * Update the ProductUpdater class to include the requirements for usage of the media_sideload_image method outside the wp-admin area (via API) and other adjustments to the products generation and hashes * remove unnecessary calls to post/product images. * Update the loop for generating products. * Further adjustments to the Product Updater. * Provide the business_description as a param for the generate_content ProductUpdates * Update the default timeout for the AI connection; update the path to the default image. Add a limit of 6 when quering the total products created by the store owner. * Add new neutral placeholder images for products and patterns. * Update the prompt and the logic for the placeholder images. * Remove placeholder images. * Pass the AI connection as a param and update the get_images_for_pattern method to rely on the results returned from the Pexels API. * update the product updater class to rely on Pexels images and add the ai_connection as a param. * Remove the unused get_random_images method. * Update the patterns endpoint. * Delete unused ChatGPTClient class. * Introduce the new Pexels class. * Remove the Verticals references. * Update the reference for the alt description for images. * Update the scheduled action to populate patterns and products. * Remove unused Verticals classes. * Ensure the Pexels class already returns the array with the expected format for assignment to Patterns and Products. * Introduce the select_image_src_based_on_format method. * Increase max execution time * Increase max execution time * Update the request to rely on the WP.com external-media endpoint instead. * Improve performance for product content update. * Improve quality of images used in products and update queries. * Update the products query. * Move the media_sideload_image function dependencies to outside of the loop and add comment. * Update text content. * Merge base branch * Introduce the should_update_dummy_product method. * Update the method to be triggered on scheduled action to return true. * Change the image format for products to improve performance. * Make portrait the default fallback image format. * Address code review. * bail early if no business description provided. * Add an extra safety check in case of query errors. * Address CR. * Raise the default memory limit. * Update the prompt for the search term for images. * Make sure the 'woocommerce_blocks_allow_ai_connection' option is set to true if the site is connected to AI. * Update the prompt for AI generated content in patterns and initialize the images and alts for the patterns. * Update the prompt for products and introduce the update_dummy_products method. * Update the default number of images returned by Pexels. * Update the default fallback for the expected image format. * Update the prompt for selecting the images. * Add a character limit to the testimonials. * Increase timeout to fetch products data * Address code review. * update changelog * add zip link * fix markdown * remove duplicate testing instructions --------- Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com> Co-authored-by: Alba Rincón <albarin@users.noreply.github.com> Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com> Co-authored-by: Tom Cafferkey <tjcafferkey@gmail.com> Co-authored-by: Luigi <gigitux@gmail.com> * Release: 11.4.3 (https://github.com/woocommerce/woocommerce-blocks/pull/11496) * bump to 11.4.3 * Empty commit for release pull request * Improve Hero Product Chessboard pattern (https://github.com/woocommerce/woocommerce-blocks/pull/11423) * improve pattern * remove hardcoded font-size * address feedback * update to h2 * Remove group and separator to get rid of the extra space (https://github.com/woocommerce/woocommerce-blocks/pull/11477) * [Store Customization] Update the design for the Product Gallery pattern (https://github.com/woocommerce/woocommerce-blocks/pull/11464) * Remove rating, show only title and price * Improve title spacing and level * Patterns with Search Bar: improve style (https://github.com/woocommerce/woocommerce-blocks/pull/11478) * "Product Collection X Columns" patterns: align "no reviews" text with the star (https://github.com/woocommerce/woocommerce-blocks/pull/11468) * improve line-height * use variable * add testing instructions * Rename pattern (https://github.com/woocommerce/woocommerce-blocks/pull/11487) * update readme * Store Customization > Enhance the Hero Product Split pattern (https://github.com/woocommerce/woocommerce-blocks/pull/11505) * Update the bottom margin for the Hero Product Split and the heading from h3 to h2. * Update heading comment * update testing instructions * Simplify the `Hero Product 3 Split` pattern design (https://github.com/woocommerce/woocommerce-blocks/pull/11495) * Simplify the pattern design * Add char limits to the AI generated content * Fix url * update testing instructions * Product Search Block: unify border-radius (https://github.com/woocommerce/woocommerce-blocks/pull/11515) * add testing instructions * [Store Customization] Update the Centered Header Menu with Search Pattern (https://github.com/woocommerce/woocommerce-blocks/pull/11304) * Fix hidden elements on mobile and margins * Increase navigation items spacing * Add site logo width * Improve search bar and title font weight * Remove width from site logo * Unify search bar * Remove search, improve margins * Use columns to improve the mobile view * add testing instructions * Large Header pattern: improve the layout on mobile view (https://github.com/woocommerce/woocommerce-blocks/pull/11490) * Improve Large header * improve large header * use lens * add padding * add testing instructions * Fix "Large footer" left spacing (https://github.com/woocommerce/woocommerce-blocks/pull/11520) * Fix large footer left spacing * Use esc_html_e * add testing instructions * add zip file * improve testing instructions * update testing instructions * update testing instructions --------- Co-authored-by: Luigi <gigitux@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Alba Rincón <albarin@users.noreply.github.com> Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com> --------- Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com> Co-authored-by: Mike Jolley <mike.jolley@me.com> Co-authored-by: Karol Manijak <20098064+kmanijak@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Alba Rincón <albarin@users.noreply.github.com> Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com> Co-authored-by: Tom Cafferkey <tjcafferkey@gmail.com>
2023-11-02 17:06:27 +00:00
* Requires PHP: 7.4
* WC requires at least: 8.2
* WC tested up to: 8.3
*
* @package WooCommerce\Blocks
* @internal This file is only used when running as a feature plugin.
*/
Release: 8.7.0 (https://github.com/woocommerce/woocommerce-blocks/pull/7355) * Empty commit for release pull request * Updated changelog. * Minor lint fix. * 8.7.0 Testing instructions * Updated and tidy docs/internal-developers/testing/releases/README.md * Add filter-link-button mixin (https://github.com/woocommerce/woocommerce-blocks/pull/7357) * Set default style to link-button mixin It was identified that we currently have 3 different behaviors for links used in the application. In issue woocommerce/woocommerce-blocks#1778, it was discussed a set of good practices that we should follow in order to obtain consistency between links. Currently, the link-button mixin is already used by the 'Clear all' button in the Active Filters block, so the idea was to increment it with a common pattern (font size small, font-weight normal, underlined by default and not underlined when on hover) that can be reused by other components (for example FilterResetButton). * Change link-button mixin to make it attend the expected default style for links * Replace text-button with link-button mixin in FilterResetButton component * Add new mixin for links in filter blocks * Revert change to link-button mixin to prevent it to affect link buttons on Checkout page * Add filter-link-button mixin that can be used in filter blocks * Remove link-button styles that were moved to filter-link-button mixin By default, link-button mixin styles should have only styles from the text-button mixin and also be underlined. The styles for link button in filter blocks should reside in filter-link-button mixin. * Cherry picked Add filter-link-button mixin woocommerce/woocommerce-blocks#7357 and updated testing instructions * Re-added woocommerce/woocommerce-blocks#7273 to changelog * Correct block name and description (https://github.com/woocommerce/woocommerce-blocks/pull/7354) * Correct block name and description * remove duplicated description for controls blocks * remove duplicated title and desc * Revert "remove duplicated description for controls blocks" This reverts commit ed5417eb0e5191ed2f1def2a04c9e724fe70856a. * removed woocommerce/woocommerce-blocks#7338 from testing instructions and changelog * Updated testing zip package. * Minor formatting fix on the release instructions * change any to or below the express payment method on cart (https://github.com/woocommerce/woocommerce-blocks/pull/7369) * Updated zip. * Add temporary workaround to fix inserting Cart block in WordPress.com (https://github.com/woocommerce/woocommerce-blocks/pull/7367) * remove problematic actions as deps * add inline docs * add todo comment * Cherry picked: Fix a problem that causes an infinite loop when inserting Cart block in wordpress.com (7367) * Updated testing zip. Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Alexandre Lara <allexandrelara@gmail.com> Co-authored-by: Tung Du <dinhtungdu@gmail.com> Co-authored-by: Alex Florisca <alex.florisca@automattic.com> Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2022-10-12 10:03:38 +00:00
defined( 'ABSPATH' ) || exit;
$minimum_wp_version = '6.4.1';
if ( ! defined( 'WC_BLOCKS_IS_FEATURE_PLUGIN' ) ) {
define( 'WC_BLOCKS_IS_FEATURE_PLUGIN', true );
}
Release: 8.7.0 (https://github.com/woocommerce/woocommerce-blocks/pull/7355) * Empty commit for release pull request * Updated changelog. * Minor lint fix. * 8.7.0 Testing instructions * Updated and tidy docs/internal-developers/testing/releases/README.md * Add filter-link-button mixin (https://github.com/woocommerce/woocommerce-blocks/pull/7357) * Set default style to link-button mixin It was identified that we currently have 3 different behaviors for links used in the application. In issue woocommerce/woocommerce-blocks#1778, it was discussed a set of good practices that we should follow in order to obtain consistency between links. Currently, the link-button mixin is already used by the 'Clear all' button in the Active Filters block, so the idea was to increment it with a common pattern (font size small, font-weight normal, underlined by default and not underlined when on hover) that can be reused by other components (for example FilterResetButton). * Change link-button mixin to make it attend the expected default style for links * Replace text-button with link-button mixin in FilterResetButton component * Add new mixin for links in filter blocks * Revert change to link-button mixin to prevent it to affect link buttons on Checkout page * Add filter-link-button mixin that can be used in filter blocks * Remove link-button styles that were moved to filter-link-button mixin By default, link-button mixin styles should have only styles from the text-button mixin and also be underlined. The styles for link button in filter blocks should reside in filter-link-button mixin. * Cherry picked Add filter-link-button mixin woocommerce/woocommerce-blocks#7357 and updated testing instructions * Re-added woocommerce/woocommerce-blocks#7273 to changelog * Correct block name and description (https://github.com/woocommerce/woocommerce-blocks/pull/7354) * Correct block name and description * remove duplicated description for controls blocks * remove duplicated title and desc * Revert "remove duplicated description for controls blocks" This reverts commit ed5417eb0e5191ed2f1def2a04c9e724fe70856a. * removed woocommerce/woocommerce-blocks#7338 from testing instructions and changelog * Updated testing zip package. * Minor formatting fix on the release instructions * change any to or below the express payment method on cart (https://github.com/woocommerce/woocommerce-blocks/pull/7369) * Updated zip. * Add temporary workaround to fix inserting Cart block in WordPress.com (https://github.com/woocommerce/woocommerce-blocks/pull/7367) * remove problematic actions as deps * add inline docs * add todo comment * Cherry picked: Fix a problem that causes an infinite loop when inserting Cart block in wordpress.com (7367) * Updated testing zip. Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Alexandre Lara <allexandrelara@gmail.com> Co-authored-by: Tung Du <dinhtungdu@gmail.com> Co-authored-by: Alex Florisca <alex.florisca@automattic.com> Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2022-10-12 10:03:38 +00:00
// Declare compatibility with custom order tables for WooCommerce.
add_action(
'before_woocommerce_init',
function () {
if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
Release: 8.7.0 (https://github.com/woocommerce/woocommerce-blocks/pull/7355) * Empty commit for release pull request * Updated changelog. * Minor lint fix. * 8.7.0 Testing instructions * Updated and tidy docs/internal-developers/testing/releases/README.md * Add filter-link-button mixin (https://github.com/woocommerce/woocommerce-blocks/pull/7357) * Set default style to link-button mixin It was identified that we currently have 3 different behaviors for links used in the application. In issue woocommerce/woocommerce-blocks#1778, it was discussed a set of good practices that we should follow in order to obtain consistency between links. Currently, the link-button mixin is already used by the 'Clear all' button in the Active Filters block, so the idea was to increment it with a common pattern (font size small, font-weight normal, underlined by default and not underlined when on hover) that can be reused by other components (for example FilterResetButton). * Change link-button mixin to make it attend the expected default style for links * Replace text-button with link-button mixin in FilterResetButton component * Add new mixin for links in filter blocks * Revert change to link-button mixin to prevent it to affect link buttons on Checkout page * Add filter-link-button mixin that can be used in filter blocks * Remove link-button styles that were moved to filter-link-button mixin By default, link-button mixin styles should have only styles from the text-button mixin and also be underlined. The styles for link button in filter blocks should reside in filter-link-button mixin. * Cherry picked Add filter-link-button mixin woocommerce/woocommerce-blocks#7357 and updated testing instructions * Re-added woocommerce/woocommerce-blocks#7273 to changelog * Correct block name and description (https://github.com/woocommerce/woocommerce-blocks/pull/7354) * Correct block name and description * remove duplicated description for controls blocks * remove duplicated title and desc * Revert "remove duplicated description for controls blocks" This reverts commit ed5417eb0e5191ed2f1def2a04c9e724fe70856a. * removed woocommerce/woocommerce-blocks#7338 from testing instructions and changelog * Updated testing zip package. * Minor formatting fix on the release instructions * change any to or below the express payment method on cart (https://github.com/woocommerce/woocommerce-blocks/pull/7369) * Updated zip. * Add temporary workaround to fix inserting Cart block in WordPress.com (https://github.com/woocommerce/woocommerce-blocks/pull/7367) * remove problematic actions as deps * add inline docs * add todo comment * Cherry picked: Fix a problem that causes an infinite loop when inserting Cart block in wordpress.com (7367) * Updated testing zip. Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Alexandre Lara <allexandrelara@gmail.com> Co-authored-by: Tung Du <dinhtungdu@gmail.com> Co-authored-by: Alex Florisca <alex.florisca@automattic.com> Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2022-10-12 10:03:38 +00:00
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
}
}
);
/**
* Whether notices must be displayed in the current page (plugins and WooCommerce pages).
*
* @since 2.5.0
*/
function should_display_compatibility_notices() {
$current_screen = get_current_screen();
if ( ! isset( $current_screen ) ) {
return false;
}
$is_plugins_page =
property_exists( $current_screen, 'id' ) &&
'plugins' === $current_screen->id;
$is_woocommerce_page =
property_exists( $current_screen, 'parent_base' ) &&
'woocommerce' === $current_screen->parent_base;
return $is_plugins_page || $is_woocommerce_page;
}
if ( version_compare( $GLOBALS['wp_version'], $minimum_wp_version, '<' ) ) {
/**
* Outputs for an admin notice about running WooCommerce Blocks on outdated WordPress.
*
* @since 2.5.0
*/
function woocommerce_blocks_admin_unsupported_wp_notice() {
if ( should_display_compatibility_notices() ) {
?>
Update relevant files due to L2->L0 policy change for minimum required versions. (https://github.com/woocommerce/woocommerce-blocks/pull/4484) * update README files with version requirements * update phpcs config * update default environment for tests locally * update workflows to only test against versions matching new policy * update plugin header for new version policy * restore older WP version support in E2E tests and PHPCS I realized that we might still want to test against L2 WP versions in our E2E tests until those tests can be moved to WC core. While the feature plugin is L0, we still need to support L2 for existing features that are already surfaced in the WooCommerce plugin package. Also with PHPCS if there are fixes to older things in the codebase, we will need to preserve the usage of L2 friendly (back-compat) code. * add detection of Woo Core version to bootstrap * update version used in phpunit tests * add links to version policy update post * restore 5.5.1 for Woo Core version Getting errors with 5.5.2 - not sure what's going on but might be the tag isn't available as expected for 5.5.2 maybe? * switch to hardcoded version header reference PHPUNIT was tripping on this for some reason. * remove older WP version e2e test workflows * fix phpunit tests for new woo test suite Woo Core now uses a container and has some mocks that are used in some legacy test helpers. * remove explicit set WOO_VERSION for phpunit tests. This should default to latest for the GH workflow runs. * Update release PR template. Add some explicit instructions around updating required WP and WC versions at time of release. * use latest WOO_VERSION in .env * some improvements to reduce the things needing updated * remove extraneous code * Add some more checklist items to release PR templates * remove unnecessary conditional * remove is-dismissible css classes * Improve clarity of error messaging * Update README.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * remove checklist items about versions for patch releases Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2021-07-29 14:52:34 +00:00
<div class="notice notice-error">
<p><?php esc_html_e( 'The WooCommerce Blocks feature plugin requires a more recent version of WordPress and has been paused. Please update WordPress to continue enjoying WooCommerce Blocks.', 'woo-gutenberg-products-block' ); ?></p>
</div>
<?php
}
}
add_action( 'admin_notices', 'woocommerce_blocks_admin_unsupported_wp_notice' );
return;
}
/**
* Returns whether the current version is a development version
* Note this relies on composer.json version, not plugin version.
* Development installs of the plugin don't have a version defined in
* composer json.
*
* @return bool True means the current version is a development version.
*/
function woocommerce_blocks_is_development_version() {
$composer_file = __DIR__ . '/composer.json';
if ( ! is_readable( $composer_file ) ) {
return false;
}
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- including local file
$composer_config = json_decode( file_get_contents( $composer_file ), true );
return ! isset( $composer_config['version'] );
}
/**
* If development version is detected and the Jetpack constant is not defined, show a notice.
*/
if ( woocommerce_blocks_is_development_version() && ( ! defined( 'JETPACK_AUTOLOAD_DEV' ) || true !== JETPACK_AUTOLOAD_DEV ) ) {
add_action(
'admin_notices',
function () {
echo '<div class="error"><p>';
printf(
/* translators: %1$s is referring to a php constant name, %2$s is referring to the wp-config.php file. */
esc_html__( 'WooCommerce Blocks development mode requires the %1$s constant to be defined and true in your %2$s file. Otherwise you are loading the blocks package from WooCommerce core.', 'woo-gutenberg-products-block' ),
'JETPACK_AUTOLOAD_DEV',
'wp-config.php'
);
echo '</p></div>';
}
);
}
/**
* Autoload packages.
*
* The package autoloader includes version information which prevents classes in this feature plugin
* conflicting with WooCommerce core.
*
* We want to fail gracefully if `composer install` has not been executed yet, so we are checking for the autoloader.
* If the autoloader is not present, let's log the failure and display a nice admin notice.
*/
$autoloader = __DIR__ . '/vendor/autoload_packages.php';
if ( is_readable( $autoloader ) ) {
require $autoloader;
} else {
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
error_log( // phpcs:ignore
sprintf(
/* translators: 1: composer command. 2: plugin directory */
esc_html__( 'Your installation of the WooCommerce Blocks feature plugin is incomplete. Please run %1$s within the %2$s directory.', 'woo-gutenberg-products-block' ),
'`composer install`',
'`' . esc_html( str_replace( ABSPATH, '', __DIR__ ) ) . '`'
)
);
}
/**
* Outputs an admin notice if composer install has not been ran.
*/
add_action(
'admin_notices',
function () {
?>
<div class="notice notice-error">
<p>
<?php
printf(
/* translators: 1: composer command. 2: plugin directory */
esc_html__( 'Your installation of the WooCommerce Blocks feature plugin is incomplete. Please run %1$s within the %2$s directory.', 'woo-gutenberg-products-block' ),
'<code>composer install</code>',
'<code>' . esc_html( str_replace( ABSPATH, '', __DIR__ ) ) . '</code>'
);
?>
</p>
</div>
<?php
}
);
return;
}
add_action( 'plugins_loaded', array( '\Automattic\WooCommerce\Blocks\Package', 'init' ) );
Implement PHP DI container and refactor. Also implements new Asset data interface for extendable settings passed to js. (https://github.com/woocommerce/woocommerce-blocks/pull/956) * Add dependency injection container for blocks * Add new Pacakge and Bootstrap classes. - Bootstrap for bootstrapping the plugin. - Package will replace `src/Package` and added as a dependency for any classes needing package info. * Introduce AssetsDataRegistry for managing asset data * refactor existing classes to use new DIC and Asset Data Registry - this is the bare minimum needed to make this pull viable. - further refactors will be done in more atomic smaller pulls for easier review. * add new settings handling and export `@woocommerce/settings` as an alias to wc.wcSettings - the export is exposed php side on the `wc-settings` handle. * Remove unnecessary concatenation * Fix typos and improve doc blocks * fix php linting issue * Use better escaping function. * improve jsdoc spacing * improve test assertion * use fully qualified class names in bootstrap * improve comment block to account for dynamic version string replace on build * handle exceptions a bit differently * correct dependency reference in webpack config * remove blank lines * fix doc block comment alignment * Various doc/grammar/spacing fixes from code review. Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com> * improve naming, documentation and logic of filter callbacks While this is intended for sanitization/validation, the callback ultimately provides flexibility for filtering the value before returning or setting in state so `filter` is a better name for this.
2019-09-23 18:07:13 +00:00
/**
* WordPress will look for translation in the following order:
* - wp-content/plugins/woocommerce-blocks/languages/woo-gutenberg-products-block-{locale}-{handle}.json
* - wp-content/plugins/woocommerce-blocks/languages/woo-gutenberg-products-block-{locale}-{md5-handle}.json
* - wp-content/languages/plugins/woo-gutenberg-products-block-{locale}-{md5-handle}.json
*
* We check if the last one exists, and if it doesn't we try to load the
* corresponding JSON file from the WC Core.
*
* @param string|false $file Path to the translation file to load. False if there isn't one.
* @param string $handle Name of the script to register a translation domain to.
* @param string $domain The text domain.
*
* @return string|false Path to the translation file to load. False if there isn't one.
*/
function load_woocommerce_core_js_translation( $file, $handle, $domain ) {
if ( 'woo-gutenberg-products-block' !== $domain ) {
return $file;
}
$lang_dir = WP_LANG_DIR . '/plugins';
/**
* We only care about the translation file of the feature plugin in the
* wp-content/languages folder.
*/
if ( false === strpos( $file, $lang_dir ) ) {
return $file;
}
// If the translation file for feature plugin exist, use it.
if ( is_readable( $file ) ) {
return $file;
}
global $wp_scripts;
if ( ! isset( $wp_scripts->registered[ $handle ], $wp_scripts->registered[ $handle ]->src ) ) {
return $file;
}
$handle_src = explode( '/build/', $wp_scripts->registered[ $handle ]->src );
$handle_filename = $handle_src[1];
$locale = determine_locale();
$lang_dir = WP_LANG_DIR . '/plugins';
// Translations are always based on the unminified filename.
if ( substr( $handle_filename, -7 ) === '.min.js' ) {
$handle_filename = substr( $handle_filename, 0, -7 ) . '.js';
}
$core_path_md5 = md5( 'packages/woocommerce-blocks/build/' . $handle_filename );
/**
* Return file path of the corresponding translation file in the WC Core is
* enough because `load_script_translations()` will check for its existence
* before loading it.
*/
return $lang_dir . '/woocommerce-' . $locale . '-' . $core_path_md5 . '.json';
}
add_filter( 'load_script_translation_file', 'load_woocommerce_core_js_translation', 10, 3 );
/**
* Filter translations so we can retrieve translations from Core when the original and the translated
* texts are the same (which happens when translations are missing).
*
* @param string $translation Translated text based on WC Blocks translations.
* @param string $text Text to translate.
* @param string $domain The text domain.
* @return string WC Blocks translation. In case it's the same as $text, Core translation.
*/
function woocommerce_blocks_get_php_translation_from_core( $translation, $text, $domain ) {
if ( 'woo-gutenberg-products-block' !== $domain ) {
return $translation;
}
// When translation is the same, that could mean the string is not translated.
// In that case, load it from core.
if ( $translation === $text ) {
return translate( $text, 'woocommerce' ); // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction, WordPress.WP.I18n.NonSingularStringLiteralText, WordPress.WP.I18n.TextDomainMismatch
}
return $translation;
}
add_filter( 'gettext', 'woocommerce_blocks_get_php_translation_from_core', 10, 3 );
/**
* Add notice to the admin dashboard if the plugin is outdated.
*
* @see https://github.com/woocommerce/woocommerce-blocks/issues/5587
*/
function woocommerce_blocks_plugin_outdated_notice() {
$is_active =
is_plugin_active( 'woo-gutenberg-products-block/woocommerce-gutenberg-products-block.php' ) ||
is_plugin_active( 'woocommerce-gutenberg-products-block/woocommerce-gutenberg-products-block.php' ) ||
is_plugin_active( 'woocommerce-blocks/woocommerce-gutenberg-products-block.php' );
if ( ! $is_active ) {
return;
}
$woocommerce_blocks_path = \Automattic\WooCommerce\Blocks\Package::get_path();
/**
* Check the current WC Blocks path. If the WC Blocks plugin is active but
* the current path is from the WC Core, we can consider the plugin is
* outdated because Jetpack Autoloader always loads the newer package.
*/
if ( ! strpos( $woocommerce_blocks_path, 'packages/woocommerce-blocks' ) ) {
return;
}
if ( should_display_compatibility_notices() ) {
?>
<div class="notice notice-warning">
<p><?php esc_html_e( 'You have WooCommerce Blocks installed, but the WooCommerce bundled version is running because it is more up-to-date. This may cause unexpected compatibility issues. Please update the WooCommerce Blocks plugin.', 'woo-gutenberg-products-block' ); ?></p>
</div>
<?php
}
}
add_action( 'admin_notices', 'woocommerce_blocks_plugin_outdated_notice' );