本文整理汇总了PHP中GFCommon类的典型用法代码示例。如果您正苦于以下问题:PHP GFCommon类的具体用法?PHP GFCommon怎么用?PHP GFCommon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GFCommon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* Loads the matching meta data for the currently set form id
* @return boolean true on success and false on failure
*/
public function load()
{
if (!defined('WPINC') || !$this->_post_id || !class_exists('GFAPI')) {
return false;
}
$lead = \GFAPI::get_entry($this->_post_id);
$form = \GFAPI::get_form($lead['form_id']);
$values = array();
foreach ($form['fields'] as $field) {
if (isset($field["inputs"]) && is_array($field['inputs'])) {
foreach ($field['inputs'] as $input) {
// Extract best label
$key = $input['label'] ? $input['label'] : \GFCommon::get_label($field, (string) $input["id"]);
// Redundant formatting
$key = strtolower(str_replace(array(' '), array('_'), $key));
$value = isset($lead[(string) $input['id']]) ? $lead[(string) $input['id']] : "";
$values[$key] = htmlentities(stripslashes($value), ENT_QUOTES);
}
} elseif (!rgar($field, 'displayOnly')) {
// Extract best label
$key = isset($field['adminLabel']) && $field['adminLabel'] != "" ? $field['adminLabel'] : ($field['label'] ? $field['label'] : \GFCommon::get_label($field));
// More redundant formatting
$key = strtolower(str_replace(array(' '), array('_'), $key));
$value = isset($lead[$field['id']]) ? $lead[$field['id']] : "";
$values[$key] = htmlentities(stripslashes($value), ENT_QUOTES);
}
}
try {
$this->assign($values);
} catch (Exception $e) {
$error = $e->getMessage();
}
return true;
}
示例2: template_redirect
/**
* 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;
}
示例3: output_data
function output_data($pdf, $lead = array(), $form = array(), $fieldData = array())
{
$pdf->AddPage();
$dataArray = array(array('Project ID #', 3, 'text'), array('Project Name', 38, 'text'), array('Name of person responsible for fire safety at your exhibit', 21, 'text'), array('Their Email', 23, 'text'), array('Their Phone', 24, 'text'), array('Description', 37, 'textarea'), array('Describe your fire safety concerns', 19, 'textarea'), array('Describe how you plan to keep your exhibit safe', 27, 'textarea'), array('Who will be assisting at your exhibit to keep it safe', 20, 'text'), array('Placement Requirements', 7, 'textarea'), array('What is burning', 10, 'text'), array('What is the fuel source', 11, 'text'), array('how much is fuel is burning and in what time period', 12, 'textarea'), array('how much fuel will you have at the event, including tank sizes', 13, 'textarea'), array('where and how is the fuel stored', 14, 'text'), array('Does the valve have an electronic propane sniffer', 15, 'text'), array('Other suppression devices', 16, 'textarea'), array('Do you have insurance?', 18, 'text'), array('Additional comments', 28, 'textarea'), array('Are you 18 years or older?', 30, 'text'), array('Signed', 32, 'text'), array('I am the Parent and/or Legal Guardian of', 33, 'text'), array('Date', 34, 'text'));
$pdf->SetFillColor(190, 210, 247);
$lineheight = 6;
foreach ($dataArray as $data) {
$fieldID = $data[1];
if (isset($fieldData[$fieldID])) {
$field = $fieldData[$fieldID];
$value = RGFormsModel::get_lead_field_value($lead, $field);
if (RGFormsModel::get_input_type($field) != 'email') {
$display_value = GFCommon::get_lead_field_display($field, $value);
$display_value = apply_filters('gform_entry_field_value', $display_value, $field, $lead, $form);
} else {
$display_value = $value;
}
} else {
$display_value = '';
}
$pdf->MultiCell(0, $lineheight, $data[0] . ': ');
$pdf->MultiCell(0, $lineheight, $display_value, 0, 'L', true);
$pdf->Ln();
}
}
示例4: add_pending_referral
/**
* Add pending referral
*
* @access public
* @uses GFFormsModel::get_lead()
* @uses GFCommon::get_product_fields()
* @uses GFCommon::to_number()
*
* @param array $entry
* @param array $form
*/
public function add_pending_referral($entry, $form)
{
if ($this->was_referred()) {
// Do some craziness to determine the price (this should be easy but is not)
$desc = '';
$entry = GFFormsModel::get_lead($entry['id']);
$products = GFCommon::get_product_fields($form, $entry);
$total = 0;
foreach ($products['products'] as $key => $product) {
$desc .= $product['name'];
if ($key + 1 < count($products)) {
$description .= ', ';
}
$price = GFCommon::to_number($product['price']);
if (is_array(rgar($product, 'options'))) {
$count = sizeof($product['options']);
$index = 1;
foreach ($product['options'] as $option) {
$price += GFCommon::to_number($option['price']);
}
}
$subtotal = floatval($product['quantity']) * $price;
$total += $subtotal;
}
$total += floatval($products['shipping']['price']);
$referral_total = $this->calculate_referral_amount($total, $entry['id']);
$this->insert_pending_referral($referral_total, $entry['id'], $desc);
}
}
示例5: __construct
function __construct()
{
//load text domains
GFCommon::load_gf_text_domain('gravityforms');
$description = esc_html__('Gravity Forms Widget', 'gravityforms');
WP_Widget::__construct('gform_widget', __('Form', 'gravityforms'), array('classname' => 'gform_widget', 'description' => $description), array('width' => 200, 'height' => 250, 'id_base' => 'gform_widget'));
}
示例6: acquirer_field_input
/**
* Acquirrer field input
*
* @param string $field_content
* @param string $field
* @param string $value
* @param string $lead_id
* @param string $form_id
*/
public static function acquirer_field_input($field_content, $field, $value, $lead_id, $form_id)
{
$type = RGFormsModel::get_input_type($field);
if (Pronamic_WP_Pay_Extensions_GravityForms_IssuerDropDown::TYPE === $type) {
$id = $field['id'];
$field_id = IS_ADMIN || 0 === $form_id ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
$class_suffix = RG_CURRENT_VIEW === 'entry' ? '_admin' : '';
$size = rgar($field, 'size');
$class = $size . $class_suffix;
$css_class = trim(esc_attr($class) . ' gfield_ideal_acquirer_select');
$tab_index = GFCommon::get_tabindex();
$disabled_text = IS_ADMIN && 'entry' !== RG_CURRENT_VIEW ? "disabled='disabled'" : '';
$html = '';
$feed = get_pronamic_gf_pay_conditioned_feed_by_form_id($form_id, true);
/**
* Developing warning:
* Don't use single quotes in the HTML you output, it is buggy in combination with SACK
*/
if (IS_ADMIN) {
if (null === $feed) {
$html .= sprintf("<a class='ideal-edit-link' href='%s' target='_blank'>%s</a>", add_query_arg('post_type', 'pronamic_pay_gf', admin_url('post-new.php')), __('Create iDEAL feed', 'pronamic_ideal'));
} else {
$html .= sprintf("<a class='ideal-edit-link' href='%s' target='_blank'>%s</a>", get_edit_post_link($feed->id), __('Edit iDEAL feed', 'pronamic_ideal'));
}
}
$html_input = '';
$html_error = '';
if (null !== $feed) {
$gateway = Pronamic_WP_Pay_Plugin::get_gateway($feed->config_id);
if ($gateway) {
$issuer_field = $gateway->get_issuer_field();
$error = $gateway->get_error();
if (is_wp_error($error)) {
$html_error .= Pronamic_WP_Pay_Plugin::get_default_error_message();
$html_error .= '<br /><em>' . $error->get_error_message() . '</em>';
} elseif ($issuer_field) {
$choices = $issuer_field['choices'];
$options = Pronamic_WP_HTML_Helper::select_options_grouped($choices, $value);
// Double quotes are not working, se we replace them with an single quote
$options = str_replace('"', '\'', $options);
$html_input = '';
$html_input .= sprintf("<select name='input_%d' id='%s' class='%s' %s %s>", $id, $field_id, $css_class, $tab_index, $disabled_text);
$html_input .= sprintf('%s', $options);
$html_input .= sprintf('</select>');
}
}
}
if ($html_error) {
$html .= sprintf("<div class='gfield_description validation_message'>");
$html .= sprintf('%s', $html_error);
$html .= sprintf('</div>');
} else {
$html .= sprintf("<div class='ginput_container ginput_ideal'>");
$html .= sprintf('%s', $html_input);
$html .= sprintf('</div>');
}
$field_content = $html;
}
return $field_content;
}
示例7: send_webhook
function send_webhook()
{
$entry = $this->get_entry();
$url = $this->url;
$this->log_debug(__METHOD__ . '() - url before replacing variables: ' . $url);
$url = GFCommon::replace_variables($url, $this->get_form(), $entry, true, false, false, 'text');
$this->log_debug(__METHOD__ . '() - url after replacing variables: ' . $url);
$method = strtoupper($this->method);
$body = null;
$headers = array();
if (in_array($method, array('POST', 'PUT'))) {
if ($this->format == 'json') {
$headers = array('Content-type' => 'application/json');
$body = json_encode($entry);
} else {
$headers = array();
$body = $entry;
}
}
$args = array('method' => $method, 'timeout' => 45, 'redirection' => 3, 'blocking' => true, 'headers' => $headers, 'body' => $body, 'cookies' => array());
$args = apply_filters('gravityflow_webhook_args', $args, $entry, $this);
$response = wp_remote_request($url, $args);
$this->log_debug(__METHOD__ . '() - response: ' . print_r($response, true));
if (is_wp_error($response)) {
$step_status = 'error';
} else {
$step_status = 'success';
}
$note = esc_html__('Webhook sent. Url: ' . $url);
$this->add_note($note, 0, 'webhook');
do_action('gravityflow_post_webhook', $response, $args, $entry, $this);
return $step_status;
}
示例8: get_field_content
public function get_field_content($value, $force_frontend_label, $form)
{
if (is_admin()) {
$admin_buttons = $this->get_admin_buttons();
$field_content = "{$admin_buttons}\n\t\t\t\t\t\t\t<div class=\"gf-pagebreak-end gf-pagebreak-container gf-repeater-end\">\n\t\t\t\t\t\t\t\t<div class=\"gf-pagebreak-text-before\">end repeater</div>\n\t\t\t\t\t\t\t\t<div class=\"gf-pagebreak-text-main\"><span>REPEATER</span></div>\n\t\t\t\t\t\t\t\t<div class=\"gf-pagebreak-text-after\">end of repeater</div>\n\t\t\t\t\t\t\t</div>";
} else {
$add_html = $this->add;
$remove_html = $this->remove;
$hideButtons = $this->hideButtons;
$tabindex = GFCommon::get_tabindex();
if (empty($add_html)) {
$add_html = "<img class=\"gf_repeater_add_default\" alt=\"+\" src=\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\">";
}
if (empty($remove_html)) {
$remove_html = "<img class=\"gf_repeater_remove_default\" alt=\"-\" src=\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\">";
}
$field_content = "<div class=\"ginput_container ginput_container_repeater-end\">\n";
if (!$hideButtons) {
$field_content .= "<span class=\"gf_repeater_remove\" {$tabindex}>{$remove_html}</span>";
$field_content .= "<span class=\"gf_repeater_add\" {$tabindex}>{$add_html}</span>";
}
$field_content .= "</div>";
}
return $field_content;
}
示例9: get_field_input
public function get_field_input($form, $value = '', $entry = null)
{
$form_id = $form['id'];
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
$id = (int) $this->id;
$product_name = !is_array($value) || empty($value[$this->id . '.1']) ? esc_attr($this->label) : esc_attr($value[$this->id . '.1']);
$price = !is_array($value) || empty($value[$this->id . '.2']) ? $this->basePrice : esc_attr($value[$this->id . '.2']);
$quantity = is_array($value) ? esc_attr($value[$this->id . '.3']) : '';
if (rgblank($quantity)) {
$quantity = 1;
}
if (empty($price)) {
$price = 0;
}
$price = esc_attr($price);
$has_quantity_field = sizeof(GFCommon::get_product_fields_by_type($form, array('quantity'), $this->id)) > 0;
if ($has_quantity_field) {
$this->disableQuantity = true;
}
$quantity_field = $has_quantity_field ? '' : "<input type='hidden' name='input_{$id}.3' value='" . esc_attr($quantity) . "' id='ginput_quantity_{$form_id}_{$this->id}' class='gform_hidden' />";
$product_name_field = "<input type='hidden' name='input_{$id}.1' value='{$product_name}' class='gform_hidden' />";
$disabled_text = $is_form_editor ? 'disabled="disabled"' : '';
$field_type = $is_entry_detail || $is_form_editor ? 'text' : 'hidden';
return $quantity_field . $product_name_field . "<input name='input_{$id}.2' id='ginput_base_price_{$form_id}_{$this->id}' type='{$field_type}' value='{$price}' class='gform_hidden ginput_amount' {$disabled_text}/>";
}
示例10: print_tooltip_scripts
function print_tooltip_scripts()
{
wp_enqueue_style('gform_tooltip', GFCommon::get_base_url() . '/css/tooltip.css', null, GFCommon::$version);
wp_enqueue_style('gform_font_awesome', GFCommon::get_base_url() . '/css/font-awesome.css', null, GFCommon::$version);
wp_print_scripts('gform_tooltip_init');
wp_print_styles('gform_tooltip', 'gform_font_awesome');
}
示例11: add_pending_referral
/**
* Add pending referral
*
* @access public
* @uses GFFormsModel::get_lead()
* @uses GFCommon::get_product_fields()
* @uses GFCommon::to_number()
*
* @param array $entry
* @param array $form
*/
public function add_pending_referral($entry, $form)
{
if (!$this->was_referred() || !rgar($form, 'affwp_allow_referrals')) {
return;
}
// Do some craziness to determine the price (this should be easy but is not)
$desc = isset($form['title']) ? $form['title'] : '';
$entry = GFFormsModel::get_lead($entry['id']);
$products = GFCommon::get_product_fields($form, $entry);
$total = 0;
foreach ($products['products'] as $key => $product) {
$price = GFCommon::to_number($product['price']);
if (is_array(rgar($product, 'options'))) {
$count = sizeof($product['options']);
$index = 1;
foreach ($product['options'] as $option) {
$price += GFCommon::to_number($option['price']);
}
}
$subtotal = floatval($product['quantity']) * $price;
$total += $subtotal;
}
// replace description if there are products
if (!empty($products['products'])) {
$product_names = wp_list_pluck($products['products'], 'name');
$desc = implode(', ', $product_names);
}
$total += floatval($products['shipping']['price']);
$referral_total = $this->calculate_referral_amount($total, $entry['id']);
$this->insert_pending_referral($referral_total, $entry['id'], $desc);
if (empty($total)) {
$this->mark_referral_complete($entry, array());
}
}
示例12: process
function process()
{
$this->log_debug(__METHOD__ . '(): starting');
if (class_exists('GFPDF_Core')) {
global $gfpdf;
if (empty($gfpdf)) {
$gfpdf = new GFPDF_Core();
}
}
$entry = $this->get_entry();
$form = $this->get_form();
foreach ($form['notifications'] as $notification) {
$notification_id = $notification['id'];
$setting_key = 'notification_id_' . $notification_id;
if ($this->{$setting_key}) {
if (!GFCommon::evaluate_conditional_logic(rgar($notification, 'conditionalLogic'), $form, $entry)) {
$this->log_debug(__METHOD__ . "(): Notification conditional logic not met, not processing notification (#{$notification_id} - {$notification['name']}).");
continue;
}
GFCommon::send_notification($notification, $form, $entry);
$this->log_debug(__METHOD__ . "(): Notification sent (#{$notification_id} - {$notification['name']}).");
$note = sprintf(esc_html__('Sent Notification: %s', 'gravityflow'), $notification['name']);
$this->add_note($note);
}
}
$this->send_workflow_notification();
return true;
}
示例13: add_hooks
/**
* @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);
}
示例14: replace_variables
/**
* Check for merge tags before passing to Gravity Forms to improve speed.
*
* GF doesn't check for whether `{` exists before it starts diving in. They not only replace fields, they do `str_replace()` on things like ip address, which is a lot of work just to check if there's any hint of a replacement variable.
*
* We check for the basics first, which is more efficient.
*
* @since 1.8.4 - Moved to GravityView_Merge_Tags
* @since 1.15.1 - Add support for $url_encode and $esc_html arguments
*
* @param string $text Text to replace variables in
* @param array $form GF Form array
* @param array $entry GF Entry array
* @param bool $url_encode Pass return value through `url_encode()`
* @param bool $esc_html Pass return value through `esc_html()`
* @return string Text with variables maybe replaced
*/
public static function replace_variables($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true)
{
/**
* @filter `gravityview_do_replace_variables` Turn off merge tag variable replacements.\n
* Useful where you want to process variables yourself. We do this in the Math Extension.
* @since 1.13
* @param[in,out] boolean $do_replace_variables True: yes, replace variables for this text; False: do not replace variables.
* @param[in] string $text Text to replace variables in
* @param[in] array $form GF Form array
* @param[in] array $entry GF Entry array
*/
$do_replace_variables = apply_filters('gravityview/merge_tags/do_replace_variables', true, $text, $form, $entry);
if (strpos($text, '{') === false || !$do_replace_variables) {
return $text;
}
/**
* Replace GravityView merge tags before going to Gravity Forms
* This allows us to replace our tags first.
* @since 1.15
*/
$text = self::replace_gv_merge_tags($text, $form, $entry);
// Check for fields - if they exist, we let Gravity Forms handle it.
preg_match_all('/{[^{]*?:(\\d+(\\.\\d+)?)(:(.*?))?}/mi', $text, $matches, PREG_SET_ORDER);
if (empty($matches)) {
// Check for form variables
if (!preg_match('/\\{(all_fields(:(.*?))?|all_fields_display_empty|pricing_fields|form_title|entry_url|ip|post_id|admin_email|post_edit_url|form_id|entry_id|embed_url|date_mdy|date_dmy|embed_post:(.*?)|custom_field:(.*?)|user_agent|referer|gv:(.*?)|get:(.*?)|user:(.*?)|created_by:(.*?))\\}/ism', $text)) {
return $text;
}
}
return GFCommon::replace_variables($text, $form, $entry, $url_encode, $esc_html);
}
示例15: render_frontend
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>';
}