| Server IP : 82.208.35.60 / Your IP : 216.73.216.89 Web Server : Apache/2.4.55 (FreeBSD) OpenSSL/1.1.1q-freebsd PHP/7.3.31 System : FreeBSD server7.d2m.cz 12.4-RELEASE-p9 FreeBSD 12.4-RELEASE-p9 GENERIC amd64 User : studiokobylisy_cz ( 1008) PHP Version : 7.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/studiokobylisy_cz/www/wp-content/themes/studiokobylisy/ |
Upload File : |
<?php
// CPT TAXONOMY
include('configure/cpt-taxonomy.php');
// Utilities
include('configure/utilities.php');
// CONFIG
include('configure/configure.php');
// JAVASCRIPT & CSS
include('configure/js-css.php');
// SHORTCODES
include('configure/shortcodes.php');
// ACF
include('configure/acf.php');
// HOOKS ADMIN
if (is_admin()) {
include('configure/admin.php');
}
function add_menu_link_class($atts, $item, $args)
{
$atts['class'] = 'nav-link';
return $atts;
}
add_filter('nav_menu_link_attributes', 'add_menu_link_class', 1, 3);
if (function_exists('add_image_size')) {
add_image_size('slider', 1200);
add_image_size('slider-thumbs', 300);
}
$header_info = array(
'width' => 980,
'height' => 60,
'default-image' => get_template_directory_uri() . '/assets/dist/img/studio-kobylisy-default.jpg',
);
add_theme_support('custom-header', $header_info);
/*** New menu item ***/
function my_admin_menu()
{
$page_title = 'Nastavení webu';
$menu_title = 'Nastavení webu';
$capability = 'edit_posts';
$menu_slug = 'theme_options_page';
$function = 'my_theme_settings_page';
$icon_url = '';
$position = 110;
add_menu_page($page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position);
}
add_action('admin_menu', 'my_admin_menu');
function my_theme_settings_page()
{
/*** New section ***/
?>
<h1>Nastavení webu</h1>
<?php settings_errors(); ?>
<form method="post" action="options.php" enctype="multipart/form-data">
<?php settings_fields("ff_theme_options"); ?>
<?php do_settings_sections('theme_options') ?>
<?php submit_button(); ?>
</form>
<?php
}
/*** Options fields ***/
add_action('admin_init', 'ff_custom_setting');
function ff_custom_setting()
{
register_setting('ff_theme_options', 'phone_field');
register_setting('ff_theme_options', 'email_field');
register_setting('ff_theme_options', 'bank_field');
register_setting('ff_theme_options', 'address_field');
register_setting('ff_theme_options', 'maplink_field');
register_setting('ff_theme_options', 'mapiframe_field');
register_setting("ff_theme_options", "footer_background", "handle_footer_upload");
add_settings_section('ff_theme_options', 'Možnosti šablony', null, 'theme_options');
add_settings_field('theme-phone', 'Telefon', 'theme_phone_func', 'theme_options', 'ff_theme_options');
add_settings_field('theme-email', 'E-mail', 'theme_email_func', 'theme_options', 'ff_theme_options');
add_settings_field('theme-bank', 'Bankovní účet', 'theme_bank_func', 'theme_options', 'ff_theme_options');
add_settings_field('theme-address', 'Adresa', 'theme_address_func', 'theme_options', 'ff_theme_options');
add_settings_field('theme-maplink', 'Link na mapu', 'theme_maplink_func', 'theme_options', 'ff_theme_options');
add_settings_field('theme-mapiframe', 'iframe na mapu<br>(1200x300px)', 'theme_mapiframe_func', 'theme_options', 'ff_theme_options');
add_settings_field('footer_background', 'Obrázek v patičce', 'logo_display', 'theme_options', 'ff_theme_options');
}
function ff_theme_options()
{
echo 'Add your theme options';
}
function theme_phone_func()
{
$phone = esc_attr(get_option('phone_field'));
echo '<input type="text" name="phone_field" value="' . $phone . '" placeholder="Telefonní číslo">';
}
function theme_email_func()
{
$email = esc_attr(get_option('email_field'));
echo '<input type="text" name="email_field" value="' . $email . '" placeholder="E-mail">';
}
function theme_bank_func()
{
$bank = esc_attr(get_option('bank_field'));
echo '<input type="text" name="bank_field" value="' . $bank . '" placeholder="Číslo účtu">';
}
function theme_address_func()
{
$address = esc_attr(get_option('address_field'));
echo '<textarea name="address_field" placeholder="Adresa" rows="3">' . $address . '</textarea>';
}
function theme_maplink_func()
{
$maplink = esc_attr(get_option('maplink_field'));
echo '<input type="text" name="maplink_field" value="' . $maplink . '" placeholder="Link na mapu">';
}
function theme_mapiframe_func()
{
$mapiframe = esc_attr(get_option('mapiframe_field'));
echo '<input type="text" name="mapiframe_field" value="' . $mapiframe . '" placeholder="Iframe mapy">';
}
function logo_display()
{
?>
<div style="display:flex; flex-direction: column;">
<?php $footer_img = get_option('footer_background');
if ($footer_img) {
echo '<img src="' . $footer_img . '" width="400" style="margin-bottom:20px;" />';
}
echo $footer_img;
?>
<input type="hidden" name="ofooter_background" value="<?php echo get_option('footer_background'); ?>" readonly />
<input type="file" name="footer_background" id="imgupload" />
</div>
<?php
}
function handle_footer_upload($option)
{
if (isset($_FILES["footer_background"]) && !empty($_FILES['footer_background']['name'])) {
$urls = wp_handle_upload($_FILES["footer_background"], array('test_form' => FALSE));
$temp = $urls["url"];
return $temp;
} elseif (isset($_FILES["footer_background"]) && empty($_FILES['footer_background']['name'])) {
$urls = $_POST["ofooter_background"];
return $urls;
}
return $option;
}
add_action('admin_head', 'custom_admin_css');
function custom_admin_css()
{
echo '<style>
.wp-block-image.is-style-circle-mask img, .wp-block-image.is-style-rounded img, .wp-block-image .is-style-rounded img {
border-radius: 20px;
}
</style>';
}