本文整理汇总了PHP中pods_evaluate_tags函数的典型用法代码示例。如果您正苦于以下问题:PHP pods_evaluate_tags函数的具体用法?PHP pods_evaluate_tags怎么用?PHP pods_evaluate_tags使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pods_evaluate_tags函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pods_shortcode
/**
* Shortcode support for use anywhere that support WP Shortcodes
*
* @param array $tags An associative array of shortcode properties
* @param string $content A string that represents a template override
*
* @return string
* @since 1.6.7
*/
function pods_shortcode($tags, $content = null)
{
$defaults = array('name' => null, 'id' => null, 'slug' => null, 'select' => null, 'order' => null, 'orderby' => null, 'limit' => null, 'where' => null, 'having' => null, 'groupby' => null, 'search' => true, 'pagination' => false, 'page' => null, 'filters' => false, 'filters_label' => null, 'filters_location' => 'before', 'pagination_label' => null, 'pagination_location' => 'after', 'field' => null, 'col' => null, 'template' => null, 'pods_page' => null, 'helper' => null, 'form' => null, 'fields' => null, 'label' => null, 'thank_you' => null, 'view' => null, 'cache_mode' => 'none', 'expires' => 0, 'shortcodes' => false);
if (!empty($tags)) {
$tags = array_merge($defaults, $tags);
} else {
$tags = $defaults;
}
$tags = apply_filters('pods_shortcode', $tags);
if (empty($content)) {
$content = null;
}
if (0 < strlen($tags['view'])) {
$return = pods_view($tags['view'], null, (int) $tags['expires'], $tags['cache_mode']);
if ($tags['shortcodes']) {
$return = do_shortcode($return);
}
return $return;
}
if (empty($tags['name'])) {
if (in_the_loop() || is_singular()) {
$pod = pods(get_post_type(), get_the_ID(), false);
if (!empty($pod)) {
$tags['name'] = get_post_type();
$id = $tags['id'] = get_the_ID();
}
}
if (empty($tags['name'])) {
return '<p>Please provide a Pod name</p>';
}
}
if (!empty($tags['col'])) {
$tags['field'] = $tags['col'];
unset($tags['col']);
}
if (!empty($tags['order'])) {
$tags['orderby'] = $tags['order'];
unset($tags['order']);
}
if (empty($content) && empty($tags['pods_page']) && empty($tags['template']) && empty($tags['field']) && empty($tags['form'])) {
return '<p>Please provide either a template or field name</p>';
}
if (!isset($id)) {
// id > slug (if both exist)
$id = empty($tags['slug']) ? null : pods_evaluate_tags($tags['slug']);
if (!empty($tags['id'])) {
$id = $tags['id'];
if (is_numeric($id)) {
$id = absint($id);
}
}
}
if (!isset($pod)) {
$pod = pods($tags['name'], $id);
}
if (empty($pod)) {
return '<p>Pod not found</p>';
}
$found = 0;
if (!empty($tags['form'])) {
return $pod->form($tags['fields'], $tags['label'], $tags['thank_you']);
} elseif (empty($id)) {
$params = array();
if (0 < strlen($tags['orderby'])) {
$params['orderby'] = $tags['orderby'];
}
if (!empty($tags['limit'])) {
$params['limit'] = $tags['limit'];
}
if (0 < strlen($tags['where'])) {
$params['where'] = pods_evaluate_tags($tags['where']);
}
if (0 < strlen($tags['having'])) {
$params['having'] = pods_evaluate_tags($tags['having']);
}
if (0 < strlen($tags['groupby'])) {
$params['groupby'] = $tags['groupby'];
}
if (0 < strlen($tags['select'])) {
$params['select'] = $tags['select'];
}
if (empty($tags['search'])) {
$params['search'] = false;
}
if (0 < absint($tags['page'])) {
$params['page'] = absint($tags['page']);
}
if (empty($tags['pagination'])) {
$params['pagination'] = false;
}
if (!empty($tags['cache_mode']) && 'none' != $tags['cache_mode']) {
//.........这里部分代码省略.........
示例2: default_value
/**
* Parse the default the value
*
* @since 2.0
*/
public static function default_value($value, $type = 'text', $name = null, $options = null, $pod = null, $id = null)
{
$default_value = pods_v('default_value', $options);
if ('' === $default_value || null === $default_value) {
$default_value = $value;
}
$default = pods_v('default', $options, $default_value, true);
$default_value = str_replace(array('{@', '}'), '', trim($default));
if ($default != $default_value && 1 == (int) pods_v('default_evaluate_tags', $options, 1)) {
$default = pods_evaluate_tags($default);
}
$default = pods_var_raw(pods_v('default_value_parameter', $options), 'request', $default, null, true);
if ($default != $value) {
$value = $default;
}
if (is_array($value)) {
$value = pods_serial_comma($value);
}
return apply_filters('pods_form_field_default_value', $value, $default, $type, $options, $pod, $id);
}
示例3: admin_content_settings
/**
* Create PodsUI content for the settings administration pages
*/
public function admin_content_settings()
{
$pod_name = str_replace('pods-settings-', '', $_GET['page']);
$pod = pods($pod_name);
if ('custom' != pods_var('ui_style', $pod->pod_data['options'], 'settings', null, true)) {
$actions_disabled = array('manage' => 'manage', 'add' => 'add', 'delete' => 'delete', 'duplicate' => 'duplicate', 'view' => 'view', 'export' => 'export');
$_GET['action'] = 'edit';
$page_title = pods_var_raw('label', $pod->pod_data, ucwords(str_replace('_', ' ', $pod->pod_data['name'])), null, true);
$ui = array('pod' => $pod, 'fields' => array('edit' => $pod->pod_data['fields']), 'header' => array('edit' => $page_title), 'label' => array('edit' => __('Save Changes', 'pods')), 'style' => pods_var('ui_style', $pod->pod_data['options'], 'settings', null, true), 'icon' => pods_evaluate_tags(pods_var_raw('menu_icon', $pod->pod_data['options']), true), 'actions_disabled' => $actions_disabled);
$ui = apply_filters('pods_admin_ui_' . $pod->pod, apply_filters('pods_admin_ui', $ui, $pod->pod, $pod), $pod->pod, $pod);
// Force disabled actions, do not pass go, do not collect $two_hundred
$ui['actions_disabled'] = $actions_disabled;
pods_ui($ui);
} else {
do_action('pods_admin_ui_custom', $pod);
do_action('pods_admin_ui_custom_' . $pod->pod, $pod);
}
}
示例4: pods_shortcode
/**
* Shortcode support for use anywhere that support WP Shortcodes
*
* @param array $tags An associative array of shortcode properties
* @param string $content A string that represents a template override
*
* @return string
* @since 1.6.7
*/
function pods_shortcode($tags, $content = null)
{
if (defined('PODS_DISABLE_SHORTCODE') && PODS_DISABLE_SHORTCODE) {
return '';
}
// For enforcing pagination parameters when not displaying pagination
$page = 1;
$offset = 0;
if (isset($tags['page'])) {
$page = (int) $tags['page'];
$page = max($page, 1);
}
if (isset($tags['offset'])) {
$offset = (int) $tags['offset'];
$offset = max($offset, 0);
}
$defaults = array('use_current' => false, 'name' => null, 'id' => null, 'slug' => null, 'select' => null, 'join' => null, 'order' => null, 'orderby' => null, 'limit' => null, 'where' => null, 'having' => null, 'groupby' => null, 'search' => true, 'pagination' => false, 'page' => null, 'offset' => null, 'filters' => false, 'filters_label' => null, 'filters_location' => 'before', 'pagination_label' => null, 'pagination_location' => 'after', 'field' => null, 'col' => null, 'template' => null, 'pods_page' => null, 'helper' => null, 'form' => null, 'fields' => null, 'label' => null, 'thank_you' => null, 'view' => null, 'cache_mode' => 'none', 'expires' => 0, 'shortcodes' => false);
if (!empty($tags)) {
$tags = array_merge($defaults, $tags);
} else {
$tags = $defaults;
}
$tags = apply_filters('pods_shortcode', $tags);
$tags['pagination'] = filter_var($tags['pagination'], FILTER_VALIDATE_BOOLEAN);
$tags['search'] = filter_var($tags['pagination'], FILTER_VALIDATE_BOOLEAN);
$tags['use_current'] = filter_var($tags['use_current'], FILTER_VALIDATE_BOOLEAN);
if (empty($content)) {
$content = null;
}
// Allow views only if not targeting a file path (must be within theme)
if (0 < strlen($tags['view'])) {
$return = '';
if (!file_exists($tags['view'])) {
$return = pods_view($tags['view'], null, (int) $tags['expires'], $tags['cache_mode']);
if ($tags['shortcodes'] && defined('PODS_SHORTCODE_ALLOW_SUB_SHORTCODES') && PODS_SHORTCODE_ALLOW_SUB_SHORTCODES) {
$return = do_shortcode($return);
}
}
return $return;
}
if (!$tags['use_current'] && empty($tags['name'])) {
if (in_the_loop() || is_singular()) {
$pod = pods(get_post_type(), get_the_ID(), false);
if (!empty($pod)) {
$tags['name'] = get_post_type();
$id = $tags['id'] = get_the_ID();
}
}
if (empty($tags['name'])) {
return '<p>Please provide a Pod name</p>';
}
}
if (!empty($tags['col'])) {
$tags['field'] = $tags['col'];
unset($tags['col']);
}
if (!empty($tags['order'])) {
$tags['orderby'] = $tags['order'];
unset($tags['order']);
}
if (empty($content) && empty($tags['pods_page']) && empty($tags['template']) && empty($tags['field']) && empty($tags['form'])) {
return '<p>Please provide either a template or field name</p>';
}
if (!$tags['use_current'] && !isset($id)) {
// id > slug (if both exist)
$id = null;
if (!empty($tags['slug'])) {
$id = $tags['slug'];
if (defined('PODS_SHORTCODE_ALLOW_EVALUATE_TAGS') && PODS_SHORTCODE_ALLOW_EVALUATE_TAGS) {
$id = pods_evaluate_tags($id);
}
}
if (!empty($tags['id'])) {
$id = $tags['id'];
if (defined('PODS_SHORTCODE_ALLOW_EVALUATE_TAGS') && PODS_SHORTCODE_ALLOW_EVALUATE_TAGS) {
$id = pods_evaluate_tags($id);
}
if (is_numeric($id)) {
$id = absint($id);
}
}
}
if (!isset($pod)) {
if (!$tags['use_current']) {
$pod = pods($tags['name'], $id);
} else {
$pod = pods();
$id = $pod->id();
}
}
if (empty($pod) || !$pod->valid()) {
//.........这里部分代码省略.........
示例5: 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);
}
}
}
示例6: get_object_data
//.........这里部分代码省略.........
} elseif (isset(self::$related_objects[$options[self::$type . '_object']]) && isset(self::$related_objects[$options[self::$type . '_object']]['data_callback']) && is_callable(self::$related_objects[$options[self::$type . '_object']]['data_callback'])) {
$data = call_user_func_array(self::$related_objects[$options[self::$type . '_object']]['data_callback'], array($name, $value, $options, $pod, $id));
$simple = true;
// Cache data from callback
if (!empty($data)) {
self::$related_objects[$options[self::$type . '_object']]['data'] = $data;
}
} elseif ('simple_value' != $context) {
$pick_val = pods_var(self::$type . '_val', $options);
if ('table' == pods_var(self::$type . '_object', $options)) {
$pick_val = pods_var(self::$type . '_table', $options, $pick_val, null, true);
}
if ('__current__' == $pick_val) {
if (is_object($pod)) {
$pick_val = $pod->pod;
} elseif (is_array($pod)) {
$pick_val = $pod['name'];
} elseif (0 < strlen($pod)) {
$pick_val = $pod;
}
}
$options['table_info'] = pods_api()->get_table_info(pods_var(self::$type . '_object', $options), $pick_val, null, null, $options);
$search_data = pods_data();
$search_data->table($options['table_info']);
if (isset($options['table_info']['pod']) && !empty($options['table_info']['pod']) && isset($options['table_info']['pod']['name'])) {
$search_data->pod = $options['table_info']['pod']['name'];
$search_data->fields = $options['table_info']['pod']['fields'];
}
$params = array('select' => "`t`.`{$search_data->field_id}`, `t`.`{$search_data->field_index}`", 'table' => $search_data->table, 'where' => pods_var_raw(self::$type . '_where', $options, (array) $options['table_info']['where_default'], null, true), 'orderby' => pods_var_raw(self::$type . '_orderby', $options, null, null, true), 'groupby' => pods_var_raw(self::$type . '_groupby', $options, null, null, true), 'pagination' => false, 'search' => false);
if (in_array($options[self::$type . '_object'], array('site', 'network'))) {
$params['select'] .= ', `t`.`path`';
}
if (!empty($params['where']) && (array) $options['table_info']['where_default'] != $params['where']) {
$params['where'] = pods_evaluate_tags($params['where'], true);
}
if (empty($params['where']) || !is_array($params['where']) && strlen(trim($params['where'])) < 1) {
$params['where'] = array();
} elseif (!is_array($params['where'])) {
$params['where'] = (array) $params['where'];
}
if ('value_to_label' == $context) {
$params['where'][] = "`t`.`{$search_data->field_id}` = " . number_format($value, 0, '', '');
}
/* not needed yet
if ( !empty( $params[ 'orderby' ] ) )
$params[ 'orderby' ] = pods_evaluate_tags( $params[ 'orderby' ], true );
if ( !empty( $params[ 'groupby' ] ) )
$params[ 'groupby' ] = pods_evaluate_tags( $params[ 'groupby' ], true );*/
$display = trim(pods_var(self::$type . '_display', $options), ' {@}');
if (0 < strlen($display)) {
if (isset($options['table_info']['pod']) && !empty($options['table_info']['pod'])) {
if (isset($options['table_info']['pod']['object_fields']) && isset($options['table_info']['pod']['object_fields'][$display])) {
$search_data->field_index = $display;
$params['select'] = "`t`.`{$search_data->field_id}`, `t`.`{$search_data->field_index}`";
} elseif (isset($options['table_info']['pod']['fields'][$display])) {
$search_data->field_index = $display;
if ('table' == $options['table_info']['pod']['storage'] && !in_array($options['table_info']['pod']['type'], array('pod', 'table'))) {
$params['select'] = "`t`.`{$search_data->field_id}`, `d`.`{$search_data->field_index}`";
} elseif ('meta' == $options['table_info']['pod']['storage']) {
$params['select'] = "`t`.`{$search_data->field_id}`, `{$search_data->field_index}`.`meta_value` AS {$search_data->field_index}";
} else {
$params['select'] = "`t`.`{$search_data->field_id}`, `t`.`{$search_data->field_index}`";
}
}
} elseif (isset($options['table_info']['object_fields']) && isset($options['table_info']['object_fields'][$display])) {
示例7: view
/**
* @static
*
* @param string $view Path of the view file
* @param array|null $data (optional) Data to pass on to the template
* @param bool|int|array $expires (optional) Time in seconds for the cache to expire, if 0 no expiration.
* @param string $cache_mode (optional) Decides the caching method to use for the view.
*
* @return bool|mixed|null|string|void
*
* @since 2.0
*/
public static function view($view, $data = null, $expires = false, $cache_mode = 'cache')
{
/**
* Override the value of $view. For example, using Pods AJAX View.
*
* To use, set first param to true. If that param in not null, this method returns its value.
*
* @param null|bool If not set to null, this filter overrides the rest of the method.
* @param string $view Path of the view file
* @param array|null $data (optional) Data to pass on to the template
* @param bool|int|array $expires (optional) Time in seconds for the cache to expire, if 0 no expiration.
* @param string $cache_mode (optional) Decides the caching method to use for the view.
*
* @returns The value of the first param.
*
* @since 2.4.1
*/
$filter_check = apply_filters('pods_view_alt_view', null, $view, $data, $expires, $cache_mode);
if (!is_null($filter_check)) {
return $filter_check;
}
// Advanced $expires handling
$expires = self::expires($expires, $cache_mode);
if (!in_array($cache_mode, self::$cache_modes)) {
$cache_mode = 'cache';
}
// Support my-view.php?custom-key=X#hash keying for cache
$view_id = '';
if (!is_array($view)) {
$view_q = explode('?', $view);
if (1 < count($view_q)) {
$view_id = '?' . $view_q[1];
$view = $view_q[0];
}
$view_h = explode('#', $view);
if (1 < count($view_h)) {
$view_id .= '#' . $view_h[1];
$view = $view_h[0];
}
// Support dynamic tags!
$view_id = pods_evaluate_tags($view_id);
}
$view = apply_filters('pods_view_inc', $view, $data, $expires, $cache_mode);
$view_key = $view;
if (is_array($view_key)) {
$view_key = implode('-', $view_key) . '.php';
}
if (false !== realpath($view_key)) {
$view_key = realpath($view_key);
}
$pods_ui_dir = realpath(PODS_DIR . 'ui/');
$pods_components_dir = realpath(PODS_DIR . 'components/');
$abspath_dir = realpath(ABSPATH);
$cache_key = pods_str_replace($abspath_dir, '/', $view_key, 1);
$output = false;
$caching = false;
if (false !== $expires && false === strpos($view_key, $pods_ui_dir) && false === strpos($view_key, $pods_components_dir)) {
$caching = true;
}
if ($caching) {
$output = self::get('pods-view-' . $cache_key . $view_id, $cache_mode, 'pods_view');
}
if (false === $output || null === $output) {
$output = self::get_template_part($view, $data);
}
if (false !== $output && $caching) {
self::set('pods-view-' . $cache_key . $view_id, $output, $expires, $cache_mode, 'pods_view');
}
$output = apply_filters('pods_view_output_' . $cache_key, $output, $view, $data, $expires, $cache_mode);
$output = apply_filters('pods_view_output', $output, $view, $data, $expires, $cache_mode);
return $output;
}
示例8: pods_evaluate_tags
/**
* Evaluate tags like magic tags but through pods_var
*
* @param string|array|object $tags String to be evaluated
* @param bool $sanitize Whether to sanitize tags
*
* @return string
*
* @version 2.1
*
* @see pods_evaluate_tag
*/
function pods_evaluate_tags($tags, $sanitize = false)
{
if (is_array($tags)) {
foreach ($tags as $k => $tag) {
$tags[$k] = pods_evaluate_tags($tag, $sanitize);
}
return $tags;
} elseif (is_object($tags)) {
$tags = get_object_vars($tags);
foreach ($tags as $k => $tag) {
$tags[$k] = pods_evaluate_tags($tag, $sanitize);
}
$tags = (object) $tags;
return $tags;
}
$callback = 'pods_evaluate_tag';
if (true === $sanitize) {
$callback = 'pods_evaluate_tag_sanitized';
}
return preg_replace_callback('/({@(.*?)})/m', $callback, (string) $tags);
}
示例9: setup_content_types
//.........这里部分代码省略.........
if (class_exists('Jetpack')) {
$cpt_supported['supports_jetpack_publicize'] = (bool) pods_var('supports_jetpack_publicize', $post_type, false);
$cpt_supported['supports_jetpack_markdown'] = (bool) pods_var('supports_jetpack_markdown', $post_type, false);
}
// WP needs something, if this was empty and none were enabled, it would show title+editor pre 3.5 :(
$cpt_supports = array();
if (!pods_version_check('wp', '3.5')) {
$cpt_supports = array('_bug_fix_pre_35');
}
foreach ($cpt_supported as $cpt_support => $supported) {
if (true === $supported) {
$cpt_supports[] = $cpt_support;
}
}
if (empty($cpt_supports) && pods_version_check('wp', '3.5')) {
$cpt_supports = false;
}
// Rewrite
$cpt_rewrite = (bool) pods_var('rewrite', $post_type, true);
$cpt_rewrite_array = array('slug' => pods_var('rewrite_custom_slug', $post_type, str_replace('_', '-', $post_type_name), null, true), 'with_front' => (bool) pods_var('rewrite_with_front', $post_type, true), 'feeds' => (bool) pods_var('rewrite_feeds', $post_type, (bool) pods_var('has_archive', $post_type, false)), 'pages' => (bool) pods_var('rewrite_pages', $post_type, true));
if (false !== $cpt_rewrite) {
$cpt_rewrite = $cpt_rewrite_array;
}
$capability_type = pods_var('capability_type', $post_type, 'post');
if ('custom' == $capability_type) {
$capability_type = pods_var('capability_type_custom', $post_type, 'post');
}
$show_in_menu = (bool) pods_var('show_in_menu', $post_type, true);
if ($show_in_menu && 0 < strlen(pods_var_raw('menu_location_custom', $post_type))) {
$show_in_menu = pods_var_raw('menu_location_custom', $post_type);
}
$menu_icon = pods_var('menu_icon', $post_type, null, null, true);
if (!empty($menu_icon)) {
$menu_icon = pods_evaluate_tags($menu_icon);
}
// Register Post Type
$pods_post_types[$post_type_name] = array('label' => $cpt_label, 'labels' => $cpt_labels, 'description' => esc_html(pods_var_raw('description', $post_type)), 'public' => (bool) pods_var('public', $post_type, true), 'publicly_queryable' => (bool) pods_var('publicly_queryable', $post_type, (bool) pods_var('public', $post_type, true)), 'exclude_from_search' => (bool) pods_var('exclude_from_search', $post_type, (bool) pods_var('public', $post_type, true) ? false : true), 'show_ui' => (bool) pods_var('show_ui', $post_type, (bool) pods_var('public', $post_type, true)), 'show_in_menu' => $show_in_menu, 'show_in_nav_menus' => (bool) pods_var('show_in_nav_menus', $post_type, (bool) pods_var('public', $post_type, true)), 'show_in_admin_bar' => (bool) pods_var('show_in_admin_bar', $post_type, (bool) pods_var('show_in_menu', $post_type, true)), 'menu_position' => (int) pods_var('menu_position', $post_type, 0, null, true), 'menu_icon' => $menu_icon, 'capability_type' => $capability_type, 'map_meta_cap' => (bool) pods_var('capability_type_extra', $post_type, true), 'hierarchical' => (bool) pods_var('hierarchical', $post_type, false), 'supports' => $cpt_supports, 'has_archive' => pods_v('has_archive_slug', $post_type, (bool) pods_v('has_archive', $post_type, false), true), 'rewrite' => $cpt_rewrite, 'query_var' => false !== (bool) pods_var('query_var', $post_type, true) ? pods_var('query_var_string', $post_type, $post_type_name, null, true) : false, 'can_export' => (bool) pods_var('can_export', $post_type, true));
// YARPP doesn't use 'supports' array option (yet)
if (!empty($cpt_supports['yarpp_support'])) {
$pods_post_types[$post_type_name]['yarpp_support'] = true;
}
// Prevent reserved query_var issues
if (in_array($pods_post_types[$post_type_name]['query_var'], $reserved_query_vars)) {
$pods_post_types[$post_type_name]['query_var'] = 'post_type_' . $pods_post_types[$post_type_name]['query_var'];
}
if (25 == $pods_post_types[$post_type_name]['menu_position']) {
$pods_post_types[$post_type_name]['menu_position']++;
}
if ($pods_post_types[$post_type_name]['menu_position'] < 1 || in_array($pods_post_types[$post_type_name]['menu_position'], $cpt_positions)) {
unset($pods_post_types[$post_type_name]['menu_position']);
} else {
$cpt_positions[] = $pods_post_types[$post_type_name]['menu_position'];
// This would be nice if WP supported floats in menu_position
// $pods_post_types[ $post_type_name ][ 'menu_position' ] = $pods_post_types[ $post_type_name ][ 'menu_position' ] . '.1';
}
// Taxonomies
$cpt_taxonomies = array();
$_taxonomies = get_taxonomies();
$_taxonomies = array_merge_recursive($_taxonomies, $pods_taxonomies);
$ignore = array('nav_menu', 'link_category', 'post_format');
foreach ($_taxonomies as $taxonomy => $label) {
if (in_array($taxonomy, $ignore)) {
continue;
}
if (false !== (bool) pods_var('built_in_taxonomies_' . $taxonomy, $post_type, false)) {
$cpt_taxonomies[] = $taxonomy;
示例10: 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']))) {
$pods = pods(pods_var('pod', self::$exists['options']), pods_evaluate_tags(pods_var_raw('pod_slug', self::$exists['options'], null, null, true), true));
}
if (0 < strlen(trim(self::$exists['precode']))) {
$content = self::$exists['precode'];
}
if (false !== $content && (!defined('PODS_DISABLE_EVAL') || !PODS_DISABLE_EVAL)) {
pods_deprecated('Use WP Page Templates or hook into the pods_page_precode action instead of using Pod Page Precode', '2.1');
eval("?>{$content}");
}
do_action('pods_page_precode', self::$exists, $pods, $content);
}
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'));
}
}
}
示例11: pods_evaluate_tags
/**
* Evaluate tags like magic tags but through pods_var
*
* @param string|array $tags String to be evaluated
* @param bool $sanitize Whether to sanitize tags
*
* @return string
* @version 2.1
*/
function pods_evaluate_tags($tags, $sanitize = false)
{
if (is_array($tags)) {
foreach ($tags as $k => $tag) {
$tags[$k] = pods_evaluate_tags($tag, $sanitize);
}
return $tags;
}
if ($sanitize) {
return preg_replace_callback('/({@(.*?)})/m', 'pods_evaluate_tag_sanitized', (string) $tags);
} else {
return preg_replace_callback('/({@(.*?)})/m', 'pods_evaluate_tag', (string) $tags);
}
}