initial commit
This commit is contained in:
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* Sample implementation of the Custom Header feature
|
||||
*
|
||||
* You can add an optional custom header image to header.php like so ...
|
||||
*
|
||||
<?php the_header_image_tag(); ?>
|
||||
*
|
||||
* @link https://developer.wordpress.org/themes/functionality/custom-headers/
|
||||
*
|
||||
* @package stnews-theme
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set up the WordPress core custom header feature.
|
||||
*
|
||||
* @uses stnews_theme_header_style()
|
||||
*/
|
||||
function stnews_theme_custom_header_setup() {
|
||||
add_theme_support(
|
||||
'custom-header',
|
||||
apply_filters(
|
||||
'stnews_theme_custom_header_args',
|
||||
array(
|
||||
'default-image' => '',
|
||||
'default-text-color' => '000000',
|
||||
'width' => 1000,
|
||||
'height' => 250,
|
||||
'flex-height' => true,
|
||||
'wp-head-callback' => 'stnews_theme_header_style',
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
add_action( 'after_setup_theme', 'stnews_theme_custom_header_setup' );
|
||||
|
||||
if ( ! function_exists( 'stnews_theme_header_style' ) ) :
|
||||
/**
|
||||
* Styles the header image and text displayed on the blog.
|
||||
*
|
||||
* @see stnews_theme_custom_header_setup().
|
||||
*/
|
||||
function stnews_theme_header_style() {
|
||||
$header_text_color = get_header_textcolor();
|
||||
|
||||
/*
|
||||
* If no custom options for text are set, let's bail.
|
||||
* get_header_textcolor() options: Any hex value, 'blank' to hide text. Default: add_theme_support( 'custom-header' ).
|
||||
*/
|
||||
if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we get this far, we have custom styles. Let's do this.
|
||||
?>
|
||||
<style type="text/css">
|
||||
<?php
|
||||
// Has the text been hidden?
|
||||
if ( ! display_header_text() ) :
|
||||
?>
|
||||
.site-title,
|
||||
.site-description {
|
||||
position: absolute;
|
||||
clip: rect(1px, 1px, 1px, 1px);
|
||||
}
|
||||
<?php
|
||||
// If the user has set a custom color for the text use that.
|
||||
else :
|
||||
?>
|
||||
.site-title a,
|
||||
.site-description {
|
||||
color: #<?php echo esc_attr( $header_text_color ); ?>;
|
||||
}
|
||||
<?php endif; ?>
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
endif;
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
|
||||
function example_customizer( $wp_customize ) {
|
||||
|
||||
|
||||
/* ============== HEADER LOGO
|
||||
========================== */
|
||||
$wp_customize->add_section( 'logo_section' , array(
|
||||
'title' => __( 'Logo' ),
|
||||
'priority' => 30,
|
||||
'description' => 'Upload a logo in the header',
|
||||
) );
|
||||
|
||||
$wp_customize->add_setting( 'logo' );
|
||||
|
||||
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'logo', array(
|
||||
'label' => __( 'Logo' ),
|
||||
'section' => 'logo_section',
|
||||
'settings' => 'logo',
|
||||
) ) );
|
||||
|
||||
|
||||
}
|
||||
add_action( 'customize_register', 'example_customizer' );
|
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Jetpack Compatibility File
|
||||
*
|
||||
* @link https://jetpack.com/
|
||||
*
|
||||
* @package stnews-theme
|
||||
*/
|
||||
|
||||
/**
|
||||
* Jetpack setup function.
|
||||
*
|
||||
* See: https://jetpack.com/support/infinite-scroll/
|
||||
* See: https://jetpack.com/support/responsive-videos/
|
||||
* See: https://jetpack.com/support/content-options/
|
||||
*/
|
||||
function stnews_theme_jetpack_setup() {
|
||||
// Add theme support for Infinite Scroll.
|
||||
add_theme_support(
|
||||
'infinite-scroll',
|
||||
array(
|
||||
'container' => 'main',
|
||||
'render' => 'stnews_theme_infinite_scroll_render',
|
||||
'footer' => 'page',
|
||||
)
|
||||
);
|
||||
|
||||
// Add theme support for Responsive Videos.
|
||||
add_theme_support( 'jetpack-responsive-videos' );
|
||||
|
||||
// Add theme support for Content Options.
|
||||
add_theme_support(
|
||||
'jetpack-content-options',
|
||||
array(
|
||||
'post-details' => array(
|
||||
'stylesheet' => 'stnews-theme-style',
|
||||
'date' => '.posted-on',
|
||||
'categories' => '.cat-links',
|
||||
'tags' => '.tags-links',
|
||||
'author' => '.byline',
|
||||
'comment' => '.comments-link',
|
||||
),
|
||||
'featured-images' => array(
|
||||
'archive' => true,
|
||||
'post' => true,
|
||||
'page' => true,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
add_action( 'after_setup_theme', 'stnews_theme_jetpack_setup' );
|
||||
|
||||
/**
|
||||
* Custom render function for Infinite Scroll.
|
||||
*/
|
||||
function stnews_theme_infinite_scroll_render() {
|
||||
while ( have_posts() ) {
|
||||
the_post();
|
||||
if ( is_search() ) :
|
||||
get_template_part( 'template-parts/content', 'search' );
|
||||
else :
|
||||
get_template_part( 'template-parts/content', get_post_type() );
|
||||
endif;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Functions which enhance the theme by hooking into WordPress
|
||||
*
|
||||
* @package stnews-theme
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds custom classes to the array of body classes.
|
||||
*
|
||||
* @param array $classes Classes for the body element.
|
||||
* @return array
|
||||
*/
|
||||
function stnews_theme_body_classes( $classes ) {
|
||||
// Adds a class of hfeed to non-singular pages.
|
||||
if ( ! is_singular() ) {
|
||||
$classes[] = 'hfeed';
|
||||
}
|
||||
|
||||
// Adds a class of no-sidebar when there is no sidebar present.
|
||||
if ( ! is_active_sidebar( 'sidebar-1' ) ) {
|
||||
$classes[] = 'no-sidebar';
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
add_filter( 'body_class', 'stnews_theme_body_classes' );
|
||||
|
||||
/**
|
||||
* Add a pingback url auto-discovery header for single posts, pages, or attachments.
|
||||
*/
|
||||
function stnews_theme_pingback_header() {
|
||||
if ( is_singular() && pings_open() ) {
|
||||
printf( '<link rel="pingback" href="%s">', esc_url( get_bloginfo( 'pingback_url' ) ) );
|
||||
}
|
||||
}
|
||||
add_action( 'wp_head', 'stnews_theme_pingback_header' );
|
@ -0,0 +1,165 @@
|
||||
<?php
|
||||
/**
|
||||
* Custom template tags for this theme
|
||||
*
|
||||
* Eventually, some of the functionality here could be replaced by core features.
|
||||
*
|
||||
* @package stnews-theme
|
||||
*/
|
||||
|
||||
if ( ! function_exists( 'stnews_theme_posted_on' ) ) :
|
||||
/**
|
||||
* Prints HTML with meta information for the current post-date/time.
|
||||
*/
|
||||
function stnews_theme_posted_on() {
|
||||
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
|
||||
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
|
||||
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
|
||||
}
|
||||
|
||||
$time_string = sprintf(
|
||||
$time_string,
|
||||
esc_attr( get_the_date( DATE_W3C ) ),
|
||||
esc_html( get_the_date() ),
|
||||
esc_attr( get_the_modified_date( DATE_W3C ) ),
|
||||
esc_html( get_the_modified_date() )
|
||||
);
|
||||
|
||||
$posted_on = sprintf(
|
||||
/* translators: %s: post date. */
|
||||
esc_html_x( 'Posted on %s', 'post date', 'stnews-theme' ),
|
||||
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
|
||||
);
|
||||
|
||||
echo '<span class="posted-on">' . $posted_on . '</span>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'stnews_theme_posted_by' ) ) :
|
||||
/**
|
||||
* Prints HTML with meta information for the current author.
|
||||
*/
|
||||
function stnews_theme_posted_by() {
|
||||
$byline = sprintf(
|
||||
/* translators: %s: post author. */
|
||||
esc_html_x( 'by %s', 'post author', 'stnews-theme' ),
|
||||
'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
|
||||
);
|
||||
|
||||
echo '<span class="byline"> ' . $byline . '</span>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'stnews_theme_entry_footer' ) ) :
|
||||
/**
|
||||
* Prints HTML with meta information for the categories, tags and comments.
|
||||
*/
|
||||
function stnews_theme_entry_footer() {
|
||||
// Hide category and tag text for pages.
|
||||
if ( 'post' === get_post_type() ) {
|
||||
/* translators: used between list items, there is a space after the comma */
|
||||
$categories_list = get_the_category_list( esc_html__( ', ', 'stnews-theme' ) );
|
||||
if ( $categories_list ) {
|
||||
/* translators: 1: list of categories. */
|
||||
printf( '<span class="cat-links">' . esc_html__( 'Posted in %1$s', 'stnews-theme' ) . '</span>', $categories_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
|
||||
/* translators: used between list items, there is a space after the comma */
|
||||
$tags_list = get_the_tag_list( '', esc_html_x( ', ', 'list item separator', 'stnews-theme' ) );
|
||||
if ( $tags_list ) {
|
||||
/* translators: 1: list of tags. */
|
||||
printf( '<span class="tags-links">' . esc_html__( 'Tagged %1$s', 'stnews-theme' ) . '</span>', $tags_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
|
||||
echo '<span class="comments-link">';
|
||||
comments_popup_link(
|
||||
sprintf(
|
||||
wp_kses(
|
||||
/* translators: %s: post title */
|
||||
__( 'Leave a Comment<span class="screen-reader-text"> on %s</span>', 'stnews-theme' ),
|
||||
array(
|
||||
'span' => array(
|
||||
'class' => array(),
|
||||
),
|
||||
)
|
||||
),
|
||||
wp_kses_post( get_the_title() )
|
||||
)
|
||||
);
|
||||
echo '</span>';
|
||||
}
|
||||
|
||||
edit_post_link(
|
||||
sprintf(
|
||||
wp_kses(
|
||||
/* translators: %s: Name of current post. Only visible to screen readers */
|
||||
__( 'Edit <span class="screen-reader-text">%s</span>', 'stnews-theme' ),
|
||||
array(
|
||||
'span' => array(
|
||||
'class' => array(),
|
||||
),
|
||||
)
|
||||
),
|
||||
wp_kses_post( get_the_title() )
|
||||
),
|
||||
'<span class="edit-link">',
|
||||
'</span>'
|
||||
);
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'stnews_theme_post_thumbnail' ) ) :
|
||||
/**
|
||||
* Displays an optional post thumbnail.
|
||||
*
|
||||
* Wraps the post thumbnail in an anchor element on index views, or a div
|
||||
* element when on single views.
|
||||
*/
|
||||
function stnews_theme_post_thumbnail() {
|
||||
if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( is_singular() ) :
|
||||
?>
|
||||
|
||||
<div class="post-thumbnail">
|
||||
<?php the_post_thumbnail(); ?>
|
||||
</div><!-- .post-thumbnail -->
|
||||
|
||||
<?php else : ?>
|
||||
|
||||
<a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1">
|
||||
<?php
|
||||
the_post_thumbnail(
|
||||
'post-thumbnail',
|
||||
array(
|
||||
'alt' => the_title_attribute(
|
||||
array(
|
||||
'echo' => false,
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
?>
|
||||
</a>
|
||||
|
||||
<?php
|
||||
endif; // End is_singular().
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'wp_body_open' ) ) :
|
||||
/**
|
||||
* Shim for sites older than 5.2.
|
||||
*
|
||||
* @link https://core.trac.wordpress.org/ticket/12563
|
||||
*/
|
||||
function wp_body_open() {
|
||||
do_action( 'wp_body_open' );
|
||||
}
|
||||
endif;
|
Reference in New Issue
Block a user