コード例 #1
1
/**
 * 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));
}
コード例 #2
0
ファイル: bodyclass.php プロジェクト: nicomollet/stormbringer
/**
 * 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;
}
コード例 #3
0
 /**
  * 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);
     }
 }
コード例 #4
0
 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;
 }
コード例 #5
0
/**
 * 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');
}
コード例 #6
0
 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);
     }
 }
コード例 #7
0
ファイル: jetpack.php プロジェクト: samikeijonen/chuchadon
/**
 * 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());
    }
}
コード例 #8
0
 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());
 }
コード例 #9
0
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');
    }
}
コード例 #10
0
 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 );
     #}
 }
コード例 #11
0
ファイル: fb-comments.php プロジェクト: nishantcbse/wordpress
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;
}
コード例 #12
0
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');
    }
}
コード例 #13
0
ファイル: meta-box.php プロジェクト: krbvroc1/Captain-Slider
/**
 * 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>';
}
コード例 #14
0
 /**
  * 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());
 }
コード例 #15
0
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');
    }
}
コード例 #16
0
 static function add_meta_box()
 {
     $post_type = get_post_type();
     if (post_type_supports($post_type, 'art-direction')) {
         add_meta_box('art-direction-redux', __('Art Direction Redux', 'art-direction-redux'), array(__CLASS__, 'display_meta_box'), $post_type, 'normal');
     }
 }
コード例 #17
0
 /**
  * @see CPAC_Column::apply_conditional()
  * @since 2.3.3
  */
 public function apply_conditional()
 {
     if (post_type_supports($this->storage_model->key, 'editor')) {
         return true;
     }
     return false;
 }
コード例 #18
0
/**
 * Plugin Name: WP REST API - Meta Endpoints
 * Description: Meta endpoints for the WP REST API
 * Author: WP REST API Team
 * Author URI: http://wp-api.org
 * Version: 0.1.0
 * Plugin URI: https://github.com/WP-API/wp-api-meta-endpoints
 * License: GPL2+
 */
function meta_rest_api_init()
{
    if (class_exists('WP_REST_Controller') && !class_exists('WP_REST_Meta_Controller')) {
        require_once dirname(__FILE__) . '/lib/class-wp-rest-meta-controller.php';
    }
    if (class_exists('WP_REST_Controller') && !class_exists('WP_REST_Meta_Posts_Controller')) {
        require_once dirname(__FILE__) . '/lib/class-wp-rest-meta-posts-controller.php';
    }
    if (class_exists('WP_REST_Controller') && !class_exists('WP_REST_Meta_Users_Controller')) {
        require_once dirname(__FILE__) . '/lib/class-wp-rest-meta-users-controller.php';
    }
    if (class_exists('WP_REST_Controller') && !class_exists('WP_REST_Meta_Comments_Controller')) {
        require_once dirname(__FILE__) . '/lib/class-wp-rest-meta-comments-controller.php';
    }
    if (class_exists('WP_REST_Controller') && !class_exists('WP_REST_Meta_Terms_Controller')) {
        require_once dirname(__FILE__) . '/lib/class-wp-rest-meta-terms-controller.php';
    }
    foreach (get_post_types(array('show_in_rest' => true), 'objects') as $post_type) {
        if (post_type_supports($post_type->name, 'custom-fields')) {
            $meta_controller = new WP_REST_Meta_Posts_Controller($post_type->name);
            $meta_controller->register_routes();
        }
    }
    foreach (get_taxonomies(array('show_in_rest' => true), 'objects') as $taxonomy) {
        $terms_meta_controller = new WP_REST_Meta_Terms_Controller($taxonomy->name);
        $terms_meta_controller->register_routes();
    }
    $user_meta_controller = new WP_REST_Meta_Users_Controller();
    $user_meta_controller->register_routes();
    $comment_meta_controller = new WP_REST_Meta_Comments_Controller();
    $comment_meta_controller->register_routes();
}
コード例 #19
0
ファイル: tab-basic.php プロジェクト: jimrucinski/Vine
 function _set_option_defaults()
 {
     $defaults = array();
     $post_type_descriptions = array('post' => __('Individual blog posts', 'it-l10n-Builder-Cohen'), 'page' => __('Individual pages', 'it-l10n-Builder-Cohen'), 'attachment' => __('When you upload images, they get their own Media page that shows the image. This option controls whether or not comments are enabled on these Media pages.', 'it-l10n-Builder-Cohen'), '' => __('Custom post type', 'it-l10n-Builder-Cohen'));
     $comment_post_types = array();
     if (function_exists('get_post_types') && function_exists('post_type_supports')) {
         $post_types = get_post_types(array(), 'objects');
         foreach ((array) $post_types as $post_type => $post_object) {
             $post_type_var = str_replace(' ', '_', $post_type);
             if (post_type_supports($post_type, 'comments')) {
                 $comment_post_types[$post_type_var] = array('name' => $post_object->labels->name);
             }
         }
     } else {
         $comment_post_types = array('post' => array('name' => 'Post'), 'page' => array('name' => 'Page'));
     }
     foreach (array_keys($comment_post_types) as $post_type) {
         if (isset($post_type_descriptions[$post_type])) {
             $comment_post_types[$post_type]['description'] = $post_type_descriptions[$post_type];
         } else {
             $comment_post_types[$post_type]['description'] = $post_type_descriptions[''];
         }
     }
     $comment_post_types = ITUtility::sort_array($comment_post_types, 'name');
     if (!is_array($comment_post_types)) {
         $comment_post_types = array();
     }
     foreach (array_keys($comment_post_types) as $post_type) {
         $defaults["enable_comments_{$post_type}"] = 1;
     }
     $this->_comment_post_types = $comment_post_types;
     $defaults['favicon_option'] = 'preset';
     $defaults['dashboard_favicon'] = 'on';
     $this->_options = array_merge($defaults, $this->_options);
 }
コード例 #20
0
 function copy_from_original()
 {
     global $post;
     if (!post_type_supports($post->post_type, 'editor')) {
         return;
     }
     global $wpml_post_translations, $sitepress;
     $show = false;
     $source_lang_name = false;
     $trid = null;
     $source_lang = filter_input(INPUT_GET, 'source_lang', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
     $source_lang = $source_lang === 'all' ? $sitepress->get_default_language() : $source_lang;
     $lang = filter_input(INPUT_GET, 'lang', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
     if ($source_lang && ($trid = filter_input(INPUT_GET, 'trid', FILTER_SANITIZE_NUMBER_INT))) {
         $_lang_details = $sitepress->get_language_details($source_lang);
         $source_lang_name = $_lang_details['display_name'];
         $show = true;
     } elseif (isset($_GET['post']) && $lang !== $sitepress->get_default_language()) {
         $source_lang = $wpml_post_translations->get_source_lang_code($post->ID);
         $_lang_details = $sitepress->get_language_details($source_lang);
         $source_lang_name = $_lang_details['display_name'];
         $show = $source_lang && $source_lang !== $lang;
     }
     if ($show && isset($source_lang)) {
         if (!$trid) {
             $trid = $wpml_post_translations->get_element_trid($post->ID);
         }
         $this->display_copy_from_button($source_lang, $source_lang_name, $post, $trid);
         $this->display_set_as_dupl_btn($post, $source_lang_name, $wpml_post_translations->get_original_post_ID($trid), $lang);
     }
 }
コード例 #21
0
 function action_init()
 {
     //syncing must wait until after init so
     //post types that support comments
     $filt_post_types = array();
     $all_post_types = get_post_types();
     foreach ($all_post_types as $post_type) {
         if (post_type_supports($post_type, 'comments')) {
             $filt_post_types[] = $post_type;
         }
     }
     Jetpack_Sync::sync_posts(__FILE__, array('post_types' => $filt_post_types, 'post_stati' => array('publish')));
     Jetpack_Sync::sync_comments(__FILE__, array('post_types' => $filt_post_types, 'post_stati' => array('publish'), 'comment_stati' => array('approve', 'approved', '1', 'hold', 'unapproved', 'unapprove', '0', 'spam', 'trash')));
     if (defined('DOING_AJAX') && DOING_AJAX) {
         return;
     }
     if (!has_filter('show_admin_bar', '__return_true') && !is_user_logged_in()) {
         return;
     }
     if (!self::current_browser_is_supported()) {
         return;
     }
     add_action('admin_bar_menu', array(&$this, 'admin_bar_menu'), 120);
     add_action('wp_head', array(&$this, 'styles_and_scripts'), 120);
     add_action('admin_head', array(&$this, 'styles_and_scripts'));
 }
 function setup_filters()
 {
     $types = array_keys(get_post_types(array('public' => true), 'objects'));
     if (!empty($types)) {
         foreach ($types as $type) {
             // we need to know what native support was for later
             if (post_type_supports($type, 'comments')) {
                 remove_post_type_support($type, 'comments');
                 remove_post_type_support($type, 'trackbacks');
             }
         }
     }
     // Filters for the admin only
     if (is_admin()) {
         add_action('admin_menu', array($this, 'filter_admin_menu'), 9999);
         // do this as late as possible
         add_action('admin_head', array($this, 'hide_dashboard_bits'));
         add_action('wp_dashboard_setup', array($this, 'filter_dashboard'));
         add_filter('pre_option_default_pingback_flag', '__return_zero');
     } else {
         add_action('template_redirect', array($this, 'check_comment_template'));
         add_filter('comments_open', array($this, 'filter_comment_status'), 20, 2);
         add_filter('pings_open', array($this, 'filter_comment_status'), 20, 2);
         // remove comments links from feed
         add_filter('post_comments_feed_link', '__return_false', 10, 1);
         add_filter('comments_link_feed', '__return_false', 10, 1);
         add_filter('comment_link', '__return_false', 10, 1);
         // remove comment count from feed
         add_filter('get_comments_number', '__return_false', 10, 2);
         // Remove feed link from header
         add_filter('feed_links_show_comments_feed', '__return_false');
         // run when wp_head executes
         add_action('wp_head', array($this, 'before_wp_head'), 0);
     }
 }
 /**
  * Get post image
  * @since  1.0.0
  */
 public function get_image($link = 'link')
 {
     global $post;
     $post_type = get_post_type($post->ID);
     if (!post_type_supports($post_type, 'thumbnail')) {
         return;
     }
     if (!has_post_thumbnail()) {
         return;
     }
     $post_meta = Cherry_Services_Template_Callbacks::setup_meta();
     if (isset($post_meta['show_thumb']) && 'no' == $post_meta['show_thumb']) {
         return;
     }
     if ('unlink' == $link) {
         $format = '<figure class="cherry-services_thumb">%1$s</figure>';
     } else {
         $format = '<figure class="cherry-services_thumb"><a href="%2$s">%1$s</a></figure>';
     }
     $size = $this->atts['size'];
     if (is_integer($size)) {
         $size = array($size, $size);
     } elseif (!is_string($size)) {
         $size = 'thumbnail';
     }
     $image = get_the_post_thumbnail($post->ID, $size, array('alt' => get_the_title()));
     return sprintf($format, $image, get_permalink());
 }
コード例 #24
0
ファイル: meta_box.php プロジェクト: juan88ac/foundation_s
 function make($name = null, $post_type = null, $settings = array('context' => 'normal', 'priority' => 'high', 'label' => null, 'callback' => null))
 {
     if (!$name) {
         exit('Making Meta Box: You need to enter a name.');
     }
     $computerName = $this->make_computer_name($name);
     $this->name = $computerName;
     if (isset($settings['label'])) {
         $this->label = $settings['label'];
     }
     $default_settings = array('context' => 'normal', 'priority' => 'high', 'label' => null, 'callback' => null);
     $settings = array_merge($default_settings, $settings);
     if (!$settings['label']) {
         $settings['label'] = $name;
     }
     if (!$settings['callback']) {
         $settings['callback'] = 'meta_' . $computerName;
     }
     $this->post_type = $post_type;
     $this->settings = $settings;
     global $post;
     $type = get_post_type($post->ID);
     if (post_type_supports($type, $computerName)) {
         $this->reg($type);
     }
     if (isset($post_type)) {
         $this->add_post_type_support($post_type);
     }
 }
コード例 #25
0
ファイル: admin.postmeta.php プロジェクト: taeche/SoDoEx
function pagelines_metabox_posts()
{
    $type = pl_get_current_post_type();
    if (!post_type_supports($type, 'post-formats')) {
        return false;
    }
    $meta_box = array('id' => 'pagelines-metabox-post-gallery', 'title' => __('Gallery', 'pagelines'), 'description' => 'Insert a WP gallery using the "Add Media" button above, use the gallery slider checkbox below to transform your images into a slider.', 'post_type' => pl_get_current_post_type(), 'context' => 'normal', 'priority' => 'high', 'fields' => array(array('name' => __('Gallery Slider', 'pagelines'), 'desc' => __('Would you like to turn your gallery into a slider?', 'pagelines'), 'id' => '_pagelines_gallery_slider', 'type' => 'checkbox', 'std' => 1)));
    $callback = create_function('$post,$meta_box', 'pl_create_meta_box( $post, $meta_box["args"] );');
    add_meta_box($meta_box['id'], $meta_box['title'], $callback, $meta_box['post_type'], $meta_box['context'], $meta_box['priority'], $meta_box);
    /* 
     * QUOTE
     */
    $meta_box = array('id' => 'pagelines-metabox-post-quote', 'title' => __('Quote Settings', 'pagelines'), 'description' => '', 'post_type' => pl_get_current_post_type(), 'context' => 'normal', 'priority' => 'high', 'fields' => array(array('name' => __('Quote Content', 'pagelines'), 'desc' => __('Please type the text for your quote here.', 'pagelines'), 'id' => '_pagelines_quote', 'type' => 'textarea', 'std' => '')));
    add_meta_box($meta_box['id'], $meta_box['title'], $callback, $meta_box['post_type'], $meta_box['context'], $meta_box['priority'], $meta_box);
    /* 
     * LINK
     */
    $meta_box = array('id' => 'pagelines-metabox-post-link', 'title' => __('Link Settings', 'pagelines'), 'description' => '', 'post_type' => pl_get_current_post_type(), 'context' => 'normal', 'priority' => 'high', 'fields' => array(array('name' => __('Link URL', 'pagelines'), 'desc' => __('Please input the URL for your link. I.e. http://www.pagelines.com', 'pagelines'), 'id' => '_pagelines_link', 'type' => 'text', 'std' => '')));
    add_meta_box($meta_box['id'], $meta_box['title'], $callback, $meta_box['post_type'], $meta_box['context'], $meta_box['priority'], $meta_box);
    /* 
     * VIDEO
     */
    $meta_box = array('id' => 'pagelines-metabox-post-video', 'title' => __('Video Settings', 'pagelines'), 'description' => '', 'post_type' => pl_get_current_post_type(), 'context' => 'normal', 'priority' => 'high', 'fields' => array(array('name' => __('M4V File URL', 'pagelines'), 'desc' => __('Please upload the .m4v video file.', 'pagelines'), 'id' => '_pagelines_video_m4v', 'type' => 'media', 'std' => ''), array('name' => __('OGV File URL', 'pagelines'), 'desc' => __('Please upload the .ogv video file', 'pagelines'), 'id' => '_pagelines_video_ogv', 'type' => 'media', 'std' => ''), array('name' => __('Preview Image', 'pagelines'), 'desc' => __('Image should be at least 680px wide.Only applies to self hosted videos.', 'pagelines'), 'id' => '_pagelines_video_poster', 'type' => 'file', 'std' => ''), array('name' => __('Embedded Code', 'pagelines'), 'desc' => __('If the video is an embed rather than self hosted, enter in a Vimeo or Youtube embed code here.', 'pagelines'), 'id' => '_pagelines_video_embed', 'type' => 'textarea', 'std' => '')));
    add_meta_box($meta_box['id'], $meta_box['title'], $callback, $meta_box['post_type'], $meta_box['context'], $meta_box['priority'], $meta_box);
    /* 
     * AUDIO
     */
    $meta_box = array('id' => 'pagelines-metabox-post-audio', 'title' => __('Audio Settings', 'pagelines'), 'description' => '', 'post_type' => pl_get_current_post_type(), 'context' => 'normal', 'priority' => 'high', 'fields' => array(array('name' => __('MP3 File URL', 'pagelines'), 'desc' => __('Please enter in the .mp3 file URL', 'pagelines'), 'id' => '_pagelines_audio_mp3', 'type' => 'text', 'std' => ''), array('name' => __('OGA File URL', 'pagelines'), 'desc' => __('Please enter in the URL to the .ogg or .oga file', 'pagelines'), 'id' => '_pagelines_audio_ogg', 'type' => 'text', 'std' => '')));
    add_meta_box($meta_box['id'], $meta_box['title'], $callback, $meta_box['post_type'], $meta_box['context'], $meta_box['priority'], $meta_box);
}
コード例 #26
0
ファイル: template.php プロジェクト: RA2WP/RA2WP
/**
 * 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');
    }
    /* 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";
        /* Template based off the post format. */
        $templates[] = "content-{$post_format}.php";
    }
    /* Template based off the post type. */
    $templates[] = "content-{$post_type}.php";
    /* Fallback 'content.php' template. */
    $templates[] = 'content.php';
    /* Apply filters and return the found content template. */
    include apply_atomic('content_template', locate_template($templates, false, false));
}
コード例 #27
0
/**
 * Register a new meta box to the post or page edit screen, so that the user can add landing section
 * on a per-post or per-page basis.
 */
function cuttz_add_landing_sections_meta_box()
{
    if (!current_theme_supports('cuttz-landing-sections')) {
        return;
    }
    global $post;
    if (get_option('show_on_front') == 'page') {
        $posts_page_id = get_option('page_for_posts');
        if ($posts_page_id == $post->ID) {
            add_action('edit_form_after_title', 'cuttz_landing_section_posts_notice');
            return;
        }
    }
    if (in_array('woocommerce/woocommerce.php', get_option('active_plugins'))) {
        if ($post->ID == wc_get_page_id('shop')) {
            add_action('edit_form_after_title', 'cuttz_landing_section_shop_notice');
            return;
        }
    }
    $context = 'normal';
    $priority = 'high';
    foreach ((array) get_post_types(array('public' => true)) as $type) {
        if (post_type_supports($type, 'cuttz-landing-sections')) {
            add_meta_box('landing-sections', __('Cuttz Landing Sections', 'cuttz-framework'), 'cuttz_landing_sections_box', $type, $context, $priority);
        }
    }
}
コード例 #28
0
ファイル: styles.php プロジェクト: xav335/sfnettoyage
/**
 * Get post specific CSS styles and paste it to head.
 *
 * @since 4.0.0
 */
function cherry_post_inline_styles()
{
    $post_id = get_queried_object_id();
    $post_type = get_post_type($post_id);
    if (!$post_type || !post_type_supports($post_type, 'cherry-post-style')) {
        return;
    }
    if (wp_style_is(CHERRY_DYNAMIC_CSS_HANDLE, 'enqueued')) {
        $handle = CHERRY_DYNAMIC_CSS_HANDLE;
    } else {
        $cherry_styles = cherry_get_styles();
        $handle = isset($cherry_styles['style']) ? $cherry_styles['style']['handle'] : false;
    }
    if (!$handle) {
        return;
    }
    $header_bg = cherry_current_page()->get_property('background', 'header');
    if (!$header_bg) {
        return;
    }
    $custom_bg = cherry_get_background_css('.site-header', $header_bg);
    /**
     * Filter a custom background style.
     *
     * @since 4.0.0
     * @param string $custom_bg Background style.
     * @param int    $post_id   The post ID.
     */
    $custom_bg = apply_filters('cherry_post_inline_styles', $custom_bg, $post_id);
    if (!$custom_bg) {
        return;
    }
    wp_add_inline_style($handle, sanitize_text_field($custom_bg));
}
コード例 #29
0
ファイル: formats.php プロジェクト: OneTimeUser/retailwire
 /**
  * @see CPAC_Column::apply_conditional()
  * @since 2.0
  */
 function apply_conditional()
 {
     if (post_type_supports($this->storage_model->key, 'post-formats')) {
         return true;
     }
     return false;
 }
コード例 #30
0
/**
 * Enqueue ajax comments scripts
 *
 * @action wp_enqueue_scripts
 */
function siteorigin_ajax_comments_enqueue_scripts()
{
    $root_uri = apply_filters('siteorigin_extras_premium_root_uri', get_template_directory_uri() . '/premium/extras/');
    if (is_singular() && post_type_supports(get_post_type(), 'comments')) {
        wp_enqueue_script('siteorigin-ajax-comments', $root_uri . 'ajax-comments/ajax-comments.min.js', array('jquery'), SITEORIGIN_THEME_VERSION);
    }
}