@@ -66,7 +66,13 @@ function get_duplicate_post_link( $post = 0 ): ?string {
6666 '_wpnonce ' => wp_create_nonce ( 'duplicate_post_ ' . $ post ->ID ),
6767 ), admin_url ( 'post.php ' ) );
6868
69- // The nonce_url part is integrated directly into the duplicate link
69+ /**
70+ * Filters the URL used for duplicating a post. This allows plugins and themes to modify the duplicate post link.
71+ * Useful for adding or removing query args, or changing the base URL, based on specific conditions or requirements.
72+ *
73+ * @param string $duplicate_link The URL to duplicate the post, including nonce for security.
74+ * @param int $post_id The ID of the post being duplicated.
75+ */
7076 return apply_filters ( 'cpt_inline_list_table_duplicate_post_link ' , $ duplicate_link , $ post ->ID );
7177 }
7278}
@@ -83,6 +89,15 @@ function check_edit_others_caps( string $post_type ): bool {
8389 $ post_type_object = get_post_type_object ( $ post_type );
8490 $ edit_others_cap = empty ( $ post_type_object ) ? 'edit_others_ ' . $ post_type . 's ' : $ post_type_object ->cap ->edit_others_posts ;
8591
92+ /**
93+ * Filters the capability check result for editing posts created by other users. This can be used to dynamically
94+ * alter permission checks, allowing or restricting user capabilities based on custom logic (e.g., user roles,
95+ * specific conditions, or post types).
96+ *
97+ * @param bool $can_edit_others True if the current user has the capability to edit others' posts, false otherwise.
98+ * @param string $post_type The post type being checked for the 'edit others' capability.
99+ */
100+
86101 return apply_filters ( 'cpt_inline_list_table_edit_others_capability ' , current_user_can ( $ edit_others_cap ), $ post_type );
87102 }
88103}
@@ -99,6 +114,14 @@ function check_delete_others_caps( string $post_type ): bool {
99114 $ post_type_object = get_post_type_object ( $ post_type );
100115 $ delete_others_cap = empty ( $ post_type_object ) ? 'delete_others_ ' . $ post_type . 's ' : $ post_type_object ->cap ->delete_others_posts ;
101116
117+ /**
118+ * Filters the capability check result for deleting posts created by other users. Similar to the edit capability filter,
119+ * this allows for custom control over who can delete others' posts within specific contexts or conditions.
120+ *
121+ * @param bool $can_delete_others True if the current user has the capability to delete others' posts, false otherwise.
122+ * @param string $post_type The post type being checked for the 'delete others' capability.
123+ */
124+
102125 return apply_filters ( 'cpt_inline_list_table_delete_others_capability ' , current_user_can ( $ delete_others_cap ), $ post_type );
103126 }
104127}
@@ -120,11 +143,14 @@ function is_post_type_sortable( string $post_type = 'post' ): bool {
120143 $ sortable = ( post_type_supports ( $ post_type , 'page-attributes ' ) && ! is_post_type_hierarchical ( $ post_type ) );
121144
122145 /**
123- * Filters the determination of whether a post type is considered sortable.
146+ * Filters the determination of whether a post type is considered sortable. Sortability can be defined by themes
147+ * or plugins based on whether a post type supports 'page-attributes' and is not hierarchical. This filter allows
148+ * overriding the default sortability condition to accommodate custom logic or requirements for sorting posts.
124149 *
125- * @param bool $sortable Whether the post type is sortable.
126- * @param string $post_type The post type being checked .
150+ * @param bool $sortable Whether the post type is sortable, determined by support for 'page-attributes' and non-hierarchical structure .
151+ * @param string $post_type The post type being evaluated for sortability .
127152 */
128- return apply_filters ( 'is_post_type_sortable ' , $ sortable , $ post_type );
153+
154+ return apply_filters ( 'cpt_inline_list_table_post_type_sortable ' , $ sortable , $ post_type );
129155 }
130156}
0 commit comments