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


PHP pods_transient_set函数代码示例

本文整理汇总了PHP中pods_transient_set函数的典型用法代码示例。如果您正苦于以下问题:PHP pods_transient_set函数的具体用法?PHP pods_transient_set怎么用?PHP pods_transient_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: export_pod

/**
 * Function, with caching, to export all items of a Pod as a serialized php array or JSON object
 *
 * @param string     $pod_name
 * @param bool 		$json
 *
 * @return bool|mixed|null|string|void
 */
function export_pod($pod_name, $json = true)
{
    //be sure to set your Pod's name here
    //name the transient we are caching in for the Pod.
    $transient_name = "all_{$pod_name}_export";
    //check if we already have this data cached, if not continue
    if (false === ($export = pods_transient_get($transient_name))) {
        //build Pods object, get all items
        $pods = pods($pod_name, array('limit' => -1), true);
        //if we have items, loop through them, adding each item's complete row to the array
        if ($pods && $pods->total() > 0) {
            while ($pods->fetch()) {
                $export[$pods->id()] = $pods->row();
            }
        }
        if ($json) {
            $export = json_encode($export);
        } else {
            $export = serialize($export);
        }
        //cache for next time
        pods_transient_set($transient_name, $export);
    }
    return $export;
}
开发者ID:logoscreative,项目名称:pods-code-library,代码行数:33,代码来源:all-items-to-serialized-array.php

示例2: field_types

 /**
  * Get a list of all available field types and include
  *
  * @return array Registered Field Types data
  *
  * @since 2.3
  */
 public static function field_types()
 {
     $field_types = array('text', 'website', 'phone', 'email', 'password', 'paragraph', 'wysiwyg', 'code', 'datetime', 'date', 'time', 'number', 'currency', 'file', 'avatar', 'pick', 'boolean', 'color', 'slug');
     $field_types = array_merge($field_types, array_keys(self::$field_types));
     $field_types = array_filter(array_unique($field_types));
     $types = apply_filters('pods_api_field_types', $field_types);
     $field_types = pods_transient_get('pods_field_types');
     if (empty($field_types) || count($types) != count($field_types)) {
         $field_types = array();
         foreach ($types as $field_type) {
             $file = null;
             if (isset(self::$field_types[$field_type])) {
                 $file = self::$field_types[$field_type]['file'];
             }
             self::field_loader($field_type, $file);
             if (!isset(self::$loaded[$field_type]) || !is_object(self::$loaded[$field_type])) {
                 continue;
             }
             $class_vars = get_class_vars(get_class(self::$loaded[$field_type]));
             // PHP 5.2.x workaround
             $field_types[$field_type] = $class_vars;
             $field_types[$field_type]['file'] = $file;
         }
         self::$field_types = $field_types;
         pods_transient_set('pods_field_types', self::$field_types);
     } else {
         self::$field_types = array_merge($field_types, self::$field_types);
     }
     return self::$field_types;
 }
开发者ID:erkmen,项目名称:wpstartersetup,代码行数:37,代码来源:PodsForm.php

示例3: get_components


//.........这里部分代码省略.........
         $components = array();
     }
     if (PodsInit::$version != PODS_VERSION || !is_array($components) || empty($components) || is_admin() && isset($_GET['page']) && 'pods-components' == $_GET['page'] && 1 !== pods_transient_get('pods_components_refresh')) {
         do_action('pods_components_get');
         $component_dir = @opendir(untrailingslashit($this->components_dir));
         $component_files = array();
         if (false !== $component_dir) {
             while (false !== ($file = readdir($component_dir))) {
                 if ('.' == substr($file, 0, 1)) {
                     continue;
                 } elseif (is_dir($this->components_dir . $file)) {
                     $component_subdir = @opendir($this->components_dir . $file);
                     if ($component_subdir) {
                         while (false !== ($subfile = readdir($component_subdir))) {
                             if ('.' == substr($subfile, 0, 1)) {
                                 continue;
                             } elseif ('.php' == substr($subfile, -4)) {
                                 $component_files[] = str_replace('\\', '/', $file . '/' . $subfile);
                             }
                         }
                         closedir($component_subdir);
                     }
                 } elseif ('.php' == substr($file, -4)) {
                     $component_files[] = $file;
                 }
             }
             closedir($component_dir);
         }
         $default_headers = array('ID' => 'ID', 'Name' => 'Name', 'ShortName' => 'Short Name', 'PluginName' => 'Plugin Name', 'ComponentName' => 'Component Name', 'URI' => 'URI', 'MenuName' => 'Menu Name', 'MenuPage' => 'Menu Page', 'MenuAddPage' => 'Menu Add Page', 'MustUse' => 'Must Use', 'Description' => 'Description', 'Version' => 'Version', 'Category' => 'Category', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'Class' => 'Class', 'Hide' => 'Hide', 'PluginDependency' => 'Plugin Dependency', 'ThemeDependency' => 'Theme Dependency', 'DeveloperMode' => 'Developer Mode', 'TablelessMode' => 'Tableless Mode', 'Capability' => 'Capability', 'Plugin' => 'Plugin');
         $component_files = apply_filters('pods_components_register', $component_files);
         $components = array();
         foreach ($component_files as $component_file) {
             $external = false;
             if (is_array($component_file) && isset($component_file['File'])) {
                 $component = $component_file = $component_file['File'];
                 $external = true;
             } else {
                 $component = $this->components_dir . $component_file;
             }
             if (!is_readable($component)) {
                 continue;
             }
             $component_data = get_file_data($component, $default_headers, 'pods_component');
             if (empty($component_data['Name']) && empty($component_data['ComponentName']) && empty($component_data['PluginName']) || 'yes' == $component_data['Hide']) {
                 continue;
             }
             if (isset($component_data['Plugin']) && pods_is_plugin_active($component_data['Plugin'])) {
                 continue;
             }
             if (empty($component_data['Name'])) {
                 if (!empty($component_data['ComponentName'])) {
                     $component_data['Name'] = $component_data['ComponentName'];
                 } elseif (!empty($component_data['PluginName'])) {
                     $component_data['Name'] = $component_data['PluginName'];
                 }
             }
             if (empty($component_data['ShortName'])) {
                 $component_data['ShortName'] = $component_data['Name'];
             }
             if (empty($component_data['MenuName'])) {
                 $component_data['MenuName'] = $component_data['Name'];
             }
             if (empty($component_data['Class'])) {
                 $component_data['Class'] = 'Pods_' . pods_clean_name(basename($component, '.php'), false);
             }
             if (empty($component_data['ID'])) {
                 $component_data['ID'] = $component_data['Name'];
             }
             $component_data['ID'] = sanitize_title($component_data['ID']);
             if ('on' == strtolower($component_data['DeveloperMode']) || 1 == $component_data['DeveloperMode']) {
                 $component_data['DeveloperMode'] = true;
             } else {
                 $component_data['DeveloperMode'] = false;
             }
             if ('on' == strtolower($component_data['TablelessMode']) || 1 == $component_data['TablelessMode']) {
                 $component_data['TablelessMode'] = true;
             } else {
                 $component_data['TablelessMode'] = false;
             }
             $component_data['External'] = (bool) $external;
             if ('on' == strtolower($component_data['MustUse']) || '1' == $component_data['MustUse']) {
                 $component_data['MustUse'] = true;
             } elseif ('off' == strtolower($component_data['MustUse']) || '0' == $component_data['MustUse']) {
                 $component_data['MustUse'] = false;
             } else {
                 $component_data['MustUse'] = $component_data['External'];
             }
             $component_data['File'] = $component_file;
             $components[$component_data['ID']] = $component_data;
         }
         ksort($components);
         pods_transient_set('pods_components_refresh', 1, 60 * 60 * 12);
         pods_transient_set('pods_components', $components);
     }
     if (1 == pods_var('pods_debug_components', 'get', 0) && pods_is_admin(array('pods'))) {
         pods_debug($components);
     }
     $this->components = $components;
     return $this->components;
 }
开发者ID:Ingenex,项目名称:redesign,代码行数:101,代码来源:PodsComponents.php

示例4: foreach

    foreach ($_data['options'] as $_option => $_value) {
        $pod['fields'][$_field][$_option] = $_value;
    }
}
$field_defaults = apply_filters('pods_field_defaults', apply_filters('pods_field_defaults_' . $pod['name'], $field_defaults, $pod));
$pick_table = pods_transient_get('pods_tables');
if (empty($pick_table)) {
    $pick_table = array('' => __('-- Select Table --', 'pods'));
    global $wpdb;
    $tables = $wpdb->get_results("SHOW TABLES", ARRAY_N);
    if (!empty($tables)) {
        foreach ($tables as $table) {
            $pick_table[$table[0]] = $table[0];
        }
    }
    pods_transient_set('pods_tables', $pick_table);
}
$field_settings = array('field_types_select' => $field_types_select, 'field_defaults' => $field_defaults, 'pick_object' => $pick_object, 'pick_table' => $pick_table, 'sister_id' => array('' => __('No Related Fields Found', 'pods')));
$field_settings = apply_filters('pods_field_settings', apply_filters('pods_field_settings_' . $pod['name'], $field_settings, $pod));
$pod['fields'] = apply_filters('pods_fields_edit', apply_filters('pods_fields_edit_' . $pod['name'], $pod['fields'], $pod));
global $wpdb;
$max_length_name = 64;
$max_length_name -= 10;
// Allow for WP Multisite or prefix changes in the future
$max_length_name -= strlen($wpdb->prefix . 'pods_');
$tabs = PodsInit::$admin->admin_setup_edit_tabs($pod);
$tab_options = PodsInit::$admin->admin_setup_edit_options($pod);
$field_tabs = PodsInit::$admin->admin_setup_edit_field_tabs($pod);
$field_tab_options = PodsInit::$admin->admin_setup_edit_field_options($pod);
$no_additional = array();
foreach ($field_tab_options['additional-field'] as $field_type => $field_type_fields) {
开发者ID:jeremybradbury,项目名称:wp-ninja-kit,代码行数:31,代码来源:setup-edit.php

示例5: cache_flush_pods

 /**
  * Clear Pod-related cache
  *
  * @param array $pod
  *
  * @return void
  *
  * @since 2.0
  */
 public function cache_flush_pods($pod = null)
 {
     /**
      * @var $wpdb wpdb
      */
     global $wpdb;
     pods_transient_clear('pods');
     pods_transient_clear('pods_components');
     if (null !== $pod && is_array($pod)) {
         pods_transient_clear('pods_pod_' . $pod['name']);
         pods_cache_clear($pod['name'], 'pods-class');
         foreach ($pod['fields'] as $field) {
             pods_transient_clear('pods_field_' . $pod['name'] . '_' . $field['name']);
         }
         if (in_array($pod['type'], array('post_type', 'taxonomy'))) {
             pods_transient_clear('pods_wp_cpt_ct');
         }
     } else {
         pods_transient_clear('pods_wp_cpt_ct');
     }
     $wpdb->query("DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE '_transient_pods%'");
     $wpdb->query("DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE '_transient_timeout_pods%'");
     pods_cache_clear(true);
     pods_transient_set('pods_flush_rewrites', 1);
 }
开发者ID:satokora,项目名称:IT354Project,代码行数:34,代码来源:PodsAPI.php

示例6: setup_related_objects

 /**
  * Setup related objects
  *
  * @param boolean $force Whether to force refresh of related objects
  * @return bool True when data has been loaded
  * @since 2.3
  */
 public function setup_related_objects($force = false)
 {
     $new_data_loaded = false;
     if (!$force && empty(self::$related_objects)) {
         // Only load transient if we aren't forcing a refresh
         self::$related_objects = pods_transient_get('pods_related_objects');
         if (false !== self::$related_objects) {
             $new_data_loaded = true;
         }
     } elseif ($force) {
         // If we are rebuilding, make sure we start with a clean slate
         self::$related_objects = array();
     }
     if (empty(self::$related_objects)) {
         // Do a complete build of related_objects
         $new_data_loaded = true;
         // Custom
         self::$related_objects['custom-simple'] = array('label' => __('Simple (custom defined list)', 'pods'), 'group' => __('Custom', 'pods'), 'simple' => true);
         // Pods
         $pod_options = array();
         // Include PodsMeta if not already included
         pods_meta();
         // Advanced Content Types
         $_pods = PodsMeta::$advanced_content_types;
         foreach ($_pods as $pod) {
             $pod_options[$pod['name']] = $pod['label'] . ' (' . $pod['name'] . ')';
         }
         // Settings
         $_pods = PodsMeta::$settings;
         foreach ($_pods as $pod) {
             $pod_options[$pod['name']] = $pod['label'] . ' (' . $pod['name'] . ')';
         }
         asort($pod_options);
         foreach ($pod_options as $pod => $label) {
             self::$related_objects['pod-' . $pod] = array('label' => $label, 'group' => __('Pods', 'pods'), 'bidirectional' => true);
         }
         // Post Types
         $post_types = get_post_types();
         asort($post_types);
         $ignore = array('attachment', 'revision', 'nav_menu_item');
         foreach ($post_types as $post_type => $label) {
             if (in_array($post_type, $ignore) || empty($post_type)) {
                 unset($post_types[$post_type]);
                 continue;
             } elseif (0 === strpos($post_type, '_pods_') && apply_filters('pods_pick_ignore_internal', true)) {
                 unset($post_types[$post_type]);
                 continue;
             }
             $post_type = get_post_type_object($post_type);
             self::$related_objects['post_type-' . $post_type->name] = array('label' => $post_type->label . ' (' . $post_type->name . ')', 'group' => __('Post Types', 'pods'), 'bidirectional' => true);
         }
         // Taxonomies
         $taxonomies = get_taxonomies();
         asort($taxonomies);
         $ignore = array('nav_menu', 'post_format');
         foreach ($taxonomies as $taxonomy => $label) {
             if (in_array($taxonomy, $ignore) || empty($taxonomy)) {
                 unset($taxonomies[$taxonomy]);
                 continue;
             } elseif (0 === strpos($taxonomy, '_pods_') && apply_filters('pods_pick_ignore_internal', true)) {
                 unset($taxonomies[$taxonomy]);
                 continue;
             }
             $taxonomy = get_taxonomy($taxonomy);
             self::$related_objects['taxonomy-' . $taxonomy->name] = array('label' => $taxonomy->label . ' (' . $taxonomy->name . ')', 'group' => __('Taxonomies', 'pods'), 'bidirectional' => true);
         }
         // Other WP Objects
         self::$related_objects['user'] = array('label' => __('Users', 'pods'), 'group' => __('Other WP Objects', 'pods'), 'bidirectional' => true);
         self::$related_objects['role'] = array('label' => __('User Roles', 'pods'), 'group' => __('Other WP Objects', 'pods'), 'simple' => true, 'data_callback' => array($this, 'data_roles'));
         self::$related_objects['capability'] = array('label' => __('User Capabilities', 'pods'), 'group' => __('Other WP Objects', 'pods'), 'simple' => true, 'data_callback' => array($this, 'data_capabilities'));
         self::$related_objects['media'] = array('label' => __('Media', 'pods'), 'group' => __('Other WP Objects', 'pods'), 'bidirectional' => true);
         self::$related_objects['comment'] = array('label' => __('Comments', 'pods'), 'group' => __('Other WP Objects', 'pods'), 'bidirectional' => true);
         self::$related_objects['image-size'] = array('label' => __('Image Sizes', 'pods'), 'group' => __('Other WP Objects', 'pods'), 'simple' => true, 'data_callback' => array($this, 'data_image_sizes'));
         self::$related_objects['nav_menu'] = array('label' => __('Navigation Menus', 'pods'), 'group' => __('Other WP Objects', 'pods'));
         self::$related_objects['post_format'] = array('label' => __('Post Formats', 'pods'), 'group' => __('Other WP Objects', 'pods'));
         self::$related_objects['post-status'] = array('label' => __('Post Status', 'pods'), 'group' => __('Other WP Objects', 'pods'), 'simple' => true, 'data_callback' => array($this, 'data_post_stati'));
         do_action('pods_form_ui_field_pick_related_objects_other');
         self::$related_objects['country'] = array('label' => __('Countries', 'pods'), 'group' => __('Predefined Lists', 'pods'), 'simple' => true, 'data_callback' => array($this, 'data_countries'));
         self::$related_objects['us_state'] = array('label' => __('US States', 'pods'), 'group' => __('Predefined Lists', 'pods'), 'simple' => true, 'data_callback' => array($this, 'data_us_states'));
         self::$related_objects['days_of_week'] = array('label' => __('Calendar - Days of Week', 'pods'), 'group' => __('Predefined Lists', 'pods'), 'simple' => true, 'data_callback' => array($this, 'data_days_of_week'));
         self::$related_objects['months_of_year'] = array('label' => __('Calendar - Months of Year', 'pods'), 'group' => __('Predefined Lists', 'pods'), 'simple' => true, 'data_callback' => array($this, 'data_months_of_year'));
         do_action('pods_form_ui_field_pick_related_objects_predefined');
         if (did_action('init')) {
             pods_transient_set('pods_related_objects', self::$related_objects);
         }
     }
     foreach (self::$custom_related_objects as $object => $related_object) {
         if (!isset(self::$related_objects[$object])) {
             $new_data_loaded = true;
             self::$related_objects[$object] = $related_object;
         }
     }
     return $new_data_loaded;
//.........这里部分代码省略.........
开发者ID:dylansmithing,项目名称:leader-of-rock-wordpress,代码行数:101,代码来源:pick.php

示例7: flush_rewrites

 /**
  * Flush Pod Page Rewrite cache
  *
  * @return array Pod Page Rewrites
  *
  * @since 2.3.4
  */
 public static function flush_rewrites()
 {
     $args = array('post_type' => '_pods_page', 'nopaging' => true, 'posts_per_page' => -1, 'post_status' => 'publish', 'order' => 'ASC', 'orderby' => 'title');
     $pod_pages = get_posts($args);
     $pod_page_rewrites = array();
     foreach ($pod_pages as $pod_page) {
         $pod_page_rewrites[$pod_page->ID] = $pod_page->post_title;
     }
     uksort($pod_page_rewrites, 'pods_page_length_sort');
     pods_transient_set('pods_object_page_rewrites', $pod_page_rewrites);
     $pod_page_rewrites = array_flip($pod_page_rewrites);
     return $pod_page_rewrites;
 }
开发者ID:erkmen,项目名称:wpstartersetup,代码行数:20,代码来源:Pages.php

示例8: enqueue

 public static function enqueue()
 {
     foreach (self::$queue as $type => $objects) {
         foreach ($objects as $pod_name => $pod) {
             pods_transient_set('pods_pod_' . $pod_name, $pod);
         }
         self::${$type} = array_merge(self::${$type}, $objects);
     }
 }
开发者ID:centaurustech,项目名称:chipin,代码行数:9,代码来源:PodsMeta.php

示例9: setup_content_types


//.........这里部分代码省略.........
                 $ct_rewrite = $ct_rewrite_array;
             }
             // Register Taxonomy
             $pods_taxonomies[pods_var('name', $taxonomy)] = array('label' => $ct_label, 'labels' => $ct_labels, 'public' => (bool) pods_var('public', $taxonomy, true), 'show_in_nav_menus' => (bool) pods_var('show_in_nav_menus', $taxonomy, (bool) pods_var('public', $taxonomy, true)), 'show_ui' => (bool) pods_var('show_ui', $taxonomy, (bool) pods_var('public', $taxonomy, true)), 'show_tagcloud' => (bool) pods_var('show_tagcloud', $taxonomy, (bool) pods_var('show_ui', $taxonomy, (bool) pods_var('public', $taxonomy, true))), 'hierarchical' => (bool) pods_var('hierarchical', $taxonomy, false), 'update_count_callback' => pods_var('update_count_callback', $taxonomy, null, null, true), 'query_var' => false !== (bool) pods_var('query_var', $taxonomy, true) ? pods_var('query_var_string', $taxonomy, pods_var('name', $taxonomy), null, true) : false, 'rewrite' => $ct_rewrite, 'show_admin_column' => (bool) pods_var('show_admin_column', $taxonomy, false), 'sort' => (bool) pods_var('sort', $taxonomy, false));
             if (is_array($ct_rewrite) && !$pods_taxonomies[pods_var('name', $taxonomy)]['query_var']) {
                 $pods_taxonomies[pods_var('name', $taxonomy)]['query_var'] = pods_var('query_var_string', $taxonomy, pods_var('name', $taxonomy), null, true);
             }
             // Post Types
             $ct_post_types = array();
             $_post_types = get_post_types();
             $_post_types = array_merge_recursive($_post_types, $pods_post_types);
             $ignore = array('revision', 'nav_menu_item');
             foreach ($_post_types as $post_type => $options) {
                 if (in_array($post_type, $ignore)) {
                     continue;
                 }
                 if (false !== (bool) pods_var('built_in_post_types_' . $post_type, $taxonomy, false)) {
                     $ct_post_types[] = $post_type;
                     if (isset($supported_taxonomies[$post_type]) && !in_array(pods_var('name', $taxonomy), $supported_taxonomies[$post_type])) {
                         $supported_taxonomies[$post_type][] = pods_var('name', $taxonomy);
                     }
                 }
             }
             if (isset($supported_post_types[pods_var('name', $taxonomy)])) {
                 $supported_post_types[pods_var('name', $taxonomy)] = array_merge($supported_post_types[pods_var('name', $taxonomy)], $ct_post_types);
             } else {
                 $supported_post_types[pods_var('name', $taxonomy)] = $ct_post_types;
             }
         }
         $pods_post_types = apply_filters('pods_wp_post_types', $pods_post_types);
         $pods_taxonomies = apply_filters('pods_wp_taxonomies', $pods_taxonomies);
         $supported_post_types = apply_filters('pods_wp_supported_post_types', $supported_post_types);
         $supported_taxonomies = apply_filters('pods_wp_supported_taxonomies', $supported_taxonomies);
         foreach ($pods_taxonomies as $taxonomy => $options) {
             $ct_post_types = null;
             if (isset($supported_post_types[$taxonomy]) && !empty($supported_post_types[$taxonomy])) {
                 $ct_post_types = $supported_post_types[$taxonomy];
             }
             $pods_cpt_ct['taxonomies'][$taxonomy] = array('post_types' => $ct_post_types, 'options' => $options);
         }
         foreach ($pods_post_types as $post_type => $options) {
             if (isset($supported_taxonomies[$post_type]) && !empty($supported_taxonomies[$post_type])) {
                 $options['taxonomies'] = $supported_taxonomies[$post_type];
             }
             $pods_cpt_ct['post_types'][$post_type] = $options;
         }
         pods_transient_set('pods_wp_cpt_ct', $pods_cpt_ct);
     }
     foreach ($pods_cpt_ct['taxonomies'] as $taxonomy => $options) {
         if (isset(self::$content_types_registered['taxonomies']) && in_array($taxonomy, self::$content_types_registered['taxonomies'])) {
             continue;
         }
         $ct_post_types = $options['post_types'];
         $options = $options['options'];
         $options = apply_filters('pods_register_taxonomy_' . $taxonomy, $options);
         $options = self::object_label_fix($options, 'taxonomy');
         // Max length for taxonomies are 32 characters
         $taxonomy = substr($taxonomy, 0, 32);
         // i18n compatibility for plugins that override it
         if (is_array($options['rewrite']) && isset($options['rewrite']['slug']) && !empty($options['rewrite']['slug'])) {
             $options['rewrite']['slug'] = _x($options['rewrite']['slug'], 'URL taxonomy slug', 'pods');
         }
         if (1 == pods_var('pods_debug_register', 'get', 0) && pods_is_admin(array('pods'))) {
             pods_debug(array($taxonomy, $ct_post_types, $options));
         }
         register_taxonomy($taxonomy, $ct_post_types, $options);
         if (!isset(self::$content_types_registered['taxonomies'])) {
             self::$content_types_registered['taxonomies'] = array();
         }
         self::$content_types_registered['taxonomies'][] = $taxonomy;
     }
     foreach ($pods_cpt_ct['post_types'] as $post_type => $options) {
         if (isset(self::$content_types_registered['post_types']) && in_array($post_type, self::$content_types_registered['post_types'])) {
             continue;
         }
         $options = apply_filters('pods_register_post_type_' . $post_type, $options);
         $options = self::object_label_fix($options, 'post_type');
         // Max length for post types are 20 characters
         $post_type = substr($post_type, 0, 20);
         // i18n compatibility for plugins that override it
         if (is_array($options['rewrite']) && isset($options['rewrite']['slug']) && !empty($options['rewrite']['slug'])) {
             $options['rewrite']['slug'] = _x($options['rewrite']['slug'], 'URL slug', 'pods');
         }
         if (1 == pods_var('pods_debug_register', 'get', 0) && pods_is_admin(array('pods'))) {
             pods_debug(array($post_type, $options));
         }
         register_post_type($post_type, $options);
         if (!isset(self::$content_types_registered['post_types'])) {
             self::$content_types_registered['post_types'] = array();
         }
         self::$content_types_registered['post_types'][] = $post_type;
     }
     $flush = pods_transient_get('pods_flush_rewrites');
     if (1 == $flush) {
         global $wp_rewrite;
         $wp_rewrite->flush_rules();
         $wp_rewrite->init();
         pods_transient_set('pods_flush_rewrites', 0);
     }
 }
开发者ID:centaurustech,项目名称:chipin,代码行数:101,代码来源:PodsInit.php

示例10: auto_pods

 /**
  * Get all Pods with auto template enable and its settings
  *
  * @return array With info about auto template settings per post type
  *
  * @since 2.4.5
  */
 function auto_pods()
 {
     /**
      * Filter to override all settings for which templates are used.
      *
      * Note: If this filter does not return null, all back-end settings are ignored. To add to settings with a filter, use 'pods_pfat_auto_pods';
      *
      * @param array $auto_pods Array of parameters to use instead of those from settings.
      *
      * @return array Settings arrays for each post type.
      *
      * @since 2.4.5
      */
     $auto_pods = apply_filters('pods_pfat_auto_pods_override', null);
     if (!is_null($auto_pods)) {
         return $auto_pods;
     }
     //try to get cached results of this method
     $key = '_pods_pfat_auto_pods';
     $auto_pods = pods_transient_get($key);
     //check if we already have the results cached & use it if we can.
     if ($auto_pods === false) {
         //get possible pods
         $the_pods = $this->the_pods();
         //start output array empty
         $auto_pods = array();
         //get pods api class
         $api = pods_api();
         //loop through each to see if auto templates is enabled
         foreach ($the_pods as $the_pod => $the_pod_label) {
             //get this Pods' data.
             $pod_data = $api->load_pod(array('name' => $the_pod));
             //if auto template is enabled add info about Pod to array
             if (1 == pods_v('pfat_enable', $pod_data['options'])) {
                 //check if pfat_single and pfat_archive are set
                 $single = pods_v('pfat_single', $pod_data['options'], false, true);
                 $archive = pods_v('pfat_archive', $pod_data['options'], false, true);
                 $single_append = pods_v('pfat_append_single', $pod_data['options'], true, true);
                 $archive_append = pods_v('pfat_append_archive', $pod_data['options'], true, true);
                 $single_filter = pods_v('pfat_filter_single', $pod_data['options'], 'the_content', true);
                 $archive_filter = pods_v('pfat_filter_archive', $pod_data['options'], 'the_content', true);
                 $type = pods_v('type', $pod_data, false, true);
                 //check if it's a post type that has an arhive
                 if ($type === 'post_type' && $the_pod !== 'post' || $the_pod !== 'page') {
                     $has_archive = pods_v('has_archive', $pod_data['options'], false, true);
                 } else {
                     $has_archive = true;
                 }
                 if (empty($single_filter)) {
                     $single_filter = 'the_content';
                 }
                 if (empty($archive_filter)) {
                     $archive_filter = 'the_content';
                 }
                 //build output array
                 $auto_pods[$the_pod] = array('name' => $the_pod, 'label' => $the_pod_label, 'single' => $single, 'archive' => $archive, 'single_append' => $single_append, 'archive_append' => $archive_append, 'has_archive' => $has_archive, 'single_filter' => $single_filter, 'archive_filter' => $archive_filter, 'type' => $type);
             }
         }
         //endforeach
         //cache the results
         pods_transient_set($key, $auto_pods);
     }
     /**
      * Add to or change settings.
      *
      * Use this filter to change or add to the settings set in the back-end for this plugin. Has no effect if 'pods_pfat_auto_pods_override' filter is being used.
      *
      * @param array $auto_pods Array of parameters to use instead of those from settings.
      *
      * @return array Settings arrays for each post type.
      *
      * @since 2.4.5
      */
     $auto_pods = apply_filters('pods_pfat_auto_pods', $auto_pods);
     return $auto_pods;
 }
开发者ID:pods-framework,项目名称:pods,代码行数:83,代码来源:Pods_Templates_Auto_Template_Front_End.php

示例11: add_rest_support

 /**
  * Add REST API support to post type and taxonomy objects.
  *
  * @uses "init"
  *
  * @since 2.5.6
  */
 public function add_rest_support()
 {
     static $rest_support_added;
     if (!function_exists('register_rest_field')) {
         return;
     }
     include_once PODS_DIR . 'classes/PodsRESTFields.php';
     include_once PODS_DIR . 'classes/PodsRESTHandlers.php';
     $rest_bases = pods_transient_get('pods_rest_bases');
     if (empty($rest_bases)) {
         $pods = pods_api()->load_pods();
         $rest_bases = array();
         if (!empty($pods) && is_array($pods)) {
             foreach ($pods as $pod) {
                 $type = $pod['type'];
                 if (in_array($type, array('post_type', 'taxonomy'))) {
                     if ($pod && PodsRESTHandlers::pod_extends_core_route($pod)) {
                         $rest_bases[$pod['name']] = array('type' => $type, 'base' => sanitize_title(pods_v('rest_base', $pod['options'], $pod['name'])));
                     }
                 }
             }
         }
         if (empty($rest_bases)) {
             $rest_bases = 'none';
         }
         pods_transient_set('pods_rest_bases', $rest_bases);
     }
     if (empty($rest_support_added) && !empty($rest_bases) && 'none' !== $rest_bases) {
         foreach ($rest_bases as $pod_name => $pod_info) {
             $pod_type = $pod_info['type'];
             $rest_base = $pod_info['base'];
             if ('post_type' == $pod_type) {
                 PodsRESTHandlers::post_type_rest_support($pod_name, $rest_base);
             } elseif ('taxonomy' == $pod_type) {
                 PodsRESTHandlers::taxonomy_rest_support($pod_name, $rest_base);
             }
             new PodsRESTFields($pod_name);
         }
         $rest_support_added = true;
     }
 }
开发者ID:benbrandt,项目名称:pods,代码行数:48,代码来源:PodsInit.php

示例12: archive_test

 /**
  * Test if archive is set for post types that don't have archives.
  *
  * @return bool|mixed|null|void
  *
  * @since 2.4.5
  */
 function archive_test()
 {
     //try to get cached results of this method
     $key = 'pods_pfat_archive_test';
     $archive_test = pods_transient_get($key);
     if ($archive_test === false) {
         $front = $this->front_end(true);
         $auto_pods = $front->auto_pods();
         foreach ($auto_pods as $name => $pod) {
             if (!$pod['has_archive'] && $pod['archive'] && $pod['type'] !== 'taxonomy' && !in_array($name, array('post', 'page', 'attachment'))) {
                 $archive_test[$pod['label']] = 'fail';
             }
         }
         pods_transient_set($key, $archive_test);
     }
     return $archive_test;
 }
开发者ID:benbrandt,项目名称:pods,代码行数:24,代码来源:Pods_Templates_Auto_Template_Settings.php

示例13: get_avatar

 /**
  * Take over the avatar served from WordPress
  *
  * @param string $avatar Default Avatar Image output from WordPress
  * @param int|string|object $id_or_email A user ID, email address, or comment object
  * @param int $size Size of the avatar image
  * @param string $default URL to a default image to use if no avatar is available
  * @param string $alt Alternate text to use in image tag. Defaults to blank
  * @return string <img> tag for the user's avatar
  */
 public function get_avatar($avatar, $id_or_email, $size, $default = '', $alt = '')
 {
     $_user_ID = 0;
     if (is_numeric($id_or_email) && 0 < $id_or_email) {
         $_user_ID = (int) $id_or_email;
     } elseif (is_object($id_or_email) && isset($id_or_email->user_id) && 0 < $id_or_email->user_id) {
         $_user_ID = (int) $id_or_email->user_id;
     } elseif (is_object($id_or_email) && isset($id_or_email->ID) && isset($id_or_email->user_login) && 0 < $id_or_email->ID) {
         $_user_ID = (int) $id_or_email->ID;
     } elseif (!is_object($id_or_email) && false !== strpos($id_or_email, '@')) {
         $_user = get_user_by('email', $id_or_email);
         if (!empty($_user)) {
             $_user_ID = (int) $_user->ID;
         }
     }
     if (0 < $_user_ID && !empty(PodsMeta::$user)) {
         $avatar_cached = pods_cache_get($_user_ID . '-' . $size, 'pods_avatars');
         if (!empty($avatar_cached)) {
             $avatar = $avatar_cached;
         } else {
             $avatar_field = pods_transient_get('pods_avatar_field');
             $user = current(PodsMeta::$user);
             if (empty($avatar_field)) {
                 foreach ($user['fields'] as $field) {
                     if ('avatar' == $field['type']) {
                         $avatar_field = $field['name'];
                         pods_transient_set('pods_avatar_field', $avatar_field);
                         break;
                     }
                 }
             } elseif (!isset($user['fields'][$avatar_field])) {
                 $avatar_field = false;
             }
             if (!empty($avatar_field)) {
                 $user_avatar = get_user_meta($_user_ID, $avatar_field . '.ID', true);
                 if (!empty($user_avatar)) {
                     $attributes = array('alt' => '', 'class' => 'avatar avatar-' . $size . ' photo');
                     if (!empty($alt)) {
                         $attributes['alt'] = $alt;
                     }
                     $user_avatar = pods_image($user_avatar, array($size, $size), 0, $attributes);
                     if (!empty($user_avatar)) {
                         $avatar = $user_avatar;
                         pods_cache_set($_user_ID . '-' . $size, $avatar, 'pods_avatars');
                     }
                 }
             }
         }
     }
     return $avatar;
 }
开发者ID:centaurustech,项目名称:chipin,代码行数:61,代码来源:avatar.php

示例14: setup_related_objects

 /**
  * Setup related objects
  *
  * @param boolean $force Whether to force refresh of related objects
  *
  * @since 2.3
  */
 public function setup_related_objects($force = false)
 {
     $related_objects = pods_transient_get('pods_related_objects');
     if (!$force && !empty($related_objects)) {
         self::$related_objects = $related_objects;
     } else {
         // Custom
         self::$related_objects['custom-simple'] = array('label' => __('Simple (custom defined list)', 'pods'), 'group' => __('Custom', 'pods'), 'simple' => true);
         // Pods
         $pod_options = array();
         // Advanced Content Types
         $_pods = PodsMeta::$advanced_content_types;
         foreach ($_pods as $pod) {
             $pod_options[$pod['name']] = $pod['label'] . ' (' . $pod['name'] . ')';
         }
         // Settings
         $_pods = PodsMeta::$settings;
         foreach ($_pods as $pod) {
             $pod_options[$pod['name']] = $pod['label'] . ' (' . $pod['name'] . ')';
         }
         asort($pod_options);
         foreach ($pod_options as $pod => $label) {
             self::$related_objects['pod-' . $pod] = array('label' => $label, 'group' => __('Pods', 'pods'), 'bidirectional' => true);
         }
         // Post Types
         $post_types = get_post_types();
         asort($post_types);
         $ignore = array('attachment', 'revision', 'nav_menu_item');
         foreach ($post_types as $post_type => $label) {
             if (in_array($post_type, $ignore) || empty($post_type)) {
                 unset($post_types[$post_type]);
                 continue;
             } elseif (0 === strpos($post_type, '_pods_')) {
                 unset($post_types[$post_type]);
                 continue;
             }
             $post_type = get_post_type_object($post_type);
             self::$related_objects['post_type-' . $post_type->name] = array('label' => $post_type->label . ' (' . $post_type->name . ')', 'group' => __('Post Types', 'pods'), 'bidirectional' => true);
         }
         // Taxonomies
         $taxonomies = get_taxonomies();
         asort($taxonomies);
         $ignore = array('nav_menu', 'post_format');
         foreach ($taxonomies as $taxonomy => $label) {
             if (in_array($taxonomy, $ignore) || empty($taxonomy)) {
                 continue;
             }
             $taxonomy = get_taxonomy($taxonomy);
             self::$related_objects['taxonomy-' . $taxonomy->name] = array('label' => $taxonomy->label . ' (' . $taxonomy->name . ')', 'group' => __('Taxonomies', 'pods'), 'bidirectional' => true);
         }
         // Other WP Objects
         self::$related_objects['user'] = array('label' => __('Users', 'pods'), 'group' => __('Other WP Objects', 'pods'), 'bidirectional' => true);
         self::$related_objects['role'] = array('label' => __('User Roles', 'pods'), 'group' => __('Other WP Objects', 'pods'), 'simple' => true, 'data_callback' => array($this, 'data_roles'));
         self::$related_objects['capability'] = array('label' => __('User Capabilities', 'pods'), 'group' => __('Other WP Objects', 'pods'), 'simple' => true, 'data_callback' => array($this, 'data_capabilities'));
         self::$related_objects['media'] = array('label' => __('Media', 'pods'), 'group' => __('Other WP Objects', 'pods'), 'bidirectional' => true);
         self::$related_objects['comment'] = array('label' => __('Comments', 'pods'), 'group' => __('Other WP Objects', 'pods'), 'bidirectional' => true);
         self::$related_objects['image-size'] = array('label' => __('Image Sizes', 'pods'), 'group' => __('Other WP Objects', 'pods'), 'simple' => true, 'data_callback' => array($this, 'data_image_sizes'));
         self::$related_objects['nav_menu'] = array('label' => __('Navigation Menus', 'pods'), 'group' => __('Other WP Objects', 'pods'));
         self::$related_objects['post_format'] = array('label' => __('Post Formats', 'pods'), 'group' => __('Other WP Objects', 'pods'));
         self::$related_objects['post-status'] = array('label' => __('Post Status', 'pods'), 'group' => __('Other WP Objects', 'pods'), 'simple' => true, 'data_callback' => array($this, 'data_post_stati'));
         do_action('pods_form_ui_field_pick_related_objects_other');
         self::$related_objects['country'] = array('label' => __('Countries', 'pods'), 'group' => __('Predefined Lists', 'pods'), 'simple' => true, 'data_callback' => array($this, 'data_countries'));
         self::$related_objects['us_state'] = array('label' => __('US States', 'pods'), 'group' => __('Predefined Lists', 'pods'), 'simple' => true, 'data_callback' => array($this, 'data_us_states'));
         do_action('pods_form_ui_field_pick_related_objects_predefined');
         if (did_action('init')) {
             pods_transient_set('pods_related_objects', self::$related_objects);
         }
     }
     foreach (self::$custom_related_objects as $object => $related_object) {
         self::$related_objects[$object] = $related_object;
     }
 }
开发者ID:centaurustech,项目名称:chipin,代码行数:79,代码来源:pick.php

示例15: flush_rewrite_rules

 /**
  * Check if we need to flush WordPress rewrite rules
  * This gets run during 'init' action late in the game to give other plugins time to register their rewrite rules
  *
  */
 public function flush_rewrite_rules()
 {
     $flush = pods_transient_get('pods_flush_rewrites');
     if (1 == $flush) {
         global $wp_rewrite;
         $wp_rewrite->flush_rules();
         $wp_rewrite->init();
         pods_transient_set('pods_flush_rewrites', 0);
     }
 }
开发者ID:talentedunicorn,项目名称:pods,代码行数:15,代码来源:PodsInit.php


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