Advertisement
wpexplorer

Classy Pricing

Jan 25th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.06 KB | None | 0 0
  1. //- Pricing Tables -------*/
  2. function pricing_tables_shortcode($atts, $content = null)   {
  3.  
  4.     extract( shortcode_atts(
  5.     array(
  6.       'columns' => 'four',
  7.       'slug' => ''
  8.     ), $atts ) );
  9.    
  10.     //get column count and set post count
  11.     if($columns == 'four') { $pricing_tables_count = '4'; } else { $pricing_tables_count = '3'; }
  12.    
  13.     //set loop arguments
  14.     $post_args = array(
  15.                         'post_type' => 'pricing_tables',
  16.                         'pricing_tables_cats' => ''. $slug.'',
  17.                         'posts_per_page' => $pricing_tables_count,
  18.                         'order'=> 'DESC',
  19.                     );
  20.                    
  21.     //get pricing table posts
  22.     $pricing_tables = get_posts($post_args);
  23.    
  24.     //Start Content
  25.     $content .= '<div class="pricing-table-wrap clearfix">';
  26.    
  27.     //start counter and loop
  28.     $count=0;
  29.     foreach ($pricing_tables as $pricing_table) {
  30.     $count++;
  31.    
  32.     //get pricing tables meta
  33.     $pricing_tables_featured = get_post_meta($pricing_table->ID, 'classy_pricing_tables_featured', TRUE);
  34.     $pricing_tables_price = get_post_meta($pricing_table->ID, 'classy_pricing_tables_price', TRUE);
  35.     $pricing_tables_money_symbol = get_post_meta($pricing_table->ID, 'classy_pricing_tables_money_symbol', TRUE);
  36.     $pricing_tables_rate = get_post_meta($pricing_table->ID, 'classy_pricing_tables_rate', TRUE);
  37.     $pricing_tables_url = get_post_meta($pricing_table->ID, 'classy_pricing_tables_url', TRUE);
  38.     $pricing_tables_btn_text = get_post_meta($pricing_table->ID, 'classy_pricing_tables_btn_text', TRUE);
  39.     //set variable for gs grid
  40.     if($columns == 'four') { $pricing_grid = 'grid_6'; } else { $pricing_grid = 'grid_8'; }
  41.    
  42.     //set variable for alpha and omegas
  43.     if($count==1){ $class = 'alpha'; }
  44.     if($count==2){ $class = ''; }
  45.     if($count==$pricing_tables_count) { $class = 'omega'; }
  46.        
  47.     //see if pricing table is featured, if so set variable class   
  48.     if($pricing_tables_featured == 'Yes') { $featured = 'featured'; } else { $featured =''; }
  49.  
  50.                     $content .= '<div class="'. $pricing_grid . ' '. $class .'">';
  51.                         $content .= '<div class="pricing-table '.$featured.' clearfix">';
  52.                             if($featured !='') {
  53.                                 $content .= '<span class="pricing-popular-tag"></span>';
  54.                             }
  55.                             $content .='<div class="pricing-table-header">';
  56.                                 $content .= '<h3>'. get_the_title($pricing_table->ID, 'testimonial') .'</h3>';
  57.                                 $content .= '<div class="price"><span class="symbol">'. $pricing_tables_money_symbol .'</span>'. $pricing_tables_price .'<span class="rate">'.$pricing_tables_rate.'</span></div>';
  58.                                 $content .= '</div>';
  59.                                 $content .= wptexturize($pricing_table->post_content);
  60.                                 if($pricing_tables_url !='') {
  61.                                     $content .= '<div class="pricing-table-button"><a href="'.$pricing_tables_url.'" title="'.$pricing_tables_btn_text.'">'.$pricing_tables_btn_text.'</a></div>';
  62.                                 }
  63.                         $content .= '</div>';  
  64.                         $content .='<span class="pricing-shadow-'.$columns.'"></span>';
  65.                     $content .= '</div>';
  66.                    
  67.                     //reset count
  68.                     if($count == $pricing_tables_count ) { $count=0; }
  69.         }
  70.     $content .= '</div>';
  71.     return $content;  
  72.     }
  73. add_shortcode('pricing_table_shortcode', 'pricing_tables_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement