コード例 #1
0
ファイル: tamatebako.php プロジェクト: Harreh/magicowl
/**
 * Post Layout Filter.
 * Problem: If in the future post meta is disabled, user cannot change post layout already set.
 * This function/filter might be removed when this option available in Hybrid Core.
 *
 * @link https://github.com/justintadlock/hybrid-core/issues/67
 * @since 0.1.0
 */
function tamatebako_filter_layout($theme_layout)
{
    /* Layout */
    $layout = '';
    /* Theme Support */
    $layouts = get_theme_support('theme-layouts');
    /* If viewing a singular post, get the post layout. */
    if (is_singular()) {
        /* Only if theme layout support post meta and post type supports it */
        if (true === $layouts[1]['post_meta'] && post_type_supports(get_post_type(get_queried_object_id()), 'theme-layouts')) {
            $layout = get_post_layout(get_queried_object_id());
        }
    } elseif (is_author()) {
        $layout = get_user_layout(get_queried_object_id());
    }
    /* If a layout was found, set it. */
    if (!empty($layout) && 'default' !== $layout) {
        $theme_layout = $layout;
    } elseif (empty($theme_layout)) {
        $args = theme_layouts_get_args();
        $theme_layout = $args['default'];
    }
    return $theme_layout;
}
コード例 #2
0
ファイル: theme-layouts.php プロジェクト: jahir07/bearded
/**
 * Checks if a specific user's layout matches that of the given layout.
 *
 * @since 0.3.0
 * @param string $layout The name of the layout to check if the user has.
 * @param int $user_id The ID of the user to check the layout for.
 * @return bool Whether the given layout matches the user's layout.
 */
function has_user_layout($layout, $user_id = '')
{
    /* If no user ID is given, assume we're viewing an author archive page and get the user ID. */
    if (empty($user_id)) {
        $user_id = get_query_var('author');
    }
    /* Return true/false based on whether the layout matches. */
    return $layout == get_user_layout($user_id) ? true : false;
}
コード例 #3
0
/**
 * Filters the default theme layout. Metaboxes options should still be able
 * to override these.
 *
 * @since  1.0.0
 * @access public
 * @return array
 */
function hybrid_base_theme_layout($theme_layout)
{
    /* If viewing a singular post, get the post layout. */
    if (is_singular()) {
        $layout = get_post_layout(get_queried_object_id());
    } elseif (is_author()) {
        $layout = get_user_layout(get_queried_object_id());
    }
    /* If a layout was found, set it. */
    if (!empty($layout) && 'default' !== $layout) {
        $theme_layout = $layout;
    } else {
        if (is_front_page()) {
            $theme_layout = '1c';
        } else {
            $args = theme_layouts_get_args();
            $theme_layout = $args['default'];
        }
    }
    return $theme_layout;
}