Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.77 KB | None | 0 0
  1. <?php
  2. GFForms::include_addon_framework();
  3.  
  4. class GFPriceFix extends GFAddOn {
  5.  
  6. protected $_version = GF_PRICEFIX_VERSION;
  7. protected $_min_gravityforms_version = '1.9';
  8. protected $_slug = GF_PRICEFIX_SLUG;
  9. protected $_path = GF_PRICEFIX_PATH;
  10. protected $_full_path = GF_PRICEFIX_FILE;
  11. protected $_title = 'Gravity Forms Price Fixer';
  12. protected $_short_title = 'Price Fixer';
  13.  
  14. /**
  15. * @var object $_instance If available, contains an instance of this class.
  16. */
  17. private static $_instance = null;
  18.  
  19.  
  20. /**
  21. * Returns an instance of this class, and stores it in the $_instance property.
  22. *
  23. * @return object $_instance An instance of this class.
  24. */
  25. public static function get_instance()
  26. {
  27. if ( self::$_instance == null )
  28. {
  29. self::$_instance = new self();
  30. }
  31. return self::$_instance;
  32. }
  33.  
  34.  
  35.  
  36. /**
  37. * Include the field early so it is available when entry exports are being performed.
  38. */
  39. public function pre_init()
  40. {
  41. parent::pre_init();
  42. }
  43.  
  44. public function init()
  45. {
  46. parent::init();
  47. }
  48.  
  49. public function init_frontend()
  50. {
  51. parent::init_frontend();
  52. add_filter( 'gform_get_form_filter', 'add_to_form', 10, 2 );
  53. }
  54.  
  55. public function init_admin()
  56. {
  57. parent::init_admin();
  58. }
  59.  
  60. public function init_ajax()
  61. {
  62. parent::init_ajax();
  63. }
  64.  
  65.  
  66.  
  67. // # SCRIPTS & STYLES -----------------------------------------------------------------------------------------------
  68.  
  69. /**
  70. * Include script.js
  71. *
  72. * @return array
  73. */
  74. public function scripts() {
  75. $scripts = array(
  76. array(
  77. 'handle' => 'priceFix_script_js',
  78. 'src' => $this->get_base_url() . '/js/script.js',
  79. 'version' => $this->_version,
  80. 'deps' => array( 'jquery' ),
  81. 'enqueue' => array( array( 'field_types' => array( 'priceFix' ) ),
  82. 'admin_page' => array( 'form_settings', 'plugin_settings' )
  83. ),
  84. ),
  85.  
  86. );
  87.  
  88. return array_merge( parent::scripts(), $scripts );
  89. }//scripts
  90.  
  91.  
  92.  
  93. /**
  94. * Include styles.css
  95. *
  96. * @return array
  97. */
  98. public function styles()
  99. {
  100. $styles = array(
  101. array(
  102. 'handle' => 'priceFix_styles_css',
  103. 'src' => $this->get_base_url() . '/css/styles.css',
  104. 'version' => $this->_version,
  105. 'enqueue' => array( array( 'field_types' => array( 'priceFix' ) ),
  106. 'admin_page' => array( 'form_settings', 'plugin_settings' )
  107. )
  108. )
  109. );
  110.  
  111. return array_merge( parent::styles(), $styles );
  112. }//styles
  113.  
  114.  
  115.  
  116. /**
  117. * Configures the settings
  118. *
  119. * @return array
  120. */
  121. public function form_settings_fields( $form )
  122. {
  123. return array(
  124. array(
  125. 'title' => esc_html__( 'Price Fix Settings', 'gravityforms-pricefix' ),
  126. 'fields' => array(
  127. array(
  128. 'label' => esc_html__( 'Enable Output', 'gravityforms-pricefix' ),
  129. 'type' => 'checkbox',
  130. 'name' => 'enablePriceFix',
  131. 'tooltip' => esc_html__( 'enable price fixing for this form?', 'gravityforms-pricefix' ),
  132. 'choices' => array(
  133. array(
  134. 'label' => esc_html__( 'Enabled', 'gravityforms-pricefix' ),
  135. 'name' => 'enablePriceFix',
  136. ),
  137. ),
  138. ),
  139. array(
  140. 'label' => esc_html__( 'Extra Currency Selection', 'gravityforms-pricefix' ),
  141. 'type' => 'checkbox',
  142. 'name' => 'enabledCurrencies',
  143. 'tooltip' => esc_html__( 'Select extra currenices you wish to use.', 'gravityforms-pricefix' ),
  144. 'choices' => array(
  145. array(
  146. 'label' => esc_html__( '€ - Euro', 'gravityforms-pricefix' ),
  147. 'name' => 'enableEURO',
  148. ),
  149. array(
  150. 'label' => esc_html__( '$ - US Dollar', 'gravityforms-pricefix' ),
  151. 'name' => 'enableUSDOLLAR',
  152. ),
  153. ),
  154. ),
  155. array(
  156. 'label' => esc_html__( 'Euro Value', 'gravityforms-pricefix' ),
  157. 'type' => 'text',
  158. 'name' => 'euroPrice',
  159. 'tooltip' => esc_html__( 'Enter the value for Euro payments', 'gravityforms-pricefix' ),
  160. 'class' => 'small',
  161. //'feedback_callback' => array( $this, 'is_valid_setting' ),
  162. ),
  163. array(
  164. 'label' => esc_html__( 'US Dollar Value', 'gravityforms-pricefix' ),
  165. 'type' => 'text',
  166. 'name' => 'usPrice',
  167. 'tooltip' => esc_html__( 'Enter the value for US Dollar payments', 'gravityforms-pricefix' ),
  168. 'class' => 'small',
  169. //'feedback_callback' => array( $this, 'is_valid_setting' ),
  170. ),
  171. )
  172. ),
  173. );
  174. }// form_settings_fields
  175.  
  176.  
  177.  
  178. public function add_to_form( $form_string, $form )
  179. {
  180. //$settings = $this->get_form_settings( $form );
  181.  
  182. $day = date( 'l' );
  183. if ( $day == 'Friday' ) {
  184. $form_string = '<p>We are closed today, please return tomorrow to make your booking.</p>';
  185. }
  186.  
  187. return $form_string;
  188. }
  189.  
  190. }//GFPriceFix
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement