Files
wp-multi-city/includes/class-options-page.php
T
Vladimir Bryzgalov 949fb19e95 fix(wpmc 1.0.1): remove __() from labels (no translations, fixes WP 6.7 notice)
Replace all __('...', 'wp-multi-city') calls in CPT, taxonomy, ACF field group,
and options page label arrays with literal Russian strings. The plugin ships no
.mo translation files, so wrapping labels in __() was YAGNI and triggered the
WP 6.7+ _load_textdomain_just_in_time notice.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 17:01:11 +05:00

128 lines
5.2 KiB
PHP

<?php
declare(strict_types=1);
namespace WPMultiCity;
final class OptionsPage
{
public const PAGE_SLUG = 'wp-multi-city';
public const GROUP_KEY = 'group_wpmc_routing';
public static function register(): void
{
\add_action('acf/init', [self::class, 'do_register']);
\add_filter('wpmc_main_town_slug', [Helpers::class, 'main_town_slug'], 5);
}
public static function do_register(): void
{
if (!\function_exists('acf_add_options_page')
|| !\function_exists('acf_add_local_field_group')) {
return;
}
\acf_add_options_page([
'page_title' => 'WP Multi City',
'menu_title' => 'WP Multi City',
'menu_slug' => self::PAGE_SLUG,
'capability' => 'manage_options',
'redirect' => false,
]);
\acf_add_local_field_group([
'key' => self::GROUP_KEY,
'title' => 'WPMultiCity / Routing',
'fields' => [
[
'key' => 'field_wpmc_main_town_slug',
'label' => 'Главный город (без префикса URL)',
'name' => 'main_town_slug',
'type' => 'taxonomy',
'taxonomy' => 'town',
'field_type' => 'select',
'return_format' => 'object',
'allow_null' => 1,
'multiple' => 0,
'add_term' => 0,
],
[
'key' => 'field_wpmc_index_town_alt',
'label' => 'Главная для других городов',
'name' => 'index_town_alt',
'type' => 'post_object',
'post_type' => ['page'],
'return_format' => 'id',
'allow_null' => 1,
'multiple' => 0,
],
[
'key' => 'field_wpmc_page_unic',
'label' => 'Клоны страниц',
'name' => 'page_unic',
'type' => 'repeater',
'layout' => 'table',
'button_label' => 'Добавить клон',
'sub_fields' => [
[
'key' => 'field_wpmc_page_unic_page_old',
'label' => 'Оригинал',
'name' => 'page_old',
'type' => 'post_object',
'post_type' => ['page'],
'return_format' => 'id',
'allow_null' => 0,
'multiple' => 0,
],
[
'key' => 'field_wpmc_page_unic_page_new',
'label' => 'Клон',
'name' => 'page_new',
'type' => 'post_object',
'post_type' => ['page'],
'return_format' => 'id',
'allow_null' => 0,
'multiple' => 0,
],
[
'key' => 'field_wpmc_page_unic_town',
'label' => 'Город',
'name' => 'town',
'type' => 'taxonomy',
'taxonomy' => 'town',
'field_type' => 'select',
'return_format' => 'id',
'allow_null' => 0,
'multiple' => 0,
'add_term' => 0,
],
],
],
[
'key' => 'field_wpmc_page_no_rep',
'label' => 'Исключения из роутинга',
'name' => 'page_no_rep',
'type' => 'repeater',
'layout' => 'table',
'button_label' => 'Добавить исключение',
'sub_fields' => [
[
'key' => 'field_wpmc_page_no_rep_link',
'label' => 'Путь',
'name' => 'link',
'type' => 'text',
'instructions' => 'Префикс URL, например /privacy/',
],
],
],
],
'location' => [
[['param' => 'options_page', 'operator' => '==', 'value' => self::PAGE_SLUG]],
],
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'active' => true,
]);
}
}