本文整理汇总了PHP中papi_get_qs函数的典型用法代码示例。如果您正苦于以下问题:PHP papi_get_qs函数的具体用法?PHP papi_get_qs怎么用?PHP papi_get_qs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了papi_get_qs函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: papi_get_post_type
/**
* Get WordPress post type in various ways.
*
* @param int $post_id
*
* @return string
*/
function papi_get_post_type($post_id = null)
{
if ($post_type = papi_get_or_post('post_type')) {
return $post_type;
}
$post_id = papi_get_post_id($post_id);
if ($post_id !== 0) {
return strtolower(get_post_type($post_id));
}
$page = papi_get_qs('page');
if (is_string($page) && strpos(strtolower($page), 'papi-add-new-page,') !== false) {
$exploded = explode(',', $page);
if (empty($exploded[1])) {
return '';
}
return $exploded[1];
}
// If only `post-new.php` without any querystrings
// it would be the post post type.
$req_uri = $_SERVER['REQUEST_URI'];
$exploded = explode('/', $req_uri);
$last = end($exploded);
if ($last === 'post-new.php') {
return 'post';
}
return '';
}
开发者ID:wp-papi,项目名称:papi,代码行数:34,代码来源:post.php
示例2: render_view
/**
* Render tools page view.
*/
public function render_view()
{
$page_view = (string) papi_get_qs('view');
if (empty($page_view)) {
$page_view = 'management-start';
}
$this->view->render($page_view);
}
开发者ID:ekandreas,项目名称:papi,代码行数:11,代码来源:class-papi-admin-management-pages.php
示例3: prepare_taxonomy_types
/**
* Prepare taxonomy types, add standard taxonomy if it should be added.
*
* @param array $taxonomy_types
*
* @return array
*/
protected function prepare_taxonomy_types(array $taxonomy_types)
{
$taxonomy = papi_get_qs('taxonomy');
if (papi_filter_settings_show_standard_taxonomy_type($taxonomy)) {
$id = sprintf('papi-standard-%s-type', $taxonomy);
$taxonomy_type = new Papi_Taxonomy_Type($id);
$taxonomy_type->id = $id;
$taxonomy_type->name = papi_filter_settings_standard_taxonomy_type_name($taxonomy);
$taxonomy_type->taxonomy = [$taxonomy];
$taxonomy_types[] = $taxonomy_type;
}
usort($taxonomy_types, function ($a, $b) {
return strcmp($a->name, $b->name);
});
return papi_sort_order(array_reverse($taxonomy_types));
}
开发者ID:wp-papi,项目名称:papi,代码行数:23,代码来源:class-papi-admin-entry-taxonomy.php
示例4: get_property
/**
* Load property from page type.
*
* @param string $slug
* @param string $child_slug
*
* @return object
*/
public function get_property($slug, $child_slug = '')
{
$page_type_id = str_replace('papi/', '', papi_get_qs('page'));
if (empty($page_type_id)) {
$page_types = papi_get_all_page_types(false, null, true);
$property = null;
foreach ($page_types as $index => $page_type) {
if ($property = $page_type->get_property($slug, $child_slug)) {
break;
}
}
if (is_null($property)) {
return;
}
return $property;
}
$page_type = papi_get_page_type_by_id($page_type_id);
if ($page_type instanceof Papi_Option_Type === false) {
return;
}
return $page_type->get_property($slug, $child_slug);
}
开发者ID:KristoferN,项目名称:papi,代码行数:30,代码来源:class-papi-option-page.php
示例5: render
/**
* Render the property.
*/
public function render()
{
// Check so the property has a type and capabilities on the property.
if (!papi_current_user_is_allowed($this->get_option('capabilities'))) {
return;
}
// A disabled property should not be rendered.
if ($this->disabled()) {
return;
}
// Only render if it's the right language if the definition exist.
if ($this->get_option('lang') === strtolower(papi_get_qs('lang'))) {
$render = true;
} else {
$render = $this->get_option('lang') === false && papi_is_empty(papi_get_qs('lang'));
}
if ($this->display()) {
$this->display = $this->render_is_allowed_by_rules();
}
$this->render_row_html();
$this->render_hidden_html();
$this->render_rules_json();
}
开发者ID:ekandreas,项目名称:papi,代码行数:26,代码来源:class-papi-property.php
示例6: render
/**
* Render the property.
*/
public function render()
{
// Check if current user can view the property.
if (!$this->current_user_can()) {
return;
}
// A disabled property should not be rendered.
if ($this->disabled()) {
return;
}
// Only render if it's the right language if the definition exist.
if ($this->get_option('lang') === strtolower(papi_get_qs('lang'))) {
$this->display = true;
} else {
$this->display = $this->get_option('lang') === false && papi_is_empty(papi_get_qs('lang'));
}
// Check rules.
if ($this->display()) {
$this->display = $this->render_is_allowed_by_rules();
}
$this->render_row_html();
$this->render_hidden_html();
$this->render_rules_json();
}
开发者ID:wp-papi,项目名称:papi,代码行数:27,代码来源:class-papi-property.php
示例7: get_property
/**
* Load property from page type.
*
* @param string $slug
* @param string $child_slug
*
* @return object
*/
public function get_property($slug, $child_slug = '')
{
$content_type_id = papi_get_qs('page');
if (empty($content_type_id)) {
$property = null;
$content_types = papi_get_all_content_types(['types' => 'option']);
foreach ($content_types as $index => $content_type) {
if ($property = $content_type->get_property($slug, $child_slug)) {
$this->option_type = $content_type;
break;
}
}
if (is_null($property)) {
return;
}
return $property;
}
$content_type = papi_get_content_type_by_id($content_type_id);
if (!papi_is_option_type($content_type)) {
return;
}
$this->option_type = $content_type;
return $content_type->get_property($slug, $child_slug);
}
开发者ID:ekandreas,项目名称:papi,代码行数:32,代码来源:class-papi-option-page.php
示例8: get_property
/**
* Load property from page type.
*
* @param string $slug
* @param string $child_slug
*
* @return null|object
*/
public function get_property($slug, $child_slug = '')
{
$entry_type_id = papi_get_qs('page');
if (empty($entry_type_id)) {
$property = null;
$entry_types = papi_get_all_entry_types(['types' => 'option']);
foreach ($entry_types as $entry_type) {
if ($property = $entry_type->get_property($slug, $child_slug)) {
break;
}
}
if (is_null($property)) {
return;
}
return $property;
}
$entry_type = papi_get_entry_type_by_id($entry_type_id);
if ($entry_type instanceof Papi_Option_Type === false) {
return;
}
if ($property = $entry_type->get_property($slug, $child_slug)) {
return $this->prepare_property($property);
}
}
开发者ID:wp-papi,项目名称:papi,代码行数:32,代码来源:class-papi-option-store.php
示例9: render_view
/**
* Menu callback that loads right view depending on what the `page` query string says.
*/
public function render_view()
{
if (strpos(papi_get_qs('page'), 'papi') !== false) {
$page = str_replace('papi-', '', papi_get_qs('page'));
$res = preg_replace('/\\,.*/', '', $page);
if (is_string($res)) {
$page_view = $res;
}
}
if (!isset($page_view)) {
$page_view = null;
}
if (!is_null($page_view)) {
$view = new Papi_Admin_View();
$view->render($page_view);
} else {
echo '<h2>Papi - 404</h2>';
}
}
开发者ID:KristoferN,项目名称:papi,代码行数:22,代码来源:class-papi-admin-menu.php
示例10: get_property
/**
* Get property html via GET.
*
* GET /papi-ajax/?action=get_property
*/
public function get_property()
{
$default_options = Papi_Core_Property::create()->get_options();
$keys = array_keys(get_object_vars($default_options));
$options = papi_get_qs($keys, true);
if ($property = papi_property($options)) {
ob_start();
$property->render_ajax_request();
$html = ob_get_clean();
wp_send_json(['html' => utf8_encode($html)]);
} else {
$this->render_error('No property found');
}
}
开发者ID:ekandreas,项目名称:papi,代码行数:19,代码来源:class-papi-admin-ajax.php
示例11: render_ajax_request
/**
* Render AJAX request.
*/
public function render_ajax_request()
{
$items = $this->get_settings_properties();
if (papi_doing_ajax()) {
$counter = papi_get_qs('counter');
$this->counter = intval($counter);
}
$this->render_properties($items, false);
}
开发者ID:nlemoine,项目名称:papi,代码行数:12,代码来源:class-papi-property-repeater.php
示例12: papi_get_content_type_id
/**
* Get content type id.
*
* @return string
*/
function papi_get_content_type_id()
{
$content_type_id = papi_get_qs('content_type');
/**
* Change content type id.
*
* @param string $content_type_id
*/
return apply_filters('papi/content_type_id', $content_type_id);
}
开发者ID:ekandreas,项目名称:papi,代码行数:15,代码来源:content.php
示例13: get_terms
/**
* Get terms via GET.
*
* GET /papi-ajax/?action=get_terms
*/
public function get_terms()
{
$query = papi_get_qs('query') ?: [];
$query = is_array($query) ? $query : [];
$taxonomy = papi_get_qs('taxonomy') ?: '';
$args = array_merge($query, ['fields' => 'id=>name']);
$terms = [];
if (taxonomy_exists($taxonomy)) {
$terms = get_terms($taxonomy, $args);
}
wp_send_json($terms);
}
开发者ID:wp-papi,项目名称:papi,代码行数:17,代码来源:class-papi-admin-ajax.php
示例14: get_entry_type
/**
* Get Entry Type instance.
*
* @return Papi_Entry_Type|false
*/
private function get_entry_type()
{
if ($this->entry_type instanceof Papi_Entry_Type) {
return $this->entry_type;
}
$entry_type_id = papi_get_entry_type_id();
// If the entry type id is empty try to load
// the entry type id from `page` query string.
//
// Example:
// /wp-admin/options-general.php?page=papi/option/site-option-type
if (empty($entry_type_id)) {
$entry_type_id = preg_replace('/^papi\\/\\w+\\//', '', papi_get_qs('page'));
}
// Use the default entry type id if empty.
if (empty($entry_type_id)) {
$entry_type_id = papi_get_entry_type_id();
}
// If no entry type id exists Papi can't setup a entry type.
if (empty($entry_type_id)) {
return false;
}
return $this->entry_type = papi_get_entry_type_by_id($entry_type_id);
}
开发者ID:nlemoine,项目名称:papi,代码行数:29,代码来源:class-papi-admin.php
示例15: papi_load_page_type_id
/**
* Load the content type id on a post types.
*
* @param string $content_type_id
*
* @return string
*/
function papi_load_page_type_id($content_type_id = '')
{
$key = papi_get_page_type_key();
$post_id = papi_get_post_id();
$post_type = papi_get_post_type($post_id);
// If we have a post id we can load the content type id
// from the post.
if ($post_id > 0) {
$meta_value = get_post_meta($post_id, $key, true);
$content_type_id = empty($meta_value) ? '' : $meta_value;
}
// Try to fetch the content type id from `page_type`
// query string.
if (empty($content_type_id)) {
$content_type_id = papi_get_qs('page_type');
}
// When using `only_page_type` filter we need to fetch the value since it
// maybe not always saved in the database.
if (empty($content_type_id)) {
$content_type_id = papi_filter_settings_only_page_type($post_type);
}
// Load right content type from the parent post id.
if (empty($content_type_id)) {
$meta_value = get_post_meta(papi_get_parent_post_id(), $key, true);
$content_type_id = empty($meta_value) ? '' : $meta_value;
}
// Load content type id from the container if it exists.
if (empty($content_type_id)) {
$key = sprintf('content_type_id.%s', $post_type);
if (papi()->exists($key)) {
return papi()->make($key);
}
}
return $content_type_id;
}
开发者ID:ekandreas,项目名称:papi,代码行数:42,代码来源:page.php
示例16: papi_get_entry_type_id
/**
* Get entry type id.
*
* @param int $id
* @param string $type
*
* @return string
*/
function papi_get_entry_type_id($id = 0, $type = null)
{
$type = papi_get_meta_type($type);
$id = papi_get_meta_id($type, $id);
if ($id > 0) {
if ($meta_value = get_metadata($type, $id, papi_get_page_type_key(), true)) {
return $meta_value;
}
}
$entry_type_id = papi_get_qs('entry_type');
/**
* Change entry type id.
*
* @param string $entry_type_id
* @param string $type
*
* @return string
*/
return apply_filters('papi/entry_type_id', $entry_type_id, $type);
}
开发者ID:nlemoine,项目名称:papi,代码行数:28,代码来源:entry.php
示例17: papi_get_meta_type
/**
* Get right meta type value. It will treat option
* as a meta type even if isn't a real meta type.
*
* @param string $type
*
* @return string|null
*/
function papi_get_meta_type($type = null)
{
if ($meta_type = papi_get_qs('meta_type')) {
return $meta_type;
}
switch ($type) {
case 'option':
return 'option';
case 'post':
case 'page':
return 'post';
case 'taxonomy':
case 'term':
return 'term';
default:
break;
}
$request_uri = $_SERVER['REQUEST_URI'];
$parsed_url = parse_url($request_uri);
if (!empty($parsed_url['query'])) {
// Taxonomy page in admin.
if (is_admin() && preg_match('/taxonomy=/', $parsed_url['query'])) {
return 'term';
}
// Option page in admin.
if (is_admin() && preg_match('/page\\=papi(\\%2F|\\/)option/', $parsed_url['query'])) {
return 'option';
}
}
// When doing ajax we need to check if it's a taxonomy ajax or a post type ajax.
if (is_admin() && defined('DOING_AJAX') && DOING_AJAX) {
if (isset($_POST['taxonomy'])) {
return 'term';
}
if (isset($_POST['post_type'])) {
return 'post';
}
}
// On the frontend term should be returned if on a category or tag page.
if (!is_admin() && (is_category() || is_tag())) {
return 'term';
}
// Check queried object for right meta type.
if ($obj = get_queried_object()) {
if ($obj instanceof WP_Term || isset($obj->term_id)) {
return 'term';
}
if ($obj instanceof WP_Post || isset($obj->post_id)) {
return 'post';
}
}
// Default was has to be set here since we trying to figure out
// which url conform which meta type.
if (is_null($type)) {
$type = 'post';
}
// If meta type exists as a filter we can return it.
if (function_exists("get_{$type}_meta")) {
return $type;
}
}
开发者ID:wp-papi,项目名称:papi,代码行数:69,代码来源:meta.php
示例18: papi_get_qs
/**
* Get query string if it exists and is not empty.
*
* @param array|string $qs
* @param bool $keep_keys
*
* @return array|string
*/
function papi_get_qs($qs, $keep_keys = false)
{
if (!is_string($qs) && !is_array($qs)) {
return;
}
if (is_array($qs)) {
if ($keep_keys) {
$results = [];
foreach ($qs as $key) {
$value = papi_get_qs($key);
if (!papi_is_empty($value)) {
$results[$key] = $value;
}
}
return $results;
} else {
return array_map('papi_get_qs', $qs);
}
}
if (isset($_GET[$qs]) && !empty($_GET[$qs])) {
$value = $_GET[$qs];
if (is_string($value)) {
$value = sanitize_text_field($value);
}
if ($value === 'false') {
$value = false;
}
if ($value === 'true') {
$value = true;
}
return $value;
}
}
开发者ID:KristoferN,项目名称:papi,代码行数:41,代码来源:utilities.php
示例19: papi_get_page_type_id
/**
* Get page type id.
*
* @param int $post_id
*
* @return string
*/
function papi_get_page_type_id($post_id = 0)
{
$post_id = papi_get_post_id($post_id);
$key = papi_get_page_type_key();
$page_type = '';
if ($post_id !== 0) {
$meta_value = get_post_meta($post_id, $key, true);
$page_type = empty($meta_value) ? '' : $meta_value;
}
if (empty($page_type)) {
$page_type = str_replace('papi/', '', papi_get_qs('page_type'));
}
if (empty($page_type)) {
$page_type = papi_get_sanitized_post(papi_get_page_type_key());
}
// Load right page type from a post query string
if (empty($page_type)) {
$meta_value = get_post_meta(papi_get_parent_post_id(), $key, true);
$page_type = empty($meta_value) ? '' : $meta_value;
}
// Load page type id from the container if it exists or
// load it from `papi_get_all_page_types`.
if (empty($page_type)) {
$post_type = papi_get_post_type();
$load_once = papi_filter_core_load_one_type_on();
$collection_key = 'core.page_type.' . $post_type;
if (in_array($post_type, $load_once)) {
if (papi()->exists($collection_key)) {
return papi()->make($collection_key);
}
if ($page_types = papi_get_all_page_types(false, $post_type)) {
return $page_types[0]->get_id();
}
}
}
return $page_type;
}
开发者ID:KristoferN,项目名称:papi,代码行数:44,代码来源:page.php
示例20: restrict_page_types
/**
* Filter page types in post type list.
*/
public function restrict_page_types()
{
$post_types = papi_get_post_types();
if (in_array($this->post_type, $post_types, true)) {
$page_types = papi_get_all_page_types($this->post_type);
$page_types = array_map(function ($page_type) {
return ['name' => $page_type->name, 'value' => $page_type->get_id()];
}, $page_types);
// Add the standard page that isn't a real page type.
if (papi_filter_settings_show_standard_page_type_in_filter($this->post_type)) {
$page_types[] = ['name' => papi_filter_settings_standard_page_type_name($this->post_type), 'value' => 'papi-standard-page'];
}
usort($page_types, function ($a, $b) {
return strcmp(strtolower($a['name']), strtolower($b['name']));
});
?>
<select name="page_type" class="postform">
<option value="0" selected><?php
esc_html_e('All types', 'papi');
?>
</option>
<?php
foreach ($page_types as $page_type) {
printf('<option value="%s" %s>%s</option>', esc_attr($page_type['value']), papi_get_qs('page_type') === $page_type['value'] ? ' selected' : '', esc_html($page_type['name']));
}
?>
</select>
<?php
}
}
开发者ID:wp-papi,项目名称:papi,代码行数:33,代码来源:class-papi-admin-columns.php
注:本文中的papi_get_qs函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论