当前位置: 首页>>代码示例>>PHP>>正文


PHP GFAPI::get_fields_by_type方法代码示例

本文整理汇总了PHP中GFAPI::get_fields_by_type方法的典型用法代码示例。如果您正苦于以下问题:PHP GFAPI::get_fields_by_type方法的具体用法?PHP GFAPI::get_fields_by_type怎么用?PHP GFAPI::get_fields_by_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GFAPI的用法示例。


在下文中一共展示了GFAPI::get_fields_by_type方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add_form_fields

 /**
  * If a form has list fields, add the columns to the field picker
  *
  * @since 1.17
  *
  * @param array $fields Associative array of fields, with keys as field type
  * @param array $form GF Form array
  * @param bool $include_parent_field Whether to include the parent field when getting a field with inputs
  *
  * @return array $fields with list field columns added, if exist. Unmodified if form has no list fields.
  */
 function add_form_fields($fields = array(), $form = array(), $include_parent_field = true)
 {
     $list_fields = GFAPI::get_fields_by_type($form, 'list');
     // Add the list columns
     foreach ($list_fields as $list_field) {
         if (empty($list_field->enableColumns)) {
             continue;
         }
         $list_columns = array();
         foreach ((array) $list_field->choices as $key => $input) {
             $input_id = sprintf('%d.%d', $list_field->id, $key);
             // {field_id}.{column_key}
             $list_columns[$input_id] = array('label' => rgar($input, 'text'), 'customLabel' => '', 'parent' => $list_field, 'type' => rgar($list_field, 'type'), 'adminLabel' => rgar($list_field, 'adminLabel'), 'adminOnly' => rgar($list_field, 'adminOnly'));
         }
         // If there are columns, add them under the parent field
         if (!empty($list_columns)) {
             $index = array_search($list_field->id, array_keys($fields)) + 1;
             /**
              * Merge the $list_columns into the $fields array at $index
              * @see https://stackoverflow.com/a/1783125
              */
             $fields = array_slice($fields, 0, $index, true) + $list_columns + array_slice($fields, $index, null, true);
         }
         unset($list_columns, $index, $input_id);
     }
     return $fields;
 }
开发者ID:mgratch,项目名称:GravityView,代码行数:38,代码来源:class-gravityview-field-list.php

示例2: after_edit_entry

 /**
  * We need to remove the $value used by Gravity Forms so it instead checks for the $_POST field values
  *
  * In ~line 541, this code would be used if we didn't override in this method:
  *
  * `if (RG_CURRENT_VIEW == "entry" && $value){`
  *
  * We don't want that code (with the download/delete icons). So unsetting the $_POST here forces using the "sign again" code instead.
  *
  * @see GFSignature::signature_input
  *
  * @param array $form GF form array
  * @param int $entry_id Entry ID being edited
  */
 function after_edit_entry($form, $entry_id)
 {
     $signature_fields = GFAPI::get_fields_by_type($form, 'signature');
     foreach ($signature_fields as $field) {
         unset($_POST["input_{$field->id}"]);
     }
 }
开发者ID:mgratch,项目名称:GravityView,代码行数:21,代码来源:class-gravityview-plugin-hooks-gravity-forms-signature.php

示例3: set_post_categories

 /**
  * Update the post categories based on all post category fields
  *
  * @since 1.17
  *
  * @param array $form Gravity Forms form array
  * @param int $entry_id Numeric ID of the entry that was updated
  *
  * @return array|false|WP_Error Array of term taxonomy IDs of affected categories. WP_Error or false on failure. false if there are no post category fields or connected post.
  */
 public function set_post_categories($form = array(), $entry_id = 0)
 {
     $entry = GFAPI::get_entry($entry_id);
     $post_id = rgar($entry, 'post_id');
     if (empty($post_id)) {
         return false;
     }
     $return = false;
     $post_category_fields = GFAPI::get_fields_by_type($form, 'post_category');
     if ($post_category_fields) {
         $updated_categories = array();
         foreach ($post_category_fields as $field) {
             // Get the value of the field, including $_POSTed value
             $field_cats = RGFormsModel::get_field_value($field);
             $field_cats = is_array($field_cats) ? array_values($field_cats) : (array) $field_cats;
             $field_cats = gv_map_deep($field_cats, 'intval');
             $updated_categories = array_merge($updated_categories, array_values($field_cats));
         }
         // Remove `0` values from intval()
         $updated_categories = array_filter($updated_categories);
         /**
          * @filter `gravityview/edit_entry/post_categories/append` Should post categories be added to or replaced?
          * @since 1.17
          * @param bool $append If `true`, don't delete existing categories, just add on. If `false`, replace the categories with the submitted categories. Default: `false`
          */
         $append = apply_filters('gravityview/edit_entry/post_categories/append', false);
         $return = wp_set_post_categories($post_id, $updated_categories, $append);
     }
     return $return;
 }
开发者ID:mgratch,项目名称:GravityView,代码行数:40,代码来源:class-gravityview-field-post-category.php

示例4: add_form_fields

 /**
  * If a form has quiz fields, add the fields to the field picker
  *
  * @since 1.17
  *
  * @param array $fields Associative array of fields, with keys as field type
  * @param array $form GF Form array
  * @param bool $include_parent_field Whether to include the parent field when getting a field with inputs
  *
  * @return array $fields with quiz fields added, if exist. Unmodified if form has no quiz fields.
  */
 function add_form_fields($fields = array(), $form = array(), $include_parent_field = true)
 {
     $quiz_fields = GFAPI::get_fields_by_type($form, 'quiz');
     if (!empty($quiz_fields)) {
         $fields['gquiz_score'] = array('label' => __('Quiz Score Total', 'gravityview'), 'type' => 'quiz_score', 'desc' => __('Displays the number of correct Quiz answers the user submitted.', 'gravityview'));
         $fields['gquiz_percent'] = array('label' => __('Quiz Percentage Grade', 'gravityview'), 'type' => 'quiz_percent', 'desc' => __('Displays the percentage of correct Quiz answers the user submitted.', 'gravityview'));
         $fields['gquiz_grade'] = array('label' => __('Quiz Letter Grade', 'gravityview'), 'type' => 'quiz_grade', 'desc' => __('Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview'));
         $fields['gquiz_is_pass'] = array('label' => __('Quiz Pass/Fail', 'gravityview'), 'type' => 'quiz_is_pass', 'desc' => __('Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview'));
     }
     return $fields;
 }
开发者ID:mgratch,项目名称:GravityView,代码行数:22,代码来源:class-gravityview-plugin-hooks-gravityformsquiz.php

示例5: upgrade

 public function upgrade($previous_version)
 {
     if (version_compare($previous_version, '1.0.5') == -1) {
         $forms = GFAPI::get_forms(true);
         foreach ($forms as $form) {
             $entries = GFAPI::get_entries($form['id']);
             $fields = GFAPI::get_fields_by_type($form, 'repeater');
             foreach ($entries as $entry) {
                 foreach ($fields as $field) {
                     if (array_key_exists($field['id'], $entry)) {
                         $dataArray = GFFormsModel::unserialize($entry[$field['id']]);
                         $dataUpdated = false;
                         if (!is_array($dataArray)) {
                             continue;
                         }
                         foreach ($dataArray as $repeaterChildId => $repeaterChild) {
                             foreach ($repeaterChild as $repeatedFieldId => $repeatedField) {
                                 if (!is_array($repeatedField)) {
                                     if ($repeatedField !== '[gfRepeater-section]') {
                                         $dataUpdated = true;
                                         $dataArray[$repeaterChildId][$repeatedFieldId] = array($repeatedField);
                                     }
                                 } elseif (reset($repeatedField) == '[gfRepeater-section]') {
                                     $dataUpdated = true;
                                     $dataArray[$repeaterChildId][$repeatedFieldId] = reset($repeatedField);
                                 }
                             }
                         }
                         if ($dataUpdated) {
                             GFAPI::update_entry_field($entry['id'], $field['id'], maybe_serialize($dataArray));
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:kodie,项目名称:gravityforms-repeater,代码行数:37,代码来源:repeater.php

示例6: contacts_tab

    public function contacts_tab($contact_id)
    {
        if (false === empty($contact_id)) {
            $search_criteria['status'] = 'active';
            $search_criteria['field_filters'][] = array('type' => 'meta', 'key' => 'gcontacts_contact_id', 'value' => $contact_id);
            $form_ids = array();
            $forms = GFFormsModel::get_forms(true);
            foreach ($forms as $form) {
                $form_meta = GFFormsModel::get_form_meta($form->id);
                $poll_fields = GFAPI::get_fields_by_type($form_meta, array('poll'));
                if (!empty($poll_fields)) {
                    $form_ids[] = $form->id;
                }
            }
            if (empty($form_ids)) {
                return;
            }
            $entries = GFAPI::get_entries($form_ids, $search_criteria);
            if (empty($entries)) {
                esc_html_e('This contact has not submitted any poll entries yet.', 'gravityformspolls');
            } else {
                ?>

				<h3><span><?php 
                esc_html_e('Poll Entries', 'gravityformspolls');
                ?>
</span></h3>
				<div>
					<table id="gcontacts-entry-list" class="widefat">
						<tr class="gcontacts-entries-header">
							<td>
								<?php 
                esc_html_e('Entry Id', 'gravityformspolls');
                ?>
							</td>
							<td>
								<?php 
                esc_html_e('Date', 'gravityformspolls');
                ?>
							</td>
							<td>
								<?php 
                esc_html_e('Form', 'gravityformspolls');
                ?>
							</td>
						</tr>
						<?php 
                foreach ($entries as $entry) {
                    $form_id = $entry['form_id'];
                    $form = GFFormsModel::get_form_meta($form_id);
                    $form_title = rgar($form, 'title');
                    $entry_id = $entry['id'];
                    $entry_date = GFCommon::format_date(rgar($entry, 'date_created'), false);
                    $entry_url = admin_url("admin.php?page=gf_entries&view=entry&id={$form_id}&lid={$entry_id}");
                    ?>
							<tr>
								<td>
									<a href="<?php 
                    echo $entry_url;
                    ?>
"><?php 
                    echo $entry_id;
                    ?>
</a>
								</td>
								<td>
									<?php 
                    echo $entry_date;
                    ?>
								</td>
								<td>
									<?php 
                    echo $form_title;
                    ?>
								</td>
							</tr>
							<?php 
                }
                ?>
					</table>
				</div>
				<?php 
            }
        }
    }
开发者ID:GravityPDF,项目名称:gravityformspolls,代码行数:85,代码来源:class-gf-polls.php

示例7: get_first_field_by_type

 /**
  * Returns the field ID of the first field of the desired type.
  * 
  * @access public
  * @param string $field_type
  * @param int $subfield_id (default: null)
  * @param int $form_id (default: null)
  * @return string
  */
 public function get_first_field_by_type($field_type, $subfield_id = null, $form_id = null, $return_first_only = true)
 {
     /* Get the current form ID. */
     if (rgblank($form_id)) {
         $form_id = rgget('id');
     }
     /* Get the form. */
     $form = GFAPI::get_form($form_id);
     /* Get the request field type for the form. */
     $fields = GFAPI::get_fields_by_type($form, array($field_type));
     if (count($fields) == 0 || count($fields) > 1 && $return_first_only) {
         return null;
     } else {
         if (rgblank($subfield_id)) {
             return $fields[0]->id;
         } else {
             return $fields[0]->id . '.' . $subfield_id;
         }
     }
 }
开发者ID:fjbeteiligung,项目名称:development,代码行数:29,代码来源:class-gf-addon.php

示例8: get_payment_choices

 protected function get_payment_choices($form)
 {
     $fields = GFAPI::get_fields_by_type($form, array('product'));
     $choices = array(array('label' => esc_html__('Select a product field', 'gravityforms'), 'value' => ''));
     foreach ($fields as $field) {
         $field_id = $field['id'];
         $field_label = RGFormsModel::get_label($field);
         $choices[] = array('value' => $field_id, 'label' => $field_label);
     }
     return $choices;
 }
开发者ID:kidaak,项目名称:gravityforms,代码行数:11,代码来源:class-gf-payment-addon.php

示例9: _field_condition_matches

 private function _field_condition_matches($field_types, $form)
 {
     if (!is_array($field_types)) {
         $field_types = array($field_types);
     }
     $fields = GFAPI::get_fields_by_type($form, $field_types);
     if (count($fields) > 0) {
         return true;
     }
     return false;
 }
开发者ID:jamesaveryw,项目名称:mississippi-staging,代码行数:11,代码来源:class-gf-addon.php

示例10: delete_passwords

 public static function delete_passwords($entry, $form)
 {
     $password_fields = GFAPI::get_fields_by_type($form, array('password'));
     foreach ($password_fields as $password_field) {
         GFAPI::update_entry_field($entry['id'], $password_field['id'], '');
     }
 }
开发者ID:TMBR,项目名称:johnjohn,代码行数:7,代码来源:class-gf-field-password.php

示例11: has_multifile_fileupload_field

 public static function has_multifile_fileupload_field($form)
 {
     $fileupload_fields = GFAPI::get_fields_by_type($form, array('fileupload', 'post_custom_field'));
     if (is_array($fileupload_fields)) {
         foreach ($fileupload_fields as $field) {
             if ($field->multipleFiles) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:12,代码来源:common.php

示例12: conditional_logic_filters

 /**
  * Remove the survey score from the entry meta conditional logic filters on the notifications/confirmations pages.
  *
  * @param array $filters The array of filters.
  * @param array $form The current form object.
  * @param string $id The ID of the notification/confirmation being edited.
  *
  * @return mixed
  */
 public function conditional_logic_filters($filters, $form, $id)
 {
     $survey_fields = GFAPI::get_fields_by_type($form, array('survey'));
     if (empty($survey_fields)) {
         return $filters;
     }
     if (false === $this->scoring_enabled($form)) {
         unset($filters['gsurvey_score']);
     }
     return $filters;
 }
开发者ID:GravityPDF,项目名称:gravityformssurvey,代码行数:20,代码来源:class-gf-survey.php

示例13: get_field_row_count

 private static function get_field_row_count($form, $exported_field_ids, $entry_count)
 {
     $list_fields = GFAPI::get_fields_by_type($form, array('list'), true);
     //only getting fields that have been exported
     $field_ids = '';
     foreach ($list_fields as $field) {
         if (in_array($field->id, $exported_field_ids) && $field->enableColumns) {
             $field_ids .= $field->id . ',';
         }
     }
     if (empty($field_ids)) {
         return array();
     }
     $field_ids = substr($field_ids, 0, strlen($field_ids) - 1);
     $page_size = 200;
     $offset = 0;
     $row_counts = array();
     global $wpdb;
     $go_to_next_page = true;
     while ($go_to_next_page) {
         $sql = "SELECT d.field_number as field_id, ifnull(l.value, d.value) as value\n                    FROM {$wpdb->prefix}rg_lead_detail d\n                    LEFT OUTER JOIN {$wpdb->prefix}rg_lead_detail_long l ON d.id = l.lead_detail_id\n                    WHERE d.form_id={$form['id']} AND cast(d.field_number as decimal) IN ({$field_ids})\n                    LIMIT {$offset}, {$page_size}";
         $results = $wpdb->get_results($sql, ARRAY_A);
         foreach ($results as $result) {
             $list = unserialize($result['value']);
             $current_row_count = isset($row_counts[$result['field_id']]) ? intval($row_counts[$result['field_id']]) : 0;
             if (is_array($list) && count($list) > $current_row_count) {
                 $row_counts[$result['field_id']] = count($list);
             }
         }
         $offset += $page_size;
         $go_to_next_page = count($results) == $page_size;
     }
     return $row_counts;
 }
开发者ID:renztoygwapo,项目名称:lincoln,代码行数:34,代码来源:export.php

示例14: has_price_field

 private static function has_price_field($form)
 {
     $price_fields = GFAPI::get_fields_by_type($form, array('product', 'donation'));
     $has_price_field = !empty($price_fields);
     return gf_apply_filters('gform_has_price_field', $form['id'], $has_price_field, $form);
 }
开发者ID:ryan2407,项目名称:Vision,代码行数:6,代码来源:form_display.php

示例15: entry_results

    /**
     * Output the Quiz results in a postbox div.
     *
     * @param array $form The current form.
     * @param array $entry The current entry.
     */
    public function entry_results($form, $entry)
    {
        $fields = GFAPI::get_fields_by_type($form, array('quiz'));
        $count_quiz_fields = count($fields);
        if ($count_quiz_fields == 0) {
            return;
        }
        $grading = $this->get_form_setting($form, 'grading');
        $score = rgar($entry, 'gquiz_score');
        $percent = rgar($entry, 'gquiz_percent');
        $is_pass = rgar($entry, 'gquiz_is_pass');
        $grade = rgar($entry, 'gquiz_grade');
        $max_score = $this->get_max_score($form);
        ?>
		<div id="gquiz-entry-detail-score-info-container" class="postbox">
			<h3 style="cursor: default;"><?php 
        esc_html_e('Quiz Results', 'gravityformsquiz');
        ?>
</h3>

			<div id="gquiz-entry-detail-score-info">
				<?php 
        echo $this->get_results_panel_markup($form, $entry);
        ?>
			</div>

		</div>

		<?php 
    }
开发者ID:GravityPDF,项目名称:gravityformsquiz,代码行数:36,代码来源:class-gf-quiz.php


注:本文中的GFAPI::get_fields_by_type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。