From 09ff7f7971830f7dc4a119902a2e9eb25876ed18 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Thu, 31 Oct 2024 12:27:26 -0400 Subject: [PATCH 01/13] register training post type --- wp-content/plugins/core/src/Core.php | 1 + .../core/src/Post_Types/Training/Config.php | 49 +++++++++++++++++++ .../core/src/Post_Types/Training/Training.php | 11 +++++ .../Training/Training_Subscriber.php | 24 +++++++++ 4 files changed, 85 insertions(+) create mode 100644 wp-content/plugins/core/src/Post_Types/Training/Config.php create mode 100644 wp-content/plugins/core/src/Post_Types/Training/Training.php create mode 100644 wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php diff --git a/wp-content/plugins/core/src/Core.php b/wp-content/plugins/core/src/Core.php index 833ca084..14d7623e 100644 --- a/wp-content/plugins/core/src/Core.php +++ b/wp-content/plugins/core/src/Core.php @@ -34,6 +34,7 @@ class Core { // Post Types Post_Types\Page\Page_Subscriber::class, Post_Types\Post\Post_Subscriber::class, + Post_Types\Training\Training_Subscriber::class, ]; private static self $instance; diff --git a/wp-content/plugins/core/src/Post_Types/Training/Config.php b/wp-content/plugins/core/src/Post_Types/Training/Config.php new file mode 100644 index 00000000..5ccf0561 --- /dev/null +++ b/wp-content/plugins/core/src/Post_Types/Training/Config.php @@ -0,0 +1,49 @@ + false, + 'hierarchical' => false, + 'menu_icon' => 'dashicons-welcome-learn-more', + 'map_meta_cap' => true, + 'supports' => [ 'title', 'editor', 'thumbnail', 'excerpt', 'revisions' ], + 'rewrite' => [ 'slug' => 'company/news' ], + 'capability_type' => 'post', + 'show_in_rest' => true, + 'menu_position' => 19, + ]; + } + + public function get_labels(): array { + return [ + 'singular' => __( 'Training', 'tribe' ), + 'plural' => __( 'Training', 'tribe' ), + 'slug' => Training::NAME, + ]; + } + + /** + * Define block templates for initial editor state + */ + public function register_block_template(): void { + $post_type_object = get_post_type_object( Training::NAME ); + $post_type_object->template = [ + [ + 'core/pattern', + [ + 'slug' => 'patterns/page', // Use patterns for Pages. + ], + ], + ]; + } + +} diff --git a/wp-content/plugins/core/src/Post_Types/Training/Training.php b/wp-content/plugins/core/src/Post_Types/Training/Training.php new file mode 100644 index 00000000..e7f0c564 --- /dev/null +++ b/wp-content/plugins/core/src/Post_Types/Training/Training.php @@ -0,0 +1,11 @@ +block_templates(); + } + + public function block_templates(): void { + add_action( 'init', function (): void { + $this->container->get( Config::class )->register_block_template(); + } ); + } + +} From 1f92ba00b691c720c3c10b0a7ffb735b418479a5 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Thu, 31 Oct 2024 13:40:11 -0400 Subject: [PATCH 02/13] prevent public access to training cpt --- .../core/src/Post_Types/Training/Config.php | 87 ++++++++++++++++--- .../Post_Types/Training/Rest_Controller.php | 19 ++++ .../Training/Training_Subscriber.php | 33 ++++++- 3 files changed, 128 insertions(+), 11 deletions(-) create mode 100644 wp-content/plugins/core/src/Post_Types/Training/Rest_Controller.php diff --git a/wp-content/plugins/core/src/Post_Types/Training/Config.php b/wp-content/plugins/core/src/Post_Types/Training/Config.php index 5ccf0561..f43a2893 100644 --- a/wp-content/plugins/core/src/Post_Types/Training/Config.php +++ b/wp-content/plugins/core/src/Post_Types/Training/Config.php @@ -11,15 +11,21 @@ class Config extends Post_Type_Config { public function get_args(): array { return [ - 'has_archive' => false, - 'hierarchical' => false, - 'menu_icon' => 'dashicons-welcome-learn-more', - 'map_meta_cap' => true, - 'supports' => [ 'title', 'editor', 'thumbnail', 'excerpt', 'revisions' ], - 'rewrite' => [ 'slug' => 'company/news' ], - 'capability_type' => 'post', - 'show_in_rest' => true, - 'menu_position' => 19, + 'capability_type' => $this->post_type, + 'delete_with_user' => false, + 'exclude_from_search' => true, + 'has_archive' => false, + 'hierarchical' => false, + 'map_meta_cap' => false, + 'menu_icon' => 'dashicons-welcome-learn-more', + 'menu_position' => 19, + 'public' => true, + 'publicly_queryable' => true, + 'rewrite' => [ 'slug' => 'training', 'with_front' => false ], + 'rest_controller_class' => Rest_Controller::class, + 'show_in_rest' => true, + 'show_in_nav_menus' => false, + 'supports' => [ 'title', 'editor', 'thumbnail', 'excerpt', 'revisions' ], ]; } @@ -35,7 +41,7 @@ public function get_labels(): array { * Define block templates for initial editor state */ public function register_block_template(): void { - $post_type_object = get_post_type_object( Training::NAME ); + $post_type_object = get_post_type_object( $this->post_type ); $post_type_object->template = [ [ 'core/pattern', @@ -46,4 +52,65 @@ public function register_block_template(): void { ]; } + /** + * Add capabilities to user roles. + */ + public function add_user_caps(): void { + global $wp_roles; + + if ( ! $wp_roles || ! is_object( $wp_roles ) || ! property_exists( $wp_roles, 'roles' ) || ! is_array( $wp_roles->roles ) ) { + return; + } + + $post_type_object = get_post_type_object( $this->post_type ); + $all_roles = array_keys( $wp_roles->roles ); + + foreach ( $all_roles as $role ) { + if ( 'subscriber' === $role ) { + continue; + } + + $role = get_role( $role ); + + foreach ( (array) $post_type_object->cap as $cap ) { + $role->add_cap( $cap ); + } + } + } + + /** + * Check the user is authorized to read the post; + * if not, send and display 404. + */ + public function send_404_unauthorized(): void { + if ( is_post_type_viewable( $this->post_type ) ) { + return; + } + + global $wp_query; + + $wp_query->set_404(); + status_header( 404 ); + nocache_headers(); + + require_once get_query_template( '404' ); + + exit(); + } + + /** + * Indicate if the post type is viewable. + */ + public function current_user_can_read( $bool, $post_type_object ): bool { + if ( ! $bool ) { + return false; + } + + if ( $post_type_object->name !== $this->post_type ) { + return true; + } + + return current_user_can( $post_type_object->cap->read_post ); + } + } diff --git a/wp-content/plugins/core/src/Post_Types/Training/Rest_Controller.php b/wp-content/plugins/core/src/Post_Types/Training/Rest_Controller.php new file mode 100644 index 00000000..d4481aac --- /dev/null +++ b/wp-content/plugins/core/src/Post_Types/Training/Rest_Controller.php @@ -0,0 +1,19 @@ +check_is_post_type_allowed( $post_type_object ) ) { + return false; + } + + return is_post_type_viewable( $post_type_object ); + } + +} diff --git a/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php b/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php index 3c52bfeb..d2ddbd6d 100644 --- a/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php +++ b/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php @@ -12,13 +12,44 @@ class Training_Subscriber extends Post_Type_Subscriber { public function register(): void { parent::register(); - $this->block_templates(); + $this->block_templates(); + $this->user_permissions(); } public function block_templates(): void { add_action( 'init', function (): void { $this->container->get( Config::class )->register_block_template(); } ); + + add_filter ( 'manage_training_posts_columns', function ( $columns ) { + unset( + $columns['wpseo-score'], + $columns['wpseo-title'], + $columns['wpseo-metadesc'], + $columns['wpseo-focuskw'], + $columns['wpseo-score-readability'], + $columns['wpseo-links'], + $columns['wpseo-linked'], + ); + + return $columns; + }, 99 ); + } + + public function user_permissions(): void { + add_action( 'init', function (): void { + $this->container->get( Config::class )->add_user_caps(); + } ); + + // Useful for excluding from sitemaps and controlling user access. + add_filter( 'is_post_type_viewable', function ( $bool, $post_type_object ): bool { + return $this->container->get( Config::class )->current_user_can_read( $bool, $post_type_object ); + }, 10, 2 ); + + // Send 404 for unauthorized users. + add_action( 'template_redirect', function (): void { + $this->container->get( Config::class )->send_404_unauthorized(); + } ); } } From d771f768048e242a33ec60fed19cc2fcc7e42b8b Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Thu, 31 Oct 2024 13:42:20 -0400 Subject: [PATCH 03/13] remove yoast-seo adjustments --- .../Post_Types/Training/Training_Subscriber.php | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php b/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php index d2ddbd6d..4b5e3f78 100644 --- a/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php +++ b/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php @@ -20,20 +20,6 @@ public function block_templates(): void { add_action( 'init', function (): void { $this->container->get( Config::class )->register_block_template(); } ); - - add_filter ( 'manage_training_posts_columns', function ( $columns ) { - unset( - $columns['wpseo-score'], - $columns['wpseo-title'], - $columns['wpseo-metadesc'], - $columns['wpseo-focuskw'], - $columns['wpseo-score-readability'], - $columns['wpseo-links'], - $columns['wpseo-linked'], - ); - - return $columns; - }, 99 ); } public function user_permissions(): void { From 9a3a52ea80b886d4d8e3eb5a906c0f655551552f Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Thu, 31 Oct 2024 14:10:55 -0400 Subject: [PATCH 04/13] change show_in_rest check, and use class property --- .../core/src/Post_Types/Training/Config.php | 7 +++---- .../Post_Types/Training/Rest_Controller.php | 19 ------------------- 2 files changed, 3 insertions(+), 23 deletions(-) delete mode 100644 wp-content/plugins/core/src/Post_Types/Training/Rest_Controller.php diff --git a/wp-content/plugins/core/src/Post_Types/Training/Config.php b/wp-content/plugins/core/src/Post_Types/Training/Config.php index f43a2893..ed659457 100644 --- a/wp-content/plugins/core/src/Post_Types/Training/Config.php +++ b/wp-content/plugins/core/src/Post_Types/Training/Config.php @@ -21,10 +21,9 @@ public function get_args(): array { 'menu_position' => 19, 'public' => true, 'publicly_queryable' => true, - 'rewrite' => [ 'slug' => 'training', 'with_front' => false ], - 'rest_controller_class' => Rest_Controller::class, - 'show_in_rest' => true, + 'rewrite' => [ 'slug' => $this->post_type, 'with_front' => false ], 'show_in_nav_menus' => false, + 'show_in_rest' => current_user_can( 'read_' . $this->post_type ), 'supports' => [ 'title', 'editor', 'thumbnail', 'excerpt', 'revisions' ], ]; } @@ -33,7 +32,7 @@ public function get_labels(): array { return [ 'singular' => __( 'Training', 'tribe' ), 'plural' => __( 'Training', 'tribe' ), - 'slug' => Training::NAME, + 'slug' => $this->post_type, ]; } diff --git a/wp-content/plugins/core/src/Post_Types/Training/Rest_Controller.php b/wp-content/plugins/core/src/Post_Types/Training/Rest_Controller.php deleted file mode 100644 index d4481aac..00000000 --- a/wp-content/plugins/core/src/Post_Types/Training/Rest_Controller.php +++ /dev/null @@ -1,19 +0,0 @@ -check_is_post_type_allowed( $post_type_object ) ) { - return false; - } - - return is_post_type_viewable( $post_type_object ); - } - -} From b589baea6954c6256ad210aacc5636b697c77d9b Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Thu, 31 Oct 2024 14:18:38 -0400 Subject: [PATCH 05/13] eliminate code smells --- .../core/src/Post_Types/Training/Config.php | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/wp-content/plugins/core/src/Post_Types/Training/Config.php b/wp-content/plugins/core/src/Post_Types/Training/Config.php index ed659457..eb45e173 100644 --- a/wp-content/plugins/core/src/Post_Types/Training/Config.php +++ b/wp-content/plugins/core/src/Post_Types/Training/Config.php @@ -11,20 +11,20 @@ class Config extends Post_Type_Config { public function get_args(): array { return [ - 'capability_type' => $this->post_type, - 'delete_with_user' => false, - 'exclude_from_search' => true, - 'has_archive' => false, - 'hierarchical' => false, - 'map_meta_cap' => false, - 'menu_icon' => 'dashicons-welcome-learn-more', - 'menu_position' => 19, - 'public' => true, - 'publicly_queryable' => true, - 'rewrite' => [ 'slug' => $this->post_type, 'with_front' => false ], - 'show_in_nav_menus' => false, - 'show_in_rest' => current_user_can( 'read_' . $this->post_type ), - 'supports' => [ 'title', 'editor', 'thumbnail', 'excerpt', 'revisions' ], + 'capability_type' => $this->post_type, + 'delete_with_user' => false, + 'exclude_from_search' => true, + 'has_archive' => false, + 'hierarchical' => false, + 'map_meta_cap' => false, + 'menu_icon' => 'dashicons-welcome-learn-more', + 'menu_position' => 19, + 'public' => true, + 'publicly_queryable' => true, + 'rewrite' => [ 'slug' => $this->post_type, 'with_front' => false ], + 'show_in_nav_menus' => false, + 'show_in_rest' => current_user_can( 'read_' . $this->post_type ), + 'supports' => [ 'title', 'editor', 'thumbnail', 'excerpt', 'revisions' ], ]; } @@ -93,14 +93,13 @@ public function send_404_unauthorized(): void { nocache_headers(); require_once get_query_template( '404' ); - - exit(); + exit; } /** * Indicate if the post type is viewable. */ - public function current_user_can_read( $bool, $post_type_object ): bool { + public function current_user_can_read( bool $bool, \WP_Post_Type $post_type_object ): bool { if ( ! $bool ) { return false; } From f88ccf96924bf900a7bc84c5569f4a2dd42eabd6 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Thu, 31 Oct 2024 14:42:48 -0400 Subject: [PATCH 06/13] specify exact user roles to access training cpt --- .../plugins/core/src/Post_Types/Training/Config.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/wp-content/plugins/core/src/Post_Types/Training/Config.php b/wp-content/plugins/core/src/Post_Types/Training/Config.php index eb45e173..67547073 100644 --- a/wp-content/plugins/core/src/Post_Types/Training/Config.php +++ b/wp-content/plugins/core/src/Post_Types/Training/Config.php @@ -62,13 +62,14 @@ public function add_user_caps(): void { } $post_type_object = get_post_type_object( $this->post_type ); - $all_roles = array_keys( $wp_roles->roles ); - - foreach ( $all_roles as $role ) { - if ( 'subscriber' === $role ) { - continue; - } + $adjust_roles = [ + 'administrator', + 'editor', + 'author', + 'contributor', + ]; + foreach ( $adjust_roles as $role ) { $role = get_role( $role ); foreach ( (array) $post_type_object->cap as $cap ) { From 0d83b6540665bd0b17fe43ff4fd8f47359226ef1 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Thu, 31 Oct 2024 15:34:22 -0400 Subject: [PATCH 07/13] remove filtering and columns added by plugins --- .../core/src/Post_Types/Training/Config.php | 27 +++++++++++++++++++ .../Training/Training_Subscriber.php | 14 ++++++++++ 2 files changed, 41 insertions(+) diff --git a/wp-content/plugins/core/src/Post_Types/Training/Config.php b/wp-content/plugins/core/src/Post_Types/Training/Config.php index 67547073..231ed8e6 100644 --- a/wp-content/plugins/core/src/Post_Types/Training/Config.php +++ b/wp-content/plugins/core/src/Post_Types/Training/Config.php @@ -112,4 +112,31 @@ public function current_user_can_read( bool $bool, \WP_Post_Type $post_type_obje return current_user_can( $post_type_object->cap->read_post ); } + /** + * Remove filters from list table. + */ + public function list_table_filters( string $post_type ): void { + if ( $post_type !== $this->post_type ) { + return; + } + + if ( ! has_action( current_action() ) ) { + return; + } + + remove_all_actions( current_action() ); + } + + /** + * Limit list table columns to checkbox and title. + */ + public function list_table_columns(): array { + return [ + 'cb' => '', + 'title' => 'Title', + ]; + + return $columns; + } + } diff --git a/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php b/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php index 4b5e3f78..240ffc02 100644 --- a/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php +++ b/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php @@ -14,6 +14,7 @@ public function register(): void { $this->block_templates(); $this->user_permissions(); + $this->list_table(); } public function block_templates(): void { @@ -38,4 +39,17 @@ public function user_permissions(): void { } ); } + public function list_table(): void { + // Prevent filtering added by plugins. + add_action( 'restrict_manage_posts', function ( $post_type ): void { + $this->container->get( Config::class )->list_table_filters( $post_type ); + }, 0 ); + + // Remove columns added by plugins. + add_filter( 'manage_' . Training::NAME . '_posts_columns', function ( $columns ): array { + return $this->container->get( Config::class )->list_table_columns(); + }, 100, 2 ); + + } + } From 88e1be753007202f2e86fc1ebf76930263ad6d43 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Thu, 31 Oct 2024 15:34:41 -0400 Subject: [PATCH 08/13] exclude training post type from rankmath and yoast --- .../Integrations/Integrations_Subscriber.php | 8 ++++++++ .../core/src/Integrations/RankMath.php | 19 +++++++++++++++++++ .../core/src/Integrations/YoastSEO.php | 19 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 wp-content/plugins/core/src/Integrations/RankMath.php create mode 100644 wp-content/plugins/core/src/Integrations/YoastSEO.php diff --git a/wp-content/plugins/core/src/Integrations/Integrations_Subscriber.php b/wp-content/plugins/core/src/Integrations/Integrations_Subscriber.php index d3657426..a46e0735 100644 --- a/wp-content/plugins/core/src/Integrations/Integrations_Subscriber.php +++ b/wp-content/plugins/core/src/Integrations/Integrations_Subscriber.php @@ -12,6 +12,14 @@ public function register(): void { add_filter( 'acf/settings/show_admin', function ( $show ): bool { return $this->container->get( ACF::class )->show_acf_menu_item( (bool) $show ); }, 10, 1 ); + + add_filter( 'wpseo_accessible_post_types', function ( $post_types ) { + return $this->container->get( YoastSEO::class )->exclude_post_types( $post_types ); + }, 100 ); + + add_filter( 'rank_math/excluded_post_types', function ( $post_types ) { + return $this->container->get( RankMath::class )->exclude_post_types( $post_types ); + }, 100 ); } } diff --git a/wp-content/plugins/core/src/Integrations/RankMath.php b/wp-content/plugins/core/src/Integrations/RankMath.php new file mode 100644 index 00000000..975c84ee --- /dev/null +++ b/wp-content/plugins/core/src/Integrations/RankMath.php @@ -0,0 +1,19 @@ + Date: Thu, 31 Oct 2024 15:37:49 -0400 Subject: [PATCH 09/13] eliminate code smells --- .../core/src/Integrations/Integrations_Subscriber.php | 8 ++++++++ wp-content/plugins/core/src/Integrations/RankMath.php | 8 ++------ wp-content/plugins/core/src/Integrations/YoastSEO.php | 8 ++------ .../core/src/Post_Types/Training/Training_Subscriber.php | 1 - 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/wp-content/plugins/core/src/Integrations/Integrations_Subscriber.php b/wp-content/plugins/core/src/Integrations/Integrations_Subscriber.php index a46e0735..15e22711 100644 --- a/wp-content/plugins/core/src/Integrations/Integrations_Subscriber.php +++ b/wp-content/plugins/core/src/Integrations/Integrations_Subscriber.php @@ -14,10 +14,18 @@ public function register(): void { }, 10, 1 ); add_filter( 'wpseo_accessible_post_types', function ( $post_types ) { + if ( ! is_array( $columns ) ) { + return []; + } + return $this->container->get( YoastSEO::class )->exclude_post_types( $post_types ); }, 100 ); add_filter( 'rank_math/excluded_post_types', function ( $post_types ) { + if ( ! is_array( $columns ) ) { + return []; + } + return $this->container->get( RankMath::class )->exclude_post_types( $post_types ); }, 100 ); } diff --git a/wp-content/plugins/core/src/Integrations/RankMath.php b/wp-content/plugins/core/src/Integrations/RankMath.php index 975c84ee..261acbbb 100644 --- a/wp-content/plugins/core/src/Integrations/RankMath.php +++ b/wp-content/plugins/core/src/Integrations/RankMath.php @@ -6,12 +6,8 @@ class RankMath { - public function exclude_post_types( $post_types ): array { - if ( ! is_array( $post_types ) ) { - return []; - } - - $post_types = array_diff( $post_types, array( Training::NAME ) ); + public function exclude_post_types( array $post_types ): array { + $post_types = array_diff( $post_types, [ Training::NAME ] ); return $post_types; } diff --git a/wp-content/plugins/core/src/Integrations/YoastSEO.php b/wp-content/plugins/core/src/Integrations/YoastSEO.php index 62326051..145273ea 100644 --- a/wp-content/plugins/core/src/Integrations/YoastSEO.php +++ b/wp-content/plugins/core/src/Integrations/YoastSEO.php @@ -6,12 +6,8 @@ class YoastSEO { - public function exclude_post_types( $post_types ): array { - if ( ! is_array( $post_types ) ) { - return []; - } - - $post_types = array_diff( $post_types, array( Training::NAME ) ); + public function exclude_post_types( array $post_types ): array { + $post_types = array_diff( $post_types, [ Training::NAME ] ); return $post_types; } diff --git a/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php b/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php index 240ffc02..6644d1d6 100644 --- a/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php +++ b/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php @@ -49,7 +49,6 @@ public function list_table(): void { add_filter( 'manage_' . Training::NAME . '_posts_columns', function ( $columns ): array { return $this->container->get( Config::class )->list_table_columns(); }, 100, 2 ); - } } From 4c3a4a034dad03141dcc37487b1e29fdc0053976 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Thu, 31 Oct 2024 15:39:08 -0400 Subject: [PATCH 10/13] fix variable name --- .../plugins/core/src/Integrations/Integrations_Subscriber.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-content/plugins/core/src/Integrations/Integrations_Subscriber.php b/wp-content/plugins/core/src/Integrations/Integrations_Subscriber.php index 15e22711..9ee0a7ea 100644 --- a/wp-content/plugins/core/src/Integrations/Integrations_Subscriber.php +++ b/wp-content/plugins/core/src/Integrations/Integrations_Subscriber.php @@ -14,7 +14,7 @@ public function register(): void { }, 10, 1 ); add_filter( 'wpseo_accessible_post_types', function ( $post_types ) { - if ( ! is_array( $columns ) ) { + if ( ! is_array( $post_types ) ) { return []; } @@ -22,7 +22,7 @@ public function register(): void { }, 100 ); add_filter( 'rank_math/excluded_post_types', function ( $post_types ) { - if ( ! is_array( $columns ) ) { + if ( ! is_array( $post_types ) ) { return []; } From f9b5b143ed8fcd44d6d66b373a7c269109886e46 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Thu, 31 Oct 2024 15:42:11 -0400 Subject: [PATCH 11/13] change labels for training cpt --- wp-content/plugins/core/src/Post_Types/Training/Config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-content/plugins/core/src/Post_Types/Training/Config.php b/wp-content/plugins/core/src/Post_Types/Training/Config.php index 231ed8e6..7081352f 100644 --- a/wp-content/plugins/core/src/Post_Types/Training/Config.php +++ b/wp-content/plugins/core/src/Post_Types/Training/Config.php @@ -30,8 +30,8 @@ public function get_args(): array { public function get_labels(): array { return [ - 'singular' => __( 'Training', 'tribe' ), - 'plural' => __( 'Training', 'tribe' ), + 'singular' => __( 'Training Doc', 'tribe' ), + 'plural' => __( 'Training Docs', 'tribe' ), 'slug' => $this->post_type, ]; } From 1750981d71191cb75cf78966667e4dfbe5cfe8b0 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Wed, 6 Nov 2024 10:25:11 -0500 Subject: [PATCH 12/13] trigger deploy From 9547d9b601f64a2b6f74ec4b7ca3ed60714c6096 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Thu, 14 Nov 2024 10:23:12 -0500 Subject: [PATCH 13/13] phpstan fixes --- wp-content/plugins/core/src/Post_Types/Training/Config.php | 2 -- .../core/src/Post_Types/Training/Training_Subscriber.php | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/wp-content/plugins/core/src/Post_Types/Training/Config.php b/wp-content/plugins/core/src/Post_Types/Training/Config.php index 7081352f..ecfad1d8 100644 --- a/wp-content/plugins/core/src/Post_Types/Training/Config.php +++ b/wp-content/plugins/core/src/Post_Types/Training/Config.php @@ -135,8 +135,6 @@ public function list_table_columns(): array { 'cb' => '', 'title' => 'Title', ]; - - return $columns; } } diff --git a/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php b/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php index 6644d1d6..554d4487 100644 --- a/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php +++ b/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php @@ -48,7 +48,7 @@ public function list_table(): void { // Remove columns added by plugins. add_filter( 'manage_' . Training::NAME . '_posts_columns', function ( $columns ): array { return $this->container->get( Config::class )->list_table_columns(); - }, 100, 2 ); + }, 100 ); } }