当前位置: 首页>>代码示例>>PHP>>正文


PHP papi_get_post_id函数代码示例

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


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

示例1: __construct

 /**
  * The constructor.
  *
  * @param int $id
  */
 public function __construct($id = 0)
 {
     $this->id = papi_get_post_id($id);
     $this->post = get_post($this->id);
     $id = papi_get_page_type_id($this->id);
     $this->type_class = papi_get_entry_type_by_id($id);
 }
开发者ID:wp-papi,项目名称:papi,代码行数:12,代码来源:class-papi-post-store.php

示例2: 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

示例3: papi_append_post_type_query

/**
 * Append post type query string.
 *
 * @param  string $url
 * @param  string $post_type_arg
 *
 * @return string
 */
function papi_append_post_type_query($url, $post_type_arg = null)
{
    if (strpos($url, 'post_type=') !== false) {
        return preg_replace('/&%.+/', '', $url);
    }
    $post_id = papi_get_post_id();
    if ($post_id === 0) {
        $post_type = papi_get_or_post('post_type');
    } else {
        $post_type = get_post_type($post_id);
    }
    if (!empty($post_type_arg) && empty($post_type)) {
        $post_type = $post_type_arg;
    }
    if (empty($post_type)) {
        $post_type = 'post';
    }
    if (!empty($post_type)) {
        if (substr($url, -1, 1) !== '&') {
            $url .= '&';
        }
        $url .= 'post_type=' . $post_type;
    }
    return $url;
}
开发者ID:ekandreas,项目名称:papi,代码行数:33,代码来源:url.php

示例4: papi_append_post_type_query

/**
 * Append post type query string.
 *
 * @param  string $url
 * @param  string $post_type_arg
 *
 * @return string
 */
function papi_append_post_type_query($url, $post_type_arg = null)
{
    if (strpos($url, 'post_type=') !== false) {
        return preg_replace('/&%.+/', '', $url);
    }
    $post_type = '';
    // Only change post type if post type arg isn't the same.
    if ($post_type_arg !== $post_type) {
        $post_type = $post_type_arg;
    }
    // Add post type if empty.
    if (empty($post_type)) {
        $post_id = papi_get_post_id();
        if ($post_id === 0) {
            $post_type = papi_get_or_post('post_type');
        } else {
            $post_type = get_post_type($post_id);
        }
        if (empty($post_type)) {
            $post_type = $post_type_arg;
        }
        if (empty($post_type)) {
            $post_type = 'post';
        }
    }
    // Add right query string character.
    if (!empty($post_type)) {
        if (substr($url, -1, 1) !== '&') {
            $url .= '&';
        }
        $url .= 'post_type=' . $post_type;
    }
    return $url;
}
开发者ID:wp-papi,项目名称:papi,代码行数:42,代码来源:url.php

示例5: get_post_type

 /**
  * Get meta post type.
  *
  * @return string
  */
 private function get_post_type()
 {
     if ($post_id = papi_get_post_id()) {
         return get_post_type($post_id);
     }
     if ($post_type = papi_get_post_type()) {
         return $post_type;
     }
     return $this->box->id;
 }
开发者ID:ekandreas,项目名称:papi,代码行数:15,代码来源:class-papi-admin-meta-box.php

示例6: __construct

 /**
  * The constructor.
  *
  * Create a new instance of the class.
  *
  * @param int $post_id
  */
 public function __construct($post_id = 0)
 {
     if ($post_id === 0) {
         $this->id = papi_get_post_id();
     } else {
         $this->id = intval($post_id);
     }
     $this->post = get_post($this->id);
     $id = papi_get_page_type_id($this->id);
     $this->page_type = papi_get_page_type_by_id($id);
 }
开发者ID:KristoferN,项目名称:papi,代码行数:18,代码来源:class-papi-post-page.php

示例7: get_post_type

 /**
  * Get meta post type.
  *
  * @return string
  */
 protected function get_post_type()
 {
     if (papi_get_meta_type() === 'post') {
         if ($post_id = papi_get_post_id()) {
             return get_post_type($post_id);
         }
         if ($post_type = papi_get_post_type()) {
             return $post_type;
         }
     }
     return $this->box->id;
 }
开发者ID:nlemoine,项目名称:papi,代码行数:17,代码来源:class-papi-admin-meta-box.php

示例8: papi_field_shortcode

/**
 * Shortcode for `papi_get_field` function.
 *
 * [papi_field id=1 slug="property_slug" default="Default value"][/papi_field]
 *
 * @param  array $atts
 *
 * @return mixed
 */
function papi_field_shortcode($atts)
{
    $atts['id'] = isset($atts['id']) ? $atts['id'] : 0;
    $atts['id'] = papi_get_post_id($atts['id']);
    $default = isset($atts['default']) ? $atts['default'] : '';
    if (empty($atts['id']) || empty($atts['slug'])) {
        $value = $default;
    } else {
        $value = papi_get_field($atts['id'], $atts['slug'], $default);
    }
    if (is_array($value)) {
        $value = implode(', ', $value);
    }
    return $value;
}
开发者ID:nlemoine,项目名称:papi,代码行数:24,代码来源:page.php

示例9: papi_set_page_type_id

/**
 * Set page type to a post.
 *
 * @param  mixed $post_id
 * @param  string $page_type
 *
 * @return bool
 */
function papi_set_page_type_id($post_id, $page_type)
{
    return papi_page_type_exists($page_type) && update_post_meta(papi_get_post_id($post_id), papi_get_page_type_key(), $page_type);
}
开发者ID:KristoferN,项目名称:papi,代码行数:12,代码来源:page.php

示例10: get_import_options

 /**
  * Get import options.
  *
  * @param  mixed $options
  *
  * @return array
  */
 protected function get_import_options($options)
 {
     $default_options = ['meta_id' => 0, 'meta_type' => 'post', 'post_id' => 0, 'page_type' => '', 'update_arrays' => false];
     if (!is_array($options)) {
         $options = array_merge($default_options, ['post_id' => papi_get_post_id($options)]);
     }
     return array_merge($default_options, $options);
 }
开发者ID:wp-papi,项目名称:papi,代码行数:15,代码来源:class-papi-porter.php

示例11: get_value

 /**
  * Get value from the database.
  *
  * @return string
  */
 public function get_value()
 {
     $value = $this->format_value(parent::get_value(), $this->get_slug(), papi_get_post_id());
     return $this->get_setting('allow_html') ? $value : esc_html($value);
 }
开发者ID:wp-papi,项目名称:papi,代码行数:10,代码来源:class-papi-property-text.php

示例12: populate_post_type

 /**
  * Populate post type.
  *
  * @param  array|string $post_type
  *
  * @return string
  */
 private function populate_post_type($post_type)
 {
     $post_id = papi_get_post_id();
     if ($post_id !== 0) {
         return get_post_type($post_id);
     }
     // Get the post type that we currently are on if it exist in the array of post types.
     $post_type = array_filter(papi_to_array($post_type), function ($post_type) {
         // Support fake post types.
         if (strpos($post_type, '_papi') !== false) {
             return true;
         }
         return !empty($post_type) && strtolower($post_type) === strtolower(papi_get_or_post('post_type'));
     });
     if (!empty($post_type)) {
         return $post_type[0];
     }
     return 'page';
 }
开发者ID:KristoferN,项目名称:papi,代码行数:26,代码来源:class-papi-admin-meta-box.php

示例13: get_value

 /**
  * Get value from the database.
  *
  * @return float|int
  */
 public function get_value()
 {
     return $this->format_value(parent::get_value(), $this->get_slug(), papi_get_post_id());
 }
开发者ID:ekandreas,项目名称:papi,代码行数:9,代码来源:class-papi-property-number.php

示例14: html

    /**
     * Render property html.
     */
    public function html()
    {
        $post_id = papi_get_post_id();
        $slug = $this->html_name();
        $settings = $this->get_settings();
        $settings_json = [];
        $sort_option = $this->get_sort_option($post_id);
        $sort_options = static::get_sort_options();
        $values = papi_get_only_objects($this->get_value());
        $items = $this->get_items($settings);
        if (papi_is_empty($settings->items)) {
            $values = array_map([$this, 'convert_post_to_item'], $values);
        } else {
            foreach (array_keys($sort_options) as $key) {
                if (strpos($key, 'Post') === 0) {
                    unset($sort_options[$key]);
                }
            }
        }
        // Remove existing values if `only once` is active.
        if ($this->get_setting('only_once')) {
            $items = array_udiff($items, $values, function ($a, $b) {
                // Backwards compatibility with both `post_title` and `title`.
                return strcmp(strtolower(isset($a->post_title) ? $a->post_title : $a->title), strtolower(isset($b->post_title) ? $b->post_title : $b->title));
            });
        }
        // Convert all sneak case key to camel case.
        foreach ((array) $settings as $key => $val) {
            if (!is_string($key) || !in_array($key, ['only_once', 'limit'], true)) {
                continue;
            }
            if ($key = papi_camel_case($key)) {
                $settings_json[$key] = $val;
            }
        }
        ?>
		<div class="papi-property-relationship" data-settings='<?php 
        echo esc_attr(papi_maybe_json_encode($settings_json));
        ?>
'>
			<input type="hidden" name="<?php 
        echo esc_attr($slug);
        ?>
[]" data-papi-rule="<?php 
        echo esc_attr($slug);
        ?>
" />
			<div class="relationship-inner">
				<div class="relationship-top-left">
					<label for="<?php 
        echo esc_attr($this->html_id('search'));
        ?>
"><?php 
        esc_html_e('Search', 'papi');
        ?>
</label>
					<input id="<?php 
        echo esc_attr($this->html_id('search'));
        ?>
" type="search" />
				</div>
				<div class="relationship-top-right">
					<?php 
        if ($settings->show_sort_by) {
            ?>
						<label for="<?php 
            echo esc_attr($this->html_id('sort_option'));
            ?>
"><?php 
            esc_html_e('Sort by', 'papi');
            ?>
</label>
						<select id="<?php 
            echo esc_attr($this->html_id('sort_option'));
            ?>
" name="<?php 
            echo esc_attr($this->html_id('sort_option'));
            ?>
">
							<?php 
            foreach (array_keys($sort_options) as $key) {
                ?>
								<option value="<?php 
                echo esc_attr($key);
                ?>
" <?php 
                echo $key === $sort_option ? 'selected="selected"' : '';
                ?>
><?php 
                echo esc_html($key);
                ?>
</option>
							<?php 
            }
            ?>
						</select>
					<?php 
//.........这里部分代码省略.........
开发者ID:nlemoine,项目名称:papi,代码行数:101,代码来源:class-papi-property-relationship.php

示例15: factory

 /**
  * Get page from factory.
  *
  * @param  int    $post_id
  * @param  string $type
  *
  * @return mixed
  */
 public static function factory($post_id, $type = self::TYPE_POST)
 {
     if (papi_is_option_page()) {
         $type = self::TYPE_OPTION;
     }
     $class_suffix = '_' . ucfirst($type) . '_Page';
     $class_name = 'Papi' . $class_suffix;
     if (!class_exists($class_name)) {
         return;
     }
     $post_id = papi_get_post_id($post_id);
     $page = new $class_name($post_id);
     $page->set_type($type);
     if (!$page->valid()) {
         return;
     }
     return $page;
 }
开发者ID:KristoferN,项目名称:papi,代码行数:26,代码来源:class-papi-core-page.php


注:本文中的papi_get_post_id函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。