function simplr_post_class($print = true) { global $post, $simplr_post_alt; $c = array('hentry', "p{$simplr_post_alt}", $post->post_type, $post->post_status); $c[] = 'author-' . get_the_author_login(); if (is_attachment()) { $c[] = 'attachment'; } foreach ((array) get_the_category() as $cat) { $c[] = 'category-' . $cat->category_nicename; } simplr_date_classes(mysql2date('U', $post->post_date), $c); if (++$simplr_post_alt % 2) { $c[] = 'alt'; } $c = join(' ', apply_filters('post_class', $c)); return $print ? print $c : $c; }
function DisplayVotes($postID, $type = '') { global $user_ID, $guest_votes, $vote_text, $use_votetext, $allow_sinks, $voteiu_skin; $postID = wp_kses($postID, array()); // Sanitize, just in case $voteiu_skin = get_option('voteiu_skin'); $votes = GetVotes($postID); $barvotes = GetBarVotes($postID); switch ($type) { case '': // In the event no theme selected, use the current theme if ($voteiu_skin == '') { return DisplayVotes($postID, 'bar'); } else { if (!LoadSkin($voteiu_skin)) { return DisplayVotes($postID, 'bar'); } } break; // The following themes below are pre-defined themes in the event there are no other themes found // The following themes below are pre-defined themes in the event there are no other themes found case 'bar': ?> <span class="barcontainer"><span class="barfill" id="votecount<?php echo $postID; ?> " style="width:<?php echo round($barvotes[0] * 2.5); ?> %;"> </span></span><?php if ($user_ID != '') { if (!($user_login == get_the_author_login() && !get_option('voteiu_allowownvote'))) { ?> <span><?php if (!UserVoted($postID, $user_ID)) { ?> <span class="bartext" id="voteid<?php the_ID(); ?> "> <a href="javascript:vote('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:sink('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_sinktext'); ?> </a><?php } ?> </span><?php } else { if (get_option('voteiu_aftervotetext') != '') { ?> <span class="bartext" id="voteid<?php the_ID(); ?> "><?php echo get_option('voteiu_aftervotetext'); ?> </span><?php } } ?> </span><?php } } else { if (get_option('voteiu_allowguests') == 'true') { ?> <span><?php if (!GuestVoted($postID, md5($_SERVER['REMOTE_ADDR']))) { ?> <span class="bartext" id="voteid<?php the_ID(); ?> "> <a href="javascript:vote('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:sink('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_sinktext'); ?> </a><?php } ?> </span><?php } ?> </span><?php } } break; case 'ticker': ?> <span class="tickercontainer" id="votes<?php the_ID(); ?> "><?php echo $votes; ?> </span><?php if ($user_ID != '') { ?> <span id="voteid<?php the_ID(); ?> "><?php if (!UserVoted($postID, $user_ID)) { ?> <span class="tickertext"><?php if ($use_votetext == 'true') { ?> <a class="votelink" href="javascript:vote_ticker(<?php echo $postID; ?> ,<?php echo $postID; ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo $vote_text; ?> </a><?php } else { ?> <span class="imagecontainer"><?php if ($allow_sinks == 'true') { ?> <a href="javascript:sink_ticker(<?php echo $postID; ?> ,<?php echo $postID; ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"> <img class="votedown" src="<?php echo VoteItUp_ExtPath(); ?> /votedown.png" alt="Vote down" border="0" /> </a><?php } ?> <a href="javascript:vote_ticker(<?php echo $postID; ?> ,<?php echo $postID; ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"> <img class="voteup" src="<?php echo VoteItUp_ExtPath(); ?> /voteup.png" alt="Vote up" border="0" /> </a> </span><?php } ?> </span><?php } ?> </span><?php } else { if ($guest_votes == 'true') { ?> <span id="voteid<?php the_ID(); ?> "><?php if (!GuestVoted($postID, md5($_SERVER['REMOTE_ADDR']))) { ?> <span class="tickertext"><?php if ($use_votetext == 'true') { ?> <a class="votelink" href="javascript:vote_ticker(<?php echo $postID; ?> ,<?php echo $postID; ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo $vote_text; ?> </a></span><?php } else { ?> <span class="imagecontainer"><?php if ($allow_sinks == 'true') { ?> <a href="javascript:sink_ticker(<?php echo $postID; ?> ,<?php echo $postID; ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"> <img class="votedown" src="<?php echo VoteItUp_ExtPath(); ?> /votedown.png" alt="Vote down" border="0" /> </a><?php } ?> <a href="javascript:vote_ticker(<?php echo $postID; ?> ,<?php echo $postID; ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"> <img class="voteup" src="<?php echo VoteItUp_ExtPath(); ?> /voteup.png" alt="Vote up" border="0" /> </a> </span><?php } ?> </span><?php } ?> </span><?php } } break; } }
function sandbox_post_class($print = true) { global $post, $sandbox_post_alt; $c = array("p{$sandbox_post_alt}", $post->post_status); $c[] = 'author-' . get_the_author_login(); sandbox_date_classes(mysql2date('U', $post->post_date), $c); if (++$sandbox_post_alt % 2) { $c[] = 'alt'; } $c = join(' ', get_post_class($c, $post->ID)); return $print ? print $c : $c; }
function LoadVote() { global $user_ID, $user_login; $postID = get_the_ID(); $votes = GetVotes($postID, true); if (function_exists('VoteItUp_options')) { ?> <span class="vote-it-up"> <span class="tickercontainer" id="votecount<?php the_ID(); ?> "><?php echo $votes == false ? "Vote" : $votes; ?> </span> <?php if ($user_ID != '') { if (!($user_login == get_the_author_login() && !get_option('voteiu_allowownvote'))) { ?> <span> <?php if (!UserVoted($postID, $user_ID)) { ?> <span class="tickertext"> <span class="votelink" id="voteid<?php the_ID(); ?> "><a href="javascript:vote('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');" class="voteuplink"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:sink('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');" class="votedownlink"><?php echo get_option('voteiu_sinktext'); ?> </a></span> <?php } ?> </span> <?php } else { ?> <?php if (get_option('voteiu_aftervotetext') != '') { ?> <span class="tickertext" id="voteid<?php the_ID(); ?> "><span class="votelink"><?php echo get_option('voteiu_aftervotetext'); ?> </span></span><?php } ?> <?php } ?> </span> <?php } else { ?> <?php if (get_option('voteiu_aftervotetext') != '') { ?> <span class="tickertext" id="voteid<?php the_ID(); ?> "><span class="votelink"><?php echo get_option('voteiu_aftervotetext'); ?> </span></span><?php } } } else { if (get_option('voteiu_allowguests') == 'true') { ?> <span id="voteid<?php the_ID(); ?> "> <?php if (!GuestVoted($postID, md5($_SERVER['REMOTE_ADDR']))) { ?> <span class="tickertext"> <span class="votelink" id="voteid<?php the_ID(); ?> "><a href="javascript:vote('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');" class="voteuplink"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:sink('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');" class="votedownlink"><?php echo get_option('voteiu_sinktext'); ?> </a></span><?php } ?> </span> <?php } else { ?> <?php if (get_option('voteiu_aftervotetext') != '') { ?> <span class="tickertext" id="voteid<?php the_ID(); ?> "><span class="votelink"><?php echo get_option('voteiu_aftervotetext'); ?> </span></span><?php } ?> <?php } } else { /*Guest voting disabled*/ ?> <span class="tickertext"> <span class="votelink" id="voteid<?php the_ID(); ?> "><a href="javascript:regboxopen();"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:regboxopen();"><?php echo get_option('voteiu_sinktext'); ?> </a></span><?php } ?> </span> </span> <?php } ?> <?php } } }
comments_number(__('Leave a Response', 'gluedideas_subtle'), __('One Response', 'gluedideas_subtle'), '% ' . __('Responses', 'gluedideas_subtle')); ?> </a></dd> </dl> <dl class="metadata even"> <dt><?php _e("Feeds and Links", 'gluedideas_subtle'); ?> </dt> <dd class="icon feed"><?php comments_rss_link(__('Comment Feed', 'gluedideas_subtle')); ?> </dd> <dd class="icon entry"><a href="<?php get_author_link(true, get_the_author_ID(), get_the_author_login()); ?> "><?php _e("From This Author", 'gluedideas_subtle'); ?> </a></dd> <dd class="icon delicious"><a href="http://del.icio.us/post?url=<?php the_permalink(); ?> &title=<?php echo urlencode(get_the_title()); ?> ">Del.icio.us</a></dd> <dd class="icon digg"><a href="http://www.digg.com/submit" target="_new">Digg</a></dd> <dd class="icon technorati"><a href="http://technorati.com/cosmos/search.html?url=<?php urlencode(the_permalink());
function LoadVote() { global $user_ID, $user_login; $postID = get_the_ID(); $votes = GetVotes($postID); $barvotes = GetBarVotes($postID); if (function_exists('VoteItUp_options')) { ?> <span class="barcontainer"><span class="barfill" id="votecount<?php echo $postID; ?> " style="width:<?php echo round($barvotes[0] * 2.5); ?> %;"> </span></span> <?php if ($user_ID != '') { if (!($user_login == get_the_author_login() && !get_option('voteiu_allowownvote'))) { ?> <?php if (!UserVoted($postID, $user_ID)) { ?> <span class="bartext" id="voteid<?php the_ID(); ?> "> <a href="javascript:vote('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:sink('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_sinktext'); ?> </a><?php } ?> </span> <?php } else { ?> <?php if (get_option('voteiu_aftervotetext') != '') { ?> <span class="bartext" id="voteid<?php the_ID(); ?> "><?php echo get_option('voteiu_aftervotetext'); ?> </span><?php } ?> <?php } } else { ?> <?php if (get_option('voteiu_aftervotetext') != '') { ?> <span class="bartext" id="voteid<?php the_ID(); ?> "><?php echo get_option('voteiu_aftervotetext'); ?> </span><?php } } } else { if (get_option('voteiu_allowguests') == 'true') { ?> <?php if (!GuestVoted($postID, md5($_SERVER['REMOTE_ADDR']))) { ?> <span class="bartext" id="voteid<?php the_ID(); ?> "> <a href="javascript:vote('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:sink('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_sinktext'); ?> </a><?php } ?> </span> <?php } else { ?> <?php if (get_option('voteiu_aftervotetext') != '') { ?> <span class="bartext" id="voteid<?php the_ID(); ?> "><?php echo get_option('voteiu_aftervotetext'); ?> </span><?php } ?> <?php } ?> <?php } else { /*Guest voting disabled*/ ?> <span class="bartext" id="voteid<?php the_ID(); ?> "> <a href="javascript:regboxopen();"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:regboxopen();"><?php echo get_option('voteiu_sinktext'); ?> </a><?php } ?> </span> <?php } } } }
function sandbox_body_class($print = true) { global $wp_query, $current_user; // It's surely a WordPress blog, right? $c = array('wordpress'); // Applies the time- and date-based classes (below) to BODY element sandbox_date_classes(time(), $c); // Generic semantic classes for what type of content is displayed is_home() ? $c[] = 'home' : null; is_archive() ? $c[] = 'archive' : null; is_date() ? $c[] = 'date' : null; is_search() ? $c[] = 'search' : null; is_paged() ? $c[] = 'paged' : null; is_attachment() ? $c[] = 'attachment' : null; is_404() ? $c[] = 'four04' : null; // CSS does not allow a digit as first character // Special classes for BODY element when a single post if (is_single()) { $postID = $wp_query->post->ID; the_post(); // Adds 'single' class and class with the post ID $c[] = 'single postid-' . $postID; // Adds classes for the month, day, and hour when the post was published if (isset($wp_query->post->post_date)) { sandbox_date_classes(mysql2date('U', $wp_query->post->post_date), $c, 's-'); } // Adds category classes for each category on single posts if ($cats = get_the_category()) { foreach ($cats as $cat) { $c[] = 's-category-' . $cat->slug; } } // Adds tag classes for each tags on single posts if ($tags = get_the_tags()) { foreach ($tags as $tag) { $c[] = 's-tag-' . $tag->slug; } } // Adds MIME-specific classes for attachments if (is_attachment()) { $the_mime = get_post_mime_type(); $boring_stuff = array("application/", "image/", "text/", "audio/", "video/", "music/"); $c[] = 'attachment-' . str_replace($boring_stuff, "", "{$the_mime}"); } // Adds author class for the post author $c[] = 's-author-' . sanitize_title_with_dashes(strtolower(get_the_author_login())); rewind_posts(); } else { if (is_author()) { $author = $wp_query->get_queried_object(); $c[] = 'author'; $c[] = 'author-' . $author->user_nicename; } else { if (is_category()) { $cat = $wp_query->get_queried_object(); $c[] = 'category'; $c[] = 'category-' . $cat->slug; } else { if (is_tag()) { $tags = $wp_query->get_queried_object(); $c[] = 'tag'; $c[] = 'tag-' . $tags->slug; // Does not work; however I try to return the tag I get a false. Grrr. } else { if (is_page()) { $pageID = $wp_query->post->ID; the_post(); $c[] = 'page pageid-' . $pageID; $c[] = 'page-author-' . sanitize_title_with_dashes(strtolower(get_the_author('login'))); rewind_posts(); } } } } } // For when a visitor is logged in while browsing if ($current_user->ID) { $c[] = 'loggedin'; } // Paged classes; for 'page X' classes of index, single, etc. if ((($page = $wp_query->get("paged")) || ($page = $wp_query->get("page"))) && $page > 1) { $c[] = 'paged-' . $page . ''; if (is_single()) { $c[] = 'single-paged-' . $page . ''; } else { if (is_page()) { $c[] = 'page-paged-' . $page . ''; } else { if (is_category()) { $c[] = 'category-paged-' . $page . ''; } else { if (is_tag()) { $c[] = 'tag-paged-' . $page . ''; } else { if (is_date()) { $c[] = 'date-paged-' . $page . ''; } else { if (is_author()) { $c[] = 'author-paged-' . $page . ''; } else { if (is_search()) { $c[] = 'search-paged-' . $page . ''; } } } } } } } } // Separates classes with a single space, collates classes for BODY $c = join(' ', apply_filters('body_class', $c)); // And tada! return $print ? print $c : $c; }
function cfct_choose_content_template_author($type = 'content', $files = null) { $files = cfct_author_templates($type, $files); if (count($files)) { $author = get_the_author_login(); $file = 'author-' . $author . '.php'; if (in_array($file, $files)) { $keys = array($author); return cfct_filename($type, 'author', $keys); } } return false; }
function thematic_body_class($print = true) { global $wp_query, $current_user; // It's surely a WordPress blog, right? $c = array('wordpress'); // Applies the time- and date-based classes (below) to BODY element thematic_date_classes(time(), $c); // Generic semantic classes for what type of content is displayed is_front_page() ? $c[] = 'home' : null; // For the front page, if set is_home() ? $c[] = 'blog' : null; // For the blog posts page, if set is_archive() ? $c[] = 'archive' : null; is_date() ? $c[] = 'date' : null; is_search() ? $c[] = 'search' : null; is_paged() ? $c[] = 'paged' : null; is_attachment() ? $c[] = 'attachment' : null; is_404() ? $c[] = 'four04' : null; // CSS does not allow a digit as first character // Special classes for BODY element when a singular post if (is_singular()) { $c[] = 'singular'; } else { $c[] = 'not-singular'; } // Special classes for BODY element when a single post if (is_single()) { $postID = $wp_query->post->ID; the_post(); // Adds post slug class, prefixed by 'slug-' $c[] = 'slug-' . $wp_query->post->post_name; // Adds 'single' class and class with the post ID $c[] = 'single postid-' . $postID; // Adds classes for the month, day, and hour when the post was published if (isset($wp_query->post->post_date)) { thematic_date_classes(mysql2date('U', $wp_query->post->post_date), $c, 's-'); } // Adds category classes for each category on single posts if ($cats = get_the_category()) { foreach ($cats as $cat) { $c[] = 's-category-' . $cat->slug; } } // Adds tag classes for each tags on single posts if ($tags = get_the_tags()) { foreach ($tags as $tag) { $c[] = 's-tag-' . $tag->slug; } } // Adds MIME-specific classes for attachments if (is_attachment()) { $mime_type = get_post_mime_type(); $mime_prefix = array('application/', 'image/', 'text/', 'audio/', 'video/', 'music/'); $c[] = 'attachmentid-' . $postID . ' attachment-' . str_replace($mime_prefix, "", "{$mime_type}"); } // Adds author class for the post author $c[] = 's-author-' . sanitize_title_with_dashes(strtolower(get_the_author_login())); rewind_posts(); // For posts with excerpts if (has_excerpt()) { $c[] = 's-has-excerpt'; } // For posts with comments open or closed if (comments_open()) { $c[] = 's-comments-open'; } else { $c[] = 's-comments-closed'; } // For posts with pings open or closed if (pings_open()) { $c[] = 's-pings-open'; } else { $c[] = 's-pings-closed'; } // For password-protected posts if ($post->post_password) { $c[] = 's-protected'; } // For sticky posts if (is_sticky()) { $c[] = 's-sticky'; } } elseif (is_author()) { $author = $wp_query->get_queried_object(); $c[] = 'author'; $c[] = 'author-' . $author->user_nicename; } elseif (is_category()) { $cat = $wp_query->get_queried_object(); $c[] = 'category'; $c[] = 'category-' . $cat->slug; } elseif (is_tag()) { $tags = $wp_query->get_queried_object(); $c[] = 'tag'; $c[] = 'tag-' . $tags->slug; } elseif (is_page()) { $pageID = $wp_query->post->ID; $page_children = wp_list_pages("child_of={$pageID}&echo=0"); the_post(); // Adds post slug class, prefixed by 'slug-' $c[] = 'slug-' . $wp_query->post->post_name; $c[] = 'page pageid-' . $pageID; $c[] = 'page-author-' . sanitize_title_with_dashes(strtolower(get_the_author('login'))); // Checks to see if the page has children and/or is a child page; props to Adam if ($page_children) { $c[] = 'page-parent'; } if ($wp_query->post->post_parent) { $c[] = 'page-child parent-pageid-' . $wp_query->post->post_parent; } // For pages with excerpts if (has_excerpt()) { $c[] = 'page-has-excerpt'; } // For pages with comments open or closed if (comments_open()) { $c[] = 'page-comments-open'; } else { $c[] = 'page-comments-closed'; } // For pages with pings open or closed if (pings_open()) { $c[] = 'page-pings-open'; } else { $c[] = 'page-pings-closed'; } // For password-protected pages if ($post->post_password) { $c[] = 'page-protected'; } // Checks to see if the page is using a template if (is_page_template() & !is_page_template('default')) { $c[] = 'page-template page-template-' . str_replace('.php', '-php', get_post_meta($pageID, '_wp_page_template', true)); } rewind_posts(); } elseif (is_search()) { the_post(); if (have_posts()) { $c[] = 'search-results'; } else { $c[] = 'search-no-results'; } rewind_posts(); } // For when a visitor is logged in while browsing if ($current_user->ID) { $c[] = 'loggedin'; } // Paged classes; for 'page X' classes of index, single, etc. if ((($page = $wp_query->get('paged')) || ($page = $wp_query->get('page'))) && $page > 1) { // Thanks to Prentiss Riddle, twitter.com/pzriddle, for the security fix below. $page = intval($page); // Ensures that an integer (not some dangerous script) is passed for the variable $c[] = 'paged-' . $page; if (is_single()) { $c[] = 'single-paged-' . $page; } elseif (is_page()) { $c[] = 'page-paged-' . $page; } elseif (is_category()) { $c[] = 'category-paged-' . $page; } elseif (is_tag()) { $c[] = 'tag-paged-' . $page; } elseif (is_date()) { $c[] = 'date-paged-' . $page; } elseif (is_author()) { $c[] = 'author-paged-' . $page; } elseif (is_search()) { $c[] = 'search-paged-' . $page; } } // A little Browser detection shall we? $browser = $_SERVER['HTTP_USER_AGENT']; // Mac, PC ...or Linux if (preg_match("/Mac/", $browser)) { $c[] = 'mac'; } elseif (preg_match("/Windows/", $browser)) { $c[] = 'windows'; } elseif (preg_match("/Linux/", $browser)) { $c[] = 'linux'; } else { $c[] = 'unknown-os'; } // Checks browsers in this order: Chrome, Safari, Opera, MSIE, FF if (preg_match("/Chrome/", $browser)) { $c[] = 'chrome'; preg_match("/Chrome\\/(\\d.\\d)/si", $browser, $matches); $ch_version = 'ch' . str_replace('.', '-', $matches[1]); $c[] = $ch_version; } elseif (preg_match("/Safari/", $browser)) { $c[] = 'safari'; preg_match("/Version\\/(\\d.\\d)/si", $browser, $matches); $sf_version = 'sf' . str_replace('.', '-', $matches[1]); $c[] = $sf_version; } elseif (preg_match("/Opera/", $browser)) { $c[] = 'opera'; preg_match("/Opera\\/(\\d.\\d)/si", $browser, $matches); $op_version = 'op' . str_replace('.', '-', $matches[1]); $c[] = $op_version; } elseif (preg_match("/MSIE/", $browser)) { $c[] = 'msie'; if (preg_match("/MSIE 6.0/", $browser)) { $c[] = 'ie6'; } elseif (preg_match("/MSIE 7.0/", $browser)) { $c[] = 'ie7'; } elseif (preg_match("/MSIE 8.0/", $browser)) { $c[] = 'ie8'; } } elseif (preg_match("/Firefox/", $browser) && preg_match("/Gecko/", $browser)) { $c[] = 'firefox'; preg_match("/Firefox\\/(\\d)/si", $browser, $matches); $ff_version = 'ff' . str_replace('.', '-', $matches[1]); $c[] = $ff_version; } else { $c[] = 'unknown-browser'; } // Separates classes with a single space, collates classes for BODY $c = join(' ', apply_filters('body_class', $c)); // Available filter: body_class // And tada! return $print ? print $c : $c; }
function cfct_choose_single_template_author($dir, $files, $filter) { $author_files = cfct_author_templates('', $files); if (count($author_files)) { $author = get_the_author_login(); $file = cfct_filename_filter('author-' . $author . '.php', $filter); if (in_array($file, $author_files)) { return $file; } } return false; }
function LoadVote() { global $user_ID, $user_login; $postID = get_the_ID(); $votes = GetVotes($postID); if (function_exists('VoteItUp_options')) { if ($user_ID != '') { if (!($user_login == get_the_author_login() && !get_option('voteiu_allowownvote'))) { /* Post author can vote own post */ if (!UserVoted($postID, $user_ID)) { /* User has not voted */ ?> <div class="post_postvote"><div class="post_votewidget" id="votewidget<?php the_ID(); ?> "> <div class="post_votecount" id="votecount<?php the_ID(); ?> "><?php echo $votes; ?> </div> <div class="post_votebuttoncontainer"><span class="post_votebutton" id="voteid<?php the_ID(); ?> "><a href="javascript:vote('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:sink('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_sinktext'); ?> </a><?php } ?> </span></div> </div></div> <?php } else { /* User has voted */ if (get_option('voteiu_aftervotetext') != '') { /* After-vote text was set */ ?> <div class="post_postvote"><div class="post_votewidget" id="votewidget<?php the_ID(); ?> "> <div class="post_votecount" id="votecount<?php the_ID(); ?> "><?php echo $votes; ?> </div> <div id="voteid<?php the_ID(); ?> " class="post_votebuttoncontainer"><span class="post_votebutton"><?php echo get_option('voteiu_aftervotetext'); ?> </span></div> </div></div> <?php } else { /* After-vote text not set */ ?> <div class="post_postvote"><div class="post_votewidget_closed" id="votewidget<?php the_ID(); ?> "> <div class="post_votecount" id="votecount<?php the_ID(); ?> "><?php echo $votes; ?> </div> </div></div> <?php } } } else { /* Post author cannot vote own post */ if (get_option('voteiu_aftervotetext') != '') { /* After-vote text was set */ ?> <div class="post_postvote"><div class="post_votewidget" id="votewidget<?php the_ID(); ?> "> <div class="post_votecount" id="votecount<?php the_ID(); ?> "><?php echo $votes; ?> </div> <div class="post_votebuttoncontainer"><span class="post_votebutton" id="voteid<?php the_ID(); ?> "><?php echo get_option('voteiu_aftervotetext'); ?> </span></div> </div></div> <?php } else { /* After-vote text not set */ ?> <div class="post_postvote"><div class="post_votewidget_closed" id="votewidget<?php the_ID(); ?> "> <div class="post_votecount" id="votecount<?php the_ID(); ?> "><?php echo $votes; ?> </div> </div></div> <?php } } } else { /* Guest is attempting to vote */ if (get_option('voteiu_allowguests') == 'true') { /* Guest voting allowed */ if (!GuestVoted($postID, md5($_SERVER['REMOTE_ADDR']))) { /* Guest has not voted */ ?> <div class="post_postvote"><div class="post_votewidget" id="votewidget<?php the_ID(); ?> "> <div class="post_votecount" id="votecount<?php the_ID(); ?> "><?php echo $votes; ?> </div> <div class="post_votebuttoncontainer"> <span class="post_votebutton" id="voteid<?php the_ID(); ?> "><a href="javascript:vote('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:sink('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_sinktext'); ?> </a><?php } ?> </span> </div></div></div> <?php } else { /* Guest has voted */ if (get_option('voteiu_aftervotetext') != '') { /* After vote text was set */ ?> <div class="post_postvote"><div class="post_votewidget" id="votewidget<?php the_ID(); ?> "> <div class="post_votecount" id="votecount<?php the_ID(); ?> "><?php echo $votes; ?> </div> <div class="post_votebuttoncontainer"> <span class="post_votebutton" id="voteid<?php the_ID(); ?> "><?php echo get_option('voteiu_aftervotetext'); ?> </span> </div></div></div> <?php } else { /* After vote text was not set */ ?> <div class="post_postvote"><div class="post_votewidget_closed" id="votewidget<?php the_ID(); ?> "> <div class="post_votecount" id="votecount<?php the_ID(); ?> "><?php echo $votes; ?> </div> </div></div> <?php } } } else { /* Guest voting disabled */ ?> <div class="post_postvote"><div class="post_votewidget" id="votewidget<?php the_ID(); ?> "> <div class="post_votecount" id="votecount<?php the_ID(); ?> "><?php echo $votes; ?> </div> <div class="post_votebuttoncontainer"> <span class="post_votebutton" id="voteid<?php the_ID(); ?> "><a href="javascript:regboxopen();"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:regboxopen();"><?php echo get_option('voteiu_sinktext'); ?> </a><?php } ?> </span> </div></div></div> <?php } } } }
function plaintxtblog_post_class($print = true) { global $post, $plaintxtblog_post_alt; $c = array('hentry', "p{$plaintxtblog_post_alt}", $post->post_type, $post->post_status); $c[] = 'author-' . get_the_author_login(); foreach ((array) get_the_category() as $cat) { $c[] = 'category-' . $cat->category_nicename; } plaintxtblog_date_classes(mysql2date('U', $post->post_date), $c); if (++$plaintxtblog_post_alt % 2) { $c[] = 'alt'; } elseif ($post->post_password) { $c[] = 'protected'; } $c = join(' ', apply_filters('post_class', $c)); return $print ? print $c : $c; }
/** * semantic_body() - Generates semantic classes for <body> element * * @since - 0.2 * @filter semantic_body * @uses semantic_time() */ function semantic_body($classes = array()) { global $wp_query, $current_user; //$classes = get_body_class(); // Starts the semantic markup array $sc = array('wpframework'); // Generic semantic classes for what type of content is displayed is_front_page() ? $classes[] = 'home' : null; // For the front page, if set is_home() ? $classes[] = 'blog' : null; // For the blog posts page, if set is_singular() ? $classes[] = 'singular' : null; is_single() ? $classes[] = 'single' : null; is_archive() ? $classes[] = 'archive' : null; // For archive based templates: archive.php, author.php, category.php, tag.php is_date() ? $classes[] = 'date' : null; is_search() ? $classes[] = 'search' : null; is_paged() ? $classes[] = 'paged' : null; is_attachment() ? $classes[] = 'attachment' : null; is_404() ? $classes[] = 'error404' : null; // Applies the time- and date-based classes (below) to BODY element semantic_date_classes(time(), $classes); // Special classes for BODY element when a single post if (is_single()) { $postID = $wp_query->post->ID; the_post(); // Adds 'single' class and class with the post ID $sc[] = 'single postid-' . $postID; // Adds classes for the month, day, and hour when the post was published if (isset($wp_query->post->post_date)) { semantic_date_classes(mysql2date('U', $wp_query->post->post_date), $classes, 's-'); } // Adds MIME-specific classes for attachments if (is_attachment()) { $mime_type = get_post_mime_type(); $mime_prefix = array('application/', 'image/', 'text/', 'audio/', 'video/', 'music/'); $sc[] = 'attachmentid-' . $postID . ' attachment-' . str_replace($mime_prefix, "", "{$mime_type}"); } // Adds category classes for each category on single posts if ($cats = get_the_category()) { foreach ($cats as $cat) { if ($cat) { $classes[] = 's-category-' . $cat->slug; } else { $classes[] = 's-category-none'; } } } // Adds tag classes for each tags on single posts if ($tags = get_the_tags()) { foreach ($tags as $tag) { if ($tag) { $classes[] = 's-tag-' . $tag->slug; } else { $classes[] = 's-tag-none'; } } } // Adds author class for the post author if (get_the_author_login()) { $s_author = sanitize_title_with_dashes(strtolower(get_the_author_login())); } else { $s_author = 'none'; } $classes[] = 's-author-' . $s_author; rewind_posts(); } elseif (is_author()) { $author = $wp_query->get_queried_object(); $classes[] = 'author'; if ($author) { $classes[] = 'author-' . $author->user_nicename; } else { $classes[] = 'author-none'; } } elseif (is_category()) { $cat = $wp_query->get_queried_object(); $classes[] = 'category'; if ($cat) { $classes[] = 'category-' . $cat->slug; } else { $classes[] = 'category-none'; } } elseif (is_tag()) { $tags = $wp_query->get_queried_object(); $classes[] = 'tag'; if ($tags) { $classes[] = 'tag-' . $tags->slug; } else { $classes[] = 'tag-none'; } } elseif (is_page()) { $pageID = $wp_query->post->ID; $page_children = wp_list_pages("child_of={$pageID}&echo=0"); if (!$pageID) { $pageID = 0; } $page_children = 0; the_post(); $classes[] = 'page pageid-' . $pageID; $classes[] = 'page-author-' . sanitize_title_with_dashes(strtolower(get_the_author('login'))); // Checks to see if the page has children and/or is a child page; props to Adam if ($page_children) { $classes[] = 'page-parent'; } if ($wp_query->post->post_parent) { $classes[] = 'page-child parent-pageid-' . $wp_query->post->post_parent; } if (is_page_template()) { $classes[] = 'page-template page-template-' . str_replace('.php', '-php', get_post_meta($pageID, '_wp_page_template', true)); } rewind_posts(); } elseif (is_page()) { $pageID = $wp_query->post->ID; $page_children = wp_list_pages("child_of={$pageID}&echo=0"); the_post(); $sc[] = 'page pageid-' . $pageID; $sc[] = 'page-author-' . sanitize_title_with_dashes(strtolower(get_the_author('login'))); // Checks to see if the page has children and/or is a child page; props to Adam if ($page_children) { $sc[] = 'page-parent'; } if ($wp_query->post->post_parent) { $sc[] = 'page-child parent-pageid-' . $wp_query->post->post_parent; } if (is_page_template()) { // Hat tip to Ian, themeshaper.com $sc[] = 'page-template page-template-' . str_replace('.php', '-php', get_post_meta($pageID, '_wp_page_template', true)); } rewind_posts(); } elseif (is_search()) { the_post(); if (have_posts()) { $sc[] = 'search-results'; } else { $sc[] = 'search-no-results'; } rewind_posts(); } // For when a visitor is logged in while browsing if ($current_user->ID) { $sc[] = 'loggedin'; } // Paged classes; for 'page X' classes of index, single, etc. if ((($page = $wp_query->get('paged')) || ($page = $wp_query->get('page'))) && $page > 1) { $sc[] = 'paged-' . $page; if (is_single()) { $sc[] = 'single-paged-' . $page; } elseif (is_page()) { $sc[] = 'page-paged-' . $page; } elseif (is_category()) { $sc[] = 'category-paged-' . $page; } elseif (is_tag()) { $sc[] = 'tag-paged-' . $page; } elseif (is_date()) { $sc[] = 'date-paged-' . $page; } elseif (is_author()) { $sc[] = 'author-paged-' . $page; } elseif (is_search()) { $sc[] = 'search-paged-' . $page; } } // A little browser detection shall we? $browser = $_SERVER['HTTP_USER_AGENT']; // Mac, PC ...or Linux? if (preg_match("/Mac/", $browser)) { $classes[] = 'mac'; } elseif (preg_match("/Windows/", $browser)) { $classes[] = 'windows'; } elseif (preg_match("/Linux/", $browser)) { $classes[] = 'linux'; } else { $classes[] = 'unknown-os'; } // Checks browsers in this order: Chrome, Safari, Opera, MSIE, FF // Then, get the browser's version number if (preg_match("/Chrome/", $browser)) { $classes[] = 'chrome'; preg_match("/Chrome\\/(\\d.\\d)/si", $browser, $matches); $ch_version = 'ch' . str_replace('.', '-', $matches[1]); $classes[] = $ch_version; } elseif (preg_match("/Safari/", $browser)) { $classes[] = 'safari'; preg_match("/Version\\/(\\d.\\d)/si", $browser, $matches); $sf_version = 'sf' . str_replace('.', '-', $matches[1]); $classes[] = $sf_version; } elseif (preg_match("/Opera/", $browser)) { $classes[] = 'opera'; preg_match("/Opera\\/(\\d.\\d)/si", $browser, $matches); $op_version = 'op' . str_replace('.', '-', $matches[1]); $classes[] = $op_version; } elseif (preg_match("/MSIE/", $browser)) { $classes[] = 'msie'; if (preg_match("/MSIE 6.0/", $browser)) { $classes[] = 'ie6'; } elseif (preg_match("/MSIE 7.0/", $browser)) { $classes[] = 'ie7'; } elseif (preg_match("/MSIE 8.0/", $browser)) { $classes[] = 'ie8'; } } elseif (preg_match("/Firefox/", $browser) && preg_match("/Gecko/", $browser)) { $classes[] = 'firefox'; preg_match("/Firefox\\/(\\d)/si", $browser, $matches); $ff_version = 'ff' . str_replace('.', '-', $matches[1]); $classes[] = $ff_version; } else { $classes[] = 'unknown-browser'; } $classes = join(' ', apply_filters('semantic_body', $classes)); // Available filter: semantic_body $print = apply_filters('semantic_body_print', false); // Available filter: semantic_body_print // And tada! if (!$print) { echo $classes; } else { return $classes; } }
function sandbox_body_class($print = true) { global $wp_query, $current_user; // It's surely a WordPress blog, right? $c = array('wordpress'); // Applies the time- and date-based classes (below) to BODY element sandbox_date_classes(time(), $c); // Generic semantic classes for what type of content is displayed is_front_page() ? $c[] = 'home' : null; // For the front page, if set is_home() ? $c[] = 'blog' : null; // For the blog posts page, if set is_archive() ? $c[] = 'archive' : null; is_date() ? $c[] = 'date' : null; is_search() ? $c[] = 'search' : null; is_paged() ? $c[] = 'paged' : null; is_attachment() ? $c[] = 'attachment' : null; is_404() ? $c[] = 'four04' : null; // CSS does not allow a digit as first character // Special classes for BODY element when a single post if (is_single()) { $postID = $wp_query->post->ID; the_post(); // Adds 'single' class and class with the post ID $c[] = 'single postid-' . $postID; // Adds classes for the month, day, and hour when the post was published if (isset($wp_query->post->post_date)) { sandbox_date_classes(mysql2date('U', $wp_query->post->post_date), $c, 's-'); } // Adds category classes for each category on single posts if ($cats = get_the_category()) { foreach ($cats as $cat) { $c[] = 's-category-' . $cat->slug; } } // Adds tag classes for each tags on single posts if ($tags = get_the_tags()) { foreach ($tags as $tag) { $c[] = 's-tag-' . $tag->slug; } } // Adds MIME-specific classes for attachments if (is_attachment()) { $mime_type = get_post_mime_type(); $mime_prefix = array('application/', 'image/', 'text/', 'audio/', 'video/', 'music/'); $c[] = 'attachmentid-' . $postID . ' attachment-' . str_replace($mime_prefix, "", "{$mime_type}"); } // Adds author class for the post author $c[] = 's-author-' . sanitize_title_with_dashes(strtolower(get_the_author_login())); rewind_posts(); } elseif (is_author()) { $author = $wp_query->get_queried_object(); $c[] = 'author'; $c[] = 'author-' . $author->user_nicename; } elseif (is_category()) { $cat = $wp_query->get_queried_object(); $c[] = 'category'; $c[] = 'category-' . $cat->slug; } elseif (is_tag()) { $tags = $wp_query->get_queried_object(); $c[] = 'tag'; $c[] = 'tag-' . $tags->slug; } elseif (is_page()) { $pageID = $wp_query->post->ID; $page_children = wp_list_pages("child_of={$pageID}&echo=0"); the_post(); $c[] = 'page pageid-' . $pageID; $c[] = 'page-author-' . sanitize_title_with_dashes(strtolower(get_the_author('login'))); // Checks to see if the page has children and/or is a child page; props to Adam if ($page_children) { $c[] = 'page-parent'; } if ($wp_query->post->post_parent) { $c[] = 'page-child parent-pageid-' . $wp_query->post->post_parent; } if (is_page_template()) { // Hat tip to Ian, themeshaper.com $c[] = 'page-template page-template-' . str_replace('.php', '-php', get_post_meta($pageID, '_wp_page_template', true)); } rewind_posts(); } elseif (is_search()) { the_post(); if (have_posts()) { $c[] = 'search-results'; } else { $c[] = 'search-no-results'; } rewind_posts(); } // Paged classes; for 'page X' classes of index, single, etc. if ((($page = $wp_query->get('paged')) || ($page = $wp_query->get('page'))) && $page > 1) { $c[] = 'paged-' . $page; if (is_single()) { $c[] = 'single-paged-' . $page; } elseif (is_page()) { $c[] = 'page-paged-' . $page; } elseif (is_category()) { $c[] = 'category-paged-' . $page; } elseif (is_tag()) { $c[] = 'tag-paged-' . $page; } elseif (is_date()) { $c[] = 'date-paged-' . $page; } elseif (is_author()) { $c[] = 'author-paged-' . $page; } elseif (is_search()) { $c[] = 'search-paged-' . $page; } } $thePostID = $wp_query->post->ID; $hero_type = get_post_meta($thePostID, 'hero_type_value', true); $layout = get_post_meta($thePostID, 'page_layout_value', true); if ($layout) { $c[] = 'layout layout_' . $layout; } if ($hero_type) { $c[] = 'hero hero_' . $hero_type; } // start http://www.nathanrice.net/blog/browser-detection-and-the-body_class-function/ global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone; if ($is_lynx) { $c[] = 'lynx'; } elseif ($is_gecko) { $c[] = 'gecko'; } elseif ($is_opera) { $c[] = 'opera'; } elseif ($is_NS4) { $c[] = 'ns4'; } elseif ($is_safari) { $c[] = 'safari'; } elseif ($is_chrome) { $c[] = 'chrome'; } elseif ($is_IE) { $c[] = 'ie'; } else { $c[] = 'unknown'; } //if($is_iphone) $c[] = 'iphone'; // end http://www.nathanrice.net/blog/browser-detection-and-the-body_class-function/ if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false) { $c[] = 'ie6'; } if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') == false) { $c[] = 'not-ie6'; } if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') == false) { $c[] = 'not-ie'; } $uagent_obj = new uagent_info(); //Detect methods return 1 for true, 0 for false $isIphone = $uagent_obj->DetectIphone(); $isIpod = $uagent_obj->DetectIpod(); $isIpad = $uagent_obj->DetectIpad(); $isAndroid = $uagent_obj->DetectAndroid(); $isTierIphone = $uagent_obj->DetectTierIphone(); if ($isIphone == 1) { $c[] = 'iphone'; } else { if ($isIpod == 1) { $c[] = 'iphone ipod'; } else { if ($isIpad == 1) { $c[] = 'iphone ipad'; } else { if ($isAndroid == 1) { $c[] = 'android'; } } } } if ($isTierIphone == 1) { $c[] = 'tierIphone'; } // For when a visitor is logged in while browsing if ($current_user->ID) { $c[] = 'loggedin'; } if (function_exists('ashford_set_theme_style')) { if ($_GET["color"] != '') { $c[] = 'theme-style-' . $_GET["color"]; } else { $c[] = ashford_set_theme_style(); } } // Separates classes with a single space, collates classes for BODY $c = join(' ', apply_filters('body_class', $c)); // Available filter: body_class // And tada! return $print ? print $c : $c; }
function webjournal_post_class( $print = true ) { global $post, $webjournal_post_alt; $c = array('hentry', "p$webjournal_post_alt", $post->post_type, $post->post_status); $c[] = 'author-' . get_the_author_login(); if ( is_attachment() ) $c[] = 'attachment'; foreach ( (array) get_the_category() as $cat ) $c[] = 'category-' . $cat->category_nicename; webjournal_date_classes(mysql2date('U', $post->post_date), $c); if ( ++$webjournal_post_alt % 2 ) $c[] = 'alt'; $c = join(' ', apply_filters('post_class', $c)); return $print ? print($c) : $c; }
function cfct_choose_single_template($files = array(), $filter = '*') { // must be called within the_loop - cfct_choose_general_template_single() approximates a loop for this reason. $exec_order = array('author', 'meta', 'category', 'role', 'tag', 'parent', 'default'); $exec_order = apply_filters('cfct_single_match_order', $exec_order); $filename = false; global $post; foreach ($exec_order as $type) { switch ($type) { case 'author': $author_files = cfct_author_templates('', $files); if (count($author_files)) { $author = get_the_author_login(); $file = cfct_filename_filter('author-' . $author . '.php', $filter); if (in_array($file, $author_files)) { $filename = $file; } } break; case 'meta': $meta_files = cfct_meta_templates('', $files); if (count($meta_files)) { $meta = get_post_custom($post->ID); if (count($meta)) { // check key, value matches first foreach ($meta as $k => $v) { $val = $v[0]; $file = cfct_filename_filter('meta-' . $k . '-' . $val . '.php', $filter); if (in_array($file, $meta_files)) { $filename = $file; break; } } // check key matches only if (!$filename) { foreach ($meta as $k => $v) { $file = cfct_filename_filter('meta-' . $k . '.php', $filter); if (in_array($file, $meta_files)) { $filename = $file; break; } } } } } break; case 'category': $cat_files = cfct_cat_templates($type, $files); if (count($cat_files)) { foreach ($cat_files as $file) { $cat_id = cfct_cat_filename_to_id($file); if (in_category($cat_id)) { $filename = $file; break; } } } break; case 'role': $role_files = cfct_role_templates($type, $files); if (count($role_files)) { $user = new WP_User(get_the_author_ID()); if (count($user->roles)) { foreach ($role_files as $file) { foreach ($user->roles as $role) { if (cfct_role_filename_to_name($file) == $role) { $filename = $file; break; } } } } } break; case 'tag': $tag_files = cfct_tag_templates($type, $files); if (count($tag_files)) { $tags = get_the_tags($post->ID); if (is_array($tags) && count($tags)) { foreach ($tag_files as $file) { foreach ($tags as $tag) { if ($tag->slug == cfct_tag_filename_to_name($file)) { $filename = $file; break; } } } } } break; case 'parent': $parent_files = cfct_parent_templates($type, $files); if (count($parent_files) && $post->post_parent > 0) { $parent = cfct_post_id_to_slug($post->post_parent); $file = cfct_filename_filter('parent-' . $parent . '.php', $filter); if (in_array($file, $parent_files)) { $filename = $file; } } break; case 'default': break; } if ($filename) { break; } } return apply_filters('cfct_choose_single_template', $filename); }
/** * Display the login name of the author of the current post. * * @link http://codex.wordpress.org/Template_Tags/the_author_login * @since 0.71 * @see get_the_author_login() */ function the_author_login() { echo get_the_author_login(); }
function cfct_choose_content_template_author($type = 'content') { $files = cfct_author_templates($type); if (count($files)) { foreach ($files as $file) { if (cfct_author_filename_to_name($file) == get_the_author_login()) { $keys = array(get_the_author_login()); return cfct_filename($type, 'author', $keys); } } } return false; }
/** * Shortcode function for displaying the current post author login * Uses the get_the_author_login() function * @link http://codex.wordpress.org/Template_Tags/the_author_login * * @since 0.1 */ function shortcode_the_author_login() { return get_the_author_login(); }
<?php /* Filename: search.php Date: 06-06-25 Copyright: 2006, Glued Ideas Author: Christopher Frazier (cfrazier@gluedideas.com) Description: Multi-Author Template for WordPress (Subtle) Requires: */ load_theme_textdomain('gluedideas_subtle'); if (isset($_GET['author_name'])) { $objAuthor = get_userdatabylogin(get_the_author_login()); } else { $objAuthor = get_userdata(intval($author)); } $aOptions = get_option('gi_subtle_theme'); get_header(); ?> <!-- Content Start --> <div id="loop_articles"> <?php if (is_author()) { ?> <h2><?php _e('Author Archives for', 'gluedideas_subtle'); ?> <?php echo $objAuthor->display_name;
function sandbox_body_class($print = true) { global $wp_query, $current_user; $c = array('wordpress'); sandbox_date_classes(time(), $c); is_home() ? $c[] = 'home' : null; is_archive() ? $c[] = 'archive' : null; is_date() ? $c[] = 'date' : null; is_search() ? $c[] = 'search' : null; is_paged() ? $c[] = 'paged' : null; is_attachment() ? $c[] = 'attachment' : null; is_404() ? $c[] = 'four04' : null; // CSS does not allow a digit as first character if (is_single()) { the_post(); $c[] = 'single'; if (isset($wp_query->post->post_date)) { sandbox_date_classes(mysql2date('U', $wp_query->post->post_date), $c, 's-'); } foreach ((array) get_the_category() as $cat) { $c[] = 's-category-' . $cat->category_nicename; } $c[] = 's-author-' . get_the_author_login(); rewind_posts(); } else { if (is_author()) { $author = $wp_query->get_queried_object(); $c[] = 'author'; $c[] = 'author-' . $author->user_nicename; } else { if (is_category()) { $cat = $wp_query->get_queried_object(); $c[] = 'category'; $c[] = 'category-' . $cat->category_nicename; } else { if (is_page()) { the_post(); $c[] = 'page'; $c[] = 'page-author-' . get_the_author_login(); rewind_posts(); } } } } if ($current_user->ID) { $c[] = 'loggedin'; } $c = join(' ', apply_filters('body_class', $c)); return $print ? print $c : $c; }
function redo_post_class($post_count = 1, $post_asides = false) { global $post; $c = array("p{$post_count}", $post->post_status); $c[] = 'author-' . get_the_author_login(); redo_date_classes(mysql2date('U', $post->post_date), $c); if ($post_asides) { $c[] = 'redo-asides'; } if ($post_count & 1 == 1) { $c[] = 'alt'; } echo join(' ', get_post_class($c, $post->ID)); }
function sandbox_body_class($print = true) { global $wp_query, $current_user; // It's surely a WordPress blog, right? $c = array('wordpress'); // Applies the time- and date-based classes (below) to BODY element sandbox_date_classes(time(), $c); // Generic semantic classes for what type of content is displayed is_front_page() ? $c[] = 'home' : null; // For the front page, if set is_home() ? $c[] = 'blog' : null; // For the blog posts page, if set is_archive() ? $c[] = 'archive' : null; is_date() ? $c[] = 'date' : null; is_search() ? $c[] = 'search' : null; is_paged() ? $c[] = 'paged' : null; is_attachment() ? $c[] = 'attachment' : null; is_404() ? $c[] = 'four04' : null; // CSS does not allow a digit as first character // Special classes for BODY element when a single post if (is_single()) { $postID = $wp_query->post->ID; the_post(); // Adds 'single' class and class with the post ID $c[] = 'single postid-' . $postID; // Adds classes for the month, day, and hour when the post was published if (isset($wp_query->post->post_date)) { sandbox_date_classes(mysql2date('U', $wp_query->post->post_date), $c, 's-'); } // Adds category classes for each category on single posts if ($cats = get_the_category()) { foreach ($cats as $cat) { $c[] = 's-category-' . $cat->slug; } } // Adds tag classes for each tags on single posts if ($tags = get_the_tags()) { foreach ($tags as $tag) { $c[] = 's-tag-' . $tag->slug; } } // Adds MIME-specific classes for attachments if (is_attachment()) { $mime_type = get_post_mime_type(); $mime_prefix = array('application/', 'image/', 'text/', 'audio/', 'video/', 'music/'); $c[] = 'attachmentid-' . $postID . ' attachment-' . str_replace($mime_prefix, "", "{$mime_type}"); } // Adds author class for the post author $c[] = 's-author-' . sanitize_title_with_dashes(strtolower(get_the_author_login())); rewind_posts(); } elseif (is_author()) { $author = $wp_query->get_queried_object(); $c[] = 'author'; $c[] = 'author-' . $author->user_nicename; } elseif (is_category()) { $cat = $wp_query->get_queried_object(); $c[] = 'category'; $c[] = 'category-' . $cat->slug; } elseif (is_tag()) { $tags = $wp_query->get_queried_object(); $c[] = 'tag'; $c[] = 'tag-' . $tags->slug; } elseif (is_page()) { $pageID = $wp_query->post->ID; $page_children = wp_list_pages("child_of={$pageID}&echo=0"); the_post(); $c[] = 'page pageid-' . $pageID; $c[] = 'page-author-' . sanitize_title_with_dashes(strtolower(get_the_author('login'))); // Checks to see if the page has children and/or is a child page; props to Adam if ($page_children) { $c[] = 'page-parent'; } if ($wp_query->post->post_parent) { $c[] = 'page-child parent-pageid-' . $wp_query->post->post_parent; } if (is_page_template()) { // Hat tip to Ian, themeshaper.com $c[] = 'page-template page-template-' . str_replace('.php', '-php', get_post_meta($pageID, '_wp_page_template', true)); } rewind_posts(); } elseif (is_search()) { the_post(); if (have_posts()) { $c[] = 'search-results'; } else { $c[] = 'search-no-results'; } rewind_posts(); } // For when a visitor is logged in while browsing if ($current_user->ID) { $c[] = 'loggedin'; } // Paged classes; for 'page X' classes of index, single, etc. if ((($page = $wp_query->get('paged')) || ($page = $wp_query->get('page'))) && $page > 1) { // Thanks to Prentiss Riddle, twitter.com/pzriddle, for the security fix below. $page = intval($page); // Ensures that an integer (not some dangerous script) is passed for the variable $c[] = 'paged-' . $page; if (is_single()) { $c[] = 'single-paged-' . $page; } elseif (is_page()) { $c[] = 'page-paged-' . $page; } elseif (is_category()) { $c[] = 'category-paged-' . $page; } elseif (is_tag()) { $c[] = 'tag-paged-' . $page; } elseif (is_date()) { $c[] = 'date-paged-' . $page; } elseif (is_author()) { $c[] = 'author-paged-' . $page; } elseif (is_search()) { $c[] = 'search-paged-' . $page; } } // Separates classes with a single space, collates classes for BODY $c = join(' ', apply_filters('body_class', $c)); // Available filter: body_class // And tada! return $print ? print $c : $c; }
/** */ function saasta_print_admin_notice() { if (get_the_author_login() != 'admin') { return; } // Achtung baby only on saasta.fi, customize later for other subsites if (get_option('saasta_subsite') == 'saasta') { print '<table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-top:0.5em;margin-bottom:0.5em;">'; print '<tr><td style="border:1px solid black;padding:0.5em;background-color:#cc0000;color:#ffffff;font-weight:bold;text-align:center;">ACHTUNG!</td></tr>'; print '</table>'; } }