New customisable rewrite bases for post types & taxonomies#812
New customisable rewrite bases for post types & taxonomies#812mauteri merged 21 commits intoGatherPress:mainfrom
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
I didn't found anything like this in the existing codebase, so I just used https://developer.wordpress.org/reference/hooks/update_option_option/. |
|
I would like to introduce a new and breaking change here: Please let us consider plurals as the post type bases, not the singulars like it is! |
Isn't singular the norm? For example, category pages by default are domain.com/category/term. |
|
I ❤️ the new spell checker! |
|
@carstingaxion I'm getting
|
|
Ah. Du you remember one of your last reviews? I should change site_url() to home_url(). But I only did that in php. 🙄 I'll fix that. |
src/components/UrlRewritePreview.js
Outdated
|
|
||
| return ( | ||
| <> | ||
| {window.GatherPress.urls.homeUrl + '/'} |
There was a problem hiding this comment.
Sorry, missed usage of this. There's a getFromGlobal helper you can use here. Has build in error handling and such.
getFromGlobal('urls.homeUrl')
There was a problem hiding this comment.
Will be fixed.
btw. I asked chatgpt how to avoid that in the future
How to write an eslint rule that checks if there is any window.gatherpress inside the code and suggests to use foo instead?
To create a custom ESLint rule that checks for the presence of window.gatherpress in your code and suggests using foo instead, you can follow these steps:
-
Set Up Your ESLint Environment: Make sure you have ESLint installed in your project. If you haven't done this yet, you can install it using npm:
npm install eslint --save-dev
-
Create a Custom Rule: You can create a custom ESLint rule by defining it in a JavaScript file. For example, create a file named
no-gatherpress.jsin a directory calledeslint-rules. -
Implement the Rule: In the
no-gatherpress.jsfile, you can implement the rule as follows:module.exports = { meta: { type: 'suggestion', // This rule is a suggestion docs: { description: 'disallow window.gatherpress and suggest using foo instead', category: 'Best Practices', recommended: false, }, schema: [], // No options }, create(context) { return { MemberExpression(node) { // Check if the expression is window.gatherpress if ( node.object.name === 'window' && node.property.name === 'gatherpress' ) { context.report({ node, message: 'Use foo instead of window.gatherpress.', }); } }, }; }, };
-
Configure ESLint to Use Your Custom Rule: In your ESLint configuration file (e.g.,
.eslintrc.js), you need to include your custom rule. Here’s an example of how to do that:module.exports = { // Your existing ESLint configuration rules: { 'no-gatherpress': 'warn', // or 'error' if you want it to be an error }, overrides: [ { files: ['*.js'], // Specify the files where the rule should apply rules: { 'no-gatherpress': require('./eslint-rules/no-gatherpress'), }, }, ], };
-
Run ESLint: Now you can run ESLint on your codebase, and it will warn you whenever it finds
window.gatherpress, suggesting to usefooinstead.npx eslint your-file.js
Summary
This custom ESLint rule checks for the usage of window.gatherpress and suggests using foo instead. You can adjust the severity of the rule (e.g., warn or error) based on your preference. Make sure to test the rule in your codebase to ensure it works as expected.
Preview changes with PlaygroundYou can preview the least recent changes for PR#812 by following one of the links below: |
|
Looks good, thanks! Merging! |


Description of the Change
This PR introduces a new settings section under GatherPress’ general settings to customise the rewrite slug for public post types and taxonomies.
If nothing is set, a localised string will be used, that is sanitised for use as part of an URL.
Screenshot with localised German defaults.
Closes #722
How to test the Change
Changelog Entry
Credits
Props @carstingaxion
Checklist: