diff --git a/.github/workflows/pull-request-post-merge-processing.yml b/.github/workflows/pull-request-post-merge-processing.yml index 68f649a6a45..42bd8aa47da 100644 --- a/.github/workflows/pull-request-post-merge-processing.yml +++ b/.github/workflows/pull-request-post-merge-processing.yml @@ -4,29 +4,39 @@ on: types: [closed] jobs: - assign-milestone: - name: "Assign milestone to merged pull request" - if: github.event.pull_request.merged == true && ! github.event.pull_request.milestone + process-pull-request-after-merge: + name: "Process a pull request after it's merged" + if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: - - name: "Get the milestone changer script" - run: | - curl \ - --silent \ - --fail \ - --header 'Authorization: bearer ${{ secrets.GITHUB_TOKEN }}' \ - --header 'User-Agent: GitHub action to set the milestone for a pull request' \ - --header 'Accept: application/vnd.github.v3.raw' \ - --remote-name \ - --location $GITHUB_API_URL/repos/${{ github.repository }}/contents/.github/workflows/scripts/assign-milestone-to-merged-pr.php - env: - GITHUB_API_URL: ${{ env.GITHUB_API_URL }} - - name: "Install PHP" - uses: shivammathur/setup-php@v2 - with: - php-version: '7.4' - - name: "Run the milestone changer script" - run: php assign-milestone-to-merged-pr.php - env: - PULL_REQUEST_ID: ${{ github.event.pull_request.node_id }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: "Get the action scripts" + run: | + scripts="assign-milestone-to-merged-pr.php add-post-merge-comment.php post-request-shared.php" + for script in $scripts + do + curl \ + --silent \ + --fail \ + --header 'Authorization: bearer ${{ secrets.GITHUB_TOKEN }}' \ + --header 'User-Agent: GitHub action to set the milestone for a pull request' \ + --header 'Accept: application/vnd.github.v3.raw' \ + --output $script \ + --location "$GITHUB_API_URL/repos/${{ github.repository }}/contents/.github/workflows/scripts/$script?ref=${{ github.event.pull_request.base.ref }}" + done + env: + GITHUB_API_URL: ${{ env.GITHUB_API_URL }} + - name: "Install PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + - name: "Run the script to assign a milestone" + if: "!github.event.pull_request.milestone" + run: php assign-milestone-to-merged-pr.php + env: + PULL_REQUEST_ID: ${{ github.event.pull_request.node_id }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: "Run the script to post a comment with next steps hint" + run: php add-post-merge-comment.php + env: + PULL_REQUEST_ID: ${{ github.event.pull_request.node_id }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/scripts/add-post-merge-comment.php b/.github/workflows/scripts/add-post-merge-comment.php new file mode 100644 index 00000000000..fbe3d37bc45 --- /dev/null +++ b/.github/workflows/scripts/add-post-merge-comment.php @@ -0,0 +1,95 @@ + "$keyword { $body }" ); - $context = stream_context_create( - array( - 'http' => array( - 'method' => 'POST', - 'header' => array( - 'Accept: application/json', - 'Content-Type: application/json', - 'User-Agent: GitHub action to set the milestone for a pull request', - 'Authorization: bearer ' . $github_token, - ), - 'content' => json_encode( $data ), - ), - ) - ); - - $result = file_get_contents( $graphql_api_url, false, $context ); - return is_string( $result ) ? json_decode( $result, true ) : $result; -} - // phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.AlternativeFunctions diff --git a/.github/workflows/scripts/post-request-shared.php b/.github/workflows/scripts/post-request-shared.php new file mode 100644 index 00000000000..21e9219f2a6 --- /dev/null +++ b/.github/workflows/scripts/post-request-shared.php @@ -0,0 +1,56 @@ + "$keyword { $body }" ); + $context = stream_context_create( + array( + 'http' => array( + 'method' => 'POST', + 'header' => array( + 'Accept: application/json', + 'Content-Type: application/json', + 'User-Agent: GitHub action to set the milestone for a pull request', + 'Authorization: bearer ' . $github_token, + ), + 'content' => json_encode( $data ), + ), + ) + ); + + $result = file_get_contents( $graphql_api_url, false, $context ); + return is_string( $result ) ? json_decode( $result, true ) : $result; +} + +// phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.AlternativeFunctions diff --git a/changelog.txt b/changelog.txt index fc6469303eb..dff62394c39 100644 --- a/changelog.txt +++ b/changelog.txt @@ -21,6 +21,7 @@ * Fix - Replace hardcoded frontend JS script versions with WC version to bust cached/staled JS scripts. #30301 * Fix - Variable product showing HTML content while granting access for downloadable product in orders. #30305 * Fix - Replaced wp.passwordStrength deprecated method. #30191 +* Fix - `woocommerce_email_settings` filter being triggered twice. #30404 * Dev - Apply `woocommerce_logout_default_redirect_url` filter to logout for custom endpoint. #29967 * Dev - Added new `woocommerce_email_sent` hook. #30123 diff --git a/i18n/states.php b/i18n/states.php index fd423a1ca62..e26c9c7d7b8 100644 --- a/i18n/states.php +++ b/i18n/states.php @@ -1595,6 +1595,32 @@ return array( 'RSVO' => _x( 'Vojvodina', 'district', 'woocommerce' ), ), 'SE' => array(), + 'UA' => array( // Ukraine. Ref: https://en.wikipedia.org/wiki/Oblasts_of_Ukraine. + 'VN' => __( 'Vinnytsia Oblast', 'woocommerce' ), + 'VL' => __( 'Volyn Oblast', 'woocommerce' ), + 'DP' => __( 'Dnipropetrovsk Oblast', 'woocommerce' ), + 'DT' => __( 'Donetsk Oblast', 'woocommerce' ), + 'ZT' => __( 'Zhytomyr Oblast', 'woocommerce' ), + 'ZK' => __( 'Zakarpattia Oblast', 'woocommerce' ), + 'ZP' => __( 'Zaporizhzhia Oblast', 'woocommerce' ), + 'IF' => __( 'Ivano-Frankivsk Oblast', 'woocommerce' ), + 'KV' => __( 'Kyiv Oblast', 'woocommerce' ), + 'KH' => __( 'Kirovohrad Oblast', 'woocommerce' ), + 'LH' => __( 'Luhansk Oblast', 'woocommerce' ), + 'LV' => __( 'Lviv Oblast', 'woocommerce' ), + 'MY' => __( 'Mykolaiv Oblast', 'woocommerce' ), + 'OD' => __( 'Odessa Oblast', 'woocommerce' ), + 'PL' => __( 'Poltava Oblast', 'woocommerce' ), + 'RV' => __( 'Rivne Oblast', 'woocommerce' ), + 'SM' => __( 'Sumy Oblast', 'woocommerce' ), + 'TP' => __( 'Ternopil Oblast', 'woocommerce' ), + 'KK' => __( 'Kharkiv Oblast', 'woocommerce' ), + 'KS' => __( 'Kherson Oblast', 'woocommerce' ), + 'KM' => __( 'Khmelnytskyi Oblast', 'woocommerce' ), + 'CK' => __( 'Cherkasy Oblast', 'woocommerce' ), + 'CH' => __( 'Chernihiv Oblast', 'woocommerce' ), + 'CV' => __( 'Chernivtsi Oblast', 'woocommerce' ), + ), 'UG' => array( // Uganda districts. Ref: https://en.wikipedia.org/wiki/ISO_3166-2:UG. 'UG314' => __( 'Abim', 'woocommerce' ), 'UG301' => __( 'Adjumani', 'woocommerce' ), diff --git a/includes/admin/class-wc-admin-menus.php b/includes/admin/class-wc-admin-menus.php index d926fcf548e..e46e38055a2 100644 --- a/includes/admin/class-wc-admin-menus.php +++ b/includes/admin/class-wc-admin-menus.php @@ -36,6 +36,8 @@ class WC_Admin_Menus { add_filter( 'menu_order', array( $this, 'menu_order' ) ); add_filter( 'custom_menu_order', array( $this, 'custom_menu_order' ) ); add_filter( 'set-screen-option', array( $this, 'set_screen_option' ), 10, 3 ); + add_filter( 'parent_file', array( $this, 'update_menu_highlight' ) ); + add_filter( 'admin_title', array( $this, 'update_my_subscriptions_title' ) ); // Add endpoints custom URLs in Appearance > Menus > Pages. add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) ); @@ -149,8 +151,9 @@ class WC_Admin_Menus { public function addons_menu() { $count_html = WC_Helper_Updater::get_updates_count_html(); /* translators: %s: extensions count */ - $menu_title = sprintf( __( 'Extensions %s', 'woocommerce' ), $count_html ); - add_submenu_page( 'woocommerce', __( 'WooCommerce extensions', 'woocommerce' ), $menu_title, 'manage_woocommerce', 'wc-addons', array( $this, 'addons_page' ) ); + $menu_title = sprintf( __( 'My Subscriptions %s', 'woocommerce' ), $count_html ); + add_submenu_page( 'woocommerce', __( 'WooCommerce Marketplace', 'woocommerce' ), __( 'Marketplace', 'woocommerce' ), 'manage_woocommerce', 'wc-addons', array( $this, 'addons_page' ) ); + add_submenu_page( 'woocommerce', __( 'My WooCommerce.com Subscriptions', 'woocommerce' ), $menu_title, 'manage_woocommerce', 'wc-addons§ion=helper', array( $this, 'addons_page' ) ); } /** @@ -387,6 +390,38 @@ class WC_Admin_Menus { ) ); } + + /** + * Highlight the My Subscriptions menu item when on that page + * + * @param string $parent_file currently opened page. + * @return string + */ + public function update_menu_highlight( $parent_file ) { + global $submenu_file; + if ( 'woocommerce' === $parent_file && isset( $_GET['section'] ) && 'helper' === $_GET['section'] ) { + $submenu_file = 'wc-addons§ion=helper'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited + } + return $parent_file; + } + + /** + * Update the My Subscriptions document title when on that page. + * We want to maintain existing page URL but add it as a separate page, + * which requires updating it manually. + * + * @param string $admin_title existing page title. + * @return string + */ + public function update_my_subscriptions_title( $admin_title ) { + if ( + isset( $_GET['page'] ) && 'wc-addons' === $_GET['page'] && + isset( $_GET['section'] ) && 'helper' === $_GET['section'] + ) { + $admin_title = 'My WooCommerce.com Subscriptions'; + } + return $admin_title; + } } return new WC_Admin_Menus(); diff --git a/includes/admin/helper/views/html-main.php b/includes/admin/helper/views/html-main.php index 3023a192b14..ef39f92ef90 100644 --- a/includes/admin/helper/views/html-main.php +++ b/includes/admin/helper/views/html-main.php @@ -1,19 +1,46 @@ - + +
- -

+

-

+

-

Plugins screen.', 'woocommerce' ), admin_url( 'plugins.php' ) ); ?>

+

+ Plugins screen.', + 'woocommerce' + ), + array( + 'a' => array( + 'href' => array(), + ), + ) + ), + esc_url( + admin_url( 'plugins.php' ) + ) + ); + ?> +