Advertisement
eventsmanager

Shortcode for Tag List

Feb 22nd, 2013 (edited)
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. /**
  2. This snippet will add new shortcode [tags_list]
  3. */
  4. function em_get_tags_shortcode(){
  5. $args = (array) $args;
  6.  
  7. $args['ajax'] = isset($args['ajax']) ? $args['ajax']:(!defined('EM_AJAX') || EM_AJAX );
  8.  
  9. $args['format'] = ($format != '' || empty($args['format'])) ? $format : $args['format'];
  10.  
  11. $args['format'] = html_entity_decode($args['format']); //shorcode doesn't accept html
  12.  
  13. $args['orderby'] = !empty($args['orderby']) ? $args['orderby'] : get_option('dbem_categories_default_orderby');
  14.  
  15. $args['order'] = !empty($args['order']) ? $args['order'] : get_option('dbem_categories_default_order');
  16.  
  17. $args['pagination'] = isset($args['pagination']) ? $args['pagination'] : !isset($args['limit']);
  18.  
  19. $args['limit'] = isset($args['limit']) ? $args['limit'] : get_option('dbem_categories_default_limit');
  20.  
  21. if( !empty($args['id']) ) $args['id'] = rand(100, getrandmax());
  22.  
  23. if( empty($args['format']) && empty($args['format_header']) && empty($args['format_footer']) ){
  24.  
  25. ob_start();
  26.  
  27. if( !empty($args['ajax']) ){ echo '<div class="em-search-ajax">'; } //open AJAX wrapper
  28.  
  29. em_locate_template('templates/tags-list.php', true, array('args'=>$args));
  30.  
  31. if( !empty($args['ajax']) ) echo "</div>"; //close AJAX wrapper
  32.  
  33. $return = ob_get_clean();
  34.  
  35. }else{
  36.  
  37. $args['ajax'] = false;
  38.  
  39. $args['page'] = ( !empty($args['pagination']) && !empty($args['page']) && is_numeric($args['page']) )? $args['page'] : 1;
  40.  
  41. $args['page'] = ( !empty($args['pagination']) && !empty($_GET['pno']) && is_numeric($_GET['pno']) )? $_GET['pno'] : $args['page'];
  42.  
  43. $return = EM_Tags::output($args);
  44.  
  45. }
  46.  
  47. return $return;
  48. }
  49.  
  50. add_shortcode ( 'tags_list', 'em_get_tags_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement