本文整理汇总了PHP中pods_api函数 的典型用法代码示例。如果您正苦于以下问题:PHP pods_api函数的具体用法?PHP pods_api怎么用?PHP pods_api使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pods_api函数 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _start_table_edit
/**
* Output something at the start of the table form
*
* @param object $form Form class
* @param bool $results
*/
function _start_table_edit($form, $results = true)
{
$api = pods_api();
$all_pods = $api->load_pods(array('names' => true));
$pod_types = array();
foreach ($all_pods as $pod_name => $pod_label) {
$pod_types[$pod_name] = $pod_label . ' (' . $pod_name . ')';
}
?>
<tr>
<td valign="top">
<label for="pod_type"><?php
_e('Pod', 'pods');
?>
</label>
</td>
<td>
<?php
if (0 < count($all_pods)) {
$form->add_drop_down('pod_type', $pod_types);
} else {
echo '<strong class="red">' . __('None Found', 'pods') . '</strong>';
}
?>
</td>
</tr>
<tr>
<td valign="top">
<label for="slug"><?php
_e('Slug or ID', 'pods');
?>
</label>
</td>
<td>
<?php
$form->add_text_box('slug');
?>
</td>
</tr>
<tr>
<td valign="top">
<label for="field"><?php
_e('Field', 'pods');
?>
</label>
</td>
<td>
<?php
$form->add_text_box('field');
?>
</td>
</tr>
<?php
}
开发者ID:dylansmithing, 项目名称:leader-of-rock-wordpress, 代码行数:60, 代码来源:PodsBuilderModuleField.php
示例2: build_menu
public static function build_menu()
{
$PodsAPI = pods_api();
$registered_pods = $PodsAPI->load_pods();
$role = get_role("administrator");
foreach ($registered_pods as $pod_info) {
if (pods_related::is_dms_pod($pod_info["name"])) {
continue;
}
// Add Custom DMS Capabilities
$role->add_cap("pods_read_others_" . $pod_info["name"]);
$role->add_cap("pods_read_bygroup_" . $pod_info["name"]);
$role->add_cap("pods_read_" . $pod_info["name"]);
$role->add_cap("pods_edit_bygroup_" . $pod_info["name"]);
$role->add_cap("pods_delete_sealed_" . $pod_info["name"]);
$role->add_cap("pods_edit_sealed_" . $pod_info["name"]);
$role->add_cap("pods_unseal_" . $pod_info["name"]);
$role->add_cap("jomiz_dms_front_settings");
$role->add_cap("show_reports_in_menu");
}
if (!is_user_logged_in()) {
return "";
}
$menu = '<div id="menu-expanded" class="list-group hidden-xs">';
$navbar_menu = "";
foreach ($registered_pods as $pod_info) {
// don't show in the main menu
if (pods_related::is_dms_pod($pod_info["name"]) || $pod_info['options']['show_in_menu'] == 0) {
continue;
}
if (dms_security::is_allowed($pod_info["name"], array("read_others", "read", "read_bygroup"))) {
$pod_label = $pod_info["label"];
$pod_link = pods_related::get_pod_url($pod_info["name"], "list");
$active_class = "";
if (isset($_GET['type']) && $_GET['type'] == $pod_info["name"]) {
$active_class = "active";
}
$listing_link = "<a class='list-group-item {$active_class}' href='{$pod_link}' title='View {$pod_label}'>{$pod_label}</a>";
$navbar_menu .= "<li class='{$active_class}'><a href='{$pod_link}'>{$pod_label}</a></li>";
$menu .= $listing_link;
}
}
//Reports Link
if (dms_security::is_allowed_cap("show_reports_in_menu")) {
$reports_link = home_url("/reports/");
$navbar_menu .= "<li class='divider'></li><li class=''><a href='{$reports_link}'>Reports</a></li>";
$menu .= "<a href='{$reports_link}' class='list-group-item'>Reports</a>";
}
$menu .= "<a href='#' id='meunitem-showhide' onclick='showhide_mainmenu()' class='list-group-item'><span class='glyphicon glyphicon-pushpin'></span></a>";
$menu .= "</div>";
return array("navbar-menu" => $navbar_menu, "vertical-menu" => $menu);
}
开发者ID:hasanhalabi, 项目名称:jDMS, 代码行数:52, 代码来源:pods_related.php
示例3: get_relationships
/**
* Gets relationships
*
* @since 0.2.0
*
* @return bool
*/
public static function get_relationships()
{
$relationships = false;
$api = pods_api();
$pods = $api->load_pods();
foreach ($pods as $pod) {
$pod_name = pods_v('name', $pod);
if (!is_null($local_fields = pods_v('fields', $pod))) {
foreach ($local_fields as $field_name => $field) {
if ('' !== ($sister_id = pods_v('sister_id', $field))) {
$relationships[pods_v('name', $field)] = array('from' => array('pod_name' => $pod_name, 'field_name' => pods_v('name', $field)), 'to' => self::find_by_id($sister_id, $pods));
}
}
}
}
return $relationships;
}
开发者ID:jamesgol, 项目名称:pods-deploy-backup, 代码行数:24, 代码来源:class-pods-deploy.php
示例4: is_dw_pods_page
public static function is_dw_pods_page($id)
{
if (function_exists('pods_api')) {
$pod_page = pods_api()->load_page(array('id' => $id));
$pod_page_name = !empty($pod_page) ? $pod_page['name'] : '';
if (!empty($pod_page_name) && is_pod_page($pod_page_name)) {
return TRUE;
}
} else {
global $pod_page_exists;
if (is_int($id)) {
$id = array($id);
}
if (in_array($pod_page_exists['id'], $id)) {
return TRUE;
}
}
return FALSE;
}
开发者ID:adisonc, 项目名称:MaineLearning, 代码行数:19, 代码来源:pods_module.php
示例5: baldrick_pods_endpoint
function baldrick_pods_endpoint()
{
if (defined('PODS_VERSION') && defined('PODS_JSON_API_VERSION')) {
//add the basic pods endpoints
$endpoints['pods'] = json_url('pods');
$endpoints['pods-api'] = json_url('pods-api');
//get name of all registered Pods
$pods = pods_api()->load_pods(array('names' => true));
//add end point foreach if there are registered Pods
if (is_array($pods) && !empty($pods)) {
$endpoint_types = array('pods', 'pods_api');
foreach ($pods as $pod) {
foreach ($endpoint_types as $type) {
$endpoints = array_merge($endpoints, array("{$type}/{$pod}" => json_url("{$type}/{$pod}")));
}
}
}
return $endpoints;
}
}
开发者ID:Shelob9, 项目名称:wp-baldrick, 代码行数:20, 代码来源:framework.php
示例6: slug_post_type_breadcrumb
/**
* Basic breadcrumbs for custom post type Pod, using load_pod to get Pod labels.
*
* Someone should add handling for posts and pages as well as ACTs to this. Possibly make a plugin.
*/
function slug_post_type_breadcrumb($divider = '>>')
{
$front = slug_link(site_url(), 'Home');
if (is_home() || is_front_page()) {
return $front;
}
if (is_post_type_archive() || is_singular() && get_post_type() !== false) {
$post_type = get_post_type();
$pod = pods_api()->load_pod($post_type);
if (!is_string($pod)) {
$single = $pod->options['single_label'];
$plural = slug_link(get_post_type_archive($post_type), $pod->label, 'All ' . $single);
if (is_post_type_archive()) {
return $front . $divider . $plural;
}
global $post;
$single = slug_link(get_permalink($post->ID), get_the__title($post->ID), 'View ' . $single);
return $front . $divider . $single;
} else {
return;
}
}
}
开发者ID:logoscreative, 项目名称:pods-code-library, 代码行数:28, 代码来源:post-type-bread-crumb.php
示例7: pods_api
<?php
if (!empty($_POST)) {
if (isset($_POST['clearcache'])) {
$api = pods_api();
$api->cache_flush_pods();
if (defined('PODS_PRELOAD_CONFIG_AFTER_FLUSH') && PODS_PRELOAD_CONFIG_AFTER_FLUSH) {
$api->load_pods();
}
pods_redirect(pods_query_arg(array('pods_clearcache' => 1), array('page', 'tab')));
}
} elseif (1 == pods_var('pods_clearcache')) {
pods_message('Pods transients and cache have been cleared.');
}
?>
<h3><?php
_e('Clear Pods Cache', 'pods');
?>
</h3>
<p><?php
_e('This tool will clear all of the transients/cache that are used by Pods. ', 'pods');
?>
</p>
<p class="submit">
<input type="submit" class="button button-primary" name="clearcache" value="<?php
esc_attr_e('Clear Pods Cache', 'pods');
?>
" />
开发者ID:dylansmithing, 项目名称:leader-of-rock-wordpress, 代码行数:31, 代码来源:settings-tools.php
示例8: save_pod_item
/**
* Add or edit a single pod item
*
* $params['pod'] string The Pod name (pod or pod_id is required)
* $params['pod_id'] string The Pod ID (pod or pod_id is required)
* $params['id'] int The item ID
* $params['data'] array (optional) Associative array of field names + values
* $params['bypass_helpers'] bool Set to true to bypass running pre-save and post-save helpers
* $params['track_changed_fields'] bool Set to true to enable tracking of saved fields via PodsAPI::get_changed_fields()
*
* @param array|object $params An associative array of parameters
*
* @return int The item ID
*
* @since 1.7.9
*/
public function save_pod_item($params)
{
global $wpdb;
$params = (object) pods_str_replace('@wp_', '{prefix}', $params);
$tableless_field_types = PodsForm::tableless_field_types();
$repeatable_field_types = PodsForm::repeatable_field_types();
$simple_tableless_objects = PodsForm::simple_tableless_objects();
// @deprecated 2.0
if (isset($params->datatype)) {
pods_deprecated('$params->pod instead of $params->datatype', '2.0');
$params->pod = $params->datatype;
unset($params->datatype);
if (isset($params->pod_id)) {
pods_deprecated('$params->id instead of $params->pod_id', '2.0');
$params->id = $params->pod_id;
unset($params->pod_id);
}
if (isset($params->data) && !empty($params->data) && is_array($params->data)) {
$check = current($params->data);
if (is_array($check)) {
pods_deprecated('PodsAPI::save_pod_items', '2.0');
return $this->save_pod_items($params, $params->data);
}
}
}
// @deprecated 2.0
if (isset($params->tbl_row_id)) {
pods_deprecated('$params->id instead of $params->tbl_row_id', '2.0');
$params->id = $params->tbl_row_id;
unset($params->tbl_row_id);
}
// @deprecated 2.0
if (isset($params->columns)) {
pods_deprecated('$params->data instead of $params->columns', '2.0');
$params->data = $params->columns;
unset($params->columns);
}
if (!isset($params->pod)) {
$params->pod = false;
}
if (isset($params->pod_id)) {
$params->pod_id = pods_absint($params->pod_id);
} else {
$params->pod_id = 0;
}
if (isset($params->id)) {
$params->id = pods_absint($params->id);
} else {
$params->id = 0;
}
if (!isset($params->from)) {
$params->from = 'save';
}
if (!isset($params->location)) {
$params->location = null;
}
if (!isset($params->track_changed_fields)) {
$params->track_changed_fields = false;
}
/**
* Override $params['track_changed_fields']
*
* Use for globally setting field change tracking.
*
* @param bool
*
* @since 2.3.19
*/
$track_changed_fields = apply_filters('pods_api_save_pod_item_track_changed_fields_' . $params->pod, (bool) $params->track_changed_fields, $params);
$changed_fields = array();
if (!isset($params->clear_slug_cache)) {
$params->clear_slug_cache = true;
}
// Support for bulk edit
if (isset($params->id) && !empty($params->id) && is_array($params->id)) {
$ids = array();
$new_params = $params;
foreach ($params->id as $id) {
$new_params->id = $id;
$ids[] = $this->save_pod_item($new_params);
}
return $ids;
}
// Allow Helpers to know what's going on, are we adding or saving?
//.........这里部分代码省略.........
开发者ID:satokora, 项目名称:IT354Project, 代码行数:101, 代码来源:PodsAPI.php
示例9: reorder
/**
* Reorder data
*/
public function reorder()
{
// loop through order
$order = (array) pods_var_raw('order', 'post', array(), null, true);
$params = array('pod' => $this->pod->pod, 'field' => $this->reorder['on'], 'order' => $order);
$reorder = pods_api()->reorder_pod_item($params);
if ($reorder) {
$this->message(sprintf(__("<strong>Success!</strong> %s reordered successfully.", 'pods'), $this->items));
} else {
$this->error(sprintf(__("<strong>Error:</strong> %s has not been reordered.", 'pods'), $this->items));
}
}
开发者ID:dylansmithing, 项目名称:leader-of-rock-wordpress, 代码行数:15, 代码来源:PodsUI.php
示例10: add_meta_boxes
/**
* Add meta boxes to the page
*
* @since 2.0
*/
public function add_meta_boxes()
{
$pod = array('name' => $this->object_type, 'type' => 'post_type');
if (isset(PodsMeta::$post_types[$pod['name']])) {
return;
}
if (!function_exists('get_page_templates')) {
include_once ABSPATH . 'wp-admin/includes/theme.php';
}
$page_templates = apply_filters('pods_page_templates', get_page_templates());
$page_templates[__('-- Page Template --', 'pods')] = '';
$page_templates[__('Custom (uses only Pod Page content)', 'pods')] = '_custom';
if (!in_array('pods.php', $page_templates) && locate_template(array('pods.php', false))) {
$page_templates[__('Pods (Pods Default)', 'pods')] = 'pods.php';
}
if (!in_array('page.php', $page_templates) && locate_template(array('page.php', false))) {
$page_templates[__('Page (WP Default)', 'pods')] = 'page.php';
}
if (!in_array('index.php', $page_templates) && locate_template(array('index.php', false))) {
$page_templates[__('Index (WP Fallback)', 'pods')] = 'index.php';
}
ksort($page_templates);
$page_templates = array_flip($page_templates);
$fields = array(array('name' => 'page_title', 'label' => __('Page Title', 'pods'), 'type' => 'text'), array('name' => 'code', 'label' => __('Page Code', 'pods'), 'type' => 'code', 'attributes' => array('id' => 'content'), 'label_options' => array('attributes' => array('for' => 'content'))), array('name' => 'precode', 'label' => __('Page Precode', 'pods'), 'type' => 'code', 'help' => __('Precode will run before your theme outputs the page. It is expected that this value will be a block of PHP. You must open the PHP tag here, as we do not open it for you by default.', 'pods')), array('name' => 'page_template', 'label' => __('Page Template', 'pods'), 'type' => 'pick', 'data' => $page_templates));
pods_group_add($pod, __('Page', 'pods'), $fields, 'normal', 'high');
$associated_pods = array(0 => __('-- Select a Pod --', 'pods'));
$all_pods = pods_api()->load_pods(array('names' => true));
if (!empty($all_pods)) {
foreach ($all_pods as $pod_name => $pod_label) {
$associated_pods[$pod_name] = $pod_label . ' (' . $pod_name . ')';
}
} else {
$associated_pods[0] = __('None Found', 'pods');
}
$fields = array(array('name' => 'pod', 'label' => __('Associated Pod', 'pods'), 'default' => 0, 'type' => 'pick', 'data' => $associated_pods, 'dependency' => true), array('name' => 'pod_slug', 'label' => __('Wildcard Slug', 'pods'), 'help' => __('Setting the Wildcard Slug is an easy way to setup a detail page. You can use the special tag {@url.2} to match the *third* level of the URL of a Pod Page named "first/second/*" part of the pod page. This is functionally the same as using pods_var( 2, "url" ) in PHP.', 'pods'), 'type' => 'text', 'excludes-on' => array('pod' => 0)));
pods_group_add($pod, __('Pod Association', 'pods'), $fields, 'normal', 'high');
$fields = array(array('name' => 'admin_only', 'label' => __('Restrict access to Admins?', 'pods'), 'default' => 0, 'type' => 'boolean', 'dependency' => true), array('name' => 'restrict_role', 'label' => __('Restrict access by Role?', 'pods'), 'help' => array(__('<h6>Roles</h6> Roles are assigned to users to provide them access to specific functionality in WordPress. Please see the Roles and Capabilities component in Pods for an easy tool to add your own roles and edit existing ones.', 'pods'), 'http://codex.wordpress.org/Roles_and_Capabilities'), 'default' => 0, 'type' => 'boolean', 'dependency' => true), array('name' => 'roles_allowed', 'label' => __('Role(s) Allowed', 'pods'), 'type' => 'pick', 'pick_object' => 'role', 'pick_format_type' => 'multi', 'pick_format_multi' => 'autocomplete', 'pick_ajax' => false, 'default' => '', 'depends-on' => array('restrict_role' => true)), array('name' => 'restrict_capability', 'label' => __('Restrict access by Capability?', 'pods'), 'help' => array(__('<h6>Capabilities</h6> Capabilities denote access to specific functionality in WordPress, and are assigned to specific User Roles. Please see the Roles and Capabilities component in Pods for an easy tool to add your own capabilities and roles.', 'pods'), 'http://codex.wordpress.org/Roles_and_Capabilities'), 'default' => 0, 'type' => 'boolean', 'dependency' => true), array('name' => 'capability_allowed', 'label' => __('Capability Allowed', 'pods'), 'type' => 'pick', 'pick_object' => 'capability', 'pick_format_type' => 'multi', 'pick_format_multi' => 'autocomplete', 'pick_ajax' => false, 'default' => '', 'depends-on' => array('restrict_capability' => true)), array('name' => 'restrict_redirect', 'label' => __('Redirect if Restricted?', 'pods'), 'default' => 0, 'type' => 'boolean', 'dependency' => true), array('name' => 'restrict_redirect_login', 'label' => __('Redirect to WP Login page', 'pods'), 'default' => 0, 'type' => 'boolean', 'dependency' => true, 'depends-on' => array('restrict_redirect' => true)), array('name' => 'restrict_redirect_url', 'label' => __('Redirect to a Custom URL', 'pods'), 'default' => '', 'type' => 'text', 'depends-on' => array('restrict_redirect' => true, 'restrict_redirect_login' => false)));
pods_group_add($pod, __('Restrict Access', 'pods'), $fields, 'normal', 'high');
}
开发者ID:erkmen, 项目名称:wpstartersetup, 代码行数:44, 代码来源:Pages.php
示例11: pods_api
<?php
$all_pods = pods_api()->load_pods();
// or $api = pods_api(); and then $api->load_pods();
foreach ($all_pods as $pod) {
echo '<p>' . $pod['name '] . ' is awesome</p>' . "\n";
}
开发者ID:logoscreative, 项目名称:pods-code-library, 代码行数:7, 代码来源:echo-name-of-pods.php
示例12: get_template_titles
/**
* Get titles of all Pods Templates
*
* @return string[] Array of template names
*
* @since 2.4.5
*/
public function get_template_titles()
{
static $template_titles;
if (empty($template_titles)) {
$all_templates = (array) pods_api()->load_templates(array());
$template_titles = array();
foreach ($all_templates as $template) {
$template_titles[] = $template['name'];
}
}
return $template_titles;
}
开发者ID:benbrandt, 项目名称:pods, 代码行数:19, 代码来源:Pods_Templates_Auto_Template_Settings.php
示例13: heres_the_beef
/**
* @param $import
* @param bool $output
*/
public function heres_the_beef($import, $output = true)
{
global $wpdb;
$api = pods_api();
for ($i = 0; $i < 40000; $i++) {
echo " \t";
// extra spaces
}
$default_data = array('pod' => null, 'table' => null, 'reset' => null, 'update_on' => null, 'where' => null, 'fields' => array(), 'row_filter' => null, 'pre_save' => null, 'post_save' => null, 'sql' => null, 'sort' => null, 'limit' => null, 'page' => null, 'output' => null, 'page_var' => 'ipg', 'bypass_helpers' => false);
$default_field_data = array('field' => null, 'filter' => null);
if (!is_array($import)) {
$import = array($import);
} elseif (empty($import)) {
die('<h1 style="color:red;font-weight:bold;">ERROR: No imports configured</h1>');
}
$import_counter = 0;
$total_imports = count($import);
$paginated = false;
$avg_time = -1;
$total_time = 0;
$counter = 0;
$avg_unit = 100;
$avg_counter = 0;
foreach ($import as $datatype => $data) {
$import_counter++;
flush();
@ob_end_flush();
usleep(50000);
if (!is_array($data)) {
$datatype = $data;
$data = array('table' => $data);
}
if (isset($data[0])) {
$data = array('table' => $data[0]);
}
$data = array_merge($default_data, $data);
if (null === $data['pod']) {
$data['pod'] = array('name' => $datatype);
}
if (false !== $output) {
echo "<br />" . date('Y-m-d h:i:sa') . " - <em>" . $data['pod']['name'] . "</em> - <em>" . $data['pod']['name'] . "</em> - <strong>Loading Pod: " . $data['pod']['name'] . "</strong>\n";
}
if (2 > count($data['pod'])) {
$data['pod'] = $api->load_pod(array('name' => $data['pod']['name']));
}
if (empty($data['pod']['fields'])) {
continue;
}
if (null === $data['table']) {
$data['table'] = $data['pod']['name'];
}
if ($data['reset'] === true) {
if (false !== $output) {
echo "<br />" . date('Y-m-d h:i:sa') . " - <em>" . $data['pod']['name'] . "</em> - <strong style='color:blue;'>Resetting Pod: " . $data['pod']['name'] . "</strong>\n";
}
$api->reset_pod(array('id' => $data['pod']['id'], 'name' => $data['pod']['name']));
}
if (null === $data['sort'] && null !== $data['update_on'] && isset($data['fields'][$data['update_on']])) {
if (isset($data['fields'][$data['update_on']]['field'])) {
$data['sort'] = $data['fields'][$data['update_on']]['field'];
} else {
$data['sort'] = $data['update_on'];
}
}
$page = 1;
if (false !== $data['page_var'] && isset($_GET[$data['page_var']])) {
$page = absval($_GET[$data['page_var']]);
}
if (null === $data['sql']) {
$data['sql'] = "SELECT * FROM {$data['table']}" . (null !== $data['where'] ? " WHERE {$data['where']}" : '') . (null !== $data['sort'] ? " ORDER BY {$data['sort']}" : '') . (null !== $data['limit'] ? " LIMIT " . (1 < $page ? ($page - 1) * $data['limit'] . ',' : '') . "{$data['limit']}" : '');
}
if (false !== $output) {
echo "<br />" . date('Y-m-d h:i:sa') . " - <em>" . $data['pod']['name'] . "</em> - Getting Results: " . $data['pod']['name'] . "\n";
}
if (false !== $output) {
echo "<br />" . date('Y-m-d h:i:sa') . " - <em>" . $data['pod']['name'] . "</em> - Using Query: <small><code>" . $data['sql'] . "</code></small>\n";
}
$result = $wpdb->get_results($data['sql'], ARRAY_A);
if (false !== $output) {
echo "<br />" . date('Y-m-d h:i:sa') . " - <em>" . $data['pod']['name'] . "</em> - Results Found: " . count($result) . "\n";
}
$avg_time = -1;
$total_time = 0;
$counter = 0;
$avg_unit = 100;
$avg_counter = 0;
$result_count = count($result);
$paginated = false;
if (false !== $data['page_var'] && $result_count == $data['limit']) {
$paginated = "<input type=\"button\" onclick=\"document.location=\\'" . pods_ui_var_update(array($data['page_var'] => $page + 1), false, false) . "\\';\" value=\" Continue Import » \" />";
}
if ($result_count < $avg_unit && 5 < $result_count) {
$avg_unit = number_format($result_count / 5, 0, '', '');
} elseif (2000 < $result_count && 10 < count($data['pod']['fields'])) {
$avg_unit = 40;
}
//.........这里部分代码省略.........
开发者ID:centaurustech, 项目名称:chipin, 代码行数:101, 代码来源:PodsMigrate.php
示例14: admin_ajax_upload
/**
* Handle plupload AJAX
*
* @since 2.3
*/
public function admin_ajax_upload()
{
if (false === headers_sent()) {
if ('' == session_id()) {
@session_start();
}
}
// Sanitize input
$params = stripslashes_deep((array) $_POST);
foreach ($params as $key => $value) {
if ('action' == $key) {
continue;
}
unset($params[$key]);
$params[str_replace('_podsfix_', '', $key)] = $value;
}
$params = (object) $params;
$methods = array('upload');
if (!isset($params->method) || !in_array($params->method, $methods) || !isset($params->pod) || !isset($params->field) || !isset($params->uri) || empty($params->uri)) {
pods_error('Invalid AJAX request', PodsInit::$admin);
} elseif (!empty($params->pod) && empty($params->field)) {
pods_error('Invalid AJAX request', PodsInit::$admin);
} elseif (empty($params->pod) && !current_user_can('upload_files')) {
pods_error('Invalid AJAX request', PodsInit::$admin);
}
// Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead
if (is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie'])) {
$_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie'];
} elseif (empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie'])) {
$_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie'];
}
if (empty($_COOKIE[LOGGED_IN_COOKIE]) && !empty($_REQUEST['logged_in_cookie'])) {
$_COOKIE[LOGGED_IN_COOKIE] = $_REQUEST['logged_in_cookie'];
}
global $current_user;
unset($current_user);
/**
* Access Checking
*/
$upload_disabled = false;
if (defined('PODS_DISABLE_FILE_UPLOAD') && true === PODS_DISABLE_FILE_UPLOAD) {
$upload_disabled = true;
} elseif (defined('PODS_UPLOAD_REQUIRE_LOGIN') && is_bool(PODS_UPLOAD_REQUIRE_LOGIN) && true === PODS_UPLOAD_REQUIRE_LOGIN && !is_user_logged_in()) {
$upload_disabled = true;
} elseif (defined('PODS_UPLOAD_REQUIRE_LOGIN') && !is_bool(PODS_UPLOAD_REQUIRE_LOGIN) && (!is_user_logged_in() || !current_user_can(PODS_UPLOAD_REQUIRE_LOGIN))) {
$upload_disabled = true;
}
$uid = @session_id();
if (is_user_logged_in()) {
$uid = 'user_' . get_current_user_id();
}
$nonce_check = 'pods_upload_' . (int) $params->pod . '_' . $uid . '_' . $params->uri . '_' . (int) $params->field;
if (true === $upload_disabled || !isset($params->_wpnonce) || false === wp_verify_nonce($params->_wpnonce, $nonce_check)) {
pods_error(__('Unauthorized request', 'pods'), PodsInit::$admin);
}
$pod = array();
$field = array('type' => 'file', 'options' => array());
$api = pods_api();
if (!empty($params->pod)) {
$pod = $api->load_pod(array('id' => (int) $params->pod));
$field = $api->load_field(array('id' => (int) $params->field));
if (empty($pod) || empty($field) || $pod['id'] != $field['pod_id'] || !isset($pod['fields'][$field['name']])) {
pods_error(__('Invalid field request', 'pods'), PodsInit::$admin);
}
if (!in_array($field['type'], PodsForm::file_field_types())) {
pods_error(__('Invalid field', 'pods'), PodsInit::$admin);
}
}
$method = $params->method;
// Cleaning up $params
unset($params->action);
unset($params->method);
unset($params->_wpnonce);
$params->post_id = pods_var('post_id', $params, 0, null, true);
/**
* Upload a new file (advanced - returns URL and ID)
*/
if ('upload' == $method) {
$file = $_FILES['Filedata'];
$limit_size = pods_var($field['type'] . '_restrict_filesize', $field['options']);
if (!empty($limit_size)) {
if (false !== stripos($limit_size, 'MB')) {
$limit_size = (double) trim(str_ireplace('MB', '', $limit_size));
$limit_size = $limit_size * 1025 * 1025;
// convert to KB to B
} elseif (false !== stripos($limit_size, 'KB')) {
$limit_size = (double) trim(str_ireplace('KB', '', $limit_size));
$limit_size = $limit_size * 1025 * 1025;
// convert to B
} elseif (false !== stripos($limit_size, 'GB')) {
$limit_size = (double) trim(str_ireplace('GB', '', $limit_size));
$limit_size = $limit_size * 1025 * 1025 * 1025;
// convert to MB to KB to B
} elseif (false !== stripos($limit_size, 'B')) {
$limit_size = (double) trim(str_ireplace('B', '', $limit_size));
//.........这里部分代码省略.........
开发者ID:centaurustech, 项目名称:chipin, 代码行数:101, 代码来源:file.php
示例15: __construct
/**
* Constructor - Pods Framework core
*
* @param string $pod The pod name
* @param mixed $id (optional) The ID or slug, to load a single record; Provide array of $params to run 'find'
*
* @return \Pods
*
* @license http://www.gnu.org/licenses/gpl-2.0.html
* @since 1.0.0
* @link http://pods.io/docs/pods/
*/
public function __construct($pod = null, $id = null)
{
if (null === $pod) {
$queried_object = get_queried_object();
if ($queried_object) {
$id_lookup = true;
// Post Type Singular
if (isset($queried_object->post_type)) {
$pod = $queried_object->post_type;
} elseif (isset($queried_object->taxonomy)) {
$pod = $queried_object->taxonomy;
} elseif (isset($queried_object->user_login)) {
$pod = 'user';
} elseif (isset($queried_object->public) && isset($queried_object->name)) {
$pod = $queried_object->name;
$id_lookup = false;
}
if (null === $id && $id_lookup) {
$id = get_queried_object_id();
}
}
}
$this->api = pods_api($pod);
$this->api->display_errors =& $this->display_errors;
$this->data = pods_data($this->api, $id, false);
PodsData::$display_errors =& $this->display_errors;
// Set up page variable
if (pods_strict(false)) {
$this->page = 1;
$this->pagination = false;
$this->search = false;
} else {
// Get the page variable
$this->page = pods_var($this->page_var, 'get');
$this->page = empty($this->page) ? 1 : max(pods_absint($this->page), 1);
}
// Set default pagination handling to on/off
if (defined('PODS_GLOBAL_POD_PAGINATION')) {
if (!PODS_GLOBAL_POD_PAGINATION) {
$this->page = 1;
$this->pagination = false;
} else {
$this->pagination = true;
}
}
// Set default search to on/off
if (defined('PODS_GLOBAL_POD_SEARCH')) {
if (PODS_GLOBAL_POD_SEARCH) {
$this->search = true;
} else {
$this->search = false;
}
}
// Set default search mode
$allowed_search_modes = array('int', 'text', 'text_like');
if (defined('PODS_GLOBAL_POD_SEARCH_MODE') && in_array(PODS_GLOBAL_POD_SEARCH_MODE, $allowed_search_modes)) {
$this->search_mode = PODS_GLOBAL_POD_SEARCH_MODE;
}
// Sync Settings
$this->data->page =& $this->page;
$this->data->limit =& $this->limit;
$this->data->pagination =& $this->pagination;
$this->data->search =& $this->search;
$this->data->search_mode =& $this->search_mode;
// Sync Pod Data
$this->api->pod_data =& $this->data->pod_data;
$this->pod_data =& $this->api->pod_data;
$this->api->pod_id =& $this->data->pod_id;
$this->pod_id =& $this->api->pod_id;
$this->datatype_id =& $this->pod_id;
$this->api->pod =& $this->data->pod;
$this->pod =& $this->api->pod;
$this->datatype =& $this->pod;
$this->api->fields =& $this->data->fields;
$this->fields =& $this->api->fields;
$this->detail_page =& $this->data->detail_page;
$this->id =& $this->data->id;
$this->row =& $this->data->row;
$this->rows =& $this->data->data;
$this->row_number =& $this->data->row_number;
$this->sql =& $this->data->sql;
if (is_array($id) || is_object($id)) {
$this->find($id);
}
}
开发者ID:erkmen, 项目名称:wpstartersetup, 代码行数:97, 代码来源:Pods.php
示例16: pods_serial_comma
/**
* Split an array into human readable text (Item, Item, and Item)
*
* @param array $value
* @param string $field
* @param array $fields
* @param string $and
* @param string $field_index
*
* @return string
*
* @since 2.0
*/
function pods_serial_comma($value, $field = null, $fields = null, $and = null, $field_index = null)
{
if (is_object($value)) {
$value = get_object_vars($value);
}
$defaults = array('field' => $field, 'fields' => $fields, 'and' => $and, 'field_index' => $field_index, 'separator' => ',', 'serial' => true);
if (is_array($field)) {
$defaults['field'] = null;
$params = array_merge($defaults, $field);
} else {
$params = $defaults;
}
$params = (object) $params;
$simple = false;
if (!empty($params->fields) && is_array($params->fields) && isset($params->fields[$params->field])) {
$params->field = $params->fields[$params->field];
$simple_tableless_objects = PodsForm::simple_tableless_objects();
if (!empty($params->field) && is_array($params->field) && in_array($params->field['type'], PodsForm::tableless_field_types())) {
if (in_array($params->field['type'], PodsForm::file_field_types())) {
if (null === $params->field_index) {
$params->field_index = 'guid';
}
} elseif (in_array($params->field['pick_object'], $simple_tableless_objects)) {
$simple = true;
} else {
$table = pods_api()->get_table_info($params->field['pick_object'], $params->field['pick_val'], null, null, $params->field);
if (!empty($table)) {
if (null === $params->field_index) {
$params->field_index = $table['field_index'];
}
}
}
}
} else {
$params->field = null;
}
if ($simple && is_array($params->field) && !is_array($value) && '' !== $value && null !== $value) {
$value = PodsForm::field_method('pick', 'simple_value', $params->field['name'], $value, $params->field);
}
if (!is_array($value)) {
return $value;
}
if (null === $params->and) {
$params->and = ' ' . __('and', 'pods') . ' ';
}
$last = '';
$original_value = $value;
if (!empty($value)) {
$last = array_pop($value);
}
if ($simple && is_array($params->field) && !is_array($last) && '' !== $last && null !== $last) {
$last = PodsForm::field_method('pick', 'simple_value', $params->field['name'], $last, $params->field);
}
if (is_array($last)) {
if (null !== $params->field_index && isset($last[$params->field_index])) {
$last = $last[$params->field_index];
} elseif (isset($last[0])) {
$last = $last[0];
} elseif ($simple) {
$last = current($last);
} else {
$last = '';
}
}
if (!empty($value)) {
if (null !== $params->field_index && isset($original_value[$params->field_index])) {
return $original_value[$params->field_index];
} elseif (null !== $params->field_index && isset($value[$params->field_index])) {
return $value[$params->field_index];
} elseif (!isset($value[0])) {
$value = array($value);
}
foreach ($value as $k => $v) {
if ($simple && is_array($params->field) && !is_array($v) && '' !== $v && null !== $v) {
$v = PodsForm::field_method('pick', 'simple_value', $params->field['name'], $v, $params->field);
}
if (is_array($v)) {
if (null !== $params->field_index && isset($v[$params->field_index])) {
$v = $v[$params->field_index];
} elseif ($simple) {
$v = trim(implode($params->separator . ' ', $v), $params->separator . ' ');
} else {
unset($value[$k]);
continue;
}
}
$value[$k] = $v;
//.........这里部分代码省略.........
开发者ID:dylansmithing, 项目名称:leader-of-rock-wordpress, 代码行数:101, 代码来源:data.php
示例17: pods_api
<?php
// Get the API object for 'event' Pod
$api = pods_api('event');
// Setup the data to import
$data = array(0 => array('name' => 'My first event', 'start_date' => '2009-10-30 08:24:30', 'attendees' => array('Bill Gates', 'Steve Jobs', 'Mario Andretti')), 1 => array('name' => 'My second event', 'start_date' => '2012-12-25 06:45:00', 'attendees' => array('Al Gore', 'Bill Clinton')), 2 => array('name' => 'My third event', 'start_date' => '2010-01-20 11:59:99', 'attendees' => array('Rick Astley')));
// Run the import
$api->import($data);
// Get CSV data
$data = file_get_contents('path/to/events.csv');
// Run the import and set the format to CSV
$api->import($data, false, 'csv');
开发者ID:logoscreative, 项目名称:pods-code-library, 代码行数:12, 代码来源:basic-usage.php
librespeed/speedtest: Self-hosted Speedtest for HTML5 and more. Easy setup, exam
阅读:1215| 2022-08-30
avehtari/BDA_m_demos: Bayesian Data Analysis demos for Matlab/Octave
阅读:1124| 2022-08-17
女人怀孕后,为了有一个健康聪明的宝宝,经历各种体检、筛查。其实这些体检和筛查中的
阅读:934| 2022-11-06
medfreeman/markdown-it-toc-and-anchor: markdown-it plugin to add a toc and ancho
阅读:1331| 2022-08-18
http://blog.sina.com.cn/s/blog_45b486b80100g45a.html
阅读:515| 2022-07-18
ZeosLibhttp://sourceforge.net/projects/zeoslib一套开源的数据库控件,可以支持多数
阅读:697| 2022-07-18
In Bluetooth, there is a possible out of bounds write due to a missing bounds ch
阅读:945| 2022-07-08
sydney0zq/covid-19-detection: The implementation of A Weakly-supervised Framewor
阅读:483| 2022-08-16
fabric8io/jenkins-pipeline-library: a collection of reusable jenkins pipelines a
阅读:688| 2022-08-15
离中国最远的国家是阿根廷。从太平洋直线计算,即往东线走,北京到阿根廷的布宜诺斯艾
阅读:633| 2022-11-06
请发表评论