/** * Функція для відображення іконок соціальних мереж */ function doc_theme_social_icons() { $facebook_url = get_theme_mod('doc_theme_facebook', ''); $twitter_url = get_theme_mod('doc_theme_twitter', ''); $instagram_url = get_theme_mod('doc_theme_instagram', ''); $youtube_url = get_theme_mod('doc_theme_youtube', ''); $linkedin_url = get_theme_mod('doc_theme_linkedin', ''); $telegram_url = get_theme_mod('doc_theme_telegram', ''); $viber_url = get_theme_mod('doc_theme_viber', ''); // Виводимо соціальні іконки лише якщо є хоча б одна соціальна мережа if (empty($facebook_url) && empty($twitter_url) && empty($instagram_url) && empty($youtube_url) && empty($linkedin_url) && empty($telegram_url) && empty($viber_url)) { // Перевіряємо, чи є меню соціальних іконок if (has_nav_menu('social')) { wp_nav_menu(array( 'theme_location' => 'social', 'menu_id' => 'social-menu', 'menu_class' => 'social-links-menu', 'link_before' => '', 'link_after' => '', 'container' => 'div', 'container_class' => 'social-menu-container', 'depth' => 1, )); } return; } echo '
'; if (!empty($facebook_url)) { echo ''; } if (!empty($twitter_url)) { echo ''; } if (!empty($instagram_url)) { echo ''; } if (!empty($youtube_url)) { echo ''; } if (!empty($linkedin_url)) { echo ''; } if (!empty($telegram_url)) { echo ''; } if (!empty($viber_url)) { echo ''; } echo '
'; } /** * Додавання налаштувань соціальних мереж у кастомайзер */ function doc_theme_social_customize_register($wp_customize) { // Додаємо секцію $wp_customize->add_section('doc_theme_social_section', array( 'title' => __('Соціальні мережі', 'doc-theme-wp'), 'priority' => 120, )); // Facebook $wp_customize->add_setting('doc_theme_facebook', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', )); $wp_customize->add_control('doc_theme_facebook', array( 'label' => __('Facebook URL', 'doc-theme-wp'), 'section' => 'doc_theme_social_section', 'type' => 'url', )); // Twitter $wp_customize->add_setting('doc_theme_twitter', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', )); $wp_customize->add_control('doc_theme_twitter', array( 'label' => __('Twitter URL', 'doc-theme-wp'), 'section' => 'doc_theme_social_section', 'type' => 'url', )); // Instagram $wp_customize->add_setting('doc_theme_instagram', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', )); $wp_customize->add_control('doc_theme_instagram', array( 'label' => __('Instagram URL', 'doc-theme-wp'), 'section' => 'doc_theme_social_section', 'type' => 'url', )); // YouTube $wp_customize->add_setting('doc_theme_youtube', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', )); $wp_customize->add_control('doc_theme_youtube', array( 'label' => __('YouTube URL', 'doc-theme-wp'), 'section' => 'doc_theme_social_section', 'type' => 'url', )); // LinkedIn $wp_customize->add_setting('doc_theme_linkedin', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', )); $wp_customize->add_control('doc_theme_linkedin', array( 'label' => __('LinkedIn URL', 'doc-theme-wp'), 'section' => 'doc_theme_social_section', 'type' => 'url', )); // Telegram $wp_customize->add_setting('doc_theme_telegram', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', )); $wp_customize->add_control('doc_theme_telegram', array( 'label' => __('Telegram URL', 'doc-theme-wp'), 'section' => 'doc_theme_social_section', 'type' => 'url', )); // Viber $wp_customize->add_setting('doc_theme_viber', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', )); $wp_customize->add_control('doc_theme_viber', array( 'label' => __('Viber URL', 'doc-theme-wp'), 'section' => 'doc_theme_social_section', 'type' => 'url', )); } add_action('customize_register', 'doc_theme_social_customize_register');