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


PHP post_type_supports函数代码示例

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


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

示例1: hybrid_get_content_template

/**
 * Loads a post content template based off the post type and/or the post format.  This functionality is 
 * not feasible with the WordPress get_template_part() function, so we have to rely on some custom logic 
 * and locate_template().
 *
 * Note that using this function assumes that you're creating a content template to handle attachments. 
 * This filter must be removed since we're bypassing the WP template hierarchy and focusing on templates 
 * specific to the content.
 *
 * @since  1.6.0
 * @access public
 * @return string
 */
function hybrid_get_content_template()
{
    /* Set up an empty array and get the post type. */
    $templates = array();
    $post_type = get_post_type();
    /* Assume the theme developer is creating an attachment template. */
    if ('attachment' === $post_type) {
        remove_filter('the_content', 'prepend_attachment');
        $mime_type = get_post_mime_type();
        list($type, $subtype) = false !== strpos($mime_type, '/') ? explode('/', $mime_type) : array($mime_type, '');
        $templates[] = "content-attachment-{$type}.php";
        $templates[] = "content/attachment-{$type}.php";
    }
    /* If the post type supports 'post-formats', get the template based on the format. */
    if (post_type_supports($post_type, 'post-formats')) {
        /* Get the post format. */
        $post_format = get_post_format() ? get_post_format() : 'standard';
        /* Template based off post type and post format. */
        $templates[] = "content-{$post_type}-{$post_format}.php";
        $templates[] = "content/{$post_type}-{$post_format}.php";
        /* Template based off the post format. */
        $templates[] = "content-{$post_format}.php";
        $templates[] = "content/{$post_format}.php";
    }
    /* Template based off the post type. */
    $templates[] = "content-{$post_type}.php";
    $templates[] = "content/{$post_type}.php";
    /* Fallback 'content.php' template. */
    $templates[] = 'content.php';
    $templates[] = 'content/content.php';
    /* Allow devs to filter the content template hierarchy. */
    $templates = apply_filters('hybrid_content_template_hierarchy', $templates);
    /* Apply filters and return the found content template. */
    include apply_filters('hybrid_content_template', locate_template($templates, false, false));
}
开发者ID:highergroundstudio,项目名称:hybrid-core,代码行数:48,代码来源:template.php

示例2: stormbringer_body_class

/**
 * Body Class - Thanks to Theme Hyprid (http://themehybrid.com/)
 */
function stormbringer_body_class($classes = '')
{
    global $wp_query;
    global $current_user;
    // User role
    $current_user->ID;
    $user = new WP_User($current_user->ID);
    // $user->roles
    foreach ($user->roles as $role) {
        $classes[] = 'role-' . $role;
    }
    /* Text direction (which direction does the text flow). */
    $classes[] = 'wordpress';
    $classes[] = get_bloginfo('text_direction');
    $classes[] = get_locale();
    /* Check if the current theme is a parent or child theme. */
    $classes[] = is_child_theme() ? 'child-theme' : 'parent-theme';
    /* Multisite check adds the 'multisite' class and the blog ID. */
    if (is_multisite()) {
        $classes[] = 'multisite';
        $classes[] = 'blog-' . get_current_blog_id();
    }
    /* Date classes. */
    $time = time() + get_option('gmt_offset') * 3600;
    $classes[] = strtolower(gmdate('\\yY \\mm \\dd \\hH l', $time));
    /* Is the current user logged in. */
    $classes[] = is_user_logged_in() ? 'logged-in' : 'logged-out';
    /* WP admin bar. */
    if (is_admin_bar_showing()) {
        $classes[] = 'admin-bar';
    }
    /* Merge base contextual classes with $classes. */
    $classes = array_merge($classes, stormbringer_get_context());
    /* Singular post (post_type) classes. */
    if (is_singular()) {
        /* Get the queried post object. */
        $post = get_queried_object();
        /* Checks for custom template. */
        $template = str_replace(array("{$post->post_type}-template-", "{$post->post_type}-", '.php'), '', get_post_meta(get_queried_object_id(), "_wp_{$post->post_type}_template", true));
        if (!empty($template)) {
            $classes[] = "{$post->post_type}-template-{$template}";
        }
        /* Post format. */
        if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats')) {
            $post_format = get_post_format(get_queried_object_id());
            $classes[] = empty($post_format) || is_wp_error($post_format) ? "{$post->post_type}-format-standard" : "{$post->post_type}-format-{$post_format}";
        }
        /* Attachment mime types. */
        if (is_attachment()) {
            foreach (explode('/', get_post_mime_type()) as $type) {
                $classes[] = "attachment-{$type}";
            }
        }
    }
    /* Paged views. */
    if ((($page = $wp_query->get('paged')) || ($page = $wp_query->get('page'))) && $page > 1) {
        $classes[] = 'paged paged-' . intval($page);
    }
    return $classes;
}
开发者ID:nicomollet,项目名称:stormbringer,代码行数:63,代码来源:bodyclass.php

示例3: save

 /**
  * Save the custom Status, used when posting to an Fan Page's Timeline
  *
  * @since 1.0
  * @param int $post_id post identifier
  */
 public static function save($post_id)
 {
     // verify if this is an auto save routine.
     // If it is our form has not been submitted, so we dont want to do anything
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     // verify this came from the our screen and with proper authorization,
     // because save_post can be triggered at other times
     if (!isset($_POST[self::FIELD_MESSAGE]) || empty($_POST[self::NONCE_NAME]) || !wp_verify_nonce($_POST[self::NONCE_NAME], plugin_basename(__FILE__))) {
         return;
     }
     // Check permissions
     $post_type = get_post_type($post_id);
     if (!($post_type && post_type_supports($post_type, 'author'))) {
         return;
     }
     if (!class_exists('Facebook_Social_Publisher')) {
         require_once dirname(__FILE__) . '/social_publisher.php';
     }
     $capability_singular_base = Facebook_Social_Publisher::post_type_capability_base($post_type);
     if (!current_user_can('edit_' . $capability_singular_base, $post_id)) {
         return;
     }
     $message = trim(sanitize_text_field($_POST[self::FIELD_MESSAGE]));
     if ($message) {
         update_post_meta($post_id, self::POST_META_KEY, $message);
     }
 }
开发者ID:hscale,项目名称:webento,代码行数:35,代码来源:publish-box-profile.php

示例4: sync_post_module_custom_data

 function sync_post_module_custom_data($custom_data, $post)
 {
     if (post_type_supports(get_post_type($post), 'publicize')) {
         $custom_data['cpt_publicizeable'] = true;
     }
     return $custom_data;
 }
开发者ID:moushegh,项目名称:blog-source-configs,代码行数:7,代码来源:publicize.php

示例5: bp_activity_mentions_script

/**
 * Enqueue @mentions JS.
 *
 * @since 2.1.0
 */
function bp_activity_mentions_script()
{
    if (!bp_activity_maybe_load_mentions_scripts()) {
        return;
    }
    // Special handling for New/Edit screens in wp-admin.
    if (is_admin()) {
        if (!get_current_screen() || !in_array(get_current_screen()->base, array('page', 'post')) || !post_type_supports(get_current_screen()->post_type, 'editor')) {
            return;
        }
    }
    $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
    wp_enqueue_script('bp-mentions', buddypress()->plugin_url . "bp-activity/js/mentions{$min}.js", array('jquery', 'jquery-atwho'), bp_get_version(), true);
    wp_enqueue_style('bp-mentions-css', buddypress()->plugin_url . "bp-activity/css/mentions{$min}.css", array(), bp_get_version());
    wp_style_add_data('bp-mentions-css', 'rtl', true);
    if ($min) {
        wp_style_add_data('bp-mentions-css', 'suffix', $min);
    }
    // If the script has been enqueued, let's attach our mentions TinyMCE init callback.
    add_filter('tiny_mce_before_init', 'bp_add_mentions_on_tinymce_init', 10, 2);
    /**
     * Fires at the end of the Activity Mentions script.
     *
     * This is the hook where BP components can add their own prefetched results
     * friends to the page for quicker @mentions lookups.
     *
     * @since 2.1.0
     */
    do_action('bp_activity_mentions_prime_results');
}
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:35,代码来源:bp-activity-cssjs.php

示例6: fully_background_setup

 public function fully_background_setup()
 {
     if (!is_singular()) {
         return;
     }
     $post = get_queried_object();
     $post_id = get_queried_object_id();
     if (!post_type_supports($post->post_type, 'fully-background-manager')) {
         return;
     }
     $this->color = get_post_meta($post_id, '_fully_background_color', true);
     $is_layout = get_post_meta($post_id, '_fully_is_layout', true);
     $attachment_id = get_post_meta($post_id, '_fully_background_image_id', true);
     $pattern_image = get_post_meta($post_id, '_fully_background_pattern', true);
     if ($is_layout == "Yes" && $pattern_image != "") {
         $image = $this->plugin_path . "assets/images/big/" . $pattern_image . ".jpg";
         $this->image = !empty($image) ? esc_url($image) : '';
     }
     if ($is_layout == "No") {
         $image = wp_get_attachment_image_src($attachment_id, 'full');
         $this->image = !empty($image) && isset($image[0]) ? esc_url($image[0]) : '';
     }
     add_filter('theme_mod_background_color', array($this, 'fbm_background_color'), 25);
     add_filter('theme_mod_background_image', array($this, 'fbm_background_image'), 25);
     if (!empty($this->image)) {
         $this->attachment = get_post_meta($post_id, '_fully_background_attachment', true);
         $this->repeat = get_post_meta($post_id, '_fully_background_repeat', true);
         add_filter('theme_mod_background_attachment', array($this, 'fbm_background_attachment'), 25);
         add_filter('theme_mod_background_repeat', array($this, 'fbm_background_repeat'), 25);
     }
 }
开发者ID:noc107,项目名称:Web-Capreso,代码行数:31,代码来源:fully-backgrounds-frontend.php

示例7: chuchadon_infinite_scroll_render

/**
 * Custom render function for Infinite Scroll.
 */
function chuchadon_infinite_scroll_render()
{
    while (have_posts()) {
        the_post();
        get_template_part('template-parts/content', post_type_supports(get_post_type(), 'post-formats') ? get_post_format() : get_post_type());
    }
}
开发者ID:samikeijonen,项目名称:chuchadon,代码行数:10,代码来源:jetpack.php

示例8: add_meta_box

 static function add_meta_box()
 {
     if (!post_type_supports(get_post_type(), 'author')) {
         return;
     }
     add_meta_box('byline', __('Byline', 'byline'), array(__CLASS__, 'display_meta_box'), get_post_type());
 }
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:7,代码来源:byline.php

示例9: wp_cta_change_excerpt_to_summary

function wp_cta_change_excerpt_to_summary()
{
    $post_type = "wp-call-to-action";
    if (post_type_supports($post_type, 'excerpt')) {
        add_meta_box('postexcerpt', __('Short Description', 'cta'), 'post_excerpt_meta_box', $post_type, 'normal', 'core');
    }
}
开发者ID:hkarriche,项目名称:wordpress,代码行数:7,代码来源:module.post-type.php

示例10: wp_edit

 function wp_edit()
 {
     global $post_type, $wp_query;
     if ($post_type != GALLERY_POST_TYPE_SLUG) {
         return;
     }
     if (!current_user_can('edit_others_pages') || !post_type_supports($post_type, 'page-attributes') && !is_post_type_hierarchical($post_type)) {
         // check permission
         return;
     }
     add_action('restrict_manage_posts', array($this, 'restrict_manage_posts'));
     // posts per page drop down UI
     if (isset($_GET['per_page']) && ($_GET['per_page'] == 99999 || $_GET['per_page'] % 10 == 0)) {
         update_user_option(get_current_user_id(), 'edit_' . $post_type . '_per_page', (int) $_GET['per_page']);
     }
     add_filter('views_' . get_current_screen()->id, array($this, 'sort_by_order_link'));
     // add view by menu order to views
     add_filter('contextual_help', array($this, 'contextual_help'));
     // add contextual help to hierarchical post screens
     #if ( $wp_query->query['orderby'] == 'menu_order title' ) {	// we can only sort if we're organized by menu order; WP 3.2 and 3.1 versions
     wp_enqueue_script('simple-page-ordering', THEMEURL . 'inc/gallery-ordering/simple-page-ordering.js', array('jquery-ui-sortable'), '0.9.7', true);
     $js_trans = array('RepositionTree' => __("Items can only be repositioned within their current branch in the page tree / hierarchy (next to pages with the same parent).\n\nIf you want to move this item into a different part of the page tree, use the Quick Edit feature to change the parent before continuing.", TD));
     #wp_localize_script( 'simple-page-ordering', 'simple_page_ordering_l10n', $js_trans );
     #}
 }
开发者ID:w392807287,项目名称:FirstRepository,代码行数:25,代码来源:simple-page-ordering.php

示例11: fb_comments_automatic

function fb_comments_automatic($content)
{
    global $post;
    if (isset($post)) {
        if (comments_open(get_the_ID()) && post_type_supports(get_post_type(), 'comments')) {
            $options = get_option('fb_options');
            $show_indiv = get_post_meta($post->ID, 'fb_social_plugin_settings_box_comments', true);
            if (!is_home() && ('default' == $show_indiv || empty($show_indiv)) && isset($options['comments']['show_on']) && isset($options['comments']['show_on'][$post->post_type])) {
                foreach ($options['comments'] as $param => $val) {
                    $param = str_replace('_', '-', $param);
                    $params[$param] = $val;
                }
                $content .= fb_get_comments($params);
            } else {
                if ('show' == $show_indiv || !isset($options['comments']['show_on']) && ('default' == $show_indiv || empty($show_indiv))) {
                    foreach ($options['comments'] as $param => $val) {
                        $param = str_replace('_', '-', $param);
                        $params[$param] = $val;
                    }
                    $content .= fb_get_comments($params);
                }
            }
            //elseif ( 'no' == $show_indiv ) {
            //}
        }
    }
    return $content;
}
开发者ID:nishantcbse,项目名称:wordpress,代码行数:28,代码来源:fb-comments.php

示例12: lp_change_excerpt_to_summary

function lp_change_excerpt_to_summary()
{
    $post_type = "landing-page";
    if (post_type_supports($post_type, 'excerpt')) {
        add_meta_box('postexcerpt', __('Short Description', 'landing-pages'), 'post_excerpt_meta_box', $post_type, 'normal', 'core');
    }
}
开发者ID:devilcranx,项目名称:landing-pages,代码行数:7,代码来源:module.post-type.php

示例13: ctslider_show_slidecaption_1_box

/**
 * Display the meta boxes
 *
 * @access      private
 * @since       1.0.0
 * @return      void
 */
function ctslider_show_slidecaption_1_box()
{
    global $post, $ctslider_slidecaption_1_metabox, $ctslider_prefix, $wp_version;
    // Use nonce for verification
    echo '<input type="hidden" name="ctslider_slidecaption_1_meta_box_nonce" value="' . wp_create_nonce(basename(__FILE__)) . '" />';
    echo '<table class="form-table">';
    foreach ($ctslider_slidecaption_1_metabox['fields'] as $field) {
        $meta = get_post_meta($post->ID, $field['id'], true);
        echo '<tr>', '<th style="width:20%"><label for="', $field['id'], '">', stripslashes($field['name']), '</label></th>', '<td class="ctslider_field_type_' . str_replace(' ', '_', $field['type']) . '">';
        switch ($field['type']) {
            case 'text':
                echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" style="width:97%" /><br/>', '', __(stripslashes($field['desc']), 'ctslider');
                break;
            case 'textarea':
                if ($field['rich_editor'] == 1) {
                    if ($wp_version >= 3.3) {
                        echo wp_editor($meta, $field['id'], array('textarea_name' => $field['id']));
                    } else {
                        $editor = '';
                        if (!post_type_supports($post->post_type, 'editor')) {
                            $editor = wp_tiny_mce(true, array('editor_selector' => $field['class'], 'remove_linebreaks' => false));
                        }
                        $field_html = '<div style="width: 97%; border: 1px solid #DFDFDF;"><textarea name="' . $field['id'] . '" class="' . $field['class'] . '" id="' . $field['id'] . '" cols="60" rows="8" style="width:100%">' . $meta . '</textarea></div><br/>' . __(stripslashes($field['desc']), 'ctslider');
                        echo $editor . $field_html;
                    }
                } else {
                    echo '<div style="width: 100%;"><textarea name="', $field['id'], '" class="', $field['class'], '" id="', $field['id'], '" cols="60" rows="8" style="width:97%">', $meta ? $meta : $field['std'], '</textarea></div>', '', __(stripslashes($field['desc']), 'ctslider');
                }
                break;
        }
        echo '<td>', '</tr>';
    }
    echo '</table>';
}
开发者ID:krbvroc1,项目名称:Captain-Slider,代码行数:41,代码来源:meta-box.php

示例14: getCommentsEnabled

 /**
  * Označení zda jsou komentáře povoleny (obecně i pro příspěvek)
  * 
  * @author Martin Hlaváč
  * @link http://www.ktstudio.cz
  * 
  * @return boolean
  */
 public function getCommentsEnabled()
 {
     if (KT::issetAndNotEmpty($this->commentsEnabled)) {
         return $this->commentsEnabled;
     }
     return $this->commentsEnabled = comments_open($this->getPostId()) && post_type_supports(KT_PRODUCT_KEY, "comments") && !post_password_required($this->getPost());
 }
开发者ID:Nodonisko,项目名称:WP-Framework,代码行数:15,代码来源:kt_wp_comments_base_presenter.inc.php

示例15: motopressCEAddTools

function motopressCEAddTools()
{
    require_once 'includes/ce/Access.php';
    $ceAccess = new MPCEAccess();
    $motopressCELibrary = new MPCELibrary();
    do_action_ref_array('mp_library', array(&$motopressCELibrary));
    $postType = get_post_type();
    $postTypes = get_option('motopress-ce-options');
    if (!$postTypes) {
        $postTypes = array();
    }
    if (in_array($postType, $postTypes) && post_type_supports($postType, 'editor') && $ceAccess->hasAccess()) {
        global $motopressCESettings;
        wp_localize_script('jquery', 'motopress', $motopressCESettings['motopress_localize']);
        wp_localize_script('jquery', 'motopressCE', array('postID' => get_the_ID(), 'nonces' => array('motopress_ce_get_wp_settings' => wp_create_nonce('wp_ajax_motopress_ce_get_wp_settings'), 'motopress_ce_render_content' => wp_create_nonce('wp_ajax_motopress_ce_render_content'), 'motopress_ce_remove_temporary_post' => wp_create_nonce('wp_ajax_motopress_ce_remove_temporary_post'), 'motopress_ce_get_library' => wp_create_nonce('wp_ajax_motopress_ce_get_library'), 'motopress_ce_render_shortcode' => wp_create_nonce('wp_ajax_motopress_ce_render_shortcode'), 'motopress_ce_get_attachment_thumbnail' => wp_create_nonce('wp_ajax_motopress_ce_get_attachment_thumbnail'), 'motopress_ce_colorpicker_update_palettes' => wp_create_nonce('wp_ajax_motopress_ce_colorpicker_update_palettes'), 'motopress_ce_render_youtube_bg' => wp_create_nonce('wp_ajax_motopress_ce_render_youtube_bg'), 'motopress_ce_render_video_bg' => wp_create_nonce('wp_ajax_motopress_ce_render_video_bg'))));
        add_action('admin_head', 'motopressCEAddCEBtn');
        add_action('admin_footer', 'motopressCEHTML');
        //admin_head
        motopressCECheckDomainMapping();
        wp_register_style('mpce-style', plugin_dir_url(__FILE__) . 'includes/css/style.css', null, $motopressCESettings['plugin_version']);
        wp_enqueue_style('mpce-style');
        wp_register_style('mpce', plugin_dir_url(__FILE__) . 'mp/ce/css/ce.css', null, $motopressCESettings['plugin_version']);
        wp_enqueue_style('mpce');
        wp_register_script('mpce-knob', plugin_dir_url(__FILE__) . 'knob/jquery.knob.min.js', array(), $motopressCESettings['plugin_version']);
        wp_enqueue_script('mpce-knob');
        if (get_user_meta(get_current_user_id(), 'rich_editing', true) === 'false' && !wp_script_is('editor')) {
            wp_enqueue_script('editor');
        }
        wp_enqueue_script('wp-link');
    }
}
开发者ID:Anciela,项目名称:anciela.info,代码行数:31,代码来源:contentEditor.php


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