function k2_asides_permalink($content) { if (in_category(get_option('unwakeable_asidescategory')) and !is_singular()) { $content .= '<a href="' . get_permalink() . '" rel="bookmark" class="asides-permalink" title="' . k2_permalink_title(false) . '">(' . get_comments_number() . ')</a>'; } return $content; }
function get_the_content_our_way($more, $strip_teaser) { if (!in_category(array('tylerdibiasio', 'mishatownsend', 'korwinbriggs', 'twogirls', 'thefinerthings'))) { $content = get_the_content($more, $strip_teaser); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); return "{$content}"; } else { //get the category if (in_category('tylerdibiasio')) { $href = "<a href=\"" . get_option('siteurl') . "/category/tylerdibiasio\">"; } elseif (in_category('mishatownsend')) { $href = "<a href=\"" . get_option('siteurl') . "/category/mishatownsend\">"; } elseif (in_category('korwinbriggs')) { $href = "<a href=\"" . get_option('siteurl') . "/category/korwinbriggs\">"; } elseif (in_category('twogirls')) { $href = "<a href=\"" . get_option('siteurl') . "/category/twogirls\">"; } elseif (in_category('thefinerthings')) { $href = "<a href=\"" . get_option('siteurl') . "/category/thefinerthings\">"; } $content = get_the_content($more, $strip_teaser); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); $content = preg_replace('/(.*)(<a.*?href.*?\\>)/is', "\\1{$href}", $content); return "{$content}"; } }
function layerslider($id = 0, $page = '') { // Check id if (!isset($id) || empty($id)) { echo '[LayerSlider WP] You need to specify the "id" parameter for the layerslider() function call'; return; } // Page filter if (isset($page) && !empty($page)) { // Get page name, ID and categories $pagename = basename(get_permalink()); $pageid = (string) get_the_ID(); $categories = get_the_category(); // Get pages $pages = explode(',', $page); // Iterate over the pages foreach ($pages as $page) { if ($page == 'homepage' && is_front_page()) { echo layerslider_init(array('id' => $id)); } elseif ($pageid == $page) { echo layerslider_init(array('id' => $id)); } elseif ($pagename == $page) { echo layerslider_init(array('id' => $id)); } elseif (in_category($page)) { echo layerslider_init(array('id' => $id)); } } // All pages } else { echo layerslider_init(array('id' => $id)); } }
function wp_enqueue_scripts() { // Remove Open Sans that WP adds from frontend wp_deregister_style('open-sans'); wp_register_style('open-sans', false); // Enqueue google fonts $fonts = db_google_font_enqueue(); wp_enqueue_style('db-enqueue-fonts', $fonts); wp_enqueue_script('jquery'); wp_enqueue_style('db-smartmenus', get_template_directory_uri() . '/js/smartmenus/addons/bootstrap/jquery.smartmenus.bootstrap.css', array(), null, 'all'); wp_enqueue_style('db-lazyloadxt-fadein', get_template_directory_uri() . '/js/lazyloadxt/dist/jquery.lazyloadxt.fadein.css', array(), null, 'all'); wp_enqueue_style('db-header-style', get_template_directory_uri() . '/layouts/header.css'); wp_enqueue_style('db-footer-style', get_template_directory_uri() . '/layouts/footer.css'); wp_enqueue_style('db-content-sidebar', get_template_directory_uri() . '/layouts/content-sidebar.css'); $jsObject = array('ajaxurl' => admin_url('admin-ajax.php'), 'themeurl' => get_bloginfo('template_url'), 'is_tpl_default' => is_page() and !is_page_template()); wp_localize_script('jquery', 'db', $jsObject); wp_enqueue_script('lazyloadxt', $this->templateURL . '/js/lazyloadxt/dist/jquery.lazyloadxt.js', array('jquery')); wp_enqueue_script('bootstrap', $this->templateURL . '/js/bootstrap.min.js', array('jquery')); wp_enqueue_script('smooth-scroll', $this->templateURL . '/js/smoothscroll.js', array('jquery')); wp_enqueue_script('smartmenus', $this->templateURL . '/js/smartmenus/jquery.smartmenus.js', array('jquery'), false, true); wp_enqueue_script('smartmenus-bootstrap', $this->templateURL . '/js/smartmenus/addons/bootstrap/jquery.smartmenus.bootstrap.js', array('jquery'), false, true); wp_enqueue_script('imagesloaded', '//cdnjs.cloudflare.com/ajax/libs/jquery.imagesloaded/4.0.0/imagesloaded.pkgd.min.js', array('jquery'), false, true); wp_enqueue_script('matchHeight', $this->templateURL . '/js/jquery.matchHeight-min.js', array('jquery'), false, true); wp_enqueue_script('db', $this->templateURL . '/js/db.js', array('jquery'), false, true); if (is_singular('post') && in_category('phan-cung')) { wp_enqueue_script('bxslider', $this->templateURL . '/js/bxslider/jquery.bxslider.min.js', array('jquery'), false, true); wp_enqueue_style('bxslider', get_template_directory_uri() . '/js/bxslider/jquery.bxslider.css', array(), null, 'all'); wp_enqueue_script('category-product', $this->templateURL . '/js/category-product.js', array('jquery', 'bxslider'), false, true); } wp_enqueue_style('db-common-style', get_template_directory_uri() . '/layouts/common.css', array('bootstrap')); }
/** * Passes some Tarski-specific arguments to wp_link_pages. * * @since 2.0 * * @uses wp_link_pages */ function tarski_link_pages() { $arguments = array('before' => '<p class="link-pages"><strong>' . __('Pages:', 'tarski') . '</strong>', 'after' => '</p>', 'next_or_number' => 'number', 'nextpagelink' => __('Next page', 'tarski'), 'previouspagelink' => __('Previous page', 'tarski'), 'pagelink' => '%', 'more_file' => '', 'echo' => true); if (!(has_post_format('aside') || in_category(get_tarski_option('asidescategory')))) { wp_link_pages($arguments); } }
function pmpro_page_meta() { global $membership_levels, $post, $wpdb; $page_levels = $wpdb->get_col("SELECT membership_id FROM {$wpdb->pmpro_memberships_pages} WHERE page_id = '{$post->ID}'"); ?> <ul id="membershipschecklist" class="list:category categorychecklist form-no-clear"> <input type="hidden" name="pmpro_noncename" id="pmpro_noncename" value="<?php echo wp_create_nonce(plugin_basename(__FILE__)); ?> " /> <?php $in_member_cat = false; foreach ($membership_levels as $level) { ?> <li id="membership-level-<?php echo $level->id; ?> "> <label class="selectit"> <input id="in-membership-level-<?php echo $level->id; ?> " type="checkbox" <?php if (in_array($level->id, $page_levels)) { ?> checked="checked"<?php } ?> name="page_levels[]" value="<?php echo $level->id; ?> " /> <?php echo $level->name; //Check which categories are protected for this level $protectedcategories = $wpdb->get_col("SELECT category_id FROM {$wpdb->pmpro_memberships_categories} WHERE membership_id = {$level->id}"); //See if this post is in any of the level's protected categories if (in_category($protectedcategories, $post->id)) { $in_member_cat = true; echo ' *'; } ?> </label> </li> <?php } ?> </ul> <?php if ('post' == get_post_type($post) && $in_member_cat) { ?> <p class="pmpro_meta_notice">* <?php _e("This post is already protected for this level because it is within a category that requires membership.", "pmpro"); ?> </p> <?php } do_action('pmpro_after_require_membership_metabox', $post); }
function results_subscribe_scripts() { if (in_category(3) || is_home()) { wp_register_script("results_subscribe", plugins_url("/index.min.js", __FILE__), ["jquery", "bootstrap-validator"], false, false); wp_localize_script("results_subscribe", "resultsSubscribe", array("phpScriptURL" => plugin_dir_url(__FILE__) . "handle_subscribe.php")); wp_enqueue_script("results_subscribe"); } }
function single_category_template($st) { global $post; if (in_category('servicios')) { $st = TEMPLATEPATH . '/single-services.php'; } return $st; }
function get_custom_cat_template($single_template) { global $post; if (in_category('adventure')) { $single_template = dirname(__FILE__) . '/single-adventure.php'; } return $single_template; }
function insert_exif() { if (is_single() && in_category('118') || is_attachment()) { global $post; $args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID); $attachments = get_posts($args); foreach ($attachments as $attachment) { $imgid = $attachment->ID; $imgmeta = wp_get_attachment_metadata($imgid); $latitude = $imgmeta['image_meta']['latitude']; $longitude = $imgmeta['image_meta']['longitude']; $lat_ref = $imgmeta['image_meta']['latitude_ref']; $lng_ref = $imgmeta['image_meta']['longitude_ref']; $lat = geo_single_fracs2dec($latitude); $lng = geo_single_fracs2dec($longitude); if ($lat_ref == 'S') { $neg_lat = '-'; } else { $neg_lat = ''; } if ($lng_ref == 'W') { $neg_lng = '-'; } else { $neg_lng = ''; } echo "<ul class='exif'>"; if (!empty($imgmeta['image_meta']['aperture'])) { echo "<li>Aperture: f/" . $imgmeta['image_meta']['aperture'] . "</li>"; } if (!empty($imgmeta['image_meta']['iso'])) { echo "<li>ISO: " . $imgmeta['image_meta']['iso'] . "</li>"; } if (!empty($imgmeta['image_meta']['shutter_speed'])) { echo "<li>Shutter Speed: "; if (1 / $imgmeta['image_meta']['shutter_speed'] > 1) { echo "1/"; if (number_format(1 / $imgmeta['image_meta']['shutter_speed'], 1) == 1.3 or number_format(1 / $imgmeta['image_meta']['shutter_speed'], 1) == 1.5 or number_format(1 / $imgmeta['image_meta']['shutter_speed'], 1) == 1.6 or number_format(1 / $imgmeta['image_meta']['shutter_speed'], 1) == 2.5) { echo number_format(1 / $imgmeta['image_meta']['shutter_speed'], 1, '.', '') . " s</li>"; } else { echo number_format(1 / $imgmeta['image_meta']['shutter_speed'], 0, '.', '') . " s</li>"; } } else { echo $imgmeta['image_meta']['shutter_speed'] . " s</li>"; } } if (!empty($imgmeta['image_meta']['focal_length'])) { echo "<li>Focal Length: " . $imgmeta['image_meta']['focal_length'] . "mm</li>"; } if (!empty($imgmeta['image_meta']['camera'])) { echo "<li>Camera: " . $imgmeta['image_meta']['camera'] . "</li>"; } if ($latitude != 0 && $longitude != 0) { echo '<li>Location: <a href="http://maps.google.com/maps?q=' . $neg_lat . number_format($lat, 6) . '+' . $neg_lng . number_format($lng, 6) . '&z=11">' . geo_pretty_fracs2dec($latitude) . $lat_ref . ' ' . geo_pretty_fracs2dec($longitude) . $lng_ref . '</a></li>'; } echo "</ul>"; } } }
function new_excerpt_more($more) { global $post; if (in_category('news')) { return '<a class="moretag" href="' . get_permalink($post->ID) . '"><img src="' . get_template_directory_uri() . '/dist/images/arrow-green-right.svg"></a>'; } elseif (in_category('datablog')) { return '<a class="moretag" href="' . get_permalink($post->ID) . '"><img src="' . get_template_directory_uri() . '/dist/images/arrow-blue-right.svg"></a>'; } }
/** * @desc check in which category we are * @param string $category - WP definition of siteareas like is_page, is_home * @return boolean true/false */ function king_in_category($categories) { global $category_cache, $post; $cat_ids = explode(',', $categories); foreach ($cat_ids as $cat_id) { if (in_category($cat_id)) { return true; } } }
function dt_in_parent_category($cats, $_post = null) { foreach ((array) $cats as $cat) { $descendants = get_term_children((int) $cat, "category"); if ($descendants && in_category($descendants, $_post)) { return true; } } return false; }
function post_is_in_descendant_category($cats, $_post = null) { foreach ((array) $cats as $cat) { // get_term_children() accepts integer ID only $descendants = get_term_children((int) $cat, 'category'); if ($descendants && in_category($descendants, $_post)) { return true; } } return false; }
/** * Checks if blog post is in subcategory, used in CP 3.0.4 and earlier. * * @deprecated 3.0.5 * * @param array $cats * @param object $post (optional) * * @return bool */ function cp_post_in_desc_cat($cats, $post = null) { _deprecated_function(__FUNCTION__, '3.0.5'); foreach ((array) $cats as $cat) { $descendants = get_term_children((int) $cat, 'category'); if ($descendants && in_category($descendants, $post)) { return true; } } return false; }
public function is_in_descendant($post_id, $parent_term) { foreach ((array) $parent_term as $pt) { $pt = get_term_by('slug', $pt, 'category'); $child_terms = get_term_children($pt->term_id, $this->tax_name); if ($child_terms && in_category($child_terms, $post_id)) { return true; } } return false; }
function aktt_excludecat_do_blog_post_tweet($tweet, $post) { $cats = get_option('aktt_excludecats'); if (is_array($cats) && count($cats)) { foreach ($cats as $cat) { if (in_category($cat, $post)) { return false; } } } return $tweet; }
function pvlpDisplayMenuItem($menuItem, $mapMenuIDToSubmenus, $tag) { global $wp_query; if (!empty($wp_query->queried_object_id)) { $queriedObjectID = (int) $wp_query->queried_object_id; } $title = $menuItem->title; $url = $menuItem->url; $classes = array('menuItem-' . pvlpShortenNameToProperNameSlug($title)); if (!empty($queriedObjectID)) { $currentItem = $menuItem->object_id == $queriedObjectID && ($wp_query->is_singular() && $menuItem->type == 'post_type' || $wp_query->is_category() && $menuItem->object == 'category'); $currentCategory = ($wp_query->is_single || $wp_query->is_page) && $menuItem->object == 'category' && in_category($menuItem->object_id, $queriedObjectID); if ($currentItem) { $classes[] = 'current-item'; } if ($currentCategory) { $classes[] = 'current-category'; } } ?> <li<?php echo glazyAttribute('class', $class); ?> ><<?php echo $tag; ?> ><a<?php glazyAttribute('href', $url); ?> ><?php echo glazeText($title); ?> </a></<?php echo $tag; ?> ><?php if (!empty($mapMenuIDToSubmenus[$menuItem->ID])) { ?> <ul class="menu submenu"> <?php foreach ($mapMenuIDToSubmenus[$menuItem->ID] as $submenu) { pvlpDisplayMenuItem($submenu, $mapMenuIDToSubmenus, $tag); } ?> </ul> <?php } ?> </li> <?php }
function widget($args, $instance) { global $adrotate_config, $post, $blog_id; extract($args); if (empty($instance['groupid'])) { $instance['groupid'] = 0; } if (empty($instance['siteid'])) { $instance['siteid'] = $blog_id; } if (empty($instance['title'])) { $instance['title'] = ''; } if (empty($instance['categories'])) { $instance['categories'] = ''; } if (empty($instance['pages'])) { $instance['pages'] = ''; } // Determine post injection if ($instance['categories'] != '' or $instance['pages'] != '') { $show = false; $categories = explode(",", $instance['categories']); $pages = explode(",", $instance['pages']); if (is_page($pages) or is_category($categories) or in_category($categories)) { $show = true; } } else { $show = true; } if ($show) { echo $before_widget; $title = apply_filters('widget_title', $instance['title']); if ($title) { echo $before_title . $title . $after_title; } if ($adrotate_config['widgetalign'] == 'Y') { echo '<ul><li>'; } if ($adrotate_config['w3caching'] == 'Y') { echo '<!-- mfunc ' . W3TC_DYNAMIC_SECURITY . ' -->'; echo 'echo adrotate_group(' . $instance['groupid'] . ', 0, 0, ' . $instance['siteid'] . ');'; echo '<!-- /mfunc ' . W3TC_DYNAMIC_SECURITY . ' -->'; } else { echo adrotate_group($instance['groupid'], 0, 0, $instance['siteid']); } if ($adrotate_config['widgetalign'] == 'Y') { echo '</li></ul>'; } echo $after_widget; } }
function crmpress_other_stats_loop() { global $post, $active_projects, $thirty_days, $seven_days; if (in_category('active-project')) { $active_projects++; } if ($post->post_date > date('Y-m-d', strtotime('-30 days'))) { $thirty_days++; } if ($post->post_date > date('Y-m-d', strtotime('-7 days'))) { $seven_days++; } }
/** * Enqueue scripts and styles. */ function sudoers_scripts() { global $page, $numpages; wp_enqueue_style('sudoers-style', get_stylesheet_uri()); wp_enqueue_script('sudoers-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true); wp_enqueue_script('sudoers-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true); if (is_singular() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } wp_register_script('sudoers', get_template_directory_uri() . '/js/sudoers.js', array(), '20151215'); wp_localize_script('sudoers', 'sudoers', array('is_home' => is_home(), 'is_front_page' => is_front_page(), 'is_single' => is_single(), 'is_singular' => is_singular(), 'is_page' => is_page(), 'is_category' => is_category(), 'is_tag' => is_tag(), 'is_archive' => is_archive(), 'is_404' => is_404(), 'is_search' => is_search(), 'is_tax' => is_tax(), 'is_author' => is_author(), 'is_paged' => is_paged(), 'is_slideshow' => is_single() && $numpages > 1 ? 1 : 0, 'is_video_single' => is_single() && in_category(SUDOERS_VIDEO_CATEGORY) ? 1 : 0, 'is_video_cat' => is_category(SUDOERS_VIDEO_CATEGORY) ? 1 : 0, 'post_page' => $page, 'post_numpages' => $numpages, 'debug_js' => false, 'environment' => get_environment())); wp_enqueue_script('sudoers'); }
function insertLinks($content) { //display all categories that have at least one post, separate each category with comma+space, put each category in quotes $categories = get_categories(); if ($categories) { $cat_array = array(); foreach ($categories as $category) { // For categories named Frontpage Article & Bespoke Solutions if ($category->name != 'Frontpage Article' && $category->name != 'Bespoke Solutions') { array_push($cat_array, $category->cat_ID); } } $exclude_str = implode(',', $cat_array); } if (in_category('Frontpage Article')) { $adj_prev = get_adjacent_post(true, $exclude_str, true); $adj_next = get_adjacent_post(true, $exclude_str, false); if ($adj_prev) { $catsp = array(); foreach (wp_get_post_categories($adj_prev->ID) as $c) { $cat_prev = get_category($c); array_push($catsp, $cat_prev->name); } if (in_array("Frontpage Article", $catsp)) { $prev_post = get_permalink($adj_prev); } // $cat_id_prev = get_the_category_by_ID($adj_prev->ID); } if ($adj_next) { $catsn = array(); foreach (wp_get_post_categories($adj_next->ID) as $c) { $cat_next = get_category($c); array_push($catsn, $cat_next->name); } if (in_array("Frontpage Article", $catsn)) { $next_post = get_permalink($adj_next); } } //$content.= "<div id='nav-cat-links'>"; if (isset($prev_post)) { $content .= "<a class='plugin btn btn-primary btn-lgh' href=" . $prev_post . "><i class='fa fa-arrow-left'></i><span>Previous</span></a>"; } if (isset($next_post)) { $content .= "<a class='plugin btn btn-primary btn-lg wubble-button-right' href=" . $next_post . "><i class='fa fa-arrow-right'></i><span>Next</span></a>"; } // $content.= "</div>"; } return $content; }
function hc_conditionaly_load_scripts() { global $post; if (is_single($post->ID)) { if (in_category('video', $post->ID)) { // Fitvids wp_register_script('fitvids-script', get_template_directory_uri() . '/js/vendor/jquery.fitvids.js', array('jquery'), '1.1', true); wp_enqueue_script('fitvids-script'); } if (in_category('Hella Hype', $post->ID)) { // Flexslider wp_register_script('flexslider-script', get_template_directory_uri() . '/js/vendor/jquery.flexslider-min.js', array('jquery'), '2.2.2', true); wp_enqueue_script('flexslider-script'); } } }
function is_desc_cat($cats, $_post = null) { foreach ((array) $cats as $cat) { if (in_category($cat, $_post)) { return true; } else { if (!is_int($cat)) { $cat = get_cat_ID($cat); } $descendants = get_term_children($cat, 'category'); if ($descendants && in_category($descendants, $_post)) { return true; } } } return false; }
function swp_yummly_button_html($array) { // If we've already generated this button, just use our existing html if (isset($_GLOBALS['sw']['buttons'][$array['postID']]['yummly'])) { $array['resource']['yummly'] = $_GLOBALS['sw']['buttons'][$array['postID']]['yummly']; // If not, let's check if Yummly is activated and create the button HTML } elseif (isset($array['options']['newOrderOfIcons']['yummly']) && !isset($array['buttons']) || isset($array['buttons']) && isset($array['buttons']['yummly'])) { if (isset($array['options']['yummly_categories']) && $array['options']['yummly_categories'] != '' && in_category($array['options']['yummly_categories'], $array['postID']) || isset($array['options']['yummly_tags']) && $array['options']['yummly_tags'] != '' && has_tag($array['options']['yummly_tags'], $array['postID']) || (!isset($array['options']['yummly_tags']) && !isset($array['options']['yummly_categories']) || $array['options']['yummly_categories'] == '' && $array['options']['yummly_tags'] == '')) { $array['totes'] += $array['shares']['yummly']; ++$array['count']; // Let's create a title if (get_post_meta($array['postID'], 'nc_ogTitle', true)) { // If the user defined an social media title, let's use it. $title = urlencode(urldecode(get_post_meta($array['postID'], 'nc_ogTitle', true))); } else { // Otherwise we'll use the default post title $title = urlencode(urldecode(get_the_title())); } if (get_post_meta($array['postID'], 'swp_open_graph_image_url')) { $image = urlencode(urldecode(get_post_meta($array['postID'], 'swp_open_graph_image_url', true))); } else { $image = urlencode(urldecode(get_post_meta($array['postID'], 'swp_open_thumbnail_url', true))); } $array['resource']['yummly'] = '<div class="nc_tweetContainer swp_yummly" data-id="' . $array['count'] . '" data-network="yummly">'; // $link = urlencode(urldecode(swp_process_url( $array['url'] , 'yummly' , $array['postID'] ))); $link = $array['url']; $array['resource']['yummly'] .= '<a target="_blank" href="http://www.yummly.com/urb/verify?url=' . $link . '&title=' . $title . '&image=' . $image . '&yumtype=button" data-link="http://www.yummly.com/urb/verify?url=' . $link . '&title=' . $title . '&image=' . $image . '&yumtype=button" class="nc_tweet">'; if ($array['options']['totesEach'] && $array['shares']['totes'] >= $array['options']['minTotes'] && $array['shares']['yummly'] > 0) { $array['resource']['yummly'] .= '<span class="iconFiller">'; $array['resource']['yummly'] .= '<span class="spaceManWilly">'; $array['resource']['yummly'] .= '<i class="sw sw-yummly"></i>'; $array['resource']['yummly'] .= '<span class="swp_share"> ' . __('Yum', 'social-warfare') . '</span>'; $array['resource']['yummly'] .= '</span></span>'; $array['resource']['yummly'] .= '<span class="swp_count">' . swp_kilomega($array['shares']['yummly']) . '</span>'; } else { $array['resource']['yummly'] .= '<span class="swp_count swp_hide"><span class="iconFiller"><span class="spaceManWilly"><i class="sw sw-yummly"></i><span class="swp_share"> ' . __('Yum', 'social-warfare') . '</span></span></span></span>'; } $array['resource']['yummly'] .= '</a>'; $array['resource']['yummly'] .= '</div>'; // Store these buttons so that we don't have to generate them for each set $_GLOBALS['sw']['buttons'][$array['postID']]['yummly'] = $array['resource']['yummly']; } } return $array; }
function widget($args, $instance) { extract($args); global $comments, $comment; //Widget title, entered in the widget settings $title = apply_filters('widget_title', $instance['title']); /* Custom Options */ // Our options from the widget settings. $number = $instance['number']; // Before widget - as defined in your specific theme. //echo $before_widget; /* Display The Widget */ $output = ''; $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments', 'thstlang') : $instance['title'], $instance, $this->id_base); if (empty($instance['number']) || !($number = absint($instance['number']))) { $number = 5; } $category_name = empty($instance['category_name']) ? '' : $instance['category_name']; $comments = get_comments(apply_filters('widget_comments_args', array('number' => $number, 'status' => 'approve', 'post_status' => 'publish'))); $output .= $before_widget; if ($title) { $output .= $before_title . $title . $after_title; } $output .= '<ul id="thst-recentcomments">'; if ($comments) { foreach ((array) $comments as $comment) { $comm_post_id = $comment->comment_post_ID; if ($category_name) { if (!in_category("{$category_name}", $comm_post_id)) { continue; } } $string = _x('%1$s %2$s - %3$s %4$s', 'recent comments 1 = gravatar, 2 = comment_author_link, 3 = comment_link, 4 = comment_date ', 'thstlang'); $visible = sprintf($string, get_avatar($comment, 48), '<div class="text">' . get_comment_author_link(), '<a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . get_the_title($comment->comment_post_ID) . '</a>', '<p class="date">' . get_comment_date(get_option('date_format')) . '</p></div>'); $output .= '<li class="recentcomments">' . $visible . '</li>'; } } $output .= '</ul>'; $output .= $after_widget; echo $output; /* After widget - as defined in your specific theme. */ //echo $after_widget; }
function isTumblrizeablePost($post_ID = NULL) { if (!isset($_POST['tumblrize_do-tumblrize']) && $_GET['action'] === 'delete') { // this is deletion operation and should be tumblrizeable // only if Tumblrize is turned on globally return get_option('tumblrize_shutoff') === '' ? true : false; } else { if ($post_ID !== NULL && in_category(get_option('tumblrize_exclude_cats'), $post_ID)) { // Don't crosspost items placed into these specific categories. return false; } else { if ($post_ID !== NULL && get_post_meta($post_ID, 'tumblrize_post-future', true)) { // This is a scheduled post that wants to be crossposted. return true; } } } return $_POST['tumblrize_do-tumblrize'] ? true : false; }
function prefix_insert_post_ads($content) { $ad_code = '<hr><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- Post Content --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-0774166343894426" data-ad-slot="2406220245" data-ad-format="auto"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script><hr>'; if (is_single() && !is_admin()) { if (!in_category('work')) { return prefix_insert_after_paragraph($ad_code, 3, $content); } } return $content; }
/** * Validates the provided shortcode filters (if any). * * @since 5.3.3 * @access public * @param array $atts Shortcode attributes * @return bool True on successful validation, false otherwise */ public static function validateFilters($atts = array()) { // Bail out early and pass the validation // if there aren't filters provided if (empty($atts['filters'])) { return true; } // Gather data needed for filters $pages = explode(',', $atts['filters']); $currSlug = basename(get_permalink()); $currPageID = (string) get_the_ID(); foreach ($pages as $page) { if ($page == 'homepage' && is_front_page() || $currPageID == $page || $currSlug == $page || in_category($page)) { return true; } } // No filters matched, // return false return false; }
/** * wcct_prepare_post extends WP-API data object * @param json $data data object for output * @param object $post post object * @param object $request type of request * @return json $data data object for output * Source https://1fix.io/blog/2015/06/26/adding-fields-wp-rest-api/ */ function wcct_prepare_post($data, $post, $request) { $_data = $data->data; // Get Post Thumbnail and add to the data object $thumbnail_id = get_post_thumbnail_id($post->ID); $thumbnail = wp_get_attachment_image_src($thumbnail_id, 'full'); $_data['featured_image_thumbnail_url'] = $thumbnail[0]; // Add Specific Categories to the data object if (in_category('intro')) { $_data['cat_name'] = 'Intro'; } if (in_category('title')) { $_data['cat_name'] = 'Title'; } if (in_category('vertical')) { $_data['cat_name'] = 'Vertical'; } // Add Specific Custom Post Meta to the data object $_data['cf_author'] = get_post_meta($post->ID, 'author', true); $_data['cf_footer'] = get_post_meta($post->ID, 'footer', true); $data->data = $_data; return $data; }