• Hello and Happy 2011 to you all,

    I switched to a new theme and the WL was working on the previous theme, but not working on the new theme. The widgets are working in the sidebar, but the moment I enter a condition ex: is_home() the widget is gone, and when I remove the WL tag, it shows up again. I have been playing around with different things, but haven’t gotten it to work.

    Your help would greatly be appreciated. I will be sure to send you all that helped a box of dounuts or a 6/pack. Thank you in advance for looking into this and your help!

    Here is my functions.php file.

    <?php
    include(TEMPLATEPATH.’/includes/controlpanel/controlpanel.php’);
    $cpanel = new Panel();

    if ( function_exists(‘register_sidebar’) )
    register_sidebar(array(
    ‘name’ => ‘Ad 300’,
    ‘before_widget’ => ‘<div class=”ad300k”>’,
    ‘after_widget’ => ‘</div> <span class=”kads”>advertising</span>’,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));
    register_sidebar(array(
    ‘name’ => ‘Top Ad 728×90’,
    ‘before_widget’ => ‘<div class=”topad”>’,
    ‘after_widget’ => ‘</div>’,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));
    register_sidebar(array(
    ‘name’ => ‘Sidebar 300px WIDGETS’,
    ‘before_widget’ => ”,
    ‘after_widget’ => ”,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));
    register_sidebar(array(
    ‘name’ => ‘MORE NEWS SIDEBAR’,
    ‘before_widget’ => ”,
    ‘after_widget’ => ”,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));
    register_sidebar(array(
    ‘name’ => ‘FOOTER: FIRST BOX’,
    ‘before_widget’ => ”,
    ‘after_widget’ => ”,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));
    register_sidebar(array(
    ‘name’ => ‘FOOTER: SECOND BOX’,
    ‘before_widget’ => ”,
    ‘after_widget’ => ”,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));
    register_sidebar(array(
    ‘name’ => ‘FOOTER: THIRD BOX’,
    ‘before_widget’ => ”,
    ‘after_widget’ => ”,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));
    register_sidebar(array(
    ‘name’ => ‘FOOTER: FOURTH BOX’,
    ‘before_widget’ => ”,
    ‘after_widget’ => ”,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));

    include_once (TEMPLATEPATH.’/includes/custom_post_video.php’);
    require_once (TEMPLATEPATH.’/includes/c_functions.php’);

    if (function_exists(‘mdv_recent_comments’)) {
    }else{
    function mdv_recent_comments($no_comments = 5, $comment_lenth = 15, $before = ‘

    • ‘, $after = ‘
    • ‘, $show_pass_post = false, $comment_style = 0) {
      global $wpdb;
      $request = “SELECT ID, comment_ID, comment_content, comment_author, comment_author_url, comment_author_email, post_title FROM $wpdb->comments LEFT JOIN $wpdb->posts ON $wpdb->posts.ID=$wpdb->comments.comment_post_ID WHERE post_status IN (‘publish’,’static’) “;
      if(!$show_pass_post) $request .= “AND post_password =” “;
      $request .= “AND comment_approved = ‘1’ ORDER BY comment_ID DESC LIMIT $no_comments”;
      $comments = $wpdb->get_results($request);
      $output = ”;
      if ($comments) {
      foreach ($comments as $comment) {
      $comment_author = stripslashes($comment->comment_author);
      if ($comment_author == “”)
      $comment_author = “anonymous”;
      $comment_content = strip_tags($comment->comment_content);
      $comment_content = stripslashes($comment_content);
      $words=split(” “,$comment_content);
      $comment_excerpt = join(” “,array_slice($words,0,$comment_lenth));
      $permalink = get_permalink($comment->ID).”#comment-“.$comment->comment_ID;
      $emailc = $comment->comment_author_email;

      if ($comment_style == 1) {
      $post_title = stripslashes($comment->post_title);

      $url = $comment->comment_author_url;

      if (empty($url))
      $output .= $before . $comment_author . ‘ on ‘ . $post_title . ‘.’ . $after;
      else
      $output .= $before . ‘‘.$comment_author.’ on ‘ . $post_title . ‘.’ . $after;
      }
      else {
      $output .= $before . ‘<div class=”rcomthumb”>’ . get_avatar($emailc, $size=”48″) . ‘</div><div class=”rcomdesc”><a href=”‘ . $permalink;
      $output .= ‘” title=”View the entire comment by ‘ . $comment_author.'”>’ . $comment_excerpt.'<p class=”rcomtd”>by ‘. $comment_author .'</p></div>’ . $after;
      }
      }
      $output = convert_smilies($output);
      } else {
      $output .= $before . “None found” . $after;
      }
      echo $output;
      }
      }

      function mdv_recent_posts($no_posts = 5, $before = ‘

    • ‘, $after = ‘
    • ‘, $hide_pass_post = true, $skip_posts = 0, $show_excerpts = false) {
      global $wpdb;
      $time_difference = get_settings(‘gmt_offset’);
      $now = gmdate(“Y-m-d H:i:s”,time());
      $request = “SELECT ID, post_title, post_excerpt FROM $wpdb->posts WHERE post_status = ‘publish’ AND post_type = ‘post’ “;
      if($hide_pass_post) $request .= “AND post_password =” “;
      $request .= “AND post_date_gmt < ‘$now’ ORDER BY post_date DESC LIMIT $skip_posts, $no_posts”;
      $posts = $wpdb->get_results($request);
      $output = ”;
      if($posts) {
      foreach ($posts as $post) {
      $post_title = stripslashes($post->post_title);
      $permalink = get_permalink($post->ID);
      $output .= $before . ‘‘ . htmlspecialchars($post_title) . ‘‘;
      if($show_excerpts) {
      $post_excerpt = stripslashes($post->post_excerpt);
      $output.= ” . $post_excerpt;
      }
      $output .= $after;
      }
      } else {
      $output .= $before . “None found” . $after;
      }
      echo $output;
      }

      function my_post_limit($limit) {
      global $paged, $myOffset;
      if (empty($paged)) {
      $paged = 1;
      }
      $postperpage = intval(get_option(‘posts_per_page’));
      $pgstrt = ((intval($paged) -1) * $postperpage) + $myOffset . ‘, ‘;
      $limit = ‘LIMIT ‘.$pgstrt.$postperpage;
      return $limit;
      } //end function my_post_limit

      function breadcrumbs() {

      $theFullUrl = $_SERVER[“REQUEST_URI”];

      $urlArray=explode(“/”,$theFullUrl);

      echo ‘<h3>You Are Here: //</h3> <span>Home</span>’;

      while (list($j,$text) = each($urlArray)) {

      $dir= ”;

      if ($j > 1) {

      $i=1;

      while ($i < $j) {

      $dir .= ‘/’ . $urlArray[$i];

      $text = $urlArray[$i];

      $i++;

      }

      if($j < count($urlArray)-1) echo ‘<span> » ‘ . str_replace(“-“, ” “, $text) . ‘</span>’;

      }

      }

      echo wp_title();
      }

      function most_commented($no_posts = 5, $before = ‘

    • ‘, $after = ‘
    • ‘, $show_pass_post = false) {
      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 =””;
      $request .= ” GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts”;
      $posts = $wpdb->get_results($request);
      $output = ”;
      $position = 0;
      if ($posts) {
      foreach ($posts as $post) {
      $post_title = stripslashes($post->post_title);
      $comment_count = $post->comment_count;
      $permalink = get_permalink($post->ID);
      $themeurl = get_stylesheet_directory_uri();
      $position++;
      $output .= $before . ‘<span>’. $position .'</span>‘ . $post_title . ‘‘ . $after;
      }
      } else {
      $output .= $before . “None found” . $after;
      }
      echo $output;
      }

      // Page Navigation
      function wp_pagenavi($before = ”, $after = ”, $prelabel = ”, $nxtlabel = ”, $pages_to_show = 5, $always_show = false) {

      global $request, $posts_per_page, $wpdb, $paged;
      if(empty($prelabel)) {
      $prelabel = ‘«‘;
      }
      if(empty($nxtlabel)) {
      $nxtlabel = ‘»‘;
      }
      $half_pages_to_show = round($pages_to_show/2);
      if (!is_single()) {
      if(is_tag()) {
      preg_match(‘#FROM\s(.*)\sGROUP BY#siU’, $request, $matches);
      } elseif (!is_category()) {
      preg_match(‘#FROM\s(.*)\sORDER BY#siU’, $request, $matches);
      } else {
      preg_match(‘#FROM\s(.*)\sGROUP BY#siU’, $request, $matches);
      }
      $fromwhere = $matches[1];
      $numposts = $wpdb->get_var(“SELECT COUNT(DISTINCT ID) FROM $fromwhere”);
      $max_page = ceil($numposts /$posts_per_page);
      if(empty($paged)) {
      $paged = 1;
      }
      if($max_page > 1 || $always_show) {
      echo “$before <div class=’Navi’>”;
      if ($paged >= ($pages_to_show-1)) {
      echo ‘« ‘.get_option(‘ptthemes_pagination_first_name’).’‘;
      }
      previous_posts_link($prelabel);
      for($i = $paged – $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) {
      if ($i >= 1 && $i <= $max_page) {
      if($i == $paged) {
      echo “<strong class=’on’>$i”;
      } else {
      echo ‘ ‘.$i.’ ‘;
      }
      }
      }
      next_posts_link($nxtlabel, $max_page);
      if (($paged+$half_pages_to_show) < ($max_page)) {
      echo ‘‘.get_option(‘ptthemes_pagination_last_name’).’ »‘;
      }
      echo “</div> $after”;
      }
      }
      }

      function truncate_post($amount,$echo=true) {
      global $post;

      $truncate = $post->post_content;
      if ( strlen($truncate) <= $amount ) $echo_out = ”; else $echo_out = ‘ …’;
      $truncate = apply_filters(‘the_content’, $truncate);
      $truncate = preg_replace(‘@<script[^>]*?>.*?</script>@si’, ”, $truncate);
      $truncate = preg_replace(‘@<style[^>]*?>.*?</style>@si’, ”, $truncate);
      $truncate = strip_tags($truncate);
      if ($echo_out == ‘…’) $truncate = substr($truncate, 0, strrpos(substr($truncate, 0, $amount), ‘ ‘));
      else $truncate = substr($truncate, 0, $amount);

      if ($echo) echo $truncate,$echo_out;
      else return ($truncate . $echo_out);
      }

      function truncate_title($amount,$echo=true) {
      global $post;

      $truncate = $post->post_title;
      if ( strlen($truncate) <= $amount ) $echo_out = ”; else $echo_out = ‘ …’;
      $truncate = apply_filters(‘the_title’, $truncate);
      $truncate = preg_replace(‘@<script[^>]*?>.*?</script>@si’, ”, $truncate);
      $truncate = preg_replace(‘@<style[^>]*?>.*?</style>@si’, ”, $truncate);
      $truncate = strip_tags($truncate);
      if ($echo_out == ‘…’) $truncate = substr($truncate, 0, strrpos(substr($truncate, 0, $amount), ‘ ‘));
      else $truncate = substr($truncate, 0, $amount);

      if ($echo) echo $truncate,$echo_out;
      else return ($truncate . $echo_out);
      }

      function adoutput($input) {
      $output = str_replace(‘\”‘,'”‘ , $input);
      echo $output;
      }

      function new_excerpt_length($length) {
      return 60;
      }
      add_filter(‘excerpt_length’, ‘new_excerpt_length’);

      add_theme_support( ‘nav-menus’ );

      add_action( ‘init’, ‘register_my_menu’ );

      function register_my_menu() {
      if (function_exists(‘register_nav_menu’ ))
      register_nav_menu( ‘primary-menu’, __( ‘Menu Elements’ ) );
      }

      // TWITTER STUFF

      function rarst_twitter_user( $username, $field, $display = false ) {
      $interval = 3600;
      $cache = get_option(‘rarst_twitter_user’);
      $url = ‘http://api.twitter.com/1/users/show.json?screen_name=&#8217;.urlencode($username);

      if ( false == $cache )
      $cache = array();

      // if first time request add placeholder and force update
      if ( !isset( $cache[$username][$field] ) ) {
      $cache[$username][$field] = NULL;
      $cache[$username][‘lastcheck’] = 0;
      }

      // if outdated
      if( $cache[$username][‘lastcheck’] < (time()-$interval) ) {

      // holds decoded JSON data in memory
      static $memorycache;

      if ( isset($memorycache[$username]) ) {
      $data = $memorycache[$username];
      }
      else {
      $result = wp_remote_retrieve_body(wp_remote_request($url));
      $data = json_decode( $result );
      if ( is_object($data) )
      $memorycache[$username] = $data;
      }

      if ( is_object($data) ) {
      // update all fields, known to be requested
      foreach ($cache[$username] as $key => $value)
      if( isset($data->$key) )
      $cache[$username][$key] = $data->$key;

      $cache[$username][‘lastcheck’] = time();
      }
      else {
      $cache[$username][‘lastcheck’] = time()+60;
      }

      update_option( ‘rarst_twitter_user’, $cache );
      }

      if ( false != $display )
      echo $cache[$username][$field];
      return $cache[$username][$field];
      }

      // TWITTER STUFF END

      function commentstemplate($comment, $args, $depth) {
      $GLOBALS[‘comment’] = $comment; ?>
      <li <?php comment_class(); ?> id=”li-comment-<?php comment_ID() ?>”>
      <div id=”comment-<?php comment_ID(); ?>”>
      <div class=”allc”>
      <span class=”comavatar”><?php echo get_avatar($comment,$size=’40’,$default='<path_to_url>’ ); ?></span>

      <div class=”comdetails”>
      <?php printf(__(‘<span class=”says”>%s</span>’), get_comment_author_link()) ?>
      <span><?php echo get_comment_date(‘d.m.Y’); ?></span>
      <span><?php echo get_comment_time(); ?></span>
      <span class=”reply”><?php comment_reply_link(array_merge( $args, array(‘depth’ => $depth, ‘max_depth’ => $args[‘max_depth’]))) ?></span>
      </div>

      </div>
      <?php if ($comment->comment_approved == ‘0’) : ?>
      <?php _e(‘<small class=”moder”>Your comment is awaiting moderation.</small>’) ?>
      <?php endif; ?>

      <div class=”comtext”>
      <?php comment_text() ?>
      </div>
      </div>
      <?php
      }
      ?>

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Ray

    (@bluechip)

    And here is the sidebar.php file.

    <div id=”sidebar”>

    <!– WIDGETS –>
    <?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(‘Ad 300’) ) : ?>
    <?php endif;

    wp_reset_query(); // Restore global post data stomped by the_post().

    ?>
    <!– WIDGETS END –>

    <!– POPULAR ARTICLES –>
    <h3>Popular articles</h3>
    <ul class=”popular”>
    <?php most_commented(); ?>

    <!– POPULAR ARTICLES END –>

    <!– FACEBOOK ACTIVITY WIDGET –>
    <h3>Recommended</h3>
    <div id=”fb-root”></div>
    <iframe src=”http://www.facebook.com/plugins/activity.php?site=&lt;?php echo urlencode(get_permalink($post->ID)); ?>&width=310&height=315&header=false&colorscheme=light&border_color=%23ffffff&recommendations=true” scrolling=”no” frameborder=”0″ css=”<?php bloginfo(‘template_url’); ?>/fbl.css?2″ style=”border:none; overflow:hidden; width:310px; height:315px;” allowTransparency=”true”></iframe>

    <!– FACEBOOK ACTIVITY WIDGET END –>
    <div style=”margin-bottom:20px;”></div>

    <!– TABS –>
    <?php include (TEMPLATEPATH . ‘/includes/tabs.php’); ?>
    <!– TABS END –>

    <!– ADS125 –>
    <?php include (TEMPLATEPATH . ‘/includes/ads125.php’); ?>
    <!– ADS125 END –>

    <!– FACEBOOK WIDGET –>
    <h3>On FACEBOOK</h3>
    <div id=”fb-root”></div>
    <script src=”http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php&#8221; type=”text/javascript”></script>
    <script type=”text/javascript”>FB.init(“979d5089fbc94a0afe569d841fc65a45”);</script>
    <fb:fan profile_id=”<?php echo $facebook_id; ?>” connections=”10″ width=”310″ height=”250″ css=”<?php bloginfo(‘template_url’); ?>/fbl.css?2″></fb:fan>

    <!– FACEBOOK WIDGET END –>

    <!– WIDGETS –>
    <?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(‘Sidebar 300px WIDGETS’) ) : ?>
    <?php endif; ?>
    <!– WIDGETS END –>

    </div>

    Your help would greatly be appreciated. I will be sure to send you all that helped a box of dounuts or a 6/pack. Thank you in advance for looking into this and your help!

    looks like a couple of functions in there play around with the wpdb object, which holds the info on the posts showing, and also the data used to evaluate the tags like is_home

    have you tried the wp_reset_query option in widget logic as described in http://wordpress.org/extend/plugins/widget-logic/faq/ and associated screenshot?

    Thread Starter Ray

    (@bluechip)

    yes I have, it didn’t work.

    sorry, if that didn’t work it would probably take some effort to rewrite the functions that use wpdb->get_results which I *think* is the source of the problem.

    You could test if that was true. Those functions are used by (what looks like) the themes built in recent comments, recent posts and most commented functions. if those are in widgets provided by the theme, try removing them and see if that fixes it

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Widget Logic] [HELP] Upgraded to new theme, and WL not working’ is closed to new replies.