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 = [];