本文整理汇总了PHP中pods_sanitize函数的典型用法代码示例。如果您正苦于以下问题:PHP pods_sanitize函数的具体用法?PHP pods_sanitize怎么用?PHP pods_sanitize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pods_sanitize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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';
}
示例2: ob_start
<?php
ob_start();
require_once preg_replace("/wp-content.*/", "wp-load.php", __FILE__);
ob_end_clean();
if (false === headers_sent()) {
if ('' == session_id()) {
@session_start();
}
header('Content-Type: text/html; charset=' . get_bloginfo('charset'));
}
// Sanitize input
$params = stripslashes_deep($_POST);
if (!defined('PODS_STRICT_MODE') || !PODS_STRICT_MODE) {
foreach ($params as $key => $val) {
$params[$key] = pods_sanitize(trim($val));
}
}
$methods = array('save_pod' => array('priv' => 'manage_pods', 'format' => 'json'), 'save_column' => array('priv' => 'manage_pods'), 'save_template' => array('priv' => 'manage_templates'), 'save_page' => array('priv' => 'manage_pod_pages'), 'save_helper' => array('priv' => 'manage_helpers'), 'save_roles' => array('priv' => 'manage_roles'), 'save_pod_item' => array('processor' => 'process_save_pod_item'), 'reorder_pod_item' => array('access_pod_specific' => true), 'drop_pod' => array('priv' => 'manage_pods'), 'drop_column' => array('priv' => 'manage_pods'), 'drop_template' => array('priv' => 'manage_templates'), 'drop_page' => array('priv' => 'manage_pod_pages'), 'drop_helper' => array('priv' => 'manage_helpers'), 'drop_pod_item' => array('access_pod_specific' => true), 'load_pod' => array('priv' => 'manage_pods', 'format' => 'json'), 'load_column' => array('priv' => 'manage_pods', 'format' => 'json'), 'load_template' => array('priv' => 'manage_templates', 'format' => 'json'), 'load_page' => array('priv' => 'manage_pod_pages', 'format' => 'json'), 'load_helper' => array('priv' => 'manage_helpers', 'format' => 'json'), 'load_sister_fields' => array('priv' => 'manage_pods', 'format' => 'json'), 'load_pod_item' => array(), 'load_files' => array(), 'export_package' => array('priv' => 'manage_packages', 'format' => 'json', 'safe' => true), 'import_package' => array('priv' => 'manage_packages'), 'validate_package' => array('priv' => 'manage_packages'), 'replace_package' => array('priv' => 'manage_packages'), 'security_settings' => array('priv' => 'manage_settings'), 'pod_page_settings' => array('priv' => 'manage_settings'), 'fix_wp_pod' => array('priv' => 'manage_settings'));
$api = new PodAPI();
$params = (object) $params;
$action = $params->action;
if (isset($methods[$action])) {
$priv = isset($methods[$action]['priv']) ? $methods[$action]['priv'] : null;
$format = isset($methods[$action]['format']) ? $methods[$action]['format'] : null;
$processor = isset($methods[$action]['processor']) ? (string) $methods[$action]['processor'] : null;
$safe = isset($methods[$action]['safe']) ? $methods[$action]['safe'] : null;
$access_pod_specific = isset($methods[$action]['access_pod_specific']) ? $methods[$action]['access_pod_specific'] : null;
if ('save_pod_item' == $action) {
if (isset($params->_wpnonce) && false === wp_verify_nonce($params->_wpnonce, 'pods-' . $action)) {
die('<e>Access denied');
示例3: traverse_recurse
//.........这里部分代码省略.........
return $joins;
}
} else {
return $joins;
}
}
}
$traverse = $pod_data['fields'][$field];
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'];
示例4: pods_evaluate_tag
/**
* Evaluate tag like magic tag but mapped through pods_v
*
* @param string|array $tag
* @param bool $sanitize Whether to sanitize tags
*
* @return string
*
* @version 2.1
*/
function pods_evaluate_tag($tag, $sanitize = false)
{
global $wpdb;
// Handle pods_evaluate_tags
if (is_array($tag)) {
if (!isset($tag[2]) && strlen(trim($tag[2])) < 1) {
return '';
}
$tag = $tag[2];
}
$tag = trim($tag, ' {@}');
$tag = explode('.', $tag);
if (empty($tag) || !isset($tag[0]) || strlen(trim($tag[0])) < 1) {
return '';
}
// Fix formatting that may be after the first .
if (2 < count($tag)) {
$first_tag = $tag[0];
unset($tag[0]);
$tag = array($first_tag, implode('.', $tag));
}
foreach ($tag as $k => $v) {
$tag[$k] = trim($v);
}
$value = '';
$single_supported = array('template-url', 'stylesheet-url', 'site-url', 'home-url', 'admin-url', 'includes-url', 'content-url', 'plugins-url', 'network-site-url', 'network-home-url', 'network-admin-url', 'user-admin-url', 'prefix');
if (in_array($tag[0], $single_supported)) {
$value = pods_v('', $tag[0], '', true);
} elseif (1 == count($tag)) {
$value = pods_v($tag[0], 'get', '', true);
} elseif (2 == count($tag)) {
$value = pods_v($tag[1], $tag[0], '', true);
}
$value = apply_filters('pods_evaluate_tag', $value, $tag);
if (is_array($value) && 1 == count($value)) {
$value = current($value);
}
if (is_array($value)) {
$value = pods_serial_comma($value);
}
if ($sanitize) {
$value = pods_sanitize($value);
}
return $value;
}
示例5: import
/**
* Import data from an array or a CSV file.
*
* @param mixed $import_data PHP associative array or CSV input
* @param bool $numeric_mode Use IDs instead of the name field when matching
* @param string $format Format of import data, options are php or csv
*
* @return array IDs of imported items
*
* @since 1.7.1
* @todo This needs some love and use of table_info etc for relationships
*/
public function import($import_data, $numeric_mode = false, $format = null)
{
/**
* @var $wpdb wpdb
*/
global $wpdb;
if (null === $format && null !== $this->format) {
$format = $this->format;
}
if ('csv' == $format && !is_array($import_data)) {
$data = pods_migrate('sv', ',')->parse($import_data);
$import_data = $data['items'];
}
pods_query("SET NAMES utf8");
pods_query("SET CHARACTER SET utf8");
// Loop through the array of items
$ids = array();
// Test to see if it's an array of arrays
if (!is_array(@current($import_data))) {
$import_data = array($import_data);
}
$pod = $this->load_pod(array('name' => $this->pod));
if (false === $pod) {
return pods_error(__('Pod not found', 'pods'), $this);
}
$fields = array_merge($pod['fields'], $pod['object_fields']);
$simple_tableless_objects = PodsForm::simple_tableless_objects();
foreach ($import_data as $key => $data_row) {
$data = array();
// Loop through each field (use $fields so only valid fields get parsed)
foreach ($fields as $field_name => $field_data) {
if (!isset($data_row[$field_name]) && !isset($data_row[$field_data['label']])) {
continue;
}
$field_id = $field_data['id'];
$type = $field_data['type'];
$pick_object = isset($field_data['pick_object']) ? $field_data['pick_object'] : '';
$pick_val = isset($field_data['pick_val']) ? $field_data['pick_val'] : '';
if (isset($data_row[$field_name])) {
$field_value = $data_row[$field_name];
} else {
$field_value = $data_row[$field_data['label']];
}
if (null !== $field_value && false !== $field_value && '' !== $field_value) {
if ('pick' == $type || in_array($type, PodsForm::file_field_types())) {
$field_values = is_array($field_value) ? $field_value : array($field_value);
$pick_values = array();
foreach ($field_values as $pick_value) {
if (in_array($type, PodsForm::file_field_types()) || 'media' == $pick_object) {
$where = "`guid` = '" . pods_sanitize($pick_value) . "'";
if (0 < pods_absint($pick_value) && false !== $numeric_mode) {
$where = "`ID` = " . pods_absint($pick_value);
}
$result = pods_query("SELECT `ID` AS `id` FROM `{$wpdb->posts}` WHERE `post_type` = 'attachment' AND {$where} ORDER BY `ID`", $this);
if (!empty($result)) {
$pick_values[] = $result[0]->id;
}
} elseif ('pick' == $type) {
$related_pod = false;
if ('pod' == $pick_object) {
$related_pod = $this->load_pod(array('name' => $pick_val, 'table_info' => true), false);
}
if (empty($related_pod)) {
$related_pod = array('id' => 0, 'type' => $pick_object);
}
if (in_array('taxonomy', array($pick_object, $related_pod['type']))) {
$where = "`t`.`name` = '" . pods_sanitize($pick_value) . "'";
if (0 < pods_absint($pick_value) && false !== $numeric_mode) {
$where = "`tt`.`term_id` = " . pods_absint($pick_value);
}
$result = pods_query("SELECT `t`.`term_id` AS `id` FROM `{$wpdb->term_taxonomy}` AS `tt` LEFT JOIN `{$wpdb->terms}` AS `t` ON `t`.`term_id` = `tt`.`term_id` WHERE `taxonomy` = '{$pick_val}' AND {$where} ORDER BY `t`.`term_id`", $this);
if (!empty($result)) {
$pick_values[] = $result[0]->id;
}
} elseif (in_array('post_type', array($pick_object, $related_pod['type'])) || in_array('media', array($pick_object, $related_pod['type']))) {
$where = "`post_title` = '" . pods_sanitize($pick_value) . "'";
if (0 < pods_absint($pick_value) && false !== $numeric_mode) {
$where = "`ID` = " . pods_absint($pick_value);
}
$result = pods_query("SELECT `ID` AS `id` FROM `{$wpdb->posts}` WHERE `post_type` = '{$pick_val}' AND {$where} ORDER BY `ID`", $this);
if (!empty($result)) {
$pick_values[] = $result[0]->id;
}
} elseif (in_array('user', array($pick_object, $related_pod['type']))) {
$where = "`user_login` = '" . pods_sanitize($pick_value) . "'";
if (0 < pods_absint($pick_value) && false !== $numeric_mode) {
$where = "`ID` = " . pods_absint($pick_value);
}
//.........这里部分代码省略.........
示例6: add_option
add_option('pods_files_require_login_cap', 'upload_files');
add_option('pods_disable_file_upload', 0);
add_option('pods_upload_require_login', 0);
add_option('pods_upload_require_login_cap', 'upload_files');
update_option('pods_version', '196');
}
if (version_compare($old_version, '1.9.7', '<')) {
pods_query("ALTER TABLE `@wp_pod` CHANGE `id` `id` BIGINT(15) UNSIGNED NOT NULL AUTO_INCREMENT");
pods_query("ALTER TABLE `@wp_pod` CHANGE `tbl_row_id` `tbl_row_id` BIGINT(15) UNSIGNED NULL DEFAULT NULL");
pods_query("ALTER TABLE `@wp_pod` CHANGE `author_id` `author_id` BIGINT(15) UNSIGNED NULL DEFAULT NULL");
pods_query("ALTER TABLE `@wp_pod_rel` CHANGE `id` `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT");
pods_query("ALTER TABLE `@wp_pod_rel` CHANGE `pod_id` `pod_id` BIGINT(15) UNSIGNED NULL DEFAULT NULL");
pods_query("ALTER TABLE `@wp_pod_rel` CHANGE `sister_pod_id` `sister_pod_id` BIGINT(15) UNSIGNED NULL DEFAULT NULL");
pods_query("ALTER TABLE `@wp_pod_rel` CHANGE `tbl_row_id` `tbl_row_id` BIGINT(15) UNSIGNED NULL DEFAULT NULL");
pods_query("ALTER TABLE `@wp_pod_rel` CHANGE `weight` `weight` INT(10) UNSIGNED NULL DEFAULT '0'");
update_option('pods_version', '197');
}
if (version_compare($old_version, '1.11', '<')) {
pods_query("ALTER TABLE `@wp_pod` CHANGE `datatype` `datatype` INT(10) UNSIGNED NULL DEFAULT NULL");
pods_query("ALTER TABLE `@wp_pod` DROP INDEX `datatype_idx`", false);
pods_query("ALTER TABLE `@wp_pod` ADD INDEX `datatype_row_idx` (`datatype`, `tbl_row_id`)", false);
pods_query("ALTER TABLE `@wp_pod_rel` DROP INDEX `field_id_idx`", false);
pods_query("ALTER TABLE `@wp_pod_rel` ADD INDEX `field_pod_idx` (`field_id`, `pod_id`)", false);
pods_query("ALTER TABLE `@wp_pod_fields` CHANGE `datatype` `datatype` INT(10) UNSIGNED NULL DEFAULT NULL");
$result = pods_query("SELECT id, name FROM @wp_pod_types");
foreach ($result as $row) {
$pod = pods_sanitize($row->name);
pods_query("ALTER TABLE `@wp_pod_tbl_{$pod}` CHANGE `id` `id` BIGINT(15) UNSIGNED NOT NULL AUTO_INCREMENT");
}
update_option('pods_version', '001011000');
}
示例7: add_option
add_option('pods_upload_require_login', 0);
add_option('pods_upload_require_login_cap', 'upload_files');
update_option('pods_version', '196');
}
if (version_compare($installed, '1.9.7', '<')) {
pod_query("ALTER TABLE `@wp_pod` CHANGE `id` `id` BIGINT(15) UNSIGNED NOT NULL AUTO_INCREMENT");
pod_query("ALTER TABLE `@wp_pod` CHANGE `tbl_row_id` `tbl_row_id` BIGINT(15) UNSIGNED NULL DEFAULT NULL");
pod_query("ALTER TABLE `@wp_pod` CHANGE `author_id` `author_id` BIGINT(15) UNSIGNED NULL DEFAULT NULL");
pod_query("ALTER TABLE `@wp_pod_rel` CHANGE `id` `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT");
pod_query("ALTER TABLE `@wp_pod_rel` CHANGE `pod_id` `pod_id` BIGINT(15) UNSIGNED NULL DEFAULT NULL");
pod_query("ALTER TABLE `@wp_pod_rel` CHANGE `sister_pod_id` `sister_pod_id` BIGINT(15) UNSIGNED NULL DEFAULT NULL");
pod_query("ALTER TABLE `@wp_pod_rel` CHANGE `tbl_row_id` `tbl_row_id` BIGINT(15) UNSIGNED NULL DEFAULT NULL");
pod_query("ALTER TABLE `@wp_pod_rel` CHANGE `weight` `weight` INT(10) UNSIGNED NULL DEFAULT '0'");
update_option('pods_version', '197');
}
if (version_compare($installed, '1.11', '<')) {
pod_query("ALTER TABLE `@wp_pod` CHANGE `datatype` `datatype` INT(10) UNSIGNED NULL DEFAULT NULL");
pod_query("ALTER TABLE `@wp_pod` DROP INDEX `datatype_idx`", false);
pod_query("ALTER TABLE `@wp_pod` ADD INDEX `datatype_row_idx` (`datatype`, `tbl_row_id`)", false);
pod_query("ALTER TABLE `@wp_pod_rel` DROP INDEX `field_id_idx`", false);
pod_query("ALTER TABLE `@wp_pod_rel` ADD INDEX `field_pod_idx` (`field_id`, `pod_id`)", false);
pod_query("ALTER TABLE `@wp_pod_fields` CHANGE `datatype` `datatype` INT(10) UNSIGNED NULL DEFAULT NULL");
$result = pod_query("SELECT id, name FROM @wp_pod_types");
while ($row = mysql_fetch_assoc($result)) {
$pod = pods_sanitize($row['name']);
pod_query("ALTER TABLE `@wp_pod_tbl_{$pod}` CHANGE `id` `id` BIGINT(15) UNSIGNED NOT NULL AUTO_INCREMENT");
}
update_option('pods_version', '001011000');
}
// Save this version
update_option('pods_version', PODS_VERSION);
示例8: table
//.........这里部分代码省略.........
if (false === $attributes['display']) {
continue;
}
if (!isset($row[$field])) {
$row[$field] = $this->get_field($field);
}
$row_value = $row[$field];
if (!empty($attributes['custom_display'])) {
if (is_callable($attributes['custom_display'])) {
$row_value = call_user_func_array($attributes['custom_display'], array($row, &$this, $row_value, $field, $attributes));
} elseif (is_object($this->pod) && class_exists('Pods_Helpers')) {
$row_value = $this->pod->helper($attributes['custom_display'], $row_value, $field);
}
} else {
ob_start();
$field_value = PodsForm::field_method($attributes['type'], 'ui', $this->id, $row_value, $field, array_merge($attributes, pods_var_raw('options', $attributes, array(), null, true)), $fields, $this->pod);
$field_output = trim((string) ob_get_clean());
if (false === $field_value) {
$row_value = '';
} elseif (0 < strlen(trim((string) $field_value))) {
$row_value = trim((string) $field_value);
} elseif (0 < strlen($field_output)) {
$row_value = $field_output;
}
}
if (false !== $attributes['custom_relate']) {
global $wpdb;
$table = $attributes['custom_relate'];
$on = $this->sql['field_id'];
$is = $row[$this->sql['field_id']];
$what = array('name');
if (is_array($table)) {
if (isset($table['on'])) {
$on = pods_sanitize($table['on']);
}
if (isset($table['is']) && isset($row[$table['is']])) {
$is = pods_sanitize($row[$table['is']]);
}
if (isset($table['what'])) {
$what = array();
if (is_array($table['what'])) {
foreach ($table['what'] as $wha) {
$what[] = pods_sanitize($wha);
}
} else {
$what[] = pods_sanitize($table['what']);
}
}
if (isset($table['table'])) {
$table = $table['table'];
}
}
$table = pods_sanitize($table);
$wha = implode(',', $what);
$sql = "SELECT {$wha} FROM {$table} WHERE `{$on}`='{$is}'";
$value = @current($wpdb->get_results($sql, ARRAY_A));
if (!empty($value)) {
$val = array();
foreach ($what as $wha) {
if (isset($value[$wha])) {
$val[] = $value[$wha];
}
}
if (!empty($val)) {
$row_value = implode(' ', $val);
}
示例9: save_meta
/**
* Save the fields
*
* @param $_null
* @param int $post_ID
* @param string $meta_key
* @param null $meta_value
*
* @return bool|int|null
*/
public function save_meta($_null, $post_ID = null, $meta_key = null, $meta_value = null)
{
if ('code' == $meta_key) {
$post = get_post($post_ID);
if (is_object($post) && $this->object_type == $post->post_type) {
$postdata = array('ID' => $post_ID, 'post_content' => pods_sanitize($meta_value));
remove_filter(current_filter(), array($this, __FUNCTION__), 10);
$revisions = false;
if (has_action('pre_post_update', 'wp_save_post_revision')) {
remove_action('pre_post_update', 'wp_save_post_revision');
$revisions = true;
}
wp_update_post($postdata);
if ($revisions) {
add_action('pre_post_update', 'wp_save_post_revision');
}
return true;
}
}
return $_null;
}
示例10: pods_unique_slug
/**
* Build a unique slug
*
* @todo Simplify this function - get rid of the pod_id crap
* @param string $value The slug value
* @param string $column_name The column name
* @param string $datatype The datatype name
* @param int $datatype_id The datatype ID
* @param int $pod_id The item's ID in the wp_pod table
* @return string The unique slug name
* @since 1.7.2
*/
function pods_unique_slug($value, $column_name, $datatype, $datatype_id = 0, $pod_id = 0)
{
$value = sanitize_title($value);
$slug = pods_sanitize($value);
$tbl_row_id = 0;
if (is_object($datatype)) {
if (isset($datatype->tbl_row_id)) {
$tbl_row_id = $datatype->tbl_row_id;
}
if (isset($datatype->pod_id)) {
$pod_id = $datatype->pod_id;
}
if (isset($datatype->datatype_id)) {
$datatype_id = $datatype->datatype_id;
}
if (isset($datatype->datatype)) {
$datatype = $datatype->datatype;
} else {
$datatype = '';
}
}
$datatype_id = absint($datatype_id);
$tbl_row_id = absint($tbl_row_id);
$pod_id = absint($pod_id);
$sql = "\r\n SELECT DISTINCT\r\n t.`{$column_name}` AS slug\r\n FROM\r\n `@wp_pod_tbl_{$datatype}` t\r\n WHERE\r\n t.`{$column_name}` = '{$value}'\r\n ";
if (0 < $tbl_row_id) {
$sql = "\r\n SELECT DISTINCT\r\n t.`{$column_name}` AS slug\r\n FROM\r\n `@wp_pod_tbl_{$datatype}` t\r\n WHERE\r\n t.`{$column_name}` = '{$value}' AND t.id != {$tbl_row_id}\r\n ";
} elseif (0 < $pod_id) {
$sql = "\r\n SELECT DISTINCT\r\n t.`{$column_name}` AS slug\r\n FROM\r\n @wp_pod p\r\n INNER JOIN\r\n `@wp_pod_tbl_{$datatype}` t ON t.id = p.tbl_row_id\r\n WHERE\r\n t.`{$column_name}` = '{$slug}' AND p.datatype = {$datatype_id} AND p.id != {$pod_id}\r\n ";
}
$result = pod_query($sql);
if (0 < mysql_num_rows($result)) {
$unique_num = 0;
$unique_found = false;
while (!$unique_found) {
$unique_num++;
$test_slug = pods_sanitize($value . '-' . $unique_num);
$result = pod_query(str_replace("t.`{$column_name}` = '{$slug}'", "t.`{$column_name}` = '{$test_slug}'", $sql));
if (0 < mysql_num_rows($result)) {
continue;
}
$value = $test_slug;
$unique_found = true;
}
}
$value = apply_filters('pods_unique_slug', $value, $column_name, $datatype, $datatype_id, $pod_id);
return $value;
}
示例11: get_current_language
//.........这里部分代码省略.........
// Overwrite the current language if this is a translateable post_type
$current_language = pll_get_post_language((int) $_GET['post']);
}
}
/**
* Polylang support (1.0.1+)
* In polylang the preferred language could be anything.
* When we're adding a new object and language is set we only want the related objects if they are not translatable OR the same language
*/
if ($translator == 'PLL' && !empty($_GET['new_lang']) && !empty($_GET['post_type']) && pll_is_translated_post_type(sanitize_text_field($_GET['post_type']))) {
$current_language = $_GET['new_lang'];
}
/**
* Overwrite the current language if needed for taxonomies
*/
} elseif (isset($current_screen->base) && ($current_screen->base == 'term' || $current_screen->base == 'edit-tags')) {
// @todo MAYBE: Similar function like get_post_type for taxonomies so we don't need to check for $_GET['taxonomy']
if (!empty($_GET['taxonomy'])) {
/*
* @todo wpml-comp API call for taxonomy needed!
* Suggested API call:
* add_filter( 'wpml_is_translated_taxonomy', $_GET['taxonomy'], 10, 2 );
*/
/**
* WPML support
* In WPML the current language is always set to default on an edit screen
* We need to overwrite this when the current object is not-translatable to enable relationships with different languages
*/
if ($translator == 'WPML' && method_exists($sitepress, 'is_translated_taxonomy') && !$sitepress->is_translated_taxonomy($_GET['taxonomy'])) {
// Overwrite the current language to nothing if this is a NOT-translatable taxonomy
$current_language = '';
}
/**
* Polylang support (1.5.4+)
* In polylang the preferred language could be anything.
* We only want the related objects if they are not translatable OR the same language as the current object
*/
if ($translator == 'PLL' && !empty($_GET['tag_ID']) && function_exists('pll_get_term_language') && pll_is_translated_taxonomy(sanitize_text_field($_GET['taxonomy']))) {
// Overwrite the current language if this is a translatable taxonomy
$current_language = pll_get_term_language((int) $_GET['tag_ID']);
}
}
/**
* Polylang support (1.0.1+)
* In polylang the preferred language could be anything.
* When we're adding a new object and language is set we only want the related objects if they are not translatable OR the same language
*/
if ($translator == 'PLL' && !empty($_GET['new_lang']) && !empty($_GET['taxonomy']) && pll_is_translated_taxonomy(sanitize_text_field($_GET['taxonomy']))) {
$current_language = $_GET['new_lang'];
}
}
}
}
$current_language = pods_sanitize(sanitize_text_field($current_language));
if (!empty($current_language)) {
// We need to return language data
$lang_data = array('language' => $current_language, 't_id' => 0, 'tt_id' => 0, 'term' => null);
/**
* Polylang support
* Get the language taxonomy object for the current language
*/
if ($translator == 'PLL') {
$current_language_t = false;
// Get the language term object
if (function_exists('PLL') && isset(PLL()->model) && method_exists(PLL()->model, 'get_language')) {
// Polylang 1.8 and newer
$current_language_t = PLL()->model->get_language($current_language);
} elseif (is_object($polylang) && isset($polylang->model) && method_exists($polylang->model, 'get_language')) {
// Polylang 1.2 - 1.7.x
$current_language_t = $polylang->model->get_language($current_language);
} elseif (is_object($polylang) && method_exists($polylang, 'get_language')) {
// Polylang 1.1.x and older
$current_language_t = $polylang->get_language($current_language);
}
// If the language object exists, add it!
if ($current_language_t && !empty($current_language_t->term_id)) {
$lang_data['t_id'] = (int) $current_language_t->term_id;
$lang_data['tt_id'] = (int) $current_language_t->term_taxonomy_id;
$lang_data['term'] = $current_language_t;
}
}
}
/**
* Override language data used by Pods.
*
* @since 2.6.6
*
* @param array|false $lang_data {
* Language data
*
* @type string $language Language slug
* @type int $t_id Language term_id
* @type int $tt_id Language term_taxonomy_id
* @type WP_Term $term Language term object
* }
* @param string|boolean $translator Language plugin used
*/
$lang_data = apply_filters('pods_get_current_language', $lang_data, $translator);
return $lang_data;
}
示例12: file_get_contents
$geoinfo = file_get_contents($geourl);
// get the geocoded info back in json format into the variable you could use curl for better performance but this is more compatible
$decoded = json_decode($geoinfo);
// decode json geoinfo into an object
// make sure value is returned and allow manual change
if ($decoded->status == "OK") {
$event_data['latitude'] = $decoded->results[0]->geometry->location->lat;
// copy lat into the field called lat in your pod
$event_data['longitude'] = $decoded->results[0]->geometry->location->lng;
// copy long into the field called long in your pod
}
}
// all clear to save the data to the database
$api = new PodAPI();
// safety cleansing
pods_sanitize($event_data);
if ($eid == 'new') {
// since we are saving a new event, these fields need initializing this one time only
$event_data['vendor'] = get_active_user_id();
$event_data['approved'] = '1';
$event_data['event_type'] = '1';
$a['approved'] = '1';
$params = array('datatype' => 'events', 'columns' => $event_data);
// create the item
$api->save_pod_item($params);
$success = true;
} else {
// SCREW PODSCMS... just do a plain ole SQL update
$sql = "UPDATE wp_pod_tbl_events SET ";
$sql_fields = array();
foreach ($event_data as $key => $val) {
示例13: file_get_contents
$geoinfo = file_get_contents($geourl);
// get the geocoded info back in json format into the variable you could use curl for better performance but this is more compatible
$decoded = json_decode($geoinfo);
// decode json geoinfo into an object
// make sure value is returned and allow manual change
if ($decoded->status == "OK") {
$profile_data['latitude'] = $decoded->results[0]->geometry->location->lat;
// copy lat into the field called lat in your pod
$profile_data['longitude'] = $decoded->results[0]->geometry->location->lng;
// copy long into the field called long in your pod
}
}
// all clear to save the data to the database
$api = new PodAPI();
// safety cleansing
pods_sanitize($profile_data);
if ($pid == 'new') {
// since we are saving a new profile, these fields need initializing this one time only
$profile_data['vendor'] = get_active_user_id();
$profile_data['active'] = '0';
$profile_data['profile_type'] = 'Free';
$profile_data['expiration_date'] = '0000-00-00 00:00:00';
$profile_data['payment_plan'] = 'NA';
$profile_data['payment_amount'] = '0';
$params = array('datatype' => 'vendor_profiles', 'columns' => $profile_data);
// create the item
$api->save_pod_item($params);
$success = true;
} else {
// SCREW PODSCMS... just do a plain ole SQL update
$sql = "UPDATE wp_pod_tbl_vendor_profiles SET ";
示例14: get_object_data
/**
* Get data from relationship objects
*
* @param array $object_params Object data parameters
*
* @return array|bool Object data
*/
public function get_object_data($object_params = null)
{
global $wpdb, $polylang, $sitepress, $icl_adjust_id_url_filter_off;
$current_language = false;
// WPML support
if (is_object($sitepress) && !$icl_adjust_id_url_filter_off) {
$current_language = pods_sanitize(ICL_LANGUAGE_CODE);
} elseif (function_exists('pll_current_language')) {
$current_language = pll_current_language('slug');
}
$object_params = array_merge(array('name' => '', 'value' => '', 'options' => array(), 'pod' => '', 'id' => '', 'context' => '', 'data_params' => array('query' => ''), 'page' => 1, 'limit' => 0), $object_params);
$name = $object_params['name'];
$value = $object_params['value'];
$options = $object_params['options'] = (array) $object_params['options'];
$pod = $object_params['pod'];
$id = $object_params['id'];
$context = $object_params['context'];
$data_params = $object_params['data_params'] = (array) $object_params['data_params'];
$page = min(1, (int) $object_params['page']);
$limit = (int) $object_params['limit'];
if (isset($options['options'])) {
$options = array_merge($options, $options['options']);
unset($options['options']);
}
$data = apply_filters('pods_field_pick_object_data', null, $name, $value, $options, $pod, $id, $object_params);
$items = array();
if (!isset($options[self::$type . '_object'])) {
$data = pods_var_raw('data', $options, array(), null, true);
}
$simple = false;
if (null === $data) {
$data = array();
if ('custom-simple' == $options[self::$type . '_object']) {
$custom = pods_var_raw(self::$type . '_custom', $options, '');
$custom = apply_filters('pods_form_ui_field_pick_custom_values', $custom, $name, $value, $options, $pod, $id, $object_params);
if (!empty($custom)) {
if (!is_array($custom)) {
$data = array();
$custom = explode("\n", trim($custom));
foreach ($custom as $custom_value) {
$custom_label = explode('|', $custom_value);
if (empty($custom_label)) {
continue;
}
if (1 == count($custom_label)) {
$custom_label = $custom_value;
} else {
$custom_value = $custom_label[0];
$custom_label = $custom_label[1];
}
$custom_value = trim((string) $custom_value);
$custom_label = trim((string) $custom_label);
$data[$custom_value] = $custom_label;
}
} else {
$data = $custom;
}
$simple = true;
}
} elseif (isset(self::$related_objects[$options[self::$type . '_object']]) && isset(self::$related_objects[$options[self::$type . '_object']]['data']) && !empty(self::$related_objects[$options[self::$type . '_object']]['data'])) {
$data = self::$related_objects[$options[self::$type . '_object']]['data'];
$simple = true;
} elseif (isset(self::$related_objects[$options[self::$type . '_object']]) && isset(self::$related_objects[$options[self::$type . '_object']]['data_callback']) && is_callable(self::$related_objects[$options[self::$type . '_object']]['data_callback'])) {
$data = call_user_func_array(self::$related_objects[$options[self::$type . '_object']]['data_callback'], array($name, $value, $options, $pod, $id));
$simple = true;
// Cache data from callback
if (!empty($data)) {
self::$related_objects[$options[self::$type . '_object']]['data'] = $data;
}
} elseif ('simple_value' != $context) {
$pick_val = pods_var(self::$type . '_val', $options);
if ('table' == pods_var(self::$type . '_object', $options)) {
$pick_val = pods_var(self::$type . '_table', $options, $pick_val, null, true);
}
if ('__current__' == $pick_val) {
if (is_object($pod)) {
$pick_val = $pod->pod;
} elseif (is_array($pod)) {
$pick_val = $pod['name'];
} elseif (0 < strlen($pod)) {
$pick_val = $pod;
}
}
$options['table_info'] = pods_api()->get_table_info(pods_var(self::$type . '_object', $options), $pick_val, null, null, $options);
$search_data = pods_data();
$search_data->table($options['table_info']);
if (isset($options['table_info']['pod']) && !empty($options['table_info']['pod']) && isset($options['table_info']['pod']['name'])) {
$search_data->pod = $options['table_info']['pod']['name'];
$search_data->fields = $options['table_info']['pod']['fields'];
}
$params = array('select' => "`t`.`{$search_data->field_id}`, `t`.`{$search_data->field_index}`", 'table' => $search_data->table, 'where' => pods_var_raw(self::$type . '_where', $options, (array) $options['table_info']['where_default'], null, true), 'orderby' => pods_var_raw(self::$type . '_orderby', $options, null, null, true), 'groupby' => pods_var_raw(self::$type . '_groupby', $options, null, null, true), 'pagination' => false, 'search' => false);
if (in_array($options[self::$type . '_object'], array('site', 'network'))) {
$params['select'] .= ', `t`.`path`';
//.........这里部分代码省略.........
示例15: showTemplate
/**
* Display the page template
*/
function showTemplate($template, $code = null)
{
ob_start();
//pre-template hooks
do_action('pods_pre_showtemplate', $template, $code, $this);
do_action("pods_pre_showtemplate_{$template}", $template, $code, $this);
if (!empty($code)) {
$function_or_file = false;
} else {
$function_or_file = $template;
$check_function = false;
$check_file = null;
if ((!defined('PODS_STRICT_MODE') || !PODS_STRICT_MODE) && (!defined('PODS_TEMPLATE_FILES') || !PODS_TEMPLATE_FILES)) {
$check_file = false;
}
if (false !== $check_function && false !== $check_file) {
$function_or_file = pods_function_or_file($function_or_file, $check_function, 'template', $check_file);
} else {
$function_or_file = false;
}
if (!$function_or_file) {
$api = new PodAPI();
$params = array('name' => $template);
if (!defined('PODS_STRICT_MODE') || !PODS_STRICT_MODE) {
$params = pods_sanitize($params);
}
$code = $api->load_template($params);
if (false !== $code && 0 < strlen(trim($code['code']))) {
$code = $code['code'];
} else {
$code = false;
}
}
}
if (empty($code) && false !== $function_or_file && isset($function_or_file['file'])) {
// Only detail templates need $this->id
if (empty($this->id)) {
while ($this->fetchRecord()) {
locate_template($function_or_file['file'], true, true);
}
} else {
locate_template($function_or_file['file'], true, true);
}
} elseif (!empty($code)) {
// Only detail templates need $this->id
if (empty($this->id)) {
while ($this->fetchRecord()) {
echo $this->parse_template_string($code);
}
} else {
echo $this->parse_template_string($code);
}
}
//post-template hooks
do_action('pods_post_showtemplate', $template, $code, $this);
do_action("pods_post_showtemplate_{$template}", $template, $code, $this);
return apply_filters('pods_showtemplate', ob_get_clean(), $template, $code, $this);
}