Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/static-linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Static Linting

on:
pull_request:
push:
branches:
- trunk

jobs:
php:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Install dependencies
uses: php-actions/composer@v6
- name: Lint PHP files
run: composer run lint

name: PHP Files

other:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 20.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install
- name: Lint JavaScript files
run: npm run lint:js
env:
CI: true

name: Javascript, CSS, and package.json
2 changes: 1 addition & 1 deletion _blueprints/cpt-demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,6 @@ function register_stream_post_type() {
);

register_taxonomy( 'genre', array( 'twitch-stream' ), $args );

}

add_action( 'init', 'register_stream_post_type' );
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"composer update",
"composer dump-autoload"
],
"phpunit": "vendor/bin/phpunit"
"phpunit": "vendor/bin/phpunit",
"lint": "./vendor/bin/phpcs . --standard=phpcs.xml"
}
}
7 changes: 3 additions & 4 deletions includes/Traits/Exclude_Taxonomies.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ trait Exclude_Taxonomies {
*/
public function process_exclude_taxonomies(): void {
$taxonomies_to_exclude = $this->custom_params['exclude_taxonomies'];
if( count( $taxonomies_to_exclude ) ) {
if ( count( $taxonomies_to_exclude ) ) {
$tax_query = [];
foreach ( $taxonomies_to_exclude as $slug ) {
$tax_query[] = [
$tax_query[] = [
'taxonomy' => $slug,
'operator' => 'NOT EXISTS'
'operator' => 'NOT EXISTS',
];
}
$this->custom_args['tax_query'] = $tax_query;
}
}
}

8 changes: 6 additions & 2 deletions includes/query-loop.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ function ( $default_query, $block ) {
\add_action(
'init',
function () {
$registered_post_types = \get_post_types( array( 'show_in_rest' => true, 'public' => true ) );
$registered_post_types = \get_post_types(
array(
'show_in_rest' => true,
'public' => true,
)
);
foreach ( $registered_post_types as $registered_post_type ) {
\add_filter( 'rest_' . $registered_post_type . '_query', __NAMESPACE__ . '\add_custom_query_params', 10, 2 );

Expand All @@ -116,7 +121,6 @@ function () {
* @see https://developer.wordpress.org/reference/classes/wp_rest_posts_controller/get_collection_params/
*
* @param array $query_params The query params.
* @param array $post_type The post type.
*
* @return array
*/
Expand Down
1 change: 0 additions & 1 deletion includes/utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ function is_core_version_or_higher( string $version ) {
$core = get_bloginfo( 'version' );
return version_compare( $core, $version, '>=' );
}

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"start:hot": "wp-scripts start --hot",
"build": "wp-scripts build",
"plugin-zip": "wp-scripts plugin-zip",
"lint:js": "wp-scripts lint-js",
"lint:php": "composer run lint",
"format": "wp-scripts format",
"wp-env": "wp-env",
"release": "composer run build && npm run build && npm run plugin-zip",
Expand Down
5 changes: 3 additions & 2 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<exclude-pattern>*/phpunit.xml*</exclude-pattern>
<exclude-pattern>*/dist/*</exclude-pattern>
<exclude-pattern>*/languages/*</exclude-pattern>
<exclude-pattern>*/build/*</exclude-pattern>

<!-- Third-party code -->
<exclude-pattern>*/bower-components/*</exclude-pattern>
Expand Down Expand Up @@ -40,7 +41,6 @@
<!-- Dont need to capitalize first letter -->
<exclude name="Generic.Commenting.DocComment.ShortNotCapital"/>
</rule>

<rule ref="WordPress-Extra">
<!-- Forget about file names -->
<exclude name="WordPress.Files.FileName"/>
Expand All @@ -64,6 +64,7 @@

<!-- Allow shorthand array syntax -->
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found"/>
<exclude name="Universal.Arrays.DisallowShortArraySyntax.Found" />

<!-- Allow WP global modification -->
<exclude name="WordPress.WP.GlobalVariablesOverride.Prohibited"/>
Expand All @@ -88,4 +89,4 @@
<!-- PHP version check. -->
<config name="testVersion" value="8.1-"/>

</ruleset>
</ruleset>
13 changes: 3 additions & 10 deletions src/components/post-exclude-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ export const PostExcludeControls = ( {
setAttributes,
allowedControls,
} ) => {
const {
query: {
exclude_current: excludeCurrent,
exclude_posts: excludePosts = [],
} = {},
} = attributes;

// If the control is not allowed, return null.
if (
! allowedControls.includes( 'exclude_current_post' ) &&
Expand Down Expand Up @@ -154,7 +147,7 @@ const ExcludeCurrentPostControl = ( {
* @param {Function} props.setAttributes Function to update the block attributes.
* @param {Array} props.allowedControls List of controls allowed for the current context.
*
* @returns {Element|null} Returns the control for selecting excluded posts,
* @return {Element|null} Returns the control for selecting excluded posts,
* or null if the 'exclude_posts' control is not allowed.
*/
const ExcludePostsControl = ( {
Expand All @@ -177,9 +170,9 @@ const ExcludePostsControl = ( {

// Fetch posts for each post type and combine them into one array
return [ ...multiplePosts, postType ].reduce(
( accumulator, postType ) => {
( accumulator, type ) => {
// Depending on the number of posts this could take a while, since we can't paginate here
const records = getEntityRecords( 'postType', postType, {
const records = getEntityRecords( 'postType', type, {
per_page: -1,
} );
return [ ...accumulator, ...( records || [] ) ];
Expand Down
1 change: 0 additions & 1 deletion src/components/post-meta-query-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { useEffect, useState } from '@wordpress/element';
* Internal dependencies
*/
import { PostMetaControl } from './post-meta-control';
import useRegisteredMeta from '../hooks/useRegisteredMeta';

/**
* Converts the meta keys from the all sources into a single array.
Expand Down
18 changes: 0 additions & 18 deletions src/hooks/useRegisteredMeta.js

This file was deleted.

1 change: 0 additions & 1 deletion tests/unit/Date_Query_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,5 @@ public function test_all_ranges_return_expected( $custom_data, $expected_results

// Empty arrays return empty.
$this->assertSame( $expected_results, $qpg->get_query_args() );

}
}
4 changes: 4 additions & 0 deletions tests/unit/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php
/**
* Bootstrap for tests.
*/

if ( ! function_exists( 'apply_filters' ) ) {
function apply_filters( $tag, $value ) {
return $value;
Expand Down
Loading