Skip to content

Commit

Permalink
Merge pull request #6 from tarosky/bugfix/title
Browse files Browse the repository at this point in the history
Avoid root CPT to be considered as "is_home"
  • Loading branch information
fumikito authored Feb 2, 2025
2 parents d8449d1 + 2f48559 commit dde06e8
Show file tree
Hide file tree
Showing 12 changed files with 1,600 additions and 291 deletions.
41 changes: 0 additions & 41 deletions .eslintrc

This file was deleted.

27 changes: 5 additions & 22 deletions .github/workflows/wordpress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,11 @@ jobs:
with:
version: 7.4

assets:
name: Check Assets
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main

- name: Install Node
uses: actions/setup-node@v4
with:
node-version: '12'

- name: Install NPM Packages
run: npm install

- name: Check JS & CSS syntax
run: npm run lint

status-check:
name: Status Check
runs-on: ubuntu-latest
if: always()
needs: [ lint, assets ]
needs: [ lint ]
steps:
- uses: re-actors/alls-green@release/v1
with:
Expand All @@ -99,10 +82,10 @@ jobs:
php-version: '7.4'
tools: composer

- name: Install NPM
uses: actions/setup-node@v4
with:
node-version: '12'
# - name: Install NPM
# uses: actions/setup-node@v4
# with:
# node-version: '18'

- name: Build package.
run: bash bin/build.sh ${{ github.ref }}
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
/wordpress
/dist
composer.lock
package-lock.json
wp-dependencies.json
16 changes: 0 additions & 16 deletions .stylelintrc.json

This file was deleted.

3 changes: 2 additions & 1 deletion .wp-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"core": null,
"plugins": [
".",
"https://downloads.wordpress.org/plugin/custom-post-type-ui.latest-stable.zip"
"https://downloads.wordpress.org/plugin/custom-post-type-ui.latest-stable.zip",
"https://downloads.wordpress.org/plugin/query-monitor.latest-stable.zip"
],
"themes": [
"https://downloads.wordpress.org/theme/twentytwenty.latest-stable.zip"
Expand Down
4 changes: 2 additions & 2 deletions bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ echo "Building Taro CPT Front v${VERSION}..."
# composer install --no-dev --prefer-dist

# Install NPM.
npm install
npm run package
#npm install
#npm run package

# Create README.txt
curl -L https://raw.githubusercontent.com/fumikito/wp-readme/master/wp-readme.php | php
Expand Down
122 changes: 0 additions & 122 deletions gulpfile.js

This file was deleted.

39 changes: 29 additions & 10 deletions includes/rewrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,34 @@
if ( ! $is_front ) {
return;
}
// Search post type root.
$sub_query = new WP_Query( [
'post_type' => $is_front,
'posts_per_page' => 1,
'no_found_rows' => true,
'ignore_sticky' => true,
'meta_query' => [
[
'key' => '_tscptf_is_front',
'value' => '1',
],
],
] );
// Not found.
if ( ! $sub_query->have_posts() ) {
$wp_query->is_404 = true;
return;
}
// Rebuild query vars for single page.
$front_page = $sub_query->posts[0];
$wp_query->set( 'root_of', '' );
$wp_query->set( 'p', $front_page->ID );
$wp_query->set( 'post_type', $is_front );
$wp_query->set( 'posts_per_page', 1 );
$wp_query->set( 'no_found_rows', true );
$wp_query->set( 'ignore_sticky', true );
$wp_query->set( 'meta_query', array(
array(
'key' => '_tscptf_is_front',
'value' => '1',
),
) );
$wp_query->singular = true;
// Set post type object.
$wp_query->queried_object = $front_page;
$wp_query->queried_object_id = $front_page->ID;
// Set flags.
$wp_query->is_singular = true;
$wp_query->is_single = true;
$wp_query->is_home = false;
} );
Loading

0 comments on commit dde06e8

Please sign in to comment.