Advertisement
Guest User

Improving Polylang plugin for WordPress

a guest
May 24th, 2012
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | None | 0 0
  1. /* In include/post-translations.php */
  2.  
  3.             <td><?php echo esc_html($language->name);?></td>
  4.             <td>
  5.                 <?php
  6.                     $this->dropdown_posts( array(
  7.                             'post_type' => get_post_type(),
  8.                             'selected' => intval($value),
  9.                             'select_name' => 'post_tr_lang['.esc_attr($language->slug).']',
  10.                             'exclude' => $post_ID
  11.                         ) );
  12.                 ?>
  13.             </td>
  14.  
  15. /* Here is the dropdown_posts function: */
  16.  
  17.     function dropdown_posts($args) {
  18.         $defaults = array(
  19.                 'depth' => 0,
  20.                 'echo' => 0,
  21.                 'numberposts' => -1,
  22.                 'sortby' => 'post_title',
  23.                 'order' => 'ASC'
  24.             );
  25.  
  26.         $r = wp_parse_args( $args, $defaults );
  27.         $posts = get_posts( $r );
  28.         $options_html = walk_page_dropdown_tree( $posts, 0, $r );
  29.  
  30.         printf('<select name="%s"><option value="">%s</option>%s</select>',
  31.             $r['select_name'],
  32.             __('None'),
  33.             $options_html);
  34.     }
  35.  
  36. /* And finaly -- you should check for the surpress_filters to be off when modifying the queries via pre_get_posts: */
  37.  
  38.     // filters posts according to the language
  39.     function pre_get_posts($query) {
  40.         // Don't run if suppress_filters is on.
  41.         if ( isset( $query->query_vars[ 'suppress_filters' ] ) && $query->query_vars[ 'suppress_filters' ] == true )
  42.             return $query;
  43.  
  44.         /* [...] */
  45.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement