presspack /
framework
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace Presspack\Framework; |
||||||
| 4 | |||||||
| 5 | use Illuminate\Support\Str; |
||||||
| 6 | |||||||
| 7 | class Setup |
||||||
| 8 | { |
||||||
| 9 | public $config; |
||||||
| 10 | |||||||
| 11 | public function __construct($path) |
||||||
| 12 | { |
||||||
| 13 | $basePath = \dirname($path, 2); |
||||||
| 14 | |||||||
| 15 | $this->config = require_once $basePath.'/config/presspack.php'; |
||||||
| 16 | |||||||
| 17 | add_action('init', [$this, 'themeSetup']); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 18 | add_action('init', [$this, 'registerPostTypes']); |
||||||
| 19 | add_action('init', [$this, 'registerTemplates']); |
||||||
| 20 | add_action('init', [$this, 'registerTaxonomies']); |
||||||
| 21 | add_action('init', [$this, 'registerMenus']); |
||||||
| 22 | add_action('after_setup_theme', [$this, 'registerImageSizes']); |
||||||
| 23 | add_filter('flush_rewrite_rules_hard', '__return_false'); |
||||||
|
0 ignored issues
–
show
The function
add_filter 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...
|
|||||||
| 24 | add_filter('use_block_editor_for_post', '__return_false', 10); // disable gutenberg for posts |
||||||
| 25 | add_filter('use_block_editor_for_post_type', '__return_false', 10); // disable gutenberg for post types |
||||||
| 26 | } |
||||||
| 27 | |||||||
| 28 | public static function bootstrap($path) |
||||||
| 29 | { |
||||||
| 30 | return new static($path); |
||||||
| 31 | } |
||||||
| 32 | |||||||
| 33 | public function themeSetup() |
||||||
| 34 | { |
||||||
| 35 | load_theme_textdomain('presspack'); |
||||||
|
0 ignored issues
–
show
The function
load_theme_textdomain 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 | add_theme_support('post-thumbnails'); |
||||||
|
0 ignored issues
–
show
The function
add_theme_support 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...
|
|||||||
| 37 | add_theme_support('automatic-feed-links'); |
||||||
| 38 | add_theme_support('title-tag'); |
||||||
| 39 | |||||||
| 40 | if (\function_exists('acf_add_options_page')) { |
||||||
| 41 | acf_add_options_page(); |
||||||
| 42 | } |
||||||
| 43 | } |
||||||
| 44 | |||||||
| 45 | public function registerPostTypes() |
||||||
| 46 | { |
||||||
| 47 | foreach ($this->config['post_types'] as $postType) { |
||||||
| 48 | $data = new $postType(); |
||||||
| 49 | register_post_type($data->postType, $data->postTypeargs()); |
||||||
|
0 ignored issues
–
show
The function
register_post_type 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...
|
|||||||
| 50 | } |
||||||
| 51 | } |
||||||
| 52 | |||||||
| 53 | public function registerTaxonomies() |
||||||
| 54 | { |
||||||
| 55 | foreach ($this->config['taxonomies'] as $taxonomy => $value) { |
||||||
| 56 | $singularName = isset($value['singular']) ? $value['singular'] : $taxonomy; |
||||||
| 57 | $pluralName = isset($value['plural']) ? $value['plural'] : Str::plural($taxonomy); |
||||||
| 58 | |||||||
| 59 | register_taxonomy(Str::slug($taxonomy), $value['post_types'], [ |
||||||
|
0 ignored issues
–
show
The function
register_taxonomy 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...
|
|||||||
| 60 | 'labels' => [ |
||||||
| 61 | 'name' => $pluralName, |
||||||
| 62 | 'singular_name' => $singularName, |
||||||
| 63 | 'menu_name' => $pluralName, |
||||||
| 64 | ], |
||||||
| 65 | 'description' => '', |
||||||
| 66 | 'public' => true, |
||||||
| 67 | 'hierarchical' => true, |
||||||
| 68 | 'show_ui' => true, |
||||||
| 69 | 'show_admin_column' => false, |
||||||
| 70 | 'show_in_nav_menus' => true, |
||||||
| 71 | 'show_tagcloud' => false, |
||||||
| 72 | 'single_value' => false, |
||||||
| 73 | ]); |
||||||
| 74 | } |
||||||
| 75 | } |
||||||
| 76 | |||||||
| 77 | public function registerTemplates() |
||||||
| 78 | { |
||||||
| 79 | foreach ($this->config['templates'] as $postType => $templates) { |
||||||
| 80 | add_filter("theme_{$postType}_templates", function ($registeredTemplates) use ($templates) { |
||||||
|
0 ignored issues
–
show
The function
add_filter 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...
|
|||||||
| 81 | return array_merge($registeredTemplates, $templates); |
||||||
| 82 | }); |
||||||
| 83 | } |
||||||
| 84 | } |
||||||
| 85 | |||||||
| 86 | public function registerMenus() |
||||||
| 87 | { |
||||||
| 88 | foreach ($this->config['menus'] as $menu) { |
||||||
| 89 | register_nav_menu($menu, $menu); |
||||||
|
0 ignored issues
–
show
The function
register_nav_menu 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...
|
|||||||
| 90 | } |
||||||
| 91 | } |
||||||
| 92 | |||||||
| 93 | public function registerImageSizes() |
||||||
| 94 | { |
||||||
| 95 | foreach ($this->config['image_sizes'] as $key => $sizes) { |
||||||
| 96 | add_image_size($key, $sizes[0], $sizes[1], isset($sizes[2]) ? $sizes[2] : true); |
||||||
|
0 ignored issues
–
show
The function
add_image_size 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...
|
|||||||
| 97 | } |
||||||
| 98 | } |
||||||
| 99 | } |
||||||
| 100 |