/** * Installs types from a single JSON file * @deprecated */ private function installCustomPostTypesFromJSON() { if (!file_exists($this->rootPath . '/config/types.json')) { return; } $types = JSONParser::parse(file_get_contents($this->rootPath . '/config/types.json')); foreach ($types as $cpt => $details) { register_post_type($cpt, $details); } }
/** * Load custom image sizes */ private function loadImageSizes() { // configure image sizes if (file_exists($this->context->rootPath . '/config/sizes.php')) { $sizesConfig = (include $this->context->rootPath . '/config/sizes.php'); } else { if (file_exists($this->context->rootPath . '/config/sizes.json')) { $sizesConfig = JSONParser::parse(file_get_contents($this->context->rootPath . '/config/sizes.json')); } else { return; } } if (isset($sizesConfig['srcset'])) { $this->srcsetConfig = $sizesConfig['srcset']; } if (isset($sizesConfig['sizes'])) { $customSizes = []; foreach ($sizesConfig['sizes'] as $key => $info) { if ($key == 'original') { Log::warning("Your sizes config has specified a size for 'original'. This is a keyword and cannot be used. Skipping for now."); continue; } if ($key == 'post-thumbnail') { set_post_thumbnail_size($info['width'], $info['height'], $info['crop']); } else { add_image_size($key, $info['width'], $info['height'], $info['crop']); } if (isset($info['display']) && $info['display']) { $customSizes[] = $key; } } if (count($customSizes) > 0) { add_filter('image_size_names_choose', function ($sizes) use($customSizes) { foreach ($customSizes as $size) { $sizes[$size] = ucwords(str_replace('_', ' ', str_replace('-', ' ', $size))); } return $sizes; }); } } if (isset($sizesConfig['disable-wp-sizes'])) { $disabled = $sizesConfig['disable-wp-sizes']; add_filter('intermediate_image_sizes_advanced', function ($sizes) use($disabled) { foreach ($disabled as $size) { unset($sizes[$size]); } return $sizes; }, 10000); } }