本文整理汇总了PHP中rgars函数的典型用法代码示例。如果您正苦于以下问题:PHP rgars函数的具体用法?PHP rgars怎么用?PHP rgars使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rgars函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gforms_autologin
function gforms_autologin($user_id, $config, $entry, $password)
{
$form = RGFormsModel::get_form_meta($entry['form_id']);
$user_login = apply_filters("gform_username_{$form['id']}", apply_filters('gform_username', GFUser::get_meta_value('username', $config, $form, $entry), $config, $form, $entry), $config, $form, $entry);
$redirect_url = rgars($form, 'confirmation/url') ? rgars($form, 'confirmation/url') : get_bloginfo('home');
//pass the above to the wp_signon function
$result = wp_signon(array('user_login' => $user_login, 'user_password' => $password, 'remember' => false));
if (!is_wp_error($result)) {
wp_redirect($redirect_url);
}
}
示例2: filter_menu_items
public function filter_menu_items($menu_items, $form_id, $compact)
{
$form_meta = GFFormsModel::get_form_meta($form_id);
$results_fields = $this->get_fields($form_meta);
if (false === empty($results_fields)) {
$form_id = $form_meta["id"];
$link_class = "";
if (rgget("page") == "gf_new_form") {
$link_class = "gf_toolbar_disabled";
} else {
if (rgget("page") == "gf_entries" && rgget("view") == "gf_results_" . $this->_slug) {
$link_class = "gf_toolbar_active";
}
}
$sub_menu_items = array();
$sub_menu_items[] = array('label' => $this->_title, 'title' => __("View results generated by this form", "gravityforms"), 'link_class' => $link_class, 'url' => admin_url("admin.php?page=gf_entries&view=gf_results_{$this->_slug}&id={$form_id}"), 'capabilities' => $this->_capabilities);
$duplicate_submenus = wp_filter_object_list(rgars($menu_items, "results/sub_menu_items"), array("label" => $sub_menu_items[0]["label"]));
if (count($duplicate_submenus) > 0) {
return $menu_items;
}
// If there's already a menu item with the key "results" then merge the two.
if (isset($menu_items["results"])) {
$existing_link_class = $menu_items["results"]["link_class"];
$link_class == empty($existing_link_class) ? $link_class : $existing_link_class;
$existing_capabilities = $menu_items["results"]["capabilities"];
$merged_capabilities = array_merge($existing_capabilities, $this->_capabilities);
$existing_sub_menu_items = $menu_items["results"]["sub_menu_items"];
$merged_sub_menu_items = array_merge($existing_sub_menu_items, $sub_menu_items);
$menu_items["results"]["link_class"] = $link_class;
$menu_items["results"]["capabilities"] = $merged_capabilities;
$menu_items["results"]["sub_menu_items"] = $merged_sub_menu_items;
$menu_items["results"]["label"] = __("Results", "gravityforms");
} else {
// so far during the page cycle this is the only menu item for this key
$menu_items["results"] = array('label' => $compact ? __("Results", "gravityforms") : $this->_title, 'title' => __("View results generated by this form", "gravityforms"), 'url' => "", 'onclick' => "return false;", 'menu_class' => 'gf_form_toolbar_results', 'link_class' => $link_class, 'capabilities' => $this->_capabilities, 'sub_menu_items' => $sub_menu_items, 'priority' => 750);
}
}
return $menu_items;
}
示例3: make_request
/**
* Make API request.
*
* @access public
* @param string $action
* @param array $options (default: array())
* @param string $method (default: 'GET')
* @param int $expected_code (default: 200)
* @return array or int
*/
function make_request($action, $options = array(), $method = 'GET', $expected_code = 200)
{
$request_options = $method == 'GET' ? '?' . http_build_query($options) : null;
/* Build request URL. */
$request_url = 'https://' . $this->account_url . '.capsulecrm.com/api/' . $action . $request_options;
/* Setup request arguments. */
$args = array('headers' => array('Accept' => 'application/json', 'Authorization' => 'Basic ' . base64_encode($this->api_token . ':x'), 'Content-Type' => 'application/json'), 'method' => $method, 'sslverify' => $this->verify_ssl);
/* Add request options to body of POST and PUT requests. */
if ($method == 'POST' || $method == 'PUT') {
$args['body'] = $options;
}
/* Execute request. */
$result = wp_remote_request($request_url, $args);
$decoded_result = json_decode($result['body'], true);
/* If WP_Error, throw exception */
if (is_wp_error($result)) {
throw new Exception('Request failed. ' . $result->get_error_messages());
}
/* If API credentials failed, throw exception. */
if (strpos(rgars($result, 'response/content-type'), 'application/json') == FALSE && $result['response']['code'] !== $expected_code) {
throw new Exception('API credentials invalid.');
}
/* If return HTTP code does not match expected code, throw exception. */
if ($result['response']['code'] !== $expected_code) {
throw new CapsuleCRM_Exception($decoded_result['message'], $result['response']['code'], null, rgar($decoded_result, 'errors'));
}
/* If the decoded result isn't empty, return it. */
if (!empty($decoded_result)) {
return $decoded_result;
}
/* If the body is empty, retrieve the ID from the location header. */
if (rgars($result, 'headers/location')) {
$new_id = explode('/', $result['headers']['location']);
return end($new_id);
}
return;
}
示例4: get_form_confirmations
public static function get_form_confirmations($form_id)
{
global $wpdb;
if (isset($_confirmations[$form_id])) {
return $_confirmations[$form_id];
}
$tablename = GFFormsModel::get_meta_table_name();
$sql = $wpdb->prepare("SELECT confirmations FROM {$tablename} WHERE form_id = %d", $form_id);
$results = $wpdb->get_results($sql, ARRAY_A);
$confirmations = rgars($results, '0/confirmations');
self::$_confirmations[$form_id] = $confirmations ? self::unserialize($confirmations) : array();
return self::$_confirmations[$form_id];
}
示例5: run_foreign_language_fix
/**
* Updates feeds to use Zoho CRM module field label instead of field name.
*
* @access public
* @return void
*/
public function run_foreign_language_fix()
{
/* Get the Zoho CRM feeds. */
$feeds = $this->get_feeds();
foreach ($feeds as &$feed) {
if (rgars($feed, 'meta/action') === 'contact') {
$contact_fields = $this->get_module_fields('Contacts');
foreach ($contact_fields as $contact_field) {
$search_for = 'contactStandardFields_' . str_replace(' ', '_', $contact_field['name']);
$replace_with = 'contactStandardFields_' . str_replace(' ', '_', $contact_field['label']);
if (rgars($feed, 'meta/' . $search_for)) {
$value = rgars($feed, 'meta/' . $search_for);
unset($feed['meta'][$search_for]);
$feed['meta'][$replace_with] = $value;
}
}
if (rgars($feed, 'meta/contactCustomFields')) {
foreach ($contact_fields as $contact_field) {
foreach ($feed['meta']['contactCustomFields'] as &$feed_custom_field) {
if ($feed_custom_field['key'] === $contact_field['name']) {
$feed_custom_field['key'] = $contact_field['label'];
}
}
}
}
}
if (rgars($feed, 'meta/action') === 'lead') {
$lead_fields = $this->get_module_fields('Leads');
foreach ($lead_fields as $lead_field) {
$search_for = 'leadStandardFields_' . str_replace(' ', '_', $lead_field['name']);
$replace_with = 'leadStandardFields_' . str_replace(' ', '_', $lead_field['label']);
if (rgars($feed, 'meta/' . $search_for)) {
$value = rgars($feed, 'meta/' . $search_for);
unset($feed['meta'][$search_for]);
$feed['meta'][$replace_with] = $value;
}
}
if (rgars($feed, 'meta/leadCustomFields')) {
foreach ($lead_fields as $lead_field) {
foreach ($feed['meta']['leadCustomFields'] as &$feed_custom_field) {
if ($feed_custom_field['key'] === $lead_field['name']) {
$feed_custom_field['key'] = $lead_field['label'];
}
}
}
}
}
$this->update_feed_meta($feed['id'], $feed['meta']);
}
}
示例6: get_field_map_choices
public static function get_field_map_choices($form_id)
{
$form = RGFormsModel::get_form_meta($form_id);
$fields = array();
// Adding default fields
$fields[] = array("value" => "", "label" => "");
$fields[] = array("value" => "date_created", "label" => __("Entry Date", "gravityforms"));
$fields[] = array("value" => "ip", "label" => __("User IP", "gravityforms"));
$fields[] = array("value" => "source_url", "label" => __("Source Url", "gravityforms"));
$fields[] = array("value" => "form_title", "label" => __("Form Title", "gravityforms"));
// Populate entry meta
$entry_meta = GFFormsModel::get_entry_meta($form["id"]);
foreach ($entry_meta as $meta_key => $meta) {
$fields[] = array('value' => $meta_key, 'label' => rgars($entry_meta, "{$meta_key}/label"));
}
// Populate form fields
if (is_array($form["fields"])) {
foreach ($form["fields"] as $field) {
if (is_array(rgar($field, "inputs"))) {
//If this is an address field, add full name to the list
if (RGFormsModel::get_input_type($field) == "address") {
$fields[] = array('value' => $field["id"], 'label' => GFCommon::get_label($field) . " (" . __("Full", "gravityforms") . ")");
}
//If this is a name field, add full name to the list
if (RGFormsModel::get_input_type($field) == "name") {
$fields[] = array('value' => $field["id"], 'label' => GFCommon::get_label($field) . " (" . __("Full", "gravityforms") . ")");
}
//If this is a checkbox field, add to the list
if (RGFormsModel::get_input_type($field) == "checkbox") {
$fields[] = array('value' => $field["id"], 'label' => GFCommon::get_label($field) . " (" . __("Selected", "gravityforms") . ")");
}
foreach ($field['inputs'] as $input) {
if (RGFormsModel::get_input_type($field) == 'creditcard') {
//only include the credit card type (field_id.4) and number (field_id.1)
if ($input['id'] == $field['id'] . '.1' || $input['id'] == $field['id'] . '.4') {
$fields[] = array('value' => $input["id"], 'label' => GFCommon::get_label($field, $input['id']));
}
} else {
$fields[] = array('value' => $input["id"], 'label' => GFCommon::get_label($field, $input["id"]));
}
}
} else {
if (!rgar($field, "displayOnly")) {
$fields[] = array('value' => $field["id"], 'label' => GFCommon::get_label($field));
}
}
}
}
return $fields;
}
示例7: do_action
<?php
/**
* Display Gravity Forms Quiz output
*
* @package GravityView
* @subpackage GravityView/templates/fields
*/
$gravityview_view = GravityView_View::getInstance();
$field = $gravityview_view->getCurrentField();
// If there's no grade, don't continue
if (gv_empty($field['value'])) {
return;
}
if (!class_exists('GFQuiz')) {
do_action('gravityview_log_error', __FILE__ . ': GFQuiz class does not exist.');
return;
}
// Get the setting for show/hide explanation
$show_answer = rgars($field, 'field_settings/quiz_show_explanation');
// Update the quiz field so GF generates the output properly
$field['field']->gquizShowAnswerExplanation = !empty($show_answer);
// Generate the output
echo GFQuiz::get_instance()->display_quiz_on_entry_detail($field['value'], $field['field'], $field['entry'], $field['form']);
示例8: has_paypal_payment
public function has_paypal_payment($feed, $form, $entry)
{
$products = GFCommon::get_product_fields($form, $entry);
$payment_field = $feed['meta']['transactionType'] == 'product' ? $feed['meta']['paymentAmount'] : $feed['meta']['recurringAmount'];
$setup_fee_field = rgar($feed['meta'], 'setupFee_enabled') ? $feed['meta']['setupFee_product'] : false;
$trial_field = rgar($feed['meta'], 'trial_enabled') ? rgars($feed, 'meta/trial_product') : false;
$amount = 0;
$line_items = array();
$discounts = array();
$fee_amount = 0;
$trial_amount = 0;
foreach ($products['products'] as $field_id => $product) {
$quantity = $product['quantity'] ? $product['quantity'] : 1;
$product_price = GFCommon::to_number($product['price']);
$options = array();
if (is_array(rgar($product, 'options'))) {
foreach ($product['options'] as $option) {
$options[] = $option['option_name'];
$product_price += $option['price'];
}
}
$is_trial_or_setup_fee = false;
if (!empty($trial_field) && $trial_field == $field_id) {
$trial_amount = $product_price * $quantity;
$is_trial_or_setup_fee = true;
} else {
if (!empty($setup_fee_field) && $setup_fee_field == $field_id) {
$fee_amount = $product_price * $quantity;
$is_trial_or_setup_fee = true;
}
}
//Do not add to line items if the payment field selected in the feed is not the current field.
if (is_numeric($payment_field) && $payment_field != $field_id) {
continue;
}
//Do not add to line items if the payment field is set to "Form Total" and the current field was used for trial or setup fee.
if ($is_trial_or_setup_fee && !is_numeric($payment_field)) {
continue;
}
$amount += $product_price * $quantity;
}
if (!empty($products['shipping']['name']) && !is_numeric($payment_field)) {
$line_items[] = array('id' => '', 'name' => $products['shipping']['name'], 'description' => '', 'quantity' => 1, 'unit_price' => GFCommon::to_number($products['shipping']['price']), 'is_shipping' => 1);
$amount += $products['shipping']['price'];
}
return $amount > 0;
}
示例9: prepare_settings_checkbox_and_select
public function prepare_settings_checkbox_and_select($field)
{
// prepare checkbox
$checkbox_input = rgars($field, 'checkbox');
$checkbox_field = array('type' => 'checkbox', 'name' => $field['name'] . 'Enable', 'label' => esc_html__('Enable', 'gravityforms'), 'horizontal' => true, 'value' => '1', 'choices' => false, 'tooltip' => false);
$checkbox_field = wp_parse_args($checkbox_input, $checkbox_field);
// prepare select
$select_input = rgars($field, 'select');
$select_field = array('name' => $field['name'] . 'Value', 'type' => 'select', 'class' => '', 'tooltip' => false);
$select_field['class'] .= ' ' . $select_field['name'];
$select_field = wp_parse_args($select_input, $select_field);
// a little more with the checkbox
if (empty($checkbox_field['choices'])) {
$checkbox_field['choices'] = array(array('name' => $checkbox_field['name'], 'label' => $checkbox_field['label'], 'onchange' => sprintf("( function( \$, elem ) {\r\n\t\t\t\t\t\t\$( elem ).parents( 'td' ).css( 'position', 'relative' );\r\n\t\t\t\t\t\tif( \$( elem ).prop( 'checked' ) ) {\r\n\t\t\t\t\t\t\t\$( '%1\$s' ).fadeIn();\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t\$( '%1\$s' ).fadeOut();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} )( jQuery, this );", "#{$select_field['name']}Span")));
}
$field['select'] = $select_field;
$field['checkbox'] = $checkbox_field;
return $field;
}
示例10: get_column_value_amount
public function get_column_value_amount($feed)
{
$form = $this->get_current_form();
$field_id = $feed["meta"]["transactionType"] == "subscription" ? rgars($feed, "meta/recurringAmount") : rgars($feed, "meta/paymentAmount");
if ($field_id == "form_total") {
$label = __("Form Total", "gravityforms");
} else {
$field = GFFormsModel::get_field($form, $field_id);
$label = GFCommon::get_label($field);
}
return $label;
}
示例11: fulfill_order
public function fulfill_order(&$entry, $transaction_id, $amount, $feed = null)
{
if (!$feed) {
$feed = $this->get_payment_feed($entry);
}
$form = GFFormsModel::get_form_meta($entry['form_id']);
if (rgars($feed, 'meta/delayPost')) {
$this->log_debug(__METHOD__ . '(): Creating post.');
$entry['post_id'] = GFFormsModel::create_post($form, $entry);
$this->log_debug(__METHOD__ . '(): Post created.');
}
if (rgars($feed, 'meta/delayNotification')) {
//sending delayed notifications
$notifications = rgars($feed, 'meta/selectedNotifications');
GFCommon::send_notifications($notifications, $form, $entry, true, 'form_submission');
}
do_action('gform_paypal_fulfillment', $entry, $feed, $transaction_id, $amount);
if (has_filter('gform_paypal_fulfillment')) {
$this->log_debug(__METHOD__ . '(): Executing functions hooked to gform_paypal_fulfillment.');
}
}
示例12: get_list_field_value
/**
* Returns the value of the specified List field.
*
* @param array $entry
* @param string $field_id
* @param object $field
*
* @return string
*/
protected function get_list_field_value($entry, $field_id, $field)
{
if (!ctype_digit($field_id)) {
$field_id_array = explode('.', $field_id);
$field_id = rgar($field_id_array, 0);
$column_num = rgar($field_id_array, 1);
}
$value = rgar($entry, $field_id);
if (empty($value)) {
return '';
}
$list_values = $column_values = unserialize($value);
if (!empty($column_num) && $field->enableColumns) {
$column = rgars($field->choices, "{$column_num}/text");
$column_values = array();
foreach ($list_values as $value) {
$column_values[] = rgar($value, $column);
}
} elseif ($field->enableColumns) {
return $value;
}
return GFCommon::implode_non_blank(', ', $column_values);
}
示例13: select_mailchimp_form
public static function select_mailchimp_form()
{
check_ajax_referer("gf_select_mailchimp_form", "gf_select_mailchimp_form");
$form_id = intval(rgpost("form_id"));
list($list_id, $list_name) = explode("|:|", rgpost("list_id"));
$setting_id = intval(rgpost("setting_id"));
$api = self::get_api();
if (!$api) {
die("EndSelectForm();");
}
//getting list of all MailChimp merge variables for the selected contact list
self::log("Retrieving Merge_Vars for list {$list_id}", "debug");
$merge_vars = $api->listMergeVars($list_id);
self::log("Merge_Vars retrieved: " . print_r($merge_vars, true), "debug");
//getting configuration
$config = GFMailChimpData::get_feed($setting_id);
//getting field map UI
$str = self::get_field_mapping($config, $form_id, $merge_vars);
//getting list of selection fields to be used by the optin
$form_meta = RGFormsModel::get_form_meta($form_id);
$selection_fields = GFCommon::get_selection_fields($form_meta, rgars($config, "meta/optin_field_id"));
$group_condition = array();
$group_names = array();
$grouping = self::get_groupings($config, $list_id, $selection_fields, $group_condition, $group_names);
//fields meta
$form = RGFormsModel::get_form_meta($form_id);
die("EndSelectForm('" . str_replace("'", "\\'", $str) . "', " . GFCommon::json_encode($form) . ", '" . str_replace("'", "\\'", $grouping) . "', " . json_encode($group_names) . " );");
}
示例14: get_subscription_line_item
public function get_subscription_line_item($response)
{
$lines = rgars($response, 'data/object/lines/data');
foreach ($lines as $line) {
if ($line['type'] == 'subscription') {
return $line;
}
}
return false;
}
示例15: get_version_info
public static function get_version_info($cache = true)
{
$raw_response = get_transient('gform_update_info');
if (!$cache) {
$raw_response = null;
}
if (!$raw_response) {
//Getting version number
$options = array('method' => 'POST', 'timeout' => 20);
$options['headers'] = array('Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'), 'User-Agent' => 'WordPress/' . get_bloginfo('version'), 'Referer' => get_bloginfo('url'));
$options['body'] = self::get_remote_post_params();
$options['timeout'] = 15;
$nocache = $cache ? '' : 'nocache=1';
//disabling server side caching
$raw_response = self::post_to_manager('version.php', $nocache, $options);
//caching responses.
set_transient('gform_update_info', $raw_response, 86400);
//caching for 24 hours
}
if (is_wp_error($raw_response) || rgars($raw_response, 'response/code') != 200) {
return array('is_valid_key' => '1', 'version' => '', 'url' => '', 'is_error' => '1');
}
$version_info = json_decode($raw_response['body'], true);
if (empty($version_info)) {
return array('is_valid_key' => '1', 'version' => '', 'url' => '', 'is_error' => '1');
}
return $version_info;
}