/**
  * Public View
  */
 function widget($args, $instance)
 {
     extract($args);
     /* Our variables from the widget settings. */
     $title = apply_filters('widget_title', $instance['title']);
     $topics = $instance['topics'];
     /* REQUIRED */
     echo $before_widget;
     /* 'before' and 'after' are REQUIRED */
     if ($title) {
         echo $before_title . $title . $after_title . ' ';
     }
     /* Display array separated by delimiter
      * TODO: make delimiter a configurable option?
      * */
     if ($topics && isset($topics)) {
         foreach ($topics as &$topic) {
             $category_id = get_cat_ID($topic);
             if (0 < $category_id) {
                 // modified the category link for the niche sites "site category" functionality
                 // @TODO: this should change in the future as we fix the niche site theme
                 $category = get_category($category_id);
                 $category_link = get_bloginfo('url') . '/category/' . $category->slug;
                 $topic = '<a href="' . $category_link . '" title="' . $topic . '">' . $topic . '</a>';
             } else {
                 //	topic is not a link
             }
         }
         echo implode(' | ', $topics);
     }
     /* REQUIRED */
     echo $after_widget;
 }
 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     // Only show the widget if it is on a specific Page, not when just showing a single post.
     if (!$this->is_post_on_its_own_page) {
         return;
     }
     echo $args['before_widget'];
     if (!empty($instance['title'])) {
         $categories = !empty($instance['categories']) ? $instance['categories'] : array();
         $category_slug_first = '';
         $category_ids = array();
         foreach ($categories as $category) {
             if ($category_slug_first == '') {
                 $category_slug_first = strtolower(str_replace(' ', '-', $category));
             }
             $category_ids[] = get_cat_ID($category);
         }
         $ace_user = new AceCourseUser();
         echo "<div class='{$category_slug_first} " . $ace_user->get_css_classes() . "'>";
         echo $args['before_title'] . $instance['title'] . $args['after_title'];
         $query_args = array('post_type' => 'post', 'post_status' => 'publish', 'category__in' => $category_ids);
         $exercise_posts = new \WP_Query($query_args);
         global $post;
         foreach ($exercise_posts->posts as $exercise_post) {
             $post = $exercise_post;
             setup_postdata($post);
             include 'ace-course-progress.template.php';
             wp_reset_postdata();
         }
         echo "</div>";
     }
     echo $args['after_widget'];
 }
Exemplo n.º 3
0
function getPhotos($category, $posts)
{
    $is_highlights = !is_array($posts);
    $data = !$is_highlights ? $posts : [];
    $url = 'http://' . $_SERVER['SERVER_NAME'] . '/' . 'cms/wp-json/posts?filter[posts_per_page]=-1&filter[order]=desc&filter[orderby]=post_date' . ($is_highlights ? '&filter[category_name]=destaque' : null);
    $response = \Httpful\Request::get($url)->send();
    $catId = get_cat_ID($category);
    foreach ($response->body as $key => $post) {
        $image_src = getImage($post->content);
        $attachment_id = pn_get_attachment_id_from_url($image_src);
        $image_large_src = wp_get_attachment_image_src($attachment_id, 'large');
        if (!$is_highlights && !isHighgligthCategory($catId, $post->terms->category)) {
            if ($image_src) {
                array_push($data, array('id' => $post->ID, 'title' => $post->title, 'image_src' => getImage($post->content), 'image_large_src' => $image_large_src[0]));
            }
        } else {
            if ($is_highlights && isHighgligthCategory($catId, $post->terms->category)) {
                if ($image_src) {
                    array_push($data, array('id' => $post->ID, 'title' => $post->title, 'image_src' => getImage($post->content), 'image_large_src' => $image_large_src[0]));
                }
            }
        }
    }
    return $data;
}
 function render($atts, $content = null)
 {
     parent::render($atts);
     $buffy = '';
     extract(shortcode_atts(array('limit' => '6', 'custom_title' => '', 'custom_url' => '', 'hide_title' => '', 'header_color' => ''), $atts));
     $cat_args = array('show_count' => true, 'orderby' => 'count', 'hide_empty' => false, 'order' => 'DESC', 'number' => $limit + 1, 'exclude' => get_cat_ID(TD_FEATURED_CAT));
     // exclude categories from the demo
     if (TD_DEPLOY_MODE == 'demo' or TD_DEPLOY_MODE == 'dev') {
         $cat_args['exclude'] = '44,45,46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 110, ' . get_cat_ID(TD_FEATURED_CAT);
     }
     $categories = get_categories($cat_args);
     $buffy .= '<div class="td_block_wrap td_popular_categories widget widget_categories">';
     $buffy .= $this->get_block_title();
     if (!empty($categories)) {
         $buffy .= '<ul class="td-pb-padding-side">';
         foreach ($categories as $category) {
             if (strtolower($category->cat_name) != 'uncategorized') {
                 $buffy .= '<li><a href="' . get_category_link($category->cat_ID) . '">' . $category->name . '<span class="td-cat-no">' . $category->count . '</span></a></li>';
             }
         }
         $buffy .= '</ul>';
     }
     $buffy .= '</div> <!-- ./block -->';
     return $buffy;
 }
 function render($atts, $content = null)
 {
     parent::render($atts);
     $buffy = '';
     extract(shortcode_atts(array('limit' => '6', 'custom_title' => '', 'custom_url' => '', 'hide_title' => '', 'header_color' => ''), $atts));
     $cat_args = array('show_count' => true, 'orderby' => 'count', 'hide_empty' => false, 'order' => 'DESC', 'number' => $limit, 'exclude' => get_cat_ID(TD_FEATURED_CAT));
     // exclude categories from the demo
     if (TD_DEPLOY_MODE == 'demo' or TD_DEPLOY_MODE == 'dev') {
         $cat_args['exclude'] = '90, 91, 92, 93 , 94, 95, 96, 97, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 82, 83, 84, 85, 86, 87, 88, 89, 98, ' . get_cat_ID(TD_FEATURED_CAT);
     }
     $categories = get_categories($cat_args);
     // has a limit of 6 by default
     $buffy .= '<div class="' . $this->get_block_classes(array('widget', 'widget_categories')) . '">';
     $buffy .= $this->get_block_title();
     if (!empty($categories)) {
         $buffy .= '<ul class="td-pb-padding-side">';
         foreach ($categories as $category) {
             if (strtolower($category->cat_name) != 'uncategorized') {
                 $buffy .= '<li><a href="' . get_category_link($category->cat_ID) . '">' . $category->name . '<span class="td-cat-no">' . $category->count . '</span></a></li>';
             }
         }
         $buffy .= '</ul>';
     }
     $buffy .= '</div> <!-- ./block -->';
     return $buffy;
 }
Exemplo n.º 6
0
function woo_tumblog_category_link($post_id = 0, $type = 'articles')
{
    $category_link = '';
    if (get_option('woo_tumblog_content_method') == 'post_format') {
        $post_format = get_post_format();
        if ($post_format == '') {
            $category = get_the_category();
            $category_name = $category[0]->cat_name;
            // Get the ID of a given category
            $category_id = get_cat_ID($category_name);
            // Get the URL of this category
            $category_link = get_category_link($category_id);
        } else {
            $category_link = get_post_format_link($post_format);
        }
    } else {
        $tumblog_list = get_the_term_list($post_id, 'tumblog', '', '|', '');
        $tumblog_array = explode('|', $tumblog_list);
        ?>
		<?php 
        $tumblog_items = array('articles' => get_option('woo_articles_term_id'), 'images' => get_option('woo_images_term_id'), 'audio' => get_option('woo_audio_term_id'), 'video' => get_option('woo_video_term_id'), 'quotes' => get_option('woo_quotes_term_id'), 'links' => get_option('woo_links_term_id'));
        ?>
		<?php 
        // Get the ID of Tumblog Taxonomy
        $category_id = $tumblog_items[$type];
        $term =& get_term($category_id, 'tumblog');
        // Get the URL of Articles Tumblog Taxonomy
        $category_link = get_term_link($term, 'tumblog');
    }
    return $category_link;
}
 public function __construct($post)
 {
     // Set Category ID Values, but First Time Only
     if (Export_ID_XML_Generator::$OPINION_CATEGORY_ID == -1) {
         Export_ID_XML_Generator::$OPINION_CATEGORY_ID = get_cat_ID("Opinion");
         Export_ID_XML_Generator::$COLUMNS_CATEGORY_ID = get_cat_ID("Columns");
     }
     $this->post = $post;
     $this->context = array();
     $this->template = $this->get_template_context();
     $this->meta = get_post_meta($post->ID, Export_ID_XML_Admin_PostMeta::$META_KEY_NAME, true);
     $this->context['url'] = $this->get_permalink();
     $this->context['headline'] = $this->get_title();
     $this->context['author'] = $this->get_author();
     $this->context['rank'] = $this->get_rank();
     $this->context['body'] = $this->get_body();
     $this->context['jumpword'] = $this->get_jumpword();
     $this->context['conthead'] = $this->get_conthead();
     $this->context['hammer'] = $this->get_hammer();
     $this->context['kicker'] = $this->get_kicker();
     $this->context['bio'] = $this->get_bio();
     $this->context['photos'] = $this->get_photos();
     // Optional for Off-the-Hill Context
     $this->context['oth'] = $this->get_oth();
 }
Exemplo n.º 8
0
 function render($atts)
 {
     $this->block_uid = td_global::td_generate_unique_id();
     //update unique id on each render
     extract(shortcode_atts(array('limit' => '6', 'custom_title' => '', 'custom_url' => '', 'hide_title' => '', 'header_color' => ''), $atts));
     $cat_args = array('show_count' => true, 'orderby' => 'count', 'hide_empty' => false, 'order' => 'DESC', 'number' => $limit, 'exclude' => get_cat_ID(TD_FEATURED_CAT));
     if (TD_DEPLOY_MODE == 'demo' or TD_DEPLOY_MODE == 'dev') {
         $cat_args['exclude'] = '251, 252, 253, 254, 255, 256, 257, 258, 305, 306, ' . get_cat_ID(TD_FEATURED_CAT);
     }
     $categories = get_categories($cat_args);
     $buffy = '';
     $buffy .= '<div class="td_block_wrap td_popular_categories widget widget_categories">';
     $buffy .= $this->get_block_title_raw($atts, 'Popular category');
     if (!empty($categories)) {
         $buffy .= '<ul>';
         foreach ($categories as $category) {
             if (strtolower($category->cat_name) != 'uncategorized') {
                 $buffy .= '<li><a href="' . get_category_link($category->cat_ID) . '">' . $category->name . '<span class="td-cat-no">' . $category->count . '</span></a></li>';
             }
         }
         $buffy .= '</ul>';
     }
     $buffy .= '</div> <!-- ./block -->';
     return $buffy;
 }
Exemplo n.º 9
0
 /**
  * TODO: docs
  * @param type $cat_name
  * @return type
  */
 public function category_count_do($cat_name)
 {
     $cat_id = get_cat_ID($cat_name);
     $category = get_category($cat_id);
     $count = $category->category_count;
     return "{$cat_name} ({$count})";
 }
Exemplo n.º 10
0
    /**
     * Display navigation to next/previous post when applicable.
     */
    function oceanic_post_nav()
    {
        // Don't print empty markup if there's nowhere to navigate.
        $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
        $next = get_adjacent_post(false, '', false);
        if (!$next && !$previous) {
            return;
        }
        ?>
	<nav class="navigation post-navigation" role="navigation">
		<h1 class="screen-reader-text"><?php 
        _e('Post navigation', 'oceanic');
        ?>
</h1>
		<div class="nav-links">
			<?php 
        $slider_cats = get_theme_mod('oceanic-slider-cats', false);
        $slider_cat_ids = array();
        if ($slider_cats) {
            $slider_cats = explode(',', esc_html($slider_cats));
            for ($i = 0; $i < count($slider_cats); ++$i) {
                $cat_id = get_cat_ID($slider_cats[$i]);
                if ($cat_id > 0) {
                    $slider_cat_ids[$i] = $cat_id;
                }
            }
        }
        previous_post_link('<div class="nav-previous">%link</div>', _x('<span class="meta-nav">&larr;</span>&nbsp;%title', 'Previous post link', 'oceanic'), false, $slider_cat_ids);
        next_post_link('<div class="nav-next">%link</div>', _x('%title&nbsp;<span class="meta-nav">&rarr;</span>', 'Next post link', 'oceanic'), false, $slider_cat_ids);
        ?>
		</div><!-- .nav-links -->
	</nav><!-- .navigation -->
	<?php 
    }
Exemplo n.º 11
0
function posthasteCatCheck()
{
    if (is_category()) {
        return get_cat_ID(single_cat_title('', false));
    } else {
        return get_option('default_category', 1);
    }
}
Exemplo n.º 12
0
function get_my_category_link($categoryName)
{
    // Get the ID of a given category
    $category_id = get_cat_ID($categoryName);
    // Get the URL of this category
    $category_link = get_category_link($category_id);
    return $category_link;
}
Exemplo n.º 13
0
function alaya_cat_slug($cate_name)
{
    $cat_ID = get_cat_ID($cate_name);
    $thisCat = get_category($cat_ID);
    $cat_slug = $thisCat->slug;
    $cat_slug = apply_filters('alaya_cat_slug', $cat_slug);
    return $cat_slug;
}
Exemplo n.º 14
0
 /**
  *  Generate array with: recent/popular/most commented posts
  * @param string $sort Sort type (recent/popular/most commented)
  * @param integer $items Number of items to be extracted
  * @param boolean $image_post Extract or no post image
  * @param integer $image_width Set width of post image
  * @param integer $image_height Set height of post image
  * @param string $image_class Set class of post image
  * @param boolean $date_post Extract or no post date
  * @param string $date_format Set date format
  * @param string $post_type Set post type
  * @param string $category Set category from where posts would be extracted
  * @since Medica 2.0
  */
 function tfuse_shortcode_posts($args = null)
 {
     $defaults = array('sort' => 'recent', 'items' => 5, 'image_post' => true, 'image_width' => 54, 'image_height' => 54, 'image_class' => 'thumbnail', 'date_post' => true, 'date_format' => 'F jS, Y', 'post_type' => 'post', 'category' => '', 'specialites' => '');
     extract(wp_parse_args($args, $defaults));
     global $post;
     $tf_cat_ID = !empty($category) && empty($specialites) ? get_cat_ID($category) : '';
     $specialites = empty($category) && !empty($specialites) ? $specialites : '';
     if ($sort == 'recent') {
         $query = new WP_Query(array('post_type' => $post_type, 'orderby' => 'post_date', 'order ' => 'DESC', 'cat' => $tf_cat_ID, 'Specialites' => $specialites, 'posts_per_page' => $items));
         $posts = $query->get_posts();
     } elseif ($sort == 'popular') {
         $query = new WP_Query(array('post_type' => $post_type, 'orderby' => 'meta_value', 'meta_key' => TF_THEME_PREFIX . '_post_viewed', 'order ' => 'DESC', 'cat' => $tf_cat_ID, 'posts_per_page' => $items));
         $posts = $query->get_posts();
     } elseif ($sort == 'commented') {
         $query = new WP_Query(array('post_type' => $post_type, 'orderby' => 'comment_count', 'order ' => 'DESC', 'cat' => $tf_cat_ID, 'posts_per_page' => $items));
         $posts = $query->get_posts();
     } else {
         return false;
     }
     $tf_post_option = array();
     $count = 0;
     if (!empty($posts)) {
         foreach ($posts as $post_elm) {
             setup_postdata($post_elm);
             $img = '';
             if ($image_post == true) {
                 $post_image_src = tfuse_page_options('thumbnail_image', tfuse_page_options('single_image', null, $post_elm->ID), $post_elm->ID);
                 if (!empty($post_image_src)) {
                     $get_image = new TF_GET_IMAGE();
                     $img = $get_image->properties(array('class' => $image_class, 'alt' => get_the_title($post_elm->ID)))->width($image_width)->height($image_height)->src($post_image_src)->resize(true)->get_img();
                 }
             }
             if (!empty($img)) {
                 $tf_post_option[$count]['post_img'] = $img;
             } else {
                 $tf_post_option[$count]['post_img'] = '';
             }
             if ($date_post) {
                 $time_format = apply_filters('tfuse_widget_time_format', $date_format);
                 $tf_post_option[$count]['post_date_post'] = get_the_time($time_format, $post_elm->ID);
             } else {
                 $tf_post_option[$count]['post_date_post'] = '';
             }
             $tf_post_option[$count]['post_class'] = is_singular() && $post->ID == $post_elm->ID ? 'current-menu-item post_' . $sort : 'post_' . $sort;
             $tf_post_option[$count]['post_title'] = get_the_title($post_elm->ID);
             $tf_post_option[$count]['post_link'] = get_permalink($post_elm->ID);
             $tf_post_option[$count]['post_author_link'] = get_author_posts_url(get_the_author_meta('ID'));
             $tf_post_option[$count]['post_author_name'] = get_the_author();
             $tf_post_option[$count]['post_comnt_numb'] = get_comments_number($post_elm->ID);
             $tf_post_option[$count]['post_comnt_numb_link'] = tfuse_get_comments(true, $post_elm->ID);
             $tf_post_option[$count]['post_loveit_number'] = get_post_meta($post_elm->ID, TF_THEME_PREFIX . '_post_viewed', true);
             $tf_post_option[$count]['post_excerpt'] = apply_filters('get_the_excerpt', $post_elm->post_excerpt);
             $count++;
         }
         wp_reset_postdata();
     }
     return $tf_post_option;
 }
Exemplo n.º 15
0
function related_posts()
{
    echo "<h3 class=\"dividing-title\">Oglejte si še</h3>";
    $rp_prikazani[0] = get_the_ID();
    //ID glavnega posta, da se ne ponovi v predlogih
    global $post;
    $rp_x = 0;
    //Štetje, koliko postov je bilo izpisanih
    $rp_relacije = get_field('relacije');
    //Funkcija od Advanced custom fields plugina, no plugin no FUN
    //Izpiši ročno izbrane poste
    if ($rp_relacije) {
        $rp_args = array('post__in' => $rp_relacije);
        $rp_post_array = get_posts($rp_args);
        foreach ($rp_post_array as $post) {
            setup_postdata($post);
            rp_izpis();
            $rp_prikazani[$rp_x + 1] = get_the_ID();
            $rp_x++;
        }
        wp_reset_postdata();
    }
    //Če niso izbrani 4 posti, poišči dodatne, glede na kategorijo ali tag
    if ($rp_x < 4) {
        $rp_categories = get_the_category();
        foreach ($rp_categories as $rp_category) {
            if ($rp_category->term_id != get_cat_ID("prva_stran1") and $rp_category->term_id != get_cat_ID("prva_stran2") and $rp_category->term_id != get_cat_ID("prva_stran3") and $rp_category->term_id != get_cat_ID("slider")) {
                $rp_cat_list[] = $rp_category->term_id;
            }
        }
        $rp_oznake = get_the_tags();
        $rp_tag_list = array();
        if (is_array($rp_oznake)) {
            foreach ($rp_oznake as $rp_oznaka) {
                $rp_tag_list[] = $rp_oznaka->term_id;
            }
        }
        $rp_args = array('posts_per_page' => 6 - $rp_x, 'offset' => 0, 'orderby' => 'date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish', 'suppress_filters' => true, 'tax_query' => array('relation' => 'OR', array('taxonomy' => 'post_tag', 'field' => 'term_id', 'terms' => $rp_tag_list), array('taxonomy' => 'category', 'field' => 'term_id', 'terms' => $rp_cat_list)));
        $rp_post_array = get_posts($rp_args);
        foreach ($rp_post_array as $post) {
            setup_postdata($post);
            $rp_cid = get_the_ID();
            //Preveri, če je post že prikazan in v tem primeru postavi $rp_y = 0
            $rp_y = 1;
            foreach ($rp_prikazani as $rp_i) {
                if ($rp_i == $rp_cid) {
                    $rp_y = 0;
                }
            }
            //Preveri, če bo post izpisan
            if ($rp_x < 4 && $rp_y) {
                rp_izpis();
                $rp_x++;
            }
        }
        wp_reset_postdata();
    }
}
Exemplo n.º 16
0
 function build_jsonldBreadcrumb()
 {
     $jsonLD["@context"] = "http://schema.org/";
     $jsonLD["@type"] = "BreadcrumbList";
     //---------------------------------
     // pre-define some variables
     //---------------------------------
     $home_title = get_bloginfo('name');
     $home_url = esc_url(home_url('/'));
     $blog_url = get_permalink(get_option('page_for_posts'));
     $blog_title = get_the_title(get_option('page_for_posts', true));
     $url = $url ? $url : get_permalink();
     $title = $title ? $title : get_the_title();
     $itemList = array();
     //----------------------------------
     // Output
     //-----------------------------------
     $itemList[] = array("@type" => "ListItem", "position" => 1, "item" => array('@id' => $home_url, 'name' => $home_title));
     //----------------------------------------------
     // figure out the next number
     // <meta property="position" content="{NUM}">
     //----------------------------------------------
     $next = 2;
     if (is_single() or is_home()) {
         //-------------------------------------
         // we have a blog "post"
         // so we added the blog url (not home)
         // so next is 3 not 2!
         //--------------------------------------
         $itemList[] = array("@type" => "ListItem", "position" => 2, "item" => array('@id' => $blog_url, 'name' => $blog_title));
         $next = 3;
     }
     if (is_single() or is_page() or is_tag() or is_category()) {
         //----------------------------------
         // is it a tag?
         //----------------------------------
         if (is_tag()) {
             $title = single_tag_title("", false);
             $tag_id = get_term_by('name', $title, 'post_tag');
             $url = get_tag_link($tag_id->term_id);
         }
         if (is_category()) {
             $title = single_cat_title("", false);
             $category_id = get_cat_ID($title);
             $url = get_category_link($category_id);
         }
         $itemList[] = array("@type" => "ListItem", "position" => $next, "item" => array('@id' => $url, 'name' => $title));
     }
     $jsonLD["itemListElement"] = $itemList;
     /*echo '<pre>';
     	print_r(json_encode($jsonLD));
     	echo '</pre>';*/
     if ((is_page() or is_single() or is_home() or is_tag() or is_category()) and !is_front_page()) {
         echo '<script type="application/ld+json">';
         echo json_encode($jsonLD);
         echo '</script>';
     }
 }
Exemplo n.º 17
0
 /**
  * Load template
  *
  * @param Int $offset number off for pagination
  *
  * @return void
  */
 public static function load($offset = 0, $category = 0)
 {
     $category = get_cat_ID($category);
     $offset = $offset;
     if (0 === $category) {
         $category = get_the_category()[0]->cat_ID;
     }
     require get_stylesheet_directory() . self::PATH;
 }
Exemplo n.º 18
0
function get_category_name_link($strName, $strDisplay = '')
{
    $strResult = '';
    if ($strDisplay == '') {
        $strDisplay = $strName;
    }
    $strResult = '<a href="' . get_category_link(get_cat_ID($strName)) . '">' . $strDisplay . '</a>';
    return $strResult;
}
Exemplo n.º 19
0
function de_create_featured_post()
{
    if (get_option('is_featured_post_sample') != 'true') {
        // Create post object
        $my_post = array('post_title' => 'Featured Post Sample', 'post_content' => 'This is just a sample post, Edit or delete it.', 'post_status' => 'publish', 'post_author' => 1, 'post_category' => array(get_cat_ID("featured post")));
        // Insert the post into the database
        wp_insert_post($my_post);
        add_option("is_featured_post_sample", 'true');
    }
}
Exemplo n.º 20
0
/**
 * Get permalink for page, post or category
 * 
 * @param int|string $system
 * @param bool $isCat
 * @return string
 */
function ale_get_permalink($system, $isCat = 0)
{
    if ($isCat) {
        if (!is_numeric($system)) {
            $system = get_cat_ID($system);
        }
        return get_category_link($system);
    } else {
        $page = ale_get_page($system);
        return null === $page ? '' : get_permalink($page->ID);
    }
}
Exemplo n.º 21
0
 public function board_title($post)
 {
     wp_nonce_field(basename(__FILE__), 'pbl_on_the_boards_nonce');
     $text = get_post_meta($post->ID, 'pbl_board_title', true);
     if (!$text) {
         $text = '';
     }
     $category_ID = get_cat_ID('On The Boards');
     echo "<div class='hidden'><input id='in-category-{$category_ID}' type='checkbox' name='post_category[]' value='{$category_ID}' checked></div>";
     $wpesettings = array('media_buttons' => false, 'textarea_rows' => 7);
     wp_editor(htmlspecialchars_decode($text), 'pbl_board_title', $wpesettings);
 }
Exemplo n.º 22
0
function slideContent($catName, $imgName, $po)
{
    if ($po == 'post') {
        $p = get_page_by_title('Camboriu');
        $catLink = get_page_link($p->ID);
    } else {
        $catId = get_cat_ID($catName);
        $catLink = get_category_link($catId);
    }
    $src = get_bloginfo('template_url') . '/img/home/slide-destinos/' . $imgName . '.jpg';
    return array('name' => $catName, 'href' => $catLink, 'src' => $src);
}
Exemplo n.º 23
0
function count_cat_post($category)
{
    if (is_string($category)) {
        $catID = get_cat_ID($category);
    } elseif (is_numeric($category)) {
        $catID = $category;
    } else {
        return 0;
    }
    $cat = get_category($catID);
    return $cat->count;
}
Exemplo n.º 24
0
    /**
     * Outputs the content of the widget
     *
     * @param array $args
     * @param array $instance
     */
    public function widget($args, $instance)
    {
        global $post;
        echo $args['before_widget'];
        // List most recent Videos
        $Videos = get_cat_ID('Videos');
        $videos_link = get_category_link($Videos);
        query_posts(array('cat' => $Videos, 'posts_per_page' => 1, 'order' => 'DESC', 'post_type' => array('post', 'recipes', 'reviews'), 'post__not_in' => array($post->ID)));
        if (have_posts()) {
            while (have_posts()) {
                the_post();
                $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large');
                $videoID = get_post_meta($post->ID, 'video_link', true);
                ?>
				<div class="hidden-xs">
					<div class="videoWrap">
						<a href="<?php 
                the_permalink();
                ?>
">
							<?php 
                if ($image) {
                    echo '<article class="recent-video" style="background: url(' . $image[0] . ') no-repeat scroll center / cover; ">';
                } else {
                    echo '<article class="recent-video" style="background: url(http://img.youtube.com/vi/' . $videoID . '/sddefault.jpg) no-repeat scroll center / cover; ">';
                }
                echo '<div class="playwrap"><i class="fa fa-play"></i></div>';
                echo '</article>';
                ?>
						</a>
					</div>
					<a href="<?php 
                echo $videos_link;
                ?>
" class="btn btn-custom btn-blue">Watch Videos</a>
				</div>
				<div class="visible-xs">
					<iframe width="100%" height="225" src="https://www.youtube.com/embed/<?php 
                echo $videoID;
                ?>
?&showinfo=0&controls=0" frameborder="0" allowfullscreen showinfo="false"></iframe>
					<a href="<?php 
                echo $videos_link;
                ?>
" class="btn btn-custom btn-blue">Watch Videos</a>
				</div>
				<?php 
            }
        }
        wp_reset_query();
        echo $args['after_widget'];
    }
Exemplo n.º 25
0
/**
 * Entropy Rising homepage have_posts query
 * @version 2.0
 */
function er_have_posts()
{
    // Get the page and offset
    $posts_per_page = 6;
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    $offset = $posts_per_page * $paged - $posts_per_page;
    // Format query arguments
    $args = array('paged' => $paged, 'posts_per_page' => $posts_per_page, 'offset' => $offset, 'cat' => get_cat_ID('guild news') . ',' . get_cat_ID('entropy rising'));
    // Retrieve posts
    query_posts($args);
    // Return whether there are posts
    return have_posts();
}
Exemplo n.º 26
0
function is_commodity()
{
    global $commodity_cat_name_group, $cat;
    if ($commodity_cat_name_group) {
        foreach ($commodity_cat_name_group as $commodity_cat_name) {
            if ($commodity_cat_name) {
                $commodity_cat_ID = get_cat_ID($commodity_cat_name);
                if ($commodity_cat_ID == get_category_root_id($cat) || $commodity_cat_ID == $cat) {
                    return true;
                }
            }
        }
    }
}
Exemplo n.º 27
0
function get_breadcrumbs()
{
    global $wp_query;
    $breadcrumbs = "";
    if (!is_home()) {
        $breadcrumbs .= '<li><a title="' . get_bloginfo('name') . '" href="' . get_settings('home') . '">' . get_bloginfo('name') . '</a></li>';
        if (is_category()) {
            $catTitle = single_cat_title("", false);
            $cat = get_cat_ID($catTitle);
            $breadcrumbs .= "<li>" . get_category_parents($cat, true, "") . "</li>";
        } elseif (is_archive() && !is_category()) {
            $y = get_query_var('year');
            $m = get_query_var('monthnum');
            if (is_year()) {
                $breadcrumbs .= "<li>" . $y . "年</li>";
            }
            if (is_month()) {
                $breadcrumbs .= '<li><a title="' . $y . '年" href="' . get_year_link($y) . '">' . $y . '年</a></li>';
                $breadcrumbs .= "<li>" . $m . "月</li>";
            }
        } elseif (is_search()) {
            $breadcrumbs .= "<li>Search Results</li>";
        } elseif (is_404()) {
            $breadcrumbs .= "<li>404 Not Found</li>";
        } elseif (is_single()) {
            $category = get_the_category();
            $category_id = get_cat_ID($category[0]->cat_name);
            $breadcrumbs .= '<li>' . get_category_parents($category_id, true, "") . "</li>";
            $breadcrumbs .= '<li>' . get_the_title(get_query_var('p')) . "</li>";
        } elseif (is_page()) {
            $post = $wp_query->get_queried_object();
            if ($post->post_parent == 0) {
                $breadcrumbs .= "<li>" . the_title('', '', false) . "</li>";
            } else {
                $title = the_title('', '', false);
                $ancestors = array_reverse(get_post_ancestors($post->ID));
                array_push($ancestors, $post->ID);
                foreach ($ancestors as $ancestor) {
                    if ($ancestor != end($ancestors)) {
                        $breadcrumbs .= '<li><a href="' . get_permalink($ancestor) . '">' . strip_tags(apply_filters('single_post_title', get_the_title($ancestor))) . '</a></li>';
                    } else {
                        $breadcrumbs .= '<li>' . strip_tags(apply_filters('single_post_title', get_the_title($ancestor))) . '</li>';
                    }
                }
            }
        }
    }
    return $breadcrumbs;
}
Exemplo n.º 28
0
function insert_faq_post()
{
    $intUserId = '';
    $strCategory = '';
    $strQuestion = '';
    $intUserId = get_current_user_id();
    $strQuestion = $_POST['question'];
    $intCategoryId = get_cat_ID(esc_attr($_POST['category']));
    $strPostType = $_POST['post_typee'];
    $strQuestionar = $_POST['questionar_name'];
    $defaults = '';
    $defaults = array('post_author' => 1, 'post_content' => '', 'post_title' => $strQuestion, 'post_status' => 'pending', 'post_category' => array($intCategoryId), 'post_type' => $strPostType);
    $id = wp_insert_post($defaults);
    add_post_meta($id, '_jkc_jaq_author', $strQuestionar);
    return 'success';
}
Exemplo n.º 29
0
function icons($link = true, $title = false)
{
    global $post;
    $categories = get_parent_cats();
    //all categorys
    foreach ($categories as $category) {
        if ($category->category_description !== '' && $category->category_description) {
            echo $link ? '<a title="' . $category->name . '" href="' . get_category_link(get_cat_ID($category->name)) . '">' : '';
            echo $title ? $category->name : '';
            echo '<i title="' . $category->name . '" class="fa ' . $category->category_description . '"></i>';
            echo $link ? '</a>' : '';
        } else {
            echo !$link ? file_get_contents("wp-content/themes/amnesty/img/amensty.svg") : '';
        }
    }
}
Exemplo n.º 30
-11
 private function _getPostTop($category)
 {
     if (empty($category)) {
         $this->_trough404('_getPostTop: No category set');
     }
     require $this->wp;
     $cid = get_cat_ID($category);
     if ($cid) {
         $wp_posts = get_posts(array('category' => get_cat_ID($category)));
         foreach ($wp_posts as $wp_post) {
             $id = $wp_post->ID;
             $tags = wp_get_post_tags($wp_post->ID);
             foreach ($tags as $tag) {
                 if ($tag->name == 'top') {
                     return $id;
                 }
             }
         }
         if (!empty($id)) {
             return $id;
         }
         // Backup, random one
     }
     $this->_trough404('_getPostTop: No category found');
 }