Guest User

Gravity Forms - Display Entries Left

a guest
Jul 23rd, 2012
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. <?php
  2. /**
  3. * Sets up the theme by loading the Mysitemyway class & initializing the framework
  4. * which activates all classes and functions needed for theme's operation.
  5. *
  6. * @package Mysitemyway
  7. * @subpackage Functions
  8. */
  9.  
  10. # Load the Mysitemyway class.
  11. require_once( TEMPLATEPATH . '/framework.php' );
  12.  
  13. # Get theme data.
  14. $theme_data = get_theme_data( TEMPLATEPATH . '/style.css' );
  15.  
  16. # Initialize the Mysitemyway framework.
  17. Mysitemyway::init(array(
  18. 'theme_name' => $theme_data['Name'],
  19. 'theme_version' => $theme_data['Version']
  20.  
  21.  
  22. ));
  23.  
  24. # Display Entroes left.
  25.  
  26. function spotsleftShortcode($atts, $content=null) {
  27.  
  28. extract(shortcode_atts(array(
  29. 'id' => ''
  30. ), $atts));
  31.  
  32. $form_id = $id;
  33. $form = RGFormsModel::get_form_meta($form_id);
  34. $entry_count = RGFormsModel::get_lead_count($form['id'], '');
  35. $entries_left = $form["limitEntriesCount"] – $entry_count;
  36.  
  37. if($entries_left > 1):
  38. $entries_left_message = $form['title']. ' – Only ' . $entries_left . ' spots left!';
  39. elseif($entries_left == 1):
  40. $entries_left_message = $form['title']. ' – Only ' . $entries_left . ' spot left!';
  41. else:
  42. $entries_left_message = $form['title']. ' - Currently sold out. Please fill out our waiting list if you wish to join';
  43. endif;
  44. return $entries_left_message;
  45. }
  46.  
  47. add_shortcode('spotsleft', 'spotsleftShortcode');
  48.  
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment