403Webshell
Server IP : 185.252.147.100  /  Your IP : 216.73.217.33
Web Server : nginx/1.27.3
System : Linux mitrofanov.ru 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64
User : mitr ( 1000)
PHP Version : 8.2.29
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /www/html/metal.mitrofanov.ru/wordpress/wp-content/themes/generatepress_child/inc/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/html/metal.mitrofanov.ru/wordpress/wp-content/themes/generatepress_child/inc/theme-options.php
<?php
    if (! defined('ABSPATH')) {
        exit;
    }

    // add_action( 'admin_enqueue_scripts', 'contact_info_admin_enqueue_scripts_action' );

    // function contact_info_admin_enqueue_scripts_action( $hook_suffix ){

    // 	if ($hook_suffix == 'settings_page_contact_info-options')
    // 	{
    // 		wp_enqueue_style( 'wp-admin-contact', get_stylesheet_directory_uri() .'/assets/admin/wp-admin-contact.css' );
    // 		wp_enqueue_script( 'wp-admin-contact', get_stylesheet_directory_uri() . '/assets/admin/wp-admin-contact.min.js', '', '', true );

    // 	}

    // }
    add_action('admin_print_scripts-settings_page_contact_info-options', 'admin_print_scripts_page_contact_info');

    function admin_print_scripts_page_contact_info()
    {
        echo '<script>window.addEventListener("load",function(){const a=document.getElementById("telephones"),e=document.querySelectorAll(".contact-input-wrapper .clean"),p=t=>{t.addEventListener("click",()=>{var e=t.closest("p.contact-input-wrapper");e.dataset.tel&&0!=e.dataset.tel?e.remove():e.querySelector(".input").value=""})};e.forEach(e=>{p(e)}),a.querySelector("button.addto").addEventListener("click",e=>{e.preventDefault();var e=a.querySelectorAll("p.contact-input-wrapper"),t=e.length,e=e[t-1],n=document.createElement("p");newinput=document.createElement("input"),(newspan=document.createElement("span")).innerHTML="&#10006;",newinput.type="tel",newinput.name="contact_info_theme_options[tel]["+t+"]",newinput.classList.add("input"),newinput.placeholder="+79876543210",n.classList.add("contact-input-wrapper"),n.dataset.tel=t,newspan.classList.add("clean"),n.appendChild(newinput),n.appendChild(newspan),e.after(n),p(newspan)})});</script>';
    }

    add_action('admin_print_styles-settings_page_contact_info-options', 'admin_print_styles_contact_info');

    function admin_print_styles_contact_info()
    {
        echo '<style>.contacts-form-table{text-align:left}.contacts-form-table th{padding-right:1.5rem;max-width:18ch;padding-bottom:1.5rem}.contacts-form-table .contact-input-wrapper{position:relative}.contacts-form-table input{width:100%}.contacts-form-table input::placeholder,.contacts-form-table textarea::placeholder{color:#c5c5c5;font-size:.9rem}.contacts-form-table .clean{position:absolute;right:.4rem;top:.5rem;width:.8rem;height:.8rem;background:#fff;color:#ff6161;display:block;border-radius:50%;text-align:center;cursor:pointer;border:1px solid #ff9494;font-size:.6rem}.contacts-form-table .clean:hover{background:red;color:#fff}.contacts-form-table .addto{border:none;color:#00f;text-decoration-line:underline;cursor:pointer}</style>';

    }

    function add_theme_options_init()
    {
        register_setting('contact_info_options_group', 'contact_info_theme_options', 'validate_theme_options');
    }

    function add_theme_options_page()
    {

        $page_title = 'Контакты сайта';
        $menu_title = 'Контакты сайта';
        $cap        = 'manage_options'; // capability required for access to this menu
        $slug       = 'contact_info-options';
        $callback   = 'draw_theme_options_page';

        add_options_page($page_title, $menu_title, $cap, $slug, $callback, 1);
    }

    add_filter('pre_update_option_contact_info_theme_options', 'wp_kama_pre_update_option_filter', 10, 3);

    function wp_kama_pre_update_option_filter($value, $old_value, $option)
    {
        $value = arrayFilterRecursive($value);
        return $value;
    }

    function arrayFilterRecursive($array)
    {
        foreach ($array as $key => &$value) {
            if (is_array($value)) {
                $value = arrayFilterRecursive($value);
                $value = array_key_exists('0', $value) ? array_values($value) : $value;
            } else if (empty($value)) {
                unset($array[ $key ]);
            }
        }
        $array = array_filter($array);
        return $array;
    }

    function draw_theme_options_page()
    {
    ?>
<div class="wrap">
<h2>Настройки контактных данных сайта</h2>
<form method="post" action="options.php">
<?php

        // this should be the same as the second parameter of register_setting()
        $opt_name = 'contact_info_theme_options';

        // adds all the necessary hidden form fields
        settings_fields('contact_info_options_group');

        // get the existing options
        $options = get_option($opt_name);

        //print_r($options);

    ?>
	<table class="contacts-form-table">
		<tr valign="top"><th scope="row"><h3>Контактный телефон</h3><small>первый указанный номер будет основным</small></th>
			<td id="telephones">
				<?php

                        $tel_input = '<p class="contact-input-wrapper" data-tel="%d"><input class="input" placeholder="+79876543210" type="tel" name="%s[tel][%d]" value="%s"><span class="clean">&#10006;</span></p>';
                        if (! empty($options[ 'tel' ])) {
                            foreach ($options[ 'tel' ] as $key => $value) {
                                echo sprintf($tel_input, $key, $opt_name, $key, $value);
                            }
                        } else {
                            echo sprintf($tel_input, '0', $opt_name, '0', '');
                        }
                    ?>
				<button class="addto">добавить дополнительный номер</button>
			</td>
		</tr>
		<tr valign="top"><th scope="row"><h3>E-mail</h3></th>
			<td>
				<p class="contact-input-wrapper">
					<input type="email" placeholder="mail@mail.ru" class="input" name="<?php echo $opt_name ?>[email]" value="<?php echo $options[ 'email' ] ?? '';
    ?>">
					<span class="clean">&#10006;</span>
				</p>
			</td>
		</tr>
		<tr valign="top"><th scope="row"><h3>Telegram</h3></th>
			<td>
				<p class="contact-input-wrapper">
					<input type="text" placeholder="https://t.me/nick" class="input" name="<?php echo $opt_name ?>[social][Telegram]" value="<?php echo $options[ 'social' ][ 'Telegram' ] ?? '';
    ?>">
					<span class="clean">&#10006;</span>
				</p>
			</td>
		</tr>
		<tr valign="top"><th scope="row"><h3>Вконтакте</h3></th>
			<td>
				<p class="contact-input-wrapper">
					<input type="text" placeholder="https://vk.com/nick" class="input" name="<?php echo $opt_name ?>[social][Вконтакте]" value="<?php echo $options[ 'social' ][ 'Вконтакте' ] ?? '';
    ?>">
					<span class="clean">&#10006;</span>
				</p>
			</td>
		</tr>
		<tr valign="top"><th scope="row"><h3>Одноклассники</h3></th>
			<td>
				<p class="contact-input-wrapper">
					<input type="text" placeholder="https://ok.ru/group/1000000000" class="input" name="<?php echo $opt_name ?>[social][Одноклассники]" value="<?php echo $options[ 'social' ][ 'Одноклассники' ] ?? '';
    ?>">
					<span class="clean">&#10006;</span>
				</p>
			</td>
		</tr>
		<tr valign="top"><th scope="row"><h3>Адрес</h3></th>
			<td>
				<p class="contact-input-wrapper">
					<textarea class="input" placeholder="г. Владивосток, Авраменко 2" rows="3" cols="50" name="<?php echo $opt_name ?>[address]"><?php echo $options[ 'address' ] ?? '';
    ?></textarea>
					<span class="clean">&#10006;</span>
				</p>
			</td>
		</tr>
		<tr valign="top"><th scope="row"><h3>Часы работы</h3></th>
			<td>
				<p class="contact-input-wrapper">
					<textarea class="input" placeholder="8:00 — 17:00
(выходной: суббота,воскресенье)" rows="3" cols="50" name="<?php echo $opt_name ?>[hours]"><?php echo $options[ 'hours' ] ?? '';
    ?></textarea>
					<span class="clean">&#10006;</span>
				</p>
			</td>
		</tr>



    </table>

    <p class="submit">
        <input type="submit" class="button-primary" value="<?php _e('Save Changes')?>" />
    </p>

</form>
</div>
<?php

    }

    function validate_theme_options($input)
    {
        $input[ 'social' ][ 'Вконтакте' ] = wp_filter_nohtml_kses($input[ 'social' ][ 'Вконтакте' ]);
        $input[ 'social' ][ 'Одноклассники' ] = wp_filter_nohtml_kses($input[ 'social' ][ 'Одноклассники' ]);
        $input[ 'social' ][ 'Telegram' ] = wp_filter_nohtml_kses($input[ 'social' ][ 'Telegram' ]);

        return $input;
    }

    add_action('admin_init', 'add_theme_options_init');
    add_action('admin_menu', 'add_theme_options_page');

    /********** RENDER BLOCKS ***************/

    add_filter('render_block', function ($block_content, $block) {

        $options = get_option('contact_info_theme_options');

        if (! empty($block[ 'attrs' ][ 'className' ]) && $block[ 'attrs' ][ 'className' ] == 'conto-social') {

            $block_content = '';

            $socials = $options[ 'social' ];

            if (! empty($socials)) {

                $block_content .= '<div class="conto-headline">Связь</div>';

                $social_p = '<p class="has-base-3-color has-text-color has-link-color"><a href="%s" target="_blank">%s</a></p>';

                foreach ($socials as $key => $val) {
                    $block_content .= sprintf($social_p, $val, $key);

                }
            }

        }

        if (! empty($block[ 'attrs' ][ 'className' ]) && $block[ 'attrs' ][ 'className' ] == 'conto-hours') {

            $block_content = '';

            $hours = $options[ 'hours' ];

            if (! empty($hours)) {

                $block_content .= '<div class="conto-headline">Часы работы</div>';

                $block_content .= '<p class="has-base-3-color has-text-color has-link-color">' . $hours . '</p>';

            }

        }

        if (! empty($block[ 'attrs' ][ 'className' ]) && $block[ 'attrs' ][ 'className' ] == 'conto-contacts') {

            $block_content = '';
            $block_content .= '<div class="conto-headline">Контакты</div>';

            if (! empty($options[ 'address' ])) {

                $block_content .= '<p class="has-base-3-color has-text-color has-link-color">' . $options[ 'address' ] . '</p>';

            }

            if (! empty($options[ 'email' ])) {

                $block_content .= '<p class="has-base-3-color has-text-color has-link-color"><a href="mailto:' . $options[ 'email' ] . '">' . $options[ 'email' ] . '</a></p>';

            }

            $phones = $options[ 'tel' ];

            if (! empty($phones)) {

                $phone_p = '<p class="has-base-3-color has-text-color has-link-color"><a href="%s" target="_blank">%s</a></p>';

                foreach ($phones as $key => $val) {
                    $block_content .= sprintf($phone_p, $val, formatting($val));

                }
            }

        }

        return $block_content;
    }, 10, 2);

    function formatting($phone)
    {

        // Pass phone number in preg_match function
        if (preg_match(
            '/^(\+[0-9])([0-9]{3})([0-9]{3})([0-9]{2})([0-9]{2})$/',
            $phone, $value)) {

            // Store value in format variable
            $format = $value[ 1 ] . ' ' .
                $value[ 2 ] . ' ' . $value[ 3 ] . ' ' . $value[ 4 ] . ' ' . $value[ 5 ];
        } else {

            $format = $phone;

            // If given number is invalid
            //echo "Invalid phone number <br>";
        }

        // Print the given format
        //echo("$format" . "<br>");
        return $format;
    }

    /*************** HEADER CALL *******************/

    add_filter('wp_nav_menu_items', 'add_extra_item_to_nav_menu', 10, 2);
    function add_extra_item_to_nav_menu($items, $args)
    {

        if ($args->theme_location == 'primary') {
            $options = get_option('contact_info_theme_options');
            if (! empty($options)) {

                $phone = array_shift($options[ 'tel' ]);

                if (! empty($phone)) {
                    $items .= '<li class="header-call menu-item"><a href="tel:' . $phone . '">' . formatting($phone) . '</a></li>';
                }

            }
        }

    return $items;
}

Youez - 2016 - github.com/yon3zu
LinuXploit