Example #1
0
<!DOCTYPE html>
<html <?php 
language_attributes();
?>
>              
    <head>
        <meta charset="<?php 
bloginfo('charset');
?>
" />                   
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title><?php 
echo KopaSEO::get_title();
?>
</title>                
        <link rel="pingback" href="<?php 
bloginfo('pingback_url');
?>
" />               
        <?php 
wp_head();
?>
    </head>    
    <body <?php 
body_class();
?>
>  
        <header id="page-header" class="clearfix">
            <div class="header-top">
                <div class="container">
Example #2
0
/**
 * @package Kopa
 * @subpackage Core
 * @author thethangtran <*****@*****.**>
 * @since 1.0.0
 */
function kopa_head()
{
    /**
     * FAVICON
     */
    $favicon = KopaOptions::get_option('favicon');
    if ($favicon) {
        printf('<link rel="shortcut icon" type="image/x-icon"  href="%s">', do_shortcode($favicon));
    }
    /**
     * APPLE ICON
     */
    $apple_icon = KopaOptions::get_option('apple_icon');
    if ($apple_icon) {
        $apple_icon = do_shortcode($apple_icon);
        foreach (array(60, 76, 120, 152) as $size) {
            $tmp = bfi_thumb($apple_icon, array('width' => $size, 'height' => $size, 'crop' => true));
            printf('<link rel="apple-touch-icon" sizes="%1$sx%1$s" href="%2$s">', $size, $tmp);
        }
    }
    /**
     * VERIFICATION SERVICES
     */
    $verification_services = array('google_verify_meta' => 'google-site-verification', 'bing_verify_meta' => 'msvalidate.01', 'pinterest_verify_meta' => 'p:domain_verify', 'yandex_verify_meta' => 'yandex-verification');
    foreach ($verification_services as $option_key => $meta_key) {
        $meta_value = KopaOptions::get_option($option_key);
        if ($meta_value) {
            printf('<meta name="%s" content="%s">', $meta_key, $meta_value);
        }
    }
    /**
     * SEO
     */
    if ('true' == KopaOptions::get_option('seo_status', 'false')) {
        $keywords = explode(',', str_replace(' ', '', KopaOptions::get_option('seo_keywords')));
        $description = KopaOptions::get_option('seo_descriptions');
        $thumbnail = do_shortcode(KopaOptions::get_option('logo'));
        $url = home_url();
        $title = KopaSEO::get_title();
        $author = KopaOptions::get_option('seo_google_profile_url');
        $tmp_keywords = '';
        $tmp_description = '';
        if (is_singular() && !is_front_page()) {
            global $post;
            $tmp_keywords = KopaUtil::get_post_meta($post->ID, KOPA_OPT_PREFIX . 'seo_keywords', true);
            $tmp_description = KopaUtil::get_post_meta($post->ID, KOPA_OPT_PREFIX . 'seo_descriptions', true);
            $url = get_permalink($post->ID);
            $thumbnail = KopaImage::get_post_image_src($post->ID, 'size_03');
            $user_id = $post->post_author;
            $current_author = get_the_author_meta('google_profile', $user_id);
            $author = $current_author ? $current_author : $author;
        } else {
            if (is_category() || is_tag()) {
                $term_id = get_queried_object_id();
                $tmp_keywords = get_option(KOPA_OPT_PREFIX . 'seo_keywords_' . $term_id);
                $tmp_description = get_option(KOPA_OPT_PREFIX . 'seo_descriptions_' . $term_id);
            }
        }
        if ($tmp_keywords) {
            $tmp_keywords = explode(',', str_replace(' ', '', $tmp_keywords));
            $keywords = array_merge($keywords, $tmp_keywords);
        }
        $keywords = implode(',', array_unique($keywords));
        $description = $tmp_description ? $tmp_description : $description;
        printf('<meta name="keywords" content="%s">', $keywords);
        printf('<meta name="description" content="%s">', $description);
        /**
         * Open Graph
         */
        printf('<meta property="og:description" content="%s">', $description);
        printf('<meta property="og:type" content="%s">', is_singular() && !is_front_page() ? 'article' : 'website');
        printf('<meta property="og:site_name" content="%s">', get_bloginfo('name'));
        printf('<meta property="og:url" content="%s">', $url);
        printf('<meta property="og:image" content="%s">', $thumbnail);
        printf('<meta property="og:title" content="%s">', $title);
        # Google Map
        $google_map = KopaOptions::get_option('contact_map');
        if ($google_map) {
            $maps_arr = explode(',', $google_map);
            if (2 == count($maps_arr)) {
                printf('<meta property="og:latitude" content="%s">', trim($maps_arr[0]));
                printf('<meta property="og:longitude" content="%s">', trim($maps_arr[1]));
                printf('<meta name="geo.position" content="%s;%s">', trim($maps_arr[0]), trim($maps_arr[1]));
            }
        }
        #Contact Information
        $contact_email = KopaOptions::get_option('contact_email');
        $contact_phone = KopaOptions::get_option('contact_phone');
        $contact_fax = KopaOptions::get_option('contact_fax');
        $contact_address = KopaOptions::get_option('contact_address');
        if ($contact_email) {
            printf('<meta property="og:email" content="%s">', $contact_email);
        }
        if ($contact_phone) {
            printf('<meta property="og:phone_number" content="%s">', $contact_phone);
        }
        if ($contact_fax) {
            printf('<meta property="og:fax_number" content="%s">', $contact_fax);
        }
        if ($contact_address) {
            printf('<meta property="og:street-address" content="%s">', $contact_address);
            printf('<meta name="geo.placename" content="%s">', $contact_address);
        }
        #Twitter
        $twitter_name = KopaOptions::get_option('seo_twitter_name');
        if ($twitter_name) {
            printf('<meta name="twitter:card" content="%s">', $twitter_name);
            printf('<meta name="twitter:site" content="%s">', $twitter_name);
        }
        printf('<meta name="twitter:title" content="%s">', $title);
        printf('<meta name="twitter:description" content="%s">', $description);
        printf('<meta name="twitter:image:src" content="%s">', $thumbnail);
        #GOOGLE PROFILE URL
        if ($author) {
            printf('<link rel="author" href="%s">', $author);
        }
    }
}