HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/test.kaunokolegija.lt/kk_wp_content/updraft/plugins-old/kk_metabox/main_options.php
<?php

/**
 * KK Theme Options
 *
 * @version   0.1.0
 */
class my_Admin
{

    /**
     * Default Option key
     * @var string
     */
    private $key = 'my_options';

    /**
     * Array of metaboxes/fields
     * @var array
     */
    protected $option_metabox = array();

    /**
     * Options Page title
     * @var string
     */
    protected $title = '';

    /**
     * Options Tab Pages
     * @var array
     */
    protected $options_pages = array();

    /**
     * Constructor
     * @since 1.0.0
     */
    public function __construct()
    {
        $this->title = __('Tinklapio nustatymai', 'kk_metabox');
    }

    /**
     * Initiate our hooks
     * @since 1.0.0
     */
    public function hooks()
    {
        add_action('admin_init', array($this, 'init' ));
        add_action('admin_menu', array($this, 'add_options_page' ));
    }

    /**
     * Register our setting tabs to WP
     * @since  1.0.0
     */
    public function init()
    {
        $option_tabs = self::option_fields();
        foreach ($option_tabs as $index => $option_tab) {
            register_setting($option_tab['id'], $option_tab['id']);
        }
    }

    /**
     * Add menu options page
     * @since 1.0.0
     */
    public function add_options_page()
    {
        $option_tabs = self::option_fields();
        foreach ($option_tabs as $index => $option_tab) {
            if ($index == 0) {
                $this->options_pages[] = add_menu_page($this->title, $this->title, 'manage_options', $option_tab['id'], array($this, 'admin_page_display')); //Link admin menu to first tab
                add_submenu_page($option_tabs[0]['id'], $this->title, $option_tab['title'], 'manage_options', $option_tab['id'], array($this, 'admin_page_display')); //Duplicate menu link for first submenu page
            } else {
                $this->options_pages[] = add_submenu_page($option_tabs[0]['id'], $this->title, $option_tab['title'], 'manage_options', $option_tab['id'], array($this, 'admin_page_display'));
            }
        }
    }

    /**
     * Admin page markup. Mostly handled by CMB
     * @since  1.0.0
     */
    public function admin_page_display()
    {
        $option_tabs = self::option_fields(); //get all option tabs
        $tab_forms = array();
        ?>
        <div class="wrap cmb_options_page <?php echo $this->key; ?>">
            <h2><?php echo esc_html(get_admin_page_title()); ?></h2>

            <!-- Options Page Nav Tabs -->
            <h2 class="nav-tab-wrapper">
                <?php foreach ($option_tabs as $option_tab) :
                    $tab_slug = $option_tab['id'];
                    $nav_class = 'nav-tab';
                    if ($tab_slug == $_GET['page']) {
                        $nav_class .= ' nav-tab-active'; //add active class to current tab
                        $tab_forms[] = $option_tab; //add current tab to forms to be rendered
                    }
                    ?>
                    <a class="<?php echo $nav_class; ?>"
                       href="<?php menu_page_url($tab_slug); ?>"><?php esc_attr_e($option_tab['title']); ?></a>
                <?php endforeach; ?>
            </h2>
            <!-- End of Nav Tabs -->

            <?php foreach ($tab_forms as $tab_form) : ?>
                <div id="<?php esc_attr_e($tab_form['id']); ?>" class="group">
                    <?php cmb2_metabox_form($tab_form, $tab_form['id']); ?>
                </div>
            <?php endforeach; ?>
        </div>
        <?php
    }

    /**
     * Defines the theme option metabox and field configuration
     * @since  1.0.0
     * @return array
     */
    public function option_fields()
    {

        // Only need to initiate the array once per page-load
        if (!empty($this->option_metabox)) {
            return $this->option_metabox;
        }
        /**
         * Theme settings
         */
        $this->option_metabox[] = array(
            'id' => 'theme_settings',
            'title' => __('Temos spalvos', 'kk_metabox'),
            'show_on' => array('key' => 'options-page', 'value' => array('theme_settings'),),
            'show_names' => true,
            'fields' => array(

                array(
                    'name' => 'Temos spalvos',
                    'type' => 'title',
                    'id' => 'theme_helper_title',
                ),

                array(
                    'name' => __('Mygtukų ir nuorodų spalva', 'kk_metabox'),
                    'desc' => __('Viso puslapio nuorodų, navigacijos ir mygtukų spalva', 'kk_metabox'),
                    'default' => '#3aa395',
                    'id' => 'main_btn_color',
                    'type' => 'colorpicker',
                ),

                array(
                    'name' => __('Mygtukų spalva užvedus pelės žymeklį', 'kk_metabox'),
                    'desc' => __('Mygtukų spalva užvedus pelės žymeklį', 'kk_metabox'),
                    'default' => '#3aa395',
                    'id' => 'btn_hover',
                    'type' => 'colorpicker',
                ),

                array(
                    'name' => __('Studijų programos spalva', 'kk_metabox'),
                    'desc' => __('Antraščių ir mygtukų spalva', 'kk_metabox'),
                    'default' => '#3aa395',
                    'id' => 'main_stud_color',
                    'type' => 'colorpicker',
                ),

                array(
                    'name' => __('Specialių nuotraukų spalva', 'kk_metabox'),
                    'desc' => __('Nuotraukų karusėlės ir specialių nuotraukų spalva', 'kk_metabox'),
                    'default' => '#3aa395',
                    'id' => 'main_thumbnail_color',
                    'type' => 'colorpicker',
                ),

                array(
                    'name' => __('Kalendoriaus aktyvios dienos spalva', 'kk_metabox'),
                    'desc' => __('Kalendoriaus modulio aktivios dienos spalva', 'kk_metabox'),
                    'default' => '#3aa395',
                    'id' => 'main_calendar_active_color',
                    'type' => 'colorpicker',
                ),

                array(
                    'name' => __('Kalendoriaus einamos dienos spalva', 'kk_metabox'),
                    'desc' => __('Kalendoriaus modulio einamos dienos spalva', 'kk_metabox'),
                    'default' => '#3aa395',
                    'id' => 'main_calendar_current_color',
                    'type' => 'colorpicker',
                ),

                array(
                    'name' => __('Kalendoriaus spalva', 'kk_metabox'),
                    'desc' => __('Pagrindinė dienų, mėnesių ir kalendoriaus pavadinimų spalva ', 'kk_metabox'),
                    'default' => '#3aa395',
                    'id' => 'main_calendar_color',
                    'type' => 'colorpicker',
                ),

            ),
        );

        /**
         * Main page settings
         */
        $this->option_metabox[] = array(
            'id' => 'main_page_settings',
            'title' => __('Pagrindinis puslapis', 'kk_metabox'),
            'show_on' => array('key' => 'options-page', 'value' => array('main_page_settings'),),
            'show_names' => true,
            'fields' => array(
                array(
                    'name' => 'Logotipas',
                    'desc' => 'Viršutinis puslapio logotipas',
                    'type' => 'title',
                    'id' => 'logo_title'
                ),

                array(
                    'name' => __('Logotipas', 'kk_metabox'),
                    'id' => 'top_main_side_logo',
                    'default' => '',
                    'type' => 'file',
                    'text' => array(
                        'add_upload_file_text' => 'Pridėti failą',
                    ),
                    'options' => array(
                        'url' => false,
                    ),
                ),

                array(
                    'name' => 'Logotipas',
                    'desc' => 'Viršutinis svetainės logotipas',
                    'type' => 'title',
                    'id' => 'logo_title'
                ),

                array(
                    'name' => 'Nuorodų blokai',
                    'type' => 'title',
                    'id' => 'call_to_action_title'
                ),
                array(
                    'id' => 'info_links',
                    'type' => 'group',
                    'options' => array(
                        'group_title' => __('Nuorodų blokas {#}', 'cmb2'),
                        'add_button' => __('Pridėti nauja', 'cmb2'),
                        'remove_button' => __('Ištrinti', 'cmb2'),
                    ),
                    'fields' => array(
                        array(
                            'name' => __('Antraštė', 'kk_metabox'),
                            'desc' => __('Nuorodų bloko antraštė', 'kk_metabox'),
                            'default' => '',
                            'id' => 'link_block_header',
                            'type' => 'text',
                        ),

                        array(
                            'name' => __('Turinys', 'kk_metabox'),
                            'desc' => __('Nuorodų bloko turinys', 'kk_metabox'),
                            'default' => '',
                            'id' => 'link_block_content',
                            'type' => 'textarea_small',
                        ),

                        array(
                            'name' => __('Nuoroda', 'kk_metabox'),
                            'desc' => __('Nuorodų bloko mygtuko nuoroda kuri gali vesti ir į išorinius puslapius', 'kk_metabox'),
                            'default' => '',
                            'id' => 'link_block_button_url',
                            'type' => 'text_url',
                            'protocols' => array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet')
                        ),
                        array(
                            'name' => __('Mygtuko pavadinimas', 'kk_metabox'),
                            'desc' => __('Nuorodų bloko mygtuko pavadinimas kuris atsivaizduos ant mygtuko', 'kk_metabox'),
                            'default' => 'Plačiau',
                            'id' => 'link_block_button_title',
                            'type' => 'text',
                        ),
                    )
                )
            ));

        /**
         * News settings
         */

        $this->option_metabox[] = array(
            'id' => 'news_settings',
            'title' => __('Naujienos', 'kk_metabox'),
            'show_on' => array('key' => 'options-page', 'value' => array('news_settings'),),
            'show_names' => true,
            'fields' => array(
                array(
                    'name' => __('Kiek rodyti naujienų', 'kk_metabox'),
                    'id' => 'news_nub_settings',
                    'type' => 'text',
                    'default' => '6',
                    'attributes' => array(
                        'type' => 'number',
                        'pattern' => '\d*',
                    ),
                    'sanitization_cb' => 'absint',
                    'escape_cb' => 'absint',
                ),

                array(
                    'name' => __('Mygtuko tekstas', 'kk_metabox'),
                    'id' => 'news_btn_title',
                    'type' => 'text',
                    'default' => 'Daugiau naujienų'
                ),

                array(
                    'name' => __('Kategorijos tekstas', 'kk_metabox'),
                    'id' => 'news_category_text',
                    'type' => 'text',
                    'default' => 'Rodyti renginius'
                )
            )
        );

        /**
         * Stud page settings
         */

        $this->option_metabox[] = array(
            'id' => 'stud_settings',
            'title' => __('Studyjų programos nustatymai', 'kk_metabox'),
            'show_on' => array('key' => 'options-page', 'value' => array('stud_settings'),),
            'show_names' => true,
            'fields' => array(
                array(
                    'name' => __('Studyjų paieškos antraštė', 'kk_metabox'),
                    'id' => 'stud_search_title',
                    'default' => 'Rask tinkamiausią',
                    'type' => 'text',
                ),
                array(
                    'name' => __('Studyjų programos sąrašo antraštė', 'kk_metabox'),
                    'id' => 'stud_list_title',
                    'default' => 'Studijų programos',
                    'type' => 'text',
                )

            )
        );

        /**
         * Event settings
         */

        $this->option_metabox[] = array(
            'id' => 'event_settings',
            'title' => __('Renginių nustatymai', 'kk_metabox'),
            'show_on' => array('key' => 'options-page', 'value' => array('event_settings'),),
            'show_names' => true,
            'fields' => array(

                array(
                    'name' => __('Renginių skaičius', 'kk_metabox'),
                    'id' => 'event_nub_settings',
                    'type' => 'text',
                    'default' => '4',
                    'attributes' => array(
                        'type' => 'number',
                        'pattern' => '\d*',
                    ),
                    'sanitization_cb' => 'absint',
                    'escape_cb' => 'absint',
                ),

                array(
                    'name' => __('Renginių modulio antraštė', 'kk_metabox'),
                    'id' => 'event_shortcode_title',
                    'default' => 'Renginių kalendorius',
                    'type' => 'text',
                )

            )
        );

        /**
         * Contact settings
         */

        $this->option_metabox[] = array(
            'id' => 'contact_info_settings',
            'title' => __('Apatinės juostos kontaktai', 'kaunokolegija'),
            'show_on' => array('key' => 'options-page', 'value' => array('contact_info_settings'),),
            'show_names' => true,
            'fields' => array(
                array(
                    'name' => __('Antraštė', 'kk_metabox'),
                    'desc' => __('Pagrindinė antraštė', 'kk_metabox'),
                    'default' => 'Kontaktai',
                    'id' => 'footer_contact_title',
                    'type' => 'text',
                ),
                array(
                    'name' => __('Logotipas', 'kk_metabox'),
                    'id' => 'side_logo',
                    'default' => '',
                    'type' => 'file',
                    'text' => array(
                        'add_upload_file_text' => 'Pridėti failą',
                    )
                ),
                array(
                    'name' => __('Įmonės informacija', 'kk_metabox'),
                    'id' => 'contact_des',
                    'type' => 'textarea_small',
                    'default' => 'Įmonės informacija'
                ),

                array(
                    'name' => __('Telefono Nr.', 'kk_metabox'),
                    'repeatable' => true,
                    'id' => 'phone_nr_repeatable',
                    'type' => 'text',
                    'default' => '+370 123 12345',
                    'text' => array(
                        'add_row_text' => 'Pridėti naują numeri',
                        'remove_row_text' => __('Pašalinti', 'kaunokolegija'),
                    ),
                ),

                array(
                    'name' => __('E-paštas', 'kk_metabox'),
                    'repeatable' => true,
                    'id' => 'email_repeatable',
                    'type' => 'text',
                    'default' => 'kolegija@kolegija.lt',
                    'text' => array(
                        'add_row_text' => 'Pridėti naują e-paštą',
                        'remove_row_text' => __('Pašalinti', 'kaunokolegija'),
                    ),
                ),

                array(
                    'name' => __('Žemėlapio trumasis kodas', 'kk_metabox'),
                    'id' => 'map_shortcode',
                    'type' => 'text',
                    'desc' => 'Žemėlapio trumpasis kodas kuris yra gaunamas iš žemėlapio nustatymų ',
                    'default' => '[mappress mapid="ID"]'
                ),

                array(
                    'name' => __('Apatinės juostos spalva', 'kk_metabox'),
                    'id' => 'bottom_border_color',
                    'type' => 'colorpicker',
                    'default' => '#3AA395'
                ),

                array(
                    'name' => __('Autorinės teisės', 'kk_metabox'),
                    'id' => 'copyright',
                    'type' => 'text',
                    'default' => 'Autorinės teisės',
                    'desc' => 'Apatinės juostos tekstas'
                )
            )
        );

        /**
         * Facebook feed settings
         */

        $this->option_metabox[] = array(
            'id' => 'facebook_settings',
            'title' => __('Facebook', 'kk_metabox'),
            'show_on' => array('key' => 'options-page', 'value' => array('facebook_settings'),),
            'show_names' => true,
            'fields' => array(
                array(
                    'name' => __('Hashtag', 'kk_metabox'),
                    'desc' => __('Žodis pagal kūrį atnaujins facebook naujienas', 'kk_metabox'),
                    'default' => '#kaunokolegija',
                    'id' => 'facebook_hashtag',
                    'type' => 'text',
                ),
                array(
                    'name' => __('Facebook puslapio ID', 'kk_metabox'),
                    'desc' => __('Facebook puslapio id', 'kk_metabox'),
                    'default' => 'Kauno.kolegija',
                    'id' => 'facebook_id',
                    'type' => 'text'
                ),
                array(
                    'name' => __('Facebook app id', 'kk_metabox'),
                    'desc' => __('Facebook app id', 'kk_metabox'),
                    'default' => '2020083878279547',
                    'id' => 'fb_app_id',
                    'type' => 'text'
                ),
                array(
                    'name' => __('Facebook app secret', 'kk_metabox'),
                    'desc' => __('Facebook app secret', 'kk_metabox'),
                    'default' => 'o9pQMoxtK75T70aezcnBMHhRnZE',
                    'id' => 'fb_app_secret',
                    'type' => 'text'
                ),
                array(
                    'name' => __('Access token', 'kk_metabox'),
                    'desc' => __('Access token', 'kk_metabox'),
                    'default' => '',
                    'id' => 'fb_accessToken',
                    'type' => 'text'
                ),

            )
        );
        /**
         * Youtube feed settings
         */

        $this->option_metabox[] = array(
            'id' => 'youtube_settings',
            'title' => __('Youtube', 'kk_metabox'),
            'show_on' => array('key' => 'options-page', 'value' => array('youtube_settings'),),
            'show_names' => true,
            'fields' => array(
                array(
                    'name' => __('Grojaraščio id', 'kk_metabox'),
                    'desc' => __('Unikalus grojaraščio kodas', 'kk_metabox'),
                    'default' => 'PLP4HsVgMHDD0Jh9lFHxt7FNJ0xPUm1gR8',
                    'id' => 'youtube_playlist_id',
                    'type' => 'text',
                ),
                array(
                    'name' => __('Youtube API', 'kk_metabox'),
                    'desc' => __('Youtube API raktas iš <a href="https://developers.google.com/maps/documentation/geocoding/get-api-key" target="_blank">google konsolės</a>', 'kk_metabox'),
                    'default' => '',
                    'id' => 'youtube_api',
                    'type' => 'text'
                ),
            )
        );

        $this->option_metabox[] = array(
            'id' => 'instagram_settings',
            'title' => __('Instagram', 'kk_metabox'),
            'show_on' => array('key' => 'options-page', 'value' => array('instagram_settings'),),
            'show_names' => true,
            'fields' => array(
                array(
                    'name' => __('Instagram id', 'kk_metabox'),
                    'desc' => __('Instagram id', 'kk_metabox'),
                    'default' => 'kaunokolegija',
                    'id' => 'instagram_id',
                    'type' => 'text'
                ),
                array(
                    'name' => __('Instagram account id', 'kk_metabox'),
                    'desc' => __('Instagram account id', 'kk_metabox'),
                    'default' => 'kaunokolegija',
                    'id' => 'account_id',
                    'type' => 'text'
                ),

            )
        );

        /**
         * Slider settings
         */

        $this->option_metabox[] = array(
            'id' => 'swipe_slider_settings',
            'title' => __('Nuotraukų karuselė', 'kk_metabox'),
            'show_on' => array('key' => 'options-page', 'value' => array('swipe_slider_settings'),),
            'show_names' => true,
            'fields' => array(
                array(
                    'id' => 'swipe_slider_group',
                    'type' => 'group',
                    'description' => __('Nuotraukų karuselės nustatymai', 'cmb2'),
                    'options' => array(
                        'group_title' => __('Nuotrauka {#}', 'cmb2'),
                        'add_button' => __('Pridėti nauja', 'cmb2'),
                        'remove_button' => __('Ištrinti', 'cmb2'),
                    ),
                    'fields' => array(

                        array(
                            'name' => 'Nuotraukos failas',
                            'id' => 'swipe_slider_image',
                            'type' => 'file',
                            // Optional:
                            'options' => array(
                                'url' => false,
                            ),
                            'text' => array(
                                'add_upload_file_text' => 'Pridėti failą'
                            ),

                        ),
                        array(
                            'name' => __('Nuotraukų karuselės antraštė', 'kk_metabox'),
                            'desc' => __('Nuotraukų karuselės antraštė kuri atsivaizduos apačioja', 'kk_metabox'),
                            'id' => 'swipe_slider_title',
                            'type' => 'text',
                        ),
                        array(
                            'name' => __('Nuotraukos nuoroda', 'cmb2'),
                            'id' => 'swipe_slider_url',
                            'type' => 'text_url',
                        )
                    )
                )

            )
        );

        //insert extra tabs here
        return $this->option_metabox;
    }

    /**
     * Returns the option key for a given field id
     * @since  1.0.0
     * @return array
     */
    public function get_option_key($field_id)
    {
        $option_tabs = $this->option_fields();
        foreach ($option_tabs as $option_tab) { //search all tabs
            foreach ($option_tab['fields'] as $field) { //search all fields
                if ($field['id'] == $field_id) {
                    return $option_tab['id'];
                }
            }
        }
        return $this->key; //return default key if field id not found
    }

    /**
     * Public getter method for retrieving protected/private variables
     * @since  1.0.0
     * @param  string $field Field to retrieve
     * @return mixed          Field value or exception is thrown
     */
    public function __get($field)
    {
        // Allowed fields to retrieve
        if (in_array($field, array('key', 'fields', 'title', 'options_pages'), true)) {
            return $this->{$field};
        }
        if ('option_metabox' === $field) {
            return $this->option_fields();
        }

        throw new Exception('Invalid property: ' . $field);
    }

}

$my_Admin = new my_Admin();
$my_Admin->hooks();

/**
 * Wrapper function around cmb_get_option
 * @since  1.0.0
 * @param  string $key Options array key
 * @return mixed        Option value
 */

function my_option($key = '', $default = false){
    global $my_Admin;

    if ( function_exists( 'cmb2_get_option' ) ) {

        return cmb2_get_option($my_Admin->get_option_key($key), $key);
    }
    // Fallback to get_option if CMB2 is not loaded yet.
    $opts = get_option( 'my_options', $default );

    $val = $default;
    if ( 'all' == $key ) {

        $val = $opts;

    } elseif ( is_array( $opts ) && array_key_exists( $key, $opts ) && false !== $opts[ $key ] ) {

        $val = $opts[ $key ];

    }

    return $val;
}