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


PHP GVCommon::gv_parse_str方法代码示例

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


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

示例1: save_postdata

 /**
  * Save View configuration
  *
  * @access public
  * @param mixed $post_id
  * @return void
  */
 function save_postdata($post_id)
 {
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     // validate post_type
     if (!isset($_POST['post_type']) || 'gravityview' != $_POST['post_type']) {
         return;
     }
     // validate user can edit and save post/page
     if ('page' == $_POST['post_type']) {
         if (!current_user_can('edit_page', $post_id)) {
             return;
         }
     } else {
         if (!current_user_can('edit_post', $post_id)) {
             return;
         }
     }
     do_action('gravityview_log_debug', '[save_postdata] Saving View post type.', $_POST);
     $statii = array();
     // check if this is a start fresh View
     if (isset($_POST['gravityview_select_form_nonce']) && wp_verify_nonce($_POST['gravityview_select_form_nonce'], 'gravityview_select_form')) {
         $form_id = !empty($_POST['gravityview_form_id']) ? $_POST['gravityview_form_id'] : '';
         // save form id
         $statii['form_id'] = update_post_meta($post_id, '_gravityview_form_id', $form_id);
     }
     // Was this a start fresh?
     if (!empty($_POST['gravityview_form_id_start_fresh'])) {
         $statii['start_fresh'] = add_post_meta($post_id, '_gravityview_start_fresh', 1);
     } else {
         $statii['start_fresh'] = delete_post_meta($post_id, '_gravityview_start_fresh');
     }
     // Check if we have a template id
     if (isset($_POST['gravityview_select_template_nonce']) && wp_verify_nonce($_POST['gravityview_select_template_nonce'], 'gravityview_select_template')) {
         $template_id = !empty($_POST['gravityview_directory_template']) ? $_POST['gravityview_directory_template'] : '';
         // now save template id
         $statii['directory_template'] = update_post_meta($post_id, '_gravityview_directory_template', $template_id);
     }
     // save View Configuration metabox
     if (isset($_POST['gravityview_view_configuration_nonce']) && wp_verify_nonce($_POST['gravityview_view_configuration_nonce'], 'gravityview_view_configuration')) {
         // template settings
         if (empty($_POST['template_settings'])) {
             $_POST['template_settings'] = array();
         }
         $statii['template_settings'] = update_post_meta($post_id, '_gravityview_template_settings', $_POST['template_settings']);
         $fields = array();
         // Directory&single Visible Fields
         if (!empty($preset_fields)) {
             $fields = $preset_fields;
         } elseif (!empty($_POST['fields'])) {
             if (!is_array($_POST['fields'])) {
                 // Fields are passed as a jQuery-serialized array, created in admin-views.js in the serializeForm method
                 // Not using parse_str due to max_input_vars limitation
                 $fields_holder = array();
                 GVCommon::gv_parse_str($_POST['fields'], $fields_holder);
                 if (isset($fields_holder['fields'])) {
                     // When parsed, there's a m
                     $fields = $fields_holder['fields'];
                 } else {
                     do_action('gravityview_log_error', '[save_postdata] No `fields` key was found after parsing $fields string', $fields_holder);
                 }
             } else {
                 $fields = $_POST['fields'];
             }
         }
         $statii['directory_fields'] = update_post_meta($post_id, '_gravityview_directory_fields', $fields);
         // Directory Visible Widgets
         if (empty($_POST['widgets'])) {
             $_POST['widgets'] = array();
         }
         $statii['directory_widgets'] = update_post_meta($post_id, '_gravityview_directory_widgets', $_POST['widgets']);
     }
     // end save view configuration
     do_action('gravityview_log_debug', '[save_postdata] Update Post Meta Statuses (also returns false if nothing changed)', array_map('intval', $statii));
 }
开发者ID:psdes,项目名称:GravityView,代码行数:83,代码来源:class-admin-views.php

示例2: _gravityview_process_posted_fields

/**
 * Maybe convert jQuery-serialized fields into array, otherwise return $_POST['fields'] array
 *
 * Fields are passed as a jQuery-serialized array, created in admin-views.js in the serializeForm method.
 *
 * @since 1.16.5
 *
 * @uses GVCommon::gv_parse_str
 *
 * @return array Array of fields
 */
function _gravityview_process_posted_fields()
{
    $fields = array();
    if (!empty($_POST['fields'])) {
        if (!is_array($_POST['fields'])) {
            // We are not using parse_str() due to max_input_vars limitation with large View configurations
            $fields_holder = array();
            GVCommon::gv_parse_str($_POST['fields'], $fields_holder);
            if (isset($fields_holder['fields'])) {
                $fields = $fields_holder['fields'];
            } else {
                do_action('gravityview_log_error', '[save_postdata] No `fields` key was found after parsing $fields string', $fields_holder);
            }
        } else {
            $fields = $_POST['fields'];
        }
    }
    return $fields;
}
开发者ID:mgratch,项目名称:GravityView,代码行数:30,代码来源:helper-functions.php


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