From 4130b86eef4f9f88a6764a4f36a65260b7625f10 Mon Sep 17 00:00:00 2001 From: Scott Kingsley Clark Date: Wed, 27 Sep 2023 22:25:57 -0500 Subject: [PATCH 1/6] Add support for disabling Quick Edit for Post Types and Taxonomies in WP 6.4+ --- classes/PodsInit.php | 49 +++++++++++++++++++++++++++++++++++ src/Pods/Admin/Config/Pod.php | 20 ++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/classes/PodsInit.php b/classes/PodsInit.php index d2fd10aa73..7c8924a4a7 100644 --- a/classes/PodsInit.php +++ b/classes/PodsInit.php @@ -1167,6 +1167,7 @@ public function setup_content_types( $force = false ) { 'revisions' => (boolean) pods_v( 'supports_revisions', $post_type, false ), 'page-attributes' => (boolean) pods_v( 'supports_page_attributes', $post_type, false ), 'post-formats' => (boolean) pods_v( 'supports_post_formats', $post_type, false ), + 'quick-edit' => (boolean) pods_v( 'supports_quick_edit', $post_type, true ), ); // Custom Supported @@ -1811,6 +1812,50 @@ public function setup_content_types( $force = false ) { } } + /** + * Filter whether Quick Edit should be enabled for the given post type. + * + * @since TBD + * + * @param bool $enable Whether to enable the Quick Edit functionality. + * @param string $post_type The post type name. + * + * @return bool Whether to enable the Quick Edit functionality. + */ + public function quick_edit_enabled_for_post_type( bool $enable, string $post_type ) { + if ( ! $enable ) { + return $enable; + } + + if ( ! isset( PodsMeta::$post_types[ $post_type ] ) ) { + return $enable; + } + + return (boolean) pods_v( 'supports_quick_edit', PodsMeta::$post_types[ $post_type ], true ); + } + + /** + * Filter whether Quick Edit should be enabled for the given taxonomy. + * + * @since TBD + * + * @param bool $enable Whether to enable the Quick Edit functionality. + * @param string $taxonomy The taxonomy name. + * + * @return bool Whether to enable the Quick Edit functionality. + */ + public function quick_edit_enabled_for_taxonomy( bool $enable, string $taxonomy ) { + if ( ! $enable ) { + return $enable; + } + + if ( ! isset( PodsMeta::$taxonomies[ $taxonomy ] ) ) { + return $enable; + } + + return (boolean) pods_v( 'supports_quick_edit', PodsMeta::$taxonomies[ $taxonomy ], true ); + } + /** * Check if we need to flush WordPress rewrite rules * This gets run during 'init' action late in the game to give other plugins time to register their rewrite rules @@ -2438,6 +2483,10 @@ public function run() { // Compatibility for Query Monitor conditionals add_filter( 'query_monitor_conditionals', array( $this, 'filter_query_monitor_conditionals' ) ); + + // Support for quick edit in WP 6.4+. + add_filter( 'quick_edit_enabled_for_post_type', [ $this, 'quick_edit_enabled_for_post_type' ], 10, 2 ); + add_filter( 'quick_edit_enabled_for_taxonomy', [ $this, 'quick_edit_enabled_for_taxonomy' ], 10, 2 ); } /** diff --git a/src/Pods/Admin/Config/Pod.php b/src/Pods/Admin/Config/Pod.php index ccc50627de..7adbdd25fd 100644 --- a/src/Pods/Admin/Config/Pod.php +++ b/src/Pods/Admin/Config/Pod.php @@ -1015,6 +1015,16 @@ public function get_fields( \Pods\Whatsit\Pod $pod, array $tabs ) { ], ]; + // Add support for disabling Quick Edit in WP 6.4+. + if ( pods_version_check( 'wp', '6.4-beta-1' ) ) { + $options['advanced']['post_type_supports']['boolean_group']['supports_quick_edit'] = [ + 'name' => 'supports_quick_edit', + 'label' => __( 'Quick Edit', 'pods' ), + 'type' => 'boolean', + 'default' => 1, + ]; + } + /** * Allow filtering the list of supported features for the post type * @@ -1322,6 +1332,16 @@ public function get_fields( \Pods\Whatsit\Pod $pod, array $tabs ) { ], ]; + // Add support for disabling Quick Edit in WP 6.4+. + if ( pods_version_check( 'wp', '6.4-beta-1' ) ) { + $options['advanced']['supports_quick_edit'] = [ + 'name' => 'supports_quick_edit', + 'label' => __( 'Enable Quick Edit', 'pods' ), + 'type' => 'boolean', + 'default' => 1, + ]; + } + $related_objects = PodsForm::field_method( 'pick', 'related_objects', true ); $available_post_types = []; From 115389f8659237d3b1c75684d1bd53c003bbea53 Mon Sep 17 00:00:00 2001 From: Scott Kingsley Clark Date: Fri, 17 Nov 2023 10:13:08 -0600 Subject: [PATCH 2/6] Remove extra things we won't use Keep open collective as we may end up switching over to that in the future --- .github/FUNDING.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index d5facf61d8..39ae7ee339 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,12 +1,5 @@ # These are supported funding model platforms github: pods-framework, sc0ttkclark # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -otechie: # Replace with a single Otechie username custom: https://friends.pods.io # Replace with a single custom sponsorship URL From 6434bce296a9216b1c52e73750f22a7feffdf781 Mon Sep 17 00:00:00 2001 From: Scott Kingsley Clark Date: Wed, 6 Dec 2023 12:32:45 -0600 Subject: [PATCH 3/6] Add action for wporg replace --- .github/workflows/wporg-replace.yml | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/wporg-replace.yml diff --git a/.github/workflows/wporg-replace.yml b/.github/workflows/wporg-replace.yml new file mode 100644 index 0000000000..2074add181 --- /dev/null +++ b/.github/workflows/wporg-replace.yml @@ -0,0 +1,42 @@ +name: WordPress.org Replace Strings +env: + WPORG_PLUGIN_VERSION_CONSTANT_NAME: 'PODS_VERSION' + WPORG_MINIMUM_WP_VERSION_CONSTANT_NAME: 'PODS_WP_VERSION_MINIMUM' + WPORG_MINIMUM_PHP_VERSION_CONSTANT_NAME: 'PODS_PHP_VERSION_MINIMUM' +on: + workflow_dispatch: + inputs: + plugin_version: + description: 'Plugin version' + required: false + tested_wp_version: + description: 'Tested up to WP version' + required: false + minimum_wp_version: + description: 'Minimum WP version' + required: false + minimum_php_version: + description: 'Minimum PHP version' + required: false + plugin_file: + description: 'Plugin file' + required: false +jobs: + prepare_release: + runs-on: ubuntu-latest + steps: + - name: Checkout the code + uses: actions/checkout@v4 + - name: Run wporg-replace + uses: sc0ttkclark/wporg-replace@v1 + with: + plugin_version: ${{ github.event.inputs.plugin_version }} + plugin_version_constant_name: ${{ env.WPORG_PLUGIN_VERSION_CONSTANT_NAME }} + tested_wp_version: ${{ github.event.inputs.tested_wp_version }} + tested_wp_version_constant_name: ${{ env.WPORG_TESTED_WP_VERSION_CONSTANT_NAME }} + minimum_wp_version: ${{ github.event.inputs.minimum_wp_version }} + minimum_wp_version_constant_name: ${{ env.WPORG_MINIMUM_WP_VERSION_CONSTANT_NAME }} + minimum_php_version: ${{ github.event.inputs.minimum_php_version }} + minimum_php_version_constant_name: ${{ env.WPORG_MINIMUM_PHP_VERSION_CONSTANT_NAME }} + plugin_file: ${{ github.event.inputs.plugin_file }} + plugin_path: ${{ github.workspace }} From 811078b57ae1e0a1347091086e5ea578a4dc5d1d Mon Sep 17 00:00:00 2001 From: Scott Kingsley Clark Date: Wed, 6 Dec 2023 12:39:50 -0600 Subject: [PATCH 4/6] More updates including auto-commit --- .github/workflows/wporg-replace.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/wporg-replace.yml b/.github/workflows/wporg-replace.yml index 2074add181..714683609b 100644 --- a/.github/workflows/wporg-replace.yml +++ b/.github/workflows/wporg-replace.yml @@ -1,5 +1,6 @@ name: WordPress.org Replace Strings env: + WPORG_PLUGIN_FILE: 'init.php' WPORG_PLUGIN_VERSION_CONSTANT_NAME: 'PODS_VERSION' WPORG_MINIMUM_WP_VERSION_CONSTANT_NAME: 'PODS_WP_VERSION_MINIMUM' WPORG_MINIMUM_PHP_VERSION_CONSTANT_NAME: 'PODS_PHP_VERSION_MINIMUM' @@ -18,9 +19,6 @@ on: minimum_php_version: description: 'Minimum PHP version' required: false - plugin_file: - description: 'Plugin file' - required: false jobs: prepare_release: runs-on: ubuntu-latest @@ -38,5 +36,16 @@ jobs: minimum_wp_version_constant_name: ${{ env.WPORG_MINIMUM_WP_VERSION_CONSTANT_NAME }} minimum_php_version: ${{ github.event.inputs.minimum_php_version }} minimum_php_version_constant_name: ${{ env.WPORG_MINIMUM_PHP_VERSION_CONSTANT_NAME }} - plugin_file: ${{ github.event.inputs.plugin_file }} + plugin_file: ${{ env.WPORG_PLUGIN_FILE }} plugin_path: ${{ github.workspace }} + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + file_pattern: ${{ env.WPORG_PLUGIN_FILE }} readme.txt package.json + commit_message: Update wporg version(s) + - name: "Run if changes have been detected" + if: steps.auto-commit-action.outputs.changes_detected == 'true' + run: echo "Changes!" + - name: "Run if no changes have been detected" + if: steps.auto-commit-action.outputs.changes_detected == 'false' + run: echo "No Changes!" From de5e02fdb9a656a49c9405c3cf2005fa2c4dfccc Mon Sep 17 00:00:00 2001 From: Scott Kingsley Clark Date: Wed, 6 Dec 2023 12:47:36 -0600 Subject: [PATCH 5/6] Update version number for action --- .github/workflows/wporg-replace.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wporg-replace.yml b/.github/workflows/wporg-replace.yml index 714683609b..8dfe13f198 100644 --- a/.github/workflows/wporg-replace.yml +++ b/.github/workflows/wporg-replace.yml @@ -26,7 +26,7 @@ jobs: - name: Checkout the code uses: actions/checkout@v4 - name: Run wporg-replace - uses: sc0ttkclark/wporg-replace@v1 + uses: sc0ttkclark/wporg-replace@v1.0.0 with: plugin_version: ${{ github.event.inputs.plugin_version }} plugin_version_constant_name: ${{ env.WPORG_PLUGIN_VERSION_CONSTANT_NAME }} From 4e6e5883aaf63d6373616cc8ffab9a2167b44e80 Mon Sep 17 00:00:00 2001 From: Scott Kingsley Clark Date: Wed, 6 Dec 2023 12:52:35 -0600 Subject: [PATCH 6/6] Update the output of what we are doing --- .github/workflows/wporg-replace.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/wporg-replace.yml b/.github/workflows/wporg-replace.yml index 8dfe13f198..a8d810a231 100644 --- a/.github/workflows/wporg-replace.yml +++ b/.github/workflows/wporg-replace.yml @@ -25,6 +25,12 @@ jobs: steps: - name: Checkout the code uses: actions/checkout@v4 + - name: What are we doing? + run: | + echo plugin_version: ${{ github.event.inputs.plugin_version }} + echo tested_wp_version: ${{ github.event.inputs.tested_wp_version }} + echo minimum_wp_version: ${{ github.event.inputs.minimum_wp_version }} + echo minimum_php_version: ${{ github.event.inputs.minimum_php_version }} - name: Run wporg-replace uses: sc0ttkclark/wporg-replace@v1.0.0 with: