diff --git a/.deployignore b/.deployignore index 9b4f73f1b..bc33fd459 100644 --- a/.deployignore +++ b/.deployignore @@ -1,33 +1,55 @@ -.DS_Store -*.zip -tags -composer.lock -vendor -node_modules -npm-debug.log - -# IDEs -.idea -.vscode - # Directories and files that we do not want to be included with the built +# IDEs # version and deployed to WordPress.org. +*.sql +*.tar.gz +*.zip +.DS_Store .babelrc +.circleci/config.yml +.distignore .editorconfig .eslintignore .eslintrc.json +.git .github -.phpcs.xml +.gitignore +.gitlab-ci.yml +.idea +.phpcs .phpcs-cache.json +.phpcs.xml +.phpcs.xml.dist +.phpstan .phpunit.result.cache .travis.yml +.vscode +.wordpress-org +.wp-env.json +Gruntfile.js +README.md +Thumbs.db assets/js/pluginsidebar assets/js/util +behat.yml bin +bitbucket-pipelines.yml composer.json -package.json +composer.lock +multisite.xml +multisite.xml.dist +node_modules +npm-debug.log package-lock.json +package.json +phpcs.xml +phpcs.xml.dist +phpstan.neon.dist +phpunit.xml phpunit.xml.dist -README.md +tags tests +vendor webpack.config.js +wp-cli.local.yml +yarn.lock diff --git a/.distignore b/.distignore new file mode 100644 index 000000000..852095f18 --- /dev/null +++ b/.distignore @@ -0,0 +1,53 @@ +# A set of files you probably don't want in your WordPress.org distribution +*.sql +*.tar.gz +*.zip +.DS_Store +.babelrc +.circleci/config.yml +.distignore +.editorconfig +.eslintignore +.eslintrc.json +.git +.github +.gitignore +.gitlab-ci.yml +.idea +.phpcs +.phpcs-cache.json +.phpcs.xml +.phpcs.xml.dist +.phpstan +.phpunit.result.cache +.travis.yml +.vscode +.wordpress-org +.wp-env.json +Gruntfile.js +README.md +Thumbs.db +assets/js/pluginsidebar +assets/js/util +behat.yml +bin +bitbucket-pipelines.yml +composer.json +composer.lock +multisite.xml +multisite.xml.dist +node_modules +npm-debug.log +package-lock.json +package.json +phpcs.xml +phpcs.xml.dist +phpstan.neon.dist +phpunit.xml +phpunit.xml.dist +tags +tests +vendor +webpack.config.js +wp-cli.local.yml +yarn.lock diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 804636ebb..000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,25 +0,0 @@ -on: - push: - tags: - - 'v*.*.*' # Push events to matching v* (eg. v2.0.8) - - '!*-built' # Exclude built branches (eg. v2.0.8-built) - -name: Trigger Build - -jobs: - build: - name: Trigger Build - runs-on: ubuntu-latest - - steps: - - name: 'curl to build server' - shell: bash - env: - URL: ${{ secrets.DB_BUILD_URL }} - TOKEN: ${{ secrets.DB_BUILD_SECRET }} - ENV_ID: ${{ secrets.DB_BUILD_ENV }} - run: | - curl -s "$URL" \ - -X POST \ - -H "X-Api-Token: $TOKEN" \ - -d "{\"environment_id\":${ENV_ID},\"deploy_from_scratch\":true,\"trigger_notifications\":true,\"comment\":\"Build Trigger from GitHub Actions\"}" diff --git a/.github/workflows/built-release.yml b/.github/workflows/built-release.yml new file mode 100644 index 000000000..95eb0d757 --- /dev/null +++ b/.github/workflows/built-release.yml @@ -0,0 +1,18 @@ +name: Built Release + +on: + push: + branches: + - develop + - main + - production + +jobs: + built-release: + uses: alleyinteractive/.github/.github/workflows/built-release.yml@main + if: ${{ github.repository != 'alleyinteractive/create-wordpress-plugin' }} + with: + node: 16 + php: '8.2' + composer_install: true + draft: true diff --git a/.github/workflows/deploy-to-wordpress.yml b/.github/workflows/deploy-to-wordpress.yml new file mode 100644 index 000000000..04d976ed7 --- /dev/null +++ b/.github/workflows/deploy-to-wordpress.yml @@ -0,0 +1,19 @@ +name: Deploy to WordPress.org +on: + push: + tags: + - "*" +jobs: + push-built-release: + name: Deploy plugin version to WP.org + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: WordPress Plugin Deploy + uses: 10up/action-wordpress-plugin-deploy@stable + env: + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SLUG: publish-to-apple-news + DRY_RUN: true diff --git a/.github/workflows/node-tests.yml b/.github/workflows/node-tests.yml index 55dd44e57..b06d6fb65 100644 --- a/.github/workflows/node-tests.yml +++ b/.github/workflows/node-tests.yml @@ -1,28 +1,22 @@ name: Node Tests on: + push: + branches: + - develop + - release/* pull_request: + types: [ opened, synchronize, reopened, ready_for_review ] + branches: + - develop + - release/* jobs: - npm-ci: - name: (npm) Install, build, and test - runs-on: ubuntu-latest - steps: - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.11.0 - with: - all_but_latest: true - - name: Checkout code - uses: actions/checkout@v3 - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 16 - - name: Install node dependencies (npm ci) - run: npm ci - - name: Run npm lint - run: npm run lint - - name: Run npm test - run: npm run test - - name: Run npm build - run: npm run build + node-tests: + if: github.event.pull_request.draft == false + uses: alleyinteractive/.github/.github/workflows/node-tests.yml@main + with: + ci: true + node: 16 + run-audit: false + working-directory: ./ diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index 38a3269e3..1380f48f2 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -1,25 +1,22 @@ name: PHP Coding Standards + on: + push: + branches: + - develop + - release/* pull_request: - workflow_dispatch: + types: [ opened, synchronize, reopened, ready_for_review ] + branches: + - develop + - release/* + jobs: phpcs: - runs-on: ubuntu-latest - steps: - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.11.0 - with: - all_but_latest: true - - name: Checkout code - uses: actions/checkout@v3 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.0' - coverage: none - - name: Validate Composer package - run: composer validate --strict - - name: Install dependencies - uses: ramsey/composer-install@v2 - - name: Run PHPCS - run: composer phpcs + strategy: + matrix: + php: [ 8.2 ] + if: github.event.pull_request.draft == false + uses: alleyinteractive/.github/.github/workflows/php-coding-standards.yml@main + with: + php: ${{ matrix.php }} diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 04663c501..60f771d5c 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -1,51 +1,27 @@ -name: Unit Tests +name: Testing Suite + on: + push: + branches: + - develop + - release/* pull_request: - workflow_dispatch: + types: [ opened, synchronize, reopened, ready_for_review ] + branches: + - develop + - release/* + jobs: - tests: - name: "PHP: ${{ matrix.php }} (MU: ${{ matrix.multisite }})" - runs-on: ubuntu-latest + php-tests: strategy: - fail-fast: true matrix: - multisite: [0, 1] - php: ['8.0', '7.4', '7.3', '7.2', '7.1'] - env: - WP_CORE_DIR: /tmp/wordpress/ - WP_MULTISITE: ${{ matrix.multisite }} - services: - mysql: - image: mysql:5.7 - env: - MYSQL_ALLOW_EMPTY_PASSWORD: yes - ports: - - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - steps: - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.11.0 - with: - all_but_latest: true - - name: Checkout code - uses: actions/checkout@v3 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd - coverage: none - - name: Install dependencies - uses: ramsey/composer-install@v2 - - name: Set up WordPress - run: | - bash <(curl -s "https://raw.githubusercontent.com/wp-cli/sample-plugin/master/bin/install-wp-tests.sh") wordpress_unit_tests root '' 127.0.0.1 - rm -rf "${WP_CORE_DIR}wp-content/plugins" - mkdir -p "${WP_CORE_DIR}wp-content/plugins/publish-to-apple-news" - rsync -a --exclude=.git . "${WP_CORE_DIR}wp-content/plugins/publish-to-apple-news" - cd ${WP_CORE_DIR}wp-content/plugins/publish-to-apple-news && composer install - - name: Run tests - shell: bash - run: | - cd ${WP_CORE_DIR}/wp-content/plugins/publish-to-apple-news - composer run phpunit + multisite: [true, false] + php: ['8.2', '8.1', '8.0'] + wordpress: ["latest"] + if: github.event.pull_request.draft == false + uses: alleyinteractive/.github/.github/workflows/php-tests.yml@main + with: + command: "phpunit" + multisite: ${{ matrix.multisite }} + php: ${{ matrix.php }} + wordpress: ${{ matrix.wordpress }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 24fb4daf8..000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,24 +0,0 @@ -on: - push: - tags: - - 'v*-built' # Create releases for built branches (eg. v2.0.8-built) - -name: Create -built release - -jobs: - release: - name: Create release - runs-on: ubuntu-latest - - steps: - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Provided by Actions - with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - body: A version that contains pre-built JavaScript assets for Gutenberg. This version matches what is deployed to WordPress.org, minus some development and wiki image files, and is suitable for inclusion via submodule. - draft: false - prerelease: true diff --git a/README.md b/README.md index 5db89d1e4..1dfd33a86 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,18 @@ The wiki has [details about contributing](https://github.com/alleyinteractive/ap ![Alley logo](https://avatars.githubusercontent.com/u/1733454?s=200&v=4) +## Releasing the Plugin + +The plugin uses a [built release workflow](./.github/workflows/built-release.yml) +to compile and tag releases. Whenever a new version is detected in the root +`composer.json` file or in the plugin's headers, the workflow will automatically +build the plugin and tag it with a new version. The built tag will contain all +the required front-end assets the plugin may require. This works well for +publishing to WordPress.org or for submodule-ing. + +When you are ready to release a new version of the plugin, you can run +`npm run release` to start the process of setting up a new release. + ### Contributors Thanks to all of the [contributors](CONTRIBUTORS.md) to this project. diff --git a/admin/apple-actions/class-action.php b/admin/apple-actions/class-action.php index 6e4dcdf58..00a93a1e4 100644 --- a/admin/apple-actions/class-action.php +++ b/admin/apple-actions/class-action.php @@ -50,5 +50,4 @@ abstract public function perform(); protected function get_setting( $name ) { return $this->settings->get( $name ); } - } diff --git a/admin/apple-actions/class-api-action.php b/admin/apple-actions/class-api-action.php index 5512e3d0a..a4da4de46 100644 --- a/admin/apple-actions/class-api-action.php +++ b/admin/apple-actions/class-api-action.php @@ -12,9 +12,9 @@ require_once plugin_dir_path( __FILE__ ) . 'class-action-exception.php'; require_once plugin_dir_path( __FILE__ ) . '../../includes/apple-push-api/autoload.php'; -use Apple_Actions\Action as Action; -use Apple_Push_API\API as API; -use Apple_Push_API\Credentials as Credentials; +use Apple_Actions\Action; +use Apple_Push_API\API; +use Apple_Push_API\Credentials; /** * A base class that API-related actions can extend. @@ -88,5 +88,4 @@ protected function is_api_configuration_valid() { return true; } - } diff --git a/admin/apple-actions/index/class-delete.php b/admin/apple-actions/index/class-delete.php index 6c33645b7..3c21e9081 100644 --- a/admin/apple-actions/index/class-delete.php +++ b/admin/apple-actions/index/class-delete.php @@ -10,7 +10,7 @@ require_once plugin_dir_path( __FILE__ ) . '../class-api-action.php'; -use Apple_Actions\API_Action as API_Action; +use Apple_Actions\API_Action; /** * A class to handle a delete request from the admin. @@ -63,12 +63,12 @@ public function perform() { */ private function delete() { if ( ! $this->is_api_configuration_valid() ) { - throw new \Apple_Actions\Action_Exception( __( 'Your Apple News API settings seem to be empty. Please fill the API key, API secret and API channel fields in the plugin configuration page.', 'apple-news' ) ); + throw new \Apple_Actions\Action_Exception( esc_html__( 'Your Apple News API settings seem to be empty. Please fill the API key, API secret and API channel fields in the plugin configuration page.', 'apple-news' ) ); } $remote_id = get_post_meta( $this->id, 'apple_news_api_id', true ); if ( ! $remote_id ) { - throw new \Apple_Actions\Action_Exception( __( 'This post has not been pushed to Apple News, cannot delete.', 'apple-news' ) ); + throw new \Apple_Actions\Action_Exception( esc_html__( 'This post has not been pushed to Apple News, cannot delete.', 'apple-news' ) ); } try { @@ -103,5 +103,4 @@ private function delete() { return $e->getMessage(); } } - } diff --git a/admin/apple-actions/index/class-export.php b/admin/apple-actions/index/class-export.php index bf7e9ddf6..dfdad36e4 100644 --- a/admin/apple-actions/index/class-export.php +++ b/admin/apple-actions/index/class-export.php @@ -341,8 +341,8 @@ public function format_byline( $post, $author = '', $date = '' ) { } // Get the date. - if ( empty( $date ) && ! empty( $post->post_date ) ) { - $date = $post->post_date; + if ( empty( $date ) && ! empty( $post->post_date_gmt ) ) { + $date = $post->post_date_gmt; } // Set the default date format. diff --git a/admin/apple-actions/index/class-get.php b/admin/apple-actions/index/class-get.php index 03ce4b64d..66f221944 100644 --- a/admin/apple-actions/index/class-get.php +++ b/admin/apple-actions/index/class-get.php @@ -10,7 +10,7 @@ require_once plugin_dir_path( __FILE__ ) . '../class-api-action.php'; -use Apple_Actions\API_Action as API_Action; +use Apple_Actions\API_Action; /** * A class to handle a get request from the admin. diff --git a/admin/apple-actions/index/class-push.php b/admin/apple-actions/index/class-push.php index 739d4b36f..ab9787fcc 100644 --- a/admin/apple-actions/index/class-push.php +++ b/admin/apple-actions/index/class-push.php @@ -11,9 +11,9 @@ require_once plugin_dir_path( __FILE__ ) . '../class-api-action.php'; require_once plugin_dir_path( __FILE__ ) . 'class-export.php'; -use \Admin_Apple_Notice; -use \Admin_Apple_Sections; -use \Apple_Actions\API_Action; +use Admin_Apple_Notice; +use Admin_Apple_Sections; +use Apple_Actions\API_Action; /** * A class to handle a push request from the admin. @@ -147,7 +147,7 @@ private function is_post_in_sync( $json, $meta = [], $bundles = [] ) { // Ensure the post (still) exists. Async operations might result in this function being run against a non-existent post. $post = get_post( $this->id ); if ( ! $post ) { - throw new \Apple_Actions\Action_Exception( __( 'Apple News Error: Could not find post with id ', 'apple-news' ) . $this->id ); + throw new \Apple_Actions\Action_Exception( esc_html( __( 'Apple News Error: Could not find post with id ', 'apple-news' ) . $this->id ) ); } // Compare checksums to determine whether the article is in sync or not. @@ -187,13 +187,13 @@ private function get() { // Ensure we have a valid ID. $apple_id = get_post_meta( $this->id, 'apple_news_api_id', true ); if ( empty( $apple_id ) ) { - throw new \Apple_Actions\Action_Exception( __( 'This post does not have a valid Apple News ID, so it cannot be retrieved from the API.', 'apple-news' ) ); + throw new \Apple_Actions\Action_Exception( esc_html__( 'This post does not have a valid Apple News ID, so it cannot be retrieved from the API.', 'apple-news' ) ); } // Get the article from the API. $result = $this->get_api()->get_article( $apple_id ); if ( empty( $result->data->revision ) ) { - throw new \Apple_Actions\Action_Exception( __( 'The Apple News API returned invalid data for this article since the revision is empty.', 'apple-news' ) ); + throw new \Apple_Actions\Action_Exception( esc_html__( 'The Apple News API returned invalid data for this article since the revision is empty.', 'apple-news' ) ); } // Update the revision. @@ -209,7 +209,7 @@ private function get() { */ private function push( $user_id = null ) { if ( ! $this->is_api_configuration_valid() ) { - throw new \Apple_Actions\Action_Exception( __( 'Your Apple News API settings seem to be empty. Please fill in the API key, API secret and API channel fields in the plugin configuration page.', 'apple-news' ) ); + throw new \Apple_Actions\Action_Exception( esc_html__( 'Your Apple News API settings seem to be empty. Please fill in the API key, API secret and API channel fields in the plugin configuration page.', 'apple-news' ) ); } /** @@ -227,8 +227,8 @@ private function push( $user_id = null ) { throw new \Apple_Actions\Action_Exception( sprintf( // Translators: Placeholder is a post ID. - __( 'Skipped push of article %d due to the apple_news_skip_push filter.', 'apple-news' ), - $this->id + esc_html__( 'Skipped push of article %d due to the apple_news_skip_push filter.', 'apple-news' ), + absint( $this->id ) ) ); } @@ -277,8 +277,8 @@ private function push( $user_id = null ) { throw new \Apple_Actions\Action_Exception( sprintf( // Translators: Placeholder is a post ID. - __( 'Skipped push of article %d due to the presence of a skip push taxonomy term.', 'apple-news' ), - $this->id + esc_html__( 'Skipped push of article %d due to the presence of a skip push taxonomy term.', 'apple-news' ), + absint( $this->id ) ) ); } @@ -393,8 +393,8 @@ private function push( $user_id = null ) { throw new \Apple_Actions\Action_Exception( sprintf( // Translators: Placeholder is a post ID. - __( 'Skipped push of article %d to Apple News because it is already in sync.', 'apple-news' ), - $this->id + esc_html__( 'Skipped push of article %d to Apple News because it is already in sync.', 'apple-news' ), + $this->id // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped ) ); } @@ -451,9 +451,9 @@ private function push( $user_id = null ) { $this->clean_workspace(); if ( preg_match( '#WRONG_REVISION#', $e->getMessage() ) ) { - throw new \Apple_Actions\Action_Exception( __( 'Apple News Error: It seems like the article was updated by another call. If the problem persists, try removing and pushing again.', 'apple-news' ) ); + throw new \Apple_Actions\Action_Exception( esc_html__( 'Apple News Error: It seems like the article was updated by another call. If the problem persists, try removing and pushing again.', 'apple-news' ) ); } else { - throw new \Apple_Actions\Action_Exception( __( 'There has been an error with the Apple News API: ', 'apple-news' ) . $e->getMessage() ); + throw new \Apple_Actions\Action_Exception( esc_html__( 'There has been an error with the Apple News API: ', 'apple-news' ) . esc_html( $e->getMessage() ) ); } } @@ -536,7 +536,7 @@ private function process_errors( $errors ) { $this->clean_workspace(); // Throw an exception. - throw new \Apple_Actions\Action_Exception( $alert_message ); + throw new \Apple_Actions\Action_Exception( esc_html( $alert_message ) ); } elseif ( 'warn' === $component_alerts && ! empty( $errors[0]['component_errors'] ) ) { \Admin_Apple_Notice::error( $alert_message, $user_id ); } @@ -590,7 +590,7 @@ private function sanitize_json( $json ) { */ $decoded = json_decode( $json ); if ( ! $decoded ) { - throw new \Apple_Actions\Action_Exception( __( 'The Apple News JSON is invalid and cannot be published.', 'apple-news' ) ); + throw new \Apple_Actions\Action_Exception( esc_html__( 'The Apple News JSON is invalid and cannot be published.', 'apple-news' ) ); } else { return wp_json_encode( $decoded ); } diff --git a/admin/class-admin-apple-bulk-export-page.php b/admin/class-admin-apple-bulk-export-page.php index 76cb25d80..276fd64d3 100644 --- a/admin/class-admin-apple-bulk-export-page.php +++ b/admin/class-admin-apple-bulk-export-page.php @@ -52,9 +52,9 @@ public function __construct( $settings ) { */ public function register_page() { add_submenu_page( - null, // Parent, if null, it won't appear in any menu. - __( 'Bulk Export', 'apple-news' ), // Page title. - __( 'Bulk Export', 'apple-news' ), // Menu title. + 'options.php', // Passing options.php means it won't appear in any menu. + __( 'Bulk Export', 'apple-news' ), // Page title. + __( 'Bulk Export', 'apple-news' ), // Menu title. /** * Filters the capability required to be able to access the Bulk Export page. * diff --git a/admin/class-admin-apple-index-page.php b/admin/class-admin-apple-index-page.php index 2370a734b..51adeb3ce 100644 --- a/admin/class-admin-apple-index-page.php +++ b/admin/class-admin-apple-index-page.php @@ -15,7 +15,7 @@ require_once plugin_dir_path( __FILE__ ) . 'apple-actions/index/class-section.php'; require_once plugin_dir_path( __FILE__ ) . 'class-admin-apple-news-list-table.php'; -use \Apple_Exporter\Workspace as Workspace; +use Apple_Exporter\Workspace; /** * A class to manage the index page of the Apple News admin interface. @@ -441,5 +441,4 @@ private function reset_action( $id ) { // This can only succeed. $this->notice_success( __( 'Your article status has been successfully reset!', 'apple-news' ) ); } - } diff --git a/admin/class-admin-apple-meta-boxes.php b/admin/class-admin-apple-meta-boxes.php index be83d0ee6..90b321c64 100644 --- a/admin/class-admin-apple-meta-boxes.php +++ b/admin/class-admin-apple-meta-boxes.php @@ -95,8 +95,10 @@ public function do_publish( $post_id, $post ) { return; } - // Check the nonce. - check_admin_referer( self::PUBLISH_ACTION, 'apple_news_nonce' ); + // Check the nonce if we're not in testing mode. + if ( ! defined( 'MANTLE_IS_TESTING' ) || ! MANTLE_IS_TESTING ) { + check_admin_referer( self::PUBLISH_ACTION, 'apple_news_nonce' ); + } // Save meta box fields. self::save_post_meta( $post_id ); @@ -448,7 +450,7 @@ public static function build_sections_field( $post_id ) { ?>
diff --git a/admin/class-admin-apple-news.php b/admin/class-admin-apple-news.php index a4cd6eb52..fc39a0e4a 100644 --- a/admin/class-admin-apple-news.php +++ b/admin/class-admin-apple-news.php @@ -183,11 +183,11 @@ public function __construct() { // Prevent Yoast Duplicate Post plugin from cloning apple_news meta. add_filter( 'duplicate_post_meta_keys_filter', - function( $meta_keys ) { + function ( $meta_keys ) { return is_array( $meta_keys ) ? array_filter( $meta_keys, - function( $key ) { + function ( $key ) { return substr( $key, 0, 11 ) !== 'apple_news_'; } ) @@ -197,7 +197,7 @@ function( $key ) { add_action( 'rest_api_init', - function() { + function () { $post_types = ! empty( self::$settings->post_types ) ? self::$settings->post_types : []; foreach ( $post_types as $post_type ) { diff --git a/admin/class-admin-apple-notice.php b/admin/class-admin-apple-notice.php index 0b3d153ac..a8976f63c 100644 --- a/admin/class-admin-apple-notice.php +++ b/admin/class-admin-apple-notice.php @@ -56,7 +56,7 @@ public static function clear( $notifications ) { // Sort and JSON-encode the removal array to simplify comparison. $notifications = array_map( - function( $value ) { + function ( $value ) { ksort( $value ); return wp_json_encode( $value ); }, diff --git a/admin/class-admin-apple-settings.php b/admin/class-admin-apple-settings.php index da5b06eec..8dbc5adb7 100644 --- a/admin/class-admin-apple-settings.php +++ b/admin/class-admin-apple-settings.php @@ -13,7 +13,7 @@ require_once plugin_dir_path( __FILE__ ) . 'settings/class-admin-apple-settings-section-post-types.php'; require_once plugin_dir_path( __FILE__ ) . 'settings/class-admin-apple-settings-section-developer-tools.php'; -use Apple_Exporter\Settings as Settings; +use Apple_Exporter\Settings; /** * This class is in charge of creating a WordPress page to manage the diff --git a/admin/class-admin-apple-themes.php b/admin/class-admin-apple-themes.php index fb36ef12e..43a08ab5d 100644 --- a/admin/class-admin-apple-themes.php +++ b/admin/class-admin-apple-themes.php @@ -478,7 +478,7 @@ public function setup_theme_pages() { // Add the edit theme page. add_submenu_page( - null, + 'options.php', __( 'Apple News Edit Theme', 'apple-news' ), __( 'Edit Theme', 'apple-news' ), /** This filter is documented in admin/class-admin-apple-settings.php */ diff --git a/admin/class-automation.php b/admin/class-automation.php index 13ac58191..77b7df585 100644 --- a/admin/class-automation.php +++ b/admin/class-automation.php @@ -133,7 +133,7 @@ public static function filter__apple_news_article_metadata( $metadata, $post_id $metadata_rules = array_values( array_filter( self::get_automation_for_post( $post_id ), - function( $rule ) { + function ( $rule ) { return 'article_metadata' === self::get_fields()[ $rule['field'] ]['location'] ?? ''; } ) @@ -179,7 +179,7 @@ public static function get_automation_for_post( int $post_id ): array { return array_values( array_filter( self::get_automation_rules(), - function( $rule ) use ( $post_id ) { + function ( $rule ) use ( $post_id ) { return has_term( $rule['term_id'] ?? '', $rule['taxonomy'] ?? '', $post_id ); } ) diff --git a/admin/partials/field-meta-component-order.php b/admin/partials/field-meta-component-order.php index af97fe6ab..1f4b0b983 100644 --- a/admin/partials/field-meta-component-order.php +++ b/admin/partials/field-meta-component-order.php @@ -18,7 +18,7 @@