• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP pods_clean_name函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: save_column

 /**
  * Add or edit a column within a content type
  *
  * $params['id'] int The field ID
  * $params['name'] string The field name
  * $params['datatype'] int The datatype ID
  * $params['dtname'] string The datatype name
  * $params['coltype'] string The column type ("txt", "desc", "pick", etc)
  * $params['sister_field_id'] int (optional) The related field ID
  * $params['pickval'] string The related PICK pod name
  * $params['label'] string The field label
  * $params['comment'] string The field comment
  * $params['display_helper'] string (optional) The display helper name
  * $params['input_helper'] string (optional) The input helper name
  * $params['pick_filter'] string (optional) WHERE clause for PICK fields
  * $params['pick_orderby'] string (optional) ORDER BY clause for PICK fields
  * $params['required'] bool Is the field required?
  * $params['unique'] bool Is the field unique?
  * $params['multiple'] bool Is the PICK dropdown a multi-select?
  *
  * @param array $params An associative array of parameters
  * @since 1.7.9
  */
 function save_column($params)
 {
     if (defined('PODS_STRICT_MODE') && PODS_STRICT_MODE) {
         $params = pods_sanitize($params);
     }
     $params = (object) str_replace('@wp_', '{prefix}', $params);
     // Set defaults
     $params = (object) array_merge(array('id' => '', 'name' => '', 'datatype' => '', 'dtname' => '', 'coltype' => 'txt', 'sister_field_id' => 0, 'pickval' => '', 'label' => '', 'comment' => '', 'display_helper' => '', 'input_helper' => '', 'pick_filter' => '', 'pick_orderby' => '', 'required' => 0, 'unique' => 0, 'multiple' => 0), (array) $params);
     // Force Types
     $params->id = absint($params->id);
     $params->sister_field_id = absint($params->sister_field_id);
     $params->required = absint($params->required);
     $params->unique = absint($params->unique);
     $params->multiple = absint($params->multiple);
     $dbtypes = array('bool' => 'bool default 0', 'date' => 'datetime', 'num' => 'decimal(12,2)', 'txt' => 'varchar(128)', 'slug' => 'varchar(128)', 'code' => 'longtext', 'desc' => 'longtext');
     $dbtypes = apply_filters('pods_column_dbtypes', $dbtypes);
     // Add new column
     if (empty($params->id)) {
         $params->name = pods_clean_name($params->name);
         if (empty($params->name)) {
             return $this->oh_snap('<e>Enter a column name');
         } elseif (in_array($params->name, array('id', 'name', 'type', 'created', 'modified', 'p', 't'))) {
             return $this->oh_snap("<e>{$params->name} is a reserved name");
         }
         $sql = "SELECT id FROM @wp_pod_fields WHERE datatype = {$params->datatype} AND name = '{$params->name}' LIMIT 1";
         pod_query($sql, 'Cannot get fields', 'Column by this name already exists');
         if ('slug' == $params->coltype) {
             $sql = "SELECT id FROM @wp_pod_fields WHERE datatype = {$params->datatype} AND coltype = 'slug' LIMIT 1";
             pod_query($sql, 'Too many permalinks', 'This pod already has a permalink column');
         }
         // Sink the new column to the bottom of the list
         $weight = 0;
         $result = pod_query("SELECT weight FROM @wp_pod_fields WHERE datatype = {$params->datatype} ORDER BY weight DESC LIMIT 1");
         if (0 < mysql_num_rows($result)) {
             $row = mysql_fetch_assoc($result);
             $weight = (int) $row['weight'] + 1;
         }
         if ('pick' != $params->coltype) {
             $params->pickval = '';
             $params->pick_filter = '';
             $params->pick_orderby = '';
             $params->sister_field_id = 0;
             $params->multiple = 0;
         }
         $field_id = pod_query("INSERT INTO @wp_pod_fields (datatype, name, label, comment, display_helper, input_helper, coltype, pickval, pick_filter, pick_orderby, sister_field_id, required, `unique`, `multiple`, weight) VALUES ('{$params->datatype}', '{$params->name}', '{$params->label}', '{$params->comment}', '{$params->display_helper}', '{$params->input_helper}', '{$params->coltype}', '{$params->pickval}', '{$params->pick_filter}', '{$params->pick_orderby}', '{$params->sister_field_id}', '{$params->required}', '{$params->unique}', '{$params->multiple}', '{$weight}')", 'Cannot add new field');
         if ('pick' != $params->coltype && 'file' != $params->coltype) {
             $dbtype = $dbtypes[$params->coltype];
             pod_query("ALTER TABLE `@wp_pod_tbl_{$params->dtname}` ADD COLUMN `{$params->name}` {$dbtype}", 'Cannot create new column');
         } else {
             pod_query("UPDATE @wp_pod_fields SET sister_field_id = '{$field_id}' WHERE id = '{$params->sister_field_id}' LIMIT 1", 'Cannot update sister field');
         }
     } else {
         if ('id' == $params->name) {
             return $this->oh_snap("<e>{$params->name} is not editable.");
         }
         $sql = "SELECT id FROM @wp_pod_fields WHERE datatype = {$params->datatype} AND id != {$params->id} AND name = '{$params->name}' LIMIT 1";
         pod_query($sql, 'Column already exists', "{$params->name} already exists.");
         $sql = "SELECT name, coltype FROM @wp_pod_fields WHERE id = {$params->id} LIMIT 1";
         $result = pod_query($sql);
         if (0 < mysql_num_rows($result)) {
             $row = mysql_fetch_assoc($result);
             $old_coltype = $row['coltype'];
             $old_name = $row['name'];
             $dbtype = $dbtypes[$params->coltype];
             $pickval = 'pick' != $params->coltype || empty($params->pickval) ? '' : "{$params->pickval}";
             if ($params->coltype != $old_coltype) {
                 if ('pick' == $params->coltype || 'file' == $params->coltype) {
                     if ('pick' != $old_coltype && 'file' != $old_coltype) {
                         pod_query("ALTER TABLE `@wp_pod_tbl_{$params->dtname}` DROP COLUMN `{$old_name}`");
                     }
                 } elseif ('pick' == $old_coltype || 'file' == $old_coltype) {
                     pod_query("ALTER TABLE `@wp_pod_tbl_{$params->dtname}` ADD COLUMN `{$params->name}` {$dbtype}", 'Cannot create column');
                     pod_query("UPDATE @wp_pod_fields SET sister_field_id = NULL WHERE sister_field_id = {$params->id}");
                     pod_query("DELETE FROM @wp_pod_rel WHERE field_id = {$params->id}");
                 } else {
                     pod_query("ALTER TABLE `@wp_pod_tbl_{$params->dtname}` CHANGE `{$old_name}` `{$params->name}` {$dbtype}");
                 }
//.........这里部分代码省略.........
开发者ID:bidhanbaral,项目名称:fotodep_store,代码行数:101,代码来源:PodAPI.php


示例2: get_components

 /**
  * Get list of components available
  *
  * @since 2.0
  */
 public function get_components()
 {
     $components = pods_transient_get('pods_components');
     if (1 == pods_var('pods_debug_components', 'get', 0) && pods_is_admin(array('pods'))) {
         $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);
//.........这里部分代码省略.........
开发者ID:Ingenex,项目名称:redesign,代码行数:101,代码来源:PodsComponents.php


示例3: get_table_info


//.........这里部分代码省略.........
             $object_type = $_info['type'];
         }
         $info = array_merge($info, $_info);
     }
     if (0 === strpos($object_type, 'post_type') || 'media' == $object_type || in_array(pods_var_raw('type', $info['pod']), array('post_type', 'media'))) {
         $info['table'] = $wpdb->posts;
         $info['meta_table'] = $wpdb->postmeta;
         $info['field_id'] = 'ID';
         $info['field_index'] = 'post_title';
         $info['field_slug'] = 'post_name';
         $info['field_type'] = 'post_type';
         $info['field_parent'] = 'post_parent';
         $info['field_parent_select'] = '`t`.`' . $info['field_parent'] . '`';
         $info['meta_field_id'] = 'post_id';
         $info['meta_field_index'] = 'meta_key';
         $info['meta_field_value'] = 'meta_value';
         if ('media' == $object_type) {
             $object = 'attachment';
         }
         if (empty($name)) {
             $prefix = 'post_type-';
             // Make sure we actually have the prefix before trying anything with the name
             if (0 === strpos($object_type, $prefix)) {
                 $name = substr($object_type, strlen($prefix), strlen($object_type));
             }
         }
         if ('media' != $object_type) {
             $object_type = 'post_type';
         }
         $post_type = pods_sanitize(empty($object) ? $name : $object);
         if ('attachment' == $post_type || 'media' == $object_type) {
             $info['pod_table'] = $wpdb->prefix . 'pods_media';
         } else {
             $info['pod_table'] = $wpdb->prefix . 'pods_' . pods_clean_name($post_type, true, false);
         }
         $post_type_object = get_post_type_object($post_type);
         if (is_object($post_type_object) && $post_type_object->hierarchical) {
             $info['object_hierarchical'] = true;
         }
         /**
          * Default Post Status to query for.
          *
          * Use to change "default" post status from publish to any other status or statuses.
          *
          * @param  array $post_status List of post statuses. Default is 'publish'
          * @param  string $post_type Post type of current object
          * @param  array $info Array of information about the object.
          * @param  string $object	Type of object
          * @param  string $name Name of pod to load
          * @param  array $pod Array with Pod information. Result of PodsAPI::load_pod()
          * @param  array $field		Array with field information
          *
          * @since unknown
          */
         $post_status = apply_filters('pods_api_get_table_info_default_post_status', array('publish'), $post_type, $info, $object_type, $object, $name, $pod, $field);
         $info['where'] = array('post_type' => '`t`.`' . $info['field_type'] . '` = "' . $post_type . '"');
         if ('post_type' == $object_type) {
             $info['where_default'] = '`t`.`post_status` IN ( "' . implode('", "', $post_status) . '" )';
         }
         $info['orderby'] = '`t`.`menu_order`, `t`.`' . $info['field_index'] . '`, `t`.`post_date`';
         // WPML support
         if (is_object($sitepress) && $sitepress->is_translated_post_type($post_type) && !$icl_adjust_id_url_filter_off) {
             $info['join']['wpml_translations'] = "\n                        LEFT JOIN `{$wpdb->prefix}icl_translations` AS `wpml_translations`\n                            ON `wpml_translations`.`element_id` = `t`.`ID`\n                                AND `wpml_translations`.`element_type` = 'post_{$post_type}'\n                                AND `wpml_translations`.`language_code` = '{$current_language}'\n                    ";
             $info['join']['wpml_languages'] = "\n                        LEFT JOIN `{$wpdb->prefix}icl_languages` AS `wpml_languages`\n                            ON `wpml_languages`.`code` = `wpml_translations`.`language_code` AND `wpml_languages`.`active` = 1\n                    ";
             $info['where']['wpml_languages'] = "`wpml_languages`.`code` IS NOT NULL";
         } elseif (is_object($polylang) && !empty($current_language) && function_exists('pll_is_translated_post_type') && pll_is_translated_post_type($post_type)) {
开发者ID:satokora,项目名称:IT354Project,代码行数:67,代码来源:PodsAPI.php


示例4: pods_clean_name

echo pods_clean_name($attributes['name']);
?>
.find( 'li.pods-file:first' ).slideDown( 'fast' );

                var items = list_<?php 
echo pods_clean_name($attributes['name']);
?>
.find( 'li.pods-file' ),
                    itemCount = items.size();

                if ( 0 < maxFiles_<?php 
echo pods_clean_name($attributes['name']);
?>
 && itemCount > maxFiles_<?php 
echo pods_clean_name($attributes['name']);
?>
 ) {
                    items.each( function ( idx, elem ) {
                        if ( idx + 1 > maxFiles_<?php 
echo pods_clean_name($attributes['name']);
?>
 ) {
                            jQuery( elem ).remove();
                        }
                    } );
                }
            }
        } );
    } );
</script>
开发者ID:Ingenex,项目名称:redesign,代码行数:30,代码来源:plupload.php


示例5: get_object_data


//.........这里部分代码省略.........
                     }
                     $lookup_where = apply_filters('pods_form_ui_field_pick_autocomplete_lookup', $lookup_where, $data_params['query'], $name, $value, $options, $pod, $id, $object_params, $search_data);
                     if (!empty($lookup_where)) {
                         $params['where'][] = implode(' OR ', $lookup_where);
                     }
                     $orderby = array();
                     $orderby[] = "(`t`.`{$search_data->field_index}` LIKE '%" . pods_sanitize_like($data_params['query']) . "%' ) DESC";
                     $pick_orderby = pods_var_raw(self::$type . '_orderby', $options, null, null, true);
                     if (0 < strlen($pick_orderby)) {
                         $orderby[] = $pick_orderby;
                     }
                     $orderby[] = "`t`.`{$search_data->field_index}`";
                     $orderby[] = "`t`.`{$search_data->field_id}`";
                     $params['orderby'] = $orderby;
                 }
             } elseif (0 < $limit) {
                 $params['limit'] = $limit;
                 $params['page'] = $page;
             }
             $extra = '';
             if ($wpdb->posts == $search_data->table) {
                 $extra = ', `t`.`post_type`';
             } elseif ($wpdb->terms == $search_data->table) {
                 $extra = ', `tt`.`taxonomy`';
             } elseif ($wpdb->comments == $search_data->table) {
                 $extra = ', `t`.`comment_type`';
             }
             $params['select'] .= $extra;
             if ('user' == pods_var(self::$type . '_object', $options)) {
                 $roles = pods_var(self::$type . '_user_role', $options);
                 if (!empty($roles)) {
                     $where = array();
                     foreach ((array) $roles as $role) {
                         if (empty($role) || pods_clean_name($role) != $role && sanitize_title($role) != $role) {
                             continue;
                         }
                         $where[] = $wpdb->base_prefix . (is_multisite() && !is_main_site() ? get_current_blog_id() . '_' : '') . 'capabilities.meta_value LIKE "%\\"' . pods_sanitize_like($role) . '\\"%"';
                     }
                     if (!empty($where)) {
                         $params['where'][] = implode(' OR ', $where);
                     }
                 }
             }
             $results = $search_data->select($params);
             if ($autocomplete && $params['limit'] < $search_data->total_found()) {
                 if (!empty($value)) {
                     $ids = $value;
                     if (is_array($ids) && isset($ids[0]) && is_array($ids[0])) {
                         $ids = wp_list_pluck($ids, $search_data->field_id);
                     }
                     if (is_array($ids)) {
                         $ids = implode(', ', $ids);
                     }
                     if (is_array($params['where'])) {
                         $params['where'] = implode(' AND ', $params['where']);
                     }
                     if (!empty($params['where'])) {
                         $params['where'] .= ' AND ';
                     }
                     $params['where'] .= "`t`.`{$search_data->field_id}` IN ( " . $ids . " )";
                     $results = $search_data->select($params);
                 }
             } else {
                 $autocomplete = false;
             }
             if ('data' == $context) {
开发者ID:dylansmithing,项目名称:leader-of-rock-wordpress,代码行数:67,代码来源:pick.php


示例6: setup

 /**
  * @param $options
  *
  * @return array|bool|mixed|null|PodsArray
  */
 public function setup($options)
 {
     $options = pods_array($options);
     $options->validate('num', '', 'absint');
     if (empty($options->num)) {
         $options->num = '';
     }
     $options->validate('id', pods_var('id' . $options->num, 'get', $this->id));
     $options->validate('do', pods_var('do' . $options->num, 'get', $this->do), 'in_array', array('save', 'create'));
     $options->validate('excluded', self::$excluded, 'array_merge');
     $options->validate('action', pods_var('action' . $options->num, 'get', $this->action, null, true), 'in_array', $this->actions);
     $options->validate('actions_bulk', $this->actions_bulk, 'array_merge');
     $options->validate('action_bulk', pods_var('action_bulk' . $options->num, 'get', $this->action_bulk, null, true), 'isset', $this->actions_bulk);
     $bulk = pods_var('action_bulk_ids' . $options->num, 'get', array(), null, true);
     if (!empty($bulk)) {
         $bulk = (array) pods_var('action_bulk_ids' . $options->num, 'get', array(), null, true);
     } else {
         $bulk = array();
     }
     $options->validate('bulk', $bulk, 'array_merge', $this->bulk);
     $options->validate('views', $this->views, 'array');
     $options->validate('view', pods_var('view' . $options->num, 'get', $this->view, null, true), 'isset', $this->views);
     $options->validate('searchable', $this->searchable, 'boolean');
     $options->validate('search', pods_var('search' . $options->num, 'get'));
     $options->validate('search_across', $this->search_across, 'boolean');
     $options->validate('search_across_picks', $this->search_across_picks, 'boolean');
     $options->validate('filters', $this->filters, 'array');
     $options->validate('filters_enhanced', $this->filters_enhanced, 'boolean');
     $options->validate('where', $this->where, 'array_merge');
     $options->validate('pagination', $this->pagination, 'boolean');
     $options->validate('page', pods_var('pg' . $options->num, 'get', $this->page), 'absint');
     $options->validate('limit', pods_var('limit' . $options->num, 'get', $this->limit), 'int');
     if (isset($this->pods_data) && is_object($this->pods_data)) {
         $this->sql = array('table' => $this->pods_data->table, 'field_id' => $this->pods_data->field_id, 'field_index' => $this->pods_data->field_index);
     }
     $options->validate('sql', $this->sql, 'array_merge');
     $options->validate('orderby_dir', strtoupper(pods_v('orderby_dir' . $options['num'], 'get', $this->orderby_dir, true)), 'in_array', array('ASC', 'DESC'));
     $orderby = $this->orderby;
     // Enforce strict DB column name usage
     if (!empty($_GET['orderby' . $options->num])) {
         $orderby = pods_clean_name($_GET['orderby' . $options->num], true, false);
     }
     if (!empty($orderby)) {
         $orderby = array('default' => $orderby);
     } else {
         $orderby = array();
     }
     $options->validate('orderby', $orderby, 'array_merge');
     $options->validate('sortable', $this->sortable, 'boolean');
     $options->validate('params', $this->params, 'array');
     $options->validate('restrict', $this->restrict, 'array_merge');
     // handle author restrictions
     if (!empty($options['restrict']['author_restrict'])) {
         $restrict = $options['restrict'];
         if (!is_array($restrict['author_restrict'])) {
             $restrict['author_restrict'] = array($restrict['author_restrict'] => get_current_user_id());
         }
         if (null === $restrict['edit']) {
             $restrict['edit'] = $restrict['author_restrict'];
         }
         $options->restrict = $restrict;
     }
     if (null !== $options['restrict']['edit']) {
         $restrict = $options['restrict'];
         if (null === $restrict['duplicate']) {
             $restrict['duplicate'] = $restrict['edit'];
         }
         if (null === $restrict['delete']) {
             $restrict['delete'] = $restrict['edit'];
         }
         if (null === $restrict['manage']) {
             $restrict['manage'] = $restrict['edit'];
         }
         if (null === $restrict['reorder']) {
             $restrict['reorder'] = $restrict['edit'];
         }
         $options->restrict = $restrict;
     }
     $item = __('Item', 'pods');
     $items = __('Items', 'pods');
     if (is_object($this->pod)) {
         $item = pods_var_raw('label_singular', $this->pod->pod_data['options'], pods_var_raw('label', $this->pod->pod_data, $item, null, true), null, true);
         $items = pods_var_raw('label', $this->pod->pod_data, $items, null, true);
     }
     $options->validate('item', $item);
     $options->validate('items', $items);
     $options->validate('heading', array('manage' => __('Manage', 'pods'), 'add' => __('Add New', 'pods'), 'edit' => __('Edit', 'pods'), 'duplicate' => __('Duplicate', 'pods'), 'view' => __('View', 'pods'), 'reorder' => __('Reorder', 'pods'), 'search' => __('Search', 'pods'), 'views' => __('View', 'pods')), 'array_merge');
     $options->validate('header', array('manage' => sprintf(__('Manage %s', 'pods'), $options->items), 'add' => sprintf(__('Add New %s', 'pods'), $options->item), 'edit' => sprintf(__('Edit %s', 'pods'), $options->item), 'duplicate' => sprintf(__('Duplicate %s', 'pods'), $options->item), 'view' => sprintf(__('View %s', 'pods'), $options->item), 'reorder' => sprintf(__('Reorder %s', 'pods'), $options->items), 'search' => sprintf(__('Search %s', 'pods'), $options->items)), 'array_merge');
     $options->validate('label', array('add' => sprintf(__('Save New %s', 'pods'), $options->item), 'add_new' => __('Add New', 'pods'), 'edit' => sprintf(__('Save %s', 'pods'), $options->item), 'duplicate' => sprintf(__('Save New %s', 'pods'), $options->item), 'delete' => sprintf(__('Delete this %s', 'pods'), $options->item), 'view' => sprintf(__('View %s', 'pods'), $options->item), 'reorder' => sprintf(__('Reorder %s', 'pods'), $options->items)), 'array_merge');
     $options->validate('fields', array('manage' => array($options->sql['field_index'] => array('label' => __('Name', 'pods')))), 'array');
     $options->validate('export', $this->export, 'array_merge');
     $options->validate('reorder', $this->reorder, 'array_merge');
     $options->validate('screen_options', $this->screen_options, 'array_merge');
     $options->validate('session', $this->session, 'in_array', array('search', 'filters', 'show_per_page', 'orderby'));
     $options->validate('user', $this->user, 'in_array', array('search', 'filters', 'show_per_page', 'orderby'));
//.........这里部分代码省略.........
开发者ID:dylansmithing,项目名称:leader-of-rock-wordpress,代码行数:101,代码来源:PodsUI.php


示例7: pods_js_name

/**
 * Return a lowercase alphanumeric name (with underscores) for safe Javascript variable names
 *
 * @param string $orig Input string to clean
 * @param boolean $lower Force lowercase
 *
 * @return string Sanitized name
 *
 * @since 2.5.3
 */
function pods_js_name($orig, $lower = true)
{
    $str = pods_clean_name($orig, $lower);
    $str = str_replace('-', '_', $str);
    return $str;
}
开发者ID:dylansmithing,项目名称:leader-of-rock-wordpress,代码行数:16,代码来源:data.php


示例8: 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';
 }
开发者ID:dylansmithing,项目名称:leader-of-rock-wordpress,代码行数:60,代码来源:PodsUpgrade_2_0_0.php


示例9: import


//.........这里部分代码省略.........
                         $pod_data['fields'][$k] = $new_field;
                     }
                 }
                 if (pods_var('id', $pod, 0) < 1) {
                     $pod_data['fields'] = array_merge($core_fields, $pod_data['fields']);
                 }
                 if (empty($pod_data['label'])) {
                     $pod_data['label'] = ucwords(str_replace('_', ' ', $pod_data['name']));
                 }
                 if (isset($pod_data['is_toplevel'])) {
                     $pod_data['show_in_menu'] = 1 == $pod_data['is_toplevel'] ? 1 : 0;
                     unset($pod_data['is_toplevel']);
                 }
                 if (isset($pod_data['detail_page'])) {
                     $pod_data['detail_url'] = $pod_data['detail_page'];
                     unset($pod_data['detail_page']);
                 }
                 if (isset($pod_data['before_helpers'])) {
                     $pod_data['pre_save_helpers'] = $pod_data['before_helpers'];
                     unset($pod_data['before_helpers']);
                 }
                 if (isset($pod_data['after_helpers'])) {
                     $pod_data['post_save_helpers'] = $pod_data['after_helpers'];
                     unset($pod_data['after_helpers']);
                 }
                 if (isset($pod_data['pre_drop_helpers'])) {
                     $pod_data['pre_delete_helpers'] = $pod_data['pre_drop_helpers'];
                     unset($pod_data['pre_drop_helpers']);
                 }
                 if (isset($pod_data['post_drop_helpers'])) {
                     $pod_data['post_delete_helpers'] = $pod_data['post_drop_helpers'];
                     unset($pod_data['post_drop_helpers']);
                 }
                 $pod_data['name'] = pods_clean_name($pod_data['name']);
                 $pod_data = array('name' => $pod_data['name'], 'label' => $pod_data['label'], 'type' => 'pod', 'storage' => 'table', 'fields' => $pod_data['fields'], 'options' => array('pre_save_helpers' => pods_var_raw('pre_save_helpers', $pod_data), 'post_save_helpers' => pods_var_raw('post_save_helpers', $pod_data), 'pre_delete_helpers' => pods_var_raw('pre_delete_helpers', $pod_data), 'post_delete_helpers' => pods_var_raw('post_delete_helpers', $pod_data), 'show_in_menu' => 1 == pods_var_raw('show_in_menu', $pod_data, 0) ? 1 : 0, 'detail_url' => pods_var_raw('detail_url', $pod_data), 'pod_index' => 'name'));
             }
             $pod = array_merge($pod, $pod_data);
             foreach ($pod['fields'] as $k => $field) {
                 if (isset($field['id']) && !isset($existing_fields[$field['name']])) {
                     unset($pod['fields'][$k]['id']);
                 }
                 if (isset($field['pod_id'])) {
                     unset($pod['fields'][$k]['pod_id']);
                 }
                 if (isset($existing_fields[$field['name']])) {
                     if ($existing_field = pods_api()->load_field(array('name' => $field['name'], 'pod' => $pod['name']))) {
                         $pod['fields'][$k]['id'] = $existing_field['id'];
                     }
                 }
                 if (isset($field['pod'])) {
                     unset($pod['fields'][$k]['pod']);
                 }
             }
             $api->save_pod($pod);
             if (!isset($found['pods'])) {
                 $found['pods'] = array();
             }
             $found['pods'][$pod['name']] = $pod['label'];
         }
     }
     if (isset($data['templates']) && is_array($data['templates'])) {
         foreach ($data['templates'] as $template_data) {
             if (isset($template_data['id'])) {
                 unset($template_data['id']);
             }
             $template = $api->load_template(array('name' => $template_data['name']));
开发者ID:dylansmithing,项目名称:leader-of-rock-wordpress,代码行数:67,代码来源:Migrate-Packages.php


示例10: build_xml_level

 public function build_xml_level($item, $column, $level = 2, $column_name = '')
 {
     $column = pods_clean_name($column, false, false);
     $line = '';
     $value = '';
     if (is_object($item)) {
         if (!isset($item->{$column})) {
             $item->{$column} = '';
         }
         $value = $item->{$column};
     } elseif (is_array($item)) {
         if (!isset($item[$column])) {
             $item[$column] = '';
         }
         $value = $item[$column];
     }
     if (!empty($column_name)) {
         $column = $column_name;
     }
     $tabs = str_repeat("\t", $level);
     $line .= $tabs . "<{$column}>";
     if (is_array($value) || is_object($value)) {
         if (is_object($value)) {
             $value = get_object_vars($value);
         }
         foreach ($value as $k => $v) {
             if (is_int($k)) {
                 $line .= $this->build_xml_level($value, $k, $level + 1, 'value');
             } else {
                 $line .= $this->build_xml_level($value, $k, $level + 1);
             }
         }
     } elseif (false !== strpos($value, '<')) {
         $value = str_replace(array('<![CDATA[', ']]>'), array('&lt;![CDATA[', ']]&gt;'), $value);
         $line .= "<![CDATA[" . $value . "]]>";
     } else {
         $line .= $value;
     }
     $line .= "</{$column}>\r\n";
     return $line;
 }
开发者ID:centaurustech,项目名称:chipin,代码行数:41,代码来源:PodsMigrate.php


示例11: migrate_taxonomy

 /**
  *
  *
  * @since 2.0
  */
 private function migrate_taxonomy($taxonomy)
 {
     $params = array('type' => 'taxonomy', 'storage' => 'table', 'object' => '', 'name' => pods_var_raw('name', $taxonomy), 'label' => pods_var_raw('label', $taxonomy), 'label_singular' => pods_var_raw('singular_label', $taxonomy), 'public' => 1, 'show_ui' => (int) pods_var_raw('show_ui', $taxonomy), 'hierarchical' => (int) pods_var_raw('hierarchical', $taxonomy), 'query_var' => (int) pods_var_raw('query_var', $taxonomy), 'rewrite' => (int) pods_var_raw('rewrite', $taxonomy), 'rewrite_custom_slug' => pods_var_raw('rewrite_slug', $taxonomy), 'label_search_items' => pods_var_raw('search_items', $taxonomy[0]), 'label_popular_items' => pods_var_raw('popular_items', $taxonomy[0]), 'label_all_items' => pods_var_raw('all_items', $taxonomy[0]), 'label_parent' => pods_var_raw('parent_item', $taxonomy[0]), 'label_parent_item_colon' => pods_var_raw('parent_item_colon', $taxonomy[0]), 'label_edit' => pods_var_raw('edit_item', $taxonomy[0]), 'label_update_item' => pods_var_raw('update_item', $taxonomy[0]), 'label_add_new' => pods_var_raw('add_new_item', $taxonomy[0]), 'label_new_item' => pods_var_raw('new_item_name', $taxonomy[0]), 'label_separate_items_with_commas' => pods_var_raw('separate_items_with_commas', $taxonomy[0]), 'label_add_or_remove_items' => pods_var_raw('add_or_remove_items', $taxonomy[0]), 'label_choose_from_the_most_used' => pods_var_raw('choose_from_most_used', $taxonomy[0]));
     // Migrate attach-to
     $attach = $taxonomy[1];
     if (is_array($attach)) {
         foreach ($attach as $type_name) {
             $params['built_in_post_types_' . $type_name] = 1;
         }
     }
     if (!is_object($this->api)) {
         $this->api = pods_api();
     }
     $pod = $this->api->load_pod(array('name' => pods_clean_name($params['name'])), false);
     if (!empty($pod)) {
         return pods_error(sprintf(__('Pod with the name %s already exists', 'pods'), pods_clean_name($params['name'])));
     }
     $id = (int) $this->api->save_pod($params);
     if (empty($id)) {
         return false;
     }
     $pod = $this->api->load_pod(array('id' => $id), false);
     if (empty($pod)) {
         return false;
     }
     if ($pod['name'] != $params['name']) {
         $this->api->rename_wp_object($params['type '], $params['name'], $pod['name']);
     }
     return $id;
 }
开发者ID:centaurustech,项目名称:chipin,代码行数:35,代码来源:Migrate-CPTUI.php


示例12: get_table_info


//.........这里部分代码省略.........
                     }
                 }
             }
         }
         if (0 === strpos($object_type, 'post_type') || 'media' == $object_type || in_array(pods_var_raw('type', $info['pod']), array('post_type', 'media'))) {
             $info['table'] = $wpdb->posts;
             $info['meta_table'] = $wpdb->postmeta;
             $info['field_id'] = 'ID';
             $info['field_index'] = 'post_title';
             $info['field_slug'] = 'post_name';
             $info['field_type'] = 'post_type';
             $info['field_parent'] = 'post_parent';
             $info['field_parent_select'] = '`t`.`' . $info['field_parent'] . '`';
             $info['meta_field_id'] = 'post_id';
             $info['meta_field_index'] = 'meta_key';
             $info['meta_field_value'] = 'meta_value';
             if ('media' == $object_type) {
                 $object = 'attachment';
             }
             if (empty($name)) {
                 $prefix = 'post_type-';
                 // Make sure we actually have the prefix before trying anything with the name
                 if (0 === strpos($object_type, $prefix)) {
                     $name = substr($object_type, strlen($prefix), strlen($object_type));
                 }
             }
             if ('media' != $object_type) {
                 $object_type = 'post_type';
             }
             $post_type = pods_sanitize(empty($object) ? $name : $object);
             if ('attachment' == $post_type || 'media' == $object_type) {
                 $info['pod_table'] = $wpdb->prefix . 'pods_media';
             } else {
                 $info['pod_table'] = $wpdb->prefix . 'pods_' . pods_clean_name($post_type, true, false);
             }
             $post_type_object = get_post_type_object($post_type);
             if (is_object($post_type_object) && $post_type_object->hierarchical) {
                 $info['object_hierarchical'] = true;
             }
             $post_stati = $this->do_hook('get_table_info_default_post_status', array('publish'), $post_type, $info, $object_type, $object, $name, $pod, $field);
             $info['where'] = array('post_type' => '`t`.`' . $info['field_type'] . '` = "' . $post_type . '"');
             if ('post_type' == $object_type) {
                 $info['where_default'] = '`t`.`post_status` IN ( "' . implode('", "', $post_stati) . '" )';
             }
             $info['orderby'] = '`t`.`menu_order`, `t`.`' . $info['field_index'] . '`, `t`.`post_date`';
             // WPML support
             if (is_object($sitepress) && $sitepress->is_translated_post_type($post_type) && !$icl_adjust_id_url_filter_off) {
                 $info['join']['wpml_translations'] = "\n                        LEFT JOIN `{$wpdb->prefix}icl_translations` AS `wpml_translations`\n                            ON `wpml_translations`.`element_id` = `t`.`ID`\n                                AND `wpml_translations`.`element_type` = 'post_{$post_type}'\n                                AND `wpml_translations`.`language_code` = '{$current_language}'\n                    ";
                 $info['join']['wpml_languages'] = "\n                        LEFT JOIN `{$wpdb->prefix}icl_languages` AS `wpml_languages`\n                            ON `wpml_languages`.`code` = `wpml_translations`.`language_code` AND `wpml_languages`.`active` = 1\n                    ";
                 $info['where']['wpml_languages'] = "`wpml_languages`.`code` IS NOT NULL";
             } elseif (is_object($polylang) && !empty($current_language) && function_exists('pll_is_translated_post_type') && pll_is_translated_post_type($post_type)) {
                 $info['join']['polylang_languages'] = "\n                        LEFT JOIN `{$wpdb->term_relationships}` AS `polylang_languages`\n                            ON `polylang_languages`.`object_id` = `t`.`ID`\n                                AND `polylang_languages`.`term_taxonomy_id` = {$current_language_tt_id}\n                    ";
                 $info['where']['polylang_languages'] = "`polylang_languages`.`object_id` IS NOT NULL";
             }
             $info['object_fields'] = $this->get_wp_object_fields($object_type, $info['pod']);
         } elseif (0 === strpos($object_type, 'taxonomy') || in_array($object_type, array('nav_menu', 'post_format')) || 'taxonomy' == pods_var_raw('type', $info['pod'])) {
             $info['table'] = $info['meta_table'] = $wpdb->terms;
             $info['join']['tt'] = "LEFT JOIN `{$wpdb->term_taxonomy}` AS `tt` ON `tt`.`term_id` = `t`.`term_id`";
             $info['field_id'] = $info['meta_field_id'] = 'term_id';
             $info['field_index'] = $info['meta_field_index'] = $info['meta_field_value'] = 'name';
             $info['field_slug'] = 'slug';
             $info['field_type'] = 'taxonomy';
             $info['field_parent'] = 'parent';
             $info['field_parent_select'] = '`tt`.`' . $info['field_parent'] . '`';
             if ('nav_menu' == $object_type) {
                 $object = 'nav_menu';
开发者ID:Ingenex,项目名称:redesign,代码行数:67,代码来源:PodsAPI.php


示例13: clean

 /**
  * Clean a value for use in class / id
  *
  * @since 2.0
  */
 public static fun 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP pods_data函数代码示例发布时间:2022-05-15
下一篇:
PHP pods_api函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap