Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- GFForms::include_addon_framework();
- class GFPriceFix extends GFAddOn {
- protected $_version = GF_PRICEFIX_VERSION;
- protected $_min_gravityforms_version = '1.9';
- protected $_slug = GF_PRICEFIX_SLUG;
- protected $_path = GF_PRICEFIX_PATH;
- protected $_full_path = GF_PRICEFIX_FILE;
- protected $_title = 'Gravity Forms Price Fixer';
- protected $_short_title = 'Price Fixer';
- /**
- * @var object $_instance If available, contains an instance of this class.
- */
- private static $_instance = null;
- /**
- * Returns an instance of this class, and stores it in the $_instance property.
- *
- * @return object $_instance An instance of this class.
- */
- public static function get_instance()
- {
- if ( self::$_instance == null )
- {
- self::$_instance = new self();
- }
- return self::$_instance;
- }
- /**
- * Include the field early so it is available when entry exports are being performed.
- */
- public function pre_init()
- {
- parent::pre_init();
- }
- public function init()
- {
- parent::init();
- }
- public function init_frontend()
- {
- parent::init_frontend();
- add_filter( 'gform_get_form_filter', 'add_to_form', 10, 2 );
- }
- public function init_admin()
- {
- parent::init_admin();
- }
- public function init_ajax()
- {
- parent::init_ajax();
- }
- // # SCRIPTS & STYLES -----------------------------------------------------------------------------------------------
- /**
- * Include script.js
- *
- * @return array
- */
- public function scripts() {
- $scripts = array(
- array(
- 'handle' => 'priceFix_script_js',
- 'src' => $this->get_base_url() . '/js/script.js',
- 'version' => $this->_version,
- 'deps' => array( 'jquery' ),
- 'enqueue' => array( array( 'field_types' => array( 'priceFix' ) ),
- 'admin_page' => array( 'form_settings', 'plugin_settings' )
- ),
- ),
- );
- return array_merge( parent::scripts(), $scripts );
- }//scripts
- /**
- * Include styles.css
- *
- * @return array
- */
- public function styles()
- {
- $styles = array(
- array(
- 'handle' => 'priceFix_styles_css',
- 'src' => $this->get_base_url() . '/css/styles.css',
- 'version' => $this->_version,
- 'enqueue' => array( array( 'field_types' => array( 'priceFix' ) ),
- 'admin_page' => array( 'form_settings', 'plugin_settings' )
- )
- )
- );
- return array_merge( parent::styles(), $styles );
- }//styles
- /**
- * Configures the settings
- *
- * @return array
- */
- public function form_settings_fields( $form )
- {
- return array(
- array(
- 'title' => esc_html__( 'Price Fix Settings', 'gravityforms-pricefix' ),
- 'fields' => array(
- array(
- 'label' => esc_html__( 'Enable Output', 'gravityforms-pricefix' ),
- 'type' => 'checkbox',
- 'name' => 'enablePriceFix',
- 'tooltip' => esc_html__( 'enable price fixing for this form?', 'gravityforms-pricefix' ),
- 'choices' => array(
- array(
- 'label' => esc_html__( 'Enabled', 'gravityforms-pricefix' ),
- 'name' => 'enablePriceFix',
- ),
- ),
- ),
- array(
- 'label' => esc_html__( 'Extra Currency Selection', 'gravityforms-pricefix' ),
- 'type' => 'checkbox',
- 'name' => 'enabledCurrencies',
- 'tooltip' => esc_html__( 'Select extra currenices you wish to use.', 'gravityforms-pricefix' ),
- 'choices' => array(
- array(
- 'label' => esc_html__( '€ - Euro', 'gravityforms-pricefix' ),
- 'name' => 'enableEURO',
- ),
- array(
- 'label' => esc_html__( '$ - US Dollar', 'gravityforms-pricefix' ),
- 'name' => 'enableUSDOLLAR',
- ),
- ),
- ),
- array(
- 'label' => esc_html__( 'Euro Value', 'gravityforms-pricefix' ),
- 'type' => 'text',
- 'name' => 'euroPrice',
- 'tooltip' => esc_html__( 'Enter the value for Euro payments', 'gravityforms-pricefix' ),
- 'class' => 'small',
- //'feedback_callback' => array( $this, 'is_valid_setting' ),
- ),
- array(
- 'label' => esc_html__( 'US Dollar Value', 'gravityforms-pricefix' ),
- 'type' => 'text',
- 'name' => 'usPrice',
- 'tooltip' => esc_html__( 'Enter the value for US Dollar payments', 'gravityforms-pricefix' ),
- 'class' => 'small',
- //'feedback_callback' => array( $this, 'is_valid_setting' ),
- ),
- )
- ),
- );
- }// form_settings_fields
- public function add_to_form( $form_string, $form )
- {
- //$settings = $this->get_form_settings( $form );
- $day = date( 'l' );
- if ( $day == 'Friday' ) {
- $form_string = '<p>We are closed today, please return tomorrow to make your booking.</p>';
- }
- return $form_string;
- }
- }//GFPriceFix
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement