本文整理汇总了PHP中pods_tableless函数的典型用法代码示例。如果您正苦于以下问题:PHP pods_tableless函数的具体用法?PHP pods_tableless怎么用?PHP pods_tableless使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pods_tableless函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Do things like register/enqueue scripts and stylesheets
*
* @since 2.3
*/
public function __construct()
{
if (!pods_tableless()) {
add_filter('pods_admin_setup_add_create_storage', '__return_true');
add_filter('pods_admin_setup_add_create_taxonomy_storage', '__return_true');
add_filter('pods_admin_setup_add_extend_storage', '__return_true');
add_filter('pods_admin_setup_add_extend_taxonomy_storage', '__return_true');
add_filter('pods_admin_setup_add_extend_pod_type', array($this, 'add_pod_type'));
}
}
示例2: install
/**
*
*/
public function install($_blog_id = null)
{
/**
* @var $wpdb WPDB
*/
global $wpdb;
// Switch DB table prefixes
if (null !== $_blog_id && $_blog_id != $wpdb->blogid) {
switch_to_blog(pods_absint($_blog_id));
} else {
$_blog_id = null;
}
$pods_version = get_option('pods_version');
do_action('pods_install', PODS_VERSION, $pods_version, $_blog_id);
if (!pods_tableless() && false !== apply_filters('pods_install_run', null, PODS_VERSION, $pods_version, $_blog_id) && !isset($_GET['pods_bypass_install'])) {
$sql = file_get_contents(PODS_DIR . 'sql/dump.sql');
$sql = apply_filters('pods_install_sql', $sql, PODS_VERSION, $pods_version, $_blog_id);
$charset_collate = 'DEFAULT CHARSET utf8';
if (!empty($wpdb->charset)) {
$charset_collate = "DEFAULT CHARSET {$wpdb->charset}";
}
if (!empty($wpdb->collate)) {
$charset_collate .= " COLLATE {$wpdb->collate}";
}
if ('DEFAULT CHARSET utf8' != $charset_collate) {
$sql = str_replace('DEFAULT CHARSET utf8', $charset_collate, $sql);
}
$sql = explode(";\n", str_replace(array("\r", 'wp_'), array("\n", $wpdb->prefix), $sql));
for ($i = 0, $z = count($sql); $i < $z; $i++) {
$query = trim($sql[$i]);
if (empty($query)) {
continue;
}
pods_query($query, 'Cannot setup SQL tables');
}
}
do_action('pods_install_post', PODS_VERSION, $pods_version, $_blog_id);
}
示例3: phpversion
<?php
global $wp_version, $wpdb;
$wp = $wp_version;
$php = phpversion();
$mysql = $wpdb->db_version();
$plugins = array();
$all_plugins = get_plugins();
foreach ($all_plugins as $plugin_file => $plugin_data) {
if (is_plugin_active($plugin_file)) {
$plugins[$plugin_data['Name']] = $plugin_data['Version'];
}
}
$stylesheet = get_stylesheet();
$theme = wp_get_theme($stylesheet);
$theme_name = $theme->get('Name');
$opcode_cache = array('Apc' => function_exists('apc_cache_info') ? 'Yes' : 'No', 'Memcached' => class_exists('eaccelerator_put') ? 'Yes' : 'No', 'Redis' => class_exists('xcache_set') ? 'Yes' : 'No');
$object_cache = array('Apc' => function_exists('apc_cache_info') ? 'Yes' : 'No', 'Apcu' => function_exists('apcu_cache_info') ? 'Yes' : 'No', 'Memcache' => class_exists('Memcache') ? 'Yes' : 'No', 'Memcached' => class_exists('Memcached') ? 'Yes' : 'No', 'Redis' => class_exists('Redis') ? 'Yes' : 'No');
$versions = array('WordPress Version' => $wp, 'PHP Version' => $php, 'MySQL Version' => $mysql, 'Server Software' => $_SERVER['SERVER_SOFTWARE'], 'Your User Agent' => $_SERVER['HTTP_USER_AGENT'], 'Session Save Path' => session_save_path(), 'Session Save Path Exists' => file_exists(session_save_path()) ? 'Yes' : 'No', 'Session Save Path Writeable' => is_writable(session_save_path()) ? 'Yes' : 'No', 'Session Max Lifetime' => ini_get('session.gc_maxlifetime'), 'Opcode Cache' => $opcode_cache, 'Object Cache' => $object_cache, 'WPDB Prefix' => $wpdb->prefix, 'WP Multisite Mode' => is_multisite() ? 'Yes' : 'No', 'WP Memory Limit' => WP_MEMORY_LIMIT, 'Pods Network-Wide Activated' => is_plugin_active_for_network(basename(PODS_DIR) . '/init.php') ? 'Yes' : 'No', 'Pods Install Location' => PODS_DIR, 'Pods Tableless Mode Activated' => pods_tableless() ? 'Yes' : 'No', 'Pods Light Mode Activated' => defined('PODS_LIGHT') && PODS_LIGHT ? 'Yes' : 'No', 'Currently Active Theme' => $theme_name, 'Currently Active Plugins' => $plugins);
foreach ($versions as $what => $version) {
echo '<p><strong>' . esc_html($what) . '</strong>: ';
if (is_array($version)) {
echo '</p><ul class="ul-disc">';
foreach ($version as $what_v => $v) {
echo '<li><strong>' . esc_html($what_v) . '</strong>: ' . esc_html($v) . '</li>';
}
echo '</ul>';
} else {
echo esc_html($version) . '</p>';
}
}
示例4: menu
/**
* Add menu item
*
* @param string $parent The parent slug.
*
* @since 2.0
*
* @uses add_submenu_page
*/
public function menu($parent)
{
global $submenu;
$custom_component_menus = array();
foreach ($this->components as $component => $component_data) {
$component_data['MustUse'] = apply_filters('pods_component_require_' . $component_data['ID'], $component_data['MustUse'], $component_data);
if (empty($component_data['MustUse']) && (!isset($this->settings['components'][$component]) || 0 == $this->settings['components'][$component])) {
continue;
}
if (!empty($component_data['Hide'])) {
continue;
}
if (!empty($component_data['DeveloperMode']) && !pods_developer()) {
continue;
}
if (empty($component_data['TablelessMode']) && pods_tableless()) {
continue;
}
if (empty($component_data['MenuPage'])) {
if (!isset($component_data['object'])) {
continue;
} elseif (!method_exists($component_data['object'], 'admin') && !method_exists($component_data['object'], 'options')) {
continue;
}
}
if (false === $component_data['External']) {
$component_data['File'] = realpath($this->components_dir . $component_data['File']);
}
if (!file_exists($component_data['File'])) {
pods_message('Pods Component not found: ' . $component_data['File']);
pods_transient_clear('pods_components');
continue;
}
$capability = 'pods_component_' . str_replace('-', '_', sanitize_title($component));
if (0 < strlen($component_data['Capability'])) {
$capability = $component_data['Capability'];
}
if (!pods_is_admin(array('pods', 'pods_components', $capability))) {
continue;
}
$menu_page = 'pods-component-' . $component;
if (!empty($component_data['MenuPage'])) {
$custom_component_menus[$menu_page] = $component_data;
}
$page = add_submenu_page($parent, strip_tags($component_data['Name']), '- ' . strip_tags($component_data['MenuName']), 'read', $menu_page, array($this, 'admin_handler'));
if (isset($component_data['object']) && method_exists($component_data['object'], 'admin_assets')) {
add_action('admin_print_styles-' . $page, array($component_data['object'], 'admin_assets'));
}
}
if (!empty($custom_component_menus)) {
foreach ($custom_component_menus as $menu_page => $component_data) {
if (isset($submenu[$parent])) {
foreach ($submenu[$parent] as $sub => &$menu) {
if ($menu[2] == $menu_page) {
$menu_page = $component_data['MenuPage'];
/*if ( !empty( $component_data[ 'MenuAddPage' ] ) ) {
if ( false !== strpos( $_SERVER[ 'REQUEST_URI' ], $component_data[ 'MenuAddPage' ] ) )
$menu_page = $component_data[ 'MenuAddPage' ];
}*/
$menu[2] = $menu_page;
$page = current(explode('?', $menu[2]));
if (isset($component_data['object']) && method_exists($component_data['object'], 'admin_assets')) {
add_action('admin_print_styles-' . $page, array($component_data['object'], 'admin_assets'));
}
break;
}
}
}
}
}
}
示例5: pods_no_conflict_on
/**
* Turn off conflicting / recursive actions for an object type that Pods hooks into
*
* @param string $object_type
* @param string $object
*
* @return bool
*
* @since 2.0
*/
function pods_no_conflict_on($object_type = 'post', $object = null)
{
if ('post_type' == $object_type) {
$object_type = 'post';
} elseif ('term' == $object_type) {
$object_type = 'taxonomy';
}
if (!empty(PodsInit::$no_conflict) && isset(PodsInit::$no_conflict[$object_type]) && !empty(PodsInit::$no_conflict[$object_type])) {
return true;
}
if (!is_object(PodsInit::$meta)) {
return false;
}
$no_conflict = array();
// Filters = Usually get/update/delete meta functions
// Actions = Usually insert/update/save/delete object functions
if ('post' == $object_type) {
$no_conflict['filter'] = array(array('get_post_metadata', array(PodsInit::$meta, 'get_post_meta'), 10, 4));
if (!pods_tableless()) {
$no_conflict['filter'] = array_merge($no_conflict['filter'], array(array('add_post_metadata', array(PodsInit::$meta, 'add_post_meta'), 10, 5), array('update_post_metadata', array(PodsInit::$meta, 'update_post_meta'), 10, 5), array('delete_post_metadata', array(PodsInit::$meta, 'delete_post_meta'), 10, 5)));
}
$no_conflict['action'] = array(array('transition_post_status', array(PodsInit::$meta, 'save_post_detect_new'), 10, 3), array('save_post', array(PodsInit::$meta, 'save_post'), 10, 2));
} elseif ('taxonomy' == $object_type) {
$no_conflict['filter'] = array();
$no_conflict['action'] = array(array('edit_term', array(PodsInit::$meta, 'save_taxonomy'), 10, 3), array('create_term', array(PodsInit::$meta, 'save_taxonomy'), 10, 3));
} elseif ('media' == $object_type) {
$no_conflict['filter'] = array(array('wp_update_attachment_metadata', array(PodsInit::$meta, 'save_media'), 10, 2), array('get_post_metadata', array(PodsInit::$meta, 'get_post_meta'), 10, 4));
if (!pods_tableless()) {
$no_conflict['filter'] = array_merge($no_conflict['filter'], array(array('add_post_metadata', array(PodsInit::$meta, 'add_post_meta'), 10, 5), array('update_post_metadata', array(PodsInit::$meta, 'update_post_meta'), 10, 5), array('delete_post_metadata', array(PodsInit::$meta, 'delete_post_meta'), 10, 5)));
}
$no_conflict['action'] = array();
} elseif ('user' == $object_type) {
$no_conflict['filter'] = array(array('get_user_metadata', array(PodsInit::$meta, 'get_user_meta'), 10, 4));
if (!pods_tableless()) {
$no_conflict['filter'] = array_merge($no_conflict['filter'], array(array('add_user_metadata', array(PodsInit::$meta, 'add_user_meta'), 10, 5), array('update_user_metadata', array(PodsInit::$meta, 'update_user_meta'), 10, 5), array('delete_user_metadata', array(PodsInit::$meta, 'delete_user_meta'), 10, 5)));
}
$no_conflict['action'] = array(array('profile_update', array(PodsInit::$meta, 'save_user')));
} elseif ('comment' == $object_type) {
$no_conflict['filter'] = array(array('get_comment_metadata', array(PodsInit::$meta, 'get_comment_meta'), 10, 4));
if (!pods_tableless()) {
$no_conflict['filter'] = array_merge($no_conflict['filter'], array(array('add_comment_metadata', array(PodsInit::$meta, 'add_comment_meta'), 10, 5), array('update_comment_metadata', array(PodsInit::$meta, 'update_comment_meta'), 10, 5), array('delete_comment_metadata', array(PodsInit::$meta, 'delete_comment_meta'), 10, 5)));
}
$no_conflict['action'] = array(array('pre_comment_approved', array(PodsInit::$meta, 'validate_comment'), 10, 2), array('comment_post', array(PodsInit::$meta, 'save_comment')), array('edit_comment', array(PodsInit::$meta, 'save_comment')));
} elseif ('settings' == $object_type) {
$no_conflict['filter'] = array();
// @todo Better handle settings conflicts apart from each other
/*if ( empty( $object ) ) {
foreach ( PodsMeta::$settings as $setting_pod ) {
foreach ( $setting_pod[ 'fields' ] as $option ) {
$no_conflict[ 'filter' ][] = array( 'pre_option_' . $setting_pod[ 'name' ] . '_' . $option[ 'name' ], array( PodsInit::$meta, 'get_option' ), 10, 1 );
$no_conflict[ 'filter' ][] = array( 'pre_update_option_' . $setting_pod[ 'name' ] . '_' . $option[ 'name' ], array( PodsInit::$meta, 'update_option' ), 10, 2 );
}
}
}
elseif ( isset( PodsMeta::$settings[ $object ] ) ) {
foreach ( PodsMeta::$settings[ $object ][ 'fields' ] as $option ) {
$no_conflict[ 'filter' ][] = array( 'pre_option_' . $object . '_' . $option[ 'name' ], array( PodsInit::$meta, 'get_option' ), 10, 1 );
$no_conflict[ 'filter' ][] = array( 'pre_update_option_' . $object . '_' . $option[ 'name' ], array( PodsInit::$meta, 'update_option' ), 10, 2 );
}
}*/
}
$conflicted = false;
foreach ($no_conflict as $action_filter => $conflicts) {
foreach ($conflicts as $k => $args) {
if (call_user_func_array('has_' . $action_filter, array_slice($args, 0, 2))) {
call_user_func_array('remove_' . $action_filter, array_slice($args, 0, 3));
$conflicted = true;
} else {
unset($no_conflict[$action_filter][$k]);
}
}
}
if ($conflicted) {
PodsInit::$no_conflict[$object_type] = $no_conflict;
return true;
}
return false;
}
示例6: lookup_related_items_from
/**
* Find related items related to an item
*
* @param int $field_id The Field ID
* @param int $pod_id The Pod ID
* @param int $id Item ID to get related IDs from
* @param array $field Field data array
* @param array $pod Pod data array
*
* @return array|bool
*
* @since 2.3
*
* @uses pods_query()
*/
public function lookup_related_items_from($field_id, $pod_id, $id, $field = null, $pod = null)
{
$related_ids = false;
$id = (int) $id;
$tableless_field_types = PodsForm::tableless_field_types();
if (empty($id) || !in_array(pods_v('type', $field), $tableless_field_types)) {
return false;
}
$related_pick_limit = 0;
if (!empty($field)) {
$options = (array) pods_var_raw('options', $field, $field, null, true);
$related_pick_limit = (int) pods_v('pick_limit', $options, 0);
if ('single' == pods_var_raw('pick_format_type', $options)) {
$related_pick_limit = 1;
}
}
if (!pods_tableless()) {
$field_id = (int) $field_id;
$sister_id = (int) pods_var_raw('sister_id', $field, 0);
$related_where = "\n `field_id` = {$field_id}\n AND `related_item_id` = {$id}\n ";
$sql = "\n SELECT *\n FROM `@wp_podsrel`\n WHERE\n {$related_where}\n ORDER BY `weight`\n ";
$relationships = pods_query($sql);
if (!empty($relationships)) {
$related_ids = array();
foreach ($relationships as $relation) {
if ($field_id == $relation->field_id && !in_array($relation->item_id, $related_ids)) {
$related_ids[] = (int) $relation->item_id;
} elseif (0 < $sister_id && $field_id == $relation->related_field_id && !in_array($relation->related_item_id, $related_ids)) {
$related_ids[] = (int) $relation->related_item_id;
}
}
}
} else {
// @todo handle meta-based lookups
return false;
if (!is_array($pod)) {
$pod = $this->load_pod(array('id' => $pod_id, 'table_info' => false), false);
}
if (!empty($pod) && in_array($pod['type'], array('post_type', 'media', 'user', 'comment', 'settings'))) {
$related_ids = array();
$meta_type = $pod['type'];
if (in_array($pod['type'], array('post_type', 'media'))) {
$meta_type = 'post';
}
$no_conflict = pods_no_conflict_check($meta_type);
if (!$no_conflict) {
pods_no_conflict_on($meta_type);
}
if ('settings' == $meta_type) {
$related_id = get_option('_pods_' . $pod['name'] . '_' . $field['name']);
if (empty($related_id)) {
$related_id = get_option($pod['name'] . '_' . $field['name']);
}
if (is_array($related_id) && !empty($related_id)) {
foreach ($related_id as $related) {
if (is_array($related) && !empty($related)) {
if (isset($related['id'])) {
$related_ids[] = (int) $related['id'];
} else {
foreach ($related as $r) {
$related_ids[] = (int) $r;
}
}
} else {
$related_ids[] = (int) $related;
}
}
}
} else {
$related_id = get_metadata($meta_type, $id, '_pods_' . $field['name'], true);
if (empty($related_id)) {
$related_id = get_metadata($meta_type, $id, $field['name']);
}
if (is_array($related_id) && !empty($related_id)) {
foreach ($related_id as $related) {
if (is_array($related) && !empty($related)) {
if (isset($related['id'])) {
$related_ids[] = (int) $related['id'];
} else {
foreach ($related as $r) {
if (isset($related['id'])) {
$related_ids[] = (int) $r['id'];
} else {
$related_ids[] = (int) $r;
}
//.........这里部分代码省略.........
示例7: __
<?php
if (!pods_tableless() && apply_filters('pods_admin_setup_add_extend_taxonomy_storage', false)) {
?>
<div class="pods-field-option pods-depends-on pods-depends-on-extend-pod-type pods-depends-on-extend-pod-type-taxonomy">
<?php
echo PodsForm::label('extend_storage_taxonomy', __('Enable Extra Fields?', 'pods'), array(__('<h6>Storage Types</h6> Taxonomies do not support extra fields natively, but Pods can add this feature for you easily. Table based storage will operate in a way where each field you create for your content type becomes a field in a table.', 'pods'), 'http://pods.io/docs/comparisons/compare-storage-types/'));
$data = array('none' => __('Do not enable extra fields to be added', 'pods'), 'table' => __('Enable extra fields for this Taxonomy (Table Based)', 'pods'));
echo PodsForm::field('extend_storage_taxonomy', pods_var_raw('extend_storage_taxonomy', 'post', 'none', null, true), 'pick', array('data' => $data));
?>
</div>
<?php
}
?>
<?php
if (!pods_tableless() && apply_filters('pods_admin_setup_add_extend_storage', false)) {
?>
<div class="pods-depends-on pods-depends-on-extend-pod-type pods-depends-on-extend-pod-type-post-type pods-depends-on-extend-pod-type-media pods-depends-on-extend-pod-type-user pods-depends-on-extend-pod-type-comment">
<p><a href="#pods-advanced" class="pods-advanced-toggle"><?php
_e('Advanced', 'pods');
?>
+</a></p>
<div class="pods-advanced">
<div class="pods-field-option">
<?php
echo PodsForm::label('extend_storage', __('Storage Type', 'pods'), array(__('<h6>Storage Types</h6> Table based storage will operate in a way where each field you create for your content type becomes a field in a table. Meta based storage relies upon the WordPress meta storage table for all field data.', 'pods'), 'http://pods.io/docs/comparisons/compare-storage-types/'));
$data = array('meta' => __('Meta Based (WP Default)', 'pods'), 'table' => __('Table Based', 'pods'));
echo PodsForm::field('extend_storage', pods_var_raw('extend_storage', 'post'), 'pick', array('data' => $data));
?>
</div>
示例8: __construct
/**
* Do things like register/enqueue scripts and stylesheets
*
* @since 2.3
*/
public function __construct()
{
if (!pods_tableless()) {
add_filter('pods_admin_setup_add_create_pod_type', array($this, 'add_pod_type'));
}
}
示例9: admin_components
/**
* Get components administration UI
*/
public function admin_components()
{
$components = PodsInit::$components->components;
$view = pods_var('view', 'get', 'all', null, true);
$recommended = array('advanced-relationships', 'advanced-content-types', 'migrate-packages', 'roles-and-capabilities', 'pages', 'table-storage', 'templates');
foreach ($components as $component => &$component_data) {
if (!in_array($view, array('all', 'recommended', 'dev')) && (!isset($component_data['Category']) || $view != sanitize_title($component_data['Category']))) {
unset($components[$component]);
continue;
} elseif ('recommended' == $view && !in_array($component_data['ID'], $recommended)) {
unset($components[$component]);
continue;
} elseif ('dev' == $view && pods_developer() && !pods_var_raw('DeveloperMode', $component_data, false)) {
unset($components[$component]);
continue;
} elseif (pods_var_raw('DeveloperMode', $component_data, false) && !pods_developer()) {
unset($components[$component]);
continue;
} elseif (!pods_var_raw('TablelessMode', $component_data, false) && pods_tableless()) {
unset($components[$component]);
continue;
}
$component_data['Name'] = strip_tags($component_data['Name']);
if (pods_var_raw('DeveloperMode', $component_data, false)) {
$component_data['Name'] .= ' <em style="font-weight: normal; color:#333;">(Developer Preview)</em>';
}
$meta = array();
if (!empty($component_data['Version'])) {
$meta[] = 'Version ' . $component_data['Version'];
}
if (empty($component_data['Author'])) {
$component_data['Author'] = 'Pods Framework Team';
$component_data['AuthorURI'] = 'http://pods.io/';
}
if (!empty($component_data['AuthorURI'])) {
$component_data['Author'] = '<a href="' . $component_data['AuthorURI'] . '">' . $component_data['Author'] . '</a>';
}
$meta[] = sprintf(__('by %s', 'pods'), $component_data['Author']);
if (!empty($component_data['URI'])) {
$meta[] = '<a href="' . $component_data['URI'] . '">' . __('Visit component site', 'pods') . '</a>';
}
$component_data['Description'] = wpautop(trim(make_clickable(strip_tags($component_data['Description'], 'em,strong'))));
if (!empty($meta)) {
$component_data['Description'] .= '<div class="pods-component-meta" ' . (!empty($component_data['Description']) ? ' style="padding:8px 0 4px;"' : '') . '>' . implode(' | ', $meta) . '</div>';
}
$component_data = array('id' => $component_data['ID'], 'name' => $component_data['Name'], 'category' => $component_data['Category'], 'version' => '', 'description' => $component_data['Description'], 'mustuse' => pods_var_raw('MustUse', $component_data, false), 'toggle' => 0);
if (!empty($component_data['category'])) {
$category_url = pods_var_update(array('view' => sanitize_title($component_data['category']), 'pg' => '', 'page' => $_GET['page']));
$component_data['category'] = '<a href="' . $category_url . '">' . $component_data['category'] . '</a>';
}
if (isset(PodsInit::$components->settings['components'][$component_data['id']]) && 0 != PodsInit::$components->settings['components'][$component_data['id']]) {
$component_data['toggle'] = 1;
} elseif ($component_data['mustuse']) {
$component_data['toggle'] = 1;
}
}
$ui = array('data' => $components, 'total' => count($components), 'total_found' => count($components), 'icon' => PODS_URL . 'ui/images/icon32.png', 'items' => 'Components', 'item' => 'Component', 'fields' => array('manage' => array('name' => array('label' => __('Name', 'pods'), 'width' => '30%', 'type' => 'text', 'options' => array('text_allow_html' => true)), 'category' => array('label' => __('Category', 'pods'), 'width' => '10%', 'type' => 'text', 'options' => array('text_allow_html' => true)), 'description' => array('label' => __('Description', 'pods'), 'width' => '60%', 'type' => 'text', 'options' => array('text_allow_html' => true, 'text_allowed_html_tags' => 'strong em a ul ol li b i br div')))), 'actions_disabled' => array('duplicate', 'view', 'export', 'add', 'edit', 'delete'), 'actions_custom' => array('toggle' => array('callback' => array($this, 'admin_components_toggle'))), 'filters_enhanced' => true, 'views' => array('all' => __('All', 'pods'), 'field-types' => __('Field Types', 'pods'), 'tools' => __('Tools', 'pods'), 'integration' => __('Integration', 'pods'), 'migration' => __('Migration', 'pods'), 'advanced' => __('Advanced', 'pods')), 'view' => $view, 'heading' => array('views' => __('Category', 'pods')), 'search' => false, 'searchable' => false, 'sortable' => false, 'pagination' => false);
if (pods_developer()) {
$ui['views']['dev'] = __('Developer Preview', 'pods');
}
pods_ui($ui);
}
示例10: delete_meta
/**
* @param $object_type
* @param null $_null
* @param int $object_id
* @param string $meta_key
* @param string $meta_value
* @param bool $delete_all
*
* @return null
*/
public function delete_meta($object_type, $_null = null, $object_id = 0, $meta_key = '', $meta_value = '', $delete_all = false)
{
if (pods_tableless()) {
return $_null;
}
$object = $this->get_object($object_type, $object_id);
if (empty($object_id) || empty($object) || !isset($object['fields'][$meta_key])) {
return $_null;
}
$pod = pods($object['name']);
// @todo handle $delete_all (delete the field values from all pod items)
if (!empty($meta_value) && in_array($object['fields'][$meta_key]['type'], PodsForm::tableless_field_types())) {
$pod->fetch($object_id);
$pod->remove_from($meta_key, $meta_value);
} else {
$pod->save(array($meta_key => null), null, $object_id);
}
return $_null;
}
示例11: traverse_recurse
//.........这里部分代码省略.........
if ('taxonomy' == $traverse['type']) {
$traverse['table_info'] = $this->api->get_table_info($traverse['type'], $traverse['name']);
} elseif (in_array($traverse['type'], $file_field_types)) {
$traverse['table_info'] = $this->api->get_table_info('post_type', 'attachment');
} elseif (!in_array($traverse['type'], $tableless_field_types)) {
$traverse['table_info'] = $this->api->get_table_info($pod_data['type'], $pod_data['name'], $pod_data['name'], $pod_data);
} elseif (empty($traverse['table_info']) || in_array($traverse['pick_object'], $simple_tableless_objects) && !empty($traverse_recurse['last_table_info'])) {
if (in_array($traverse['pick_object'], $simple_tableless_objects) && !empty($traverse_recurse['last_table_info'])) {
$traverse['table_info'] = $traverse_recurse['last_table_info'];
if (!empty($traverse['table_info']['meta_table'])) {
$meta_data_table = true;
}
} elseif (!in_array($traverse['type'], $tableless_field_types) && isset($traverse_recurse['last_table_info']) && !empty($traverse_recurse['last_table_info']) && 0 == $traverse_recurse['depth']) {
$traverse['table_info'] = $traverse_recurse['last_table_info'];
} else {
$traverse['table_info'] = $this->api->get_table_info($traverse['pick_object'], $traverse['pick_val'], null, $traverse['pod'], $traverse);
}
}
if (isset($this->traversal[$traverse_recurse['pod']][$traverse['name']])) {
$traverse = array_merge($traverse, (array) $this->traversal[$traverse_recurse['pod']][$traverse['name']]);
}
$traverse = $this->do_hook('traverse', $traverse, compact('pod', 'fields', 'joined', 'depth', 'joined_id', 'params'));
if (empty($traverse)) {
return $joins;
}
$traverse = pods_sanitize($traverse);
$traverse['id'] = (int) $traverse['id'];
if (empty($traverse['id'])) {
$traverse['id'] = $field;
}
$table_info = $traverse['table_info'];
$this->traversal[$traverse_recurse['pod']][$field] = $traverse;
$field_joined = $field;
if (0 < $traverse_recurse['depth'] && 't' != $traverse_recurse['joined']) {
if ($meta_data_table && ('pick' != $traverse['type'] || !in_array(pods_var('pick_object', $traverse), $simple_tableless_objects))) {
$field_joined = $traverse_recurse['joined'] . '_d';
} else {
$field_joined = $traverse_recurse['joined'] . '_' . $field;
}
}
$rel_alias = 'rel_' . $field_joined;
if (pods_var('search', $traverse_recurse['params'], false) && empty($traverse_recurse['params']->filters)) {
if (0 < strlen(pods_var('filter_' . $field_joined, 'get'))) {
$val = absint(pods_var('filter_' . $field_joined, 'get'));
$search = "`{$field_joined}`.`{$table_info['field_id']}` = {$val}";
if ('text' == $this->search_mode) {
$val = pods_var('filter_' . $field_joined, 'get');
$search = "`{$field_joined}`.`{$traverse['name']}` = '{$val}'";
} elseif ('text_like' == $this->search_mode) {
$val = pods_sanitize(pods_sanitize_like(pods_var_raw('filter_' . $field_joined)));
$search = "`{$field_joined}`.`{$traverse['name']}` LIKE '%{$val}%'";
}
$this->search_where[] = " {$search} ";
}
}
$the_join = null;
$joined_id = $table_info['field_id'];
$joined_index = $table_info['field_index'];
if ('taxonomy' == $traverse['type']) {
$rel_tt_alias = 'rel_tt_' . $field_joined;
if ($meta_data_table) {
$the_join = "\n LEFT JOIN `{$table_info['pod_table']}` AS `{$field_joined}` ON\n `{$field_joined}`.`{$table_info['pod_field_id']}` = `{$traverse_recurse['rel_alias']}`.`{$traverse_recurse['joined_id']}`\n ";
} else {
$the_join = "\n LEFT JOIN `{$wpdb->term_relationships}` AS `{$rel_alias}` ON\n `{$rel_alias}`.`object_id` = `{$traverse_recurse['joined']}`.`ID`\n\n LEFT JOIN `{$wpdb->term_taxonomy}` AS `{$rel_tt_alias}` ON\n `{$rel_tt_alias}`.`taxonomy` = '{$traverse['name']}'\n AND `{$rel_tt_alias}`.`term_taxonomy_id` = `{$rel_alias}`.`term_taxonomy_id`\n\n LEFT JOIN `{$table_info['table']}` AS `{$field_joined}` ON\n `{$field_joined}`.`{$table_info['field_id']}` = `{$rel_tt_alias}`.`{$table_info['field_id']}`\n ";
// Override $rel_alias
$rel_alias = $field_joined;
$joined_id = $table_info['field_id'];
$joined_index = $table_info['field_index'];
}
} elseif (in_array($traverse['type'], $tableless_field_types) && ('pick' != $traverse['type'] || !in_array(pods_var('pick_object', $traverse), $simple_tableless_objects))) {
if (pods_tableless()) {
$the_join = "\n LEFT JOIN `{$table_info['meta_table']}` AS `{$rel_alias}` ON\n `{$rel_alias}`.`{$table_info['meta_field_index']}` = '{$traverse['name']}'\n AND `{$rel_alias}`.`{$table_info['meta_field_id']}` = `{$traverse_recurse['joined']}`.`{$traverse_recurse['joined_id']}`\n\n LEFT JOIN `{$table_info['meta_table']}` AS `{$field_joined}` ON\n `{$field_joined}`.`{$table_info['meta_field_index']}` = '{$traverse['name']}'\n AND `{$field_joined}`.`{$table_info['meta_field_id']}` = CONVERT( `{$rel_alias}`.`{$table_info['meta_field_value']}`, SIGNED )\n ";
$joined_id = $table_info['meta_field_id'];
$joined_index = $table_info['meta_field_index'];
} elseif ($meta_data_table) {
$the_join = "\n LEFT JOIN `{$table_info['pod_table']}` AS `{$field_joined}` ON\n `{$field_joined}`.`{$table_info['pod_field_id']}` = `{$traverse_recurse['rel_alias']}`.`{$traverse_recurse['joined_id']}`\n ";
} else {
$the_join = "\n LEFT JOIN `@wp_podsrel` AS `{$rel_alias}` ON\n `{$rel_alias}`.`field_id` = {$traverse['id']}\n AND `{$rel_alias}`.`item_id` = `{$traverse_recurse['joined']}`.`{$traverse_recurse['joined_id']}`\n\n LEFT JOIN `{$table_info['table']}` AS `{$field_joined}` ON\n `{$field_joined}`.`{$table_info['field_id']}` = `{$rel_alias}`.`related_item_id`\n ";
}
} elseif ('meta' == $pod_data['storage']) {
if ($traverse_recurse['depth'] + 2 == count($traverse_recurse['fields']) && ('pick' != $traverse['type'] || !in_array(pods_var('pick_object', $traverse), $simple_tableless_objects)) && $table_info['meta_field_value'] == $traverse_recurse['fields'][$traverse_recurse['depth'] + 1]) {
$the_join = "\n LEFT JOIN `{$table_info['meta_table']}` AS `{$field_joined}` ON\n `{$field_joined}`.`{$table_info['meta_field_index']}` = '{$traverse['name']}'\n AND `{$field_joined}`.`{$table_info['meta_field_id']}` = `{$traverse_recurse['joined']}`.`{$traverse_recurse['joined_id']}`\n ";
$table_info['recurse'] = false;
} else {
$the_join = "\n LEFT JOIN `{$table_info['meta_table']}` AS `{$field_joined}` ON\n `{$field_joined}`.`{$table_info['meta_field_index']}` = '{$traverse['name']}'\n AND `{$field_joined}`.`{$table_info['meta_field_id']}` = `{$traverse_recurse['joined']}`.`{$traverse_recurse['joined_id']}`\n ";
$joined_id = $table_info['meta_field_id'];
$joined_index = $table_info['meta_field_index'];
}
}
$traverse_recursive = array('pod' => pods_var_raw('name', pods_var_raw('pod', $table_info)), 'fields' => $traverse_recurse['fields'], 'joined' => $field_joined, 'depth' => $traverse_recurse['depth'] + 1, 'joined_id' => $joined_id, 'joined_index' => $joined_index, 'params' => $traverse_recurse['params'], 'rel_alias' => $rel_alias, 'last_table_info' => $table_info);
$the_join = $this->do_hook('traverse_the_join', $the_join, $traverse_recurse, $traverse_recursive);
if (empty($the_join)) {
return $joins;
}
$joins[$traverse_recurse['pod'] . '_' . $traverse_recurse['depth'] . '_' . $traverse['id']] = $the_join;
if ($traverse_recurse['depth'] + 1 < count($traverse_recurse['fields']) && !empty($traverse_recurse['pod']) && false !== $table_info['recurse']) {
$joins = array_merge($joins, $this->traverse_recurse($traverse_recursive));
}
return $joins;
}
示例12: delete_attachment
/**
* Delete Attachments from relationships
*
* @param int $_ID
*/
public function delete_attachment($_ID)
{
global $wpdb;
$_ID = (int) $_ID;
do_action('pods_delete_attachment', $_ID);
$file_types = "'" . implode("', '", PodsForm::file_field_types()) . "'";
if (!pods_tableless()) {
$sql = "\n DELETE `rel`\n FROM `@wp_podsrel` AS `rel`\n LEFT JOIN `{$wpdb->posts}` AS `p`\n ON\n `p`.`post_type` = '_pods_field'\n AND ( `p`.`ID` = `rel`.`field_id` OR `p`.`ID` = `rel`.`related_field_id` )\n LEFT JOIN `{$wpdb->postmeta}` AS `pm`\n ON\n `pm`.`post_id` = `p`.`ID`\n AND `pm`.`meta_key` = 'type'\n AND `pm`.`meta_value` IN ( {$file_types} )\n WHERE\n `p`.`ID` IS NOT NULL\n AND `pm`.`meta_id` IS NOT NULL\n AND `rel`.`item_id` = {$_ID}";
pods_query($sql, false);
}
// Post Meta
if (!empty(PodsMeta::$post_types)) {
$sql = "\n DELETE `rel`\n FROM `@wp_postmeta` AS `rel`\n LEFT JOIN `{$wpdb->posts}` AS `p`\n ON\n `p`.`post_type` = '_pods_field'\n LEFT JOIN `{$wpdb->postmeta}` AS `pm`\n ON\n `pm`.`post_id` = `p`.`ID`\n AND `pm`.`meta_key` = 'type'\n AND `pm`.`meta_value` IN ( {$file_types} )\n WHERE\n `p`.`ID` IS NOT NULL\n AND `pm`.`meta_id` IS NOT NULL\n AND `rel`.`meta_key` = `p`.`post_name`\n AND `rel`.`meta_value` = '{$_ID}'";
pods_query($sql, false);
}
// User Meta
if (!empty(PodsMeta::$user)) {
$sql = "\n DELETE `rel`\n FROM `@wp_usermeta` AS `rel`\n LEFT JOIN `{$wpdb->posts}` AS `p`\n ON\n `p`.`post_type` = '_pods_field'\n LEFT JOIN `{$wpdb->postmeta}` AS `pm`\n ON\n `pm`.`post_id` = `p`.`ID`\n AND `pm`.`meta_key` = 'type'\n AND `pm`.`meta_value` IN ( {$file_types} )\n WHERE\n `p`.`ID` IS NOT NULL\n AND `pm`.`meta_id` IS NOT NULL\n AND `rel`.`meta_key` = `p`.`post_name`\n AND `rel`.`meta_value` = '{$_ID}'";
pods_query($sql, false);
}
// Comment Meta
if (!empty(PodsMeta::$comment)) {
$sql = "\n DELETE `rel`\n FROM `@wp_commentmeta` AS `rel`\n LEFT JOIN `{$wpdb->posts}` AS `p`\n ON\n `p`.`post_type` = '_pods_field'\n LEFT JOIN `{$wpdb->postmeta}` AS `pm`\n ON\n `pm`.`post_id` = `p`.`ID`\n AND `pm`.`meta_key` = 'type'\n AND `pm`.`meta_value` IN ( {$file_types} )\n WHERE\n `p`.`ID` IS NOT NULL\n AND `pm`.`meta_id` IS NOT NULL\n AND `rel`.`meta_key` = `p`.`post_name`\n AND `rel`.`meta_value` = '{$_ID}'";
pods_query($sql, false);
}
}
示例13: menu
/**
* Add menu item
*
* @param string $parent The parent slug.
*
* @since 2.0
*
* @uses add_submenu_page
*/
public function menu($parent)
{
global $submenu;
$custom_component_menus = array();
$pods_component_menu_items = array();
foreach ($this->components as $component => $component_data) {
$component_data['MustUse'] = apply_filters('pods_component_require_' . $component_data['ID'], $component_data['MustUse'], $component_data);
if (empty($component_data['MustUse']) && (!isset($this->settings['components'][$component]) || 0 == $this->settings['components'][$component])) {
continue;
}
if (!empty($component_data['Hide'])) {
continue;
}
if (!empty($component_data['DeveloperMode']) && !pods_developer()) {
continue;
}
if (empty($component_data['TablelessMode']) && pods_tableless()) {
continue;
}
if (empty($component_data['MenuPage'])) {
if (!isset($component_data['object'])) {
continue;
} elseif (!method_exists($component_data['object'], 'admin') && !method_exists($component_data['object'], 'options')) {
continue;
}
}
if (false === $component_data['External']) {
$component_data['File'] = realpath($this->components_dir . $component_data['File']);
}
if (!file_exists($component_data['File'])) {
pods_message('Pods Component not found: ' . $component_data['File']);
pods_transient_clear('pods_components');
continue;
}
$capability = 'pods_component_' . str_replace('-', '_', sanitize_title($component));
if (0 < strlen($component_data['Capability'])) {
$capability = $component_data['Capability'];
}
if (!pods_is_admin(array('pods', 'pods_components', $capability))) {
continue;
}
$menu_page = 'pods-component-' . $component;
if (!empty($component_data['MenuPage'])) {
$custom_component_menus[$menu_page] = $component_data;
}
$pods_component_menu_items[$component_data['MenuName']] = array('menu_page' => $menu_page, 'page_title' => $component_data['Name'], 'capability' => 'read', 'callback' => array($this, 'admin_handler'));
if (isset($component_data['object']) && method_exists($component_data['object'], 'admin_assets')) {
$pods_component_menu_items[$component_data['MenuName']]['assets'] = array($component_data['object'], 'admin_assets');
}
}
/**
* Add or change the items in the Pods Components Submenu.
*
* Can also be used to change which menu components is a submenu of or change title of menu.
*
* @params array $pods_component_menu_items {
* An array of arguments for add_submenu_page
*
* @param string $parent_slug The slug name for the parent menu (or the file name of a standard WordPress admin page)
* @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
* @param $menu_title The text to be used for the menu
* @param $capability The capability required for this menu to be displayed to the user.
* @param $menu_slug The slug name to refer to this menu by (should be unique for this menu)
* @param $function The function to be called to output the content for this page.
* }
*
* @returns array Array of submenu pages to be passed to add_submenu_page()
*
* @since 2.4.1
*/
$pods_component_menu_items = apply_filters('pods_admin_components_menu', $pods_component_menu_items);
ksort($pods_component_menu_items);
foreach ($pods_component_menu_items as $menu_title => $menu_data) {
if (!is_callable($menu_data['callback'])) {
continue;
}
$page = add_submenu_page($parent, strip_tags($menu_data['page_title']), '- ' . strip_tags($menu_title), pods_v('capability', $menu_data, 'read', true), $menu_data['menu_page'], $menu_data['callback']);
if (isset($menu_data['assets']) && is_callable($menu_data['assets'])) {
add_action('admin_print_styles-' . $page, $menu_data['assets']);
}
}
if (!empty($custom_component_menus)) {
foreach ($custom_component_menus as $menu_page => $component_data) {
if (isset($submenu[$parent])) {
foreach ($submenu[$parent] as $sub => &$menu) {
if ($menu[2] == $menu_page) {
$menu_page = $component_data['MenuPage'];
/*if ( !empty( $component_data[ 'MenuAddPage' ] ) ) {
if ( false !== strpos( $_SERVER[ 'REQUEST_URI' ], $component_data[ 'MenuAddPage' ] ) )
$menu_page = $component_data[ 'MenuAddPage' ];
}*/
//.........这里部分代码省略.........