/** * @since 1.7.5 */ function add_hooks() { // If Gravity Forms isn't active or compatibile, stop loading if (false === GravityView_Compatibility::is_valid()) { return; } // Migrate Class require_once GRAVITYVIEW_DIR . 'includes/class-migrate.php'; // Don't load tooltips if on Gravity Forms, otherwise it overrides translations if (!GFForms::is_gravity_page()) { require_once GFCommon::get_base_path() . '/tooltips.php'; } require_once GRAVITYVIEW_DIR . 'includes/admin/metaboxes/class-gravityview-admin-metaboxes.php'; require_once GRAVITYVIEW_DIR . 'includes/admin/entry-list.php'; require_once GRAVITYVIEW_DIR . 'includes/class-change-entry-creator.php'; /** @since 1.6 */ require_once GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-duplicate-view.php'; // Filter Admin messages add_filter('post_updated_messages', array($this, 'post_updated_messages')); add_filter('bulk_post_updated_messages', array($this, 'post_updated_messages')); add_filter('plugin_action_links_' . plugin_basename(GRAVITYVIEW_FILE), array($this, 'plugin_action_links')); add_action('plugins_loaded', array($this, 'backend_actions'), 100); //Hooks for no-conflict functionality add_action('wp_print_scripts', array($this, 'no_conflict_scripts'), 1000); add_action('admin_print_footer_scripts', array($this, 'no_conflict_scripts'), 9); add_action('wp_print_styles', array($this, 'no_conflict_styles'), 1000); add_action('admin_print_styles', array($this, 'no_conflict_styles'), 11); add_action('admin_print_footer_scripts', array($this, 'no_conflict_styles'), 1); add_action('admin_footer', array($this, 'no_conflict_styles'), 1); }
public static function init() { if (basename($_SERVER['PHP_SELF']) == "plugins.php") { //loading translations load_plugin_textdomain('gravityformsmailchimp', FALSE, '/gravityformsmailchimp/languages'); add_action('after_plugin_row_' . self::$path, array('GFMailChimp', 'plugin_row')); //force new remote request for version info on the plugin page self::flush_version_info(); } if (!self::is_gravityforms_supported()) { return; } if (is_admin()) { //loading translations load_plugin_textdomain('gravityformsmailchimp', FALSE, '/gravityformsmailchimp/languages'); add_filter("transient_update_plugins", array('GFMailChimp', 'check_update')); add_filter("site_transient_update_plugins", array('GFMailChimp', 'check_update')); add_action('install_plugins_pre_plugin-information', array('GFMailChimp', 'display_changelog')); // paypal plugin integration hooks add_action("gform_paypal_action_fields", array("GFMailChimp", "add_paypal_settings"), 10, 2); add_filter("gform_paypal_save_config", array("GFMailChimp", "save_paypal_settings")); //creates a new Settings page on Gravity Forms' settings screen if (self::has_access("gravityforms_mailchimp")) { RGForms::add_settings_page("MailChimp", array("GFMailChimp", "settings_page"), self::get_base_url() . "/images/mailchip_wordpress_icon_32.png"); } } //integrating with Members plugin if (function_exists('members_get_capabilities')) { add_filter('members_get_capabilities', array("GFMailChimp", "members_get_capabilities")); } //creates the subnav left menu add_filter("gform_addon_navigation", array('GFMailChimp', 'create_menu')); if (self::is_mailchimp_page()) { //enqueueing sack for AJAX requests wp_enqueue_script(array("sack")); //loading data lib require_once self::get_base_path() . "/data.php"; //loading upgrade lib if (!class_exists("RGMailChimpUpgrade")) { require_once "plugin-upgrade.php"; } //loading Gravity Forms tooltips require_once GFCommon::get_base_path() . "/tooltips.php"; add_filter('gform_tooltips', array('GFMailChimp', 'tooltips')); //runs the setup when version changes self::setup(); } else { if (in_array(RG_CURRENT_PAGE, array("admin-ajax.php"))) { //loading data class require_once self::get_base_path() . "/data.php"; add_action('wp_ajax_rg_update_feed_active', array('GFMailChimp', 'update_feed_active')); add_action('wp_ajax_gf_select_mailchimp_form', array('GFMailChimp', 'select_mailchimp_form')); } else { //handling post submission. add_action("gform_after_submission", array('GFMailChimp', 'export'), 10, 2); //handling paypal fulfillment add_action("gform_paypal_fulfillment", array("GFMailChimp", "paypal_fulfillment"), 10, 4); } } }
/** * Handle requests for form iframes. * * @since 1.0.0 */ public function template_redirect() { global $wp; if (empty($wp->query_vars['gfiframe']) || 'gfembed' != $wp->query_vars['gfiframe'] && 'gfembed.php' != $wp->query_vars['gfiframe']) { return; } $form_id = null; if (!empty($_GET['f'])) { $form_id = absint($_GET['f']); } else { // The request needs an 'f' query arg with the form id. wp_die(esc_html__('Invalid form id.', 'gravity-forms-iframe')); } $form = GFFormsModel::get_form_meta($form_id); $settings = $this->addon->get_form_settings($form); // Make sure the form can be embedded. if (empty($settings['is_enabled']) || !$settings['is_enabled']) { wp_die(esc_html__('Embedding is disabled for this form.', 'gravity-forms-iframe')); } // Disable the toolbar in case the form is embedded on the same domain. show_admin_bar(false); require_once GFCommon::get_base_path() . '/form_display.php'; // Settings may be overridden in the query string (querystring -> form settings -> default). $args = wp_parse_args($_GET, array('dt' => empty($settings['display_title']) ? false : (bool) $settings['display_title'], 'dd' => empty($settings['display_description']) ? false : (bool) $settings['display_description'])); // @todo Need to convert query string values to boolean. $display_title = (bool) $args['dt']; $display_description = (bool) $args['dd']; unset($args); unset($settings); // Templates can be customized in parent or child themes. $templates = array('gravity-forms-iframe-' . $form_id . '.php', 'gravity-forms-iframe.php'); $template = gfiframe_locate_template($templates); include $template; exit; }
public function render_frontend($widget_args, $content = '', $context = '') { if (!$this->pre_render_frontend()) { return; } if (!empty($widget_args['title'])) { echo $widget_args['title']; } // Make sure the class is loaded in DataTables if (!class_exists('GFFormDisplay')) { include_once GFCommon::get_base_path() . '/form_display.php'; } $widget_args['content'] = trim(rtrim($widget_args['content'])); // No custom content if (empty($widget_args['content'])) { do_action('gravityview_log_debug', sprintf('%s[render_frontend]: No content.', get_class($this))); return; } // Add paragraphs? if (!empty($widget_args['wpautop'])) { $widget_args['content'] = wpautop($widget_args['content']); } // Enqueue scripts needed for Gravity Form display, if form shortcode exists. // Also runs `do_shortcode()` $content = GFCommon::gform_do_shortcode($widget_args['content']); // Add custom class $class = !empty($widget_args['custom_class']) ? $widget_args['custom_class'] : ''; $class = gravityview_sanitize_html_class($class); echo '<div class="gv-widget-custom-content ' . $class . '">' . $content . '</div>'; }
public static function init() { //supports logging add_filter('gform_logging_supported', array('GFLimit', 'gform_logging_supported')); if (basename($_SERVER['PHP_SELF']) == 'plugins.php') { //loading translations load_plugin_textdomain('gf-limit', FALSE, dirname(GF_LIMIT_FILE) . '/languages'); } if (!self::is_gravityforms_supported()) { return; } //loading data lib require_once GF_LIMIT_PATH . '/inc/data.php'; // load our limit functions require_once GF_LIMIT_PATH . '/inc/gf_field_sum.php'; if (is_admin()) { //runs the setup when version changes self::setup(); //loading translations load_plugin_textdomain('gf-limit', FALSE, dirname(GF_LIMIT_FILE) . '/languages'); //integrating with Members plugin if (function_exists('members_get_capabilities')) { add_filter('members_get_capabilities', array('GFLimit', 'members_get_capabilities')); } //creates the subnav left menu add_filter('gform_addon_navigation', array('GFLimit', 'gform_addon_navigation')); if (self::is_limit_page()) { //enqueueing sack for AJAX requests wp_enqueue_script(array('sack')); //loading Gravity Forms tooltips require_once GFCommon::get_base_path() . '/tooltips.php'; add_filter('gform_tooltips', array('GFLimit', 'gform_tooltips')); } else { if (in_array(RG_CURRENT_PAGE, array('admin-ajax.php'))) { add_action('wp_ajax_gf_limit_update_feed_active', array('GFLimit', 'gf_limit_update_feed_active')); add_action('wp_ajax_gfp_select_limit_form', array('GFLimit', 'gfp_select_limit_form')); } else { if ('gf_entries' == RGForms::get('page')) { } } } } else { // Load feed data $feeds = GFLimitData::get_feeds(); // Cycle through feeds and add limits to the form foreach ($feeds as $k => $v) { // Enable if active if ($v['is_active']) { // Replace variable strings // {remaining} for remaining tickets // {ordered} for tickets ordered $validation = str_replace('{remaining}', '%2$s', $v['meta']['messages']['validation']); $validation = str_replace('{ordered}', '%1$s', $validation); $remainder = str_replace('{remaining}', '%1$s', $v['meta']['messages']['remainder']); $sold_out = $v['meta']['messages']['sold_out']; new MY_GWLimitBySum(array('form_id' => $v['form_id'], 'field_id' => $v['field_id'], 'limit' => $v['quantity_limit'], 'limit_message' => '<span class="error-notice">' . $sold_out . '</span>', 'validation_message' => $validation, 'remainder_message' => '<span class="remaining">' . $remainder . '</span>')); } } } }
function setUp() { parent::setUp(); $this->AJAX = new GravityView_Ajax(); $this->create_test_nonce(); $this->GravityView_Preset_Business_Data = new GravityView_Preset_Business_Data(); require_once GFCommon::get_base_path() . '/export.php'; }
function bb_click_array_field_input($input, $field, $value, $lead_id, $form_id) { if ($field["type"] == "bb_click_array") { $field_id = IS_ADMIN || $form_id == 0 ? "input_{$id}" : "input_" . $form_id . "_{$id}"; $input_name = $form_id . '_' . $field["id"]; $css = isset($field['cssClass']) ? $field['cssClass'] : ""; $disabled_text = IS_ADMIN && RG_CURRENT_VIEW != "entry" ? "disabled='disabled'" : ""; $amount = ''; $clicked = ''; if (is_array($value)) { $amount = esc_attr(rgget($field["id"] . ".1", $value)); $clicked = rgget($field["id"] . ".5", $value); } $html = "<div id='{$field_id}' class='ginput_container bb-click-array-" . count($field['choices']) . " " . esc_attr($css) . "'>" . "\n"; if (is_array($field["choices"])) { $choice_id = 0; $tabindex = GFCommon::get_tabindex(); foreach ($field["choices"] as $choice) { $id = $field["id"] . '_' . $choice_id; $field_value = !empty($choice["value"]) || rgar($field, "enableChoiceValue") ? $choice["value"] : $choice["text"]; if (rgblank($amount) && RG_CURRENT_VIEW != "entry") { $active = rgar($choice, "isSelected") ? "checked='checked'" : ""; } else { $active = RGFormsModel::choice_value_match($field, $choice, $amount) ? "checked='checked'" : ""; } if ($active) { $amount = $field_value; } $field_class = $active ? 's-active' : 's-passive'; if (rgar($field, 'field_bb_click_array_is_product')) { require_once GFCommon::get_base_path() . '/currency.php'; $currency = new RGCurrency(GFCommon::get_currency()); $field_value = $currency->to_money($field_value); $field_class .= ' s-currency'; } $html .= sprintf('<div data-clickarray-value="%s" data-choice-id="%s" class="s-html-wrapper %s" id="%s">', esc_attr($field_value), $choice_id, $field_class, $id); $html .= sprintf('<div class="s-html-value">%s</div>', $field_value); $html .= sprintf("<label for='choice_%s' id='label_%s'>%s</label>", $id, $id, $choice["text"]); $html .= '</div>'; $choice_id++; } $onblur = !IS_ADMIN ? 'if(jQuery(this).val().replace(" ", "") == "") { jQuery(this).val("' . $other_default_value . '"); }' : ''; $onkeyup = empty($field["conditionalLogicFields"]) || IS_ADMIN ? '' : "onchange='gf_apply_rules(" . $field["formId"] . "," . GFCommon::json_encode($field["conditionalLogicFields"]) . ");' onkeyup='clearTimeout(__gf_timeout_handle); __gf_timeout_handle = setTimeout(\"gf_apply_rules(" . $field["formId"] . "," . GFCommon::json_encode($field["conditionalLogicFields"]) . ")\", 300);'"; $value_exists = RGFormsModel::choices_value_match($field, $field["choices"], $value); $other_label = empty($field['field_bb_click_array_other_label']) ? 'My Best Gift' : $field['field_bb_click_array_other_label']; $other_class = rgar($field, 'enableOtherChoice') ? '' : 'hide'; $html .= "<label for='input_{$field["formId"]}_{$field["id"]}_1' class='ginput_bb_click_array_other_label " . $other_class . "'>" . $other_label . "</label>"; $other_class .= rgar($field, 'field_bb_click_array_is_product') ? ' ginput_amount gfield_price gfield_price_' . $field['formId'] . '_' . $field['id'] . '_1 gfield_product_' . $field['formId'] . '_' . $field['id'] . '_1' : ''; $html .= "<input id='input_{$field["formId"]}_{$field["id"]}_1' name='input_{$field["id"]}_1' type='text' value='" . esc_attr($amount) . "' class='ginput_bb ginput_click_array_other " . $other_class . " " . $field['size'] . "' onblur='{$onblur}' {$tabindex} {$onkeyup} {$disabled_text}>"; $html .= "<input id='input_{$field["formId"]}_{$field["id"]}_5' name='input_{$field["id"]}_5' type='hidden' value='" . esc_attr($clicked) . "' class='ginput_bb ginput_click_array_clicked'>"; } $html .= "</div>"; return $html; } return $input; }
public static function init() { //supports logging add_filter("gform_logging_supported", array("GFZapier", "set_logging_supported")); if (basename($_SERVER['PHP_SELF']) == "plugins.php") { //loading translations load_plugin_textdomain('gravityformszapier', FALSE, '/gravityformszapier/languages'); add_action('after_plugin_row_' . self::$path, array('GFZapier', 'plugin_row')); //force new remote request for version info on the plugin page self::flush_version_info(); } if (!self::is_gravityforms_supported()) { return; } //loading data lib require_once self::get_base_path() . "/data.php"; if (is_admin()) { //loading translations load_plugin_textdomain('gravityformszapier', FALSE, '/gravityformszapier/languages'); add_filter("transient_update_plugins", array('GFZapier', 'check_update')); add_filter("site_transient_update_plugins", array('GFZapier', 'check_update')); add_action('install_plugins_pre_plugin-information', array('GFZapier', 'display_changelog')); //add item to form settings menu in expand list add_action('gform_form_settings_menu', array("GFZapier", 'add_form_settings_menu')); //add action so that when form is updated, data fields are sent to Zapier add_action("gform_after_save_form", array("GFZapier", 'send_form_updates'), 10, 2); if (RGForms::get("page") == "gf_settings") { //add Zapier link to settings tabs on GF Main Settings page if (self::has_access("gravityforms_zapier")) { RGForms::add_settings_page("Zapier", array("GFZapier", "settings_page"), self::get_base_url() . "/images/zapier_wordpress_icon_32.png"); } } if (RGForms::get("subview") == "gravityformszapier") { //add page Zapier link will go to add_action("gform_form_settings_page_gravityformszapier", array("GFZapier", 'zapier_page')); //loading upgrade lib if (!class_exists("GFZapierUpgrade")) { require_once "plugin-upgrade.php"; } //loading Gravity Forms tooltips require_once GFCommon::get_base_path() . "/tooltips.php"; add_filter('gform_tooltips', array('GFZapier', 'tooltips')); } //runs the setup when version changes self::setup(); } else { // ManageWP premium update filters add_filter('mwp_premium_update_notification', array('GFZapier', 'premium_update_push')); add_filter('mwp_premium_perform_update', array('GFZapier', 'premium_update')); add_action("gform_after_submission", array("GFZapier", "send_form_data_to_zapier"), 10, 2); } //integrating with Members plugin if (function_exists('members_get_capabilities')) { add_filter('members_get_capabilities', array("GFZapier", "members_get_capabilities")); } }
public function validate($value, $form) { if (!class_exists('RGCurrency')) { require_once GFCommon::get_base_path() . '/currency.php'; } $price = GFCommon::to_number($value); if (!rgblank($value) && ($price === false || $price < 0)) { $this->failed_validation = true; $this->validation_message = empty($this->errorMessage) ? __('Please enter a valid amount.', 'gravityforms') : $this->errorMessage; } }
public function get_value_save_entry($value, $form, $input_name, $lead_id, $lead) { // ignore submitted value and recalculate price in backend list($prefix, $field_id, $input_id) = rgexplode('_', $input_name, 3); if ($input_id == 2) { require_once GFCommon::get_base_path() . '/currency.php'; $currency = new RGCurrency(GFCommon::get_currency()); $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead; $value = $currency->to_money(GFCommon::calculate($this, $form, $lead)); } return $value; }
public function init() { add_action('admin_menu', array('TemplateMerge', 'templatemerge_plugin_admin_actions')); require_once self::get_base_path() . DIRECTORY_SEPARATOR . "data.php"; add_action('wp_ajax_templatemerge_update_feed_active', array('TemplateMerge', 'update_templatemerge_active')); add_action('wp_ajax_templatemerge_update_tagmapping_status', array('TemplateMerge', 'update_tagmapping_status')); add_action('wp_ajax_letters_update_feed_active', array('TemplateMerge', 'update_letters_active')); add_action('wp_ajax_invoices_update_feed_active', array('TemplateMerge', 'update_invoices_active')); add_action('wp_ajax_gf_select_form', array('TemplateMerge', 'select_form_field')); add_action('wp_ajax_gf_select_form_setting', array('TemplateMerge', 'setting_select_form_field')); require_once GFCommon::get_base_path() . DIRECTORY_SEPARATOR . "tooltips.php"; add_filter('gform_tooltips', array('TemplateMerge', 'tooltips')); }
function getFormInitScripts() { if (intval(get_query_var('getFormInitScripts')) != '') { require_once GFCommon::get_base_path() . '/form_display.php'; $form = GFAPI::get_form(get_query_var('getFormInitScripts')); $field_values = array(); // the array of parameter names and values if any fields are being populated GFFormDisplay::register_form_init_scripts($form, $field_values); $form_string = GFFormDisplay::get_form_init_scripts($form); echo strip_tags($form_string); exit; } }
public function init() { if (!GFCommon::current_user_can_any($this->_capabilities)) { return; } //add top toolbar menu item add_filter("gform_toolbar_menu", array($this, 'add_toolbar_menu_item'), 10, 2); //add custom form action add_filter("gform_form_actions", array($this, 'add_form_action'), 10, 2); //add the results view add_action("gform_entries_view", array($this, 'add_view'), 10, 2); add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts')); require_once GFCommon::get_base_path() . "/tooltips.php"; add_filter('gform_tooltips', array($this, 'add_tooltips')); }
/** * @since 1.15 * @return void */ private function include_required_files() { // Migrate Class require_once GRAVITYVIEW_DIR . 'includes/class-migrate.php'; // Don't load tooltips if on Gravity Forms, otherwise it overrides translations if (class_exists('GFCommon') && class_exists('GFForms') && !GFForms::is_gravity_page()) { require_once GFCommon::get_base_path() . '/tooltips.php'; } require_once GRAVITYVIEW_DIR . 'includes/admin/metaboxes/class-gravityview-admin-metaboxes.php'; require_once GRAVITYVIEW_DIR . 'includes/admin/entry-list.php'; require_once GRAVITYVIEW_DIR . 'includes/class-change-entry-creator.php'; /** @since 1.15 **/ require_once GRAVITYVIEW_DIR . 'includes/admin/class-gravityview-support-port.php'; /** @since 1.6 */ require_once GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-duplicate-view.php'; }
public function init() { //add top toolbar menu item add_filter("gform_toolbar_menu", array($this, 'add_toolbar_menu_item'), 10, 2); //add custom form action add_filter("gform_form_actions", array($this, 'add_form_action'), 10, 2); //add the gf_quiz_results view add_action("gform_view", array($this, 'add_view'), 10, 2); add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts')); require_once GFCommon::get_base_path() . "/tooltips.php"; add_filter('gform_tooltips', array($this, 'add_tooltips')); if (RG_CURRENT_PAGE == "admin-ajax.php") { if (rgpost("view") == "gf_results_" . $this->_slug) { add_action('wp_ajax_gresults_get_results_gf_results_' . $this->_slug, array($this, 'ajax_get_results')); } } }
public function get_value_submission($field_values, $get_from_post_global_var = true) { $value = $this->get_input_value_submission('input_' . $this->id, $this->inputName, $field_values, $get_from_post_global_var); $value = trim($value); if ($this->numberFormat == 'currency') { require_once GFCommon::get_base_path() . '/currency.php'; $currency = new RGCurrency(GFCommon::get_currency()); $value = $currency->to_number($value); } else { if ($this->numberFormat == 'decimal_comma') { $value = GFCommon::clean_number($value, 'decimal_comma'); } else { if ($this->numberFormat == 'decimal_dot') { $value = GFCommon::clean_number($value, 'decimal_dot'); } } } return $value; }
public function app_settings_tab() { require_once GFCommon::get_base_path() . '/tooltips.php'; $icon = $this->app_settings_icon(); if (empty($icon)) { $icon = '<i class="fa fa-cogs"></i>'; } ?> <h3><span><?php echo $icon; ?> <?php echo $this->app_settings_title(); ?> </span></h3> <?php if ($this->maybe_uninstall()) { ?> <div class="push-alert-gold" style="border-left: 1px solid #E6DB55; border-right: 1px solid #E6DB55;"> <?php printf(esc_html_x('%s has been successfully uninstalled. It can be re-activated from the %splugins page%s.', 'Displayed on the settings page after uninstalling a Gravity Flow extension.', 'gravityforms'), esc_html($this->_title), "<a href='plugins.php'>", '</a>'); ?> </div> <?php } else { //saves settings page if save button was pressed $this->maybe_save_app_settings(); //reads main addon settings $settings = $this->get_app_settings(); $this->set_settings($settings); //reading addon fields $sections = $this->app_settings_fields(); GFCommon::display_admin_message(); //rendering settings based on fields and current settings $this->render_settings($sections); $this->render_uninstall(); } }
public function init() { if (!GFCommon::current_user_can_any($this->_capabilities)) { return; } // is any GF page if (GFForms::is_gravity_page()) { // add top toolbar menu item add_filter('gform_toolbar_menu', array($this, 'add_toolbar_menu_item'), 10, 2); // add custom form action add_filter('gform_form_actions', array($this, 'add_form_action'), 10, 2); } // is results page if (rgget('view') == "gf_results_{$this->_slug}") { // add the results view add_action('gform_entries_view', array($this, 'add_view'), 10, 2); add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts')); // tooltips require_once GFCommon::get_base_path() . '/tooltips.php'; add_filter('gform_tooltips', array($this, 'add_tooltips')); } }
public static function refresh_field_preview() { check_ajax_referer('rg_refresh_field_preview', 'rg_refresh_field_preview'); $field_json = stripslashes_deep($_POST['field']); $field_properties = GFCommon::json_decode($field_json, true); $field = GF_Fields::create($field_properties); $form_id = absint($_POST['formId']); $form = GFFormsModel::get_form_meta($form_id); require_once GFCommon::get_base_path() . '/form_display.php'; $field_content = GFFormDisplay::get_field_content($field, '', true, $form_id, $form); $args['fieldString'] = $field_content; $args_json = json_encode($args); die($args_json); }
public static function get_calculations_init_script($form) { require_once GFCommon::get_base_path() . '/currency.php'; $formula_fields = array(); foreach ($form['fields'] as $field) { if (!rgar($field, 'enableCalculation') || !rgar($field, 'calculationFormula')) { continue; } $formula_fields[] = array('field_id' => $field['id'], 'formula' => rgar($field, 'calculationFormula'), 'rounding' => rgar($field, 'calculationRounding'), 'numberFormat' => rgar($field, 'numberFormat')); } if (empty($formula_fields)) { return ''; } $script = 'new GFCalc(' . $form['id'] . ', ' . GFCommon::json_encode($formula_fields) . ');'; return $script; }
/** * Generates a map of fields IDs and their corresponding number formats used by the GFCalc JS object for correctly * converting field values to clean numbers. * * - Number fields have a 'numberFormat' setting (w/ UI). * - Single-input product fields (i.e. 'singleproduct', 'calculation', 'price' and 'hiddenproduct') should default to * the number format of the configured currency. * - All other product fields will default to 'decimal_dot' for the number format. * - All other fields will have no format (false) and inherit the format of the formula field when the formula is * calculated. * * @param mixed $form * @return string */ public static function get_number_formats_script($form) { require_once GFCommon::get_base_path() . '/currency.php'; $number_formats = array(); $currency = RGCurrency::get_currency(GFCommon::get_currency()); foreach ($form['fields'] as $field) { // default format is false, fields with no format will inherit the format of the formula field when calculated $format = false; switch (GFFormsModel::get_input_type($field)) { case 'number': $format = $field->numberFormat ? $field->numberFormat : 'decimal_dot'; break; case 'singleproduct': case 'calculation': case 'price': case 'hiddenproduct': case 'singleshipping': $format = $currency['decimal_separator'] == ',' ? 'decimal_comma' : 'decimal_dot'; break; default: // we check above for all single-input product types, for all other products, assume decimal format if (in_array($field->type, array('product', 'option', 'shipping'))) { $format = 'decimal_dot'; } } $number_formats[$field->id] = $format; } return 'gf_global["number_formats"][' . $form['id'] . '] = ' . json_encode($number_formats) . ';'; }
/** * Returns the physical path of the Add-On Framework root folder * * @return string */ private static function _get_base_path() { $folder = basename(dirname(__FILE__)); return GFCommon::get_base_path() . "/includes/" . $folder; }
public static function maybe_thankyou_page() { if (!self::is_gravityforms_supported()) { return; } if ($str = RGForms::get("gf_paypal_return")) { $str = base64_decode($str); parse_str($str, $query); if (wp_hash("ids=" . $query["ids"]) == $query["hash"]) { list($form_id, $lead_id) = explode("|", $query["ids"]); $form = RGFormsModel::get_form_meta($form_id); $lead = RGFormsModel::get_lead($lead_id); if (!class_exists("GFFormDisplay")) { require_once GFCommon::get_base_path() . "/form_display.php"; } $confirmation = GFFormDisplay::handle_confirmation($form, $lead, false); if (is_array($confirmation) && isset($confirmation["redirect"])) { header("Location: {$confirmation["redirect"]}"); exit; } GFFormDisplay::$submission[$form_id] = array("is_confirmation" => true, "confirmation_message" => $confirmation, "form" => $form, "lead" => $lead); } } }
?> </head> <body onload="window.print();"> <div id="print_preview_hdr" style="display:none"> <div><span class="actionlinks"><a href="javascript:;" onclick="window.print();" class="header-print-link">print this page</a> | <a href="javascript:window.close()" class="close_window"><?php _e("close window", "gravityforms"); ?> </a></span><?php _e("Print Preview", "gravityforms"); ?> </div> </div> <div id="view-container"> <?php require_once GFCommon::get_base_path() . "/entry_detail.php"; foreach ($lead_ids as $lead_id) { $lead = RGFormsModel::get_lead($lead_id); do_action("gform_print_entry_header", $form, $lead); GFEntryDetail::lead_detail_grid($form, $lead); if (rgget('notes')) { $notes = RGFormsModel::get_lead_notes($lead["id"]); if (!empty($notes)) { GFEntryDetail::notes_grid($notes, false); } } // output entry divider/page break if (array_search($lead_id, $lead_ids) < count($lead_ids) - 1) { echo '<div class="print-hr ' . $page_break . '"></div>'; } do_action("gform_print_entry_footer", $form, $lead);
public static function enqueue_form_scripts($form_id, $is_ajax = false) { require_once GFCommon::get_base_path() . '/form_display.php'; $form = RGFormsModel::get_form_meta($form_id); GFFormDisplay::enqueue_form_scripts($form, $is_ajax); $addons = GFAddOn::get_registered_addons(); foreach ($addons as $addon) { $a = call_user_func(array($addon, 'get_instance')); $a->enqueue_scripts($form, $is_ajax); } }
public static function init() { //supports logging add_filter("gform_logging_supported", array("GFUser", "set_logging_supported")); //loading translations load_plugin_textdomain('gravityformsuserregistration', FALSE, '/gravityformsuserregistration/languages'); if (basename($_SERVER['PHP_SELF']) == "plugins.php") { add_action('after_plugin_row_' . self::$path, array('GFUser', 'plugin_row')); } if (!self::is_gravityforms_supported()) { return; } if (is_admin()) { //runs the setup when version changes self::setup(); // automatic upgrade hooks add_filter("transient_update_plugins", array('GFUser', 'check_update')); add_filter("site_transient_update_plugins", array('GFUser', 'check_update')); add_action('install_plugins_pre_plugin-information', array('GFUser', 'display_changelog')); add_action('gform_after_check_update', array("GFUser", 'flush_version_info')); // paypal plugin integration hooks add_action("gform_paypal_add_option_group", array("GFUser", "add_paypal_user_registration_options"), 10, 2); add_filter("gform_paypal_save_config", array("GFUser", "save_paypal_user_config")); // integrating with Members plugin if (function_exists('members_get_capabilities')) { add_filter('members_get_capabilities', array("GFUser", "members_get_capabilities")); } // creates the subnav left menu add_filter("gform_addon_navigation", array('GFUser', 'create_menu')); // activate password field add_filter("gform_enable_password_field", create_function("", "return true;")); // process users from unspammed entries add_action("gform_update_status", array("GFUser", "gf_process_user"), 10, 3); add_action("gform_paypal_fulfillment", array("GFUser", "add_paypal_user"), 10, 8); if (self::is_user_registration_page()) { //enqueueing sack for AJAX requests wp_enqueue_script(array("sack")); wp_enqueue_script("jquery_json", self::get_base_url() . "/js/jquery.json-1.3.js", array("jquery"), self::$version); //loading data lib require_once self::get_base_path() . "/data.php"; self::include_upgrade_library(); //loading Gravity Forms tooltips require_once GFCommon::get_base_path() . "/tooltips.php"; add_filter('gform_tooltips', array('GFUser', 'tooltips')); } else { if (in_array(RG_CURRENT_PAGE, array("admin-ajax.php"))) { //loading data class require_once self::get_base_path() . "/data.php"; add_action('wp_ajax_rg_user_update_feed_active', array('GFUser', 'update_feed_active')); add_action('wp_ajax_gf_user_select_form', array('GFUser', 'select_form')); add_action('wp_ajax_gf_user_get_available_forms', array('GFUser', 'get_available_forms')); add_action('wp_ajax_gf_user_activate', array('GFUser', 'activate_user')); } else { if (RGForms::get("page") == "gf_settings") { // add settings page RGForms::add_settings_page("User Registration", array("GFUser", "settings_page"), self::get_base_url() . "/images/user-registration-icon-32.png"); } else { if (rgget('page') == 'gf_entries') { // add activate button to entry list page add_action('gform_entry_info', array('GFUser', 'entry_activation_button'), 10, 2); } } } } } else { // add paypal ipn hooks add_action("gform_paypal_fulfillment", array("GFUser", "add_paypal_user"), 10, 8); add_action("gform_subscription_canceled", array("GFUser", "downgrade_paypal_user"), 10, 8); // ManageWP premium update filters add_filter('mwp_premium_update_notification', array('GFUser', 'premium_update_push')); add_filter('mwp_premium_perform_update', array('GFUser', 'premium_update')); } //loading data class require_once self::get_base_path() . "/data.php"; // handling post submission add_action('gform_pre_submission', array(__CLASS__, 'handle_existing_images_submission')); add_action("gform_after_submission", array("GFUser", "gf_create_user"), 10, 2); add_filter("gform_validation", array("GFUser", "user_registration_validation")); // custom registration form page add_action('wp_loaded', array('GFUser', 'custom_registration_page')); // add support for prepopulating update feeds add_action('gform_pre_render', array('GFUser', 'maybe_prepopulate_form')); // buddypress hooks if (self::is_bp_active()) { self::add_buddypress_hooks(); } // multisite hooks if (is_multisite()) { self::add_multisite_hooks(); } }
/** * Prepare the value before saving it to the lead. * * @param mixed $form * @param mixed $field * @param mixed $value * @param mixed $input_name * @param mixed $lead_id the current lead ID, used for fields that are processed after other fields have been saved (ie Total, Calculations) * @param mixed $lead passed by the RGFormsModel::create_lead() method, lead ID is not available for leads created by this function */ public static function prepare_value($form, $field, $value, $input_name, $lead_id, $lead = array()) { $form_id = $form["id"]; $input_type = self::get_input_type($field); switch ($input_type) { case "total": $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead; $value = GFCommon::get_order_total($form, $lead); break; case "calculation": // ignore submitted value and recalculate price in backend list(, , $input_id) = rgexplode("_", $input_name, 3); if ($input_id == 2) { require_once GFCommon::get_base_path() . '/currency.php'; $currency = new RGCurrency(GFCommon::get_currency()); $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead; $value = $currency->to_money(GFCommon::calculate($field, $form, $lead)); } break; case "phone": if ($field["phoneFormat"] == "standard" && preg_match('/^\\D?(\\d{3})\\D?\\D?(\\d{3})\\D?(\\d{4})$/', $value, $matches)) { $value = sprintf("(%s)%s-%s", $matches[1], $matches[2], $matches[3]); } break; case "time": if (!is_array($value) && !empty($value)) { preg_match('/^(\\d*):(\\d*) ?(.*)$/', $value, $matches); $value = array(); $value[0] = $matches[1]; $value[1] = $matches[2]; $value[2] = rgar($matches, 3); } $hour = empty($value[0]) ? "0" : strip_tags($value[0]); $minute = empty($value[1]) ? "0" : strip_tags($value[1]); $ampm = strip_tags(rgar($value, 2)); if (!empty($ampm)) { $ampm = " {$ampm}"; } if (!(empty($hour) && empty($minute))) { $value = sprintf("%02d:%02d%s", $hour, $minute, $ampm); } else { $value = ""; } break; case "date": $value = self::prepare_date($field["dateFormat"], $value); break; case "post_image": $url = self::get_fileupload_value($form_id, $input_name); $image_title = isset($_POST["{$input_name}_1"]) ? strip_tags($_POST["{$input_name}_1"]) : ""; $image_caption = isset($_POST["{$input_name}_4"]) ? strip_tags($_POST["{$input_name}_4"]) : ""; $image_description = isset($_POST["{$input_name}_7"]) ? strip_tags($_POST["{$input_name}_7"]) : ""; $value = !empty($url) ? $url . "|:|" . $image_title . "|:|" . $image_caption . "|:|" . $image_description : ""; break; case "fileupload": $value = self::get_fileupload_value($form_id, $input_name); break; case "number": $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead; $value = GFCommon::has_field_calculation($field) ? GFCommon::round_number(GFCommon::calculate($field, $form, $lead), rgar($field, "calculationRounding")) : GFCommon::clean_number($value, rgar($field, "numberFormat")); //return the value as a string when it is zero and a calc so that the "==" comparison done when checking if the field has changed isn't treated as false if (GFCommon::has_field_calculation($field) && $value == 0) { $value = "0"; } break; case "website": if ($value == "http://") { $value = ""; } break; case "list": if (GFCommon::is_empty_array($value)) { $value = ""; } else { $value = self::create_list_array($field, $value); $value = serialize($value); } break; case "radio": if (rgar($field, 'enableOtherChoice') && $value == 'gf_other_choice') { $value = rgpost("input_{$field['id']}_other"); } break; case "multiselect": $value = empty($value) ? "" : implode(",", $value); break; case "creditcard": //saving last 4 digits of credit card list($input_token, $field_id_token, $input_id) = rgexplode("_", $input_name, 3); if ($input_id == "1") { $value = str_replace(" ", "", $value); $card_number_length = strlen($value); $value = substr($value, -4, 4); $value = str_pad($value, $card_number_length, "X", STR_PAD_LEFT); } else { if ($input_id == "4") { $card_number = rgpost("input_{$field_id_token}_1"); $card_type = GFCommon::get_card_type($card_number); $value = $card_type ? $card_type["name"] : ""; } else { $value = ""; } } break; default: //allow HTML for certain field types $allow_html = in_array($field["type"], array("post_custom_field", "post_title", "post_content", "post_excerpt", "post_tags")) || in_array($input_type, array("checkbox", "radio")) ? true : false; $allowable_tags = apply_filters("gform_allowable_tags_{$form_id}", apply_filters("gform_allowable_tags", $allow_html, $field, $form_id), $field, $form_id); if ($allowable_tags !== true) { $value = strip_tags($value, $allowable_tags); } break; } // special format for Post Category fields if ($field['type'] == 'post_category') { $full_values = array(); if (!is_array($value)) { $value = explode(',', $value); } foreach ($value as $cat_id) { $cat = get_term($cat_id, 'category'); $full_values[] = !is_wp_error($cat) && is_object($cat) ? $cat->name . ":" . $cat_id : ""; } $value = implode(',', $full_values); } //do not save price fields with blank price if (rgar($field, "enablePrice")) { $ary = explode("|", $value); $label = count($ary) > 0 ? $ary[0] : ""; $price = count($ary) > 1 ? $ary[1] : ""; $is_empty = strlen(trim($price)) <= 0; if ($is_empty) { $value = ""; } } return $value; }
/** * Displays the installation wizard on single site installations and on multisite * * @return bool Was the installation wizard displayed? */ public static function maybe_display_installation_wizard() { if (defined('GF_LICENSE_KEY') && is_multisite() && !is_main_site()) { return false; } $pending_installation = get_option('gform_pending_installation') || isset($_GET['gform_installation_wizard']); if ($pending_installation) { require_once GFCommon::get_base_path() . '/includes/wizard/class-gf-installation-wizard.php'; $wizard = new GF_Installation_Wizard(); $result = $wizard->display(); return $result; } }
public function ajax_get_results() { // tooltips require_once GFCommon::get_base_path() . '/tooltips.php'; add_filter('gform_tooltips', array($this, 'add_tooltips')); $output = array(); $html = ''; $form_id = rgpost('id'); $form = GFFormsModel::get_form_meta($form_id); $form = gf_apply_filters(array('gform_form_pre_results', $form_id), $form); $search_criteria['status'] = 'active'; $fields = $this->get_fields($form); $total_entries = GFAPI::count_entries($form_id, $search_criteria); if ($total_entries == 0) { $html = esc_html__('No results.', 'gravityforms'); } else { $search_criteria = array(); $search_criteria['field_filters'] = GFCommon::get_field_filters_from_post($form); $start_date = rgpost('start'); $end_date = rgpost('end'); if ($start_date) { $search_criteria['start_date'] = $start_date; } if ($end_date) { $search_criteria['end_date'] = $end_date; } $search_criteria['status'] = 'active'; $output['s'] = http_build_query($search_criteria); $state_array = null; if (isset($_POST['state'])) { $state = $_POST['state']; $posted_check_sum = rgpost('checkSum'); $generated_check_sum = self::generate_checksum($state); $state_array = json_decode(base64_decode($state), true); if ($generated_check_sum !== $posted_check_sum) { $output['status'] = 'complete'; $output['html'] = esc_html__('There was an error while processing the entries. Please contact support.', 'gravityforms'); echo json_encode($output); die; } } $data = isset($this->_callbacks['data']) ? call_user_func($this->_callbacks['data'], $form, $fields, $search_criteria, $state_array) : $this->get_results_data($form, $fields, $search_criteria, $state_array); $entry_count = $data['entry_count']; if ('incomplete' === rgar($data, 'status')) { $state = base64_encode(json_encode($data)); $output['status'] = 'incomplete'; $output['stateObject'] = $state; $output['checkSum'] = self::generate_checksum($state); $output['html'] = sprintf(esc_html__('Entries processed: %1$d of %2$d', 'gravityforms'), rgar($data, 'offset'), $entry_count); echo json_encode($output); die; } if ($total_entries > 0) { $html = isset($this->_callbacks['markup']) ? call_user_func($this->_callbacks['markup'], $html, $data, $form, $fields) : ''; if (empty($html)) { foreach ($fields as $field) { $field_id = $field->id; $html .= "<div class='gresults-results-field' id='gresults-results-field-{$field_id}'>"; $html .= "<div class='gresults-results-field-label'>" . esc_html(GFCommon::get_label($field)) . '</div>'; $html .= '<div>' . self::get_field_results($form_id, $data, $field, $search_criteria) . '</div>'; $html .= '</div>'; } } } else { $html .= esc_html__('No results', 'gravityforms'); } } $output['html'] = $html; $output['status'] = 'complete'; $output['searchCriteria'] = $search_criteria; echo json_encode($output); die; }
public static function ajax_qrcode() { require_once GFCommon::get_base_path() . "/includes/phpqrcode/phpqrcode.php"; $settings = get_option("gravityformsaddon_gravityformswebapi_settings"); if (empty($settings)) { die; } $data["site"] = site_url(); $data["public_key"] = rgar($settings, "public_key"); $data["private_key"] = rgar($settings, "private_key"); QRcode::png(json_encode($data), false, QR_ECLEVEL_L, 4, 1, false); die; }