本文整理汇总了PHP中get_post_format_strings函数的典型用法代码示例。如果您正苦于以下问题:PHP get_post_format_strings函数的具体用法?PHP get_post_format_strings怎么用?PHP get_post_format_strings使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_post_format_strings函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct($args)
{
if (is_array($this->post_object_format) && isset($this->post_object_format['format'])) {
$this->post_object_format['format'] = get_post_format_strings();
}
if (!$this->response_format) {
$this->response_format =& $this->post_object_format;
}
parent::__construct($args);
}
示例2: get_post_formats
function get_post_formats()
{
// deprecated - see separate endpoint. get a list of supported post formats
$all_formats = get_post_format_strings();
$supported = $this->get_theme_support('post-formats');
$supported_formats = array();
if (isset($supported[0])) {
foreach ($supported[0] as $format) {
$supported_formats[$format] = $all_formats[$format];
}
}
return $supported_formats;
}
示例3: A_show_post_formats
function A_show_post_formats($key, $details)
{
$table = maybe_unserialize($details->feed_meta);
echo "<tr>";
echo "<td valign='top' class='heading'>";
echo __('Post format for new posts', 'autoblogtext');
echo "</td>";
echo "<td valign='top' class=''>";
$formats = get_post_format_strings();
echo "<select name='abtble[postformat]' class='field'>";
foreach ($formats as $key => $format) {
echo "<option value='" . $key . "'";
echo $table['postformat'] == $key ? " selected='selected'" : "";
echo ">" . $format . "</option>";
}
echo "</select>" . "<a href='#' class='info' title='" . __('Select the post format the imported posts will have in the blog.', 'autoblogtext') . "'></a>";
echo "</td>";
echo "</tr>\n";
}
示例4: _get_es_filters_from_args
/**
* Creates an array of ElasticSearch filters based on the post_id and args.
*
* @param int $post_id
* @param array $args
* @uses apply_filters, get_post_types, get_post_format_strings
* @return array
*/
protected function _get_es_filters_from_args($post_id, array $args)
{
$filters = array();
/**
* Filter the terms used to search for Related Posts.
*
* @module related-posts
*
* @since 2.8.0
*
* @param array $args['has_terms'] Array of terms associated to the Related Posts.
* @param string $post_id Post ID of the post for which we are retrieving Related Posts.
*/
$args['has_terms'] = apply_filters('jetpack_relatedposts_filter_has_terms', $args['has_terms'], $post_id);
if (!empty($args['has_terms'])) {
foreach ((array) $args['has_terms'] as $term) {
if (mb_strlen($term->taxonomy)) {
switch ($term->taxonomy) {
case 'post_tag':
$tax_fld = 'tag.slug';
break;
case 'category':
$tax_fld = 'category.slug';
break;
default:
$tax_fld = 'taxonomy.' . $term->taxonomy . '.slug';
break;
}
$filters[] = array('term' => array($tax_fld => $term->slug));
}
}
}
/**
* Filter the Post Types where we search Related Posts.
*
* @module related-posts
*
* @since 2.8.0
*
* @param array $args['post_type'] Array of Post Types.
* @param string $post_id Post ID of the post for which we are retrieving Related Posts.
*/
$args['post_type'] = apply_filters('jetpack_relatedposts_filter_post_type', $args['post_type'], $post_id);
$valid_post_types = get_post_types();
if (is_array($args['post_type'])) {
$sanitized_post_types = array();
foreach ($args['post_type'] as $pt) {
if (in_array($pt, $valid_post_types)) {
$sanitized_post_types[] = $pt;
}
}
if (!empty($sanitized_post_types)) {
$filters[] = array('terms' => array('post_type' => $sanitized_post_types));
}
} else {
if (in_array($args['post_type'], $valid_post_types) && 'all' != $args['post_type']) {
$filters[] = array('term' => array('post_type' => $args['post_type']));
}
}
/**
* Filter the Post Formats where we search Related Posts.
*
* @module related-posts
*
* @since 3.3.0
*
* @param array $args['post_formats'] Array of Post Formats.
* @param string $post_id Post ID of the post for which we are retrieving Related Posts.
*/
$args['post_formats'] = apply_filters('jetpack_relatedposts_filter_post_formats', $args['post_formats'], $post_id);
$valid_post_formats = get_post_format_strings();
$sanitized_post_formats = array();
foreach ($args['post_formats'] as $pf) {
if (array_key_exists($pf, $valid_post_formats)) {
$sanitized_post_formats[] = $pf;
}
}
if (!empty($sanitized_post_formats)) {
$filters[] = array('terms' => array('post_format' => $sanitized_post_formats));
}
/**
* Filter the date range used to search Related Posts.
*
* @module related-posts
*
* @since 2.8.0
*
* @param array $args['date_range'] Array of a month interval where we search Related Posts.
* @param string $post_id Post ID of the post for which we are retrieving Related Posts.
*/
$args['date_range'] = apply_filters('jetpack_relatedposts_filter_date_range', $args['date_range'], $post_id);
if (is_array($args['date_range']) && !empty($args['date_range'])) {
//.........这里部分代码省略.........
示例5: callback
function callback($path = '', $blog_id = 0)
{
$blog_id = $this->api->switch_to_blog_and_validate_user($this->api->get_blog_id($blog_id));
if (is_wp_error($blog_id)) {
return $blog_id;
}
if (defined('IS_WPCOM') && IS_WPCOM) {
$this->load_theme_functions();
}
// Get a list of supported post formats.
$all_formats = get_post_format_strings();
$supported = get_theme_support('post-formats');
$supported_formats = $response['formats'] = array();
if (isset($supported[0])) {
foreach ($supported[0] as $format) {
$supported_formats[$format] = $all_formats[$format];
}
}
$response['formats'] = (object) $supported_formats;
return $response;
}
示例6: render_location_value
function render_location_value($options)
{
// vars
$options = wp_parse_args($options, array('group_id' => 0, 'rule_id' => 0, 'value' => null, 'param' => null));
// vars
$choices = array();
// some case's have the same outcome
if ($options['param'] == "page_parent") {
$options['param'] = "page";
}
switch ($options['param']) {
/*
* Basic
*/
case "post_type":
// all post types except attachment
$exclude = array('attachment');
$choices = acf_get_post_types($exclude);
$choices = acf_get_pretty_post_types($choices);
break;
case "user_type":
global $wp_roles;
$choices = $wp_roles->get_names();
if (is_multisite()) {
$choices['super_admin'] = __('Super Admin');
}
break;
/*
* Post
*/
/*
* Post
*/
case "post":
// get post types
$exclude = array('page', 'attachment');
$post_types = acf_get_post_types($exclude);
// get posts grouped by post type
$groups = acf_get_posts(array('post_type' => $post_types));
if (!empty($groups)) {
foreach (array_keys($groups) as $group_title) {
// vars
$posts = acf_extract_var($groups, $group_title);
// override post data
foreach (array_keys($posts) as $post_id) {
// update
$posts[$post_id] = acf_get_post_title($posts[$post_id]);
}
// append to $choices
$choices[$group_title] = $posts;
}
}
break;
case "post_category":
$terms = acf_get_taxonomy_terms('category');
if (!empty($terms)) {
$choices = array_pop($terms);
}
break;
case "post_format":
$choices = get_post_format_strings();
break;
case "post_status":
$choices = array('publish' => __('Publish', 'acf'), 'pending' => __('Pending Review', 'acf'), 'draft' => __('Draft', 'acf'), 'future' => __('Future', 'acf'), 'private' => __('Private', 'acf'), 'inherit' => __('Revision', 'acf'), 'trash' => __('Trash', 'acf'));
break;
case "post_taxonomy":
$choices = acf_get_taxonomy_terms();
// unset post_format
if (isset($choices['post_format'])) {
unset($choices['post_format']);
}
break;
/*
* Page
*/
/*
* Page
*/
case "page":
// get posts grouped by post type
$groups = acf_get_posts(array('post_type' => 'page'));
if (!empty($groups)) {
foreach (array_keys($groups) as $group_title) {
// vars
$posts = acf_extract_var($groups, $group_title);
// override post data
foreach (array_keys($posts) as $post_id) {
// update
$posts[$post_id] = acf_get_post_title($posts[$post_id]);
}
// append to $choices
$choices = $posts;
}
}
break;
case "page_type":
$choices = array('front_page' => __("Front Page", 'acf'), 'posts_page' => __("Posts Page", 'acf'), 'top_level' => __("Top Level Page (parent of 0)", 'acf'), 'parent' => __("Parent Page (has children)", 'acf'), 'child' => __("Child Page (has parent)", 'acf'));
break;
case "page_parent":
// refer to "page"
//.........这里部分代码省略.........
示例7: get_theme_support
}
?>
</td>
</tr>
<?php
}
?>
<?php
if (current_theme_supports('post-formats')) {
?>
<?php
$post_formats = get_theme_support('post-formats');
if (is_array($post_formats[0])) {
$formatName = get_post_format_strings();
?>
<tr>
<td style="padding:0 0 10px 0;"><?php
echo __('Post Format', 'wp-autopost');
?>
:</td>
<td style="padding:0 0 10px 0;">
<input type="radio" name="post_format" value="" <?php
if ($config->post_format == '' || $config->post_format == null) {
echo 'checked="true"';
}
?>
/> <?php
echo $formatName['standard'];
?>
示例8: ajax_acf_location
function ajax_acf_location($options = array())
{
// defaults
$defaults = array('key' => null, 'value' => null, 'param' => null);
// Is AJAX call?
if (isset($_POST['action']) && $_POST['action'] == "acf_location") {
$options = array_merge($defaults, $_POST);
} else {
$options = array_merge($defaults, $options);
}
// some case's have the same outcome
if ($options['param'] == "page_parent") {
$options['param'] = "page";
}
$choices = array();
$optgroup = false;
switch ($options['param']) {
case "post_type":
$choices = get_post_types(array('public' => true));
unset($choices['attachment']);
break;
case "page":
$pages = get_pages(array('numberposts' => -1, 'post_type' => 'page', 'sort_column' => 'menu_order', 'order' => 'ASC', 'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'), 'suppress_filters' => false));
foreach ($pages as $page) {
$title = '';
$ancestors = get_ancestors($page->ID, 'page');
if ($ancestors) {
foreach ($ancestors as $a) {
$title .= '- ';
}
}
$title .= apply_filters('the_title', $page->post_title, $page->ID);
// status
if ($page->post_status != "publish") {
$title .= " ({$page->post_status})";
}
$choices[$page->ID] = $title;
}
break;
case "page_type":
$choices = array('parent' => __("Parent Page", 'acf'), 'child' => __("Child Page", 'acf'));
break;
case "page_template":
$choices = array('default' => __("Default Template", 'acf'));
$templates = get_page_templates();
foreach ($templates as $k => $v) {
$choices[$v] = $k;
}
break;
case "post":
$posts = get_posts(array('numberposts' => '-1', 'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'), 'suppress_filters' => false));
foreach ($posts as $post) {
$title = apply_filters('the_title', $post->post_title, $post->ID);
// status
if ($post->post_status != "publish") {
$title .= " ({$post->post_status})";
}
$choices[$post->ID] = $title;
}
break;
case "post_category":
$category_ids = get_all_category_ids();
foreach ($category_ids as $cat_id) {
$cat_name = get_cat_name($cat_id);
$choices[$cat_id] = $cat_name;
}
break;
case "post_format":
$choices = get_post_format_strings();
break;
case "user_type":
global $wp_roles;
$choices = $wp_roles->get_names();
break;
case "options_page":
$choices = array(__('Options', 'acf') => __('Options', 'acf'));
$custom = apply_filters('acf_register_options_page', array());
if (!empty($custom)) {
$choices = array();
foreach ($custom as $c) {
$choices[$c['slug']] = $c['title'];
}
}
break;
case "taxonomy":
$choices = $this->parent->get_taxonomies_for_select(array('simple_value' => true));
$optgroup = true;
break;
case "ef_taxonomy":
$choices = array('all' => __('All', 'acf'));
$taxonomies = get_taxonomies(array('public' => true), 'objects');
foreach ($taxonomies as $taxonomy) {
$choices[$taxonomy->name] = $taxonomy->labels->name;
}
// unset post_format (why is this a public taxonomy?)
if (isset($choices['post_format'])) {
unset($choices['post_format']);
}
break;
case "ef_user":
//.........这里部分代码省略.........
示例9: inline_edit
//.........这里部分代码省略.........
_e('Not Sticky');
?>
</option>
</select>
</label>
<?php
} else {
// $bulk
?>
<label class="alignleft">
<input type="checkbox" name="sticky" value="sticky" />
<span class="checkbox-title"><?php
_e('Make this post sticky');
?>
</span>
</label>
<?php
}
// $bulk
?>
<?php
}
// 'post' && $can_publish && current_user_can( 'edit_others_cap' )
?>
</div>
<?php
if ($bulk && post_type_supports($screen->post_type, 'post-formats')) {
$all_post_formats = get_post_format_strings();
?>
<label class="alignleft" for="post_format">
<span class="title"><?php
_ex('Format', 'post format');
?>
</span>
<select name="post_format">
<option value="-1"><?php
_e('— No Change —');
?>
</option>
<?php
foreach ($all_post_formats as $slug => $format) {
?>
<option value="<?php
echo esc_attr($slug);
?>
"><?php
echo esc_html($format);
?>
</option>
<?php
}
?>
</select></label>
<?php
}
?>
</div></fieldset>
<?php
示例10: ajax_render_location
function ajax_render_location($options = array())
{
// defaults
$defaults = array('group_id' => 0, 'rule_id' => 0, 'value' => null, 'param' => null);
$is_ajax = false;
if (isset($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], 'acf_nonce')) {
$is_ajax = true;
}
// Is AJAX call?
if ($is_ajax) {
$options = array_merge($defaults, $_POST);
} else {
$options = array_merge($defaults, $options);
}
// vars
$choices = array();
// some case's have the same outcome
if ($options['param'] == "page_parent") {
$options['param'] = "page";
}
switch ($options['param']) {
case "post_type":
// all post types except attachment
$choices = apply_filters('acf/get_post_types', array(), array('attachment'));
break;
case "page":
$post_type = 'page';
$posts = get_posts(array('posts_per_page' => -1, 'post_type' => $post_type, 'orderby' => 'menu_order title', 'order' => 'ASC', 'post_status' => 'any', 'suppress_filters' => false, 'update_post_meta_cache' => false));
if ($posts) {
// sort into hierachial order!
if (is_post_type_hierarchical($post_type)) {
$posts = get_page_children(0, $posts);
}
foreach ($posts as $page) {
$title = '';
$ancestors = get_ancestors($page->ID, 'page');
if ($ancestors) {
foreach ($ancestors as $a) {
$title .= '- ';
}
}
$title .= apply_filters('the_title', $page->post_title, $page->ID);
// status
if ($page->post_status != "publish") {
$title .= " ({$page->post_status})";
}
$choices[$page->ID] = $title;
}
// foreach($pages as $page)
}
break;
case "page_type":
$choices = array('front_page' => __("Front Page", 'acf'), 'posts_page' => __("Posts Page", 'acf'), 'top_level' => __("Top Level Page (parent of 0)", 'acf'), 'parent' => __("Parent Page (has children)", 'acf'), 'child' => __("Child Page (has parent)", 'acf'));
break;
case "page_template":
$choices = array('default' => __("Default Template", 'acf'));
$templates = get_page_templates();
foreach ($templates as $k => $v) {
$choices[$v] = $k;
}
break;
case "post":
$post_types = get_post_types();
unset($post_types['page'], $post_types['attachment'], $post_types['revision'], $post_types['nav_menu_item'], $post_types['acf']);
if ($post_types) {
foreach ($post_types as $post_type) {
$posts = get_posts(array('numberposts' => '-1', 'post_type' => $post_type, 'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'), 'suppress_filters' => false));
if ($posts) {
$choices[$post_type] = array();
foreach ($posts as $post) {
$title = apply_filters('the_title', $post->post_title, $post->ID);
// status
if ($post->post_status != "publish") {
$title .= " ({$post->post_status})";
}
$choices[$post_type][$post->ID] = $title;
}
// foreach($posts as $post)
}
// if( $posts )
}
// foreach( $post_types as $post_type )
}
// if( $post_types )
break;
case "post_category":
$category_ids = get_all_category_ids();
foreach ($category_ids as $cat_id) {
$cat_name = get_cat_name($cat_id);
$choices[$cat_id] = $cat_name;
}
break;
case "post_format":
$choices = get_post_format_strings();
break;
case "post_status":
$choices = array('publish' => __('Publish', 'acf'), 'pending' => __('Pending Review', 'acf'), 'draft' => __('Draft', 'acf'), 'future' => __('Future', 'acf'), 'private' => __('Private', 'acf'), 'inherit' => __('Revision', 'acf'), 'trash' => __('Trash', 'acf'));
break;
case "user_type":
global $wp_roles;
//.........这里部分代码省略.........
示例11: esc_attr_e
<ul class="clearfix">
<li class="post-format-pad"><a title="<?php
esc_attr_e('Standard', 'church-event');
?>
" href="<?php
echo esc_attr(add_query_arg('format_filter', 'standard', home_url()));
?>
" class="standard"><?php
echo do_shortcode('[icon name="' . WpvPostFormats::get_post_format_icon('standard') . '"]');
?>
</a></li>
<?php
$tooltip = empty($instance['tooltip']) ? __('View all %format posts', 'church-event') : esc_attr($instance['tooltip']);
foreach (get_post_format_strings() as $slug => $string) {
if (get_post_format_link($slug)) {
$post_format = get_term_by('slug', 'post-format-' . $slug, 'post_format');
if ($post_format->count > 0) {
echo '<li class="post-format-pad"><a title="' . esc_attr(str_replace('%format', $string, $tooltip)) . '" href="' . esc_attr(add_query_arg('format_filter', $slug, home_url())) . '" class="' . $slug . '">' . do_shortcode('[icon name="' . WpvPostFormats::get_post_format_icon($slug) . '"]') . '</a></li>';
}
}
}
?>
</ul>
示例12: wp_getPostFormats
/**
* Retrieves a list of post formats used by the site.
*
* @since 3.1.0
*
* @param array $args {
* Method arguments. Note: arguments must be ordered as documented.
*
* @type int $blog_id (unused)
* @type string $username
* @type string $password
* }
* @return array|IXR_Error List of post formats, otherwise IXR_Error object.
*/
public function wp_getPostFormats($args)
{
$this->escape($args);
$username = $args[1];
$password = $args[2];
if (!($user = $this->login($username, $password))) {
return $this->error;
}
if (!current_user_can('edit_posts')) {
return new IXR_Error(403, __('You are not allowed access to details about this site.'));
}
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action('xmlrpc_call', 'wp.getPostFormats');
$formats = get_post_format_strings();
// find out if they want a list of currently supports formats
if (isset($args[3]) && is_array($args[3])) {
if ($args[3]['show-supported']) {
if (current_theme_supports('post-formats')) {
$supported = get_theme_support('post-formats');
$data = array();
$data['all'] = $formats;
$data['supported'] = $supported[0];
$formats = $data;
}
}
}
return $formats;
}
示例13: default_content_filter
/**
* Try to make a nice comment
*
* @param string $context the comment-content
* @param string $contents the HTML of the source
* @param string $target the target URL
* @param string $source the source URL
*
* @return string the filtered content
*/
public static function default_content_filter($content, $contents, $target, $source)
{
// get post format
$post_ID = url_to_postid($target);
$post_format = get_post_format($post_ID);
// replace "standard" with "Article"
if (!$post_format || 'standard' == $post_format) {
$post_format = 'Article';
} else {
$post_formatstrings = get_post_format_strings();
// get the "nice" name
$post_format = $post_formatstrings[$post_format];
}
$host = parse_url($source, PHP_URL_HOST);
// strip leading www, if any
$host = preg_replace('/^www\\./', '', $host);
// generate default text
$content = sprintf(__('This %s was mentioned on <a href="%s">%s</a>', 'webmention'), $post_format, esc_url($source), $host);
return $content;
}
示例14: page_selectors
public static function page_selectors()
{
global $wp_post_types, $wp_taxonomies;
$res = q2w3_include_obj::page_selectors();
foreach ($wp_post_types as $post_type) {
if (!in_array($post_type->name, q2w3_inc_manager::$restricted_post_types)) {
$res += array($post_type->name . '_all' => __('All', q2w3_inc_manager::ID) . ' ' . $post_type->labels->name);
$res += array('post_type_archive_' . $post_type->name => __('Archive', q2w3_inc_manager::ID) . ': ' . $post_type->labels->name);
$selectors = self::select_post_type($post_type->name);
if (!empty($selectors)) {
$res += $selectors;
}
}
}
foreach ($wp_taxonomies as $taxonomy) {
if (!in_array($taxonomy->name, q2w3_inc_manager::$restricted_taxonomies)) {
$res += array($taxonomy->name . '_all' => __('All', q2w3_inc_manager::ID) . ' ' . $taxonomy->labels->name);
$selectors = self::select_taxonomy($taxonomy->name);
if (!empty($selectors)) {
$res += $selectors;
}
}
}
$formats_orig = get_post_format_strings();
foreach ($formats_orig as $fkey => $fname) {
$res['post_format_' . $fkey] = __('PF', $plugin_id) . ': ' . $fname;
}
return $res;
}
示例15: get_post_format_slugs
function get_post_format_slugs()
{
$slugs = array_keys(get_post_format_strings());
return array_combine($slugs, $slugs);
}