fad5a7d03b
S1 skeleton (cp-8ci, already done): - wp-multi-city.php with header, constants, hooks bootstrap - includes/class-plugin.php with PSR-4-ish autoloader, ACF dependency guard - includes/class-activator.php placeholder - composer.json (PHP 8.0, phpunit dev) - README.md with roadmap - uninstall.php placeholder S2 design (cp-q7g): - docs/superpowers/specs/2026-05-12-s2-taxonomy-cpt-acf-design.md
58 lines
1.8 KiB
PHP
58 lines
1.8 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace WPMultiCity;
|
|
|
|
final class Plugin
|
|
{
|
|
private static ?Plugin $instance = null;
|
|
|
|
public static function instance(): Plugin
|
|
{
|
|
if (self::$instance === null) self::$instance = new self();
|
|
return self::$instance;
|
|
}
|
|
|
|
public static function register_autoloader(): void
|
|
{
|
|
spl_autoload_register(static function (string $class): void {
|
|
if (strpos($class, 'WPMultiCity\\') !== 0) return;
|
|
$relative = substr($class, strlen('WPMultiCity\\'));
|
|
$slug = strtolower(preg_replace('/([a-z0-9])([A-Z])/', '$1-$2', $relative));
|
|
$slug = str_replace('_', '-', $slug);
|
|
$candidates = [
|
|
dirname(__DIR__) . '/includes/class-' . $slug . '.php',
|
|
dirname(__DIR__) . '/includes/' . $slug . '.php',
|
|
dirname(__DIR__) . '/admin/class-' . $slug . '.php',
|
|
];
|
|
foreach ($candidates as $path) {
|
|
if (is_file($path)) {
|
|
require_once $path;
|
|
return;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
public function boot(): void
|
|
{
|
|
if (!$this->dependencies_satisfied()) {
|
|
add_action('admin_notices', [$this, 'render_dependency_notice']);
|
|
return;
|
|
}
|
|
|
|
// Stage 2-5 hooks register here. Stage 1 (skeleton) intentionally empty.
|
|
}
|
|
|
|
private function dependencies_satisfied(): bool
|
|
{
|
|
return class_exists('ACF') || function_exists('acf_add_local_field_group');
|
|
}
|
|
|
|
public function render_dependency_notice(): void
|
|
{
|
|
if (!current_user_can('activate_plugins')) return;
|
|
echo '<div class="notice notice-error"><p><strong>WP Multi City:</strong> требуется активный плагин Advanced Custom Fields Pro.</p></div>';
|
|
}
|
|
}
|