Skip to content

Commit

Permalink
Merge pull request #7189 from pods-framework/feature/support-disablin…
Browse files Browse the repository at this point in the history
…g-quick-edit
  • Loading branch information
sc0ttkclark authored Dec 7, 2023
2 parents 6917ebe + 2b683ba commit 1ba4f00
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 7 deletions.
7 changes: 0 additions & 7 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -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
49 changes: 49 additions & 0 deletions classes/PodsInit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2439,6 +2484,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 );

require_once PODS_DIR . 'includes/compatibility.php';
}

Expand Down
20 changes: 20 additions & 0 deletions src/Pods/Admin/Config/Pod.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1ba4f00

Please sign in to comment.