本文整理汇总了PHP中pods_var函数的典型用法代码示例。如果您正苦于以下问题:PHP pods_var函数的具体用法?PHP pods_var怎么用?PHP pods_var使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pods_var函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pods_markdown_output
function pods_markdown_output($value, $name, $options, $pod, $id, $traverse)
{
if (1 == pods_var($options['type'] . '_allow_markdown', $options)) {
$value = Markdown($value);
}
return $value;
}
示例2: display
/**
* Change the way the value of the field is displayed with Pods::get
*
* @param mixed $value
* @param string $name
* @param array $options
* @param array $fields
* @param array $pod
* @param int $id
*
* @since 2.0
*/
public function display($value = null, $name = null, $options = null, $pod = null, $id = null)
{
if (1 == pods_var(self::$type . '_allow_shortcode', $options, 0)) {
$value = do_shortcode($value);
}
return $value;
}
示例3: admin
/**
* Build admin area
*
* @param $options
* @param $component
*
* @return void
* @since 2.0
*/
public function admin($options, $component)
{
global $wp_roles;
// Hook into Gravity Forms roles (since it only adds filter if Members plugin itself is activated
if (class_exists('RGForms') && !has_filter('members_get_capabilities', array('RGForms', 'members_get_capabilities'))) {
add_filter('members_get_capabilities', array('RGForms', 'members_get_capabilities'));
}
$default_role = get_option('default_role');
$roles = array();
foreach ($wp_roles->role_objects as $key => $role) {
$count = $this->count_users($key);
$roles[$key] = array('id' => $key, 'label' => $wp_roles->role_names[$key], 'name' => $key, 'capabilities' => count((array) $role->capabilities), 'users' => sprintf(_n('%s User', '%s Users', $count, 'pods'), $count));
if ($default_role == $key) {
$roles[$key]['label'] .= ' (site default)';
}
if (0 < $count && pods_is_admin(array('list_users'))) {
$roles[$key]['users'] .= '<br /><a href="' . admin_url(esc_url('users.php?role=' . $key)) . '">' . __('View Users', 'pods') . '</a>';
}
}
$ui = array('component' => $component, 'data' => $roles, 'total' => count($roles), 'total_found' => count($roles), 'icon' => PODS_URL . 'ui/images/icon32.png', 'items' => 'Roles', 'item' => 'Role', 'fields' => array('manage' => array('label' => array('label' => __('Label', 'pods')), 'name' => array('label' => __('Name', 'pods')), 'capabilities' => array('label' => __('Capabilities', 'pods')), 'users' => array('label' => __('Users', 'pods'), 'type' => 'text', 'options' => array('text_allow_html' => 1, 'text_allowed_html_tags' => '')))), 'actions_disabled' => array('duplicate', 'view', 'export'), 'actions_custom' => array('add' => array($this, 'admin_add'), 'edit' => array($this, 'admin_edit'), 'delete' => array($this, 'admin_delete')), 'search' => false, 'searchable' => false, 'sortable' => false, 'pagination' => false);
if (isset($roles[pods_var('id', 'get', -1)])) {
$ui['row'] = $roles[pods_var('id', 'get', -1)];
}
if (!pods_is_admin(array('pods_roles_add'))) {
$ui['actions_disabled'][] = 'add';
}
if (!pods_is_admin(array('pods_roles_edit'))) {
$ui['actions_disabled'][] = 'edit';
}
if (count($roles) < 2 || !pods_is_admin(array('pods_roles_delete'))) {
$ui['actions_disabled'][] = 'delete';
}
pods_ui($ui);
}
示例4: migrate_relationships
/**
* @return string
*/
public function migrate_relationships()
{
if (true === $this->check_progress(__FUNCTION__)) {
return '1';
}
$migration_limit = (int) apply_filters('pods_upgrade_item_limit', 1500);
$migration_limit = max($migration_limit, 100);
$last_id = (int) $this->check_progress(__FUNCTION__);
$relationship_fields = $this->api->load_fields(array('type' => array('pick', 'file')));
foreach ($relationship_fields as $field) {
$pod = $this->api->load_pod(array('pod' => $field['pod']));
// Only target pods that are meta-enabled
if (!in_array($pod['type'], array('post_type', 'media', 'user', 'comment'))) {
continue;
}
// Only target multi-select relationships
$single_multi = pods_var($field['type'] . '_format_type', $field['options'], 'single');
if ('multi' == $single_multi) {
$limit = (int) pods_var($field['type'] . '_limit', $field['options'], 0);
} else {
$limit = 1;
}
if ($limit <= 1) {
continue;
}
// Get and loop through relationship meta
$sql = "\n\n ";
// if serialized (or array), save as individual meta items and save new order meta key
}
$last_id = true;
$rel = array();
$this->update_progress(__FUNCTION__, $last_id);
if ($migration_limit == count($rel)) {
return '-2';
} else {
return '1';
}
}
示例5: pods_var_raw
echo $indent;
?>
>
<input<?php
PodsForm::attributes($attributes, $name, $form_field_type, $options);
?>
/>
<?php
if (0 < strlen($label)) {
$help = pods_var_raw('help', $options);
if (1 == pods_var('grouped', $options, 0, null, true) || empty($help)) {
$help = '';
}
echo PodsForm::label($attributes['id'], $label, $help);
}
?>
</div>
<?php
if (1 == pods_var('grouped', $options, 0, null, true)) {
?>
</li>
<?php
}
$counter++;
}
if (1 == pods_var('grouped', $options, 0, null, true)) {
?>
</ul>
</div>
<?php
}
示例6: migrate_pod
/**
* @param $params
*
* @return mixed|string|void
*/
public function migrate_pod($params)
{
/**
* @var $wpdb WPDB
*/
global $wpdb;
if (!isset($params->pod)) {
return pods_error(__('Invalid Pod.', 'pods'));
}
$pod = pods_sanitize(pods_clean_name($params->pod));
if (!in_array("{$wpdb->prefix}pod_tbl_{$pod}", $this->tables)) {
return pods_error(__('Table not found, items cannot be migrated', 'pods'));
}
if (!in_array("{$wpdb->prefix}pods_{$pod}", $this->tables)) {
return pods_error(__('New table not found, items cannot be migrated', 'pods'));
}
if (!in_array("{$wpdb->prefix}pod_types", $this->tables)) {
return pods_error(__('Pod Types table not found, items cannot be migrated', 'pods'));
}
if (!in_array("{$wpdb->prefix}pod", $this->tables)) {
return pods_error(__('Pod table not found, items cannot be migrated', 'pods'));
}
if (true === $this->check_progress(__FUNCTION__, $pod)) {
return '1';
}
$pod_data = $this->api->load_pod(array('name' => $pod), false);
if (empty($pod_data)) {
return pods_error(sprintf(__('Pod <strong>%s</strong> not found, items cannot be migrated', 'pods'), $pod));
}
$columns = array();
$old_columns = array();
foreach ($pod_data['fields'] as $field) {
if (!in_array($field['name'], array('created', 'modified', 'author')) && !in_array($field['type'], array('file', 'pick'))) {
$columns[] = pods_sanitize($field['name']);
$old_columns[] = pods_var('_pods_1x_field_name', $field['options'], $field['name'], null, false);
}
}
$into = '`id`';
$select = '`t`.`id`';
if (!empty($columns)) {
$into .= ', `' . implode('`, `', $columns) . '`';
$select .= ', `t`.`' . implode('`, `t`.`', $old_columns) . '`';
}
// Copy content from the old table into the new
$sql = "\n REPLACE INTO `@wp_pods_{$pod}`\n ( {$into} )\n ( SELECT {$select}\n FROM `@wp_pod_tbl_{$pod}` AS `t` )\n ";
pods_query($sql);
// Copy index data from the old index table into the new individual table
$sql = "\n UPDATE `@wp_pods_{$pod}` AS `t`\n LEFT JOIN `@wp_pod_types` AS `x` ON `x`.`name` = '{$pod}'\n LEFT JOIN `@wp_pod` AS `p` ON `p`.`datatype` = `x`.`id` AND `p`.`tbl_row_id` = `t`.`id`\n SET `t`.`created` = `p`.`created`, `t`.`modified` = `p`.`modified`\n WHERE `x`.`id` IS NOT NULL AND `p`.`id` IS NOT NULL\n ";
pods_query($sql);
// Copy name data from the old index table into the new individual table (if name empty in indiv table)
$sql = "\n UPDATE `@wp_pods_{$pod}` AS `t`\n LEFT JOIN `@wp_pod_types` AS `x` ON `x`.`name` = '{$pod}'\n LEFT JOIN `@wp_pod` AS `p` ON `p`.`datatype` = `x`.`id` AND `p`.`tbl_row_id` = `t`.`id`\n SET `t`.`name` = `p`.`name`\n WHERE ( `t`.`name` IS NULL OR `t`.`name` = '' ) AND `x`.`id` IS NOT NULL AND `p`.`id` IS NOT NULL\n ";
pods_query($sql);
$this->update_progress(__FUNCTION__, true, $pod);
return '1';
}
示例7: fields_setup
/**
* Get options for a field and setup defaults
*
*
* @param null $fields
* @param null $core_defaults
* @param bool $single
*
* @return array|null
*
* @static
* @since 2.0
*/
public static function fields_setup($fields = null, $core_defaults = null, $single = false)
{
if (empty($core_defaults)) {
$core_defaults = array('id' => 0, 'name' => '', 'label' => '', 'description' => '', 'help' => '', 'default' => null, 'attributes' => array(), 'class' => '', 'type' => 'text', 'group' => 0, 'grouped' => 0, 'developer_mode' => false, 'dependency' => false, 'depends-on' => array(), 'excludes-on' => array(), 'options' => array());
}
if ($single) {
$fields = array($fields);
}
foreach ($fields as $f => $field) {
$fields[$f] = self::field_setup($field, $core_defaults, pods_var('type', $field, 'text'));
if (!$single && strlen($fields[$f]['name']) < 1) {
$fields[$f]['name'] = $f;
}
}
if ($single) {
$fields = $fields[0];
}
return $fields;
}
示例8: 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);
示例9: pods_upgrade
if (isset($_POST['cleanup_1x'])) {
pods_upgrade('2.0.0')->cleanup();
pods_redirect(pods_var_update(array('pods_cleanup_1x' => 1), array('page', 'tab')));
} elseif (isset($_POST['reset'])) {
$pods_init->reset();
$pods_init->setup();
pods_redirect(pods_var_update(array('pods_reset' => 1), array('page', 'tab')));
} elseif (isset($_POST['reset_deactivate'])) {
$pods_init->reset();
deactivate_plugins(PODS_DIR . 'init.php');
pods_redirect('index.php');
} elseif (1 == pods_var('pods_reset')) {
pods_message('Pods 2.x settings and data have been reset.');
} elseif (1 == pods_var('pods_cleanup_1x')) {
pods_message('Pods 1.x data has been deleted.');
} elseif (pods_var('reset_weekend', 'post', pods_var('reset_weekend', 'get', 0, null, true), null, true)) {
if ($monday_mode) {
$html = '<br /><br /><iframe width="480" height="360" src="http://www.youtube-nocookie.com/embed/QH2-TGUlwu4?autoplay=1" frameborder="0" allowfullscreen></iframe>';
pods_message('The weekend has been reset and you have been sent back to Friday night. Unfortunately due to a tear in the fabric of time, you slipped back to Monday. We took video of the whole process and you can see it below..' . $html);
} else {
$html = '<br /><br /><iframe width="480" height="360" src="http://www.youtube-nocookie.com/embed/xhrBDcQq2DM?autoplay=1" frameborder="0" allowfullscreen></iframe>';
pods_message('Oops, sorry! You can only reset the weekend on a Monday before the end of the work day. Somebody call the Waaambulance!' . $html, 'error');
}
}
$old_version = get_option('pods_version');
if (!empty($old_version)) {
?>
<h3><?php
_e('Delete Pods 1.x data', 'pods');
?>
</h3>
示例10: pods_has_permissions
/**
* Check if permissions are restricted
*
* @param array $options
*
* @return bool Whether the permissions are restricted
*
* @since 2.3.4
*/
function pods_has_permissions($options)
{
$permission = false;
if (isset($options['options'])) {
$options = $options['options'];
}
if (1 == pods_var('restrict_role', $options, 0) || 1 == pods_var('restrict_capability', $options, 0) || 1 == pods_var('admin_only', $options, 0)) {
return true;
}
return false;
}
示例11: _e
$field = $pod;
include PODS_DIR . 'ui/admin/field-option.php';
?>
</div>
<?php
}
if (isset($tabs['extra-fields'])) {
?>
<div id="pods-extra-fields" class="pods-nav-tab">
<p><?php
_e('Taxonomies do not support extra fields natively, but Pods can add this feature for you easily. Table based storage will operate in a way where each field you create for your content type becomes a field in a table.', 'pods');
?>
</p>
<p><?php
echo sprintf(__('Enabling extra fields for this taxonomy will add a custom table into your database as <em>%s</em>.', 'pods'), $wpdb->prefix . 'pods_' . pods_var('name', $pod));
?>
</p>
<p><a href="http://pods.io/docs/comparisons/compare-storage-types/" target="_blank"><?php
_e('Find out more', 'pods');
?>
»</a></p>
<p class="submit">
<a href="<?php
echo esc_url(pods_query_arg(array('enable_extra_fields' => 1)));
?>
" class="button-primary"><?php
_e('Enable Extra Fields', 'pods');
?>
示例12: format
/**
* Build date/time format string based on options
*
* @param $options
*
* @return string
* @since 2.0
*/
public function format($options)
{
$date_format = array('mdy' => 'm/d/Y', 'mdy_dash' => 'm-d-Y', 'mdy_dot' => 'm.d.Y', 'dmy' => 'd/m/Y', 'dmy_dash' => 'd-m-Y', 'dmy_dot' => 'd.m.Y', 'ymd_slash' => 'Y/m/d', 'ymd_dash' => 'Y-m-d', 'ymd_dot' => 'Y.m.d', 'dMy' => 'd/M/Y', 'dMy_dash' => 'd-M-Y', 'fjy' => 'F j, Y', 'fjsy' => 'F jS, Y', 'c' => 'c');
$time_format = array('h_mm_A' => 'g:i A', 'h_mm_ss_A' => 'g:i:s A', 'hh_mm_A' => 'h:i A', 'hh_mm_ss_A' => 'h:i:s A', 'h_mma' => 'g:ia', 'hh_mma' => 'h:ia', 'h_mm' => 'g:i', 'h_mm_ss' => 'g:i:s', 'hh_mm' => 'h:i', 'hh_mm_ss' => 'h:i:s');
$format_value = pods_var(self::$type . '_format', $options, 'ymd_dash', null, true);
$format = $date_format[$format_value];
if ('c' != $format_value) {
if (12 == pods_var(self::$type . '_time_type', $options)) {
$format .= ' ' . $time_format[pods_var(self::$type . '_time_format', $options, 'hh_mm', null, true)];
} else {
$format .= ' ' . str_replace(array('h:', 'g:'), 'H:', $time_format[pods_var(self::$type . '_time_format', $options, 'hh_mm', null, true)]);
}
}
return $format;
}
示例13: pods_var
<?php
/*
Template Name: Edit A Project Template
*/
$projectID = pods_var(-1, 'url');
$podForm = pods('project');
get_header();
?>
<div class="content clearfix">
<div class="header">
<h1>Edit your project</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<div class="start-project clearfix">
<?php
if (is_user_logged_in()) {
// Only show the 'name', 'description', and 'other' fields.
$fields = array('name', 'timeframe', 'budget', 'image', 'description', 'region');
// Output a form with specific fields
echo pods('project', $projectID)->form($fields);
} else {
?>
<h1>Please Login or Register to start a project.</h1>
<?php
}
示例14: admin_ajax_relationship
/**
* Handle autocomplete AJAX
*
* @since 2.3
*/
public function admin_ajax_relationship()
{
pods_session_start();
// Sanitize input
$params = pods_unslash((array) $_POST);
foreach ($params as $key => $value) {
if ('action' == $key) {
continue;
}
unset($params[$key]);
$params[str_replace('_podsfix_', '', $key)] = $value;
}
$params = (object) $params;
$uid = @session_id();
if (is_user_logged_in()) {
$uid = 'user_' . get_current_user_id();
}
$nonce_check = 'pods_relationship_' . (int) $params->pod . '_' . $uid . '_' . $params->uri . '_' . (int) $params->field;
if (!isset($params->_wpnonce) || false === wp_verify_nonce($params->_wpnonce, $nonce_check)) {
pods_error(__('Unauthorized request', 'pods'), PodsInit::$admin);
}
$api = pods_api();
$pod = $api->load_pod(array('id' => (int) $params->pod));
$field = $api->load_field(array('id' => (int) $params->field, 'table_info' => true));
$id = (int) $params->id;
$limit = 15;
if (isset($params->limit)) {
$limit = (int) $params->limit;
}
$page = 1;
if (isset($params->page)) {
$page = (int) $params->page;
}
if (!isset($params->query) || strlen(trim($params->query)) < 1) {
pods_error(__('Invalid field request', 'pods'), PodsInit::$admin);
} elseif (empty($pod) || empty($field) || $pod['id'] != $field['pod_id'] || !isset($pod['fields'][$field['name']])) {
pods_error(__('Invalid field request', 'pods'), PodsInit::$admin);
} elseif ('pick' != $field['type'] || empty($field['table_info'])) {
pods_error(__('Invalid field', 'pods'), PodsInit::$admin);
} elseif ('single' == pods_var(self::$type . '_format_type', $field) && 'autocomplete' == pods_var(self::$type . '_format_single', $field)) {
pods_error(__('Invalid field', 'pods'), PodsInit::$admin);
} elseif ('multi' == pods_var(self::$type . '_format_type', $field) && 'autocomplete' == pods_var(self::$type . '_format_multi', $field)) {
pods_error(__('Invalid field', 'pods'), PodsInit::$admin);
}
$object_params = array('name' => $field['name'], 'value' => null, 'options' => array_merge($field, $field['options']), 'pod' => $pod, 'id' => $id, 'context' => 'admin_ajax_relationship', 'data_params' => $params, 'page' => $page, 'limit' => $limit);
$pick_data = apply_filters('pods_field_pick_data_ajax', null, $field['name'], null, $field, $pod, $id);
if (null !== $pick_data) {
$items = $pick_data;
} else {
$items = $this->get_object_data($object_params);
}
if (!empty($items) && isset($items[0]) && !is_array($items[0])) {
$new_items = array();
foreach ($items as $id => $text) {
$new_items[] = array('id' => $id, 'text' => $text, 'image' => '');
}
$items = $new_items;
}
$items = apply_filters('pods_field_pick_data_ajax_items', $items, $field['name'], null, $field, $pod, $id);
$items = array('results' => $items);
wp_send_json($items);
die;
// KBAI!
}
示例15: precode
/**
* Run any precode for current Pod Page
*/
public function precode()
{
global $pods;
// Fix any global confusion wherever this runs
if (isset($pods) && !isset($GLOBALS['pods'])) {
$GLOBALS['pods'] =& $pods;
} elseif (!isset($pods) && isset($GLOBALS['pods'])) {
$pods =& $GLOBALS['pods'];
}
if (false !== self::$exists) {
$permission = pods_permission(self::$exists['options']);
$permission = (bool) apply_filters('pods_pages_permission', $permission, self::$exists);
if ($permission) {
$content = false;
if (!is_object($pods) && 404 != $pods && 0 < strlen(pods_var('pod', self::$exists['options']))) {
$slug = pods_var_raw('pod_slug', self::$exists['options'], null, null, true);
// Handle special magic tags
if (0 < strlen($slug)) {
$slug = pods_evaluate_tags($slug, true);
}
$pods = pods(pods_var('pod', self::$exists['options']), $slug);
// Auto 404 handling if item doesn't exist
if (0 < strlen($slug) && !$pods->exists() && apply_filters('pods_pages_auto_404', true, $slug, $pods, self::$exists)) {
$pods = 404;
}
}
if (0 < strlen(trim(self::$exists['precode']))) {
$content = self::$exists['precode'];
}
if (false !== $content && (!defined('PODS_DISABLE_EVAL') || !PODS_DISABLE_EVAL)) {
pods_deprecated('Pod Page Precode has been deprecated, please use WP Page Templates or hook into the pods_content filter instead of embedding PHP.', '2.1');
eval("?>{$content}");
}
do_action('pods_page_precode', self::$exists, $pods, $content);
} elseif (self::$exists['options']['restrict_redirect']) {
$redirect_url = '';
if (self::$exists['options']['restrict_redirect_login']) {
$redirect_url = wp_login_url(pods_current_url());
} elseif (!empty(self::$exists['options']['restrict_redirect_url'])) {
$redirect_url = self::$exists['options']['restrict_redirect_url'];
}
if (!empty($redirect_url)) {
wp_redirect($redirect_url);
die;
}
}
if (!$permission || !is_object($pods) && (404 == $pods || is_wp_error($pods))) {
remove_action('template_redirect', array($this, 'template_redirect'));
remove_action('wp_head', array($this, 'wp_head'));
remove_filter('redirect_canonical', '__return_false');
remove_filter('wp_title', array($this, 'wp_title'));
remove_filter('body_class', array($this, 'body_class'));
remove_filter('status_header', array($this, 'status_header'));
remove_action('wp', array($this, 'silence_404'), 1);
}
}
}