當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PodsForm類代碼示例

本文整理匯總了PHP中PodsForm的典型用法代碼示例。如果您正苦於以下問題:PHP PodsForm類的具體用法?PHP PodsForm怎麽用?PHP PodsForm使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PodsForm類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: wizard_form

function wizard_form($data = null, $name = null, $data_name, $data_text, $checked = true)
{
    if (!empty($data)) {
        ?>
		<div class="stuffbox pods-package-import-group">
			<h3><label for="link_name"><?php 
        _e($data_text, 'pods');
        ?>
</label></h3>

			<div class="inside pods-manage-field pods-dependency">
				<div class="pods-field-option-group">
					<p>
						<a href="#toggle" class="button pods-wizard-toggle-all"
						   data-toggle="<?php 
        echo $data_name;
        ?>
"><?php 
        _e('Toggle all on / off', 'pods');
        ?>
</a>
					</p>

					<div class="pods-pick-values pods-pick-checkbox pods-zebra">
						<ul>
							<?php 
        $zebra = false;
        foreach ($data as $item) {
            $class = $zebra ? 'even' : 'odd';
            $zebra = !$zebra;
            ?>
								<li class="pods-zebra-<?php 
            echo $class;
            ?>
">
									<?php 
            echo PodsForm::field($data_name . '[' . $item[$name] . ']', $checked, 'boolean', array('boolean_yes_label' => $item['name'] . (!empty($item['label']) ? ' (' . $item['label'] . ')' : '')));
            ?>
								</li>
							<?php 
        }
        ?>
						</ul>
					</div>
				</div>
			</div>
		</div>
<?php 
    }
}
開發者ID:pods-framework,項目名稱:pods-deploy,代碼行數:50,代碼來源:pods-wizard.php

示例2: ui

 /**
  *
  * Generate UI for Data Management
  *
  * @param mixed $options Array or String containing Pod or Options to be used
  * @param bool $amend Whether to amend the default UI options or replace entirely
  *
  * @return PodsUI|void UI object or void if custom UI used
  *
  * @since 2.3.10
  */
 public function ui($options = null, $amend = false)
 {
     $num = '';
     if (empty($options)) {
         $options = array();
     } else {
         $num = pods_var('num', $options, '');
         if (empty($num)) {
             $num = '';
         }
     }
     if ($this->id() != pods_var('id' . $num, 'get', null, null, true)) {
         $this->fetch(pods_var('id' . $num, 'get', null, null, true));
     }
     if (!empty($options) && !$amend) {
         $this->ui = $options;
         return pods_ui($this);
     } elseif (!empty($options) || 'custom' != pods_var('ui_style', $this->pod_data['options'], 'post_type', null, true)) {
         $actions_enabled = pods_var_raw('ui_actions_enabled', $this->pod_data['options']);
         if (!empty($actions_enabled)) {
             $actions_enabled = (array) $actions_enabled;
         } else {
             $actions_enabled = array();
         }
         $available_actions = array('add', 'edit', 'duplicate', 'delete', 'reorder', 'export');
         if (!empty($actions_enabled)) {
             $actions_disabled = array('view' => 'view');
             foreach ($available_actions as $action) {
                 if (!in_array($action, $actions_enabled)) {
                     $actions_disabled[$action] = $action;
                 }
             }
         } else {
             $actions_disabled = array('duplicate' => 'duplicate', 'view' => 'view', 'export' => 'export');
             if (1 == pods_var('ui_export', $this->pod_data['options'], 0)) {
                 unset($actions_disabled['export']);
             }
         }
         if (empty($options)) {
             $author_restrict = false;
             if (isset($this->fields['author']) && 'pick' == $this->fields['author']['type'] && 'user' == $this->fields['author']['pick_object']) {
                 $author_restrict = 'author.ID';
             }
             if (!pods_is_admin(array('pods', 'pods_content'))) {
                 if (!current_user_can('pods_add_' . $this->pod)) {
                     $actions_disabled['add'] = 'add';
                     if ('add' == pods_var('action' . $num, 'get')) {
                         $_GET['action' . $num] = 'manage';
                     }
                 }
                 if (!$author_restrict && !current_user_can('pods_edit_' . $this->pod) && !current_user_can('pods_edit_others_' . $this->pod)) {
                     $actions_disabled['edit'] = 'edit';
                 }
                 if (!$author_restrict && !current_user_can('pods_delete_' . $this->pod) && !current_user_can('pods_delete_others_' . $this->pod)) {
                     $actions_disabled['delete'] = 'delete';
                 }
                 if (!current_user_can('pods_reorder_' . $this->pod)) {
                     $actions_disabled['reorder'] = 'reorder';
                 }
                 if (!current_user_can('pods_export_' . $this->pod)) {
                     $actions_disabled['export'] = 'export';
                 }
             }
         }
         $_GET['action' . $num] = pods_var('action' . $num, 'get', pods_var('action', $options, 'manage'));
         $index = $this->pod_data['field_id'];
         $label = __('ID', 'pods');
         if (isset($this->pod_data['fields'][$this->pod_data['field_index']])) {
             $index = $this->pod_data['field_index'];
             $label = $this->pod_data['fields'][$this->pod_data['field_index']];
         }
         $manage = array($index => $label);
         if (isset($this->pod_data['fields']['modified'])) {
             $manage['modified'] = $this->pod_data['fields']['modified']['label'];
         }
         $manage_fields = pods_var_raw('ui_fields_manage', $this->pod_data['options']);
         if (!empty($manage_fields)) {
             $manage_new = array();
             foreach ($manage_fields as $manage_field) {
                 if (isset($this->pod_data['fields'][$manage_field])) {
                     $manage_new[$manage_field] = $this->pod_data['fields'][$manage_field];
                 } elseif (isset($this->pod_data['object_fields'][$manage_field])) {
                     $manage_new[$manage_field] = $this->pod_data['object_fields'][$manage_field];
                 } elseif ($manage_field == $this->pod_data['field_id']) {
                     $field = array('name' => $manage_field, 'label' => 'ID', 'type' => 'number', 'width' => '8%');
                     $manage_new[$manage_field] = PodsForm::field_setup($field, null, $field['type']);
                 }
             }
             if (!empty($manage_new)) {
//.........這裏部分代碼省略.........
開發者ID:erkmen,項目名稱:wpstartersetup,代碼行數:101,代碼來源:Pods.php

示例3: array

<?php

$type = 'textarea';
$attributes = array();
$attributes['tabindex'] = 2;
$attributes = PodsForm::merge_attributes($attributes, $name, $form_field_type, $options);
if (pods_var('readonly', $options, false)) {
    $attributes['readonly'] = 'READONLY';
    $attributes['class'] .= ' pods-form-ui-read-only';
}
?>
    <textarea<?php 
PodsForm::attributes($attributes, $name, $form_field_type, $options);
?>
><?php 
echo esc_textarea($value);
?>
</textarea>
<?php 
PodsForm::regex($form_field_type, $options);
開發者ID:dylansmithing,項目名稱:leader-of-rock-wordpress,代碼行數:20,代碼來源:textarea.php

示例4: wp_enqueue_script

<?php

wp_enqueue_script('pods-codemirror');
wp_enqueue_style('pods-codemirror');
wp_enqueue_script('pods-codemirror-loadmode');
$type = 'textarea';
$attributes = array();
$attributes['tabindex'] = 2;
$attributes = PodsForm::merge_attributes($attributes, $name, $form_field_type, $options, 'pods-ui-field-codemirror');
?>
<div class="code-toolbar"><!-- Placeholder --></div>
<textarea<?php 
PodsForm::attributes($attributes, $name, $form_field_type, $options);
?>
><?php 
echo esc_textarea($value);
?>
</textarea>
<div class="code-footer"><!-- Placeholder --></div>

<script>
    var $textarea_<?php 
echo esc_js(pods_js_name($attributes['id']));
?>
, codemirror_<?php 
echo esc_js(pods_js_name($attributes['id']));
?>
;

    jQuery( function ( $ ) {
        $textarea_<?php 
開發者ID:dylansmithing,項目名稱:leader-of-rock-wordpress,代碼行數:31,代碼來源:codemirror.php

示例5: elseif

    $plupload_init['filters'][0]['extensions'] = $limit_types;
}
if (is_admin() && !empty($post_ID)) {
    $plupload_init['multipart_params']['post_id'] = (int) $post_ID;
} elseif (is_object($pod) && in_array($pod->pod_data['type'], array('post_type', 'media')) && 0 < $id) {
    $plupload_init['multipart_params']['post_id'] = (int) $id;
}
$plupload_init = apply_filters('plupload_init', $plupload_init);
if (empty($value)) {
    $value = array();
} else {
    $value = (array) $value;
}
?>
<div<?php 
PodsForm::attributes(array('class' => $attributes['class'], 'id' => $attributes['id']), $name, $form_field_type, $options);
?>
>
    <ul class="pods-files pods-files-list"><?php 
// no extra space in ul or CSS:empty won't work
foreach ($value as $val) {
    $attachment = get_post($val);
    if (empty($attachment)) {
        continue;
    }
    $thumb = wp_get_attachment_image_src($val, 'thumbnail', true);
    $title = $attachment->post_title;
    if (0 == $title_editable) {
        $title = basename($attachment->guid);
    }
    echo $field_file->markup($attributes, $file_limit, $title_editable, $val, $thumb[0], $title);
開發者ID:Ingenex,項目名稱:redesign,代碼行數:31,代碼來源:plupload.php

示例6: import

 /**
  * Import data from an array or a CSV file.
  *
  * @param mixed $import_data PHP associative array or CSV input
  * @param bool $numeric_mode Use IDs instead of the name field when matching
  * @param string $format Format of import data, options are php or csv
  *
  * @return array IDs of imported items
  *
  * @since 1.7.1
  * @todo This needs some love and use of table_info etc for relationships
  */
 public function import($import_data, $numeric_mode = false, $format = null)
 {
     /**
      * @var $wpdb wpdb
      */
     global $wpdb;
     if (null === $format && null !== $this->format) {
         $format = $this->format;
     }
     if ('csv' == $format && !is_array($import_data)) {
         $data = pods_migrate('sv', ',')->parse($import_data);
         $import_data = $data['items'];
     }
     pods_query("SET NAMES utf8");
     pods_query("SET CHARACTER SET utf8");
     // Loop through the array of items
     $ids = array();
     // Test to see if it's an array of arrays
     if (!is_array(@current($import_data))) {
         $import_data = array($import_data);
     }
     $pod = $this->load_pod(array('name' => $this->pod));
     if (false === $pod) {
         return pods_error(__('Pod not found', 'pods'), $this);
     }
     $fields = array_merge($pod['fields'], $pod['object_fields']);
     $simple_tableless_objects = PodsForm::simple_tableless_objects();
     foreach ($import_data as $key => $data_row) {
         $data = array();
         // Loop through each field (use $fields so only valid fields get parsed)
         foreach ($fields as $field_name => $field_data) {
             if (!isset($data_row[$field_name]) && !isset($data_row[$field_data['label']])) {
                 continue;
             }
             $field_id = $field_data['id'];
             $type = $field_data['type'];
             $pick_object = isset($field_data['pick_object']) ? $field_data['pick_object'] : '';
             $pick_val = isset($field_data['pick_val']) ? $field_data['pick_val'] : '';
             if (isset($data_row[$field_name])) {
                 $field_value = $data_row[$field_name];
             } else {
                 $field_value = $data_row[$field_data['label']];
             }
             if (null !== $field_value && false !== $field_value && '' !== $field_value) {
                 if ('pick' == $type || in_array($type, PodsForm::file_field_types())) {
                     $field_values = is_array($field_value) ? $field_value : array($field_value);
                     $pick_values = array();
                     foreach ($field_values as $pick_value) {
                         if (in_array($type, PodsForm::file_field_types()) || 'media' == $pick_object) {
                             $where = "`guid` = '" . pods_sanitize($pick_value) . "'";
                             if (0 < pods_absint($pick_value) && false !== $numeric_mode) {
                                 $where = "`ID` = " . pods_absint($pick_value);
                             }
                             $result = pods_query("SELECT `ID` AS `id` FROM `{$wpdb->posts}` WHERE `post_type` = 'attachment' AND {$where} ORDER BY `ID`", $this);
                             if (!empty($result)) {
                                 $pick_values[] = $result[0]->id;
                             }
                         } elseif ('pick' == $type) {
                             $related_pod = false;
                             if ('pod' == $pick_object) {
                                 $related_pod = $this->load_pod(array('name' => $pick_val, 'table_info' => true), false);
                             }
                             if (empty($related_pod)) {
                                 $related_pod = array('id' => 0, 'type' => $pick_object);
                             }
                             if (in_array('taxonomy', array($pick_object, $related_pod['type']))) {
                                 $where = "`t`.`name` = '" . pods_sanitize($pick_value) . "'";
                                 if (0 < pods_absint($pick_value) && false !== $numeric_mode) {
                                     $where = "`tt`.`term_id` = " . pods_absint($pick_value);
                                 }
                                 $result = pods_query("SELECT `t`.`term_id` AS `id` FROM `{$wpdb->term_taxonomy}` AS `tt` LEFT JOIN `{$wpdb->terms}` AS `t` ON `t`.`term_id` = `tt`.`term_id` WHERE `taxonomy` = '{$pick_val}' AND {$where} ORDER BY `t`.`term_id`", $this);
                                 if (!empty($result)) {
                                     $pick_values[] = $result[0]->id;
                                 }
                             } elseif (in_array('post_type', array($pick_object, $related_pod['type'])) || in_array('media', array($pick_object, $related_pod['type']))) {
                                 $where = "`post_title` = '" . pods_sanitize($pick_value) . "'";
                                 if (0 < pods_absint($pick_value) && false !== $numeric_mode) {
                                     $where = "`ID` = " . pods_absint($pick_value);
                                 }
                                 $result = pods_query("SELECT `ID` AS `id` FROM `{$wpdb->posts}` WHERE `post_type` = '{$pick_val}' AND {$where} ORDER BY `ID`", $this);
                                 if (!empty($result)) {
                                     $pick_values[] = $result[0]->id;
                                 }
                             } elseif (in_array('user', array($pick_object, $related_pod['type']))) {
                                 $where = "`user_login` = '" . pods_sanitize($pick_value) . "'";
                                 if (0 < pods_absint($pick_value) && false !== $numeric_mode) {
                                     $where = "`ID` = " . pods_absint($pick_value);
                                 }
//.........這裏部分代碼省略.........
開發者ID:satokora,項目名稱:IT354Project,代碼行數:101,代碼來源:PodsAPI.php

示例7: table


//.........這裏部分代碼省略.........
                ?>
" class="iedit<?php 
                echo esc_attr($toggle_class);
                ?>
">
                            <?php 
                if (!empty($this->actions_bulk)) {
                    ?>
                                <th scope="row" class="check-column"><input type="checkbox" name="action_bulk_ids<?php 
                    echo esc_attr($this->num);
                    ?>
[]" value="<?php 
                    echo esc_attr($row[$this->sql['field_id']]);
                    ?>
"></th>
            <?php 
                }
                foreach ($fields as $field => $attributes) {
                    if (false === $attributes['display']) {
                        continue;
                    }
                    if (!isset($row[$field])) {
                        $row[$field] = $this->get_field($field);
                    }
                    $row_value = $row[$field];
                    if (!empty($attributes['custom_display'])) {
                        if (is_callable($attributes['custom_display'])) {
                            $row_value = call_user_func_array($attributes['custom_display'], array($row, &$this, $row_value, $field, $attributes));
                        } elseif (is_object($this->pod) && class_exists('Pods_Helpers')) {
                            $row_value = $this->pod->helper($attributes['custom_display'], $row_value, $field);
                        }
                    } else {
                        ob_start();
                        $field_value = PodsForm::field_method($attributes['type'], 'ui', $this->id, $row_value, $field, array_merge($attributes, pods_var_raw('options', $attributes, array(), null, true)), $fields, $this->pod);
                        $field_output = trim((string) ob_get_clean());
                        if (false === $field_value) {
                            $row_value = '';
                        } elseif (0 < strlen(trim((string) $field_value))) {
                            $row_value = trim((string) $field_value);
                        } elseif (0 < strlen($field_output)) {
                            $row_value = $field_output;
                        }
                    }
                    if (false !== $attributes['custom_relate']) {
                        global $wpdb;
                        $table = $attributes['custom_relate'];
                        $on = $this->sql['field_id'];
                        $is = $row[$this->sql['field_id']];
                        $what = array('name');
                        if (is_array($table)) {
                            if (isset($table['on'])) {
                                $on = pods_sanitize($table['on']);
                            }
                            if (isset($table['is']) && isset($row[$table['is']])) {
                                $is = pods_sanitize($row[$table['is']]);
                            }
                            if (isset($table['what'])) {
                                $what = array();
                                if (is_array($table['what'])) {
                                    foreach ($table['what'] as $wha) {
                                        $what[] = pods_sanitize($wha);
                                    }
                                } else {
                                    $what[] = pods_sanitize($table['what']);
                                }
                            }
開發者ID:dylansmithing,項目名稱:leader-of-rock-wordpress,代碼行數:67,代碼來源:PodsUI.php

示例8: foreach

                                            <div class="pods-pick-values pods-pick-checkbox pods-zebra">
                                                <ul>
                                                    <?php 
    $zebra = false;
    foreach ($data as $item) {
        $checked = true;
        $class = $zebra ? 'even' : 'odd';
        $zebra = !$zebra;
        ?>
                                                        <li class="pods-zebra-<?php 
        echo $class;
        ?>
">
                                                            <?php 
        echo PodsForm::field($data_name . '[' . $item['id'] . ']', $checked, 'boolean', array('boolean_yes_label' => $item['name'] . (!empty($item['label']) ? ' (' . $item['label'] . ')' : '')));
        ?>
                                                        </li>
                                                    <?php 
    }
    ?>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            <?php 
}
do_action('pods_packages_export_options', $pods, $pod_templates, $pod_pages, $pod_helpers);
?>
                        </div>
開發者ID:satokora,項目名稱:IT354Project,代碼行數:30,代碼來源:wizard.php

示例9:

            <?php 
    } else {
        $option_label = (string) $option_label;
        $selected = '';
        $options['selected'] = '';
        if (!$selection_made && (!is_array($value) && (string) $option_value === (string) $value || is_array($value) && (in_array($option_value, $value) || in_array((string) $option_value, $value)))) {
            $selected = ' SELECTED';
            $options['selected'] = 'selected';
            if (!$multiple) {
                $selection_made = true;
            }
        }
        if (is_array($option_value)) {
            ?>
                <option<?php 
            PodsForm::attributes($option_value, $name, $form_field_type . '_option', $options);
            ?>
><?php 
            echo esc_html($option_label);
            ?>
</option>
                <?php 
        } else {
            ?>
                <option value="<?php 
            echo esc_attr($option_value);
            ?>
"<?php 
            echo $selected;
            ?>
><?php 
開發者ID:centaurustech,項目名稱:chipin,代碼行數:31,代碼來源:select.php

示例10: foreach

                                <?php 
        foreach ($field_option['group'] as $field_group_name => $field_group_option) {
            $field_group_option = PodsForm::field_setup($field_group_option, null, $field_group_option['type']);
            if ('boolean' != $field_group_option['type']) {
                continue;
            }
            $field_group_option['boolean_yes_label'] = $field_group_option['label'];
            $depends_option = PodsForm::dependencies($field_group_option);
            $value = pods_var_raw($field_group_name, $settings, $field_group_option['default']);
            ?>
                                    <li class="<?php 
            echo $depends_option;
            ?>
">
                                        <?php 
            echo PodsForm::field('pods_setting_' . $field_group_name, $value, $field_group_option['type'], $field_group_option);
            ?>
                                    </li>
                                <?php 
        }
        ?>
                            </ul>
                        </td>
                    </tr>
                <?php 
    }
    if (false !== $depends_on || !empty($depends)) {
        $depends_on = $depends;
    }
}
if (!empty($depends_on)) {
開發者ID:satokora,項目名稱:IT354Project,代碼行數:31,代碼來源:components-admin.php

示例11: input

 /**
  * Customize output of the form field
  *
  * @param string $name
  * @param mixed $value
  * @param array $options
  * @param array $pod
  * @param int $id
  *
  * @since 2.0
  */
 public function input($name, $value = null, $options = null, $pod = null, $id = null)
 {
     $options = (array) $options;
     $form_field_type = PodsForm::$field_type;
     if (is_array($value)) {
         $value = implode("\n", $value);
     }
     if (isset($options['name']) && false === PodsForm::permission(self::$type, $options['name'], $options, null, $pod, $id)) {
         if (pods_var('read_only', $options, false)) {
             $options['readonly'] = true;
             $field_type = 'textarea';
         } else {
             return;
         }
     } elseif (!pods_has_permissions($options) && pods_var('read_only', $options, false)) {
         $options['readonly'] = true;
         $field_type = 'textarea';
     } elseif ('tinymce' == pods_var(self::$type . '_editor', $options)) {
         $field_type = 'tinymce';
     } elseif ('cleditor' == pods_var(self::$type . '_editor', $options)) {
         $field_type = 'cleditor';
     } else {
         // Support custom WYSIWYG integration
         do_action('pods_form_ui_field_wysiwyg_' . pods_var(self::$type . '_editor', $options), $name, $value, $options, $pod, $id);
         do_action('pods_form_ui_field_wysiwyg', pods_var(self::$type . '_editor', $options), $name, $value, $options, $pod, $id);
         return;
     }
     pods_view(PODS_DIR . 'ui/fields/' . $field_type . '.php', compact(array_keys(get_defined_vars())));
 }
開發者ID:dylansmithing,項目名稱:leader-of-rock-wordpress,代碼行數:40,代碼來源:wysiwyg.php

示例12:

<label<?php 
PodsForm::attributes($attributes, $name, 'label');
?>
>
    <?php 
echo $label;
if (1 == pods_var('required', $options, pods_var('options', $options, $options))) {
    echo ' <abbr title="required" class="required">*</abbr>';
}
if (0 == pods_var('grouped', $options, 0, null, true) && !empty($help) && 'help' != $help) {
    pods_help($help);
}
?>
</label>
開發者ID:dylansmithing,項目名稱:leader-of-rock-wordpress,代碼行數:14,代碼來源:_label.php

示例13: foreach

					</p>

					<div class="pods-pick-values pods-pick-checkbox pods-zebra">
						<ul>
							<?php 
$zebra = false;
foreach ($this->exportable_pods() as $this_pod) {
    $class = $zebra ? 'even' : 'odd';
    $zebra = !$zebra;
    ?>
								<li class="pods-zebra-<?php 
    echo $class;
    ?>
">
									<?php 
    echo PodsForm::field($this_pod['name'], true, 'boolean', array('boolean_yes_label' => $this_pod['name'] . (!empty($this_pod['label']) ? ' (' . $this_pod['label'] . ')' : '')));
    ?>
								</li>
							<?php 
}
?>
						</ul>
					</div>
					<div class="submit">
						<a class="button button-primary" id="export" href="#"> Export </a>
					</div>
					<textarea id="feedback"></textarea>
				</div>
			</div>
		</div>
	</form>
開發者ID:oligoform,項目名稱:pods-export-code,代碼行數:31,代碼來源:admin.php

示例14: admin_ajax_upload

 /**
  * Handle plupload AJAX
  *
  * @since 2.3
  */
 public function admin_ajax_upload()
 {
     if (false === headers_sent()) {
         if ('' == session_id()) {
             @session_start();
         }
     }
     // Sanitize input
     $params = stripslashes_deep((array) $_POST);
     foreach ($params as $key => $value) {
         if ('action' == $key) {
             continue;
         }
         unset($params[$key]);
         $params[str_replace('_podsfix_', '', $key)] = $value;
     }
     $params = (object) $params;
     $methods = array('upload');
     if (!isset($params->method) || !in_array($params->method, $methods) || !isset($params->pod) || !isset($params->field) || !isset($params->uri) || empty($params->uri)) {
         pods_error('Invalid AJAX request', PodsInit::$admin);
     } elseif (!empty($params->pod) && empty($params->field)) {
         pods_error('Invalid AJAX request', PodsInit::$admin);
     } elseif (empty($params->pod) && !current_user_can('upload_files')) {
         pods_error('Invalid AJAX request', PodsInit::$admin);
     }
     // Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead
     if (is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie'])) {
         $_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie'];
     } elseif (empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie'])) {
         $_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie'];
     }
     if (empty($_COOKIE[LOGGED_IN_COOKIE]) && !empty($_REQUEST['logged_in_cookie'])) {
         $_COOKIE[LOGGED_IN_COOKIE] = $_REQUEST['logged_in_cookie'];
     }
     global $current_user;
     unset($current_user);
     /**
      * Access Checking
      */
     $upload_disabled = false;
     if (defined('PODS_DISABLE_FILE_UPLOAD') && true === PODS_DISABLE_FILE_UPLOAD) {
         $upload_disabled = true;
     } elseif (defined('PODS_UPLOAD_REQUIRE_LOGIN') && is_bool(PODS_UPLOAD_REQUIRE_LOGIN) && true === PODS_UPLOAD_REQUIRE_LOGIN && !is_user_logged_in()) {
         $upload_disabled = true;
     } elseif (defined('PODS_UPLOAD_REQUIRE_LOGIN') && !is_bool(PODS_UPLOAD_REQUIRE_LOGIN) && (!is_user_logged_in() || !current_user_can(PODS_UPLOAD_REQUIRE_LOGIN))) {
         $upload_disabled = true;
     }
     $uid = @session_id();
     if (is_user_logged_in()) {
         $uid = 'user_' . get_current_user_id();
     }
     $nonce_check = 'pods_upload_' . (int) $params->pod . '_' . $uid . '_' . $params->uri . '_' . (int) $params->field;
     if (true === $upload_disabled || !isset($params->_wpnonce) || false === wp_verify_nonce($params->_wpnonce, $nonce_check)) {
         pods_error(__('Unauthorized request', 'pods'), PodsInit::$admin);
     }
     $pod = array();
     $field = array('type' => 'file', 'options' => array());
     $api = pods_api();
     if (!empty($params->pod)) {
         $pod = $api->load_pod(array('id' => (int) $params->pod));
         $field = $api->load_field(array('id' => (int) $params->field));
         if (empty($pod) || empty($field) || $pod['id'] != $field['pod_id'] || !isset($pod['fields'][$field['name']])) {
             pods_error(__('Invalid field request', 'pods'), PodsInit::$admin);
         }
         if (!in_array($field['type'], PodsForm::file_field_types())) {
             pods_error(__('Invalid field', 'pods'), PodsInit::$admin);
         }
     }
     $method = $params->method;
     // Cleaning up $params
     unset($params->action);
     unset($params->method);
     unset($params->_wpnonce);
     $params->post_id = pods_var('post_id', $params, 0, null, true);
     /**
      * Upload a new file (advanced - returns URL and ID)
      */
     if ('upload' == $method) {
         $file = $_FILES['Filedata'];
         $limit_size = pods_var($field['type'] . '_restrict_filesize', $field['options']);
         if (!empty($limit_size)) {
             if (false !== stripos($limit_size, 'MB')) {
                 $limit_size = (double) trim(str_ireplace('MB', '', $limit_size));
                 $limit_size = $limit_size * 1025 * 1025;
                 // convert to KB to B
             } elseif (false !== stripos($limit_size, 'KB')) {
                 $limit_size = (double) trim(str_ireplace('KB', '', $limit_size));
                 $limit_size = $limit_size * 1025 * 1025;
                 // convert to B
             } elseif (false !== stripos($limit_size, 'GB')) {
                 $limit_size = (double) trim(str_ireplace('GB', '', $limit_size));
                 $limit_size = $limit_size * 1025 * 1025 * 1025;
                 // convert to MB to KB to B
             } elseif (false !== stripos($limit_size, 'B')) {
                 $limit_size = (double) trim(str_ireplace('B', '', $limit_size));
//.........這裏部分代碼省略.........
開發者ID:centaurustech,項目名稱:chipin,代碼行數:101,代碼來源:file.php

示例15: admin_setup_edit_field_options

 /**
  * Get list of Pod field options
  *
  * @return array
  */
 public function admin_setup_edit_field_options($pod)
 {
     $options = array();
     $options['additional-field'] = array();
     $field_types = PodsForm::field_types();
     foreach ($field_types as $type => $field_type_data) {
         /**
          * @var $field_type PodsField
          */
         $field_type = PodsForm::field_loader($type, $field_type_data['file']);
         $field_type_vars = get_class_vars(get_class($field_type));
         if (!isset($field_type_vars['pod_types'])) {
             $field_type_vars['pod_types'] = true;
         }
         $options['additional-field'][$type] = array();
         // Only show supported field types
         if (true !== $field_type_vars['pod_types']) {
             if (empty($field_type_vars['pod_types'])) {
                 continue;
             } elseif (is_array($field_type_vars['pod_types']) && !in_array(pods_var('type', $pod), $field_type_vars['pod_types'])) {
                 continue;
             } elseif (!is_array($field_type_vars['pod_types']) && pods_var('type', $pod) != $field_type_vars['pod_types']) {
                 continue;
             }
         }
         $options['additional-field'][$type] = PodsForm::ui_options($type);
     }
     $input_helpers = array('' => '-- Select --');
     if (class_exists('Pods_Helpers')) {
         $helpers = pods_api()->load_helpers(array('options' => array('helper_type' => 'input')));
         foreach ($helpers as $helper) {
             $input_helpers[$helper['name']] = $helper['name'];
         }
     }
     $options['advanced'] = array(__('Visual', 'pods') => array('class' => array('name' => 'class', 'label' => __('Additional CSS Classes', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => ''), 'input_helper' => array('name' => 'input_helper', 'label' => __('Input Helper', 'pods'), 'help' => __('help', 'pods'), 'type' => 'pick', 'default' => '', 'data' => $input_helpers)), __('Values', 'pods') => array('default_value' => array('name' => 'default_value', 'label' => __('Default Value', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => ''), 'default_value_parameter' => array('name' => 'default_value_parameter', 'label' => __('Set Default Value via Parameter', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => '')), __('Visibility', 'pods') => array('restrict_access' => array('name' => 'restrict_access', 'label' => __('Restrict Access', 'pods'), 'group' => array('admin_only' => array('name' => 'admin_only', 'label' => __('Restrict access to Admins?', 'pods'), 'default' => 0, 'type' => 'boolean', 'dependency' => true, 'help' => __('This field will only be able to be edited by users with the ability to manage_options or delete_users, or super admins of a WordPress Multisite network', 'pods')), 'restrict_role' => array('name' => 'restrict_role', 'label' => __('Restrict access by Role?', 'pods'), 'default' => 0, 'type' => 'boolean', 'dependency' => true), 'restrict_capability' => array('name' => 'restrict_capability', 'label' => __('Restrict access by Capability?', 'pods'), 'default' => 0, 'type' => 'boolean', 'dependency' => true), 'hidden' => array('name' => 'hidden', 'label' => __('Hide field from UI', 'pods'), 'default' => 0, 'type' => 'boolean', 'help' => __('This option is overriden by access restrictions. If the user does not have access to edit this field, it will be hidden. If no access restrictions are set, this field will always be hidden.', 'pods')), 'read_only' => array('name' => 'read_only', 'label' => __('Make field "Read Only" in UI', 'pods'), 'default' => 0, 'type' => 'boolean', 'help' => __('This option is overriden by access restrictions. If the user does not have access to edit this field, it will be read only. If no access restrictions are set, this field will always be read only.', 'pods'), 'depends-on' => array('type' => array('boolean', 'color', 'currency', 'date', 'datetime', 'email', 'number', 'paragraph', 'password', 'phone', 'slug', 'text', 'time', 'website'))))), 'roles_allowed' => array('name' => 'roles_allowed', 'label' => __('Role(s) Allowed', 'pods'), 'help' => __('help', 'pods'), 'type' => 'pick', 'pick_object' => 'role', 'pick_format_type' => 'multi', 'default' => 'administrator', 'depends-on' => array('restrict_role' => true)), 'capability_allowed' => array('name' => 'capability_allowed', 'label' => __('Capability Allowed', 'pods'), 'help' => __('Comma-separated list of cababilities, for example add_podname_item, please see the Roles and Capabilities component for the complete list and a way to add your own.', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('restrict_capability' => true))));
     if (!class_exists('Pods_Helpers')) {
         unset($options['advanced-options']['input_helper']);
     }
     $options = apply_filters('pods_admin_setup_edit_field_options', $options, $pod);
     return $options;
 }
開發者ID:erkmen,項目名稱:wpstartersetup,代碼行數:46,代碼來源:PodsAdmin.php


注:本文中的PodsForm類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。