function wpgeoip_redirect()
{
    if (get_option('wpgeoip_no_redirect', 0) == 1 and isset($_GET['noredirect'])) {
        return false;
    }
    require_once 'geoip.inc';
    //open geoip binary database
    $gi = geoip_open(plugin_dir_path(__FILE__) . 'GeoIP.dat', GEOIP_STANDARD);
    global $wpdb;
    global $wp_query;
    global $post;
    $prefix = $wpdb->prefix;
    $postID = $post->ID;
    $catID = intval($wp_query->query_vars['cat']);
    $isHome = is_home();
    $the_page_name = '';
    //get user country
    $countryCode = geoip_country_code_by_addr($gi, WPGeoIP_getIP());
    //sitewide rule
    $rs_redirect = $wpdb->get_row("SELECT `targetURL` FROM `" . $prefix . "grules` WHERE `countryID` = '{$countryCode}' \n\t\t\t\t\t\t\tAND `postID` = 999999");
    if (isset($rs_redirect) and count($rs_redirect)) {
        $the_page_name = get_the_title($postID);
        $wpdb->query("INSERT INTO wpgeoip_log VALUES (null, 'SITEWIDE Redirect', 'Redirecting Country <strong>" . $countryCode . "</strong> to " . $rs_redirect->targetURL . "')");
        print '<meta http-equiv="refresh" content="0;url=' . $rs_redirect->targetURL . '"/>';
        exit;
    }
    //redirect if any rule for this country
    if ($postID != 0) {
        $rs_redirect = $wpdb->get_row("SELECT `targetURL` FROM `" . $prefix . "grules` WHERE `countryID` = '{$countryCode}' \n\t\t\t\t\t\t\tAND `postID` = {$postID}");
        $the_page_name = get_the_title($postID);
    }
    if ($catID != 0) {
        $rs_redirect = $wpdb->get_row("SELECT `targetURL` FROM `" . $prefix . "grules` WHERE `countryID` = '{$countryCode}' \n\t\t\t\t\t\t\tAND `catID` = {$catID}");
        $the_page_name = 'Category : ' . get_the_category_by_ID($catID);
    }
    if ($isHome) {
        $rs_redirect = $wpdb->get_row("SELECT `targetURL` FROM `" . $prefix . "grules` WHERE `countryID` = '{$countryCode}' \n\t\t\t\t\t\t\tAND `home_rule` = 1");
        $the_page_name = 'Homepage';
    }
    if (!$rs_redirect) {
        //NOTHING TO DO
        #$wpdb->query("INSERT INTO wpgeoip_log VALUES (null, 'Redirect', 'Nothing to do. No rules for Country <strong>".$countryCode."</strong>')");
    }
    if (isset($rs_redirect) and count($rs_redirect)) {
        $wpdb->query("INSERT INTO wpgeoip_log VALUES (null, 'Redirect <em>" . $the_page_name . "</em>', 'Redirecting Country <strong>" . $countryCode . "</strong> to " . $rs_redirect->targetURL . "')");
        print '<meta http-equiv="refresh" content="0;url=' . $rs_redirect->targetURL . '"/>';
        exit;
    } else {
        //CHECK COUNTRIES WITHOUT REDIRECT RULES
        $mass_redirect_enabled = get_option('wpgeoip_mass_redirect');
        if ($mass_redirect_enabled != "0") {
            $mass_url = get_option('wpgeoip_mass_url');
            $wpdb->query("INSERT INTO wpgeoip_log VALUES (null, 'Mass Redirect', 'Redirecting Country <strong>" . $countryCode . "</strong> to " . $rs_redirect->targetURL . "')");
            print '<meta http-equiv="refresh" content="0;url=' . $mass_url . '"/>';
            exit;
        } else {
            //NOTHING TO DO AGAINM
        }
    }
}
function get_nested_categories($default = 0, $parent = 0) {
 global $post_ID, $mode, $wpdb;

 if ($post_ID) {
   $checked_categories = $wpdb->get_col("
     SELECT category_id
     FROM $wpdb->categories, $wpdb->post2cat
     WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_ID'
     ");

   if(count($checked_categories) == 0)
   {
     // No selected categories, strange
     $checked_categories[] = $default;
   }

 } else {
   $checked_categories[] = $default;
 }

 $cats = return_categories_list($parent, TRUE);
 $result = array();

 foreach($cats as $cat)
 {
   $result[$cat]['children'] = get_nested_categories($default, $cat);
   $result[$cat]['cat_ID'] = $cat;
   $result[$cat]['checked'] = in_array($cat, $checked_categories);
   $result[$cat]['cat_name'] = get_the_category_by_ID($cat);
 }

 return $result;
}
function wpml_link_to_element($element_id, $element_type = 'post', $link_text = '', $optional_parameters = array(), $anchor = '', $echoit = true)
{
    if (!function_exists('icl_link_to_element')) {
        switch ($element_type) {
            case 'post':
            case 'page':
                $ret = '<a href="' . get_permalink($element_id) . '">';
                if ($anchor) {
                    $ret .= $anchor;
                } else {
                    $ret .= get_the_title($element_id);
                }
                $ret .= '<a>';
                break;
            case 'tag':
            case 'post_tag':
                $tag = get_term_by('id', $element_id, 'tag', ARRAY_A);
                $ret = '<a href="' . get_tag_link($element_id) . '">' . $tag->name . '</a>';
            case 'category':
                $ret = '<a href="' . get_tag_link($element_id) . '">' . get_the_category_by_ID($element_id) . '</a>';
            default:
                $ret = '';
        }
        if ($echoit) {
            echo $ret;
        } else {
            return $ret;
        }
    } else {
        return icl_link_to_element($element_id, $element_type, $link_text, $optional_parameters, $anchor, $echoit);
    }
}
	function field_value( $data ) {
		if ( $data == -1 )
			return false;
			
		if ( is_numeric( $data ) )
			return get_the_category_by_ID( intval( $data ) );
			
		return $data;
	}
function the_category_head($before='', $after='') {
	global $currentcat, $previouscat;
	// Grab the first cat in the list.
	$categories = get_the_category();
	$currentcat = $categories[0]->category_id;
	if ( $currentcat != $previouscat ) {
		echo $before;
		echo get_the_category_by_ID($currentcat);
		echo $after;
		$previouscat = $currentcat;
	}
}
 /**
  * column_default function.
  *
  * @access public
  * @param mixed $item
  * @param mixed $column_name
  */
 function column_default($item, $column_name)
 {
     global $wpdb;
     switch ($column_name) {
         case 'text':
             echo $item->text;
             break;
         case 's':
             if ($item->s) {
                 echo $item->s;
             } else {
                 echo 'Any';
             }
             break;
         case 'category':
             if ($item->category) {
                 $cat = get_the_category_by_ID($item->category);
                 echo $cat;
             } else {
                 echo 'Any';
             }
             break;
         case 'enabled':
             if ($item->enabled) {
                 echo '<b style="color:green;">Enabled</b>';
             } else {
                 echo '<b style="color:red;">Disabled</b>';
             }
             break;
         case 'wc_actions':
             ?>
                 <?php 
             $actions = array();
             $action_id = $item->id;
             $actions['edit'] = array('url' => admin_url('admin.php?page=autoText&id=' . $item->id . '&action=edit'), 'name' => __('Edit', 'fastedit'), 'action' => "edit");
             if (!$item->enabled) {
                 $actions['view'] = array('url' => admin_url('admin.php?page=autoText&id=' . $item->id . '&action=enable'), 'name' => __('Enable', 'fastedit'), 'action' => "enable");
             } else {
                 $actions['view'] = array('url' => admin_url('admin.php?page=autoText&id=' . $item->id . '&action=disable'), 'name' => __('Disable', 'fastedit'), 'action' => "disable");
             }
             $actions['delete'] = array('url' => admin_url('admin.php?page=autoText&id=' . $item->id . '&action=delete'), 'name' => __('Delete', 'fastedit'), 'action' => "delete");
             $actions = apply_filters('fastedit_admin_text_table_actions', $actions, $product);
             foreach ($actions as $action) {
                 printf('<a class="button tips %s" href="%s" >%s</a>', $action['action'], esc_url($action['url']), esc_attr($action['name']), esc_attr($action['name']));
             }
             ?>
             <?php 
             break;
     }
 }
Example #7
0
function check_for_category_single_template($t)
{
    foreach ((array) get_the_category() as $cat) {
        if (file_exists(TEMPLATEPATH . "/single-{$cat->slug}.php")) {
            return TEMPLATEPATH . "/single-{$cat->slug}.php";
        }
        if ($cat->parent) {
            $cat = get_the_category_by_ID($cat->parent);
            if (file_exists(TEMPLATEPATH . "/single-{$cat->slug}.php")) {
                return TEMPLATEPATH . "/single-{$cat->slug}.php";
            }
        }
    }
    return $t;
}
 function codeless_register_sidebars_init()
 {
     global $cl_redata;
     register_sidebar(array('id' => 'sidebar-1', 'name' => __('Sidebar Blog', 'codeless'), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h5 class="widget-title">', 'after_title' => '</h5>'));
     register_sidebar(array('id' => 'sidebar-2', 'name' => __('Sidebar Pages', 'codeless'), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h5 class="widget-title">', 'after_title' => '</h5>'));
     register_sidebar(array('id' => 'sidebar-3', 'name' => __('Sidebar Portfolio', 'codeless'), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h5 class="widget-title">', 'after_title' => '</h5>'));
     register_sidebar(array('id' => 'sidebar-4', 'name' => __('Top Header Left', 'codeless'), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '', 'after_title' => ''));
     register_sidebar(array('id' => 'sidebar-5', 'name' => __('Top Header Right', 'codeless'), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '', 'after_title' => ''));
     if (isset($cl_redata['footer_columns'])) {
         $footer_columns = $cl_redata['footer_columns'];
         for ($i = 1; $i <= $footer_columns; $i++) {
             register_sidebar(array('name' => 'Footer - column' . $i, 'id' => 'footer-column-' . $i, 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h5 class="widget-title">', 'after_title' => '</h5>'));
         }
     }
     register_sidebar(array('id' => 'sidebar-7', 'name' => __('Copyright Footer Sidebar', 'codeless'), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '', 'after_title' => ''));
     if (isset($cl_redata['pages_sidebar'])) {
         $id_array = $cl_redata['pages_sidebar'];
         if (isset($id_array[0])) {
             foreach ($id_array as $page_id) {
                 if ($page_id != "") {
                     register_sidebar(array('id' => 'page-' . get_the_title($page_id), 'name' => __('Page', 'codeless') . ': ' . get_the_title($page_id) . '', 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h6 class="widget-title">', 'after_title' => '</h6>'));
                 }
             }
         }
     }
     if (isset($cl_redata['categories_sidebar'])) {
         $id_array = $cl_redata['categories_sidebar'];
         if (isset($id_array[0])) {
             foreach ($id_array as $cat_id) {
                 if ($cat_id != "") {
                     register_sidebar(array('id' => 'category-' . get_the_category_by_ID($cat_id), 'name' => __('Category', 'codeless') . ': ' . get_the_category_by_ID($cat_id) . '', 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h6 class="widget-title">', 'after_title' => '</h6>'));
                 }
             }
         }
     }
     if (isset($cl_redata['extra_navigation']) && $cl_redata['extra_navigation']) {
         register_sidebar(array('id' => 'sidebar-10', 'name' => __('Extra Side Navigation', 'codeless'), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h5 class="widget-title">', 'after_title' => '</h5>'));
     }
     if (class_exists('Woocommerce')) {
         register_sidebar(array('id' => 'sidebar-11', 'name' => __('Sidebar Woocommerce', 'codeless'), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h5 class="widget-title">', 'after_title' => '</h5>'));
     }
     if (isset($cl_redata['header_style']) && ($cl_redata['header_style'] == 'header_6' || $cl_redata['header_style'] == 'header_7' || $cl_redata['header_style'] == 'header_12')) {
         register_sidebar(array('id' => 'sidebar-12', 'name' => __('Header Widgetized Area', 'codeless'), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h5 class="widget-title">', 'after_title' => '</h5>'));
     }
     if (isset($cl_redata['header_style']) && $cl_redata['header_style'] == 'header_12') {
         register_sidebar(array('id' => 'sidebar-13', 'name' => __('After Navigation Area', 'codeless'), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h5 class="widget-title">', 'after_title' => '</h5>'));
     }
 }
Example #9
0
/**
 * b2.newPost. Adds a post, blogger-api like, +title +category +postdate.
 *
 * b2 API
 *
 * @param xmlrpcmsg XML-RPC Message
 *					0 ?
 *					1 ?
 *					2 username (string): Login for a Blogger user who is member of the blog.
 *					3 password (string): Password for said username.
 *					4 content (string): The content of the post.
 *					5 publish (boolean): If set to true, the post will be published immediately.
 *					6 title (string): The title of the post.
 *					7 category (string): The internal name of the category you want to post the post into.
 *					8 date (string): This is the date that will be shown in the post, give "" for current date.
 * @return xmlrpcresp XML-RPC Response
 */
function b2_newpost($m)
{
    global $xmlrpcerruser;
    // import user errcode value
    global $DB;
    global $Settings, $Messages;
    // CHECK LOGIN:
    /**
     * @var User
     */
    if (!($current_User =& xmlrpcs_login($m, 2, 3))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    $publish = $m->getParam(5);
    $publish = $publish->scalarval();
    $status = $publish ? 'published' : 'draft';
    $main_cat = $m->getParam(7);
    $main_cat = $main_cat->scalarval();
    // CHECK PERMISSION: (we need perm on all categories, especially if they are in different blogs)
    if (!$current_User->check_perm('cats_post!' . $status, 'edit', false, array($main_cat))) {
        // Permission denied
        return xmlrpcs_resperror(3);
        // User error 3
    }
    logIO('Permission granted.');
    // Check if category exists
    if (get_the_category_by_ID($main_cat, false) === false) {
        // Cat does not exist:
        return xmlrpcs_resperror(11);
        // User error 11
    }
    $cat_IDs = array($main_cat);
    $postdate = $m->getParam(8);
    $postdate = $postdate->scalarval();
    if ($postdate != '') {
        $post_date = $postdate;
    } else {
        $post_date = date('Y-m-d H:i:s', time() + $Settings->get('time_difference'));
    }
    $post_title = $m->getParam(6);
    $post_title = $post_title->scalarval();
    $content = $m->getParam(4);
    $content = $content->scalarval();
    // COMPLETE VALIDATION & INSERT:
    return xmlrpcs_new_item($post_title, $content, $post_date, $main_cat, $cat_IDs, $status);
}
Example #10
0
 function _single_cat_title($prefix = '', $display = true)
 {
     $cat = intval(get_query_var('cat'));
     if (!empty($cat) && !(strtoupper($cat) == 'ALL')) {
         $my_cat_name = apply_filters('single_cat_title', get_the_category_by_ID($cat));
         if (!empty($my_cat_name)) {
             if ($display) {
                 echo '<h3>' . $prefix . strip_tags($my_cat_name) . '</h3>';
             } else {
                 return strip_tags($my_cat_name);
             }
             if ($index_filename == 'index-wap.php') {
                 echo '<br/>';
             }
         }
     }
 }
 public function get_rows_data()
 {
     $search_value = isset($_POST['search_value']) ? esc_html(stripslashes($_POST['search_value'])) : '';
     $category_id = isset($_POST['category_id']) && esc_html(stripslashes($_POST['category_id'])) != -1 ? esc_html(stripslashes($_POST['category_id'])) : '';
     $category_name = $category_id ? get_the_category_by_ID($category_id) : '';
     $asc_or_desc = isset($_POST['asc_or_desc']) ? esc_html(stripslashes($_POST['asc_or_desc'])) : 'ASC';
     $order_by = isset($_POST['order_by']) ? esc_html(stripslashes($_POST['order_by'])) : 'date';
     if (isset($_POST['page_number']) && $_POST['page_number']) {
         $limit = ((int) $_POST['page_number'] - 1) * 20;
     } else {
         $limit = 0;
     }
     $page_limit = (int) ($limit / 20 + 1);
     $args = array('posts_per_page' => 255, 'category_name' => $category_name, 'orderby' => $order_by, 'order' => $asc_or_desc, 'post_status' => 'publish');
     $posts = get_posts($args);
     $row = array();
     $counter = 0;
     for ($i = 0; $i < count($posts); $i++) {
         $post = $posts[$i];
         if (has_post_thumbnail($post->ID) && (!$search_value || stristr($post->post_title, $search_value) !== FALSE)) {
             $counter++;
             if ($counter > $limit && $counter <= $limit + 20) {
                 $row[$post->ID] = new stdClass();
                 $row[$post->ID]->id = $post->ID;
                 $image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
                 $row[$post->ID]->image_url = $image_url[0];
                 $thumb_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'thumbnail');
                 $row[$post->ID]->thumb_url = $thumb_url[0] ? $thumb_url[0] : $image_url[0];
                 $row[$post->ID]->title = $post->post_title;
                 $row[$post->ID]->date = $post->post_date;
                 $row[$post->ID]->modified = $post->post_modified;
                 $row[$post->ID]->type = $post->post_type;
                 $row[$post->ID]->author = get_the_author_meta('display_name', $post->post_author);
                 $row[$post->ID]->link = get_permalink($post->ID);
                 $row[$post->ID]->content = $this->add_more_link(strip_tags($post->post_content), $row[$post->ID]->link, 250);
             }
         }
     }
     return array($row, $counter, $page_limit);
 }
function the_category_head($before = '', $after = '')
{
    global $post, $currentcat, $previouscat, $dateformat, $newday;
    $currentcat = $post->post_category;
    if ($currentcat != $previouscat) {
        echo $before;
        echo get_the_category_by_ID($currentcat);
        echo $after;
        $previouscat = $currentcat;
    }
}
                        ?>
,
<?php 
                    }
                } else {
                    echo "Not Avail.";
                }
                ?>
                               </p>
                                    <p> <strong>Student/Alum of: </strong>
                                 <?php 
                if (get_post_meta(get_the_ID(), 'Institute Name', true)) {
                    foreach (explode(",", get_post_meta(get_the_ID(), 'Institute Name', true)) as $inst) {
                        ?>
                                    <?php 
                        echo get_the_category_by_ID($inst);
                        ?>
,
                                <?php 
                    }
                } else {
                    echo "Not Avail.";
                }
                ?>
								 </p>
                                   <strong>One Line Pitch: </strong> <?php 
                if (get_post_meta(get_the_ID(), 'One line pitch', true)) {
                    echo get_post_meta(get_the_ID(), 'One line pitch', true);
                } else {
                    echo "Not Avail.";
                }
function get_nested_categories($default = 0, $parent = 0)
{
    global $post_ID, $mode, $wpdb;
    if ($post_ID) {
        $checked_categories = $wpdb->get_col("\n\t\t     SELECT category_id\n\t\t     FROM {$wpdb->categories}, {$wpdb->post2cat}\n\t\t     WHERE {$wpdb->post2cat}.category_id = cat_ID AND {$wpdb->post2cat}.post_id = '{$post_ID}'\n\t\t     ");
        if (count($checked_categories) == 0) {
            // No selected categories, strange
            $checked_categories[] = $default;
        }
    } else {
        $checked_categories[] = $default;
    }
    $cats = return_categories_list($parent);
    $result = array();
    if (is_array($cats)) {
        foreach ($cats as $cat) {
            $result[$cat]['children'] = get_nested_categories($default, $cat);
            $result[$cat]['cat_ID'] = $cat;
            $result[$cat]['checked'] = in_array($cat, $checked_categories);
            $result[$cat]['cat_name'] = get_the_category_by_ID($cat);
        }
    }
    usort($result, 'sort_cats');
    return $result;
}
                        <!-- **portfolio-detail - Starts** -->
 <div class="portfolio-detail" onclick="window.location.href = '<?php 
        echo the_permalink();
        ?>
?id=post_details'">

 <div class="views">
                                <h5 class="prname"><a href="<?php 
        echo the_permalink();
        ?>
"><?php 
        echo get_the_category_by_ID(get_post_meta(get_the_ID(), 'Alumni of Institute', true));
        ?>
</a></h5>
                                <span>City of Location: <?php 
        echo get_the_category_by_ID(get_post_meta(get_the_ID(), 'City Of location', true));
        ?>
 </span>
                            </div>

<!--                            <div class="portfolio-title">

                              

                                <p><strong>Position at Institute: </strong><br>
                                <?php 
        // get_the_category_by_ID(get_post_meta(get_the_ID(), 'Position', true));
        ?>
</p>

                            </div>-->
Example #16
0
function check_post()
{
    global $wpdb;
    $postid = get_the_ID();
    $post = get_post($postid);
    $title = $post->post_title;
    $content = $post->post_content;
    $guid = $post->guid;
    $categoriesID = wp_get_post_categories($postid);
    if ($categoriesID[0] == 9) {
        $categoryDesc = get_the_category_by_ID($categoriesID[count($categoriesID) - 2]);
        $categoryCity = get_the_category_by_ID($categoriesID[count($categoriesID) - 1]);
        $mastersId = $wpdb->get_results("SELECT wp_posts.ID\n                                          FROM wp_users\n                                          JOIN wp_posts on wp_posts.post_author = wp_users.ID\n                                          JOIN wp_term_relationships on wp_term_relationships.object_id = wp_posts.ID\n                                          JOIN wp_term_taxonomy on wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id\n                                          JOIN wp_terms on wp_terms.term_id = wp_term_taxonomy.term_id\n                                          WHERE wp_posts.post_status='publish' and wp_terms.name='мастера' GROUP BY wp_posts.ID", ARRAY_N);
        if (!empty($mastersId)) {
            foreach ($mastersId as $mID) {
                $masters[] = $wpdb->get_results("SELECT wp_posts.ID, user_email, wp_posts.post_content, wp_posts.post_title, wp_posts.guid, wp_terms.name\n                                                FROM wp_users\n                                                JOIN wp_posts on wp_posts.post_author = wp_users.ID\n                                                JOIN wp_term_relationships on wp_term_relationships.object_id = wp_posts.ID\n                                                JOIN wp_term_taxonomy on wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id\n                                                JOIN wp_terms on wp_terms.term_id = wp_term_taxonomy.term_id\n                                                WHERE wp_posts.ID = '{$mID['0']}'", ARRAY_A);
            }
        }
        $recipients = array();
        if (!empty($masters)) {
            foreach ($masters as $key => $master) {
                //var_dump($master[$key+1]['name'], $categoryCity);
                if ($master[1]['name'] == $categoryCity && $master[2]['name'] == $categoryDesc) {
                    array_push($recipients, $master[0]['user_email']);
                    $multiple_recipients = $recipients;
                    $subj = $title;
                    $body = $content;
                    $link = $guid;
                    echo 'mail sended';
                    wp_mail($multiple_recipients, $subj, $body, $link);
                }
            }
        }
    }
}
/**
 * Display or retrieve page title for category archive.
 *
 * This is useful for category template file or files, because it is optimized
 * for category page title and with less overhead than {@link wp_title()}.
 *
 * It does not support placing the separator after the title, but by leaving the
 * prefix parameter empty, you can set the title separator manually. The prefix
 * does not automatically place a space between the prefix, so if there should
 * be a space, the parameter value will need to have it at the end.
 *
 * @since 0.71
 *
 * @param string $prefix Optional. What to display before the title.
 * @param bool $display Optional, default is true. Whether to display or retrieve title.
 * @return string|null Title when retrieving, null when displaying or failure.
 */
function single_cat_title($prefix = '', $display = true)
{
    $cat = intval(get_query_var('cat'));
    if (!empty($cat) && !(strtoupper($cat) == 'ALL')) {
        $my_cat_name = apply_filters('single_cat_title', get_the_category_by_ID($cat));
        if (!empty($my_cat_name)) {
            if ($display) {
                echo $prefix . strip_tags($my_cat_name);
            } else {
                return strip_tags($my_cat_name);
            }
        }
    } else {
        if (is_tag()) {
            return single_tag_title($prefix, $display);
        }
    }
}
Example #18
0
function get_home_cats($cat_data)
{
    global $columns;
    $Cat_ID = $cat_data['id'];
    $offset = $Posts_num = $order = $rand = '';
    if (!empty($cat_data['number'])) {
        $Posts_num = $cat_data['number'];
    }
    if (!empty($cat_data['order'])) {
        $order = $cat_data['order'];
    }
    if (!empty($cat_data['offset'])) {
        $offset = $cat_data['offset'];
    }
    if ($order == 'rand') {
        $rand = "&orderby=rand";
    }
    $cat_query = new WP_Query('cat=' . $Cat_ID . '&no_found_rows=1&posts_per_page=' . $Posts_num . $rand . '&offset=' . $offset);
    $cat_title = get_the_category_by_ID($Cat_ID);
    $count = 0;
    $home_layout = $cat_data['style'];
    ?>
	<?php 
    if ($home_layout == '2c') {
        //************** 2C ******************************************************
        ?>
		<?php 
        $columns++;
        ?>
		<section class="cat-box column2 tie-cat-<?php 
        echo $Cat_ID;
        ?>
 <?php 
        if ($columns == 2) {
            echo 'last-column';
            $columns = 0;
        }
        ?>
">
			<h2 class="cat-box-title"><a href="<?php 
        echo get_category_link($Cat_ID);
        ?>
"><?php 
        echo $cat_title;
        ?>
</a></h2>
			<div class="cat-box-content">
			
				<?php 
        if ($cat_query->have_posts()) {
            ?>
				<ul>
				<?php 
            while ($cat_query->have_posts()) {
                $cat_query->the_post();
                $count++;
                ?>
				<?php 
                if ($count == 1) {
                    ?>
					<li class="first-news">
						<div class="inner-content">
						<?php 
                    if (function_exists("has_post_thumbnail") && has_post_thumbnail()) {
                        ?>
			
							<div class="post-thumbnail">
								<a href="<?php 
                        the_permalink();
                        ?>
" title="<?php 
                        printf(esc_attr__('Permalink to %s', 'tie'), the_title_attribute('echo=0'));
                        ?>
" rel="bookmark">
									<?php 
                        the_post_thumbnail('tie-large');
                        ?>
									<?php 
                        tie_get_score(true);
                        ?>
								</a>
							</div><!-- post-thumbnail /-->
						<?php 
                    } else {
                        ?>
						<div class="empty-space"></div>
						<?php 
                    }
                    ?>
					
							<h2 class="post-box-title"><a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    printf(esc_attr__('Permalink to %s', 'tie'), the_title_attribute('echo=0'));
                    ?>
" rel="bookmark"><?php 
                    the_title();
                    ?>
</a></h2>
							<?php 
                    get_template_part('includes/boxes-meta');
                    ?>
							<div class="entry">
								<p><?php 
                    tie_excerpt_home();
                    ?>
</p>
								<a class="more-link" href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    _e('Read More &raquo;', 'tie');
                    ?>
</a>
							</div>
						</div>
					</li><!-- .first-news -->
					<?php 
                } else {
                    ?>
					<li>
						<?php 
                    if (function_exists("has_post_thumbnail") && has_post_thumbnail()) {
                        ?>
			
							<div class="post-thumbnail">
								<a href="<?php 
                        the_permalink();
                        ?>
" title="<?php 
                        printf(esc_attr__('Permalink to %s', 'tie'), the_title_attribute('echo=0'));
                        ?>
" rel="bookmark">
									<?php 
                        the_post_thumbnail('tie-small');
                        ?>
									<?php 
                        tie_get_score();
                        ?>
								</a>
							</div><!-- post-thumbnail /-->
						<?php 
                    }
                    ?>
			
						<h3 class="post-box-title"><a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    printf(esc_attr__('Permalink to %s', 'tie'), the_title_attribute('echo=0'));
                    ?>
" rel="bookmark"><?php 
                    the_title();
                    ?>
</a></h3>
						<?php 
                    get_template_part('includes/boxes-meta');
                    ?>
					</li>
					<?php 
                }
                ?>
				<?php 
            }
            ?>
				</ul>

				<?php 
        }
        ?>
			</div><!-- .cat-box-content /-->
		</section> <!-- Two Columns -->
		
		
	<?php 
    } elseif ($home_layout == '1c') {
        //************** 1C ******************************************************
        ?>
		<section class="cat-box wide-box tie-cat-<?php 
        echo $Cat_ID;
        ?>
">
			<h2 class="cat-box-title"><a href="<?php 
        echo get_category_link($Cat_ID);
        ?>
"><?php 
        echo $cat_title;
        ?>
</a></h2>
			<div class="cat-box-content">
			
				<?php 
        $count = 0;
        $count2 = 0;
        if ($cat_query->have_posts()) {
            ?>
				<ul>
				<?php 
            while ($cat_query->have_posts()) {
                $cat_query->the_post();
                $count++;
                ?>
				<?php 
                if ($count == 1) {
                    ?>
					<li class="first-news">
						<div class="inner-content">
						<?php 
                    if (function_exists("has_post_thumbnail") && has_post_thumbnail()) {
                        ?>
			
							<div class="post-thumbnail">
								<a href="<?php 
                        the_permalink();
                        ?>
" title="<?php 
                        printf(esc_attr__('Permalink to %s', 'tie'), the_title_attribute('echo=0'));
                        ?>
" rel="bookmark">
									<?php 
                        the_post_thumbnail('tie-large');
                        ?>
									<?php 
                        tie_get_score(true);
                        ?>
								</a>
							</div><!-- post-thumbnail /-->
						<?php 
                    } else {
                        ?>
						<div class="empty-space"></div>
						<?php 
                    }
                    ?>
						
							<h2 class="post-box-title"><a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    printf(esc_attr__('Permalink to %s', 'tie'), the_title_attribute('echo=0'));
                    ?>
" rel="bookmark"><?php 
                    the_title();
                    ?>
</a></h2>
							<?php 
                    get_template_part('includes/boxes-meta');
                    ?>
							<div class="entry">
								<p><?php 
                    tie_excerpt_home();
                    ?>
</p>
								<a class="more-link" href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    _e('Read More &raquo;', 'tie');
                    ?>
</a>
							</div>
						</div>
					</li><!-- .first-news -->
					<?php 
                } else {
                    $count2++;
                    ?>
					<li <?php 
                    if ($count2 == 2) {
                        echo 'class="last-column"';
                        $count2 = 0;
                    }
                    ?>
>
						<?php 
                    if (function_exists("has_post_thumbnail") && has_post_thumbnail()) {
                        ?>
			
							<div class="post-thumbnail">
								<a href="<?php 
                        the_permalink();
                        ?>
" title="<?php 
                        printf(esc_attr__('Permalink to %s', 'tie'), the_title_attribute('echo=0'));
                        ?>
" rel="bookmark">
									<?php 
                        the_post_thumbnail('tie-small');
                        ?>
									<?php 
                        tie_get_score();
                        ?>
								</a>
							</div><!-- post-thumbnail /-->
						<?php 
                    }
                    ?>
			
						<h3 class="post-box-title"><a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    printf(esc_attr__('Permalink to %s', 'tie'), the_title_attribute('echo=0'));
                    ?>
" rel="bookmark"><?php 
                    the_title();
                    ?>
</a></h3>
						<?php 
                    get_template_part('includes/boxes-meta');
                    ?>
					</li>
					<?php 
                }
                ?>
				<?php 
            }
            ?>
				</ul>
				<div class="clear"></div>

					<?php 
        }
        ?>
			</div><!-- .cat-box-content /-->
		</section><!-- Wide Box -->

	<?php 
    } else {
        //************** list **********************************************************************************
        ?>
		
		<section class="cat-box list-box tie-cat-<?php 
        echo $Cat_ID;
        ?>
">
			<h2 class="cat-box-title"><a href="<?php 
        echo get_category_link($Cat_ID);
        ?>
"><?php 
        echo $cat_title;
        ?>
</a></h2>
			<div class="cat-box-content">
			
				<?php 
        if ($cat_query->have_posts()) {
            ?>
				<ul>
				<?php 
            while ($cat_query->have_posts()) {
                $cat_query->the_post();
                $count++;
                ?>
				<?php 
                if ($count == 1) {
                    ?>
					<li class="first-news">
						<?php 
                    if (function_exists("has_post_thumbnail") && has_post_thumbnail()) {
                        ?>
			
							<div class="post-thumbnail">
								<a href="<?php 
                        the_permalink();
                        ?>
" title="<?php 
                        printf(esc_attr__('Permalink to %s', 'tie'), the_title_attribute('echo=0'));
                        ?>
" rel="bookmark">
									<?php 
                        the_post_thumbnail('tie-large');
                        ?>
									<?php 
                        tie_get_score(true);
                        ?>
								</a>
							</div><!-- post-thumbnail /-->
						<?php 
                    } else {
                        ?>
						<div class="empty-space"></div>
						<?php 
                    }
                    ?>
						
							<h2 class="post-box-title"><a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    printf(esc_attr__('Permalink to %s', 'tie'), the_title_attribute('echo=0'));
                    ?>
" rel="bookmark"><?php 
                    the_title();
                    ?>
</a></h2>
							<?php 
                    get_template_part('includes/boxes-meta');
                    ?>
							<div class="entry">
								<p><?php 
                    tie_excerpt_home();
                    ?>
</p>
								<a class="more-link" href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    _e('Read More &raquo;', 'tie');
                    ?>
</a>
							</div>
						</li><!-- .first-news -->
					<?php 
                } else {
                    ?>
					<li class="other-news">
						<?php 
                    if (function_exists("has_post_thumbnail") && has_post_thumbnail()) {
                        ?>
			
							<div class="post-thumbnail">
								<a href="<?php 
                        the_permalink();
                        ?>
" title="<?php 
                        printf(esc_attr__('Permalink to %s', 'tie'), the_title_attribute('echo=0'));
                        ?>
" rel="bookmark">
									<?php 
                        the_post_thumbnail('tie-small');
                        ?>
									<?php 
                        tie_get_score();
                        ?>
								</a>
							</div><!-- post-thumbnail /-->
						<?php 
                    }
                    ?>
			
						<h3 class="post-box-title"><a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    printf(esc_attr__('Permalink to %s', 'tie'), the_title_attribute('echo=0'));
                    ?>
" rel="bookmark"><?php 
                    the_title();
                    ?>
</a></h3>
						<?php 
                    get_template_part('includes/boxes-meta');
                    ?>
					</li>
					<?php 
                }
                ?>
				<?php 
            }
            ?>
				</ul>
				<div class="clear"></div>

					<?php 
        }
        ?>
			</div><!-- .cat-box-content /-->
		</section><!-- List Box -->

	<?php 
    }
    ?>
	
	
<?php 
}
    register_sidebar(array('name' => "Page: {$title}", 'id' => "page-{$page_id}-sidebar", 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widgettitle"><span>', 'after_title' => '</span></h3>'));
}
#Custom sidebars for Posts
$posts = mytheme_option("widgetarea", "posts");
$posts = !empty($posts) ? $posts : array();
$widget_areas_for_posts = array_filter(array_unique($posts));
foreach ($widget_areas_for_posts as $post_id) {
    $title = get_the_title($post_id);
    register_sidebar(array('name' => "Post: {$title}", 'id' => "post-{$post_id}-sidebar", 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widgettitle"><span>', 'after_title' => '</span></h3>'));
}
#Custom sidebars for categories
$cats = mytheme_option("widgetarea", "cats");
$cats = !empty($cats) ? $cats : array();
$widget_areas_for_cats = array_filter(array_unique($cats));
foreach ($widget_areas_for_cats as $cat_id) {
    $title = get_the_category_by_ID($cat_id);
    register_sidebar(array('name' => "Category: {$title}", 'id' => "category-{$cat_id}-sidebar", 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widgettitle"><span>', 'after_title' => '</span></h3>'));
}
if (class_exists('woocommerce')) {
    #Custom Sidebars for Product
    $products = mytheme_option("widgetarea", "products");
    $products = !empty($products) ? $products : array();
    $widget_areas_for_products = array_filter(array_unique($products));
    foreach ($widget_areas_for_products as $id) {
        $title = get_the_title($id);
        register_sidebar(array('name' => "Product: {$title}", 'id' => "product-{$id}-sidebar", 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widgettitle"><span>', 'after_title' => '</span></h3>'));
    }
    #Custom Sidebars for Product Category
    $product_categories = mytheme_option("widgetarea", "product-category");
    $product_categories = !empty($product_categories) ? $product_categories : array();
    $widget_areas_for_product_categories = array_filter(array_unique($product_categories));
Example #20
0
 function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     $instance = wp_parse_args($instance, $this->widget_defaults());
     extract($instance, EXTR_SKIP);
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     if ($random_post) {
         $sortby = 'rand';
     } else {
         $sortby = '';
     }
     if ($sticky_post) {
         $sticky = array();
     } else {
         $sticky = get_option('sticky_posts');
     }
     global $xinwp_display_excerpt, $xinwp_entry_meta;
     $xinwp_display_excerpt = $display_excerpt;
     $xinwp_entry_meta = $entry_meta;
     $query_str = array('order' => 'DESC', 'orderby' => $sortby, 'posts_per_page' => $number, 'post_status' => 'publish', 'post_type' => $posttype, 'ignore_sticky_posts' => 1, 'no_found_rows' => 1);
     if ('post' == $posttype) {
         $query_str['category__in'] = $category;
         $query_str['post__not_in'] = $sticky;
     }
     if (!empty($customquery)) {
         $custom_query = wp_parse_args($customquery, NULL);
         foreach ($custom_query as $key => $query) {
             if (strpos($key, '__') && strpos($query, ',')) {
                 $query_str[$key] = explode(',', $query);
             } else {
                 $query_str[$key] = $query;
             }
         }
     }
     $recent_posts = new WP_Query($query_str);
     if ($recent_posts->have_posts()) {
         echo $before_widget;
         if (!empty($title)) {
             echo $before_title;
             echo $title;
             // Can set this with a widget option, or omit altogether
             echo $after_title;
             if (!empty($category_link) && $category) {
                 printf('<a href="%1$s" title="%2$s" class="xinwp_recent_post_link btn btn-small btn-transparent">%3$s</a>', get_category_link($category), get_the_category_by_ID($category), $category_link);
             }
         }
         global $xinwp_thumbnail;
         $xinwp_thumbnail = xinwp_thumbnail_size($thumbnail, $thumbnail_x, $thumbnail_y);
         $col = 0;
         while ($recent_posts->have_posts()) {
             $recent_posts->the_post();
             $div_class = '';
             if ($column > 1 && $col == 0) {
                 echo '<div class="row">';
             }
             if ($column == 2) {
                 $div_class = "large-6 columns";
                 $col = $col + 1;
                 if ($col == 2) {
                     $col = 0;
                 }
             } elseif ($column == 3) {
                 $div_class = "large-4 columns";
                 $col = $col + 1;
                 if ($col == 3) {
                     $col = 0;
                 }
             } elseif ($column == 4) {
                 $div_class = "large-3 columns";
                 $col = $col + 1;
                 if ($col == 4) {
                     $col = 0;
                 }
             }
             if ($column > 1) {
                 echo '<div class="' . $div_class . '">';
             }
             get_template_part('content', 'summary');
             if ($column > 1) {
                 echo '</div>';
                 if ($col == 0) {
                     echo '</div>';
                 }
             }
         }
         if ($col > 0) {
             echo '</div>';
         }
         echo $after_widget;
         // Reset the post globals as this query will have stomped on it
         wp_reset_postdata();
     }
 }
<?php

global $count2, $block, $page_builder_id;
$Cat_ID = $block['id'];
$args = array('cat' => $Cat_ID, 'no_found_rows' => true, 'ignore_sticky_posts' => true);
if (!empty($block['number'])) {
    $args['posts_per_page'] = $block['number'];
}
if (!empty($block['order']) && $block['order'] == 'rand') {
    $args['orderby'] = 'rand';
}
if (!empty($block['offset'])) {
    $args['offset'] = $block['offset'];
}
$cat_query = new WP_Query($args);
$cat_title = get_the_category_by_ID($Cat_ID);
$count = 0;
$home_layout = $block['style'];
?>
	<?php 
if ($home_layout == '2c') {
    //************** 2C ******************************************************
    ?>
		<?php 
    $count2++;
    ?>
		<section class="cat-box column2 tie-cat-<?php 
    echo $Cat_ID;
    ?>
 <?php 
    if ($count2 == 2) {
            $interest_query1->the_post();
            ?>
                                <td><b><a href="javascript:void(0);" onclick="window.location.href = '<?php 
            echo get_the_permalink();
            ?>
?id=post_details'"><?php 
            echo get_userdata($value['id'])->display_name;
            ?>
</a></b></td>

                                <td><?php 
            if (get_post_meta(get_the_ID(), 'Institute Name', true)) {
                foreach (explode(",", get_post_meta(get_the_ID(), 'Institute Name', true)) as $institute) {
                    ?>
                                                <p><?php 
                    echo get_the_category_by_ID($institute);
                    ?>
</p>
                                            <?php 
                }
            } else {
                echo "Not Avail.";
            }
            // echo get_the_category_by_ID(get_post_meta(get_the_ID(), 'Alumni of Institute', true));
            ?>
 </td>

                                <td><?php 
            echo get_the_author_meta("entity", $value['id']);
            ?>
</td>
function single_cat_title($prefix = '', $display = true ) {
	  $cat = get_query_var('cat');
    if(!empty($cat) && !(strtoupper($cat) == 'ALL')) {
        $my_cat_name = get_the_category_by_ID($cat);
        if(!empty($my_cat_name)) {
            if ($display)
                echo $prefix.strip_tags($my_cat_name);
            else
                return strip_tags($my_cat_name);
        }
    }
}
            } elseif (get_post_meta(get_the_ID(), 'Other associate', true)) {
                echo 'Other - ';
                echo get_post_meta(get_the_ID(), 'Other associate', true);
            } else {
                echo "Not Avail.";
            }
        }
        ?>
</p>
                                    <strong>Sectors:</strong><br/>
            <?php 
        if (get_post_meta(get_the_ID(), 'Sector', true)) {
            foreach (explode(",", get_post_meta(get_the_ID(), 'Sector', true)) as $sector) {
                ?>
                                        <p><?php 
                echo get_the_category_by_ID($sector);
                ?>
</p>
            <?php 
            }
        } else {
            echo "Not Avail.";
        }
        ?>
                                </div>

                            </div><!-- **portfolio-detail - Ends** -->

                        </div><!-- **portfolio-detail - Ends** -->

                    
 /**
  * Gets post's category.
  *
  * @since	3.0.0
  * @param	object	p
  * @param	array	instance	The current instance of the widget / shortcode parameters
  * @return	string
  */
 protected function _get_post_cat($p, $instance)
 {
     $post_cat = '';
     if ($instance['stats_tag']['category']) {
         $cache =& $this->__cache(__FUNCTION__, array());
         if (isset($cache[$p->id])) {
             return $cache[$p->id];
         }
         // Try and get parent category
         $cats = get_the_category($p->id);
         foreach ($cats as $cat) {
             if ($cat->category_parent == 0) {
                 $post_cat = $cat;
             }
         }
         // Default to first category avaliable
         if ($post_cat == "" && isset($cats[0]) && isset($cats[0]->slug)) {
             $post_cat = $cats[0];
         }
         // Build category tag
         if ("" != $post_cat) {
             $category_id = $post_cat->term_id;
             $category_name = $post_cat->cat_name;
             // WPML support, based on Serhat Evren's suggestion - see http://wordpress.org/support/topic/wpml-trick#post-5452607
             if (defined('ICL_LANGUAGE_CODE') && function_exists('icl_object_id')) {
                 $category_id = icl_object_id($category_id, 'category', true, ICL_LANGUAGE_CODE);
                 $category_name = get_the_category_by_ID($category_id);
             }
             $post_cat = '<a href="' . get_category_link($category_id) . '" class="cat-id-' . $category_id . '">' . $category_name . '</a>';
         }
         return $cache[$p->id] = $post_cat;
     }
     return $post_cat;
 }
Example #26
0
<?php

get_header();
if (have_posts()) {
    ?>


<div class="content-wrapper">
	<div class="container-fluid">
		<div class="row-fluid top">
			<div class="col-sm-12 content">
				<h1>
					<?php 
    echo get_the_category_by_ID(2);
    ?>
				</h1>
				<div class="text-wrap">
					<?php 
    while (have_posts()) {
        the_post();
        ?>
					<div class="row-fluid margin20-bottom">
							<div class="col-sm-2">
									<span class="date">
									<?php 
        $the_date = apply_filters('the_date', get_the_date("d.m.Y"));
        echo $the_date;
        ?>
									</span>
									<a class="fb_share_button" href="https://www.facebook.com/sharer/sharer.php?u=<?php 
        echo get_permalink();
function single_cat_title($prefix = '', $display = true)
{
    global $cat;
    if (!empty($cat) && !(strtoupper($cat) == 'ALL')) {
        $my_cat_name = get_the_category_by_ID($cat);
        if (!empty($my_cat_name)) {
            if ($display) {
                echo $prefix . strip_tags(stripslashes($my_cat_name));
            } else {
                return strip_tags(stripslashes($my_cat_name));
            }
        }
    }
}
 function the_category_head($before = '', $after = '', $echo = true)
 {
     // Grab the first cat in the list.
     $categories = get_the_category();
     $GLOBALS['currentcat'] = $categories[0]->category_id;
     if ($GLOBALS['currentcat'] != $GLOBALS['previouscat']) {
         $GLOBALS['previouscat'] = $GLOBALS['currentcat'];
         return _echo($before . get_the_category_by_ID($GLOBALS['currentcat']) . $after, $echo);
     }
     return "";
 }
Example #29
0
/**
 * Print category with optional text before and after.
 *
 * @since 0.71
 * @deprecated 0.71
 * @deprecated use get_the_category_by_ID()
 * @see get_the_category_by_ID()
 *
 * @param string $before
 * @param string $after
 */
function the_category_head($before = '', $after = '')
{
    global $currentcat, $previouscat;
    _deprecated_function(__FUNCTION__, '0.71', 'get_the_category_by_ID()');
    // Grab the first cat in the list.
    $categories = get_the_category();
    $currentcat = $categories[0]->category_id;
    if ($currentcat != $previouscat) {
        echo $before;
        echo get_the_category_by_ID($currentcat);
        echo $after;
        $previouscat = $currentcat;
    }
}
Example #30
0
 function raindrops_post_category_relation()
 {
     global $post;
     $result = array();
     $tmp_id = absint(get_query_var('cat'));
     $categories = get_the_category($post->ID);
     foreach ($categories as $category) {
         $category->term_id = absint($category->term_id);
         $parents = get_category_parents($category->term_id, true, '&raquo;');
         $parents_item = str_replace('<a href="' . get_category_link($category->term_id) . '">' . $category->name . "</a>&raquo;", '', $parents);
         $parents = explode('&raquo;', $parents_item);
         if (!empty($parents_item)) {
             $result[] = '<span class="label title parent">' . esc_html__('Parent Category:', 'raindrops') . '</span>';
         }
         foreach ($parents as $links) {
             $result[] = $links;
         }
         $replace_check = get_the_category_by_ID($category->term_id);
         $replace_check = get_category_link($category->term_id);
         $tmp_child_ids = get_term_children($category->term_id, 'category');
         $child_result = '';
         $child_ready = array();
         if (!empty($tmp_child_ids)) {
             $result[] = '<span class="label title child">' . esc_html__('Child Category:', 'raindrops') . '</span>';
         }
         foreach ($tmp_child_ids as $tmp_id) {
             $tmp_id = absint($tmp_id);
             $term = get_term_by('id', $tmp_id, 'category');
             $result[] = '<a href="' . get_term_link($tmp_id, 'category') . '">' . $term->name . "</a>";
         }
     }
     $result = array_unique($result);
     $result = implode(' ', $result);
     return apply_filters('raindrops_post_category_relation', rtrim($result, ' &raquo; '));
 }