# darkify/2.0.3/src/Admin/Views/Control.php

Darkify – Dark Mode &amp; Night Mode for Website &amp; Admin (Dark Theme Included), version 2.0.3. 349 lines.

- Page: https://pluginprobe.com/plugins/darkify/2.0.3/code/src/Admin/Views/Control.php
- Raw: https://pluginprobe.com/plugins/darkify/2.0.3/raw/src/Admin/Views/Control.php
- Modified: 2026-08-11T09:00:00+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/darkify/2.0.3/code/src/Admin/Views/Control.php#L10-L20`.

```php
<?php

/**
 * Control class for Control options.
 *
 * @link       https://themeatelier.net
 * @since      1.0.0
 *
 * @package darkify
 * @subpackage darkify/src/Admin/Views/Control
 * @author     ThemeAtelier<themeatelierbd@gmail.com>
 */

namespace ThemeAtelier\Darkify\Admin\Views;

use ThemeAtelier\Darkify\Admin\Schema\SchemaRegistry as Darkify;

class Control
{
    /**
     * Create Option fields for the setting options.
     *
     * @param string $prefix Option setting key prefix.
     * @return void
     */
    public static function options($prefix)
    {
        Darkify::createSection(
            $prefix,
            array(
                // Explicit, locale-independent id. Without it the REST layer falls
                // back to sanitize_title() of the *translated* title, so the route
                // became #/sterowanie on a Polish site and every link 404'd inside
                // the SPA. Value matches the old English slug so existing
                // `#tab=` / `#/controls` bookmarks keep resolving.
                'id'          => 'controls',
                'title'       => esc_html__('Controls', 'darkify'),
                'icon'        => 'icofont-ui-settings',
                'fields'      => array(
                    array(
                        'type' => 'section_tab',
                        'tabs' => array(

                            array(
                                'id'    => 'frontend',
                                'title' => esc_html__('Frontend', 'darkify'),
                                'icon'  => 'icofont-computer',
                                'fields' => array(
                                    // Intro line with a docs link, rendered plain above the section cards.
                                    array(
                                        'type'    => 'page_hint',
                                        'content' => sprintf(
                                            /* translators: %s: documentation link */
                                            __('Decide how and when dark mode turns on for visitors on your public website. %s', 'darkify'),
                                            '<a href="https://darkifywp.com/docs/" target="_blank" rel="noopener noreferrer">' . esc_html__('View documentation', 'darkify') . '</a>'
                                        ),
                                    ),

                                    // ===== AVAILABILITY =====
                                    array(
                                        'type'          => 'heading',
                                        'title'         => esc_html__('Availability', 'darkify'),
                                        'section_start' => true,
                                    ),
                                    array(
                                        'id'      => 'enable_dark_mode_switch',
                                        'type'    => 'switcher',
                                        'title' => esc_html__('Frontend Dark Mode', 'darkify'),
                                        'title_help' => '<div class="darkify-info-label">' .
                                            __('Show the dark mode floating switch on your website frontend. This is the master control for everything below.', 'darkify') .
                                            '</div>' . '' . '',
                                        'text_on'    => esc_html__('Enabled', 'darkify'),
                                        'text_off'    => esc_html__('Disabled', 'darkify'),
                                        'text_width' => 100,
                                        'default' => true,
                                        // Commit instantly (master toggle governs the whole frontend feature).
                                        'auto_save' => true,
                                    ),
                                    array(
                                        'id'      => 'enable_default_dark_mode',
                                        'type'    => 'switcher',
                                        'title' => esc_html__('Default Dark Mode', 'darkify'),
                                        'title_help' =>
                                        '<div class="darkify-info-label">' .
                                            __('Enable dark mode by default on your website.', 'darkify') .
                                            '</div>' .
                                            '' .
                                            '',
                                        'text_on'  => esc_html__('Enabled', 'darkify'),
                                        'text_off' => esc_html__('Disabled', 'darkify'),
                                        'text_width' => 100,
                                        // Commit instantly (the priority notice depends on it, which would
                                        // otherwise force the manual-Save workflow).
                                        'auto_save' => true,
                                    ),
                                    array(
                                        'id'      => 'enable_os_aware',
                                        'type'    => 'switcher',
                                        'title' => esc_html__('OS Aware Dark Mode', 'darkify'),
                                        'title_help' =>
                                        '<div class="darkify-info-label">' .
                                            __('Toggle dark mode based on the user’s device or operating system preference.', 'darkify') .
                                            '</div>' .
                                            '' .
                                            '',
                                        'text_on'  => esc_html__('Enabled', 'darkify'),
                                        'text_off' => esc_html__('Disabled', 'darkify'),
                                        'text_width' => 100,
                                        'default' => true,
                                        // Commit instantly (the priority notice depends on it).
                                        'auto_save' => true,
                                    ),
                                    // Priority notice: shown only when Default Dark Mode AND OS Aware are both on.
                                    array(
                                        'type'       => 'submessage',
                                        'style'      => 'info',
                                        'content'    => '<strong>' . esc_html__('OS Aware takes priority.', 'darkify') . '</strong> ' . esc_html__('Both are on, so visitors following the system “dark” setting get dark mode automatically; Default Dark Mode applies only when no system preference is detected.', 'darkify'),
                                        'dependency' => array('enable_default_dark_mode|enable_os_aware', '==|==', 'true|true'),
                                    ),

                                    // ===== ACTIVATION =====
                                    array(
                                        'type'          => 'heading',
                                        'title'         => esc_html__('Activation', 'darkify'),
                                        'section_start' => true,
                                    ),
                                    array(
                                        'id'      => 'enable_keyboard_shortcut',
                                        'type'    => 'switcher',
                                        'title' => esc_html__('Keyboard Shortcut', 'darkify'),
                                        'title_help' =>
                                        '<div class="darkify-info-label">' .
                                            __('Let visitors toggle dark mode with a keyboard shortcut.', 'darkify') .
                                            '</div>' .
                                            '' .
                                            '',
                                        'text_on'  => esc_html__('Enabled', 'darkify'),
                                        'text_off' => esc_html__('Disabled', 'darkify'),
                                        'text_width' => 100,
                                        'default' => true,
                                        // Commit instantly (the shortcut-keys field depends on it).
                                        'auto_save' => true,
                                    ),
                                    // Editable shortcut combo (shown when the shortcut is enabled).
                                    array(
                                        'id'         => 'keyboard_shortcut_keys',
                                        'type'       => 'keyboard_shortcut',
                                        'default'    => 'ctrl+alt+d',
                                        'dependency' => array('enable_keyboard_shortcut', '==', 'true'),
                                    ),
                                    // Enable Time Based Auto Dark Mode
                                    array(
                                        'id'     => 'enable_time',
                                        'type'   => 'fieldset',
                                        'fields' => array(
                                            array(
                                                'id'    => 'enable_time_based_dark',
                                                'type'  => 'switcher',
                                                'title' => esc_html__('Time Based Auto Dark Mode', 'darkify'),
                                                'title_help' =>
                                                '<div class="darkify-info-label">' .
                                                    __('Automatically enable dark mode based on the user’s local time.', 'darkify') .
                                                    '</div>' .
                                                    '' .
                                                    '',
                                                'text_on'  => esc_html__('Enabled', 'darkify'),
                                                'text_off' => esc_html__('Disabled', 'darkify'),
                                                'text_width' => 100,
                                            ),
                                            array(
                                                'id'     => 'enable_time_fields',
                                                'type'   => 'fieldset',
                                                'class'   => 'enable_time_fields',
                                                'dependency' => array('enable_time_based_dark', '==', 'true'),
                                                'title' => esc_html__('Pick a Time', 'darkify'),
                                                'title_help' =>
                                                '<div class="darkify-info-label">' .
                                                    __('Set the exact start and end times when dark mode should be automatically enabled or disabled.', 'darkify') .
                                                    '</div>' .
                                                    '' .
                                                    '',
                                                'fields' => array(
                                                    /*
                                                     * Which clock drives the schedule. Darkify Lite ships
                                                     * only "fixed" (the start/end window below); the
                                                     * sunrise/sunset schedule is a Pro feature, so its
                                                     * option row carries `pro_only` — the REST layer turns
                                                     * that into the `pro_options` stamp the React admin
                                                     * renders as a locked, badged preview, and
                                                     * strip_pro_keys() refuses to persist the value even
                                                     * if a crafted request sends it.
                                                     */
                                                    array(
                                                        'id'      => 'time_based_dark_mode',
                                                        'type'    => 'button_set',
                                                        'default' => 'fixed',
                                                        'options' => array(
                                                            'fixed'    => esc_html__('Fixed times', 'darkify'),
                                                            'suncycle' => array(
                                                                'text'     => esc_html__('Sunrise & sunset', 'darkify'),
                                                                'pro_only' => true,
                                                            ),
                                                        ),
                                                    ),
                                                    array(
                                                        'id'        => 'time_based_dark_start',
                                                        'type'      => 'datetime',
                                                        'after'     => esc_html__('From', 'darkify'),
                                                        'placeholder'   => esc_html__('From', 'darkify'),
                                                        'settings'  => array(
                                                            'noCalendar' => true,
                                                            'enableTime' => true,
                                                            'dateFormat' => 'H:i',
                                                            'time_24hr'  => false,
                                                        ),
                                                    ),
                                                    array(
                                                        'id'        => 'time_based_dark_end',
                                                        'type'      => 'datetime',
                                                        'after'     => esc_html__('To', 'darkify'),
                                                        'placeholder'   => esc_html__('To', 'darkify'),
                                                        'settings'  => array(
                                                            'noCalendar' => true,
                                                            'enableTime' => true,
                                                            'dateFormat' => 'H:i',
                                                            'time_24hr'  => false,
                                                        ),
                                                    ),
                                                ),
                                            ),
                                        ),
                                    ),
                                ),
                            ),
                            array(
                                'id'    => 'admin',
                                'title' => esc_html__('Admin', 'darkify'),
                                'icon'  => 'icofont-dashboard-web',
                                'fields' => array(
                                    // Intro line with a docs link, rendered plain above the section cards.
                                    array(
                                        'type'    => 'page_hint',
                                        'content' => sprintf(
                                            /* translators: %s: documentation link */
                                            __('Bring dark mode to the WordPress admin dashboard and editors. %s', 'darkify'),
                                            '<a href="https://darkifywp.com/docs/" target="_blank" rel="noopener noreferrer">' . esc_html__('View documentation', 'darkify') . '</a>'
                                        ),
                                    ),
                                    // ===== ADMIN APPEARANCE =====
                                    array(
                                        'type'          => 'heading',
                                        'title'         => esc_html__('Admin Appearance', 'darkify'),
                                        'section_start' => true,
                                    ),
                                    array(
                                        'id'      => 'enable_admin_panel_dark_mode',
                                        'type'    => 'switcher',
                                        'title' => esc_html__('Admin Panel Dark Mode', 'darkify'),
                                        'title_help' =>
                                        '<div class="darkify-info-label">' .
                                            __('Enable dark mode in the WordPress admin dashboard.', 'darkify') .
                                            '</div>' .
                                            '' .
                                            '',
                                        'text_on'   => esc_html__('Enabled', 'darkify'),
                                        'text_off'  => esc_html__('Disabled', 'darkify'),
                                        'default'   => false,
                                        'text_width' => 100,
                                        // Commit instantly even though other fields depend on it.
                                        'auto_save' => true,
                                    ),

                                    array(
                                        'id'      => 'block_editor_dark_mode',
                                        'type'    => 'switcher',
                                        'title' => esc_html__('Block Editor Dark Mode', 'darkify'),
                                        'title_help' =>
                                        '<div class="darkify-info-label">' .
                                            __('Enable the dark mode switch in the block editor to toggle between dark and light mode.', 'darkify') .
                                            '</div>'  .
                                            '' .
                                            '',
                                        'text_on'  => esc_html__('Enabled', 'darkify'),
                                        'text_off' => esc_html__('Disabled', 'darkify'),
                                        'default' => false,
                                        'text_width' => 100,
                                    ),
                                    array(
                                        'id'      => 'classic_editor_dark_mode',
                                        'type'    => 'switcher',
                                        'title' => esc_html__('Classic Editor Dark Mode', 'darkify'),
                                        'title_help' =>
                                        '<div class="darkify-info-label">' .
                                            __('Enable the dark mode switch in the classic editor to toggle between dark and light modes.', 'darkify') .
                                            '</div>'  .
                                            '' .
                                            '',
                                        'text_on'  => esc_html__('Enabled', 'darkify'),
                                        'text_off' => esc_html__('Disabled', 'darkify'),

                                        'default' => false,
                                        'text_width' => 100,
                                    ),

                                    // ===== SCOPE & CUSTOMIZATION =====
                                    array(
                                        'type'          => 'heading',
                                        'title'         => esc_html__('Scope & Customization', 'darkify'),
                                        'section_start' => true,
                                        'dependency'    => array('enable_admin_panel_dark_mode', '==', 'true'),
                                    ),
                                    array(
                                        'id'          => 'disallowed_admin_pages',
                                        'type'        => 'textarea',
                                        'title' => esc_html__('Disallowed Pages', 'darkify'),
                                        'title_help' => '<div class="darkify-info-text">' .
                                            __('If an admin page URL looks like http://example.com/wp-admin/admin.php?page=darkify, then "darkify" is the page slug.', 'darkify') .
                                            '</div>' .
                                            '' .
                                            '',
                                        'placeholder' => esc_html__('Enter comma-separated page slugs. Example: darkify-dashboard, elementor', 'darkify'),
                                        'dependency'  => array('enable_admin_panel_dark_mode', '==', 'true'),
                                        'class' => 'only_pro'
                                    ),
                                    array(
                                        'id'       => 'admin_custom_css',
                                        'type'     => 'code_editor',
                                        'title' => esc_html__('Admin Dark Mode CSS', 'darkify'),
                                        'title_help' =>
                                        '<div class="darkify-info-label">' .
                                            __('The CSS code will only be applied when admin dark mode is active.', 'darkify') .
                                            '</div>',
                                        'settings' => array(
                                            'theme'  => 'mbo',
                                            'mode'   => 'css',
                                        ),
                                        // Only relevant when admin dark mode is active — hide it while off.
                                        'dependency' => array('enable_admin_panel_dark_mode', '==', 'true'),
                                    ),
                                ),
                            ),
                        ),
                    ),
                ),
            ),
        );
    }
}

```
