| @@ -24,9 +24,9 @@ | ||
| 24 | 24 | * @param callable|null $transform |
| 25 | 25 | * |
| 26 | 26 | * @return array|mixed|\WP_Post|null |
| 27 | 27 | */ |
| 28 | - public function find( $id, ?callable $transform = null ) { | |
| 28 | + public function find( $id, callable $transform = null ) { | |
| 29 | 29 | $post = get_post( $id ); |
| 30 | 30 | |
| 31 | 31 | if ( ! is_null( $transform ) ) { |
| 32 | 32 | $post = call_user_func( $transform, $post ); |
| @@ -40,9 +40,9 @@ | ||
| 40 | 40 | * @param callable|null $transform |
| 41 | 41 | * |
| 42 | 42 | * @return array |
| 43 | 43 | */ |
| 44 | - public function find_where( array $args = [], ?callable $transform = null ) { | |
| 44 | + public function find_where( array $args = [], callable $transform = null ) { | |
| 45 | 45 | $posts = $this->query( $args )->posts; |
| 46 | 46 | |
| 47 | 47 | if ( ! is_null( $transform ) ) { |
| 48 | 48 | $posts = array_map( $transform, $posts ); |
| @@ -56,9 +56,9 @@ | ||
| 56 | 56 | * @param callable|null $transform |
| 57 | 57 | * |
| 58 | 58 | * @return array |
| 59 | 59 | */ |
| 60 | - public function find_by_label( int $label_id, ?callable $transform = null ) { | |
| 60 | + public function find_by_label( int $label_id, callable $transform = null ) { | |
| 61 | 61 | $labels = $this->notations->get_labels_by_id( 'post', $label_id ); |
| 62 | 62 | $post_ids = []; |
| 63 | 63 | |
| 64 | 64 | foreach ( $labels as $label ) { |
| @@ -86,9 +86,9 @@ | ||
| 86 | 86 | * @param callable|null $transform |
| 87 | 87 | * |
| 88 | 88 | * @return Pager |
| 89 | 89 | */ |
| 90 | - public function paginate( array $args = [], ?callable $transform = null ) { | |
| 90 | + public function paginate( array $args = [], callable $transform = null ) { | |
| 91 | 91 | $query = $this->query( $args ); |
| 92 | 92 | |
| 93 | 93 | $pager = new Pager( |
| 94 | 94 | $query->posts, |
| @@ -119,21 +119,8 @@ | ||
| 119 | 119 | return $data; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
| 123 | - * Plural label from registered post type (WP_Post_Type::$label), not contextual list titles. | |
| 124 | - * @param \WP_Post_Type $type | |
| 125 | - * @return string | |
| 126 | - */ | |
| 127 | - private function get_stable_plural_label( \WP_Post_Type $type ) { | |
| 128 | - if ( isset( $type->label ) && '' !== $type->label ) { | |
| 129 | - return $type->label; | |
| 130 | - } | |
| 131 | - | |
| 132 | - return $type->labels->name; | |
| 133 | - } | |
| 134 | - | |
| 135 | - /** | |
| 136 | 123 | * Get array of post types registered in WordPress |
| 137 | 124 | * @return array |
| 138 | 125 | */ |
| 139 | 126 | public function get_types() { |
| @@ -140,23 +127,14 @@ | ||
| 140 | 127 | $data = []; |
| 141 | 128 | $types = get_post_types( [], 'objects' ); |
| 142 | 129 | |
| 143 | 130 | // Types with show_ui false that we want to show |
| 144 | - $known = apply_filters( 'fl_assistant_post_types_known', [ | |
| 131 | + $known = [ | |
| 145 | 132 | 'wp_template', |
| 146 | 133 | 'wp_template_part', |
| 147 | 134 | 'fl_code', |
| 148 | - ] ); | |
| 135 | + ]; | |
| 149 | 136 | |
| 150 | - // Of the types above, those whose items are portable enough to bulk add to a | |
| 151 | - // cloud library. Opt-in only: block templates are scoped to a theme via the | |
| 152 | - // wp_theme taxonomy and code snippets have their own library item type, so | |
| 153 | - // neither belongs in the upload picker. Design systems are portable by UUID, | |
| 154 | - // so they do. | |
| 155 | - $library = apply_filters( 'fl_assistant_post_types_library', [ | |
| 156 | - 'fl-design-system', | |
| 157 | - ] ); | |
| 158 | - | |
| 159 | 137 | // Types to never show |
| 160 | 138 | $ignore = [ |
| 161 | 139 | 'attachment', |
| 162 | 140 | 'wp_navigation', |
| @@ -183,10 +161,9 @@ | ||
| 183 | 161 | require_once ABSPATH . 'wp-admin/includes/theme.php'; |
| 184 | 162 | } |
| 185 | 163 | |
| 186 | 164 | $data[ $slug ] = [ |
| 187 | - 'canView' => $type->public || $type->publicly_queryable || in_array( $slug, $library ), | |
| 188 | - 'hasPublicUrl' => $type->public || $type->publicly_queryable, | |
| 165 | + 'canView' => $type->public || $type->publicly_queryable, | |
| 189 | 166 | 'canExport' => $type->can_export, |
| 190 | 167 | 'hasArchive' => $type->has_archive, |
| 191 | 168 | 'isHierarchical' => $type->hierarchical, |
| 192 | 169 | 'builtin' => $type->_builtin, |
| @@ -200,9 +177,9 @@ | ||
| 200 | 177 | 'order' => post_type_supports( $slug, 'page-attributes' ), |
| 201 | 178 | ], |
| 202 | 179 | 'labels' => [ |
| 203 | 180 | 'singular' => esc_html( $type->labels->singular_name ), |
| 204 | - 'plural' => esc_html( $this->get_stable_plural_label( $type ) ), | |
| 181 | + 'plural' => esc_html( $type->labels->name ), | |
| 205 | 182 | 'newItem' => esc_html( $type->labels->new_item ), |
| 206 | 183 | 'editItem' => esc_html( $type->labels->edit_item ), |
| 207 | 184 | 'viewItem' => esc_html( $type->labels->view_item ), |
| 208 | 185 | ], |
| @@ -209,9 +186,9 @@ | ||
| 209 | 186 | ]; |
| 210 | 187 | |
| 211 | 188 | if ( 'wp_template' === $slug || 'wp_template_part' === $slug ) { |
| 212 | 189 | $data[ $slug ]['labels']['singular'] = sprintf( esc_html_x( 'Block %s', 'Singular type name.', 'assistant' ), $type->labels->singular_name ); |
| 213 | - $data[ $slug ]['labels']['plural'] = sprintf( esc_html_x( 'Block %s', 'Plural type name.', 'assistant' ), $this->get_stable_plural_label( $type ) ); | |
| 190 | + $data[ $slug ]['labels']['plural'] = sprintf( esc_html_x( 'Block %s', 'Plural type name.', 'assistant' ), $type->labels->name ); | |
| 214 | 191 | } |
| 215 | 192 | |
| 216 | 193 | $taxonomies = get_object_taxonomies( $slug, 'objects' ); |
| 217 | 194 | |