[ Index ]

WordPress Source Cross Reference

title

Body

[close]

/wp-includes/ -> classes.php (source)

   1  <?php
   2  
   3  class retrospam_mgr {
   4      var $spam_words;
   5      var $comments_list;
   6      var $found_comments;
   7  
   8  	function retrospam_mgr() {
   9          global $wpdb;
  10  
  11          $list = explode("\n", get_settings('moderation_keys') );
  12          $list = array_unique( $list );
  13          $this->spam_words = $list;
  14  
  15          $this->comment_list = $wpdb->get_results("SELECT comment_ID AS ID, comment_content AS text, comment_approved AS approved, comment_author_url AS url, comment_author_ip AS ip, comment_author_email AS email FROM $wpdb->comments ORDER BY comment_ID ASC");
  16      }    // End of class constructor
  17  
  18  	function move_spam( $id_list ) {
  19          global $wpdb;
  20          $cnt = 0;
  21          $id_list = explode( ',', $id_list );
  22  
  23          foreach ( $id_list as $comment ) {
  24              if ( $wpdb->query("update $wpdb->comments set comment_approved = '0' where comment_ID = '$comment'") ) {
  25                  $cnt++;
  26              }
  27          }
  28          echo "<div class='updated'><p>$cnt comment";
  29          if ($cnt != 1 ) echo "s";
  30          echo " moved to the moderation queue.</p></div>\n";
  31      }    // End function move_spam
  32  
  33  	function find_spam() {
  34          $in_queue = 0;
  35  
  36          foreach( $this->comment_list as $comment ) {
  37              if( $comment->approved == 1 ) {
  38                  foreach( $this->spam_words as $word ) {
  39                      $word = trim($word);
  40                      if ( empty( $word ) )
  41                          continue;
  42                      $fulltext = strtolower($comment->email.' '.$comment->url.' '.$comment->ip.' '.$comment->text);
  43                      if( false !== strpos( $fulltext, strtolower($word) ) ) {
  44                          $this->found_comments[] = $comment->ID;
  45                          break;
  46                      }
  47                  }
  48              } else {
  49                  $in_queue++;
  50              }
  51          }
  52          return array( 'found' => $this->found_comments, 'in_queue' => $in_queue );
  53      }    // End function find_spam
  54  
  55  	function display_edit_form( $counters ) {
  56          $numfound = count($counters[found]);
  57          $numqueue = $counters[in_queue];
  58  
  59          $body = '<p>' . sprintf(__('Suspected spam comments: <strong>%s</strong>'), $numfound) . '</p>';
  60  
  61          if ( count($counters[found]) > 0 ) {
  62              $id_list = implode( ',', $counters[found] );
  63              $body .= '<p><a href="options-discussion.php?action=retrospam&amp;move=true&amp;ids='.$id_list.'">'. __('Move suspect comments to moderation queue &raquo;') . '</a></p>';
  64  
  65          }
  66          $head = '<div class="wrap"><h2>' . __('Check Comments Results:') . '</h2>';
  67  
  68          $foot .= '<p><a href="options-discussion.php">' . __('&laquo; Return to Discussion Options page.') . '</a></p></div>';
  69  
  70          return $head . $body . $foot;
  71      }     // End function display_edit_form
  72  
  73  }
  74  
  75  class WP {
  76      var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots');
  77  
  78      var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type');
  79      var $extra_query_vars = array();
  80  
  81      var $query_vars;
  82      var $query_string;
  83      var $request;
  84      var $matched_rule;
  85      var $matched_query;
  86      var $did_permalink = false;
  87      
  88  	function add_query_var($qv) {
  89          $this->public_query_vars[] = $qv;
  90      }
  91  
  92  	function parse_request($extra_query_vars = '') {
  93          global $wp_rewrite;
  94  
  95          $this->query_vars = array();
  96  
  97          if (! empty($extra_query_vars))
  98              parse_str($extra_query_vars, $this->extra_query_vars);
  99  
 100          // Process PATH_INFO, REQUEST_URI, and 404 for permalinks.
 101  
 102          // Fetch the rewrite rules.
 103          $rewrite = $wp_rewrite->wp_rewrite_rules();
 104  
 105          if (! empty($rewrite)) {
 106              // If we match a rewrite rule, this will be cleared.
 107              $error = '404';
 108              $this->did_permalink = true;
 109  
 110              $pathinfo = $_SERVER['PATH_INFO'];
 111              $pathinfo_array = explode('?', $pathinfo);
 112              $pathinfo = $pathinfo_array[0];
 113              $req_uri = $_SERVER['REQUEST_URI'];
 114              $req_uri_array = explode('?', $req_uri);
 115              $req_uri = $req_uri_array[0];
 116              $self = $_SERVER['PHP_SELF'];
 117              $home_path = parse_url(get_settings('home'));
 118              $home_path = $home_path['path'];
 119              $home_path = trim($home_path, '/');
 120  
 121              // Trim path info from the end and the leading home path from the
 122              // front.  For path info requests, this leaves us with the requesting
 123              // filename, if any.  For 404 requests, this leaves us with the
 124              // requested permalink.
 125              $req_uri = str_replace($pathinfo, '', $req_uri);
 126              $req_uri = trim($req_uri, '/');
 127              $req_uri = preg_replace("|^$home_path|", '', $req_uri);
 128              $req_uri = trim($req_uri, '/');
 129              $pathinfo = trim($pathinfo, '/');
 130              $pathinfo = preg_replace("|^$home_path|", '', $pathinfo);
 131              $pathinfo = trim($pathinfo, '/');
 132              $self = trim($self, '/');
 133              $self = preg_replace("|^$home_path|", '', $self);
 134              $self = str_replace($home_path, '', $self);
 135              $self = trim($self, '/');
 136  
 137              // The requested permalink is in $pathinfo for path info requests and
 138              //  $req_uri for other requests.
 139              if ( ! empty($pathinfo) && !preg_match('|^.*' . $wp_rewrite->index . '$|', $pathinfo) ) {
 140                  $request = $pathinfo;
 141              } else {
 142                  // If the request uri is the index, blank it out so that we don't try to match it against a rule.
 143                  if ( $req_uri == $wp_rewrite->index )
 144                      $req_uri = '';
 145                  $request = $req_uri;
 146              }
 147  
 148              $this->request = $request;
 149  
 150              // Look for matches.
 151              $request_match = $request;
 152              foreach ($rewrite as $match => $query) {
 153                  // If the requesting file is the anchor of the match, prepend it
 154                  // to the path info.
 155                  if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request)) {
 156                      $request_match = $req_uri . '/' . $request;
 157                  }
 158  
 159                  if (preg_match("!^$match!", $request_match, $matches) ||
 160                      preg_match("!^$match!", urldecode($request_match), $matches)) {
 161                      // Got a match.
 162                      $this->matched_rule = $match;
 163                      
 164                      // Trim the query of everything up to the '?'.
 165                      $query = preg_replace("!^.+\?!", '', $query);
 166  
 167                      // Substitute the substring matches into the query.
 168                      eval("\$query = \"$query\";");
 169                      $this->matched_query = $query;
 170  
 171                      // Parse the query.
 172                      parse_str($query, $perma_query_vars);
 173  
 174                      // If we're processing a 404 request, clear the error var
 175                      // since we found something.
 176                      if (isset($_GET['error']))
 177                          unset($_GET['error']);
 178  
 179                      if (isset($error))
 180                          unset($error);
 181  
 182                      break;
 183                  }
 184              }
 185  
 186              // If req_uri is empty or if it is a request for ourself, unset error.
 187              if ( empty($request) || $req_uri == $self || strstr($_SERVER['PHP_SELF'], 'wp-admin/') ) {
 188                  if (isset($_GET['error']))
 189                      unset($_GET['error']);
 190  
 191                  if (isset($error))
 192                      unset($error);
 193  
 194                  if ( isset($perma_query_vars) && strstr($_SERVER['PHP_SELF'], 'wp-admin/') )
 195                      unset($perma_query_vars);
 196  
 197                  $this->did_permalink = false;
 198              }
 199          }
 200  
 201          $this->public_query_vars = apply_filters('query_vars', $this->public_query_vars);
 202  
 203          for ($i=0; $i<count($this->public_query_vars); $i += 1) {
 204              $wpvar = $this->public_query_vars[$i];
 205              if (isset($this->extra_query_vars[$wpvar]))
 206                  $this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar];
 207              elseif (isset($GLOBALS[$wpvar]))
 208                  $this->query_vars[$wpvar] = $GLOBALS[$wpvar];
 209              elseif (!empty($_POST[$wpvar]))
 210                  $this->query_vars[$wpvar] = $_POST[$wpvar];
 211              elseif (!empty($_GET[$wpvar]))
 212                  $this->query_vars[$wpvar] = $_GET[$wpvar];
 213              elseif (!empty($perma_query_vars[$wpvar]))
 214                  $this->query_vars[$wpvar] = $perma_query_vars[$wpvar];
 215              else
 216                  $this->query_vars[$wpvar] = '';
 217          }
 218  
 219          for ($i=0; $i<count($this->private_query_vars); $i += 1) {
 220              $wpvar = $this->private_query_vars[$i];
 221              if (isset($this->extra_query_vars[$wpvar]))
 222                  $this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar];        
 223          }
 224  
 225          if ( isset($error) )
 226              $this->query_vars['error'] = $error;
 227  
 228          do_action('parse_request', array(&$this));
 229      }
 230  
 231  	function send_headers() {
 232          @header('X-Pingback: '. get_bloginfo('pingback_url'));
 233          if ( is_user_logged_in() )
 234              nocache_headers();
 235          if ( !empty($this->query_vars['error']) && '404' == $this->query_vars['error'] ) {
 236              status_header( 404 );
 237              @header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
 238          } else if ( empty($this->query_vars['feed']) ) {
 239              @header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
 240          } else {
 241              // We're showing a feed, so WP is indeed the only thing that last changed
 242              if ( $this->query_vars['withcomments'] )
 243                  $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT';
 244              else 
 245                  $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT';
 246              $wp_etag = '"' . md5($wp_last_modified) . '"';
 247              @header("Last-Modified: $wp_last_modified");
 248              @header("ETag: $wp_etag");
 249  
 250              // Support for Conditional GET
 251              if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) 
 252                  $client_etag = stripslashes(stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
 253              else $client_etag = false;
 254  
 255              $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE']);
 256              // If string is empty, return 0. If not, attempt to parse into a timestamp
 257              $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
 258  
 259              // Make a timestamp for our most recent modification...
 260              $wp_modified_timestamp = strtotime($wp_last_modified);
 261  
 262              if ( ($client_last_modified && $client_etag) ?
 263                       (($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) :
 264                       (($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag)) ) {
 265                  status_header( 304 );
 266                  exit;
 267              }
 268          }
 269  
 270          do_action('send_headers', array(&$this));
 271      }
 272  
 273  	function build_query_string() {
 274          $this->query_string = '';
 275  
 276          foreach (array_keys($this->query_vars) as $wpvar) {
 277              if ( '' != $this->query_vars[$wpvar] ) {
 278                  $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&';
 279                  $this->query_string .= $wpvar . '=' . rawurlencode($this->query_vars[$wpvar]);
 280              }
 281          }
 282  
 283          foreach ($this->private_query_vars as $wpvar) {
 284              if (isset($GLOBALS[$wpvar]) && '' != $GLOBALS[$wpvar] && ! isset($this->extra_query_vars[$wpvar]) ) {
 285                  $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&';
 286                  $this->query_string .= $wpvar . '=' . rawurlencode($GLOBALS[$wpvar]);
 287              }
 288          }
 289  
 290          $this->query_string = apply_filters('query_string', $this->query_string);
 291      }
 292  
 293  	function register_globals() {
 294          global $wp_query;
 295          // Extract updated query vars back into global namespace.
 296          foreach ($wp_query->query_vars as $key => $value) {
 297              $GLOBALS[$key] = $value;
 298          }
 299  
 300          $GLOBALS['query_string'] = & $this->query_string;
 301          $GLOBALS['posts'] = & $wp_query->posts;
 302          $GLOBALS['post'] = & $wp_query->post;
 303          $GLOBALS['request'] = & $wp_query->request;
 304  
 305          if ( is_single() || is_page() ) {
 306              $GLOBALS['more'] = 1;
 307              $GLOBALS['single'] = 1;
 308          }
 309      }
 310  
 311  	function init() {
 312          wp_get_current_user();
 313      }
 314  
 315  	function query_posts() {
 316          $this->build_query_string();
 317          query_posts($this->query_string);
 318       }
 319  
 320  	function handle_404() {
 321          global $wp_query;
 322          // Issue a 404 if a permalink request doesn't match any posts.  Don't
 323          // issue a 404 if one was already issued, if the request was a search,
 324          // or if the request was a regular query string request rather than a
 325          // permalink request.
 326          if ( (0 == count($wp_query->posts)) && !is_404() && !is_search() && ( $this->did_permalink || (!empty($_SERVER['QUERY_STRING']) && (false === strpos($_SERVER['REQUEST_URI'], '?'))) ) ) {
 327              $wp_query->set_404();
 328              status_header( 404 );
 329          }    elseif( is_404() != true ) {
 330              status_header( 200 );
 331          }
 332      }
 333  
 334  	function main($query_args = '') {
 335          $this->init();
 336          $this->parse_request($query_args);
 337          $this->send_headers();
 338          $this->query_posts();
 339          $this->handle_404();
 340          $this->register_globals();
 341          do_action('wp', array(&$this));
 342      }
 343  
 344      function WP() {
 345          // Empty.
 346      }
 347  }
 348  
 349  class WP_Error {
 350      var $errors = array();
 351  
 352  	function WP_Error($code = '', $message = '') {
 353          if ( ! empty($code) )
 354              $this->errors[$code][] = $message;
 355      }
 356  
 357  	function get_error_codes() {
 358          if ( empty($this->errors) )
 359              return array();
 360  
 361          return array_keys($this->errors);
 362      }
 363  
 364  	function get_error_code() {
 365          $codes = $this->get_error_codes();
 366  
 367          if ( empty($codes) )
 368              return '';
 369  
 370          return $codes[0];    
 371      }
 372  
 373  	function get_error_messages($code = '') {
 374          // Return all messages if no code specified.
 375          if ( empty($code) ) {
 376              $all_messages = array();
 377              foreach ( $this->errors as $code => $messages )
 378                  $all_messages = array_merge($all_messages, $messages);
 379  
 380              return $all_messages;
 381          }
 382  
 383          if ( isset($this->errors[$code]) )
 384              return $this->errors[$code];
 385          else
 386              return array();    
 387      }
 388  
 389  	function get_error_message($code = '') {
 390          if ( empty($code) )
 391              $code = $this->get_error_code();
 392          $messages = $this->get_error_messages($code);
 393          if ( empty($messages) )
 394              return '';
 395          return $messages[0];
 396      }
 397  
 398  	function add($code, $message) {
 399          $this->errors[$code][] = $message;    
 400      }
 401  }
 402  
 403  function is_wp_error($thing) {
 404      if ( is_object($thing) && is_a($thing, 'WP_Error') )
 405          return true;
 406      return false;
 407  }
 408  
 409  
 410  // A class for displaying various tree-like structures. Extend the Walker class to use it, see examples at the bottom
 411  
 412  class Walker {    
 413      var $tree_type;
 414      var $db_fields;
 415      
 416      //abstract callbacks
 417  	function start_lvl($output) { return $output; }
 418  	function end_lvl($output)   { return $output; }
 419  	function start_el($output)  { return $output; }
 420  	function end_el($output)    { return $output; }
 421      
 422  	function walk($elements, $to_depth) {
 423          $args = array_slice(func_get_args(), 2); $parents = array(); $depth = 1; $previous_element = ''; $output = '';
 424      
 425          //padding at the end
 426          $last_element->post_parent = 0;
 427          $last_element->post_id = 0;
 428          $elements[] = $last_element;
 429      
 430          $id_field = $this->db_fields['id'];
 431          $parent_field = $this->db_fields['parent'];
 432      
 433          $flat = ($to_depth == -1) ? true : false;
 434      
 435          foreach ( $elements as $element ) {
 436              // If flat, start and end the element and skip the level checks.
 437              if ( $flat) {
 438                  // Start the element.
 439                  if ( $element->$id_field != 0 ) {
 440                      $cb_args = array_merge( array($output, $element, $depth - 1), $args);
 441                      $output = call_user_func_array(array(&$this, 'start_el'), $cb_args);
 442                  }
 443      
 444                  // End the element.
 445                  if ( $element->$id_field != 0 ) {
 446                      $cb_args = array_merge( array($output, $element, $depth - 1), $args);
 447                      $output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
 448                  }
 449      
 450                  continue;    
 451              }
 452      
 453              // Walk the tree.
 454              if ( !empty($previous_element) && ($element->$parent_field == $previous_element->$id_field) ) {
 455                  // Previous element is my parent. Descend a level.
 456                  array_unshift($parents, $previous_element);
 457                  $depth++; //always do this so when we start the element further down, we know where we are
 458                  if ( !$to_depth || ($depth < $to_depth) ) { //only descend if we're below $to_depth
 459                      $cb_args = array_merge( array($output, $depth - 1), $args);
 460                      $output = call_user_func_array(array(&$this, 'start_lvl'), $cb_args);
 461                  }
 462              } else if ( $element->$parent_field == $previous_element->$parent_field) {
 463                  // On the same level as previous element.
 464                  if ( !$to_depth || ($depth <= $to_depth) ) {
 465                      $cb_args = array_merge( array($output, $previous_element, $depth - 1), $args);
 466                      $output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
 467                  }
 468              } else if ( $depth > 1 ) {
 469                  // Ascend one or more levels.
 470                  if ( !$to_depth || ($depth <= $to_depth) ) {
 471                      $cb_args = array_merge( array($output, $previous_element, $depth - 1), $args);
 472                      $output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
 473                  }
 474      
 475                  while ( $parent = array_shift($parents) ) {
 476                      $depth--;
 477                      if ( !$to_depth || ($depth < $to_depth) ) {
 478                          $cb_args = array_merge( array($output, $depth - 1), $args);
 479                          $output = call_user_func_array(array(&$this, 'end_lvl'), $cb_args);
 480                          $cb_args = array_merge( array($output, $parent, $depth - 1), $args);
 481                          $output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
 482                      }
 483                      if ( $element->$parent_field == $parents[0]->$id_field ) {
 484                          break;
 485                      }
 486                  }
 487              } else if ( !empty($previous_element) ) {
 488                  // Close off previous element.
 489                  if ( !$to_depth || ($depth <= $to_depth) ) {
 490                      $cb_args = array_merge( array($output, $previous_element, $depth - 1), $args);
 491                      $output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
 492                  }
 493              }
 494      
 495              // Start the element.
 496              if ( !$to_depth || ($depth <= $to_depth) ) {
 497                  if ( $element->$id_field != 0 ) {
 498                      $cb_args = array_merge( array($output, $element, $depth - 1), $args);
 499                      $output = call_user_func_array(array(&$this, 'start_el'), $cb_args);
 500                  }
 501              }
 502      
 503              $previous_element = $element;
 504          }
 505          
 506          return $output;
 507      }
 508  }
 509  
 510  class Walker_Page extends Walker {
 511      var $tree_type = 'page';
 512      var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this
 513      
 514  	function start_lvl($output, $depth) {
 515          $indent = str_repeat("\t", $depth);
 516          $output .= "$indent<ul>\n";
 517          return $output;
 518      }
 519      
 520  	function end_lvl($output, $depth) {
 521          $indent = str_repeat("\t", $depth);
 522          $output .= "$indent</ul>\n";
 523          return $output;
 524      }
 525      
 526  	function start_el($output, $page, $depth, $current_page, $show_date, $date_format) {
 527          if ( $depth )
 528              $indent = str_repeat("\t", $depth);
 529  
 530          $css_class = 'page_item';
 531          if ( $page->ID == $current_page )
 532              $css_class .= ' current_page_item';
 533  
 534          $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . wp_specialchars($page->post_title) . '">' . $page->post_title . '</a>';
 535      
 536          if ( !empty($show_date) ) {
 537              if ( 'modified' == $show_date )
 538                  $time = $page->post_modified;
 539              else
 540                  $time = $page->post_date;
 541      
 542              $output .= " " . mysql2date($date_format, $time);
 543          }
 544  
 545          return $output;
 546      }
 547      
 548  	function end_el($output, $page, $depth) {
 549          $output .= "</li>\n";
 550  
 551          return $output;
 552      }
 553  
 554  }
 555  
 556  class Walker_PageDropdown extends Walker {
 557      var $tree_type = 'page';
 558      var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this
 559  
 560  	function start_el($output, $page, $depth, $args) {
 561          $pad = str_repeat('&nbsp;', $depth * 3);
 562  
 563          $output .= "\t<option value=\"$page->ID\"";
 564          if ( $page->ID == $args['selected'] )
 565                  $output .= ' selected="selected"';
 566          $output .= '>';
 567          $title = wp_specialchars($page->post_title);
 568          $output .= "$pad$title";
 569          $output .= "</option>\n";
 570  
 571          return $output;
 572      }
 573  }
 574  
 575  class Walker_Category extends Walker {
 576      var $tree_type = 'category';
 577      var $db_fields = array ('parent' => 'category_parent', 'id' => 'cat_ID'); //TODO: decouple this
 578      
 579  	function start_lvl($output, $depth, $args) {
 580          if ( 'list' != $args['style'] )
 581              return $output;
 582      
 583          $indent = str_repeat("\t", $depth);
 584          $output .= "$indent<ul class='children'>\n";
 585          return $output;
 586      }
 587      
 588  	function end_lvl($output, $depth, $args) {
 589          if ( 'list' != $args['style'] )
 590              return $output;
 591      
 592          $indent = str_repeat("\t", $depth);
 593          $output .= "$indent</ul>\n";
 594          return $output;
 595      }
 596      
 597  	function start_el($output, $category, $depth, $args) {
 598          extract($args);
 599      
 600          $link = '<a href="' . get_category_link($category->cat_ID) . '" ';
 601          if ( $use_desc_for_title == 0 || empty($category->category_description) )
 602              $link .= 'title="'. sprintf(__("View all posts filed under %s"), wp_specialchars($category->cat_name)) . '"';
 603          else
 604              $link .= 'title="' . wp_specialchars(apply_filters('category_description',$category->category_description,$category)) . '"';
 605          $link .= '>';
 606          $link .= apply_filters('list_cats', $category->cat_name, $category).'</a>';
 607      
 608          if ( (! empty($feed_image)) || (! empty($feed)) ) {
 609              $link .= ' ';
 610      
 611              if ( empty($feed_image) )
 612                  $link .= '(';
 613      
 614              $link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"';
 615      
 616              if ( !empty($feed) ) {
 617                  $title = ' title="' . $feed . '"';
 618                  $alt = ' alt="' . $feed . '"';
 619                  $name = $feed;
 620                  $link .= $title;
 621              }
 622      
 623              $link .= '>';
 624      
 625              if ( !empty($feed_image) )
 626                  $link .= "<img src='$feed_image' $alt$title" . ' />';
 627              else
 628                  $link .= $name;
 629              $link .= '</a>';
 630              if (empty($feed_image))
 631                  $link .= ')';
 632          }
 633      
 634          if ( $show_count )
 635              $link .= ' ('.intval($category->category_count).')';
 636      
 637          if ( $show_date ) {
 638              $link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp);
 639          }
 640      
 641          if ( 'list' == $args['style'] ) {
 642              $output .= "\t<li";
 643              if ( ($category->cat_ID == $current_category) && is_category() )
 644                  $output .=  ' class="current-cat"';
 645              $output .= ">$link\n";
 646          } else {
 647              $output .= "\t$link<br />\n";
 648          }
 649      
 650          return $output;
 651      }
 652      
 653  	function end_el($output, $page, $depth, $args) {
 654          if ( 'list' != $args['style'] )
 655              return $output;
 656      
 657          $output .= "</li>\n";
 658          return $output;
 659      }
 660  
 661  }
 662  
 663  class Walker_CategoryDropdown extends Walker {
 664      var $tree_type = 'category';
 665      var $db_fields = array ('parent' => 'category_parent', 'id' => 'cat_ID'); //TODO: decouple this
 666      
 667  	function start_el($output, $category, $depth, $args) { 
 668          $pad = str_repeat('&nbsp;', $depth * 3);
 669          
 670          $cat_name = apply_filters('list_cats', $category->cat_name, $category);
 671          $output .= "\t<option value=\"".$category->cat_ID."\"";
 672          if ( $category->cat_ID == $args['selected'] )
 673              $output .= ' selected="selected"';
 674          $output .= '>';
 675          $output .= $cat_name;
 676          if ( $args['show_count'] )
 677              $output .= '&nbsp;&nbsp;('. $category->category_count .')';
 678          if ( $args['show_last_update'] ) {
 679              $format = 'Y-m-d';
 680              $output .= '&nbsp;&nbsp;' . gmdate($format, $category->last_update_timestamp);
 681          }
 682          $output .= "</option>\n";
 683          
 684          return $output;
 685      }
 686  }
 687  
 688  ?>

Your comment here...

Name: Location:
Comments:


List: Classes | Functions | Variables | Constants | Tables

Generated: Sat Jul 15 11:57:04 2006 Courtesy of Taragana