function barcelona_social_icons($items = array()) { $output = ''; if (!is_array($items) || empty($items)) { $items = false; } $barcelona_social_links = barcelona_get_social_links(); foreach ($barcelona_social_links as $k => $v) { if ($items && !in_array($k, $items)) { unset($barcelona_social_links[$k]); } } if (!empty($barcelona_social_links)) { $output = '<ul class="social-icons">'; foreach ($barcelona_social_links as $k => $v) { $output .= '<li><a href="' . esc_url($v['href']) . '" title="' . esc_attr($v['title']) . '"><span class="fa fa-' . sanitize_html_class($v['icon']) . '"></span></a></li>'; } $output .= '</ul>'; } return $output; }
function barcelona_get_option($field, $is_default = FALSE, $affix_check = FALSE) { global $wp_query; if ($field == 'social_links') { return barcelona_get_social_links(); } if ($field == 'posts_layout' && (is_archive() || is_search()) && !have_posts()) { return 'none'; } // Remove prefix of the key if (strpos($field, 'barcelona_') === 0) { $field = preg_replace('#^barcelona_#is', '', $field); } if (is_single() || is_page()) { $barcelona_post_option = get_post_meta(get_the_ID(), 'barcelona_' . $field, true); if (!empty($barcelona_post_option)) { return $barcelona_post_option; } } if (preg_match('#__category_([0-9]+)$#is', $field, $barcelona_match)) { $barcelona_affix = '_category'; $barcelona_cat_id = end($barcelona_match); $field = preg_replace('#_' . $barcelona_cat_id . '$#', '', $field); } else { if (is_home()) { $barcelona_affix = '_home'; } else { if (is_category()) { $barcelona_affix = '_category'; $barcelona_cat_id = $wp_query->get_queried_object_id(); } else { if (is_tag()) { $barcelona_affix = '_tag'; } else { if (is_author()) { $barcelona_affix = '_author'; } else { if (is_search()) { $barcelona_affix = '_search'; } else { if (is_archive()) { $barcelona_affix = '_archive'; } else { if (is_single()) { $barcelona_affix = '_single'; } else { if (is_page()) { $barcelona_affix = '_page'; } } } } } } } } } if (isset($barcelona_cat_id)) { $barcelona_cat_option = get_option('_barcelona_category_' . $barcelona_cat_id); $barcelona_f = preg_replace('#__category$#', '', $field); if (is_array($barcelona_cat_option)) { if ($barcelona_f == 'custom_background' && $barcelona_cat_option['set_background'] == 'custom') { return $barcelona_cat_option['background']; } else { if (in_array($barcelona_f, array('header_ad_1', 'header_ad_2'))) { if ($barcelona_cat_option['add_header_ad'] == 'custom') { return $barcelona_cat_option[$barcelona_f]; } } else { if (isset($barcelona_cat_option[$barcelona_f])) { return $barcelona_cat_option[$barcelona_f]; } } } } else { if (in_array($barcelona_f, array('add_header_ad', 'set_background'))) { return 'inherit'; } } } /* Whether to check the field more spesific or not */ $barcelona_check_affix = true; if (in_array($field, array('header_ad_1', 'header_ad_2')) && barcelona_get_option('add_header_ad') == 'inherit') { $barcelona_check_affix = false; } if ($barcelona_check_affix && isset($barcelona_affix) && !preg_match('#_' . $barcelona_affix . '$#is', $field)) { $barcelona_field = 'barcelona_' . $field . '_' . $barcelona_affix; $barcelona_opt = barcelona_get_option($barcelona_field, false, true); if ($barcelona_opt) { return $barcelona_opt; } } // Default values of theme options $barcelona_defaults = array('header_custom_code' => '', 'footer_custom_code' => '', 'css_custom_code' => '', 'show_header_logo_as_text' => 'off', 'header_logo_text' => get_bloginfo('name'), 'header_dark_logo_url' => '', 'header_dark_retina_logo_url' => '', 'header_light_logo_url' => '', 'header_light_retina_logo_url' => '', 'show_footer_logo_as_text' => 'off', 'footer_logo_text' => get_bloginfo('name'), 'footer_dark_logo_url' => '', 'footer_dark_retina_logo_url' => '', 'footer_light_logo_url' => '', 'footer_light_retina_logo_url' => '', 'favicon_url' => '', 'apple_touch_icon_iphone' => '', 'apple_touch_icon_ipad' => '', 'apple_touch_icon_retina' => '', 'default_sidebar' => 'barcelona-default-sidebar', 'sidebar_position' => 'right', 'header_style' => 'a', 'show_top_bar_menu' => 'on', 'show_header_social_icons' => 'on', 'show_footer_sidebars' => 'on', 'show_footer_logo' => 'on', 'show_footer_menu' => 'on', 'footer_copyright_text' => '', 'mm_orderby' => 'date', 'mm_order' => 'desc', 'show_tags_under_mm' => 'on', 'boxed_layout' => 'off', 'sticky_nav_bar' => 'on', 'sticky_sidebars' => 'on', 'show_breadcrumb' => 'on', 'show_cat_title' => 'on', 'disqus_comments' => 'off', 'disqus_sitename' => '', 'posts_layout' => 'c', 'posts_layout__archive' => 'd', 'posts_layout__author' => 'd', 'fp_style__category' => 'none', 'fp_max_number_of_posts__category' => 3, 'fp_filter_tag__category' => '', 'fp_filter_post__category' => '', 'fp_orderby__category' => 'date', 'fp_order__category' => 'desc', 'featured_image_style' => 'fw', 'show_comments' => 'on', 'show_comments__page' => 'on', 'show_tags' => 'on', 'show_social_sharing' => 'on', 'show_social_sharing__page' => 'off', 'show_author_box' => 'on', 'show_voting' => 'on', 'show_voting__page' => 'off', 'voting_login_req' => 'on', 'show_post_nav' => 'on', 'show_related_posts' => 'on', 'post_meta_choices' => array('date', 'views', 'likes', 'comments'), 'sidebars' => '', 'social_rss_feed_url' => '', 'social_facebook_url' => '', 'social_twitter_url' => '', 'social_google_plus_url' => '', 'social_linkedin_url' => '', 'social_youtube_url' => '', 'social_vimeo_url' => '', 'social_vk_url' => '', 'social_instagram_url' => '', 'social_pinterest_url' => '', 'social_github_url' => '', 'social_flickr_url' => '', 'facebook_app_id' => '', 'add_facebook_og_tags' => 'on', 'add_facebook_sdk' => 'off', 'twitter_access_token' => '', 'twitter_access_token_secret' => '', 'twitter_consumer_key' => '', 'twitter_consumer_secret' => '', 'font_headings' => 'Montserrat', 'font_general' => 'Montserrat', 'font_latin_ext' => 'off', 'font_cyrillic_ext' => 'off', 'font_greek_charset' => 'off', 'top_nav_color_scheme' => 'dark', 'footer_color_scheme' => 'dark', 'megamenu_color_scheme' => 'dark', 'selection_color' => '#f2132d', 'add_header_ad' => 'inherit', 'header_ad_1' => '', 'header_ad_2' => '', 'set_background' => 'inherit', 'custom_background' => '', 'show_post_content_ad' => 'off', 'post_content_ad_1' => '', 'post_content_ad_2' => ''); $barcelona_pattern = '#__(home|category|tag|author|search|archive|single|page)$#is'; if (!array_key_exists($field, $barcelona_defaults)) { if (preg_match($barcelona_pattern, $field)) { $barcelona_default_field = preg_replace($barcelona_pattern, '', $field); if (!array_key_exists($barcelona_default_field, $barcelona_defaults)) { return false; } $barcelona_default_option = $barcelona_defaults[$barcelona_default_field]; } else { return false; } } if (!isset($barcelona_default_option)) { $barcelona_default_option = $barcelona_defaults[$field]; } else { if (isset($barcelona_default_field) && $is_default) { return barcelona_get_option($barcelona_default_field); } } if (function_exists('ot_get_option')) { $barcelona_result = ot_get_option('barcelona_' . $field); if (empty($barcelona_result)) { return preg_match($barcelona_pattern, $field) && $affix_check ? false : $barcelona_default_option; } return $barcelona_result; } return $barcelona_default_option; }