Example #1
0
/**
 * @package Kopa
 * @subpackage Core
 * @author thethangtran <*****@*****.**>
 * @since 1.0.0         
 */
function kopa_after_save_post_custom_post_type()
{
    global $post;
    $is_use_custom_layout = KopaUtil::get_post_meta($post->ID, KOPA_OPT_PREFIX . 'is_use_custom_layout', true, 'Boolean', false);
    if (!$is_use_custom_layout) {
        delete_post_meta($post->ID, KOPA_OPT_PREFIX . 'is_use_custom_layout');
        delete_post_meta($post->ID, KOPA_OPT_PREFIX . 'layout');
    }
}
Example #2
0
 /**
  * 
  *
  * @package Kopa
  * @subpackage Core
  * @author thethangtran <*****@*****.**>
  * @since 1.0.0
  *      
  */
 public static function get_current_setting()
 {
     $settings = get_option(KOPA_OPT_PREFIX . 'layout_settings');
     $setting = array('layout' => '', 'sidebars' => array());
     if (!empty($settings) && is_main_query()) {
         if (is_archive()) {
             $setting = $settings['archive'];
             if (is_tag() || is_category()) {
                 $setting = $settings['taxonomy'];
                 $term_id = get_queried_object_id();
                 if ('true' == get_option(KOPA_OPT_PREFIX . 'is_use_custom_layout_' . $term_id, 'false')) {
                     $setting = get_option(KOPA_OPT_PREFIX . 'layout_' . $term_id, $setting);
                 }
             } else {
                 if (is_author()) {
                     $setting = $settings['author'];
                 }
             }
         } else {
             if (is_search()) {
                 $setting = $settings['search'];
             } else {
                 if (is_singular()) {
                     global $post;
                     if (is_page()) {
                         $setting = $settings['page'];
                         if (is_front_page()) {
                             $setting = $settings['front-page'];
                         } else {
                             if ('true' == KopaUtil::get_post_meta($post->ID, KOPA_OPT_PREFIX . 'is_use_custom_layout', TRUE, 'String', 'false')) {
                                 $setting = KopaUtil::get_post_meta($post->ID, KOPA_OPT_PREFIX . 'layout', true, NULL, $setting);
                             }
                         }
                     } else {
                         if (is_single()) {
                             $setting = $settings['post'];
                             if ('true' == KopaUtil::get_post_meta($post->ID, KOPA_OPT_PREFIX . 'is_use_custom_layout', TRUE, 'String', 'false')) {
                                 $setting = KopaUtil::get_post_meta($post->ID, KOPA_OPT_PREFIX . 'layout', true, NULL, $setting);
                             }
                         }
                     }
                 } else {
                     if (is_404()) {
                         $setting = $settings['_404'];
                     } else {
                         $setting = $settings['home'];
                     }
                 }
             }
         }
     }
     return apply_filters('kopa_layout_get_current_setting', $setting);
 }
Example #3
0
 /**
  * 
  *
  * @package Kopa
  * @subpackage Core
  * @author thethangtran <*****@*****.**>
  * @since 1.0.0
  *      
  */
 public static function get_post_image_src($post_id = 0, $size = NULL, $width = NULL, $height = NULL, $crop = true)
 {
     $src = NULL;
     if ($size) {
         $size = self::detect_image_size($size);
     }
     if (isset($post_id) && !empty($post_id) && has_post_thumbnail($post_id)) {
         if ('true' == KopaUtil::get_post_meta($post_id, KOPA_OPT_PREFIX . 'is_use_custom_thumbnail', TRUE, 'String', false) && 'true' == KopaOptions::get_option('is_use_custom_thumbnail', 'false') && !empty($size)) {
             $tmp = KopaUtil::get_post_meta($post_id, KOPA_OPT_PREFIX . "thumbnail_{$size}", true);
             if ($tmp) {
                 $src = do_shortcode($tmp);
             }
         }
         if (empty($src)) {
             $feature_image = KopaUtil::get_image_src($post_id, 'full');
             $src = self::get_image_src($feature_image, $size, $width, $height, $crop);
         }
     }
     return apply_filters('kopa_image_get_post_image_src', $src);
 }
Example #4
0
 /**
  * @package Kopa
  * @subpackage Core
  * @author thethangtran <*****@*****.**>
  * @since 1.0.0     
  */
 public static function is_liked($post_id)
 {
     $key = KOPA_OPT_PREFIX . 'like_by_' . KopaUtil::get_client_IP();
     return KopaUtil::get_post_meta($post_id, $key, true, 'Boolean', false);
 }
 /**
  * 
  *
  * @package Kopa
  * @subpackage Core
  * @author thethangtran <*****@*****.**>
  * @since 1.0.0
  *      
  */
 public function manage_posts_custom_column($column)
 {
     global $post;
     $column_info = $this->post_columns[$column];
     $column_type = $column_info[1];
     switch ($column_type) {
         case 'thumbnail':
             $image = KopaUtil::get_image_src($post->ID, 'full');
             if ($image) {
                 printf('<a target="_blank" href="%s"><img src="%s"></a>', $image, bfi_thumb($image, array('width' => 60, 'height' => 60, 'crop' => true)));
             }
             break;
         case 'image':
             $image = KopaUtil::get_post_meta($post->ID, $column, true, 'String', '');
             if ($image) {
                 $image = do_shortcode($image);
                 printf('<a target="_blank" href="%s"><img src="%s"></a>', $image, bfi_thumb($image, array('width' => 60, 'height' => 60, 'crop' => true)));
             }
             break;
         case 'text':
             echo KopaUtil::get_post_meta($post->ID, $column, true, 'String', '');
             break;
         case 'link':
             $url = KopaUtil::get_post_meta($post->ID, $column, true, 'String', '');
             if ($url) {
                 printf('<a href="%1$s">%1$s</a>', $url);
             }
             break;
         case 'id':
             echo $post->ID;
             break;
         case 'int':
             echo KopaUtil::get_post_meta($post->ID, $column, true, 'Int', 0);
             break;
         case 'float':
             echo KopaUtil::get_post_meta($post->ID, $column, true, 'Float', 0);
             break;
         case 'term':
             the_terms($post->ID, $column);
             break;
         case 'features':
             $features = KopaUtil::get_post_meta($post->ID, $column, true);
             if ($features && is_array($features)) {
                 $items = $features['feature'];
                 echo '<ul>';
                 foreach ($items as $item) {
                     printf('<li>%s</li>', $item);
                 }
                 echo '</ul>';
             }
             break;
         default:
             break;
     }
 }
Example #6
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);
        }
    }
}