helick /
related-posts
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Helick\RelatedPosts; |
||||
| 4 | |||||
| 5 | use Carbon_Fields\Container; |
||||
| 6 | use Carbon_Fields\Field; |
||||
| 7 | use Helick\Contracts\Bootable; |
||||
| 8 | |||||
| 9 | final class CustomFields implements Bootable |
||||
| 10 | { |
||||
| 11 | /** |
||||
| 12 | * Boot the service. |
||||
| 13 | * |
||||
| 14 | * @return void |
||||
| 15 | */ |
||||
| 16 | public static function boot(): void |
||||
| 17 | { |
||||
| 18 | $self = new static; |
||||
| 19 | |||||
| 20 | add_action('carbon_fields_register_fields', [$self, 'register']); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 21 | } |
||||
| 22 | |||||
| 23 | /** |
||||
| 24 | * Register the custom fields. |
||||
| 25 | * |
||||
| 26 | * @return void |
||||
| 27 | */ |
||||
| 28 | public function register(): void |
||||
| 29 | { |
||||
| 30 | /** |
||||
| 31 | * Control the supported post types. |
||||
| 32 | * |
||||
| 33 | * @param array $supportedPostTypes |
||||
| 34 | */ |
||||
| 35 | $supportedPostTypes = apply_filters('helick_related_posts_supported_post_types', ['post']); |
||||
|
0 ignored issues
–
show
The function
apply_filters was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 36 | |||||
| 37 | /** |
||||
| 38 | * Control the associated post types. |
||||
| 39 | * |
||||
| 40 | * @param array $associatedPostTypes |
||||
| 41 | */ |
||||
| 42 | $associatedPostTypes = apply_filters('helick_related_posts_associated_post_types', ['post']); |
||||
| 43 | |||||
| 44 | $associationTypes = array_map(function (string $postType) { |
||||
| 45 | return [ |
||||
| 46 | 'type' => 'post', |
||||
| 47 | 'post_type' => $postType, |
||||
| 48 | ]; |
||||
| 49 | }, $associatedPostTypes); |
||||
| 50 | |||||
| 51 | Container::make('post_meta', __('Related Posts', DOMAIN)) |
||||
|
0 ignored issues
–
show
The function
__ was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 52 | ->where('post_type', 'IN', (array)$supportedPostTypes) |
||||
| 53 | ->add_fields([ |
||||
| 54 | Field::make('association', 'helick_related_posts', __('Manually selected related posts', DOMAIN)) |
||||
| 55 | ->set_help_text(__('By default, 10 related posts are dynamically generated.', DOMAIN)) |
||||
| 56 | ->set_types($associationTypes), |
||||
|
0 ignored issues
–
show
The method
set_types() does not exist on Carbon_Fields\Field\Field. It seems like you code against a sub-type of Carbon_Fields\Field\Field such as Carbon_Fields\Field\Association_Field.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 57 | ]); |
||||
| 58 | } |
||||
| 59 | } |
||||
| 60 |