Initial commit
This commit is contained in:
parent
79c4716b45
commit
bfa86a9aca
53
404.php
Executable file
53
404.php
Executable file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* The main template file.
|
||||
*
|
||||
* This is the most generic template file in a WordPress theme
|
||||
* and one of the two required files for a theme (the other being style.css).
|
||||
* It is used to display a page when nothing more specific matches a query.
|
||||
* E.g., it puts together the home page when no home.php file exists.
|
||||
* Learn more: http://codex.wordpress.org/Template_Hierarchy
|
||||
*
|
||||
* @package Portage
|
||||
*/
|
||||
|
||||
get_header();
|
||||
|
||||
?>
|
||||
|
||||
<?php get_sidebar(); ?>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<!-- Post title info -->
|
||||
<div class="post" >
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<?php _e( '404: We can\'t find that page', 'atticus-finch' ); ?>
|
||||
</h2>
|
||||
|
||||
<!-- Post content -->
|
||||
<div class="post-content">
|
||||
<p><img src='<?php echo get_template_directory_uri(); ?>/images/404.jpg' /></p>
|
||||
<p>
|
||||
<?php
|
||||
_e( 'Sorry, that page or post doesn\'t appear to be here. It may have been deleted, moved, or at the other end of an outdated link.', 'atticus-finch' );
|
||||
?>
|
||||
</p>
|
||||
<p>
|
||||
<?php
|
||||
_e( 'You can use the menus, categories, or tags to find what you are looking for. You can also use the search form below.', 'atticus-finch' );
|
||||
?>
|
||||
</p>
|
||||
<p id="404search">
|
||||
<?php
|
||||
get_search_form();
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div><!-- end "post" -->
|
||||
|
||||
</div> <!-- end Content -->
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php get_footer(); ?>
|
@ -1,3 +0,0 @@
|
||||
# portage
|
||||
|
||||
An updated theme (based on Atticus Finch) for ClassicPress
|
48
archive.php
Executable file
48
archive.php
Executable file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* The archive template file.
|
||||
*
|
||||
* Displays generic archives.
|
||||
* Learn more: http://codex.wordpress.org/Template_Hierarchy
|
||||
*
|
||||
* @package Atticus Finch
|
||||
*/
|
||||
|
||||
get_header();
|
||||
|
||||
?>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<div id="archive-title">
|
||||
<?php if ( is_day() ) : ?>
|
||||
<?php printf( __( 'Daily Archive for %s', 'atticus-finch' ), '<span>' . get_the_date() . '</span>' ); ?>
|
||||
<?php elseif ( is_month() ) : ?>
|
||||
<?php printf( __( 'Monthly Archive for %s', 'atticus-finch' ),
|
||||
/* translators: F will be replaced with month, and Y will be replaced with year, so "F Y" in English would be replaced with something like "June 2008". */
|
||||
'<span>' . get_the_date( __( 'F Y', 'atticus-finch' ) ) . '</span>' ); ?>
|
||||
<?php elseif ( is_year() ) : ?>
|
||||
<?php printf(__( 'Yearly Archive for %s', 'atticus-finch' ), '<span>' . get_the_date( 'Y' ) . '</span>' ); ?>
|
||||
<?php else : ?>
|
||||
<?php _e( 'Blog Archive', 'atticus-finch' ); ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Start the loop -->
|
||||
<?php if ( have_posts() ) : ?>
|
||||
<?php while ( have_posts() ) : the_post(); ?>
|
||||
|
||||
<?php get_template_part( 'formats/excerpt', get_post_format() ); ?>
|
||||
|
||||
<!-- End the loop -->
|
||||
<?php endwhile; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php atticus_finch_display_nav(); ?>
|
||||
</div> <!-- end Content -->
|
||||
|
||||
<?php get_sidebar(); ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php get_footer(); ?>
|
45
category.php
Executable file
45
category.php
Executable file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* The category template file.
|
||||
*
|
||||
* Displays category archives.
|
||||
* Learn more: http://codex.wordpress.org/Template_Hierarchy
|
||||
*
|
||||
* @package Atticus Finch
|
||||
*/
|
||||
|
||||
get_header();
|
||||
|
||||
?>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<div id="archive-title">
|
||||
<h2>
|
||||
<?php
|
||||
printf( __( 'Posts contained in the “<span>%s</span>” category:', 'atticus-finch' ), single_cat_title( '', false ) );
|
||||
?>
|
||||
</h2>
|
||||
<?php
|
||||
echo category_description();
|
||||
?>
|
||||
</div>
|
||||
|
||||
<!-- Start the loop -->
|
||||
<?php if ( have_posts() ) : ?>
|
||||
<?php while ( have_posts() ) : the_post(); ?>
|
||||
|
||||
<?php get_template_part( 'formats/excerpt', get_post_format() ); ?>
|
||||
|
||||
<!-- End the loop -->
|
||||
<?php endwhile; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php atticus_finch_display_nav(); ?>
|
||||
</div> <!-- end Content -->
|
||||
|
||||
<?php get_sidebar(); ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php get_footer(); ?>
|
75
comments.php
Executable file
75
comments.php
Executable file
@ -0,0 +1,75 @@
|
||||
<div id="comments">
|
||||
<?php if ( have_comments() ) : ?>
|
||||
<?php do_action( 'atticus_finch_before_comments' ); ?>
|
||||
|
||||
<?php
|
||||
if ( post_password_required() ) {
|
||||
echo '<p class="nocomments">This post is password protected. Enter the password to view comments.</p>';
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Actual comments are listed here -->
|
||||
<h3 class="comments-title">
|
||||
<?php
|
||||
$post_comments = count( get_comments(array('type' => 'comment','post_id' => $post->ID)) );
|
||||
printf( _nx( 'One comment on “%2$s”', '%1$s comments on “%2$s”', $post_comments, 'comments title', 'atticus-finch' ),
|
||||
number_format_i18n( $post_comments ), '<span>' . get_the_title() . '</span>' );
|
||||
?>
|
||||
</h3>
|
||||
<ol class="comment-list">
|
||||
<?php
|
||||
wp_list_comments( array(
|
||||
'style' => 'div',
|
||||
'short_ping' => false,
|
||||
'avatar_size' => 32,
|
||||
'type' => 'comment',
|
||||
'format' => 'xhtml',
|
||||
) );
|
||||
?>
|
||||
</ol><!-- .comment-list -->
|
||||
|
||||
<!-- Pingbacks and trackbacks are listed here -->
|
||||
<h3 class="comments-title">
|
||||
<?php
|
||||
$post_pings = count( get_comments(array( 'type' => 'pings', 'post_id' => $post->ID )) );
|
||||
if ( $post_pings > 0 ) {
|
||||
printf( _nx( 'One pingback/trackback on “%2$s”', '%1$s pingbacks/trackbacks on “%2$s”', $post_pings, 'pingbacks title', 'atticus-finch' ),
|
||||
number_format_i18n( $post_pings ), '<span>' . get_the_title() . '</span>' );
|
||||
}
|
||||
?>
|
||||
</h3>
|
||||
<ol class="comment-list">
|
||||
<?php
|
||||
wp_list_comments( array(
|
||||
'style' => 'div',
|
||||
'short_ping' => true,
|
||||
'avatar_size' => 0,
|
||||
'type' => 'pings',
|
||||
'format' => 'xhtml',
|
||||
) );
|
||||
?>
|
||||
</ol><!-- .comment-list -->
|
||||
|
||||
<?php
|
||||
// Are there comments to navigate through?
|
||||
if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) :
|
||||
?>
|
||||
<nav class="navigation comment-navigation" role="navigation">
|
||||
<h1 class="screen-reader-text section-heading"><?php _e( 'Comment navigation', 'atticus-finch' ); ?></h1>
|
||||
<div class="nav-previous"><?php previous_comments_link( __( '← Older Comments', 'atticus-finch' ) ); ?></div>
|
||||
<div class="nav-next"><?php next_comments_link( __( 'Newer Comments →', 'atticus-finch' ) ); ?></div>
|
||||
</nav><!-- .comment-navigation -->
|
||||
<?php endif; // Check for comment navigation ?>
|
||||
|
||||
<?php if ( ! comments_open() && get_comments_number() ) : ?>
|
||||
<p class="no-comments"><?php _e( 'Sorry, but comments are closed.' , 'atticus-finch' ); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php do_action( 'atticus_finch_after_comments' ); ?>
|
||||
<?php endif; // have_comments() ?>
|
||||
|
||||
<?php do_action( 'atticus_finch_before_comment_form' ) ?>
|
||||
<?php comment_form(); ?>
|
||||
<?php do_action( 'atticus_finch_after_comment_form' ) ?>
|
||||
</div>
|
56
footer.php
Executable file
56
footer.php
Executable file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* The template for displaying the footer.
|
||||
*
|
||||
* Contains all content after #container div.
|
||||
*
|
||||
* @package Atticus Finch
|
||||
*/
|
||||
|
||||
?>
|
||||
|
||||
<?php do_action( 'atticus_finch_container_bottom' ); ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</div><!-- end #container -->
|
||||
|
||||
<footer>
|
||||
|
||||
<?php atticus_finch_footer_top_link(); ?>
|
||||
|
||||
<?php do_action( 'atticus_finch_before_footer_menu' ); ?>
|
||||
|
||||
<nav id="footer-menu">
|
||||
<?php wp_nav_menu( array(
|
||||
'theme_location' => 'footer-menu',
|
||||
'fallback_cb' => '',
|
||||
'menu_class' => '',
|
||||
'menu_id' => 'footermenu-ul',
|
||||
'container' => 'div',
|
||||
'container_id' => 'footermenu',
|
||||
'depth' => 4
|
||||
) );
|
||||
?>
|
||||
<div class="clear"></div>
|
||||
</nav>
|
||||
|
||||
<?php do_action( 'atticus_finch_footer_top' ); ?>
|
||||
|
||||
<?php
|
||||
atticus_finch_display_footer_copyright();
|
||||
atticus_finch_display_footer_credits();
|
||||
?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php do_action( 'atticus_finch_footer_bottom' ); ?>
|
||||
|
||||
</footer>
|
||||
|
||||
<?php do_action( 'atticus_finch_after_footer' ); ?>
|
||||
|
||||
<?php wp_footer(); ?>
|
||||
|
||||
</body>
|
||||
</html>
|
20
formats/content-aside.php
Executable file
20
formats/content-aside.php
Executable file
@ -0,0 +1,20 @@
|
||||
<!-- Post title info -->
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<?php do_action( 'atticus_finch_before_post_title' ); ?>
|
||||
|
||||
<?php if ( get_theme_mod( 'atticus_finch_aside_title') == '1' ) { ?>
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
|
||||
<span class="fa fa-asterisk"></span>
|
||||
<?php the_title(); ?>
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<?php } else { ?>
|
||||
<h2 class="notitle-h2"><span class="fa fa-asterisk notitle"></span></h2>
|
||||
<?php } ?>
|
||||
|
||||
<?php get_template_part( 'inc/content', 'excerpt' ); ?>
|
19
formats/content-audio.php
Executable file
19
formats/content-audio.php
Executable file
@ -0,0 +1,19 @@
|
||||
<!-- Post title info -->
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<?php do_action( 'atticus_finch_before_post_title' ); ?>
|
||||
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<?php
|
||||
if ( post_password_required() ) {
|
||||
echo '<span class="fa fa-key fa-rotate-90"></span>';
|
||||
} else {
|
||||
echo '<span class="fa fa-headphones"></span>';
|
||||
}
|
||||
?>
|
||||
<?php the_title(); ?>
|
||||
</h2>
|
||||
|
||||
<?php get_template_part( 'inc/content', 'main' ); ?>
|
19
formats/content-chat.php
Executable file
19
formats/content-chat.php
Executable file
@ -0,0 +1,19 @@
|
||||
<!-- Post title info -->
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<?php do_action( 'atticus_finch_before_post_title' ); ?>
|
||||
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<?php
|
||||
if ( post_password_required() ) {
|
||||
echo '<span class="fa fa-key fa-rotate-90"></span>';
|
||||
} else {
|
||||
echo '<span class="fa fa-comments-o"></span>';
|
||||
}
|
||||
?>
|
||||
<?php the_title(); ?>
|
||||
</h2>
|
||||
|
||||
<?php get_template_part( 'inc/content', 'main' ); ?>
|
19
formats/content-gallery.php
Executable file
19
formats/content-gallery.php
Executable file
@ -0,0 +1,19 @@
|
||||
<!-- Post title info -->
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<?php do_action( 'atticus_finch_before_post_title' ); ?>
|
||||
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<?php
|
||||
if ( post_password_required() ) {
|
||||
echo '<span class="fa fa-key fa-rotate-90"></span>';
|
||||
} else {
|
||||
echo '<span class="fa fa-th"></span>';
|
||||
}
|
||||
?>
|
||||
<?php the_title(); ?>
|
||||
</h2>
|
||||
|
||||
<?php get_template_part( 'inc/content', 'main' ); ?>
|
19
formats/content-image.php
Executable file
19
formats/content-image.php
Executable file
@ -0,0 +1,19 @@
|
||||
<!-- Post title info -->
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<?php do_action( 'atticus_finch_before_post_title' ); ?>
|
||||
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<?php
|
||||
if ( post_password_required() ) {
|
||||
echo '<span class="fa fa-key fa-rotate-90"></span>';
|
||||
} else {
|
||||
echo '<span class="fa fa-image"></span>';
|
||||
}
|
||||
?>
|
||||
<?php the_title(); ?>
|
||||
</h2>
|
||||
|
||||
<?php get_template_part( 'inc/content', 'main' ); ?>
|
20
formats/content-link.php
Executable file
20
formats/content-link.php
Executable file
@ -0,0 +1,20 @@
|
||||
<!-- Post title info -->
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<?php do_action( 'atticus_finch_before_post_title' ); ?>
|
||||
|
||||
<?php if ( get_theme_mod( 'atticus_finch_link_title') == '1' ) { ?>
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
|
||||
<span class="fa fa-link fa-rotate-90"></span>
|
||||
<?php the_title(); ?>
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<?php } else { ?>
|
||||
<h2 class="notitle-h2"><span class="fa fa-link fa-rotate-90 notitle"></span><div class="clear"></div></h2>
|
||||
<?php } ?>
|
||||
|
||||
<?php get_template_part( 'inc/content', 'excerpt' ); ?>
|
21
formats/content-quote.php
Executable file
21
formats/content-quote.php
Executable file
@ -0,0 +1,21 @@
|
||||
<!-- Post title info -->
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<?php do_action( 'atticus_finch_before_post_title' ); ?>
|
||||
|
||||
<?php if ( get_theme_mod( 'atticus_finch_quote_title') == '1' ) { ?>
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
|
||||
<span class="fa fa-quote-left"></span>
|
||||
<?php the_title(); ?>
|
||||
<span class="fa fa-quote-right"></span>
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<?php } else { ?>
|
||||
<h2><span class="fa fa-quote-left notitle"></span></h2>
|
||||
<?php } ?>
|
||||
|
||||
<?php get_template_part( 'inc/content', 'main' ); ?>
|
20
formats/content-status.php
Executable file
20
formats/content-status.php
Executable file
@ -0,0 +1,20 @@
|
||||
<!-- Post title info -->
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<?php do_action( 'atticus_finch_before_post_title' ); ?>
|
||||
|
||||
<?php if ( get_theme_mod( 'atticus_finch_status_title') == '1' ) { ?>
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
|
||||
<span class="fa fa-at"></span>
|
||||
<?php the_title(); ?>
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<?php } else { ?>
|
||||
<h2 class="notitle-h2"><span class="fa fa-at notitle"></span></h2>
|
||||
<?php } ?>
|
||||
|
||||
<?php get_template_part( 'inc/content', 'excerpt' ); ?>
|
19
formats/content-video.php
Executable file
19
formats/content-video.php
Executable file
@ -0,0 +1,19 @@
|
||||
<!-- Post title info -->
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<?php do_action( 'atticus_finch_before_post_title' ); ?>
|
||||
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<?php
|
||||
if ( post_password_required() ) {
|
||||
echo '<span class="fa fa-key fa-rotate-90"></span>';
|
||||
} else {
|
||||
echo '<span class="fa fa-video-camera"></span>';
|
||||
}
|
||||
?>
|
||||
<?php the_title(); ?>
|
||||
</h2>
|
||||
|
||||
<?php get_template_part( 'inc/content', 'main' ); ?>
|
20
formats/content.php
Executable file
20
formats/content.php
Executable file
@ -0,0 +1,20 @@
|
||||
<!-- Post title info -->
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
<!-- closing tag in content-main.php -->
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<?php do_action( 'atticus_finch_before_post_title' ); ?>
|
||||
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<?php
|
||||
if ( post_password_required() ) {
|
||||
echo '<span class="fa fa-key fa-rotate-90"></span>';
|
||||
} else {
|
||||
echo '<span class="fa fa-pencil"></span>';
|
||||
}
|
||||
?>
|
||||
<?php the_title(); ?>
|
||||
</h2>
|
||||
|
||||
<?php get_template_part( 'inc/content', 'main' ); ?>
|
42
formats/excerpt-aside.php
Executable file
42
formats/excerpt-aside.php
Executable file
@ -0,0 +1,42 @@
|
||||
<!-- Post title info -->
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<?php if ( get_theme_mod( 'atticus_finch_aside_title') == '1' ) { ?>
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
|
||||
<span class="fa fa-asterisk"></span>
|
||||
<?php the_title(); ?>
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<!-- Post content -->
|
||||
<div class="post-content">
|
||||
|
||||
<?php } else { ?>
|
||||
<div class="post-content">
|
||||
<h2><a href="<?php echo get_permalink(); ?>"><span class="fa fa-asterisk notitle"></span></a></h2>
|
||||
<?php } ?>
|
||||
|
||||
<?php
|
||||
if ( has_post_thumbnail() ) {
|
||||
the_post_thumbnail( 'thumbnail' );
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if ( get_theme_mod( 'atticus_finch_aside_excerpt' ) == '1' ) {
|
||||
the_excerpt();
|
||||
} else {
|
||||
the_content();
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</div><!-- end post content -->
|
||||
|
||||
<?php get_template_part( 'inc/excerpt', 'short-meta' ); ?>
|
||||
|
||||
</div><!-- end "Entry" -->
|
36
formats/excerpt-audio.php
Executable file
36
formats/excerpt-audio.php
Executable file
@ -0,0 +1,36 @@
|
||||
<!-- Post title info -->
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
|
||||
<?php
|
||||
if ( post_password_required() ) {
|
||||
echo '<span class="fa fa-key fa-rotate-90"></span>';
|
||||
} else {
|
||||
echo '<span class="fa fa-headphones"></span>';
|
||||
}
|
||||
?>
|
||||
<?php the_title(); ?>
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<!-- Post content -->
|
||||
<div class="post-content">
|
||||
|
||||
<?php
|
||||
if ( has_post_thumbnail() ) {
|
||||
the_post_thumbnail( 'thumbnail' );
|
||||
}
|
||||
?>
|
||||
|
||||
<?php the_excerpt(); ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</div><!-- end post content -->
|
||||
|
||||
<?php get_template_part( 'inc/excerpt', 'entry-meta' ); ?>
|
||||
|
||||
</div><!-- end "Entry" -->
|
36
formats/excerpt-chat.php
Executable file
36
formats/excerpt-chat.php
Executable file
@ -0,0 +1,36 @@
|
||||
<!-- Post title info -->
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
|
||||
<?php
|
||||
if ( post_password_required() ) {
|
||||
echo '<span class="fa fa-key fa-rotate-90"></span>';
|
||||
} else {
|
||||
echo '<span class="fa fa-comments-o"></span>';
|
||||
}
|
||||
?>
|
||||
<?php the_title(); ?>
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<!-- Post content -->
|
||||
<div class="post-content">
|
||||
|
||||
<?php
|
||||
if ( has_post_thumbnail() ) {
|
||||
the_post_thumbnail( 'thumbnail' );
|
||||
}
|
||||
?>
|
||||
|
||||
<?php the_excerpt(); ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</div><!-- end post content -->
|
||||
|
||||
<?php get_template_part( 'inc/excerpt', 'entry-meta' ); ?>
|
||||
|
||||
</div><!-- end "Entry" -->
|
36
formats/excerpt-gallery.php
Executable file
36
formats/excerpt-gallery.php
Executable file
@ -0,0 +1,36 @@
|
||||
<!-- Post title info -->
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
|
||||
<?php
|
||||
if ( post_password_required() ) {
|
||||
echo '<span class="fa fa-key fa-rotate-90"></span>';
|
||||
} else {
|
||||
echo '<span class="fa fa-th"></span>';
|
||||
}
|
||||
?>
|
||||
<?php the_title(); ?>
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<!-- Post content -->
|
||||
<div class="post-content">
|
||||
|
||||
<?php
|
||||
if ( has_post_thumbnail() ) {
|
||||
the_post_thumbnail( 'thumbnail' );
|
||||
}
|
||||
?>
|
||||
|
||||
<?php the_excerpt(); ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</div><!-- end post content -->
|
||||
|
||||
<?php get_template_part( 'inc/excerpt', 'entry-meta' ); ?>
|
||||
|
||||
</div><!-- end "Entry" -->
|
36
formats/excerpt-image.php
Executable file
36
formats/excerpt-image.php
Executable file
@ -0,0 +1,36 @@
|
||||
<!-- Post title info -->
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
|
||||
<?php
|
||||
if ( post_password_required() ) {
|
||||
echo '<span class="fa fa-key fa-rotate-90"></span>';
|
||||
} else {
|
||||
echo '<span class="fa fa-image"></span>';
|
||||
}
|
||||
?>
|
||||
<?php the_title(); ?>
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<!-- Post content -->
|
||||
<div class="post-content">
|
||||
|
||||
<?php
|
||||
if ( has_post_thumbnail() ) {
|
||||
the_post_thumbnail( 'thumbnail' );
|
||||
}
|
||||
?>
|
||||
|
||||
<?php the_excerpt(); ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</div><!-- end post content -->
|
||||
|
||||
<?php get_template_part( 'inc/excerpt', 'entry-meta' ); ?>
|
||||
|
||||
</div><!-- end "Entry" -->
|
42
formats/excerpt-link.php
Executable file
42
formats/excerpt-link.php
Executable file
@ -0,0 +1,42 @@
|
||||
<!-- Post title info -->
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<?php if ( get_theme_mod( 'atticus_finch_link_title') == '1' ) { ?>
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
|
||||
<span class="fa fa-link fa-rotate-90"></span>
|
||||
<?php the_title(); ?>
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<!-- Post content -->
|
||||
<div class="post-content">
|
||||
|
||||
<?php } else { ?>
|
||||
<div class="post-content">
|
||||
<h2><a href="<?php echo get_permalink(); ?>"><span class="fa fa-link fa-rotate-90 notitle"></span></a></h2>
|
||||
<?php } ?>
|
||||
|
||||
<?php
|
||||
if ( has_post_thumbnail() ) {
|
||||
the_post_thumbnail( 'thumbnail' );
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if ( get_theme_mod( 'atticus_finch_link_excerpt' ) == '1' ) {
|
||||
the_excerpt();
|
||||
} else {
|
||||
the_content();
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</div><!-- end post content -->
|
||||
|
||||
<?php get_template_part( 'inc/excerpt', 'short-meta' ); ?>
|
||||
|
||||
</div><!-- end "Entry" -->
|
43
formats/excerpt-quote.php
Executable file
43
formats/excerpt-quote.php
Executable file
@ -0,0 +1,43 @@
|
||||
<!-- Post title info -->
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<?php if ( get_theme_mod( 'atticus_finch_quote_title') == '1' ) { ?>
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
|
||||
<span class="fa fa-quote-left"></span>
|
||||
<?php the_title(); ?>
|
||||
<span class="fa fa-quote-right"></span>
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<!-- Post content -->
|
||||
<div class="post-content">
|
||||
|
||||
<?php } else { ?>
|
||||
<div class="post-content post-content-quote">
|
||||
<h2><a href="<?php echo get_permalink(); ?>"><span class="fa fa-quote-left notitle"></span></a></h2>
|
||||
<?php } ?>
|
||||
|
||||
<?php
|
||||
if ( has_post_thumbnail() ) {
|
||||
the_post_thumbnail( 'thumbnail' );
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if ( get_theme_mod( 'atticus_finch_quote_excerpt' ) == '1' ) {
|
||||
the_excerpt();
|
||||
} else {
|
||||
the_content();
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</div><!-- end post content -->
|
||||
|
||||
<?php get_template_part( 'inc/excerpt', 'short-meta' ); ?>
|
||||
|
||||
</div><!-- end "Entry" -->
|
42
formats/excerpt-status.php
Executable file
42
formats/excerpt-status.php
Executable file
@ -0,0 +1,42 @@
|
||||
<!-- Post title info -->
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<?php if ( get_theme_mod( 'atticus_finch_status_title') == '1' ) { ?>
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
|
||||
<span class="fa fa-at"></span>
|
||||
<?php the_title(); ?>
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<!-- Post content -->
|
||||
<div class="post-content">
|
||||
|
||||
<?php } else { ?>
|
||||
<div class="post-content">
|
||||
<h2><a href="<?php echo get_permalink(); ?>"><span class="fa fa-at notitle"></span></a></h2>
|
||||
<?php } ?>
|
||||
|
||||
<?php
|
||||
if ( has_post_thumbnail() ) {
|
||||
the_post_thumbnail( 'thumbnail' );
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if ( get_theme_mod( 'atticus_finch_status_excerpt' ) == '1' ) {
|
||||
the_excerpt();
|
||||
} else {
|
||||
the_content();
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</div><!-- end post content -->
|
||||
|
||||
<?php get_template_part( 'inc/excerpt', 'short-meta' ); ?>
|
||||
|
||||
</div><!-- end "Entry" -->
|
36
formats/excerpt-video.php
Executable file
36
formats/excerpt-video.php
Executable file
@ -0,0 +1,36 @@
|
||||
<!-- Post title info -->
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
|
||||
<?php
|
||||
if ( post_password_required() ) {
|
||||
echo '<span class="fa fa-key fa-rotate-90"></span>';
|
||||
} else {
|
||||
echo '<span class="fa fa-video-camera"></span>';
|
||||
}
|
||||
?>
|
||||
<?php the_title(); ?>
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<!-- Post content -->
|
||||
<div class="post-content">
|
||||
|
||||
<?php
|
||||
if ( has_post_thumbnail() ) {
|
||||
the_post_thumbnail( 'thumbnail' );
|
||||
}
|
||||
?>
|
||||
|
||||
<?php the_excerpt(); ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</div><!-- end post content -->
|
||||
|
||||
<?php get_template_part( 'inc/excerpt', 'entry-meta' ); ?>
|
||||
|
||||
</div><!-- end "Entry" -->
|
36
formats/excerpt.php
Executable file
36
formats/excerpt.php
Executable file
@ -0,0 +1,36 @@
|
||||
<!-- Post title info -->
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<h2 id="post-<?php the_ID(); ?>" class="post-title">
|
||||
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
|
||||
<?php
|
||||
if ( post_password_required() ) {
|
||||
echo '<span class="fa fa-key fa-rotate-90"></span>';
|
||||
} else {
|
||||
echo '<span class="fa fa-pencil"></span>';
|
||||
}
|
||||
?>
|
||||
<?php the_title(); ?>
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<!-- Post content -->
|
||||
<div class="post-content">
|
||||
|
||||
<?php
|
||||
if ( has_post_thumbnail() ) {
|
||||
the_post_thumbnail( 'thumbnail' );
|
||||
}
|
||||
?>
|
||||
|
||||
<?php the_excerpt(); ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</div><!-- end post content -->
|
||||
|
||||
<?php get_template_part( 'inc/excerpt', 'entry-meta' ); ?>
|
||||
|
||||
</div><!-- end "Entry" -->
|
233
functions.php
Executable file
233
functions.php
Executable file
@ -0,0 +1,233 @@
|
||||
<?php
|
||||
/**
|
||||
* Atticus Finch functions and definitions
|
||||
*
|
||||
* @package Atticus Finch
|
||||
*/
|
||||
|
||||
if ( ! function_exists( 'atticus_finch_setup' ) ) :
|
||||
/**
|
||||
* Sets up theme defaults and registers support for various WordPress features.
|
||||
*
|
||||
* Note that this function is hooked into the after_setup_theme hook, which
|
||||
* runs before the init hook. The init hook is too late for some features, such
|
||||
* as indicating support for post thumbnails.
|
||||
*/
|
||||
function atticus_finch_setup() {
|
||||
/*
|
||||
* Make theme available for translation.
|
||||
* Translations can be filed in the /languages/ directory.
|
||||
* If you're building a theme based on Atticus Finch, use a find and replace
|
||||
* to change 'atticus-finch' to the name of your theme in all the template files
|
||||
*/
|
||||
load_theme_textdomain( 'atticus-finch', get_template_directory() . '/lang' );
|
||||
|
||||
// Add default posts and comments RSS feed links to head.
|
||||
add_theme_support( 'automatic-feed-links' );
|
||||
|
||||
/*
|
||||
* Let WordPress manage the document title.
|
||||
* By adding theme support, we declare that this theme does not use a
|
||||
* hard-coded <title> tag in the document head, and expect WordPress to
|
||||
* provide it for us.
|
||||
*/
|
||||
add_theme_support( 'title-tag' );
|
||||
|
||||
/*
|
||||
* Enable support for Post Thumbnails on posts and pages.
|
||||
*
|
||||
* @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
|
||||
*/
|
||||
add_theme_support( 'post-thumbnails' );
|
||||
|
||||
// This theme uses wp_nav_menu() in three locations.
|
||||
register_nav_menus( array(
|
||||
'top-menu' => esc_html__( 'Top Menu', 'atticus-finch' ),
|
||||
'primary-menu' => esc_html__( 'Primary Menu', 'atticus-finch' ),
|
||||
'footer-menu' => esc_html__( 'Footer Menu', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
/*
|
||||
* Switch default core markup for search form, comment form, and comments
|
||||
* to output valid HTML5.
|
||||
*/
|
||||
add_theme_support( 'html5', array(
|
||||
'search-form',
|
||||
'comment-form',
|
||||
'comment-list',
|
||||
'gallery',
|
||||
'caption',
|
||||
) );
|
||||
|
||||
/*
|
||||
* Enable support for Post Formats.
|
||||
* See http://codex.wordpress.org/Post_Formats
|
||||
*/
|
||||
add_theme_support( 'post-formats', array(
|
||||
'aside',
|
||||
'audio',
|
||||
'chat',
|
||||
'gallery',
|
||||
'image',
|
||||
'link',
|
||||
'quote',
|
||||
'status',
|
||||
'video',
|
||||
) );
|
||||
|
||||
// Set up the WordPress core custom background feature.
|
||||
add_theme_support( 'custom-background', apply_filters( 'atticus_finch_custom_background_args', array(
|
||||
'default-color' => 'ffffff',
|
||||
'default-image' => '',
|
||||
) ) );
|
||||
}
|
||||
endif; // atticus_finch_setup
|
||||
add_action( 'after_setup_theme', 'atticus_finch_setup' );
|
||||
|
||||
/**
|
||||
* Set the content width in pixels, based on the theme's design and stylesheet.
|
||||
*
|
||||
* Priority 0 to make it available to lower priority callbacks.
|
||||
*
|
||||
* @global int $content_width
|
||||
*/
|
||||
function atticus_finch_content_width() {
|
||||
$GLOBALS['content_width'] = apply_filters( 'atticus_finch_content_width', 620 );
|
||||
}
|
||||
add_action( 'after_setup_theme', 'atticus_finch_content_width', 0 );
|
||||
|
||||
/**
|
||||
* Register widget area.
|
||||
*
|
||||
* @link http://codex.wordpress.org/Function_Reference/register_sidebar
|
||||
*/
|
||||
function atticus_finch_widgets_init() {
|
||||
register_sidebar( array(
|
||||
'name' => esc_html__( 'Sidebar', 'atticus-finch' ),
|
||||
'id' => 'sidebar-1',
|
||||
'description' => '',
|
||||
'before_widget' => '',
|
||||
'after_widget' => '',
|
||||
'before_title' => '<h2 class="widget-title">',
|
||||
'after_title' => '</h2>',
|
||||
) );
|
||||
}
|
||||
add_action( 'widgets_init', 'atticus_finch_widgets_init' );
|
||||
|
||||
/**
|
||||
* Enqueue scripts and styles.
|
||||
*/
|
||||
function atticus_finch_scripts() {
|
||||
wp_enqueue_style( 'atticus-finch-googlefont', 'https://fonts.googleapis.com/css?family=IM+Fell+English:400,400italic', 'atticus-finch-style', wp_get_theme() -> get( 'Version' ), 'all' );
|
||||
|
||||
if ( !wp_style_is( 'font-awesome.min.css', 'enqueued' ) ) {
|
||||
wp_enqueue_style( 'atticus-finch-fa', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css', 'atticus-finch-style', wp_get_theme() -> get( 'Version' ), 'all' );
|
||||
}
|
||||
|
||||
wp_enqueue_style( 'atticus-finch-style', get_stylesheet_uri() );
|
||||
|
||||
wp_enqueue_style( 'atticus-finch-menus', get_template_directory_uri() . '/styles/menus.css', array( 'atticus-finch-style' ), wp_get_theme() -> get( 'Version' ) );
|
||||
|
||||
wp_enqueue_style( 'atticus-finch-mobile', get_template_directory_uri() . '/styles/mobile.css', array( 'atticus-finch-style' ), wp_get_theme() -> get( 'Version' ), 'screen and (max-width: '. get_theme_mod( 'atticus_finch_mobile_breakpoint' ) . 'px)' );
|
||||
|
||||
wp_enqueue_style( 'atticus-finch-print', get_template_directory_uri() . '/styles/print.css', array( 'atticus-finch-style' ), wp_get_theme() -> get( 'Version' ), 'print' );
|
||||
|
||||
wp_enqueue_script( 'atticus-finch-menumaker', get_template_directory_uri() . '/js/menumaker.js', array( 'jquery' ), wp_get_theme() -> get( 'Version' ), true );
|
||||
|
||||
wp_enqueue_script( 'atticus-finch-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), wp_get_theme() -> get( 'Version' ), true );
|
||||
|
||||
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
|
||||
wp_enqueue_script( 'comment-reply' );
|
||||
}
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'atticus_finch_scripts' );
|
||||
|
||||
/**
|
||||
* Enable live changes in the customizer
|
||||
*/
|
||||
function atticus_finch_customizer_script() {
|
||||
wp_enqueue_script( 'atticus-finch-theme-customizer', get_template_directory_uri() . '/js/customizer.js', array(), wp_get_theme() -> get( 'Version' ), true );
|
||||
}
|
||||
add_action( 'customize_preview_init', 'atticus_finch_customizer_script' );
|
||||
|
||||
|
||||
// Change "read more" link on excerpts
|
||||
// codex.wordpress.org/Function_Reference/the_excerpt
|
||||
function atticus_finch_excerpt_more( $more ) {
|
||||
$text = get_theme_mod( 'atticus_finch_readmore', '…read more…' );
|
||||
return ' <a class="excerpt-link" href="' . get_permalink( get_the_ID() ) . '">' . $text . '</a>';
|
||||
}
|
||||
add_filter( 'excerpt_more', 'atticus_finch_excerpt_more' );
|
||||
|
||||
|
||||
// Add descriptions to main menu
|
||||
// http://www.wpbeginner.com/wp-themes/how-to-add-menu-descriptions-in-your-wordpress-themes/
|
||||
/*
|
||||
class Atticus_Finch_Menu_With_Description extends Walker_Nav_Menu {
|
||||
function start_el(&$output, $item, $depth=0, $args = array(), $id=0) {
|
||||
global $wp_query;
|
||||
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
|
||||
|
||||
$class_names = $value = '';
|
||||
|
||||
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
|
||||
|
||||
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
|
||||
$class_names = ' class="' . esc_attr( $class_names ) . '"';
|
||||
|
||||
$output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
|
||||
|
||||
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
|
||||
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
|
||||
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
|
||||
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
|
||||
|
||||
$item_output = $args->before;
|
||||
$item_output .= '<a'. $attributes .'>';
|
||||
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
|
||||
$item_output .= '<p class="sub">' . $item->description . '</p>';
|
||||
$item_output .= '</a>';
|
||||
$item_output .= $args->after;
|
||||
|
||||
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args, $id );
|
||||
}
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* Implement the Custom Header feature.
|
||||
*/
|
||||
require get_template_directory() . '/functions/custom-header.php';
|
||||
|
||||
/**
|
||||
* Custom template tags for this theme.
|
||||
*/
|
||||
require get_template_directory() . '/functions/template-tags.php';
|
||||
|
||||
/**
|
||||
* Customizer additions.
|
||||
*/
|
||||
require get_template_directory() . '/functions/customizer.php';
|
||||
|
||||
/**
|
||||
* Load Jetpack compatibility file.
|
||||
*/
|
||||
require get_template_directory() . '/functions/jetpack.php';
|
||||
|
||||
/**
|
||||
* Add our widget areas.
|
||||
*/
|
||||
require get_template_directory() . '/functions/widget-areas.php';
|
||||
|
||||
/**
|
||||
* Make our menus mobile.
|
||||
*/
|
||||
require get_template_directory() . '/functions/mobile-menus.php';
|
||||
|
||||
|
||||
// Include our update script to update from private repo
|
||||
require 'update/puc.php';
|
||||
$myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
|
||||
'http://api.kjodle.net/?action=get_metadata&slug=atticus-finch',
|
||||
__FILE__,
|
||||
'atticus-finch'
|
||||
);
|
126
functions/custom-header.php
Executable file
126
functions/custom-header.php
Executable file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
/**
|
||||
* Sample implementation of the Custom Header feature
|
||||
* http://codex.wordpress.org/Custom_Headers
|
||||
*
|
||||
* You can add an optional custom header image to header.php like so ...
|
||||
*
|
||||
<?php if ( get_header_image() ) : ?>
|
||||
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
|
||||
<img src="<?php header_image(); ?>" width="<?php echo esc_attr( get_custom_header()->width ); ?>" height="<?php echo esc_attr( get_custom_header()->height ); ?>" alt="">
|
||||
</a>
|
||||
<?php endif; // End header image check. ?>
|
||||
*
|
||||
* @package Atticus Finch
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set up the WordPress core custom header feature.
|
||||
*
|
||||
* @uses atticus_finch_header_style()
|
||||
* @uses atticus_finch_admin_header_style()
|
||||
* @uses atticus_finch_admin_header_image()
|
||||
*/
|
||||
function atticus_finch_custom_header_setup() {
|
||||
add_theme_support( 'custom-header', apply_filters( 'atticus_finch_custom_header_args', array(
|
||||
'default-image' => '',
|
||||
'default-text-color' => '000000',
|
||||
'width' => 1000,
|
||||
'height' => 250,
|
||||
'flex-height' => true,
|
||||
'wp-head-callback' => 'atticus_finch_header_style',
|
||||
'admin-head-callback' => 'atticus_finch_admin_header_style',
|
||||
'admin-preview-callback' => 'atticus_finch_admin_header_image',
|
||||
) ) );
|
||||
}
|
||||
add_action( 'after_setup_theme', 'atticus_finch_custom_header_setup' );
|
||||
|
||||
if ( ! function_exists( 'atticus_finch_header_style' ) ) :
|
||||
/**
|
||||
* Styles the header image and text displayed on the blog
|
||||
*
|
||||
* @see atticus_finch_custom_header_setup().
|
||||
*/
|
||||
function atticus_finch_header_style() {
|
||||
$header_text_color = get_header_textcolor();
|
||||
|
||||
// If no custom options for text are set, let's bail
|
||||
// get_header_textcolor() options: HEADER_TEXTCOLOR is default, hide text (returns 'blank') or any hex value.
|
||||
if ( HEADER_TEXTCOLOR == $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 ( 'blank' == $header_text_color ) :
|
||||
?>
|
||||
.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; // atticus_finch_header_style
|
||||
|
||||
if ( ! function_exists( 'atticus_finch_admin_header_style' ) ) :
|
||||
/**
|
||||
* Styles the header image displayed on the Appearance > Header admin panel.
|
||||
*
|
||||
* @see atticus_finch_custom_header_setup().
|
||||
*/
|
||||
function atticus_finch_admin_header_style() {
|
||||
?>
|
||||
<style type="text/css">
|
||||
.appearance_page_custom-header #headimg {
|
||||
border: none;
|
||||
}
|
||||
#headimg h1,
|
||||
#desc {
|
||||
}
|
||||
#headimg h1 {
|
||||
}
|
||||
#headimg h1 a {
|
||||
}
|
||||
#desc {
|
||||
}
|
||||
#headimg img {
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
endif; // atticus_finch_admin_header_style
|
||||
|
||||
if ( ! function_exists( 'atticus_finch_admin_header_image' ) ) :
|
||||
/**
|
||||
* Custom header image markup displayed on the Appearance > Header admin panel.
|
||||
*
|
||||
* @see atticus_finch_custom_header_setup().
|
||||
*/
|
||||
function atticus_finch_admin_header_image() {
|
||||
?>
|
||||
<div id="headimg">
|
||||
<h1 class="displaying-header-text">
|
||||
<a id="name" style="<?php echo esc_attr( 'color: #' . get_header_textcolor() ); ?>" onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a>
|
||||
</h1>
|
||||
<div class="displaying-header-text" id="desc" style="<?php echo esc_attr( 'color: #' . get_header_textcolor() ); ?>"><?php bloginfo( 'description' ); ?></div>
|
||||
<?php if ( get_header_image() ) : ?>
|
||||
<img src="<?php header_image(); ?>" alt="">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
endif; // atticus_finch_admin_header_image
|
975
functions/customizer.php
Executable file
975
functions/customizer.php
Executable file
@ -0,0 +1,975 @@
|
||||
<?php
|
||||
/**
|
||||
* Atticus Finch Theme Customizer
|
||||
*
|
||||
* @package Atticus Finch
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
|
||||
*/
|
||||
function atticus_finch_customize_preview_js() {
|
||||
wp_enqueue_script( 'atticus_finch_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20130508', true );
|
||||
}
|
||||
add_action( 'customize_preview_init', 'atticus_finch_customize_preview_js' );
|
||||
|
||||
|
||||
// Add some Customizer stuff
|
||||
// developer.wordpress.org/themes/advanced-topics/customizer-api/
|
||||
add_action( 'customize_register', 'atticus_finch_customize_register', 11 );
|
||||
function atticus_finch_customize_register( $wp_customize ) {
|
||||
|
||||
// Add postMessage support for site title and description for the Theme Customizer
|
||||
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
|
||||
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
|
||||
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
|
||||
|
||||
|
||||
$wp_customize->add_panel( 'atticusfinch', array(
|
||||
'title' => __( 'Atticus Finch Theme Options', 'atticus-finch' ),
|
||||
'description' => __( 'The Atticus Finch theme has many options. Vist the theme\'s <a href="http://www.example.com/">home page</a> for complete instructions.', 'atticus-finch' ),
|
||||
'priority' => 05,
|
||||
) );
|
||||
|
||||
|
||||
// Widget Areas
|
||||
$wp_customize->add_section( 'atticus_finch_widget_areas', array(
|
||||
'title' => __( 'Widget Areas', 'atticus-finch' ),
|
||||
'capability' => 'edit_theme_options',
|
||||
'priority' => 30,
|
||||
'description' => __( 'Select which action hook widget areas you would like to activate.', 'atticus-finch' ),
|
||||
'panel' => 'atticusfinch',
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_before_header', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_before_header', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Before Header', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_after_top_menu', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_after_top_menu', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'After Top Menu', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_before_social_media', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_before_social_media', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Before Social Media', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_before_primary_menu', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_before_primary_menu', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Before Primary Menu', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_after_header', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_after_header', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'After Header', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_container_top', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_container_top', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Top of Container', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_before_post_title', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_before_post_title', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Before Post Title', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
/*
|
||||
* We've removed this action hook, but let's leave this control in place
|
||||
* in case we find a use for it later.
|
||||
$wp_customize->add_setting( 'atticus_finch_before_post_content', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_before_post_content', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Before Post Content', 'atticus-finch' ),
|
||||
) );
|
||||
*/
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_post_top', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_post_top', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Top of Post', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_post_bottom', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_post_bottom', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Bottom of Post', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_after_post_content', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_after_post_content', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'After Post Content', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_before_post_meta', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_before_post_meta', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Before Post Meta', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_after_post_meta', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_after_post_meta', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'After Post Meta', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_before_comments', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_before_comments', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Before Comments', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_after_comments', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_after_comments', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'After Comments', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_before_comment_form', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_before_comment_form', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Before Comment Form', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_after_comment_form', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_after_comment_form', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'After Comment Form', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_container_bottom', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_container_bottom', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Bottom of Container', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_before_footer_menu', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_before_footer_menu', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Before Footer Menu', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_footer_top', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_footer_top', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Top of Footer', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_footer_bottom', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_footer_bottom', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Bottom of Footer', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_after_footer', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_after_footer', array(
|
||||
'section' => 'atticus_finch_widget_areas',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'After Footer', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
// Post Format Title Options
|
||||
$wp_customize->add_section( 'atticus_finch_post_format_title_options', array(
|
||||
'title' => __( 'Post Format Title Options', 'atticus-finch' ),
|
||||
'capability' => 'edit_theme_options',
|
||||
'priority' => 10,
|
||||
'description' => __('Select whether titles should appear for various post formats.', 'atticus-finch'),
|
||||
'panel' => 'atticusfinch',
|
||||
) );
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_aside_title', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_aside_title', array(
|
||||
'section' => 'atticus_finch_post_format_title_options',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Display title for asides', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_link_title', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_link_title', array(
|
||||
'section' => 'atticus_finch_post_format_title_options',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Display title for links', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_quote_title', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_quote_title', array(
|
||||
'section' => 'atticus_finch_post_format_title_options',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Display title for quotes', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_status_title', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_status_title', array(
|
||||
'section' => 'atticus_finch_post_format_title_options',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Display title for statuses', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
// Post Format Excerpt Options
|
||||
$wp_customize->add_section( 'atticus_finch_post_format_excerpt_options', array(
|
||||
'title' => __( 'Post Format Excerpt Options', 'atticus-finch' ),
|
||||
'capability' => 'edit_theme_options',
|
||||
'priority' => 20,
|
||||
'description' => __('By default, the aside, link, quote, and statu post format will display full content on the home page. You can choose to show excerpts instead.', 'atticus-finch'),
|
||||
'panel' => 'atticusfinch',
|
||||
) );
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_aside_excerpt', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_aside_excerpt', array(
|
||||
'section' => 'atticus_finch_post_format_excerpt_options',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Display excerpt for asides', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_link_excerpt', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_link_excerpt', array(
|
||||
'section' => 'atticus_finch_post_format_excerpt_options',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Display excerpt for links', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_quote_excerpt', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_quote_excerpt', array(
|
||||
'section' => 'atticus_finch_post_format_excerpt_options',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Display excerpt for quotes', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_status_excerpt', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_status_excerpt', array(
|
||||
'section' => 'atticus_finch_post_format_excerpt_options',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Display excerpt for statuses', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$default_readmore = __( '…read more…', 'atticus-finch' );
|
||||
$wp_customize->add_setting( 'atticus_finch_readmore', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'default' => $default_readmore,
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_text',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_readmore', array(
|
||||
'section' => 'atticus_finch_post_format_excerpt_options',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Text for ‘read more’ link (in all excerpts)', 'atticus-finch'),
|
||||
) );
|
||||
|
||||
|
||||
// Copyright Information
|
||||
$wp_customize->add_section( 'atticus_finch_copyright', array(
|
||||
'title' => __( 'Copyright Information', 'atticus-finch' ),
|
||||
'capability' => 'edit_theme_options',
|
||||
'priority' => 50,
|
||||
'description' => __( 'Copyright information will appear in the footer, and at the bottom of printed pages. (Make sure you have not disabled this function under "Miscellaneous Options")', 'atticus-finch' ),
|
||||
'panel' => 'atticusfinch',
|
||||
) );
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_copyright', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'html',
|
||||
) );
|
||||
|
||||
$default_copyright = '<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" id="cc-button" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a>This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.';
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_copyright', array(
|
||||
'section' => 'atticus_finch_copyright',
|
||||
'default' => $default_copyright,
|
||||
'type' => 'textarea',
|
||||
'label' => __( 'Enter your copyright information. (HTML is allowed.)', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
// Print Options
|
||||
$wp_customize->add_section( 'atticus_finch_print', array (
|
||||
'title' => __( 'Print Options', 'atticus-finch' ),
|
||||
'capability' => 'edit_theme_options',
|
||||
'priority' => 40,
|
||||
'panel' => 'atticusfinch',
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_print_url', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_print_url', array(
|
||||
'section' => 'atticus_finch_print',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Print URL information at end of post', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_print_copyright', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_print_copyright', array(
|
||||
'section' => 'atticus_finch_print',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Print copyright information at end of post', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
// Social Media Options
|
||||
$wp_customize->add_section( 'atticus_finch_social_media', array(
|
||||
'title' => __( 'Social Media Options', 'atticus-finch' ),
|
||||
'capability' => 'edit_theme_options',
|
||||
'priority' => 90,
|
||||
'panel' => 'atticusfinch',
|
||||
) );
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_rss', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_rss', array(
|
||||
'section' => 'atticus_finch_social_media',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Display link to RSS feed', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_twitter', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_url',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_twitter', array(
|
||||
'section' => 'atticus_finch_social_media',
|
||||
'type' => 'url',
|
||||
'label' => __( 'Enter Twitter URL', 'atticus-finch'),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_twitter2', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_url',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_twitter2', array(
|
||||
'section' => 'atticus_finch_social_media',
|
||||
'type' => 'url',
|
||||
'label' => __( 'Enter second Twitter URL', 'atticus-finch'),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_facebook', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_url',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_facebook', array(
|
||||
'section' => 'atticus_finch_social_media',
|
||||
'type' => 'url',
|
||||
'label' => __( 'Enter Facebook URL', 'atticus-finch'),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_instagram', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_url',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_instagram', array(
|
||||
'section' => 'atticus_finch_social_media',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Enter Instagram URL', 'atticus-finch'),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_youtube', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_url',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_youtube', array(
|
||||
'section' => 'atticus_finch_social_media',
|
||||
'type' => 'url',
|
||||
'label' => __( 'Enter YouTube URL', 'atticus-finch'),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_pinterest', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_url',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_pinterest', array(
|
||||
'section' => 'atticus_finch_social_media',
|
||||
'type' => 'url',
|
||||
'label' => __( 'Enter Pinterest Profile URL', 'atticus-finch'),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_amazon', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_url',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_amazon', array(
|
||||
'section' => 'atticus_finch_social_media',
|
||||
'type' => 'url',
|
||||
'label' => __( 'Enter Amazon Wish List URL', 'atticus-finch'),
|
||||
) );
|
||||
|
||||
|
||||
|
||||
|
||||
// Mobile Menu Options
|
||||
$wp_customize->add_section( 'atticus_finch_mobile_menu_options', array(
|
||||
'title' => __( 'Mobile Menu Options', 'atticus-finch' ),
|
||||
'capability' => 'edit_theme_options',
|
||||
'priority' => 110,
|
||||
'description' => __('Menu settings for mobile appearance. <b>Note:</b> The breakpoint settings will override the "mobile breakpoint" setting.', 'atticus-finch'),
|
||||
'panel' => 'atticusfinch',
|
||||
) );
|
||||
|
||||
// Top Menu Options
|
||||
$wp_customize->add_setting( 'atticus_finch_top_menu_name', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_text',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_top_menu_name', array(
|
||||
'section' => 'atticus_finch_mobile_menu_options',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Mobile display name for top menu', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_top_menu_type', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_mobile_menu_type',
|
||||
'default' => 'select',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_top_menu_type', array(
|
||||
'section' => 'atticus_finch_mobile_menu_options',
|
||||
'type' => 'select',
|
||||
'choices' => array(
|
||||
'select' => 'Select Menu',
|
||||
'dropdown' => 'Flat Menu',
|
||||
'multitoggle' => 'Dropdown Menu',
|
||||
),
|
||||
'label' => __( 'Display the top menu as', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_top_menu_breakpoint', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_int',
|
||||
'default' => 640,
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_top_menu_breakpoint', array(
|
||||
'section' => 'atticus_finch_mobile_menu_options',
|
||||
'type' => 'integer',
|
||||
'label' => __( 'Breakpoint to display top menu as mobile', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
// Main Menu Options
|
||||
$wp_customize->add_setting( 'atticus_finch_main_menu_name', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_text',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_main_menu_name', array(
|
||||
'section' => 'atticus_finch_mobile_menu_options',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Mobile display name for main menu', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_main_menu_type', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_mobile_menu_type',
|
||||
'default' => 'select',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_main_menu_type', array(
|
||||
'section' => 'atticus_finch_mobile_menu_options',
|
||||
'type' => 'select',
|
||||
'choices' => array(
|
||||
'select' => 'Select Menu',
|
||||
'dropdown' => 'Flat Menu',
|
||||
'multitoggle' => 'Dropdown Menu',
|
||||
),
|
||||
'label' => __( 'Display the menu menu as', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_main_menu_breakpoint', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_int',
|
||||
'default' => 640,
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_main_menu_breakpoint', array(
|
||||
'section' => 'atticus_finch_mobile_menu_options',
|
||||
'type' => 'integer',
|
||||
'label' => __( 'Breakpoint to display main menu as mobile', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
// Footer Menu Options
|
||||
$wp_customize->add_setting( 'atticus_finch_footer_menu_name', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_text',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_footer_menu_name', array(
|
||||
'section' => 'atticus_finch_mobile_menu_options',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Mobile display name for footer menu', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_footer_menu_type', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_mobile_menu_type',
|
||||
'default' => 'select',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_footer_menu_type', array(
|
||||
'section' => 'atticus_finch_mobile_menu_options',
|
||||
'type' => 'select',
|
||||
'choices' => array(
|
||||
'select' => 'Select Menu',
|
||||
'dropdown' => 'Flat Menu',
|
||||
'multitoggle' => 'Dropdown Menu',
|
||||
),
|
||||
'label' => __( 'Display the footer menu as', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_footer_menu_breakpoint', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_int',
|
||||
'default' => 640,
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_footer_menu_breakpoint', array(
|
||||
'section' => 'atticus_finch_mobile_menu_options',
|
||||
'type' => 'integer',
|
||||
'label' => __( 'Breakpoint to display footer menu as mobile', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
// Mobile Options Options
|
||||
$wp_customize->add_section( 'atticus_finch_mobile', array(
|
||||
'title' => __( 'Mobile Options', 'atticus-finch' ),
|
||||
'capability' => 'edit_theme_options',
|
||||
'priority' => 100,
|
||||
'panel' => 'atticusfinch',
|
||||
'description' => 'Fine-tune your mobile appearance',
|
||||
) );
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_mobile_breakpoint', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'default' => '640',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_int',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_mobile_breakpoint', array(
|
||||
'section' => 'atticus_finch_mobile',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Breakpoint to display mobile version of theme', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_post_top_link', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'default' => '0',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_post_top_link', array(
|
||||
'section' => 'atticus_finch_mobile',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Display \'Return to Top\' link after post content', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_footer_top_link', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'default' => '0',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_footer_top_link', array(
|
||||
'section' => 'atticus_finch_mobile',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Display \'Return to Top\' link before footer content', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
// Miscellaneous Options
|
||||
$wp_customize->add_section( 'atticus_finch_misc', array(
|
||||
'title' => __( 'Miscellaneous Options', 'atticus-finch' ),
|
||||
'capability' => 'edit_theme_options',
|
||||
'priority' => 200,
|
||||
'panel' => 'atticusfinch',
|
||||
) );
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_display_copyright', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'default' => '1',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_display_copyright', array(
|
||||
'section' => 'atticus_finch_misc',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Display copyright information in footer', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_display_credits', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'default' => '1',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_display_credits', array(
|
||||
'section' => 'atticus_finch_misc',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Display developer credits in footer', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_edit_post_link', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'default' => '1',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_edit_post_link', array(
|
||||
'section' => 'atticus_finch_misc',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Display "Edit this post" link if user is logged in', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
|
||||
$wp_customize->add_setting( 'atticus_finch_excerpt_length', array(
|
||||
'type' => 'theme_mod',
|
||||
'transport' => 'postMessage',
|
||||
'default' => '20',
|
||||
'sanitize_callback' => 'atticus_finch_sanitize_excerpt',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'atticus_finch_excerpt_length', array(
|
||||
'section' => 'atticus_finch_misc',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Excerpt length in number of words (maximum = 100)', 'atticus-finch' ),
|
||||
) );
|
||||
|
||||
// Preview some of our options
|
||||
/*
|
||||
if ( $wp_customize->is_preview() && ! is_admin() )
|
||||
add_action( 'wp_footer', 'atticus_finch_customize_preview', 21);
|
||||
|
||||
function themename_customize_preview() {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
( function( $ ){
|
||||
wp.customize('setting_name',function( value ) {
|
||||
value.bind(function(to) {
|
||||
$('.posttitle').css('color', to ? to : '' );
|
||||
});
|
||||
});
|
||||
} )( jQuery )
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
*/
|
||||
|
||||
} // End register function
|
||||
|
||||
|
||||
// Sanitizer Functions
|
||||
|
||||
function atticus_finch_sanitize_checkbox( $input ) {
|
||||
if ( $input == 1 ) {
|
||||
return 1;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function atticus_finch_sanitize_text( $input ) {
|
||||
return wp_kses_post( force_balance_tags( $input ) );
|
||||
}
|
||||
|
||||
function atticus_finch_sanitize_excerpt( $input ) {
|
||||
$input = absint( $input );
|
||||
if ( $input > 100 ) { $input = 100; }
|
||||
return $input;
|
||||
}
|
||||
|
||||
function atticus_finch_sanitize_html( $input ) {
|
||||
wp_kses($input,
|
||||
array(),
|
||||
array(
|
||||
'http' => array(),
|
||||
'https' => array(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function atticus_finch_sanitize_url( $url ) {
|
||||
return esc_url_raw( $url );
|
||||
}
|
||||
|
||||
function atticus_finch_sanitize_mobile_menu_type( $input ){
|
||||
$valid = array(
|
||||
'select' => 'Select Menu',
|
||||
'dropdown' => 'Flat Menu',
|
||||
'multitoggle' => 'Dropdown Menu',
|
||||
);
|
||||
if ( array_key_exists( $input, $valid ) ) {
|
||||
return $input;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function atticus_finch_sanitize_int( $input ){
|
||||
if( is_numeric( $input) ) {
|
||||
return intval( $input );
|
||||
}
|
||||
}
|
||||
|
30
functions/jetpack.php
Executable file
30
functions/jetpack.php
Executable file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Jetpack Compatibility File
|
||||
* See: https://jetpack.me/
|
||||
*
|
||||
* @package Atticus Finch
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add theme support for Infinite Scroll.
|
||||
* See: https://jetpack.me/support/infinite-scroll/
|
||||
*/
|
||||
function atticus_finch_jetpack_setup() {
|
||||
add_theme_support( 'infinite-scroll', array(
|
||||
'container' => 'main',
|
||||
'render' => 'atticus_finch_infinite_scroll_render',
|
||||
'footer' => 'page',
|
||||
) );
|
||||
} // end function atticus_finch_jetpack_setup
|
||||
add_action( 'after_setup_theme', 'atticus_finch_jetpack_setup' );
|
||||
|
||||
/**
|
||||
* Custom render function for Infinite Scroll.
|
||||
*/
|
||||
function atticus_finch_infinite_scroll_render() {
|
||||
while ( have_posts() ) {
|
||||
the_post();
|
||||
get_template_part( 'template-parts/content', get_post_format() );
|
||||
}
|
||||
} // end function atticus_finch_infinite_scroll_render
|
26
functions/mobile-menus.php
Executable file
26
functions/mobile-menus.php
Executable file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
function atticus_finch_mobile_menus(){
|
||||
echo '
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function() {
|
||||
jQuery("#aboveheadermenu").menumaker({
|
||||
title: "' . get_theme_mod( 'atticus_finch_top_menu_name' ) . '",
|
||||
breakpoint: ' . get_theme_mod( 'atticus_finch_top_menu_breakpoint' ) . ',
|
||||
format: "' . get_theme_mod( 'atticus_finch_top_menu_type' ) . '"
|
||||
});
|
||||
jQuery("#belowheadermenu").menumaker({
|
||||
title: "' . get_theme_mod( 'atticus_finch_main_menu_name' ) . '",
|
||||
breakpoint: ' . get_theme_mod( 'atticus_finch_main_menu_breakpoint' ) . ',
|
||||
format: "' . get_theme_mod( 'atticus_finch_main_menu_type' ) . '"
|
||||
});
|
||||
jQuery("#footermenu").menumaker({
|
||||
title: "' . get_theme_mod( 'atticus_finch_footer_menu_name' ) . '",
|
||||
breakpoint: ' . get_theme_mod( 'atticus_finch_footer_menu_breakpoint' ) . ',
|
||||
format: "' . get_theme_mod( 'atticus_finch_footer_menu_type' ) . '"
|
||||
});
|
||||
});
|
||||
</script>
|
||||
';
|
||||
}
|
||||
add_action( 'wp_footer', 'atticus_finch_mobile_menus' );
|
337
functions/template-tags.php
Executable file
337
functions/template-tags.php
Executable file
@ -0,0 +1,337 @@
|
||||
<?php
|
||||
/**
|
||||
* Custom template tags for this theme.
|
||||
*
|
||||
* Eventually, some of the functionality here could be replaced by core features.
|
||||
*
|
||||
* @package Atticus Finch
|
||||
*/
|
||||
|
||||
|
||||
if ( ! function_exists( 'atticus_finch_posted_on' ) ) :
|
||||
/**
|
||||
* Prints HTML with meta information for the current post-date/time and author.
|
||||
*/
|
||||
function atticus_finch_posted_on() {
|
||||
|
||||
$date = get_the_date();
|
||||
$modd = get_the_modified_date();
|
||||
|
||||
if ( $modd == $date ) {
|
||||
printf(__( '<time class="entry-date published updated" datetime="%s">', 'atticus-finch' ), esc_attr( get_the_date( 'c' ) ) );
|
||||
echo '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">';
|
||||
printf(__( 'Posted on %s', 'atticus-finch' ), get_the_date() );
|
||||
$date;
|
||||
echo '</a></time>';
|
||||
} else {
|
||||
printf(__( '<time class="entry-date published updated" datetime="%s">', 'atticus-finch' ), esc_attr( get_the_date( 'c' ) ) );
|
||||
echo '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">';
|
||||
printf(__( 'Posted on %s', 'atticus-finch' ), get_the_date() );
|
||||
$date;
|
||||
echo '</a>; ';
|
||||
printf(__( '<time class="updated" datetime="%s">', 'atticus-finch') , esc_attr( get_the_modified_date( 'c' ) ) );
|
||||
printf(__( 'modified on %s', 'atticus-finch' ), get_the_modified_date() );
|
||||
echo '</time> ';
|
||||
|
||||
}
|
||||
|
||||
$byline = sprintf(
|
||||
esc_html_x( 'by %s', 'post author', 'atticus-finch' ),
|
||||
'<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>'; // WPCS: XSS OK.
|
||||
}
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if a blog has more than 1 category.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function atticus_finch_categorized_blog() {
|
||||
if ( false === ( $all_the_cool_cats = get_transient( 'atticus_finch_categories' ) ) ) {
|
||||
// Create an array of all the categories that are attached to posts.
|
||||
$all_the_cool_cats = get_categories( array(
|
||||
'fields' => 'ids',
|
||||
'hide_empty' => 1,
|
||||
|
||||
// We only need to know if there is more than one category.
|
||||
'number' => 2,
|
||||
) );
|
||||
|
||||
// Count the number of categories that are attached to the posts.
|
||||
$all_the_cool_cats = count( $all_the_cool_cats );
|
||||
|
||||
set_transient( 'atticus_finch_categories', $all_the_cool_cats );
|
||||
}
|
||||
|
||||
if ( $all_the_cool_cats > 1 ) {
|
||||
// This blog has more than 1 category so atticus_finch_categorized_blog should return true.
|
||||
return true;
|
||||
} else {
|
||||
// This blog has only 1 category so atticus_finch_categorized_blog should return false.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush out the transients used in atticus_finch_categorized_blog.
|
||||
*/
|
||||
function atticus_finch_category_transient_flusher() {
|
||||
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
||||
return;
|
||||
}
|
||||
// Like, beat it. Dig?
|
||||
delete_transient( 'atticus_finch_categories' );
|
||||
}
|
||||
add_action( 'edit_category', 'atticus_finch_category_transient_flusher' );
|
||||
add_action( 'save_post', 'atticus_finch_category_transient_flusher' );
|
||||
|
||||
|
||||
/* My Stuff */
|
||||
|
||||
|
||||
// Determine whether or not to show page navigation at bottom of index/archive
|
||||
// Necessary because page navigation is in a styled <div> and should not appear
|
||||
// on non-paginated pages
|
||||
function atticus_finch_display_nav() {
|
||||
$atticus_finch_num_posts = wp_count_posts()->publish;
|
||||
$atticus_finch_posts_per_page = get_option('posts_per_page ');
|
||||
if ( $atticus_finch_num_posts > $atticus_finch_posts_per_page) {
|
||||
echo '<div id="posts-nav">' . get_posts_nav_link(' • ','« Newer Posts','Older Posts;') . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Determine whether to display the comments box
|
||||
function atticus_finch_comment_display() {
|
||||
$var = get_comments_number();
|
||||
if ( comments_open() || $var > 0 ) {
|
||||
comments_template();
|
||||
} else { echo '
|
||||
<div id="comments">
|
||||
<div id="respond">
|
||||
<p>' . __( 'Sorry, but comments are closed.', 'atticus-finch' ) . '</p>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Display the time
|
||||
// Included here if we need to change it later
|
||||
function atticus_finch_date() {
|
||||
return get_the_time(get_option('date_format'));
|
||||
}
|
||||
|
||||
|
||||
// Display publication info as a translatable string in 'content-entry-meta.php'
|
||||
function atticus_finch_pub() {
|
||||
$atticus_finch_author_link = get_author_posts_url( get_the_author_meta( 'ID' ) );
|
||||
$atticus_finch_author_href = '<a href="' . $atticus_finch_author_link . '">' . get_the_author() . '</a>';
|
||||
echo '<a href="' . get_permalink() . '">';
|
||||
printf( __( 'Published on: %1$s by %2$s', 'atticus-finch' ), atticus_finch_date(), $atticus_finch_author_href );
|
||||
echo '</a>';
|
||||
}
|
||||
|
||||
|
||||
// Display category info as a translatable string in 'content-entry-meta.php'
|
||||
function atticus_finch_cat() {
|
||||
$gbcat = get_the_category_list( ', ' );
|
||||
printf( __( 'Categorized under: %s', 'atticus-finch'), $gbcat );
|
||||
}
|
||||
|
||||
|
||||
// Display tags info as a translatable string in 'content-entry-meta.php'
|
||||
function atticus_finch_tags() {
|
||||
$tags_array = has_tag();
|
||||
if (!empty($tags_array)) {
|
||||
printf( __( 'Tagged with: %s', 'atticus-finch'), get_the_tag_list('', ', ', '' ) );
|
||||
} else {
|
||||
_e( 'This post has no tags.', 'atticus-finch' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Display next post link only if a newer post exists
|
||||
function atticus_finch_next_post_link() {
|
||||
$atticus_finch_npl = get_next_post_link();
|
||||
if ( empty ( $atticus_finch_npl ) ) {
|
||||
echo '<p>' . __( 'You are reading the newest post.', 'atticus-finch' ) . '</p>';
|
||||
} else {
|
||||
echo '<p>' . __( 'Read a newer post:', 'atticus-finch' ) . '</p>';
|
||||
next_post_link();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Display previous post link only if an older post exists
|
||||
function atticus_finch_prev_post_link() {
|
||||
$atticus_finch_ppl = get_previous_post_link();
|
||||
if ( empty ( $atticus_finch_ppl ) ) {
|
||||
echo '<p>>' . __( 'You are reading the oldest post.', 'atticus-finch' ) . '</p>';
|
||||
} else {
|
||||
echo '<p>' . __( 'Read an older post:', 'atticus-finch' ) . '</p>';
|
||||
previous_post_link();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add the URL information when printing
|
||||
function atticus_finch_print_url() {
|
||||
echo '<p class="printonly printurl">';
|
||||
printf(__( 'Link for this article:', 'atticus-finch' ) );
|
||||
echo '<br /><span class="printurl-url">' . get_the_permalink() . '<span></p>';
|
||||
}
|
||||
|
||||
|
||||
// Add a "Read More" box on excerpts
|
||||
function atticus_finch_read_more() {
|
||||
echo '<p class="read-more"><a href="' . get_the_permalink() . '">';
|
||||
printf(__( 'Read the complete article…', 'atticus-finch' ) );
|
||||
echo '</a></p>';
|
||||
}
|
||||
|
||||
|
||||
// Take care of wp_link_pages
|
||||
function atticus_finch_link_pages() {
|
||||
$defaults = array(
|
||||
'before' => '<div id="link-pages">' . __( 'This post has multiple pages:', 'atticus-finch' ),
|
||||
'after' => '</div>',
|
||||
'link_before' => '',
|
||||
'link_after' => '',
|
||||
'next_or_number' => 'number',
|
||||
'separator' => ' ',
|
||||
'nextpagelink' => __( 'Next page', 'atticus-finch' ),
|
||||
'previouspagelink' => __( 'Previous page', 'atticus-finch' ),
|
||||
'pagelink' => '%',
|
||||
'echo' => 1
|
||||
);
|
||||
wp_link_pages( $defaults );
|
||||
}
|
||||
|
||||
|
||||
// Print options
|
||||
function atticus_finch_print_options() {
|
||||
if ( get_theme_mod( 'atticus_finch_print_copyright' ) == '1' ) {
|
||||
echo '<span class="printonly printcopyright">' .
|
||||
get_theme_mod( 'atticus_finch_copyright', '<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" id="cc-button" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a>This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.' ) .
|
||||
'</span>';
|
||||
}
|
||||
if ( get_theme_mod( 'atticus_finch_print_url' ) == '1' ) {
|
||||
echo '<span class="printonly printurl">';
|
||||
printf(__( 'Permalink for this article:', 'atticus-finch' ) );
|
||||
echo '<br /><span class="printurl-url">' . get_the_permalink() . '<span></span>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Edit post link, if user is logged in
|
||||
function atticus_finch_edit_post() {
|
||||
if ( get_theme_mod( 'atticus_finch_edit_post_link' ) == '1' && is_user_logged_in() ) : {
|
||||
edit_post_link('Edit this post', '<p class="edit-post">', '</p>');
|
||||
}
|
||||
endif;
|
||||
}
|
||||
|
||||
|
||||
// Footer options
|
||||
function atticus_finch_display_footer_copyright() {
|
||||
if ( get_theme_mod( 'atticus_finch_display_copyright' ) == '1' ) : {
|
||||
echo '<div id="copyright">' .
|
||||
get_theme_mod( 'atticus_finch_copyright', '<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" id="cc-button" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a>This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.' ) .
|
||||
'</div>';
|
||||
}
|
||||
endif;
|
||||
}
|
||||
|
||||
function atticus_finch_display_footer_credits() {
|
||||
if ( get_theme_mod( 'atticus_finch_display_credits') == '1' ) : {
|
||||
$afwp = '<a href="http://wordpress.org/">WordPress</a>';
|
||||
$afaf = '<a href="http://d12webdesign.com/">Atticus Finch Theme</a>';
|
||||
echo '<div id="credits">';
|
||||
printf(__( 'Powered by %1$s and the %2$s.', 'atticus-finch' ), $afwp, $afaf );
|
||||
echo '</div>';
|
||||
}
|
||||
endif;
|
||||
}
|
||||
|
||||
|
||||
// Custom CSS Option
|
||||
function atticus_finch_custom_css_head() {
|
||||
$afcss = get_theme_mod( 'atticus_finch_ccss' );
|
||||
if ( !empty( $afcss ) ) {
|
||||
echo '<style type="text/css">/* Atticus Finch Custom CSS */' . "\n" . get_theme_mod( 'atticus_finch_ccss' ) . "\n" . '</style>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Social Media
|
||||
function atticus_finch_social_media_display() {
|
||||
if ( get_theme_mod( 'atticus_finch_rss' ) == '1' ) {
|
||||
echo '<a href="' . site_url() . '/feed" class="sm-rss"><span class="fa fa-rss-square"></span></a>';
|
||||
}
|
||||
|
||||
$aftw = get_theme_mod( 'atticus_finch_twitter' );
|
||||
if ( !empty( $aftw ) ) {
|
||||
echo '<a href="' . get_theme_mod( 'atticus_finch_twitter' ) . '" target="_blank" class="sm-twitter"><span class="fa fa-twitter-square"></span></a>';
|
||||
}
|
||||
|
||||
$aft2 = get_theme_mod( 'atticus_finch_twitter2' );
|
||||
if ( !empty( $aft2 ) ) {
|
||||
echo '<a href="' . get_theme_mod( 'atticus_finch_twitter2' ) . '" target="_blank" class="sm-twitter"><span class="fa fa-twitter-square"></span></a>';
|
||||
}
|
||||
|
||||
$affb = get_theme_mod( 'atticus_finch_facebook' );
|
||||
if ( !empty( $affb ) ) {
|
||||
echo '<a href="' . get_theme_mod( 'atticus_finch_facebook' ) . '" target="_blank" class="sm-facebook"><span class="fa fa-facebook-square"></span></a>';
|
||||
}
|
||||
|
||||
$afig = get_theme_mod( 'atticus_finch_instagram' );
|
||||
if ( !empty( $afig ) ) {
|
||||
echo '<a href="' . get_theme_mod( 'atticus_finch_instagram' ) . '" target="_blank" class="sm-instagram"><span class="fa fa-instagram"></span></a>';
|
||||
}
|
||||
|
||||
$afyt = get_theme_mod( 'atticus_finch_youtube' );
|
||||
if ( !empty( $afyt ) ) {
|
||||
echo '<a href="' . get_theme_mod( 'atticus_finch_youtube' ) . '" target="_blank" class="sm-youtube"><span class="fa fa-youtube-square"></span></a>';
|
||||
}
|
||||
|
||||
$afyt = get_theme_mod( 'atticus_finch_pinterest' );
|
||||
if ( !empty( $afyt ) ) {
|
||||
echo '<a href="' . get_theme_mod( 'atticus_finch_pinterest' ) . '" target="_blank" class="sm-pinterest"><span class="fa fa-pinterest-square"></span></a>';
|
||||
}
|
||||
|
||||
$afam = get_theme_mod( 'atticus_finch_amazon' );
|
||||
if ( !empty( $afam ) ) {
|
||||
echo '<a href="' . get_theme_mod( 'atticus_finch_amazon' ) . '" target="_blank" class="sm-amazon"><span class="fa fa-amazon"></span></a>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Mobile Top Link Options
|
||||
function atticus_finch_footer_top_link() {
|
||||
if ( get_theme_mod( 'atticus_finch_footer_top_link' ) == 1 ) {
|
||||
echo '<a href="#" class="top-button">';
|
||||
_e( 'Return to Top', 'atticus-finch' );
|
||||
echo '</a>';
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function atticus_finch_post_top_link() {
|
||||
if ( get_theme_mod( 'atticus_finch_post_top_link' ) == 1 ) {
|
||||
echo '<a href="#" class="top-button">';
|
||||
_e( 'Return to Top', 'atticus-finch' );
|
||||
echo '</a>';
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
544
functions/widget-areas.php
Executable file
544
functions/widget-areas.php
Executable file
@ -0,0 +1,544 @@
|
||||
<?php
|
||||
|
||||
// Our action hook widget areas -- only display them if active
|
||||
|
||||
// header.php action hooks
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_before_header') == '1' ) :
|
||||
add_action('atticus_finch_before_header', 'atticus_finch_before_header_fc' );
|
||||
function atticus_finch_before_header_fc(){
|
||||
if ( is_active_sidebar( 'atticus_finch_before_header' ) ) {
|
||||
echo '<div id="atticus_finch_before_header" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_before_header' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_after_top_menu') == '1' ) :
|
||||
add_action('atticus_finch_after_top_menu', 'atticus_finch_after_top_menu_FC' );
|
||||
function atticus_finch_after_top_menu_FC(){
|
||||
if ( is_active_sidebar( 'atticus_finch_after_top_menu' ) ) {
|
||||
echo '<div id="atticus_finch_after_top_menu" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_after_top_menu' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_before_social_media') == '1' ) :
|
||||
add_action('atticus_finch_before_social_media', 'atticus_finch_before_social_media_fc' );
|
||||
function atticus_finch_before_social_media_fc(){
|
||||
if ( is_active_sidebar( 'atticus_finch_before_social_media' ) ) {
|
||||
echo '<div id="atticus_finch_before_social_media" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_before_social_media' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_before_primary_menu') == '1' ) :
|
||||
add_action('atticus_finch_before_primary_menu', 'atticus_finch_before_primary_menu_fc' );
|
||||
function atticus_finch_before_primary_menu_fc(){
|
||||
if ( is_active_sidebar( 'atticus_finch_before_primary_menu' ) ) {
|
||||
echo '<div id="atticus_finch_before_primary_menu" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_before_primary_menu' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_after_header') == '1' ) :
|
||||
add_action('atticus_finch_after_header', 'atticus_finch_after_header_fc' );
|
||||
function atticus_finch_after_header_fc(){
|
||||
if ( is_active_sidebar( 'atticus_finch_after_header' ) ) {
|
||||
echo '<div id="atticus_finch_after_header" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_after_header' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
// index.php action hooks
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_container_top') == '1' ) :
|
||||
add_action('atticus_finch_container_top', 'atticus_finch_container_top_fc' );
|
||||
function atticus_finch_container_top_fc(){
|
||||
if ( is_active_sidebar( 'atticus_finch_container_top' ) ) {
|
||||
echo '<div id="atticus_finch_container_top" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_container_top' );
|
||||
echo '</div><div class="clear"></div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
// content.php action hooks
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_before_post_title') == '1' ) :
|
||||
add_action('atticus_finch_before_post_title', 'atticus_finch_before_post_title_fc' );
|
||||
function atticus_finch_before_post_title_fc(){
|
||||
if ( is_active_sidebar( 'atticus_finch_before_post_title' ) ) {
|
||||
echo '<div id="atticus_finch_before_post_title" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_before_post_title' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_before_post_content') == '1' ) :
|
||||
add_action('atticus_finch_before_post_content', 'atticus_finch_before_post_content_fc' );
|
||||
function atticus_finch_before_post_content_fc(){
|
||||
if ( is_active_sidebar( 'atticus_finch_before_post_content' ) ) {
|
||||
echo '<div id="atticus_finch_before_post_content" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_before_post_content' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_post_top') == '1' ) :
|
||||
add_action('atticus_finch_post_top', 'atticus_finch_post_top_fc' );
|
||||
function atticus_finch_post_top_fc(){
|
||||
if ( is_active_sidebar( 'atticus_finch_post_top' ) ) {
|
||||
echo '<div id="atticus_finch_post_top" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_post_top' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_post_bottom') == '1' ) :
|
||||
add_action('atticus_finch_post_bottom', 'atticus_finch_post_bottom_fc' );
|
||||
function atticus_finch_post_bottom_fc(){
|
||||
if ( is_active_sidebar( 'atticus_finch_post_bottom' ) ) {
|
||||
echo '<div id="atticus_finch_post_bottom" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_post_bottom' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_after_post_content') == '1' ) :
|
||||
add_action('atticus_finch_after_post_content', 'atticus_finch_after_post_content_fc' );
|
||||
function atticus_finch_after_post_content_fc(){
|
||||
if ( is_active_sidebar( 'atticus_finch_after_post_content' ) ) {
|
||||
echo '<div id="atticus_finch_after_post_content" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_after_post_content' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_before_post_meta') == '1' ) :
|
||||
add_action('atticus_finch_before_post_meta', 'atticus_finch_before_post_meta_fc' );
|
||||
function atticus_finch_before_post_meta_fc(){
|
||||
if ( is_active_sidebar( 'atticus_finch_before_post_meta' ) ) {
|
||||
echo '<div id="atticus_finch_before_post_meta" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_before_post_meta' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_after_post_meta') == '1' ) :
|
||||
add_action('atticus_finch_after_post_meta', 'atticus_finch_after_post_meta_fc' );
|
||||
function atticus_finch_after_post_meta_fc(){
|
||||
if ( is_active_sidebar( 'atticus_finch_after_post_meta' ) ) {
|
||||
echo '<div id="atticus_finch_after_post_meta" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_after_post_meta' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
// comments.php action hooks
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_before_comments') == '1' ) :
|
||||
add_action('atticus_finch_before_comments', 'atticus_finch_before_comments_fc' );
|
||||
function atticus_finch_before_comments_fc(){
|
||||
if ( is_active_sidebar( 'atticus_finch_before_comments' ) ) {
|
||||
echo '<div id="atticus_finch_before_comments" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_before_comments' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_after_comments') == '1' ) :
|
||||
add_action('atticus_finch_after_comments', 'atticus_finch_after_comments_fc' );
|
||||
function atticus_finch_after_comments_fc(){
|
||||
if ( is_active_sidebar( 'atticus_finch_after_comments' ) ) {
|
||||
echo '<div id="atticus_finch_after_comments" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_after_comments' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_before_comment_form') == '1' ) :
|
||||
add_action('atticus_finch_before_comment_form', 'atticus_finch_before_comment_form_fc' );
|
||||
function atticus_finch_before_comment_form_fc(){
|
||||
if ( comments_open() ) : {
|
||||
if ( is_active_sidebar( 'atticus_finch_before_comment_form' ) ) {
|
||||
echo '<div id="atticus_finch_before_comment_form" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_before_comment_form' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_after_comment_form') == '1' ) :
|
||||
add_action('atticus_finch_after_comment_form', 'atticus_finch_after_comment_form_fc' );
|
||||
function atticus_finch_after_comment_form_fc(){
|
||||
if (comments_open() ) : {
|
||||
if ( is_active_sidebar( 'atticus_finch_after_comment_form' ) ) {
|
||||
echo '<div id="atticus_finch_after_comment_form" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_after_comment_form' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
}
|
||||
endif;
|
||||
|
||||
// footer.php action hooks
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_container_bottom') == '1' ) :
|
||||
add_action('atticus_finch_container_bottom', 'atticus_finch_container_bottom_fc' );
|
||||
function atticus_finch_container_bottom_fc(){
|
||||
if ( is_active_sidebar( 'atticus_finch_container_bottom' ) ) {
|
||||
echo '<div class="clear"></div><div id="atticus_finch_container_bottom" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_container_bottom' );
|
||||
echo '</div><div class="clear"></div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_before_footer_menu') == '1' ) :
|
||||
add_action('atticus_finch_before_footer_menu', 'atticus_finch_before_footer_menu_fc' );
|
||||
function atticus_finch_before_footer_menu_fc(){
|
||||
if ( is_active_sidebar( 'atticus_finch_before_footer_menu' ) ) {
|
||||
echo '<div id="atticus_finch_before_footer_menu" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_before_footer_menu' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_footer_top') == '1' ) :
|
||||
add_action('atticus_finch_footer_top', 'atticus_finch_footer_top_fc' );
|
||||
function atticus_finch_footer_top_fc(){
|
||||
if ( is_active_sidebar( 'atticus_finch_footer_top' ) ) {
|
||||
echo '<div id="atticus_finch_footer_top" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_footer_top' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_footer_bottom') == '1' ) :
|
||||
add_action('atticus_finch_footer_bottom', 'atticus_finch_footer_bottom_fc' );
|
||||
function atticus_finch_footer_bottom_fc(){
|
||||
if ( is_active_sidebar( 'atticus_finch_footer_bottom' ) ) {
|
||||
echo '<div id="atticus_finch_footer_bottom" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_footer_bottom' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_after_footer') == '1' ) :
|
||||
add_action('atticus_finch_after_footer', 'atticus_finch_after_footer_fc' );
|
||||
function atticus_finch_after_footer_fc(){
|
||||
if ( is_active_sidebar( 'atticus_finch_after_footer' ) ) {
|
||||
echo '<div id="atticus_finch_after_footer" class="atticus-finch-action-hook">';
|
||||
dynamic_sidebar( 'atticus_finch_after_footer' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
// Register our action hooks as widget areas
|
||||
// codex.wordpress.org/Widgetizing_Themes
|
||||
function greybox_action_hook_widgets() {
|
||||
|
||||
// Header widgets
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_before_header') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'Before Header',
|
||||
'id' => 'atticus_finch_before_header',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages just above the header and the "above header menu" (if you are using one).', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-before-header-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_after_top_menu') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'After Top Menu',
|
||||
'id' => 'atticus_finch_after_top_menu',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages below the top menu and above the site name.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-after-top-menu-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_before_social_media') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'Before Social Media',
|
||||
'id' => 'atticus_finch_before_social_media',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages to the left of the title and to the right of the social media menu.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-before-social-media-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_before_primary_menu') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'Before Primary Menu',
|
||||
'id' => 'atticus_finch_before_primary_menu',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages above the primary menu.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-before-primary-menu-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_after_header') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'After Header',
|
||||
'id' => 'atticus_finch_after_header',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages after the header and before the main content and sidebar.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-after-header-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
// Index widgets
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_container_top') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'Top of Container',
|
||||
'id' => 'atticus_finch_container_top',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages above the sidebar and content.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-container-top-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
// Content widgets
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_before_post_title') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'Before Post Title',
|
||||
'id' => 'atticus_finch_before_post_title',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages before the post title.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-before-post-title-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_before_post_content') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'Before Post Content',
|
||||
'id' => 'atticus_finch_before_post_content',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages after the title and before the post content.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-before-post-content-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_post_top') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'Top of Post',
|
||||
'id' => 'atticus_finch_post_top',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages at the top of the post.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-post-top-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_post_bottom') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'Bottom of Post',
|
||||
'id' => 'atticus_finch_post_bottom',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages at the bottom of the post.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-post-bottom-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_after_post_content') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'After Post Content',
|
||||
'id' => 'atticus_finch_after_post_content',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages after the post content.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-after-post-content-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_before_post_meta') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'Before Post Meta',
|
||||
'id' => 'atticus_finch_before_post_meta',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages before the post meta.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-before-post-meta-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_after_post_meta') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'After Post Meta',
|
||||
'id' => 'atticus_finch_after_post_meta',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages after the post meta.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-after-post-meta-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
// Comments widgets
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_before_comments') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'Before Comments',
|
||||
'id' => 'atticus_finch_before_comments',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages before the comments.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-before-comments-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_after_comments') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'After Comments',
|
||||
'id' => 'atticus_finch_after_comments',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages after the comments.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-after-comments-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_before_comment_form') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'Before Comment Form',
|
||||
'id' => 'atticus_finch_before_comment_form',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages before the comment form.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-before-comment-form-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_after_comment_form') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'After Comment Form',
|
||||
'id' => 'atticus_finch_after_comment_form',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages after the comment form.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-after-comment-form-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
// Footer widgets
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_container_bottom') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'Bottom of Container',
|
||||
'id' => 'atticus_finch_container_bottom',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages before the footer.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-container-bottom-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_before_footer_menu') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'Before Footer Menu',
|
||||
'id' => 'atticus_finch_before_footer_menu',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages before the footer menu.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-before-footer-menu-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_footer_top') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'Footer Top',
|
||||
'id' => 'atticus_finch_footer_top',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages at the top of the footer.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-footer-top-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_footer_bottom') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'Footer Bottom',
|
||||
'id' => 'atticus_finch_footer_bottom',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages at the bottom of the footer.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-footer-bottom-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
if ( get_theme_mod( 'atticus_finch_after_footer') == '1' ) :
|
||||
register_sidebar( array(
|
||||
'name' => 'After Footer',
|
||||
'id' => 'atticus_finch_after_footer',
|
||||
'description' => __( 'Widgets in this area will be shown on all posts and pages after the footer.', 'atticus-finch' ),
|
||||
'before_widget' => '<div class="atticus-finch-after-footer-widget">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
} // end function
|
||||
add_action( 'widgets_init', 'greybox_action_hook_widgets' );
|
122
header.php
Executable file
122
header.php
Executable file
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* The header for our theme.
|
||||
*
|
||||
* Displays all of the <head> section and everything up till <div id="container">
|
||||
*
|
||||
* @package Atticus Finch
|
||||
*/
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html <?php language_attributes(); ?>>
|
||||
<head>
|
||||
<meta charset="<?php bloginfo( 'charset' ); ?>">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="profile" href="http://gmpg.org/xfn/11">
|
||||
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
|
||||
|
||||
<!-- Commented out on 2021.06.27 -->
|
||||
<?php // atticus_finch_custom_css_head(); ?>
|
||||
|
||||
<?php wp_head(); ?>
|
||||
</head>
|
||||
|
||||
<body <?php body_class(); ?>>
|
||||
|
||||
<?php do_action( 'atticus_finch_before_header' ); ?>
|
||||
|
||||
<header>
|
||||
|
||||
<nav id="top-menu">
|
||||
<?php wp_nav_menu( array(
|
||||
'theme_location' => 'top-menu',
|
||||
'fallback_cb' => '',
|
||||
'menu_class' => 'sf-menu',
|
||||
'menu_id' => 'aboveheadermenu-ul',
|
||||
'container' => 'div',
|
||||
'container_id' => 'aboveheadermenu',
|
||||
'depth' => 1
|
||||
) );
|
||||
?>
|
||||
<div class="clear"></div>
|
||||
</nav>
|
||||
|
||||
<?php do_action( 'atticus_finch_after_top_menu' ); ?>
|
||||
|
||||
<div id="header" style="background-image: url('<?php header_image(); ?>');">
|
||||
|
||||
<div id="site-title">
|
||||
<?php if ( is_front_page() ){
|
||||
echo '<h1>' . get_option( 'blogname' ) . '</h1>';
|
||||
} else { ?>
|
||||
<h2><a href="<?php echo home_url(); ?>"><?php bloginfo( 'name' ); ?></a></h2>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div><!-- end #site-title -->
|
||||
|
||||
<div id="site-desc">
|
||||
<?php
|
||||
if ( is_front_page() ){
|
||||
echo '<h2>' . get_option( 'blogdescription' ) . '</h2>';
|
||||
} else {
|
||||
echo '<h3>' . get_option( 'blogdescription' ) . '</h3>';
|
||||
}
|
||||
?>
|
||||
<div class="clear"></div>
|
||||
</div><!-- end #site-desc -->
|
||||
|
||||
<?php do_action( 'atticus_finch_before_social_media'); ?>
|
||||
|
||||
<div id="social-media-menu" class="social-navigation">
|
||||
<?php atticus_finch_social_media_display(); ?>
|
||||
<div class="clear"></div>
|
||||
</div><!-- end #social-media-menu -->
|
||||
|
||||
</div><!-- end #header -->
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php do_action( 'atticus_finch_before_primary_menu' ); ?>
|
||||
|
||||
<!-- Commented out on 2021.06.27 -->
|
||||
<?php // $walker = new Atticus_Finch_Menu_With_Description; ?>
|
||||
|
||||
<nav id="primary-menu">
|
||||
<?php
|
||||
if ( get_theme_mod( 'atticus_finch_main_menu_desc' ) == 1 ) {
|
||||
$array = array(
|
||||
'theme_location' => 'primary-menu',
|
||||
'fallback_cb' => '',
|
||||
'menu_class' => 'sf-menu',
|
||||
'menu_id' => 'belowheadermenu-ul',
|
||||
'container' => 'div',
|
||||
'container_id' => 'belowheadermenu',
|
||||
'depth' => 3,
|
||||
// 'walker' => $walker,
|
||||
);
|
||||
} else {
|
||||
$array = array(
|
||||
'theme_location' => 'primary-menu',
|
||||
'fallback_cb' => '',
|
||||
'menu_class' => 'sf-menu',
|
||||
'menu_id' => 'belowheadermenu-ul',
|
||||
'container' => 'div',
|
||||
'container_id' => 'belowheadermenu',
|
||||
'depth' => 3,
|
||||
);
|
||||
}
|
||||
wp_nav_menu( $array );
|
||||
?>
|
||||
<div class="clear"></div>
|
||||
</nav>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</header>
|
||||
|
||||
<?php do_action( 'atticus_finch_after_header' ); ?>
|
||||
|
||||
<div id="container"><!-- closing tag is in footer.php -->
|
||||
|
||||
<?php do_action( 'atticus_finch_container_top' ); ?>
|
BIN
images/404.jpg
Executable file
BIN
images/404.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
14
inc/content-entry-meta.php
Executable file
14
inc/content-entry-meta.php
Executable file
@ -0,0 +1,14 @@
|
||||
<div class="clear"></div>
|
||||
<div id="post-meta">
|
||||
<?php do_action( 'atticus_finch_before_post_meta' ); ?>
|
||||
<div class="list-pub">
|
||||
<?php atticus_finch_pub(); ?>
|
||||
</div>
|
||||
<div class="list-cat">
|
||||
<?php atticus_finch_cat(); ?>
|
||||
</div>
|
||||
<div class="list-tags">
|
||||
<?php atticus_finch_tags(); ?>
|
||||
</div>
|
||||
<?php do_action( 'atticus_finch_after_post_meta' ); ?>
|
||||
</div>
|
30
inc/content-excerpt.php
Executable file
30
inc/content-excerpt.php
Executable file
@ -0,0 +1,30 @@
|
||||
<!-- Post content -->
|
||||
|
||||
<div class="post-content post-content-<?php echo get_post_format(); ?>">
|
||||
|
||||
<?php do_action( 'atticus_finch_post_top' ); ?>
|
||||
|
||||
<?php the_content(); ?>
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php do_action( 'atticus_finch_post_bottom' ); ?>
|
||||
|
||||
<?php atticus_finch_print_options() ?>
|
||||
|
||||
</div><!-- end post content -->
|
||||
|
||||
<?php do_action( 'atticus_finch_after_post_content' ); ?>
|
||||
|
||||
<?php atticus_finch_link_pages(); ?>
|
||||
|
||||
<?php do_action( 'atticus_finch_before_post_meta' ); ?>
|
||||
|
||||
<?php get_template_part( 'inc/content', 'entry-meta' ); ?>
|
||||
|
||||
<?php do_action( 'atticus_finch_after_post_meta' ); ?>
|
||||
|
||||
<?php get_template_part( 'inc/content', 'post-nav' ); ?>
|
||||
|
||||
<?php atticus_finch_comment_display(); ?>
|
||||
|
||||
</div><!-- end post -->
|
28
inc/content-main.php
Executable file
28
inc/content-main.php
Executable file
@ -0,0 +1,28 @@
|
||||
<!-- Post content -->
|
||||
|
||||
<?php get_template_part( 'inc/content', 'entry-meta' ); ?>
|
||||
|
||||
<div class="post-content">
|
||||
|
||||
<?php do_action( 'atticus_finch_post_top' ); ?>
|
||||
|
||||
<?php the_content(); ?>
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php do_action( 'atticus_finch_post_bottom' ); ?>
|
||||
|
||||
<?php atticus_finch_print_options() ?>
|
||||
|
||||
</div><!-- end post content -->
|
||||
|
||||
<?php atticus_finch_post_top_link(); ?>
|
||||
|
||||
<?php atticus_finch_link_pages(); ?>
|
||||
|
||||
<?php get_template_part( 'inc/content', 'post-nav' ); ?>
|
||||
|
||||
<?php atticus_finch_comment_display(); ?>
|
||||
|
||||
</div><!-- end post -->
|
||||
|
||||
<?php do_action( 'atticus_finch_after_post_content' ); ?>
|
9
inc/content-post-nav.php
Executable file
9
inc/content-post-nav.php
Executable file
@ -0,0 +1,9 @@
|
||||
<div id="post-series">
|
||||
<div class="post-next">
|
||||
<?php atticus_finch_next_post_link(); ?>
|
||||
</div>
|
||||
<div class="post-prev">
|
||||
<?php atticus_finch_prev_post_link(); ?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
6
inc/excerpt-entry-meta.php
Executable file
6
inc/excerpt-entry-meta.php
Executable file
@ -0,0 +1,6 @@
|
||||
<div class="entry-meta">
|
||||
<p><?php atticus_finch_pub(); ?></p>
|
||||
<p><?php atticus_finch_cat(); ?></p>
|
||||
<p><?php atticus_finch_tags(); ?></p>
|
||||
<div class="clear"></div>
|
||||
</div>
|
5
inc/excerpt-short-meta.php
Executable file
5
inc/excerpt-short-meta.php
Executable file
@ -0,0 +1,5 @@
|
||||
<div class="aside-meta">
|
||||
<?php
|
||||
printf(__( 'Published on %1$s at %2$s', 'atticus-finch'), atticus_finch_date(), get_the_time() );
|
||||
?>
|
||||
</div>
|
36
inc/page-main.php
Executable file
36
inc/page-main.php
Executable file
@ -0,0 +1,36 @@
|
||||
<!-- Post content -->
|
||||
|
||||
<div class="post-content">
|
||||
|
||||
<?php do_action( 'atticus_finch_post_top' ); ?>
|
||||
|
||||
<?php the_content(); ?>
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php do_action( 'atticus_finch_post_bottom' ); ?>
|
||||
|
||||
<div id="page-info">
|
||||
<p>
|
||||
<?php
|
||||
_e( 'Published on: ', 'atticus-finch' );
|
||||
the_date();
|
||||
?>
|
||||
</p>
|
||||
<p>
|
||||
<?php
|
||||
_e( 'Lasted edited on: ', 'atticus-finch' );
|
||||
the_modified_date();
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php atticus_finch_print_options() ?>
|
||||
|
||||
</div><!-- end post content -->
|
||||
|
||||
|
||||
<?php atticus_finch_comment_display(); ?>
|
||||
|
||||
|
||||
<?php do_action( 'atticus_finch_after_post_content' ); ?>
|
||||
|
37
index.php
Executable file
37
index.php
Executable file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* The main template file.
|
||||
*
|
||||
* This is the most generic template file in a WordPress theme
|
||||
* and one of the two required files for a theme (the other being style.css).
|
||||
* It is used to display a page when nothing more specific matches a query.
|
||||
* E.g., it puts together the home page when no home.php file exists.
|
||||
* Learn more: http://codex.wordpress.org/Template_Hierarchy
|
||||
*
|
||||
* @package Atticus Finch
|
||||
*/
|
||||
|
||||
get_header();
|
||||
|
||||
?>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<!-- Start the loop -->
|
||||
<?php if ( have_posts() ) : ?>
|
||||
<?php while ( have_posts() ) : the_post(); ?>
|
||||
|
||||
<?php get_template_part( 'formats/excerpt', get_post_format() ); ?>
|
||||
|
||||
<!-- End the loop -->
|
||||
<?php endwhile; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php atticus_finch_display_nav(); ?>
|
||||
</div> <!-- end Content -->
|
||||
|
||||
<?php atticus_finch_post_top_link(); ?>
|
||||
|
||||
<?php get_sidebar(); ?>
|
||||
|
||||
<?php get_footer(); ?>
|
44
js/customizer.js
Executable file
44
js/customizer.js
Executable file
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* customizer.js
|
||||
*
|
||||
* Theme Customizer enhancements for a better user experience.
|
||||
*
|
||||
* Contains handlers to make Theme Customizer preview reload changes asynchronously.
|
||||
*/
|
||||
|
||||
( function( $ ) {
|
||||
// Site title and description.
|
||||
wp.customize( 'blogname', function( value ) {
|
||||
value.bind( function( to ) {
|
||||
$( '.site-title a' ).text( to );
|
||||
} );
|
||||
} );
|
||||
wp.customize( 'blogdescription', function( value ) {
|
||||
value.bind( function( to ) {
|
||||
$( '.site-description' ).text( to );
|
||||
} );
|
||||
} );
|
||||
// Header text color.
|
||||
wp.customize( 'header_textcolor', function( value ) {
|
||||
value.bind( function( to ) {
|
||||
if ( 'blank' === to ) {
|
||||
$( '.site-title, .site-description' ).css( {
|
||||
'clip': 'rect(1px, 1px, 1px, 1px)',
|
||||
'position': 'absolute'
|
||||
} );
|
||||
} else {
|
||||
$( '.site-title, .site-description' ).css( {
|
||||
'clip': 'auto',
|
||||
'color': to,
|
||||
'position': 'relative'
|
||||
} );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
// Social Media Options
|
||||
wp.customize( 'atticus_finch_twitter', function( value ) {
|
||||
value.bind( function( to ) {
|
||||
$( '#social-media-menu' ).text( to );
|
||||
} );
|
||||
} );
|
||||
} )( jQuery );
|
1
js/menumaker.min.js
vendored
Executable file
1
js/menumaker.min.js
vendored
Executable file
@ -0,0 +1 @@
|
||||
!function(e){e.fn.menumaker=function(n){var s=e(this),t=e.extend({title:"Menu",format:"dropdown",breakpoint:768,sticky:!1},n);return this.each(function(){if(s.find("li ul").parent().addClass("has-sub"),"select"!=t.format)s.prepend('<div id="menu-button">'+t.title+"</div>"),e(this).find("#menu-button").on("click",function(){e(this).toggleClass("menu-opened");var n=e(this).next("ul");n.hasClass("open")?n.hide().removeClass("open"):(n.show().addClass("open"),"dropdown"===t.format&&n.find("ul").show())}),multiTg=function(){s.find(".has-sub").prepend('<span class="submenu-button"></span>'),s.find(".submenu-button").on("click",function(){e(this).toggleClass("submenu-opened"),e(this).siblings("ul").hasClass("open")?e(this).siblings("ul").removeClass("open").hide():e(this).siblings("ul").addClass("open").show()})},"multitoggle"===t.format?multiTg():s.addClass("dropdown");else if("select"===t.format){s.append('<select style="width: 100%"/>').addClass("select-list");var n=s.find("select");n.append("<option>"+t.title+"</option>",{selected:"selected",value:""}),s.find("a").each(function(){console.log(e(this).parents("ul").length);var s=e(this),t="";for(i=1;i<s.parents("ul").length;i++)t+="-";n.append('<option value="'+e(this).attr("href")+'">'+t+s.text()+"</option")}),n.on("change",function(){window.location=e(this).find("option:selected").val()})}return t.sticky===!0&&s.css("position","fixed"),resizeFix=function(){e(window).width()>t.breakpoint&&(s.find("ul").show(),s.removeClass("small-screen"),"select"===t.format&&s.find("select").hide()),e(window).width()<=t.breakpoint&&(s.find("ul").hide().removeClass("open"),s.addClass("small-screen"),"select"===t.format&&s.find("select").show())},resizeFix(),e(window).on("resize",resizeFix)})}}(jQuery);
|
81
js/navigation.js
Executable file
81
js/navigation.js
Executable file
@ -0,0 +1,81 @@
|
||||
/**
|
||||
* navigation.js
|
||||
*
|
||||
* Handles toggling the navigation menu for small screens and enables tab
|
||||
* support for dropdown menus.
|
||||
*/
|
||||
( function() {
|
||||
var container, button, menu, links, subMenus;
|
||||
|
||||
container = document.getElementById( 'site-navigation' );
|
||||
if ( ! container ) {
|
||||
return;
|
||||
}
|
||||
|
||||
button = container.getElementsByTagName( 'button' )[0];
|
||||
if ( 'undefined' === typeof button ) {
|
||||
return;
|
||||
}
|
||||
|
||||
menu = container.getElementsByTagName( 'ul' )[0];
|
||||
|
||||
// Hide menu toggle button if menu is empty and return early.
|
||||
if ( 'undefined' === typeof menu ) {
|
||||
button.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
menu.setAttribute( 'aria-expanded', 'false' );
|
||||
if ( -1 === menu.className.indexOf( 'nav-menu' ) ) {
|
||||
menu.className += ' nav-menu';
|
||||
}
|
||||
|
||||
button.onclick = function() {
|
||||
if ( -1 !== container.className.indexOf( 'toggled' ) ) {
|
||||
container.className = container.className.replace( ' toggled', '' );
|
||||
button.setAttribute( 'aria-expanded', 'false' );
|
||||
menu.setAttribute( 'aria-expanded', 'false' );
|
||||
} else {
|
||||
container.className += ' toggled';
|
||||
button.setAttribute( 'aria-expanded', 'true' );
|
||||
menu.setAttribute( 'aria-expanded', 'true' );
|
||||
}
|
||||
};
|
||||
|
||||
// Get all the link elements within the menu.
|
||||
links = menu.getElementsByTagName( 'a' );
|
||||
subMenus = menu.getElementsByTagName( 'ul' );
|
||||
|
||||
// Set menu items with submenus to aria-haspopup="true".
|
||||
for ( var i = 0, len = subMenus.length; i < len; i++ ) {
|
||||
subMenus[i].parentNode.setAttribute( 'aria-haspopup', 'true' );
|
||||
}
|
||||
|
||||
// Each time a menu link is focused or blurred, toggle focus.
|
||||
for ( i = 0, len = links.length; i < len; i++ ) {
|
||||
links[i].addEventListener( 'focus', toggleFocus, true );
|
||||
links[i].addEventListener( 'blur', toggleFocus, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets or removes .focus class on an element.
|
||||
*/
|
||||
function toggleFocus() {
|
||||
var self = this;
|
||||
|
||||
// Move up through the ancestors of the current link until we hit .nav-menu.
|
||||
while ( -1 === self.className.indexOf( 'nav-menu' ) ) {
|
||||
|
||||
// On li elements toggle the class .focus.
|
||||
if ( 'li' === self.tagName.toLowerCase() ) {
|
||||
if ( -1 !== self.className.indexOf( 'focus' ) ) {
|
||||
self.className = self.className.replace( ' focus', '' );
|
||||
} else {
|
||||
self.className += ' focus';
|
||||
}
|
||||
}
|
||||
|
||||
self = self.parentElement;
|
||||
}
|
||||
}
|
||||
} )();
|
33
js/skip-link-focus-fix.js
Executable file
33
js/skip-link-focus-fix.js
Executable file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* skip-link-focus-fix.js
|
||||
*
|
||||
* Helps with accessibility for keyboard only users.
|
||||
*
|
||||
* Learn more: https://github.com/Automattic/Atticus Finch/pull/136
|
||||
*/
|
||||
( function() {
|
||||
var is_webkit = navigator.userAgent.toLowerCase().indexOf( 'webkit' ) > -1,
|
||||
is_opera = navigator.userAgent.toLowerCase().indexOf( 'opera' ) > -1,
|
||||
is_ie = navigator.userAgent.toLowerCase().indexOf( 'msie' ) > -1;
|
||||
|
||||
if ( ( is_webkit || is_opera || is_ie ) && document.getElementById && window.addEventListener ) {
|
||||
window.addEventListener( 'hashchange', function() {
|
||||
var id = location.hash.substring( 1 ),
|
||||
element;
|
||||
|
||||
if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
element = document.getElementById( id );
|
||||
|
||||
if ( element ) {
|
||||
if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) {
|
||||
element.tabIndex = -1;
|
||||
}
|
||||
|
||||
element.focus();
|
||||
}
|
||||
}, false );
|
||||
}
|
||||
})();
|
0
lang/.gitignore
vendored
Executable file
0
lang/.gitignore
vendored
Executable file
2
notes.txt
Normal file
2
notes.txt
Normal file
@ -0,0 +1,2 @@
|
||||
2021.06.27
|
||||
Theme was not working on localhost. Commented out all lines in header.php that referred to the walker. These is now working.
|
40
page-no-sidebar.php
Executable file
40
page-no-sidebar.php
Executable file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* <?php
|
||||
*
|
||||
* Template Name: Full Width Page
|
||||
*
|
||||
*
|
||||
* @package Atticus Finch
|
||||
*/
|
||||
|
||||
get_header();
|
||||
|
||||
?>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<?php do_action( 'atticus_finch_before_post_title' ); ?>
|
||||
|
||||
<h1 class="post-title">
|
||||
<span class="dashicons dashicons-admin-page"></span>
|
||||
<?php the_title(); ?>
|
||||
</h1>
|
||||
|
||||
<!-- Start the loop -->
|
||||
<?php if ( have_posts() ) : ?>
|
||||
<?php while ( have_posts() ) : the_post(); ?>
|
||||
|
||||
<?php get_template_part( 'inc/page', 'main' ); ?>
|
||||
|
||||
<!-- End the loop -->
|
||||
<?php endwhile; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
</div> <!-- end Content -->
|
||||
|
||||
<?php get_footer(); ?>
|
49
page.php
Executable file
49
page.php
Executable file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* The page template file.
|
||||
*
|
||||
* This is the most generic template file in a WordPress theme
|
||||
* and one of the two required files for a theme (the other being style.css).
|
||||
* It is used to display a page when nothing more specific matches a query.
|
||||
* E.g., it puts together the home page when no home.php file exists.
|
||||
* Learn more: http://codex.wordpress.org/Template_Hierarchy
|
||||
*
|
||||
* @package Atticus Finch
|
||||
*/
|
||||
|
||||
get_header();
|
||||
|
||||
?>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php atticus_finch_edit_post(); ?>
|
||||
|
||||
<?php do_action( 'atticus_finch_before_post_title' ); ?>
|
||||
|
||||
<h1 class="post-title">
|
||||
<span class="dashicons dashicons-admin-page"></span>
|
||||
<?php the_title(); ?>
|
||||
</h1>
|
||||
|
||||
<!-- Start the loop -->
|
||||
<?php if ( have_posts() ) : ?>
|
||||
<?php while ( have_posts() ) : the_post(); ?>
|
||||
|
||||
<?php get_template_part( 'inc/page', 'main' ); ?>
|
||||
|
||||
<!-- End the loop -->
|
||||
<?php endwhile; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
</div><!-- end Post -->
|
||||
|
||||
</div><!-- end Content -->
|
||||
|
||||
<?php get_sidebar(); ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php get_footer(); ?>
|
45
readme.md
Normal file
45
readme.md
Normal file
@ -0,0 +1,45 @@
|
||||
# Atticus Finch #
|
||||
* Contributors: @kjodle
|
||||
* Tags: black, gray, white, fixed-layout, two-columns, left-sidebar, custom-menu, featured-images, post-formats, theme-options, threaded-comments, translation-ready
|
||||
* Requires at least: 1.0
|
||||
* Tested up to: 1.2
|
||||
* ~~Stable tag: 0.9.1~~ (Not sure how this will work under ClassicPress.)
|
||||
* License: GPLv2 or later
|
||||
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
## Description ##
|
||||
|
||||
af2 is a spinoff of the Atticus Finch theme I originally designed for use on my WordPress blogs. Because of my dissatisfaction with WordPress and the block editor, I stopped developing it for some time. After transitioning to [ClassicPress](https://www.classicpress.net/), I decided to continue developing it, but changed the name to "af2" to avoid confusion.
|
||||
|
||||
For more information about Atticus Finch please go to http://wiki.kjodle.net/Category:Atticus_Finch_Theme.
|
||||
|
||||
|
||||
## Installation ##
|
||||
|
||||
1. In your admin panel, go to Appearance -> Themes and click the 'Add New' button.
|
||||
1. Upload the zip file.
|
||||
|
||||
## Copyright ##
|
||||
|
||||
Atticus Finch WordPress Theme, Copyright 2021 Kenneth John Odle.
|
||||
Atticus Finch is distributed under the terms of the GNU GPL.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
The Atticus Finch theme bundles the following third-party resources:
|
||||
|
||||
FontAwesome Icon Font, Copyright 2016 Dave Gandy
|
||||
License: MIT (http://opensource.org/licenses/mit-license.html)
|
||||
Source: https://fortawesome.github.io/Font-Awesome/
|
||||
|
||||
IM Fell English Font, Copyright 2016 Igino Marini
|
||||
License: SIL (http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL)
|
||||
Source: https://www.google.com/fonts/specimen/IM+Fell+English
|
||||
|
||||
Superfish jQuery Menu Plugin, Copyright 2015 Joel Birch
|
||||
License: MIT (http://opensource.org/licenses/mit-license.html)
|
||||
Source: http://users.tpg.com.au/j_birch/plugins/superfish/
|
||||
|
||||
## Notes ##
|
44
readme.txt
Executable file
44
readme.txt
Executable file
@ -0,0 +1,44 @@
|
||||
=== Portage ===
|
||||
Contributors: kjodle
|
||||
Tags: black, gray, white, fixed-layout, two-columns, left-sidebar, custom-menu, featured-images, post-formats, theme-options, threaded-comments, translation-ready
|
||||
Requires at least: 4.1
|
||||
Tested up to: 4.7.5
|
||||
Stable tag: 0.1.0 ~~Not sure how this works under ClassicPress
|
||||
License: GPLv2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
== Description ==
|
||||
|
||||
For more information about Atticus Finch please go to http://wiki.kjodle.net/Category:Atticus_Finch_Theme.
|
||||
|
||||
As of version 0.1.0, development is exclusively for ClassicPress.
|
||||
|
||||
== Installation ==
|
||||
|
||||
1. In your admin panel, go to Appearance -> Themes and click the 'Add New' button.
|
||||
2.
|
||||
|
||||
== Copyright ==
|
||||
|
||||
Portage ClassicPress Theme, Copyright 2021 Kenneth John Odle
|
||||
Portage is distributed under the terms of the GNU GPL
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
The Atticus Finch theme bundles the following third-party resources:
|
||||
|
||||
FontAwesome Icon Font, Copyright 2016 Dave Gandy
|
||||
License: MIT (http://opensource.org/licenses/mit-license.html)
|
||||
Source: https://fortawesome.github.io/Font-Awesome/
|
||||
|
||||
IM Fell English Font, Copyright 2016 Igino Marini
|
||||
License: SIL (http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL)
|
||||
Source: https://www.google.com/fonts/specimen/IM+Fell+English
|
||||
|
||||
Superfish jQuery Menu Plugin, Copyright 2015 Joel Birch
|
||||
License: MIT (http://opensource.org/licenses/mit-license.html)
|
||||
Source: http://users.tpg.com.au/j_birch/plugins/superfish/
|
||||
|
||||
== Notes ==
|
BIN
screenshot.png
Executable file
BIN
screenshot.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
15
sidebar.php
Executable file
15
sidebar.php
Executable file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* The sidebar containing the main widget area.
|
||||
*
|
||||
* @package Atticus Finch
|
||||
*/
|
||||
|
||||
if ( ! is_active_sidebar( 'sidebar-1' ) ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="sidebar" class="widget-area" role="complementary">
|
||||
<?php dynamic_sidebar( 'sidebar-1' ); ?>
|
||||
</div><!-- end #sidebar -->
|
33
single.php
Executable file
33
single.php
Executable file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* The template for displaying all single posts and attachments
|
||||
*
|
||||
* @package Atticus Finch
|
||||
*/
|
||||
|
||||
get_header();
|
||||
|
||||
?>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<article>
|
||||
<!-- Start the loop -->
|
||||
<?php if (have_posts()) : ?>
|
||||
<?php while (have_posts()) : the_post(); ?>
|
||||
|
||||
<?php get_template_part( 'formats/content', get_post_format() ); ?>
|
||||
|
||||
<!-- End the loop -->
|
||||
<?php endwhile; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
</article>
|
||||
|
||||
</div> <!-- end Content -->
|
||||
|
||||
<?php get_sidebar(); ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php get_footer(); ?>
|
787
style.css
Executable file
787
style.css
Executable file
@ -0,0 +1,787 @@
|
||||
/*
|
||||
Theme Name: Portage
|
||||
Theme URI: http://wiki.kjodle.net/Category:Atticus_Finch_Theme
|
||||
Author: kjodle
|
||||
Author URI: http://d12webdesign.com/
|
||||
Description: Description
|
||||
Version: 0.1.0
|
||||
License: GNU General Public License v2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
Tags: two-columns, left-sidebar, custom-menu, featured-images, post-formats, theme-options, threaded-comments, translation-ready
|
||||
Text Domain: portage
|
||||
Details URI: http://wiki.kjodle.net/Category:Atticus_Finch_Theme
|
||||
|
||||
This theme, like WordPress, is licensed under the GPL.
|
||||
Use it to make something cool, have fun, and share what you've learned with others.
|
||||
*/
|
||||
|
||||
/**********************************/
|
||||
/*
|
||||
* 1. Simple Resets
|
||||
* 2. Main Containers
|
||||
* 3. Top Elements
|
||||
* 4. #content Elements
|
||||
* 5. .post Elements
|
||||
* 6. Post Formats
|
||||
* 7. Comments
|
||||
* 8. Sidebar Elements
|
||||
* 9. Footer Elements
|
||||
* 10. Special Sections
|
||||
* 11. Archive Pages
|
||||
* 12. Action Hook Widget Areas
|
||||
* 13. Social Media Menu
|
||||
* 14. Required by WordPress
|
||||
* 15. Miscellaneous Fixes
|
||||
*
|
||||
/**********************************/
|
||||
|
||||
|
||||
|
||||
/**********************************/
|
||||
/* 1. Simple Resets */
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: serif;
|
||||
}
|
||||
|
||||
body {
|
||||
color: #222;
|
||||
}
|
||||
|
||||
pre {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
|
||||
/**********************************/
|
||||
/* 2. Main Containers */
|
||||
|
||||
#container {
|
||||
margin: 0px auto;
|
||||
max-width: 1000px;
|
||||
min-width: 700px;
|
||||
width: 80%;
|
||||
background: #ffffff;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
#sidebar {
|
||||
float: left;
|
||||
padding-right: 6%;
|
||||
text-align: right;
|
||||
width: 26%;
|
||||
}
|
||||
|
||||
#content {
|
||||
float: right;
|
||||
padding: 0 2%;
|
||||
width: 74%;
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
.page-template-page-no-sidebar #content {
|
||||
border-left: none;
|
||||
width: 80%;
|
||||
padding: 0;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
float: none;
|
||||
}
|
||||
|
||||
body > footer {
|
||||
clear: both;
|
||||
width: 100%;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
body > header {
|
||||
border-bottom: solid 1px #444;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
body > footer {
|
||||
border-top: solid 1px #444;
|
||||
}
|
||||
|
||||
|
||||
/**********************************/
|
||||
/* 3. Top Elements */
|
||||
|
||||
#site-title {
|
||||
position: relative;
|
||||
clear: both;
|
||||
width: 60%;
|
||||
float: left;
|
||||
padding: 24px 0 24px 30px;
|
||||
}
|
||||
|
||||
#site-title h1,
|
||||
#site-title h2 {
|
||||
font-size: 28px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
#site-title a {
|
||||
text-decoration: none;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
#site-desc {
|
||||
position: relative;
|
||||
width: 20%;
|
||||
float: right;
|
||||
padding: 1.8em 1em 1.8em 1em;
|
||||
font-style: italic;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
#site-desc h2,
|
||||
#site-desc h3 {
|
||||
font-size: 16px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
nav#top-menu,
|
||||
nav#primary-menu {
|
||||
background: #fafafa;
|
||||
font-size: 14px;
|
||||
position: relative;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
p.sub { /* Style main menu descriptions */
|
||||
margin: 0.3em 0 0 0;
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
||||
/**********************************/
|
||||
/* 4. #content Elements */
|
||||
|
||||
#content h2:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
a.top-button {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/**********************************/
|
||||
/* 5. .post Elements */
|
||||
|
||||
.home .post,
|
||||
.archive .post {
|
||||
border-top: solid 1px #888;
|
||||
margin-top: 1.2em;
|
||||
padding-top: 1.2em;
|
||||
}
|
||||
.home .post:first-child,
|
||||
.archive .post:first-child {
|
||||
border-top: none;
|
||||
padding-top: 0;
|
||||
margin-top: 0;
|
||||
}
|
||||
.home .post:last-child,
|
||||
.archive .post:last-child {
|
||||
border-bottom: solid 1px #888;
|
||||
}
|
||||
|
||||
.post p,
|
||||
.post li {
|
||||
font-size: 1rem;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.post li {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.post-content a {
|
||||
text-decoration: none;
|
||||
border-bottom: dotted 1px #222;
|
||||
color: #222;
|
||||
-webkit-transition: border-color 1s;
|
||||
transition: border-color 1s, color 1s;
|
||||
}
|
||||
.post.sticky a {
|
||||
border-bottom: dotted 1px #efefef;
|
||||
-webkit-transition: border-color 1s;
|
||||
transition: border-color 1s;
|
||||
}
|
||||
.post-content a:hover {
|
||||
border-color: #eee;
|
||||
color: #3437e5;
|
||||
}
|
||||
|
||||
/* Remove borders on image links */
|
||||
.post-content a[href$=jpg],
|
||||
.post-content a[href$=jpeg],
|
||||
.post-content a[href$=jpe],
|
||||
.post-content a[href$=png],
|
||||
.post-content a[href$=gif] {
|
||||
text-decoration: none;
|
||||
border: 0 none;
|
||||
}
|
||||
|
||||
.post-title {
|
||||
font-size: 24px;
|
||||
margin: 0;
|
||||
}
|
||||
.post-title a {
|
||||
color: #444;
|
||||
border-bottom: dotted 1px #fff;
|
||||
-webkit-transition: border-color 2s, color 2s;
|
||||
transition: border-color 2s, color 2s;
|
||||
}
|
||||
.post-title a:hover {
|
||||
border-color: #888;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.tags-links,
|
||||
.cat-links,
|
||||
.edit-link {
|
||||
font-size: 12px;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
.tags-links a,
|
||||
.cat-links a,
|
||||
.edit-link a {
|
||||
text-decoration: none;
|
||||
color: #444;
|
||||
}
|
||||
|
||||
.entry-meta {
|
||||
padding-top: 6px;
|
||||
text-align: right;
|
||||
}
|
||||
.entry-meta a {
|
||||
text-decoration: none;
|
||||
color: #444;
|
||||
border-bottom: dotted 1px #fff;
|
||||
}
|
||||
.entry-meta a:hover {
|
||||
border-bottom: dotted 1px #999;
|
||||
}
|
||||
.entry-meta p {
|
||||
margin: 0;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.edit-post {
|
||||
float: right;
|
||||
clear: both;
|
||||
background: #fff;
|
||||
margin: 0;
|
||||
}
|
||||
.edit-post a {
|
||||
padding: 6px;
|
||||
font-size: 10px;
|
||||
text-decoration: none;
|
||||
color: #555;
|
||||
font-family: monospace;
|
||||
display: block;
|
||||
}
|
||||
.edit-post a:hover {
|
||||
background: #fee;
|
||||
}
|
||||
|
||||
#post-meta {
|
||||
border-top: solid 1px #bbb;
|
||||
padding: 6px 0;
|
||||
margin: 12px 0 0 0;
|
||||
}
|
||||
.list-pub a,
|
||||
.list-cat a,
|
||||
.list-tags a {
|
||||
text-decoration: none;
|
||||
color: #444;
|
||||
}
|
||||
.list-pub a:hover,
|
||||
.list-cat a:hover,
|
||||
.list-tags a:hover{
|
||||
border-bottom: dotted 1px #444;
|
||||
}
|
||||
.list-pub,
|
||||
.list-cat,
|
||||
.list-tags {
|
||||
padding: 4px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#post-series {
|
||||
border-top: solid 1px #bbb;
|
||||
border-bottom: solid 1px #bbb;
|
||||
padding: 6px 9px;
|
||||
margin: 0 0 12px 0;
|
||||
font-size: 16px;
|
||||
}
|
||||
#post-series a {
|
||||
text-decoration: none;
|
||||
color: #222;
|
||||
padding: 6px 6px 4px 6px;
|
||||
}
|
||||
#post-series p {
|
||||
margin-bottom: 3px;
|
||||
margin-top: 0;
|
||||
font-size: 16px;
|
||||
}
|
||||
.post-prev {
|
||||
float: left;
|
||||
display: inline-block;
|
||||
}
|
||||
.post-next {
|
||||
float: right;
|
||||
display: inline-block;
|
||||
text-align: right;
|
||||
}
|
||||
.post-prev a,
|
||||
.post-next a {
|
||||
transition: background 1s;
|
||||
}
|
||||
.post-prev a:hover,
|
||||
.post-next a:hover {
|
||||
background: #eef;
|
||||
}
|
||||
|
||||
|
||||
/**********************************/
|
||||
/* 6. Post Formats */
|
||||
|
||||
.aside-meta { /* For aside, link, quote, status on front page */
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.dashicons,
|
||||
.dashicons-before::before {
|
||||
font-size: 24px;
|
||||
margin-top: 1px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
.notitle {
|
||||
font-size: 48px !important; /* Mark as important because of Font Awesome settings */
|
||||
float: left;
|
||||
color: #444;
|
||||
margin-bottom: 0px;
|
||||
padding-right: 14px;
|
||||
}
|
||||
.home .notitle {
|
||||
font-size: 24px !important;
|
||||
}
|
||||
.notitle-h2 {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
a .dashicons-format-aside,
|
||||
a .dashicons-admin-links,
|
||||
a .dashicons-format-quote,
|
||||
a .dashicons-format-status {
|
||||
text-decoration: none;
|
||||
color: #444;
|
||||
}
|
||||
|
||||
/* Chat Posts */
|
||||
.format-chat .post-content p{
|
||||
background: #E9E9E9; /* The background color of first paragraph */
|
||||
border-left: 7px solid #C9C9C9; /* The setting for border of first paragraph */
|
||||
margin-bottom: 2px;
|
||||
padding: 6px 0 6px 13px;
|
||||
}
|
||||
.format-chat .post-content p:nth-child(odd) {
|
||||
background: #F7F7F7; /* The background color of next paragraph */
|
||||
border-left-color: #E0E0E0; /* The setting for border of next paragraph */
|
||||
}
|
||||
|
||||
div.post-content > p { /* Eliminate top margin on aside, link, quote, status if title is not displayed */
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
/* Quote Posts */
|
||||
.format-quote .post-content p {
|
||||
font-weight: bold;
|
||||
font-size: 24px;
|
||||
}
|
||||
.format-quote .post-content p:last-of-type {
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
text-align: right;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
|
||||
/**********************************/
|
||||
/* 7. Comments */
|
||||
|
||||
ol.comment-list {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
div.comment,
|
||||
div.pingback {
|
||||
font-size: 14px;
|
||||
margin: 6px 0px;
|
||||
box-shadow: 2px 2px 2px 0 #eee;
|
||||
color: #222;
|
||||
padding: 0 0 10px 20px;
|
||||
}
|
||||
|
||||
|
||||
/**********************************/
|
||||
/* 8. Sidebar elements */
|
||||
|
||||
#sidebar {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
#sidebar h2 {
|
||||
font-size: 17px;
|
||||
margin-bottom: 0.8em;
|
||||
margin-top: 1.5em;
|
||||
}
|
||||
|
||||
#sidebar h2:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
#sidebar ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#sidebar li {
|
||||
list-style-type: none;
|
||||
padding-bottom: 0.6em;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
#sidebar a {
|
||||
text-decoration: none;
|
||||
color: #444;
|
||||
border-bottom: dotted 1px #fff;
|
||||
transition: border-color 1s;
|
||||
-webkit-transition: border-color 1s;
|
||||
}
|
||||
|
||||
#sidebar a:hover {
|
||||
border-bottom: dotted 1px #222;
|
||||
}
|
||||
|
||||
#sidebar .screen-reader-text {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#sidebar td,
|
||||
#sidebar table caption,
|
||||
#sidebar thead,
|
||||
#sidebar tfoot {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
|
||||
/**********************************/
|
||||
/* 9. Footer Elements */
|
||||
|
||||
footer {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
footer a {
|
||||
text-decoration: none;
|
||||
color: #777;
|
||||
border-bottom: dotted 1px #fff;
|
||||
transition: border-color 1s;
|
||||
}
|
||||
footer a:hover {
|
||||
border-color: #444;
|
||||
}
|
||||
|
||||
#copyright,
|
||||
#credits {
|
||||
margin: 10px;
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
#copyright {
|
||||
float: left;
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
#cc-button {
|
||||
float: left;
|
||||
padding: 0 4px 4px 0;
|
||||
}
|
||||
|
||||
#credits {
|
||||
float: right;
|
||||
text-align: right;
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
ul#footermenu-ul {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
/**********************************/
|
||||
/* 10. Special Sections */
|
||||
|
||||
#page-info {
|
||||
border-bottom: solid 1px #fff;
|
||||
padding: 3px 0;
|
||||
transition: border-color 2s;
|
||||
}
|
||||
#page-info:hover {
|
||||
border-color: #ddd;
|
||||
}
|
||||
#page-info p {
|
||||
margin: 0 0 2px;
|
||||
font-size: 13px;
|
||||
font-style: italic;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.clear {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.printonly {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
/**********************************/
|
||||
/* 11. Archive Pages */
|
||||
|
||||
#archive-title {
|
||||
border: solid 1px #999;
|
||||
background: #fff;
|
||||
padding: 9px 12px;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
color: #555;
|
||||
}
|
||||
#posts-nav {
|
||||
border-top: 1px solid #777;
|
||||
margin: 2em 0.8em 0;
|
||||
padding: 6px;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
}
|
||||
#posts-nav a {
|
||||
text-decoration: none;
|
||||
color: #222;
|
||||
}
|
||||
#posts-nav a:hover {
|
||||
border-bottom: dotted 1px #444;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**********************************/
|
||||
/* 12. Action Hook Widget Areas */
|
||||
|
||||
#atticus_finch_before_social_media,
|
||||
#atticus_finch_after_footer,
|
||||
#atticus_finch_footer_bottom {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
/**********************************/
|
||||
/* 13. Social Media Menu */
|
||||
|
||||
#social-media-menu {
|
||||
clear: both;
|
||||
margin-bottom: 6px;
|
||||
padding: 0 0 0 30px;
|
||||
height: 60px;
|
||||
max-height: 48px;
|
||||
}
|
||||
|
||||
#social-media-menu a {
|
||||
font-size: 32px;
|
||||
color: #ddd;
|
||||
padding-right: 6px;
|
||||
vertical-align: text-top;
|
||||
transition: color 2s, font-size 2s;
|
||||
border: none;
|
||||
}
|
||||
#social-media-menu a:hover {
|
||||
font-size: 48px;
|
||||
color: #444;
|
||||
}
|
||||
#social-media-menu a.sm-rss:hover {
|
||||
color: #ff8300;
|
||||
}
|
||||
#social-media-menu a.sm-twitter:hover {
|
||||
color: #4F9FDD;
|
||||
}
|
||||
#social-media-menu a.sm-facebook:hover {
|
||||
color: #3A5795;
|
||||
}
|
||||
#social-media-menu a.sm-instagram:hover {
|
||||
color: #9b6954;
|
||||
}
|
||||
#social-media-menu a.sm-youtube:hover {
|
||||
color: #DF2826;
|
||||
}
|
||||
#social-media-menu a.sm-pinterest:hover {
|
||||
color: #C92228;
|
||||
}
|
||||
#social-media-menu a.sm-amazon:hover {
|
||||
color: #F3A847;
|
||||
}
|
||||
|
||||
/**********************************/
|
||||
/* 14. Required by WordPress */
|
||||
|
||||
.size-auto,
|
||||
.size-full,
|
||||
.size-large,
|
||||
.size-medium,
|
||||
.size-thumbnail {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.sticky {
|
||||
background: #efefef;
|
||||
padding: 0.5em;
|
||||
}
|
||||
.sticky:first-child .post-title,
|
||||
.post:first-child .post-title {
|
||||
margin-top: 0;
|
||||
}
|
||||
.post:first-child h2 {
|
||||
padding-top: 0;
|
||||
}
|
||||
.sticky:first-child h2 {
|
||||
padding-top: 12px;
|
||||
}
|
||||
|
||||
.wp-caption {
|
||||
border: solid 1px #bbb;
|
||||
padding: 6px;
|
||||
background: #f9f9f9;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.wp-caption-text {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.gallery-caption {
|
||||
|
||||
}
|
||||
|
||||
.bypostauthor {
|
||||
|
||||
}
|
||||
|
||||
.alignright {
|
||||
float: right;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.alignleft {
|
||||
float: left;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.aligncenter {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.wp-caption a,
|
||||
.wp-caption a:hover {
|
||||
border: none;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.wp-post-image { /* Align images in excerpts */
|
||||
float: left;
|
||||
margin: 0 10px 8px 0;
|
||||
}
|
||||
|
||||
|
||||
/**********************************/
|
||||
/* 15. Miscellaneous Fixes */
|
||||
|
||||
table#wp-calendar {
|
||||
width: 100%;
|
||||
margin-top: 1.5em;
|
||||
}
|
||||
|
||||
h2 table#wp-calendar {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
figure {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Development */
|
||||
/* Delete when theme is complete */
|
||||
|
||||
.post-content img { /*For images without a caption */
|
||||
border: solid 1px #ddd;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.wp-caption img { /* For images with a caption */
|
||||
border: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.atticus-finch-post-top-widget {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
span.fa .fa-at {
|
||||
font-weight: bold !important;
|
||||
}
|
||||
|
||||
.format-quote .post-content iframe {
|
||||
clear:both;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
border: solid 1px #ddd;
|
||||
padding: 12px;
|
||||
}
|
||||
blockquote:before {
|
||||
font-family: "FontAwesome";
|
||||
content: '\f10d';
|
||||
color: rgba( 50, 50, 50, 0.3);
|
||||
font-size: 50px;
|
||||
float: left;
|
||||
margin-right: 12px;
|
||||
}
|
||||
|
||||
blockquote.PWGP_caption::before {
|
||||
/* border: none; */
|
||||
content: none;
|
||||
}
|
||||
|
||||
blockquote.PWGP_caption {
|
||||
margin: 3px 0;
|
||||
text-align: left;
|
||||
border: none;
|
||||
}
|
1084
styles/menumaker.css
Executable file
1084
styles/menumaker.css
Executable file
File diff suppressed because it is too large
Load Diff
1087
styles/menus.css
Executable file
1087
styles/menus.css
Executable file
File diff suppressed because it is too large
Load Diff
112
styles/mobile.css
Executable file
112
styles/mobile.css
Executable file
@ -0,0 +1,112 @@
|
||||
/* Mobile Style Sheet for Atticus Finch Theme */
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #fff;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
body > header {
|
||||
background: #333;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
textarea {
|
||||
width: auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
#container {
|
||||
width: 100%;
|
||||
max-width: auto;
|
||||
min-width: auto;
|
||||
margin: 0;
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
#sidebar {
|
||||
float: none;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#sidebar,
|
||||
#content {
|
||||
width: 100%;
|
||||
border: none;
|
||||
}
|
||||
|
||||
#site-title,
|
||||
#site-desc,
|
||||
#social-media-menu {
|
||||
float: none;
|
||||
width: 100%;
|
||||
padding: 0.5em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#site-title h1,
|
||||
#site-title a,
|
||||
#site-desc,
|
||||
#site-desc a {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
a.top-button {
|
||||
background: #333;
|
||||
display: inline-block;
|
||||
padding: 1em;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
margin: 1em 0;
|
||||
letter-spacing: 0.1em;
|
||||
color: #ddd;
|
||||
font-family: 'IM Fell English', serif;
|
||||
border-bottom: solid 1px #999;
|
||||
}
|
||||
|
||||
footer a.top-button{
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
body > footer {
|
||||
background: #333;
|
||||
color: #fff;
|
||||
padding-bottom: 2em;
|
||||
}
|
||||
|
||||
#footer-menu {
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
#copyright,
|
||||
#credits {
|
||||
float: none;
|
||||
padding: 0.5em;
|
||||
width: auto;
|
||||
text-align: center;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
margin: 0 1em;
|
||||
}
|
||||
|
||||
|
||||
/* Mobile Menu Adjustments */
|
||||
|
||||
#aboveheadermenu {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
#footer-menu {
|
||||
border-bottom: solid 1px #555;
|
||||
}
|
||||
/*
|
||||
#footermenu li.current-menu-item a {
|
||||
color: #333;
|
||||
}
|
||||
*/
|
90
styles/print.css
Executable file
90
styles/print.css
Executable file
@ -0,0 +1,90 @@
|
||||
body > header,
|
||||
body > footer,
|
||||
#sidebar,
|
||||
a.post-edit-link,
|
||||
#post-series,
|
||||
#respond {
|
||||
display: none;
|
||||
}
|
||||
|
||||
html,
|
||||
body,
|
||||
#container,
|
||||
#content,
|
||||
.post,
|
||||
.page,
|
||||
.post-content {
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.post li {
|
||||
margin-bottom: 6pt;
|
||||
}
|
||||
|
||||
.post-content a {
|
||||
text-decoration: none;
|
||||
border-bottom: solid 1pt #99f;
|
||||
}
|
||||
|
||||
#content {
|
||||
border: none;
|
||||
}
|
||||
|
||||
#content p,
|
||||
#content ol,
|
||||
#content ul,
|
||||
#content li,
|
||||
#content dl,
|
||||
#content dd,
|
||||
#content dt {
|
||||
font-size: 12pt;
|
||||
}
|
||||
|
||||
.noprint {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.printonly {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.printcopyright,
|
||||
.printurl {
|
||||
border: solid 1pt #000;
|
||||
font-size: 8pt;
|
||||
padding: 6pt;
|
||||
width: 80%;
|
||||
margin: 6pt auto;
|
||||
}
|
||||
|
||||
.alignright {
|
||||
float: right;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.alignleft {
|
||||
float: left;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.aligncenter {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.post-content a:after {
|
||||
content:" [URL: " attr(href) "] ";
|
||||
}
|
||||
|
||||
/* Remove borders on image links */
|
||||
.post-content a[href$=jpg]:after,
|
||||
.post-content a[href$=jpeg]:after,
|
||||
.post-content a[href$=jpe]:after,
|
||||
.post-content a[href$=png]:after,
|
||||
.post-content a[href$=gif]:after {
|
||||
content:"\A[Image location: " attr(href) "] ";
|
||||
}
|
||||
|
44
tag.php
Executable file
44
tag.php
Executable file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* The tag template file.
|
||||
*
|
||||
* Displays a tag archive
|
||||
*
|
||||
* @package Atticus Finch
|
||||
*/
|
||||
|
||||
get_header();
|
||||
|
||||
?>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<div id="archive-title">
|
||||
<h2>
|
||||
<?php
|
||||
printf( __( 'Posts tagged with: <span>%s</span>', 'atticus-finch' ), single_cat_title( '', false ) );
|
||||
?>
|
||||
</h2>
|
||||
<?php
|
||||
$description = tag_description();
|
||||
?>
|
||||
</div>
|
||||
|
||||
<!-- Start the loop -->
|
||||
<?php if ( have_posts() ) : ?>
|
||||
<?php while ( have_posts() ) : the_post(); ?>
|
||||
|
||||
<?php get_template_part( 'formats/excerpt', get_post_format() ); ?>
|
||||
|
||||
<!-- End the loop -->
|
||||
<?php endwhile; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php atticus_finch_display_nav(); ?>
|
||||
</div> <!-- end Content -->
|
||||
|
||||
<?php get_sidebar(); ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php get_footer(); ?>
|
271
update/Puc/v4/Factory.php
Executable file
271
update/Puc/v4/Factory.php
Executable file
@ -0,0 +1,271 @@
|
||||
<?php
|
||||
if ( !class_exists('Puc_v4_Factory', false) ):
|
||||
|
||||
/**
|
||||
* A factory that builds update checker instances.
|
||||
*
|
||||
* When multiple versions of the same class have been loaded (e.g. PluginUpdateChecker 4.0
|
||||
* and 4.1), this factory will always use the latest available minor version. Register class
|
||||
* versions by calling {@link PucFactory::addVersion()}.
|
||||
*
|
||||
* At the moment it can only build instances of the UpdateChecker class. Other classes are
|
||||
* intended mainly for internal use and refer directly to specific implementations.
|
||||
*/
|
||||
class Puc_v4_Factory {
|
||||
protected static $classVersions = array();
|
||||
protected static $sorted = false;
|
||||
|
||||
protected static $myMajorVersion = '';
|
||||
protected static $latestCompatibleVersion = '';
|
||||
|
||||
/**
|
||||
* Create a new instance of the update checker.
|
||||
*
|
||||
* This method automatically detects if you're using it for a plugin or a theme and chooses
|
||||
* the appropriate implementation for your update source (JSON file, GitHub, BitBucket, etc).
|
||||
*
|
||||
* @see Puc_v4p1_UpdateChecker::__construct
|
||||
*
|
||||
* @param string $metadataUrl The URL of the metadata file, a GitHub repository, or another supported update source.
|
||||
* @param string $fullPath Full path to the main plugin file or to the theme directory.
|
||||
* @param string $slug Custom slug. Defaults to the name of the main plugin file or the theme directory.
|
||||
* @param int $checkPeriod How often to check for updates (in hours).
|
||||
* @param string $optionName Where to store book-keeping info about update checks.
|
||||
* @param string $muPluginFile The plugin filename relative to the mu-plugins directory.
|
||||
* @return Puc_v4p1_Plugin_UpdateChecker|Puc_v4p1_Theme_UpdateChecker|Puc_v4p1_Vcs_BaseChecker
|
||||
*/
|
||||
public static function buildUpdateChecker($metadataUrl, $fullPath, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = '') {
|
||||
$fullPath = wp_normalize_path($fullPath);
|
||||
$id = null;
|
||||
|
||||
//Plugin or theme?
|
||||
$themeDirectory = self::getThemeDirectoryName($fullPath);
|
||||
if ( self::isPluginFile($fullPath) ) {
|
||||
$type = 'Plugin';
|
||||
$id = $fullPath;
|
||||
} else if ( $themeDirectory !== null ) {
|
||||
$type = 'Theme';
|
||||
$id = $themeDirectory;
|
||||
} else {
|
||||
throw new RuntimeException(sprintf(
|
||||
'The update checker cannot determine if "%s" is a plugin or a theme. ' .
|
||||
'This is a bug. Please contact the PUC developer.',
|
||||
htmlentities($fullPath)
|
||||
));
|
||||
}
|
||||
|
||||
//Which hosting service does the URL point to?
|
||||
$service = self::getVcsService($metadataUrl);
|
||||
|
||||
$apiClass = null;
|
||||
if ( empty($service) ) {
|
||||
//The default is to get update information from a remote JSON file.
|
||||
$checkerClass = $type . '_UpdateChecker';
|
||||
} else {
|
||||
//You can also use a VCS repository like GitHub.
|
||||
$checkerClass = 'Vcs_' . $type . 'UpdateChecker';
|
||||
$apiClass = $service . 'Api';
|
||||
}
|
||||
|
||||
$checkerClass = self::getCompatibleClassVersion($checkerClass);
|
||||
if ( $checkerClass === null ) {
|
||||
trigger_error(
|
||||
sprintf(
|
||||
'PUC %s does not support updates for %ss %s',
|
||||
htmlentities(self::$latestCompatibleVersion),
|
||||
strtolower($type),
|
||||
$service ? ('hosted on ' . htmlentities($service)) : 'using JSON metadata'
|
||||
),
|
||||
E_USER_ERROR
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( !isset($apiClass) ) {
|
||||
//Plain old update checker.
|
||||
return new $checkerClass($metadataUrl, $id, $slug, $checkPeriod, $optionName, $muPluginFile);
|
||||
} else {
|
||||
//VCS checker + an API client.
|
||||
$apiClass = self::getCompatibleClassVersion($apiClass);
|
||||
if ( $apiClass === null ) {
|
||||
trigger_error(sprintf(
|
||||
'PUC %s does not support %s',
|
||||
htmlentities(self::$latestCompatibleVersion),
|
||||
htmlentities($service)
|
||||
), E_USER_ERROR);
|
||||
return null;
|
||||
}
|
||||
|
||||
return new $checkerClass(
|
||||
new $apiClass($metadataUrl),
|
||||
$id,
|
||||
$slug,
|
||||
$checkPeriod,
|
||||
$optionName,
|
||||
$muPluginFile
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the path points to a plugin file.
|
||||
*
|
||||
* @param string $absolutePath Normalized path.
|
||||
* @return bool
|
||||
*/
|
||||
protected static function isPluginFile($absolutePath) {
|
||||
//Is the file inside the "plugins" or "mu-plugins" directory?
|
||||
$pluginDir = wp_normalize_path(WP_PLUGIN_DIR);
|
||||
$muPluginDir = wp_normalize_path(WPMU_PLUGIN_DIR);
|
||||
if ( (strpos($absolutePath, $pluginDir) === 0) || (strpos($absolutePath, $muPluginDir) === 0) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//Is it a file at all? Caution: is_file() can fail if the parent dir. doesn't have the +x permission set.
|
||||
if ( !is_file($absolutePath) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Does it have a valid plugin header?
|
||||
//This is a last-ditch check for plugins symlinked from outside the WP root.
|
||||
if ( function_exists('get_file_data') ) {
|
||||
$headers = get_file_data($absolutePath, array('Name' => 'Plugin Name'), 'plugin');
|
||||
return !empty($headers['Name']);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the theme's directory from a full path to a file inside that directory.
|
||||
* E.g. "/abc/public_html/wp-content/themes/foo/whatever.php" => "foo".
|
||||
*
|
||||
* Note that subdirectories are currently not supported. For example,
|
||||
* "/xyz/wp-content/themes/my-theme/includes/whatever.php" => NULL.
|
||||
*
|
||||
* @param string $absolutePath Normalized path.
|
||||
* @return string|null Directory name, or NULL if the path doesn't point to a theme.
|
||||
*/
|
||||
protected static function getThemeDirectoryName($absolutePath) {
|
||||
if ( is_file($absolutePath) ) {
|
||||
$absolutePath = dirname($absolutePath);
|
||||
}
|
||||
|
||||
if ( file_exists($absolutePath . '/style.css') ) {
|
||||
return basename($absolutePath);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the hosting service that the URL points to.
|
||||
*
|
||||
* @param string $metadataUrl
|
||||
* @return string|null
|
||||
*/
|
||||
private static function getVcsService($metadataUrl) {
|
||||
$service = null;
|
||||
|
||||
//Which hosting service does the URL point to?
|
||||
$host = @parse_url($metadataUrl, PHP_URL_HOST);
|
||||
$path = @parse_url($metadataUrl, PHP_URL_PATH);
|
||||
//Check if the path looks like "/user-name/repository".
|
||||
$usernameRepoRegex = '@^/?([^/]+?)/([^/#?&]+?)/?$@';
|
||||
if ( preg_match($usernameRepoRegex, $path) ) {
|
||||
$knownServices = array(
|
||||
'github.com' => 'GitHub',
|
||||
'bitbucket.org' => 'BitBucket',
|
||||
'gitlab.com' => 'GitLab',
|
||||
);
|
||||
if ( isset($knownServices[$host]) ) {
|
||||
$service = $knownServices[$host];
|
||||
}
|
||||
}
|
||||
|
||||
return $service;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest version of the specified class that has the same major version number
|
||||
* as this factory class.
|
||||
*
|
||||
* @param string $class Partial class name.
|
||||
* @return string|null Full class name.
|
||||
*/
|
||||
protected static function getCompatibleClassVersion($class) {
|
||||
if ( isset(self::$classVersions[$class][self::$latestCompatibleVersion]) ) {
|
||||
return self::$classVersions[$class][self::$latestCompatibleVersion];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the specific class name for the latest available version of a class.
|
||||
*
|
||||
* @param string $class
|
||||
* @return null|string
|
||||
*/
|
||||
public static function getLatestClassVersion($class) {
|
||||
if ( !self::$sorted ) {
|
||||
self::sortVersions();
|
||||
}
|
||||
|
||||
if ( isset(self::$classVersions[$class]) ) {
|
||||
return reset(self::$classVersions[$class]);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort available class versions in descending order (i.e. newest first).
|
||||
*/
|
||||
protected static function sortVersions() {
|
||||
foreach ( self::$classVersions as $class => $versions ) {
|
||||
uksort($versions, array(__CLASS__, 'compareVersions'));
|
||||
self::$classVersions[$class] = $versions;
|
||||
}
|
||||
self::$sorted = true;
|
||||
}
|
||||
|
||||
protected static function compareVersions($a, $b) {
|
||||
return -version_compare($a, $b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a version of a class.
|
||||
*
|
||||
* @access private This method is only for internal use by the library.
|
||||
*
|
||||
* @param string $generalClass Class name without version numbers, e.g. 'PluginUpdateChecker'.
|
||||
* @param string $versionedClass Actual class name, e.g. 'PluginUpdateChecker_1_2'.
|
||||
* @param string $version Version number, e.g. '1.2'.
|
||||
*/
|
||||
public static function addVersion($generalClass, $versionedClass, $version) {
|
||||
if ( empty(self::$myMajorVersion) ) {
|
||||
$nameParts = explode('_', __CLASS__, 3);
|
||||
self::$myMajorVersion = substr(ltrim($nameParts[1], 'v'), 0, 1);
|
||||
}
|
||||
|
||||
//Store the greatest version number that matches our major version.
|
||||
$components = explode('.', $version);
|
||||
if ( $components[0] === self::$myMajorVersion ) {
|
||||
|
||||
if (
|
||||
empty(self::$latestCompatibleVersion)
|
||||
|| version_compare($version, self::$latestCompatibleVersion, '>')
|
||||
) {
|
||||
self::$latestCompatibleVersion = $version;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( !isset(self::$classVersions[$generalClass]) ) {
|
||||
self::$classVersions[$generalClass] = array();
|
||||
}
|
||||
self::$classVersions[$generalClass][$version] = $versionedClass;
|
||||
self::$sorted = false;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
49
update/Puc/v4p1/Autoloader.php
Executable file
49
update/Puc/v4p1/Autoloader.php
Executable file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
if ( !class_exists('Puc_v4p1_Autoloader', false) ):
|
||||
|
||||
class Puc_v4p1_Autoloader {
|
||||
private $prefix = '';
|
||||
private $rootDir = '';
|
||||
private $libraryDir = '';
|
||||
|
||||
private $staticMap;
|
||||
|
||||
public function __construct() {
|
||||
$this->rootDir = dirname(__FILE__) . '/';
|
||||
$nameParts = explode('_', __CLASS__, 3);
|
||||
$this->prefix = $nameParts[0] . '_' . $nameParts[1] . '_';
|
||||
|
||||
$this->libraryDir = realpath($this->rootDir . '../..') . '/';
|
||||
$this->staticMap = array(
|
||||
'PucReadmeParser' => 'vendor/readme-parser.php',
|
||||
'Parsedown' => 'vendor/ParsedownLegacy.php',
|
||||
);
|
||||
if ( version_compare(PHP_VERSION, '5.3.0', '>=') ) {
|
||||
$this->staticMap['Parsedown'] = 'vendor/Parsedown.php';
|
||||
}
|
||||
|
||||
spl_autoload_register(array($this, 'autoload'));
|
||||
}
|
||||
|
||||
public function autoload($className) {
|
||||
if ( isset($this->staticMap[$className]) && file_exists($this->libraryDir . $this->staticMap[$className]) ) {
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
include ($this->libraryDir . $this->staticMap[$className]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (strpos($className, $this->prefix) === 0) {
|
||||
$path = substr($className, strlen($this->prefix));
|
||||
$path = str_replace('_', '/', $path);
|
||||
$path = $this->rootDir . $path . '.php';
|
||||
|
||||
if (file_exists($path)) {
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
include $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
117
update/Puc/v4p1/DebugBar/Extension.php
Executable file
117
update/Puc/v4p1/DebugBar/Extension.php
Executable file
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
if ( !class_exists('Puc_v4p1_DebugBar_Extension', false) ):
|
||||
|
||||
class Puc_v4p1_DebugBar_Extension {
|
||||
/** @var Puc_v4p1_UpdateChecker */
|
||||
protected $updateChecker;
|
||||
protected $panelClass = 'Puc_v4p1_DebugBar_Panel';
|
||||
|
||||
public function __construct($updateChecker, $panelClass = null) {
|
||||
$this->updateChecker = $updateChecker;
|
||||
if ( isset($panelClass) ) {
|
||||
$this->panelClass = $panelClass;
|
||||
}
|
||||
|
||||
add_filter('debug_bar_panels', array($this, 'addDebugBarPanel'));
|
||||
add_action('debug_bar_enqueue_scripts', array($this, 'enqueuePanelDependencies'));
|
||||
|
||||
add_action('wp_ajax_puc_v4_debug_check_now', array($this, 'ajaxCheckNow'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the PUC Debug Bar panel.
|
||||
*
|
||||
* @param array $panels
|
||||
* @return array
|
||||
*/
|
||||
public function addDebugBarPanel($panels) {
|
||||
if ( $this->updateChecker->userCanInstallUpdates() ) {
|
||||
$panels[] = new $this->panelClass($this->updateChecker);
|
||||
}
|
||||
return $panels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue our Debug Bar scripts and styles.
|
||||
*/
|
||||
public function enqueuePanelDependencies() {
|
||||
wp_enqueue_style(
|
||||
'puc-debug-bar-style-v4',
|
||||
$this->getLibraryUrl("/css/puc-debug-bar.css"),
|
||||
array('debug-bar'),
|
||||
'20161217'
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'puc-debug-bar-js-v4',
|
||||
$this->getLibraryUrl("/js/debug-bar.js"),
|
||||
array('jquery'),
|
||||
'20170516'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run an update check and output the result. Useful for making sure that
|
||||
* the update checking process works as expected.
|
||||
*/
|
||||
public function ajaxCheckNow() {
|
||||
if ( $_POST['uid'] !== $this->updateChecker->getUniqueName('uid') ) {
|
||||
return;
|
||||
}
|
||||
$this->preAjaxReqest();
|
||||
$update = $this->updateChecker->checkForUpdates();
|
||||
if ( $update !== null ) {
|
||||
echo "An update is available:";
|
||||
echo '<pre>', htmlentities(print_r($update, true)), '</pre>';
|
||||
} else {
|
||||
echo 'No updates found.';
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check access permissions and enable error display (for debugging).
|
||||
*/
|
||||
protected function preAjaxReqest() {
|
||||
if ( !$this->updateChecker->userCanInstallUpdates() ) {
|
||||
die('Access denied');
|
||||
}
|
||||
check_ajax_referer('puc-ajax');
|
||||
|
||||
error_reporting(E_ALL);
|
||||
@ini_set('display_errors','On');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filePath
|
||||
* @return string
|
||||
*/
|
||||
private function getLibraryUrl($filePath) {
|
||||
$absolutePath = realpath(dirname(__FILE__) . '/../../../' . ltrim($filePath, '/'));
|
||||
|
||||
//Where is the library located inside the WordPress directory structure?
|
||||
$absolutePath = wp_normalize_path($absolutePath);
|
||||
|
||||
$pluginDir = wp_normalize_path(WP_PLUGIN_DIR);
|
||||
$muPluginDir = wp_normalize_path(WPMU_PLUGIN_DIR);
|
||||
$themeDir = wp_normalize_path(get_theme_root());
|
||||
|
||||
if ( (strpos($absolutePath, $pluginDir) === 0) || (strpos($absolutePath, $muPluginDir) === 0) ) {
|
||||
//It's part of a plugin.
|
||||
return plugins_url(basename($absolutePath), $absolutePath);
|
||||
} else if ( strpos($absolutePath, $themeDir) === 0 ) {
|
||||
//It's part of a theme.
|
||||
$relativePath = substr($absolutePath, strlen($themeDir) + 1);
|
||||
$template = substr($relativePath, 0, strpos($relativePath, '/'));
|
||||
$baseUrl = get_theme_root_uri($template);
|
||||
|
||||
if ( !empty($baseUrl) && $relativePath ) {
|
||||
return $baseUrl . '/' . $relativePath;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
165
update/Puc/v4p1/DebugBar/Panel.php
Executable file
165
update/Puc/v4p1/DebugBar/Panel.php
Executable file
@ -0,0 +1,165 @@
|
||||
<?php
|
||||
|
||||
if ( !class_exists('Puc_v4p1_DebugBar_Panel', false) && class_exists('Debug_Bar_Panel', false) ):
|
||||
|
||||
class Puc_v4p1_DebugBar_Panel extends Debug_Bar_Panel {
|
||||
/** @var Puc_v4p1_UpdateChecker */
|
||||
protected $updateChecker;
|
||||
|
||||
private $responseBox = '<div class="puc-ajax-response" style="display: none;"></div>';
|
||||
|
||||
public function __construct($updateChecker) {
|
||||
$this->updateChecker = $updateChecker;
|
||||
$title = sprintf(
|
||||
'<span class="puc-debug-menu-link-%s">PUC (%s)</span>',
|
||||
esc_attr($this->updateChecker->getUniqueName('uid')),
|
||||
$this->updateChecker->slug
|
||||
);
|
||||
parent::__construct($title);
|
||||
}
|
||||
|
||||
public function render() {
|
||||
printf(
|
||||
'<div class="puc-debug-bar-panel-v4" id="%1$s" data-slug="%2$s" data-uid="%3$s" data-nonce="%4$s">',
|
||||
esc_attr($this->updateChecker->getUniqueName('debug-bar-panel')),
|
||||
esc_attr($this->updateChecker->slug),
|
||||
esc_attr($this->updateChecker->getUniqueName('uid')),
|
||||
esc_attr(wp_create_nonce('puc-ajax'))
|
||||
);
|
||||
|
||||
$this->displayConfiguration();
|
||||
$this->displayStatus();
|
||||
$this->displayCurrentUpdate();
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
private function displayConfiguration() {
|
||||
echo '<h3>Configuration</h3>';
|
||||
echo '<table class="puc-debug-data">';
|
||||
$this->displayConfigHeader();
|
||||
$this->row('Slug', htmlentities($this->updateChecker->slug));
|
||||
$this->row('DB option', htmlentities($this->updateChecker->optionName));
|
||||
|
||||
$requestInfoButton = $this->getMetadataButton();
|
||||
$this->row('Metadata URL', htmlentities($this->updateChecker->metadataUrl) . ' ' . $requestInfoButton . $this->responseBox);
|
||||
|
||||
$scheduler = $this->updateChecker->scheduler;
|
||||
if ( $scheduler->checkPeriod > 0 ) {
|
||||
$this->row('Automatic checks', 'Every ' . $scheduler->checkPeriod . ' hours');
|
||||
} else {
|
||||
$this->row('Automatic checks', 'Disabled');
|
||||
}
|
||||
|
||||
if ( isset($scheduler->throttleRedundantChecks) ) {
|
||||
if ( $scheduler->throttleRedundantChecks && ($scheduler->checkPeriod > 0) ) {
|
||||
$this->row(
|
||||
'Throttling',
|
||||
sprintf(
|
||||
'Enabled. If an update is already available, check for updates every %1$d hours instead of every %2$d hours.',
|
||||
$scheduler->throttledCheckPeriod,
|
||||
$scheduler->checkPeriod
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->row('Throttling', 'Disabled');
|
||||
}
|
||||
}
|
||||
|
||||
$this->updateChecker->onDisplayConfiguration($this);
|
||||
|
||||
echo '</table>';
|
||||
}
|
||||
|
||||
protected function displayConfigHeader() {
|
||||
//Do nothing. This should be implemented in subclasses.
|
||||
}
|
||||
|
||||
protected function getMetadataButton() {
|
||||
return '';
|
||||
}
|
||||
|
||||
private function displayStatus() {
|
||||
echo '<h3>Status</h3>';
|
||||
echo '<table class="puc-debug-data">';
|
||||
$state = $this->updateChecker->getUpdateState();
|
||||
$checkNowButton = '';
|
||||
if ( function_exists('get_submit_button') ) {
|
||||
$checkNowButton = get_submit_button(
|
||||
'Check Now',
|
||||
'secondary',
|
||||
'puc-check-now-button',
|
||||
false,
|
||||
array('id' => $this->updateChecker->getUniqueName('check-now-button'))
|
||||
);
|
||||
}
|
||||
|
||||
if ( $state->getLastCheck() > 0 ) {
|
||||
$this->row('Last check', $this->formatTimeWithDelta($state->getLastCheck()) . ' ' . $checkNowButton . $this->responseBox);
|
||||
} else {
|
||||
$this->row('Last check', 'Never');
|
||||
}
|
||||
|
||||
$nextCheck = wp_next_scheduled($this->updateChecker->scheduler->getCronHookName());
|
||||
$this->row('Next automatic check', $this->formatTimeWithDelta($nextCheck));
|
||||
|
||||
if ( $state->getCheckedVersion() !== '' ) {
|
||||
$this->row('Checked version', htmlentities($state->getCheckedVersion()));
|
||||
$this->row('Cached update', $state->getUpdate());
|
||||
}
|
||||
$this->row('Update checker class', htmlentities(get_class($this->updateChecker)));
|
||||
echo '</table>';
|
||||
}
|
||||
|
||||
private function displayCurrentUpdate() {
|
||||
$update = $this->updateChecker->getUpdate();
|
||||
if ( $update !== null ) {
|
||||
echo '<h3>An Update Is Available</h3>';
|
||||
echo '<table class="puc-debug-data">';
|
||||
$fields = $this->getUpdateFields();
|
||||
foreach($fields as $field) {
|
||||
if ( property_exists($update, $field) ) {
|
||||
$this->row(ucwords(str_replace('_', ' ', $field)), htmlentities($update->$field));
|
||||
}
|
||||
}
|
||||
echo '</table>';
|
||||
} else {
|
||||
echo '<h3>No updates currently available</h3>';
|
||||
}
|
||||
}
|
||||
|
||||
protected function getUpdateFields() {
|
||||
return array('version', 'download_url', 'slug',);
|
||||
}
|
||||
|
||||
private function formatTimeWithDelta($unixTime) {
|
||||
if ( empty($unixTime) ) {
|
||||
return 'Never';
|
||||
}
|
||||
|
||||
$delta = time() - $unixTime;
|
||||
$result = human_time_diff(time(), $unixTime);
|
||||
if ( $delta < 0 ) {
|
||||
$result = 'after ' . $result;
|
||||
} else {
|
||||
$result = $result . ' ago';
|
||||
}
|
||||
$result .= ' (' . $this->formatTimestamp($unixTime) . ')';
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function formatTimestamp($unixTime) {
|
||||
return gmdate('Y-m-d H:i:s', $unixTime + (get_option('gmt_offset') * 3600));
|
||||
}
|
||||
|
||||
public function row($name, $value) {
|
||||
if ( is_object($value) || is_array($value) ) {
|
||||
$value = '<pre>' . htmlentities(print_r($value, true)) . '</pre>';
|
||||
} else if ($value === null) {
|
||||
$value = '<code>null</code>';
|
||||
}
|
||||
printf('<tr><th scope="row">%1$s</th> <td>%2$s</td></tr>', $name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
33
update/Puc/v4p1/DebugBar/PluginExtension.php
Executable file
33
update/Puc/v4p1/DebugBar/PluginExtension.php
Executable file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
if ( !class_exists('Puc_v4p1_DebugBar_PluginExtension', false) ):
|
||||
|
||||
class Puc_v4p1_DebugBar_PluginExtension extends Puc_v4p1_DebugBar_Extension {
|
||||
/** @var Puc_v4p1_Plugin_UpdateChecker */
|
||||
protected $updateChecker;
|
||||
|
||||
public function __construct($updateChecker) {
|
||||
parent::__construct($updateChecker, 'Puc_v4p1_DebugBar_PluginPanel');
|
||||
|
||||
add_action('wp_ajax_puc_v4_debug_request_info', array($this, 'ajaxRequestInfo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Request plugin info and output it.
|
||||
*/
|
||||
public function ajaxRequestInfo() {
|
||||
if ( $_POST['uid'] !== $this->updateChecker->getUniqueName('uid') ) {
|
||||
return;
|
||||
}
|
||||
$this->preAjaxReqest();
|
||||
$info = $this->updateChecker->requestInfo();
|
||||
if ( $info !== null ) {
|
||||
echo 'Successfully retrieved plugin info from the metadata URL:';
|
||||
echo '<pre>', htmlentities(print_r($info, true)), '</pre>';
|
||||
} else {
|
||||
echo 'Failed to retrieve plugin info from the metadata URL.';
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
38
update/Puc/v4p1/DebugBar/PluginPanel.php
Executable file
38
update/Puc/v4p1/DebugBar/PluginPanel.php
Executable file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
if ( !class_exists('Puc_v4p1_DebugBar_PluginPanel', false) ):
|
||||
|
||||
class Puc_v4p1_DebugBar_PluginPanel extends Puc_v4p1_DebugBar_Panel {
|
||||
/**
|
||||
* @var Puc_v4p1_Plugin_UpdateChecker
|
||||
*/
|
||||
protected $updateChecker;
|
||||
|
||||
protected function displayConfigHeader() {
|
||||
$this->row('Plugin file', htmlentities($this->updateChecker->pluginFile));
|
||||
parent::displayConfigHeader();
|
||||
}
|
||||
|
||||
protected function getMetadataButton() {
|
||||
$requestInfoButton = '';
|
||||
if ( function_exists('get_submit_button') ) {
|
||||
$requestInfoButton = get_submit_button(
|
||||
'Request Info',
|
||||
'secondary',
|
||||
'puc-request-info-button',
|
||||
false,
|
||||
array('id' => $this->updateChecker->getUniqueName('request-info-button'))
|
||||
);
|
||||
}
|
||||
return $requestInfoButton;
|
||||
}
|
||||
|
||||
protected function getUpdateFields() {
|
||||
return array_merge(
|
||||
parent::getUpdateFields(),
|
||||
array('homepage', 'upgrade_notice', 'tested',)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
21
update/Puc/v4p1/DebugBar/ThemePanel.php
Executable file
21
update/Puc/v4p1/DebugBar/ThemePanel.php
Executable file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
if ( !class_exists('Puc_v4p1_DebugBar_ThemePanel', false) ):
|
||||
|
||||
class Puc_v4p1_DebugBar_ThemePanel extends Puc_v4p1_DebugBar_Panel {
|
||||
/**
|
||||
* @var Puc_v4p1_Theme_UpdateChecker
|
||||
*/
|
||||
protected $updateChecker;
|
||||
|
||||
protected function displayConfigHeader() {
|
||||
$this->row('Theme directory', htmlentities($this->updateChecker->directoryName));
|
||||
parent::displayConfigHeader();
|
||||
}
|
||||
|
||||
protected function getUpdateFields() {
|
||||
return array_merge(parent::getUpdateFields(), array('details_url'));
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
132
update/Puc/v4p1/Metadata.php
Executable file
132
update/Puc/v4p1/Metadata.php
Executable file
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
if ( !class_exists('Puc_v4p1_Metadata', false) ):
|
||||
|
||||
/**
|
||||
* A base container for holding information about updates and plugin metadata.
|
||||
*
|
||||
* @author Janis Elsts
|
||||
* @copyright 2016
|
||||
* @access public
|
||||
*/
|
||||
abstract class Puc_v4p1_Metadata {
|
||||
|
||||
/**
|
||||
* Create an instance of this class from a JSON document.
|
||||
*
|
||||
* @abstract
|
||||
* @param string $json
|
||||
* @return self
|
||||
*/
|
||||
public static function fromJson(/** @noinspection PhpUnusedParameterInspection */ $json) {
|
||||
throw new LogicException('The ' . __METHOD__ . ' method must be implemented by subclasses');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $json
|
||||
* @param self $target
|
||||
* @return bool
|
||||
*/
|
||||
protected static function createFromJson($json, $target) {
|
||||
/** @var StdClass $apiResponse */
|
||||
$apiResponse = json_decode($json);
|
||||
if ( empty($apiResponse) || !is_object($apiResponse) ){
|
||||
trigger_error(
|
||||
"Failed to parse update metadata. Try validating your .json file with http://jsonlint.com/",
|
||||
E_USER_NOTICE
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
$valid = $target->validateMetadata($apiResponse);
|
||||
if ( is_wp_error($valid) ){
|
||||
trigger_error($valid->get_error_message(), E_USER_NOTICE);
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach(get_object_vars($apiResponse) as $key => $value){
|
||||
$target->$key = $value;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* No validation by default! Subclasses should check that the required fields are present.
|
||||
*
|
||||
* @param StdClass $apiResponse
|
||||
* @return bool|WP_Error
|
||||
*/
|
||||
protected function validateMetadata(/** @noinspection PhpUnusedParameterInspection */ $apiResponse) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance by copying the necessary fields from another object.
|
||||
*
|
||||
* @abstract
|
||||
* @param StdClass|self $object The source object.
|
||||
* @return self The new copy.
|
||||
*/
|
||||
public static function fromObject(/** @noinspection PhpUnusedParameterInspection */ $object) {
|
||||
throw new LogicException('The ' . __METHOD__ . ' method must be implemented by subclasses');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of StdClass that can later be converted back to an
|
||||
* update or info container. Useful for serialization and caching, as it
|
||||
* avoids the "incomplete object" problem if the cached value is loaded
|
||||
* before this class.
|
||||
*
|
||||
* @return StdClass
|
||||
*/
|
||||
public function toStdClass() {
|
||||
$object = new stdClass();
|
||||
$this->copyFields($this, $object);
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform the metadata into the format used by WordPress core.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
abstract public function toWpFormat();
|
||||
|
||||
/**
|
||||
* Copy known fields from one object to another.
|
||||
*
|
||||
* @param StdClass|self $from
|
||||
* @param StdClass|self $to
|
||||
*/
|
||||
protected function copyFields($from, $to) {
|
||||
$fields = $this->getFieldNames();
|
||||
|
||||
if ( property_exists($from, 'slug') && !empty($from->slug) ) {
|
||||
//Let plugins add extra fields without having to create subclasses.
|
||||
$fields = apply_filters($this->getPrefixedFilter('retain_fields') . '-' . $from->slug, $fields);
|
||||
}
|
||||
|
||||
foreach ($fields as $field) {
|
||||
if ( property_exists($from, $field) ) {
|
||||
$to->$field = $from->$field;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getFieldNames() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tag
|
||||
* @return string
|
||||
*/
|
||||
protected function getPrefixedFilter($tag) {
|
||||
return 'puc_' . $tag;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
88
update/Puc/v4p1/OAuthSignature.php
Executable file
88
update/Puc/v4p1/OAuthSignature.php
Executable file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
if ( !class_exists('Puc_v4p1_OAuthSignature', false) ):
|
||||
|
||||
/**
|
||||
* A basic signature generator for zero-legged OAuth 1.0.
|
||||
*/
|
||||
class Puc_v4p1_OAuthSignature {
|
||||
private $consumerKey = '';
|
||||
private $consumerSecret = '';
|
||||
|
||||
public function __construct($consumerKey, $consumerSecret) {
|
||||
$this->consumerKey = $consumerKey;
|
||||
$this->consumerSecret = $consumerSecret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sign a URL using OAuth 1.0.
|
||||
*
|
||||
* @param string $url The URL to be signed. It may contain query parameters.
|
||||
* @param string $method HTTP method such as "GET", "POST" and so on.
|
||||
* @return string The signed URL.
|
||||
*/
|
||||
public function sign($url, $method = 'GET') {
|
||||
$parameters = array();
|
||||
|
||||
//Parse query parameters.
|
||||
$query = @parse_url($url, PHP_URL_QUERY);
|
||||
if ( !empty($query) ) {
|
||||
parse_str($query, $parsedParams);
|
||||
if ( is_array($parameters) ) {
|
||||
$parameters = $parsedParams;
|
||||
}
|
||||
//Remove the query string from the URL. We'll replace it later.
|
||||
$url = substr($url, 0, strpos($url, '?'));
|
||||
}
|
||||
|
||||
$parameters = array_merge(
|
||||
$parameters,
|
||||
array(
|
||||
'oauth_consumer_key' => $this->consumerKey,
|
||||
'oauth_nonce' => $this->nonce(),
|
||||
'oauth_signature_method' => 'HMAC-SHA1',
|
||||
'oauth_timestamp' => time(),
|
||||
'oauth_version' => '1.0',
|
||||
)
|
||||
);
|
||||
unset($parameters['oauth_signature']);
|
||||
|
||||
//Parameters must be sorted alphabetically before signing.
|
||||
ksort($parameters);
|
||||
|
||||
//The most complicated part of the request - generating the signature.
|
||||
//The string to sign contains the HTTP method, the URL path, and all of
|
||||
//our query parameters. Everything is URL encoded. Then we concatenate
|
||||
//them with ampersands into a single string to hash.
|
||||
$encodedVerb = urlencode($method);
|
||||
$encodedUrl = urlencode($url);
|
||||
$encodedParams = urlencode(http_build_query($parameters, '', '&'));
|
||||
|
||||
$stringToSign = $encodedVerb . '&' . $encodedUrl . '&' . $encodedParams;
|
||||
|
||||
//Since we only have one OAuth token (the consumer secret) we only have
|
||||
//to use it as our HMAC key. However, we still have to append an & to it
|
||||
//as if we were using it with additional tokens.
|
||||
$secret = urlencode($this->consumerSecret) . '&';
|
||||
|
||||
//The signature is a hash of the consumer key and the base string. Note
|
||||
//that we have to get the raw output from hash_hmac and base64 encode
|
||||
//the binary data result.
|
||||
$parameters['oauth_signature'] = base64_encode(hash_hmac('sha1', $stringToSign, $secret, true));
|
||||
|
||||
return ($url . '?' . http_build_query($parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a random nonce.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function nonce() {
|
||||
$mt = microtime();
|
||||
$rand = mt_rand();
|
||||
return md5($mt . '_' . $rand);
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
127
update/Puc/v4p1/Plugin/Info.php
Executable file
127
update/Puc/v4p1/Plugin/Info.php
Executable file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
if ( !class_exists('Puc_v4p1_Plugin_Info', false) ):
|
||||
|
||||
/**
|
||||
* A container class for holding and transforming various plugin metadata.
|
||||
*
|
||||
* @author Janis Elsts
|
||||
* @copyright 2016
|
||||
* @access public
|
||||
*/
|
||||
class Puc_v4p1_Plugin_Info extends Puc_v4p1_Metadata {
|
||||
//Most fields map directly to the contents of the plugin's info.json file.
|
||||
//See the relevant docs for a description of their meaning.
|
||||
public $name;
|
||||
public $slug;
|
||||
public $version;
|
||||
public $homepage;
|
||||
public $sections = array();
|
||||
public $banners;
|
||||
public $translations = array();
|
||||
public $download_url;
|
||||
|
||||
public $author;
|
||||
public $author_homepage;
|
||||
|
||||
public $requires;
|
||||
public $tested;
|
||||
public $upgrade_notice;
|
||||
|
||||
public $rating;
|
||||
public $num_ratings;
|
||||
public $downloaded;
|
||||
public $active_installs;
|
||||
public $last_updated;
|
||||
|
||||
public $id = 0; //The native WP.org API returns numeric plugin IDs, but they're not used for anything.
|
||||
|
||||
public $filename; //Plugin filename relative to the plugins directory.
|
||||
|
||||
/**
|
||||
* Create a new instance of Plugin Info from JSON-encoded plugin info
|
||||
* returned by an external update API.
|
||||
*
|
||||
* @param string $json Valid JSON string representing plugin info.
|
||||
* @return self|null New instance of Plugin Info, or NULL on error.
|
||||
*/
|
||||
public static function fromJson($json){
|
||||
$instance = new self();
|
||||
|
||||
if ( !parent::createFromJson($json, $instance) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//json_decode decodes assoc. arrays as objects. We want it as an array.
|
||||
$instance->sections = (array)$instance->sections;
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Very, very basic validation.
|
||||
*
|
||||
* @param StdClass $apiResponse
|
||||
* @return bool|WP_Error
|
||||
*/
|
||||
protected function validateMetadata($apiResponse) {
|
||||
if (
|
||||
!isset($apiResponse->name, $apiResponse->version)
|
||||
|| empty($apiResponse->name)
|
||||
|| empty($apiResponse->version)
|
||||
) {
|
||||
return new WP_Error(
|
||||
'puc-invalid-metadata',
|
||||
"The plugin metadata file does not contain the required 'name' and/or 'version' keys."
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Transform plugin info into the format used by the native WordPress.org API
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function toWpFormat(){
|
||||
$info = new stdClass;
|
||||
|
||||
//The custom update API is built so that many fields have the same name and format
|
||||
//as those returned by the native WordPress.org API. These can be assigned directly.
|
||||
$sameFormat = array(
|
||||
'name', 'slug', 'version', 'requires', 'tested', 'rating', 'upgrade_notice',
|
||||
'num_ratings', 'downloaded', 'active_installs', 'homepage', 'last_updated',
|
||||
);
|
||||
foreach($sameFormat as $field){
|
||||
if ( isset($this->$field) ) {
|
||||
$info->$field = $this->$field;
|
||||
} else {
|
||||
$info->$field = null;
|
||||
}
|
||||
}
|
||||
|
||||
//Other fields need to be renamed and/or transformed.
|
||||
$info->download_link = $this->download_url;
|
||||
$info->author = $this->getFormattedAuthor();
|
||||
$info->sections = array_merge(array('description' => ''), $this->sections);
|
||||
|
||||
if ( !empty($this->banners) ) {
|
||||
//WP expects an array with two keys: "high" and "low". Both are optional.
|
||||
//Docs: https://wordpress.org/plugins/about/faq/#banners
|
||||
$info->banners = is_object($this->banners) ? get_object_vars($this->banners) : $this->banners;
|
||||
$info->banners = array_intersect_key($info->banners, array('high' => true, 'low' => true));
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
protected function getFormattedAuthor() {
|
||||
if ( !empty($this->author_homepage) ){
|
||||
/** @noinspection HtmlUnknownTarget */
|
||||
return sprintf('<a href="%s">%s</a>', $this->author_homepage, $this->author);
|
||||
}
|
||||
return $this->author;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
91
update/Puc/v4p1/Plugin/Update.php
Executable file
91
update/Puc/v4p1/Plugin/Update.php
Executable file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
if ( !class_exists('Puc_v4p1_Plugin_Update', false) ):
|
||||
|
||||
/**
|
||||
* A simple container class for holding information about an available update.
|
||||
*
|
||||
* @author Janis Elsts
|
||||
* @copyright 2016
|
||||
* @access public
|
||||
*/
|
||||
class Puc_v4p1_Plugin_Update extends Puc_v4p1_Update {
|
||||
public $id = 0;
|
||||
public $homepage;
|
||||
public $upgrade_notice;
|
||||
public $tested;
|
||||
public $filename; //Plugin filename relative to the plugins directory.
|
||||
|
||||
protected static $extraFields = array(
|
||||
'id', 'homepage', 'tested', 'upgrade_notice', 'filename',
|
||||
);
|
||||
|
||||
/**
|
||||
* Create a new instance of PluginUpdate from its JSON-encoded representation.
|
||||
*
|
||||
* @param string $json
|
||||
* @return Puc_v4p1_Plugin_Update|null
|
||||
*/
|
||||
public static function fromJson($json){
|
||||
//Since update-related information is simply a subset of the full plugin info,
|
||||
//we can parse the update JSON as if it was a plugin info string, then copy over
|
||||
//the parts that we care about.
|
||||
$pluginInfo = Puc_v4p1_Plugin_Info::fromJson($json);
|
||||
if ( $pluginInfo != null ) {
|
||||
return self::fromPluginInfo($pluginInfo);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of PluginUpdate based on an instance of PluginInfo.
|
||||
* Basically, this just copies a subset of fields from one object to another.
|
||||
*
|
||||
* @param Puc_v4p1_Plugin_Info $info
|
||||
* @return Puc_v4p1_Plugin_Update
|
||||
*/
|
||||
public static function fromPluginInfo($info){
|
||||
return self::fromObject($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance by copying the necessary fields from another object.
|
||||
*
|
||||
* @param StdClass|Puc_v4p1_Plugin_Info|Puc_v4p1_Plugin_Update $object The source object.
|
||||
* @return Puc_v4p1_Plugin_Update The new copy.
|
||||
*/
|
||||
public static function fromObject($object) {
|
||||
$update = new self();
|
||||
$update->copyFields($object, $update);
|
||||
return $update;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getFieldNames() {
|
||||
return array_merge(parent::getFieldNames(), self::$extraFields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform the update into the format used by WordPress native plugin API.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function toWpFormat(){
|
||||
$update = parent::toWpFormat();
|
||||
|
||||
$update->id = $this->id;
|
||||
$update->url = $this->homepage;
|
||||
$update->tested = $this->tested;
|
||||
$update->plugin = $this->filename;
|
||||
|
||||
if ( !empty($this->upgrade_notice) ){
|
||||
$update->upgrade_notice = $this->upgrade_notice;
|
||||
}
|
||||
|
||||
return $update;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
546
update/Puc/v4p1/Plugin/UpdateChecker.php
Executable file
546
update/Puc/v4p1/Plugin/UpdateChecker.php
Executable file
@ -0,0 +1,546 @@
|
||||
<?php
|
||||
if ( !class_exists('Puc_v4p1_Plugin_UpdateChecker', false) ):
|
||||
|
||||
/**
|
||||
* A custom plugin update checker.
|
||||
*
|
||||
* @author Janis Elsts
|
||||
* @copyright 2016
|
||||
* @access public
|
||||
*/
|
||||
class Puc_v4p1_Plugin_UpdateChecker extends Puc_v4p1_UpdateChecker {
|
||||
protected $updateTransient = 'update_plugins';
|
||||
protected $translationType = 'plugin';
|
||||
|
||||
public $pluginAbsolutePath = ''; //Full path of the main plugin file.
|
||||
public $pluginFile = ''; //Plugin filename relative to the plugins directory. Many WP APIs use this to identify plugins.
|
||||
public $muPluginFile = ''; //For MU plugins, the plugin filename relative to the mu-plugins directory.
|
||||
|
||||
private $cachedInstalledVersion = null;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param string $metadataUrl The URL of the plugin's metadata file.
|
||||
* @param string $pluginFile Fully qualified path to the main plugin file.
|
||||
* @param string $slug The plugin's 'slug'. If not specified, the filename part of $pluginFile sans '.php' will be used as the slug.
|
||||
* @param integer $checkPeriod How often to check for updates (in hours). Defaults to checking every 12 hours. Set to 0 to disable automatic update checks.
|
||||
* @param string $optionName Where to store book-keeping info about update checks. Defaults to 'external_updates-$slug'.
|
||||
* @param string $muPluginFile Optional. The plugin filename relative to the mu-plugins directory.
|
||||
*/
|
||||
public function __construct($metadataUrl, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = ''){
|
||||
$this->pluginAbsolutePath = $pluginFile;
|
||||
$this->pluginFile = plugin_basename($this->pluginAbsolutePath);
|
||||
$this->muPluginFile = $muPluginFile;
|
||||
|
||||
//If no slug is specified, use the name of the main plugin file as the slug.
|
||||
//For example, 'my-cool-plugin/cool-plugin.php' becomes 'cool-plugin'.
|
||||
if ( empty($slug) ){
|
||||
$slug = basename($this->pluginFile, '.php');
|
||||
}
|
||||
|
||||
//Plugin slugs must be unique.
|
||||
$slugCheckFilter = 'puc_is_slug_in_use-' . $this->slug;
|
||||
$slugUsedBy = apply_filters($slugCheckFilter, false);
|
||||
if ( $slugUsedBy ) {
|
||||
$this->triggerError(sprintf(
|
||||
'Plugin slug "%s" is already in use by %s. Slugs must be unique.',
|
||||
htmlentities($this->slug),
|
||||
htmlentities($slugUsedBy)
|
||||
), E_USER_ERROR);
|
||||
}
|
||||
add_filter($slugCheckFilter, array($this, 'getAbsolutePath'));
|
||||
|
||||
//Backwards compatibility: If the plugin is a mu-plugin but no $muPluginFile is specified, assume
|
||||
//it's the same as $pluginFile given that it's not in a subdirectory (WP only looks in the base dir).
|
||||
if ( (strpbrk($this->pluginFile, '/\\') === false) && $this->isUnknownMuPlugin() ) {
|
||||
$this->muPluginFile = $this->pluginFile;
|
||||
}
|
||||
|
||||
parent::__construct($metadataUrl, dirname($this->pluginFile), $slug, $checkPeriod, $optionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the scheduler.
|
||||
*
|
||||
* @param int $checkPeriod
|
||||
* @return Puc_v4p1_Scheduler
|
||||
*/
|
||||
protected function createScheduler($checkPeriod) {
|
||||
$scheduler = new Puc_v4p1_Scheduler($this, $checkPeriod, array('load-plugins.php'));
|
||||
register_deactivation_hook($this->pluginFile, array($scheduler, 'removeUpdaterCron'));
|
||||
return $scheduler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install the hooks required to run periodic update checks and inject update info
|
||||
* into WP data structures.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function installHooks(){
|
||||
//Override requests for plugin information
|
||||
add_filter('plugins_api', array($this, 'injectInfo'), 20, 3);
|
||||
|
||||
add_filter('plugin_row_meta', array($this, 'addCheckForUpdatesLink'), 10, 2);
|
||||
add_action('admin_init', array($this, 'handleManualCheck'));
|
||||
add_action('all_admin_notices', array($this, 'displayManualCheckResult'));
|
||||
|
||||
//Clear the version number cache when something - anything - is upgraded or WP clears the update cache.
|
||||
add_filter('upgrader_post_install', array($this, 'clearCachedVersion'));
|
||||
add_action('delete_site_transient_update_plugins', array($this, 'clearCachedVersion'));
|
||||
|
||||
parent::installHooks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve plugin info from the configured API endpoint.
|
||||
*
|
||||
* @uses wp_remote_get()
|
||||
*
|
||||
* @param array $queryArgs Additional query arguments to append to the request. Optional.
|
||||
* @return Puc_v4p1_Plugin_Info
|
||||
*/
|
||||
public function requestInfo($queryArgs = array()) {
|
||||
list($pluginInfo, $result) = $this->requestMetadata('Puc_v4p1_Plugin_Info', 'request_info', $queryArgs);
|
||||
|
||||
if ( $pluginInfo !== null ) {
|
||||
/** @var Puc_v4p1_Plugin_Info $pluginInfo */
|
||||
$pluginInfo->filename = $this->pluginFile;
|
||||
$pluginInfo->slug = $this->slug;
|
||||
}
|
||||
|
||||
$pluginInfo = apply_filters($this->getUniqueName('request_info_result'), $pluginInfo, $result);
|
||||
return $pluginInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the latest update (if any) from the configured API endpoint.
|
||||
*
|
||||
* @uses PluginUpdateChecker::requestInfo()
|
||||
*
|
||||
* @return Puc_v4p1_Update|null An instance of Plugin_Update, or NULL when no updates are available.
|
||||
*/
|
||||
public function requestUpdate() {
|
||||
//For the sake of simplicity, this function just calls requestInfo()
|
||||
//and transforms the result accordingly.
|
||||
$pluginInfo = $this->requestInfo(array('checking_for_updates' => '1'));
|
||||
if ( $pluginInfo == null ){
|
||||
return null;
|
||||
}
|
||||
$update = Puc_v4p1_Plugin_Update::fromPluginInfo($pluginInfo);
|
||||
|
||||
$update = $this->filterUpdateResult($update);
|
||||
|
||||
return $update;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently installed version of the plugin.
|
||||
*
|
||||
* @return string Version number.
|
||||
*/
|
||||
public function getInstalledVersion(){
|
||||
if ( isset($this->cachedInstalledVersion) ) {
|
||||
return $this->cachedInstalledVersion;
|
||||
}
|
||||
|
||||
$pluginHeader = $this->getPluginHeader();
|
||||
if ( isset($pluginHeader['Version']) ) {
|
||||
$this->cachedInstalledVersion = $pluginHeader['Version'];
|
||||
return $pluginHeader['Version'];
|
||||
} else {
|
||||
//This can happen if the filename points to something that is not a plugin.
|
||||
$this->triggerError(
|
||||
sprintf(
|
||||
"Can't to read the Version header for '%s'. The filename is incorrect or is not a plugin.",
|
||||
$this->pluginFile
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plugin's metadata from its file header.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getPluginHeader() {
|
||||
if ( !is_file($this->pluginAbsolutePath) ) {
|
||||
//This can happen if the plugin filename is wrong.
|
||||
$this->triggerError(
|
||||
sprintf(
|
||||
"Can't to read the plugin header for '%s'. The file does not exist.",
|
||||
$this->pluginFile
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
return array();
|
||||
}
|
||||
|
||||
if ( !function_exists('get_plugin_data') ){
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
||||
}
|
||||
return get_plugin_data($this->pluginAbsolutePath, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getHeaderNames() {
|
||||
return array(
|
||||
'Name' => 'Plugin Name',
|
||||
'PluginURI' => 'Plugin URI',
|
||||
'Version' => 'Version',
|
||||
'Description' => 'Description',
|
||||
'Author' => 'Author',
|
||||
'AuthorURI' => 'Author URI',
|
||||
'TextDomain' => 'Text Domain',
|
||||
'DomainPath' => 'Domain Path',
|
||||
'Network' => 'Network',
|
||||
|
||||
//The newest WordPress version that this plugin requires or has been tested with.
|
||||
//We support several different formats for compatibility with other libraries.
|
||||
'Tested WP' => 'Tested WP',
|
||||
'Requires WP' => 'Requires WP',
|
||||
'Tested up to' => 'Tested up to',
|
||||
'Requires at least' => 'Requires at least',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Intercept plugins_api() calls that request information about our plugin and
|
||||
* use the configured API endpoint to satisfy them.
|
||||
*
|
||||
* @see plugins_api()
|
||||
*
|
||||
* @param mixed $result
|
||||
* @param string $action
|
||||
* @param array|object $args
|
||||
* @return mixed
|
||||
*/
|
||||
public function injectInfo($result, $action = null, $args = null){
|
||||
$relevant = ($action == 'plugin_information') && isset($args->slug) && (
|
||||
($args->slug == $this->slug) || ($args->slug == dirname($this->pluginFile))
|
||||
);
|
||||
if ( !$relevant ) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$pluginInfo = $this->requestInfo();
|
||||
$pluginInfo = apply_filters($this->getUniqueName('pre_inject_info'), $pluginInfo);
|
||||
if ( $pluginInfo ) {
|
||||
return $pluginInfo->toWpFormat();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function shouldShowUpdates() {
|
||||
//No update notifications for mu-plugins unless explicitly enabled. The MU plugin file
|
||||
//is usually different from the main plugin file so the update wouldn't show up properly anyway.
|
||||
return !$this->isUnknownMuPlugin();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stdClass|null $updates
|
||||
* @param stdClass $updateToAdd
|
||||
* @return stdClass
|
||||
*/
|
||||
protected function addUpdateToList($updates, $updateToAdd) {
|
||||
if ( $this->isMuPlugin() ) {
|
||||
//WP does not support automatic update installation for mu-plugins, but we can
|
||||
//still display a notice.
|
||||
$updateToAdd->package = null;
|
||||
}
|
||||
return parent::addUpdateToList($updates, $updateToAdd);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stdClass|null $updates
|
||||
* @return stdClass|null
|
||||
*/
|
||||
protected function removeUpdateFromList($updates) {
|
||||
$updates = parent::removeUpdateFromList($updates);
|
||||
if ( !empty($this->muPluginFile) && isset($updates, $updates->response) ) {
|
||||
unset($updates->response[$this->muPluginFile]);
|
||||
}
|
||||
return $updates;
|
||||
}
|
||||
|
||||
/**
|
||||
* For plugins, the update array is indexed by the plugin filename relative to the "plugins"
|
||||
* directory. Example: "plugin-name/plugin.php".
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getUpdateListKey() {
|
||||
if ( $this->isMuPlugin() ) {
|
||||
return $this->muPluginFile;
|
||||
}
|
||||
return $this->pluginFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for isBeingUpgraded().
|
||||
*
|
||||
* @deprecated
|
||||
* @param WP_Upgrader|null $upgrader The upgrader that's performing the current update.
|
||||
* @return bool
|
||||
*/
|
||||
public function isPluginBeingUpgraded($upgrader = null) {
|
||||
return $this->isBeingUpgraded($upgrader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is there an update being installed for this plugin, right now?
|
||||
*
|
||||
* @param WP_Upgrader|null $upgrader
|
||||
* @return bool
|
||||
*/
|
||||
public function isBeingUpgraded($upgrader = null) {
|
||||
return $this->upgraderStatus->isPluginBeingUpgraded($this->pluginFile, $upgrader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the details of the currently available update, if any.
|
||||
*
|
||||
* If no updates are available, or if the last known update version is below or equal
|
||||
* to the currently installed version, this method will return NULL.
|
||||
*
|
||||
* Uses cached update data. To retrieve update information straight from
|
||||
* the metadata URL, call requestUpdate() instead.
|
||||
*
|
||||
* @return Puc_v4p1_Plugin_Update|null
|
||||
*/
|
||||
public function getUpdate() {
|
||||
$update = parent::getUpdate();
|
||||
if ( isset($update) ) {
|
||||
/** @var Puc_v4p1_Plugin_Update $update */
|
||||
$update->filename = $this->pluginFile;
|
||||
}
|
||||
return $update;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a "Check for updates" link to the plugin row in the "Plugins" page. By default,
|
||||
* the new link will appear after the "Visit plugin site" link.
|
||||
*
|
||||
* You can change the link text by using the "puc_manual_check_link-$slug" filter.
|
||||
* Returning an empty string from the filter will disable the link.
|
||||
*
|
||||
* @param array $pluginMeta Array of meta links.
|
||||
* @param string $pluginFile
|
||||
* @return array
|
||||
*/
|
||||
public function addCheckForUpdatesLink($pluginMeta, $pluginFile) {
|
||||
$isRelevant = ($pluginFile == $this->pluginFile)
|
||||
|| (!empty($this->muPluginFile) && $pluginFile == $this->muPluginFile);
|
||||
|
||||
if ( $isRelevant && $this->userCanInstallUpdates() ) {
|
||||
$linkUrl = wp_nonce_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
'puc_check_for_updates' => 1,
|
||||
'puc_slug' => $this->slug,
|
||||
),
|
||||
self_admin_url('plugins.php')
|
||||
),
|
||||
'puc_check_for_updates'
|
||||
);
|
||||
|
||||
$linkText = apply_filters(
|
||||
$this->getUniqueName('manual_check_link'),
|
||||
__('Check for updates', 'plugin-update-checker')
|
||||
);
|
||||
if ( !empty($linkText) ) {
|
||||
/** @noinspection HtmlUnknownTarget */
|
||||
$pluginMeta[] = sprintf('<a href="%s">%s</a>', esc_attr($linkUrl), $linkText);
|
||||
}
|
||||
}
|
||||
return $pluginMeta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for updates when the user clicks the "Check for updates" link.
|
||||
* @see self::addCheckForUpdatesLink()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handleManualCheck() {
|
||||
$shouldCheck =
|
||||
isset($_GET['puc_check_for_updates'], $_GET['puc_slug'])
|
||||
&& $_GET['puc_slug'] == $this->slug
|
||||
&& $this->userCanInstallUpdates()
|
||||
&& check_admin_referer('puc_check_for_updates');
|
||||
|
||||
if ( $shouldCheck ) {
|
||||
$update = $this->checkForUpdates();
|
||||
$status = ($update === null) ? 'no_update' : 'update_available';
|
||||
wp_redirect(add_query_arg(
|
||||
array(
|
||||
'puc_update_check_result' => $status,
|
||||
'puc_slug' => $this->slug,
|
||||
),
|
||||
self_admin_url('plugins.php')
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the results of a manual update check.
|
||||
* @see self::handleManualCheck()
|
||||
*
|
||||
* You can change the result message by using the "puc_manual_check_message-$slug" filter.
|
||||
*/
|
||||
public function displayManualCheckResult() {
|
||||
if ( isset($_GET['puc_update_check_result'], $_GET['puc_slug']) && ($_GET['puc_slug'] == $this->slug) ) {
|
||||
$status = strval($_GET['puc_update_check_result']);
|
||||
$title = $this->getPluginTitle();
|
||||
if ( $status == 'no_update' ) {
|
||||
$message = sprintf(_x('The %s plugin is up to date.', 'the plugin title', 'plugin-update-checker'), $title);
|
||||
} else if ( $status == 'update_available' ) {
|
||||
$message = sprintf(_x('A new version of the %s plugin is available.', 'the plugin title', 'plugin-update-checker'), $title);
|
||||
} else {
|
||||
$message = sprintf(__('Unknown update checker status "%s"', 'plugin-update-checker'), htmlentities($status));
|
||||
}
|
||||
printf(
|
||||
'<div class="updated notice is-dismissible"><p>%s</p></div>',
|
||||
apply_filters($this->getUniqueName('manual_check_message'), $message, $status)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the translated plugin title.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getPluginTitle() {
|
||||
$title = '';
|
||||
$header = $this->getPluginHeader();
|
||||
if ( $header && !empty($header['Name']) && isset($header['TextDomain']) ) {
|
||||
$title = translate($header['Name'], $header['TextDomain']);
|
||||
}
|
||||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current user has the required permissions to install updates.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function userCanInstallUpdates() {
|
||||
return current_user_can('update_plugins');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the plugin file is inside the mu-plugins directory.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isMuPlugin() {
|
||||
static $cachedResult = null;
|
||||
|
||||
if ( $cachedResult === null ) {
|
||||
//Convert both paths to the canonical form before comparison.
|
||||
$muPluginDir = realpath(WPMU_PLUGIN_DIR);
|
||||
$pluginPath = realpath($this->pluginAbsolutePath);
|
||||
|
||||
$cachedResult = (strpos($pluginPath, $muPluginDir) === 0);
|
||||
}
|
||||
|
||||
return $cachedResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* MU plugins are partially supported, but only when we know which file in mu-plugins
|
||||
* corresponds to this plugin.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isUnknownMuPlugin() {
|
||||
return empty($this->muPluginFile) && $this->isMuPlugin();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cached plugin version. This method can be set up as a filter (hook) and will
|
||||
* return the filter argument unmodified.
|
||||
*
|
||||
* @param mixed $filterArgument
|
||||
* @return mixed
|
||||
*/
|
||||
public function clearCachedVersion($filterArgument = null) {
|
||||
$this->cachedInstalledVersion = null;
|
||||
return $filterArgument;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get absolute path to the main plugin file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAbsolutePath() {
|
||||
return $this->pluginAbsolutePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback for filtering query arguments.
|
||||
*
|
||||
* The callback function should take one argument - an associative array of query arguments.
|
||||
* It should return a modified array of query arguments.
|
||||
*
|
||||
* @uses add_filter() This method is a convenience wrapper for add_filter().
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return void
|
||||
*/
|
||||
public function addQueryArgFilter($callback){
|
||||
$this->addFilter('request_info_query_args', $callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback for filtering arguments passed to wp_remote_get().
|
||||
*
|
||||
* The callback function should take one argument - an associative array of arguments -
|
||||
* and return a modified array or arguments. See the WP documentation on wp_remote_get()
|
||||
* for details on what arguments are available and how they work.
|
||||
*
|
||||
* @uses add_filter() This method is a convenience wrapper for add_filter().
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return void
|
||||
*/
|
||||
public function addHttpRequestArgFilter($callback) {
|
||||
$this->addFilter('request_info_options', $callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback for filtering the plugin info retrieved from the external API.
|
||||
*
|
||||
* The callback function should take two arguments. If the plugin info was retrieved
|
||||
* successfully, the first argument passed will be an instance of PluginInfo. Otherwise,
|
||||
* it will be NULL. The second argument will be the corresponding return value of
|
||||
* wp_remote_get (see WP docs for details).
|
||||
*
|
||||
* The callback function should return a new or modified instance of PluginInfo or NULL.
|
||||
*
|
||||
* @uses add_filter() This method is a convenience wrapper for add_filter().
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return void
|
||||
*/
|
||||
public function addResultFilter($callback) {
|
||||
$this->addFilter('request_info_result', $callback, 10, 2);
|
||||
}
|
||||
|
||||
protected function createDebugBarExtension() {
|
||||
return new Puc_v4p1_DebugBar_PluginExtension($this);
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
177
update/Puc/v4p1/Scheduler.php
Executable file
177
update/Puc/v4p1/Scheduler.php
Executable file
@ -0,0 +1,177 @@
|
||||
<?php
|
||||
if ( !class_exists('Puc_v4p1_Scheduler', false) ):
|
||||
|
||||
/**
|
||||
* The scheduler decides when and how often to check for updates.
|
||||
* It calls @see Puc_v4p1_UpdateChecker::checkForUpdates() to perform the actual checks.
|
||||
*/
|
||||
class Puc_v4p1_Scheduler {
|
||||
public $checkPeriod = 12; //How often to check for updates (in hours).
|
||||
public $throttleRedundantChecks = false; //Check less often if we already know that an update is available.
|
||||
public $throttledCheckPeriod = 72;
|
||||
|
||||
protected $hourlyCheckHooks = array('load-update.php');
|
||||
|
||||
/**
|
||||
* @var Puc_v4p1_UpdateChecker
|
||||
*/
|
||||
protected $updateChecker;
|
||||
|
||||
private $cronHook = null;
|
||||
|
||||
/**
|
||||
* Scheduler constructor.
|
||||
*
|
||||
* @param Puc_v4p1_UpdateChecker $updateChecker
|
||||
* @param int $checkPeriod How often to check for updates (in hours).
|
||||
* @param array $hourlyHooks
|
||||
*/
|
||||
public function __construct($updateChecker, $checkPeriod, $hourlyHooks = array('load-plugins.php')) {
|
||||
$this->updateChecker = $updateChecker;
|
||||
$this->checkPeriod = $checkPeriod;
|
||||
|
||||
//Set up the periodic update checks
|
||||
$this->cronHook = $this->updateChecker->getUniqueName('cron_check_updates');
|
||||
if ( $this->checkPeriod > 0 ){
|
||||
|
||||
//Trigger the check via Cron.
|
||||
//Try to use one of the default schedules if possible as it's less likely to conflict
|
||||
//with other plugins and their custom schedules.
|
||||
$defaultSchedules = array(
|
||||
1 => 'hourly',
|
||||
12 => 'twicedaily',
|
||||
24 => 'daily',
|
||||
);
|
||||
if ( array_key_exists($this->checkPeriod, $defaultSchedules) ) {
|
||||
$scheduleName = $defaultSchedules[$this->checkPeriod];
|
||||
} else {
|
||||
//Use a custom cron schedule.
|
||||
$scheduleName = 'every' . $this->checkPeriod . 'hours';
|
||||
add_filter('cron_schedules', array($this, '_addCustomSchedule'));
|
||||
}
|
||||
|
||||
if ( !wp_next_scheduled($this->cronHook) && !defined('WP_INSTALLING') ) {
|
||||
wp_schedule_event(time(), $scheduleName, $this->cronHook);
|
||||
}
|
||||
add_action($this->cronHook, array($this, 'maybeCheckForUpdates'));
|
||||
|
||||
//In case Cron is disabled or unreliable, we also manually trigger
|
||||
//the periodic checks while the user is browsing the Dashboard.
|
||||
add_action( 'admin_init', array($this, 'maybeCheckForUpdates') );
|
||||
|
||||
//Like WordPress itself, we check more often on certain pages.
|
||||
/** @see wp_update_plugins */
|
||||
add_action('load-update-core.php', array($this, 'maybeCheckForUpdates'));
|
||||
//"load-update.php" and "load-plugins.php" or "load-themes.php".
|
||||
$this->hourlyCheckHooks = array_merge($this->hourlyCheckHooks, $hourlyHooks);
|
||||
foreach($this->hourlyCheckHooks as $hook) {
|
||||
add_action($hook, array($this, 'maybeCheckForUpdates'));
|
||||
}
|
||||
//This hook fires after a bulk update is complete.
|
||||
add_action('upgrader_process_complete', array($this, 'maybeCheckForUpdates'), 11, 0);
|
||||
|
||||
} else {
|
||||
//Periodic checks are disabled.
|
||||
wp_clear_scheduled_hook($this->cronHook);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for updates if the configured check interval has already elapsed.
|
||||
* Will use a shorter check interval on certain admin pages like "Dashboard -> Updates" or when doing cron.
|
||||
*
|
||||
* You can override the default behaviour by using the "puc_check_now-$slug" filter.
|
||||
* The filter callback will be passed three parameters:
|
||||
* - Current decision. TRUE = check updates now, FALSE = don't check now.
|
||||
* - Last check time as a Unix timestamp.
|
||||
* - Configured check period in hours.
|
||||
* Return TRUE to check for updates immediately, or FALSE to cancel.
|
||||
*
|
||||
* This method is declared public because it's a hook callback. Calling it directly is not recommended.
|
||||
*/
|
||||
public function maybeCheckForUpdates(){
|
||||
if ( empty($this->checkPeriod) ){
|
||||
return;
|
||||
}
|
||||
|
||||
$state = $this->updateChecker->getUpdateState();
|
||||
$shouldCheck = ($state->timeSinceLastCheck() >= $this->getEffectiveCheckPeriod());
|
||||
|
||||
//Let plugin authors substitute their own algorithm.
|
||||
$shouldCheck = apply_filters(
|
||||
$this->updateChecker->getUniqueName('check_now'),
|
||||
$shouldCheck,
|
||||
$state->getLastCheck(),
|
||||
$this->checkPeriod
|
||||
);
|
||||
|
||||
if ( $shouldCheck ) {
|
||||
$this->updateChecker->checkForUpdates();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the actual check period based on the current status and environment.
|
||||
*
|
||||
* @return int Check period in seconds.
|
||||
*/
|
||||
protected function getEffectiveCheckPeriod() {
|
||||
$currentFilter = current_filter();
|
||||
if ( in_array($currentFilter, array('load-update-core.php', 'upgrader_process_complete')) ) {
|
||||
//Check more often when the user visits "Dashboard -> Updates" or does a bulk update.
|
||||
$period = 60;
|
||||
} else if ( in_array($currentFilter, $this->hourlyCheckHooks) ) {
|
||||
//Also check more often on /wp-admin/update.php and the "Plugins" or "Themes" page.
|
||||
$period = 3600;
|
||||
} else if ( $this->throttleRedundantChecks && ($this->updateChecker->getUpdate() !== null) ) {
|
||||
//Check less frequently if it's already known that an update is available.
|
||||
$period = $this->throttledCheckPeriod * 3600;
|
||||
} else if ( defined('DOING_CRON') && constant('DOING_CRON') ) {
|
||||
//WordPress cron schedules are not exact, so lets do an update check even
|
||||
//if slightly less than $checkPeriod hours have elapsed since the last check.
|
||||
$cronFuzziness = 20 * 60;
|
||||
$period = $this->checkPeriod * 3600 - $cronFuzziness;
|
||||
} else {
|
||||
$period = $this->checkPeriod * 3600;
|
||||
}
|
||||
|
||||
return $period;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add our custom schedule to the array of Cron schedules used by WP.
|
||||
*
|
||||
* @param array $schedules
|
||||
* @return array
|
||||
*/
|
||||
public function _addCustomSchedule($schedules){
|
||||
if ( $this->checkPeriod && ($this->checkPeriod > 0) ){
|
||||
$scheduleName = 'every' . $this->checkPeriod . 'hours';
|
||||
$schedules[$scheduleName] = array(
|
||||
'interval' => $this->checkPeriod * 3600,
|
||||
'display' => sprintf('Every %d hours', $this->checkPeriod),
|
||||
);
|
||||
}
|
||||
return $schedules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the scheduled cron event that the library uses to check for updates.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removeUpdaterCron(){
|
||||
wp_clear_scheduled_hook($this->cronHook);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the update checker's WP-cron hook. Mostly useful for debugging.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCronHookName() {
|
||||
return $this->cronHook;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
207
update/Puc/v4p1/StateStore.php
Executable file
207
update/Puc/v4p1/StateStore.php
Executable file
@ -0,0 +1,207 @@
|
||||
<?php
|
||||
|
||||
if ( !class_exists('Puc_v4p1_StateStore', false) ):
|
||||
|
||||
class Puc_v4p1_StateStore {
|
||||
/**
|
||||
* @var int Last update check timestamp.
|
||||
*/
|
||||
protected $lastCheck = 0;
|
||||
|
||||
/**
|
||||
* @var string Version number.
|
||||
*/
|
||||
protected $checkedVersion = '';
|
||||
|
||||
/**
|
||||
* @var Puc_v4p1_Update|null Cached update.
|
||||
*/
|
||||
protected $update = null;
|
||||
|
||||
/**
|
||||
* @var string Site option name.
|
||||
*/
|
||||
private $optionName = '';
|
||||
|
||||
/**
|
||||
* @var bool Whether we've already tried to load the state from the database.
|
||||
*/
|
||||
private $isLoaded = false;
|
||||
|
||||
public function __construct($optionName) {
|
||||
$this->optionName = $optionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get time elapsed since the last update check.
|
||||
*
|
||||
* If there are no recorded update checks, this method returns a large arbitrary number
|
||||
* (i.e. time since the Unix epoch).
|
||||
*
|
||||
* @return int Elapsed time in seconds.
|
||||
*/
|
||||
public function timeSinceLastCheck() {
|
||||
$this->lazyLoad();
|
||||
return time() - $this->lastCheck;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLastCheck() {
|
||||
$this->lazyLoad();
|
||||
return $this->lastCheck;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the time of the last update check to the current timestamp.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLastCheckToNow() {
|
||||
$this->lazyLoad();
|
||||
$this->lastCheck = time();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|Puc_v4p1_Update
|
||||
*/
|
||||
public function getUpdate() {
|
||||
$this->lazyLoad();
|
||||
return $this->update;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Puc_v4p1_Update|null $update
|
||||
* @return $this
|
||||
*/
|
||||
public function setUpdate(Puc_v4p1_Update $update = null) {
|
||||
$this->lazyLoad();
|
||||
$this->update = $update;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCheckedVersion() {
|
||||
$this->lazyLoad();
|
||||
return $this->checkedVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $version
|
||||
* @return $this
|
||||
*/
|
||||
public function setCheckedVersion($version) {
|
||||
$this->lazyLoad();
|
||||
$this->checkedVersion = strval($version);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get translation updates.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTranslations() {
|
||||
$this->lazyLoad();
|
||||
if ( isset($this->update, $this->update->translations) ) {
|
||||
return $this->update->translations;
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set translation updates.
|
||||
*
|
||||
* @param array $translationUpdates
|
||||
*/
|
||||
public function setTranslations($translationUpdates) {
|
||||
$this->lazyLoad();
|
||||
if ( isset($this->update) ) {
|
||||
$this->update->translations = $translationUpdates;
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function save() {
|
||||
$state = new stdClass();
|
||||
|
||||
$state->lastCheck = $this->lastCheck;
|
||||
$state->checkedVersion = $this->checkedVersion;
|
||||
|
||||
if ( isset($this->update)) {
|
||||
$state->update = $this->update->toStdClass();
|
||||
|
||||
$updateClass = get_class($this->update);
|
||||
$state->updateClass = $updateClass;
|
||||
$prefix = $this->getLibPrefix();
|
||||
if ( Puc_v4p1_Utils::startsWith($updateClass, $prefix) ) {
|
||||
$state->updateBaseClass = substr($updateClass, strlen($prefix));
|
||||
}
|
||||
}
|
||||
|
||||
update_site_option($this->optionName, $state);
|
||||
$this->isLoaded = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function lazyLoad() {
|
||||
if ( !$this->isLoaded ) {
|
||||
$this->load();
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function load() {
|
||||
$this->isLoaded = true;
|
||||
|
||||
$state = get_site_option($this->optionName, null);
|
||||
|
||||
if ( !is_object($state) ) {
|
||||
$this->lastCheck = 0;
|
||||
$this->checkedVersion = '';
|
||||
$this->update = null;
|
||||
return;
|
||||
}
|
||||
|
||||
$this->lastCheck = intval(Puc_v4p1_Utils::get($state, 'lastCheck', 0));
|
||||
$this->checkedVersion = Puc_v4p1_Utils::get($state, 'checkedVersion', '');
|
||||
$this->update = null;
|
||||
|
||||
if ( isset($state->update) ) {
|
||||
//This mess is due to the fact that the want the update class from this version
|
||||
//of the library, not the version that saved the update.
|
||||
|
||||
$updateClass = null;
|
||||
if ( isset($state->updateBaseClass) ) {
|
||||
$updateClass = $this->getLibPrefix() . $state->updateBaseClass;
|
||||
} else if ( isset($state->updateClass) && class_exists($state->updateClass) ) {
|
||||
$updateClass = $state->updateClass;
|
||||
}
|
||||
|
||||
if ( $updateClass !== null ) {
|
||||
$this->update = call_user_func(array($updateClass, 'fromObject'), $state->update);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
delete_site_option($this->optionName);
|
||||
|
||||
$this->lastCheck = 0;
|
||||
$this->checkedVersion = '';
|
||||
$this->update = null;
|
||||
}
|
||||
|
||||
private function getLibPrefix() {
|
||||
$parts = explode('_', __CLASS__, 3);
|
||||
return $parts[0] . '_' . $parts[1] . '_';
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
84
update/Puc/v4p1/Theme/Update.php
Executable file
84
update/Puc/v4p1/Theme/Update.php
Executable file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
if ( !class_exists('Puc_v4p1_Theme_Update', false) ):
|
||||
|
||||
class Puc_v4p1_Theme_Update extends Puc_v4p1_Update {
|
||||
public $details_url = '';
|
||||
|
||||
protected static $extraFields = array('details_url');
|
||||
|
||||
/**
|
||||
* Transform the metadata into the format used by WordPress core.
|
||||
* Note the inconsistency: WP stores plugin updates as objects and theme updates as arrays.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toWpFormat() {
|
||||
$update = array(
|
||||
'theme' => $this->slug,
|
||||
'new_version' => $this->version,
|
||||
'url' => $this->details_url,
|
||||
);
|
||||
|
||||
if ( !empty($this->download_url) ) {
|
||||
$update['package'] = $this->download_url;
|
||||
}
|
||||
|
||||
return $update;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of Theme_Update from its JSON-encoded representation.
|
||||
*
|
||||
* @param string $json Valid JSON string representing a theme information object.
|
||||
* @return self New instance of ThemeUpdate, or NULL on error.
|
||||
*/
|
||||
public static function fromJson($json) {
|
||||
$instance = new self();
|
||||
if ( !parent::createFromJson($json, $instance) ) {
|
||||
return null;
|
||||
}
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance by copying the necessary fields from another object.
|
||||
*
|
||||
* @param StdClass|Puc_v4p1_Theme_Update $object The source object.
|
||||
* @return Puc_v4p1_Theme_Update The new copy.
|
||||
*/
|
||||
public static function fromObject($object) {
|
||||
$update = new self();
|
||||
$update->copyFields($object, $update);
|
||||
return $update;
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic validation.
|
||||
*
|
||||
* @param StdClass $apiResponse
|
||||
* @return bool|WP_Error
|
||||
*/
|
||||
protected function validateMetadata($apiResponse) {
|
||||
$required = array('version', 'details_url');
|
||||
foreach($required as $key) {
|
||||
if ( !isset($apiResponse->$key) || empty($apiResponse->$key) ) {
|
||||
return new WP_Error(
|
||||
'tuc-invalid-metadata',
|
||||
sprintf('The theme metadata is missing the required "%s" key.', $key)
|
||||
);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getFieldNames() {
|
||||
return array_merge(parent::getFieldNames(), self::$extraFields);
|
||||
}
|
||||
|
||||
protected function getPrefixedFilter($tag) {
|
||||
return parent::getPrefixedFilter($tag) . '_theme';
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
167
update/Puc/v4p1/Theme/UpdateChecker.php
Executable file
167
update/Puc/v4p1/Theme/UpdateChecker.php
Executable file
@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
if ( !class_exists('Puc_v4p1_Theme_UpdateChecker', false) ):
|
||||
|
||||
class Puc_v4p1_Theme_UpdateChecker extends Puc_v4p1_UpdateChecker {
|
||||
protected $filterSuffix = 'theme';
|
||||
protected $updateTransient = 'update_themes';
|
||||
protected $translationType = 'theme';
|
||||
|
||||
/**
|
||||
* @var string Theme directory name.
|
||||
*/
|
||||
protected $stylesheet;
|
||||
|
||||
/**
|
||||
* @var WP_Theme Theme object.
|
||||
*/
|
||||
protected $theme;
|
||||
|
||||
public function __construct($metadataUrl, $stylesheet = null, $customSlug = null, $checkPeriod = 12, $optionName = '') {
|
||||
if ( $stylesheet === null ) {
|
||||
$stylesheet = get_stylesheet();
|
||||
}
|
||||
$this->stylesheet = $stylesheet;
|
||||
$this->theme = wp_get_theme($this->stylesheet);
|
||||
|
||||
parent::__construct(
|
||||
$metadataUrl,
|
||||
$stylesheet,
|
||||
$customSlug ? $customSlug : $stylesheet,
|
||||
$checkPeriod,
|
||||
$optionName
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* For themes, the update array is indexed by theme directory name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getUpdateListKey() {
|
||||
return $this->directoryName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the latest update (if any) from the configured API endpoint.
|
||||
*
|
||||
* @return Puc_v4p1_Update|null An instance of Update, or NULL when no updates are available.
|
||||
*/
|
||||
public function requestUpdate() {
|
||||
list($themeUpdate, $result) = $this->requestMetadata('Puc_v4p1_Theme_Update', 'request_update');
|
||||
|
||||
if ( $themeUpdate !== null ) {
|
||||
/** @var Puc_v4p1_Theme_Update $themeUpdate */
|
||||
$themeUpdate->slug = $this->slug;
|
||||
}
|
||||
|
||||
$themeUpdate = $this->filterUpdateResult($themeUpdate, $result);
|
||||
return $themeUpdate;
|
||||
}
|
||||
|
||||
public function userCanInstallUpdates() {
|
||||
return current_user_can('update_themes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently installed version of the plugin or theme.
|
||||
*
|
||||
* @return string Version number.
|
||||
*/
|
||||
public function getInstalledVersion() {
|
||||
return $this->theme->get('Version');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the scheduler.
|
||||
*
|
||||
* @param int $checkPeriod
|
||||
* @return Puc_v4p1_Scheduler
|
||||
*/
|
||||
protected function createScheduler($checkPeriod) {
|
||||
return new Puc_v4p1_Scheduler($this, $checkPeriod, array('load-themes.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Is there an update being installed right now for this theme?
|
||||
*
|
||||
* @param WP_Upgrader|null $upgrader The upgrader that's performing the current update.
|
||||
* @return bool
|
||||
*/
|
||||
public function isBeingUpgraded($upgrader = null) {
|
||||
return $this->upgraderStatus->isThemeBeingUpgraded($this->stylesheet, $upgrader);
|
||||
}
|
||||
|
||||
protected function createDebugBarExtension() {
|
||||
return new Puc_v4p1_DebugBar_Extension($this, 'Puc_v4p1_DebugBar_ThemePanel');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback for filtering query arguments.
|
||||
*
|
||||
* The callback function should take one argument - an associative array of query arguments.
|
||||
* It should return a modified array of query arguments.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return void
|
||||
*/
|
||||
public function addQueryArgFilter($callback){
|
||||
$this->addFilter('request_update_query_args', $callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback for filtering arguments passed to wp_remote_get().
|
||||
*
|
||||
* The callback function should take one argument - an associative array of arguments -
|
||||
* and return a modified array or arguments. See the WP documentation on wp_remote_get()
|
||||
* for details on what arguments are available and how they work.
|
||||
*
|
||||
* @uses add_filter() This method is a convenience wrapper for add_filter().
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return void
|
||||
*/
|
||||
public function addHttpRequestArgFilter($callback) {
|
||||
$this->addFilter('request_update_options', $callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback for filtering theme updates retrieved from the external API.
|
||||
*
|
||||
* The callback function should take two arguments. If the theme update was retrieved
|
||||
* successfully, the first argument passed will be an instance of Theme_Update. Otherwise,
|
||||
* it will be NULL. The second argument will be the corresponding return value of
|
||||
* wp_remote_get (see WP docs for details).
|
||||
*
|
||||
* The callback function should return a new or modified instance of Theme_Update or NULL.
|
||||
*
|
||||
* @uses add_filter() This method is a convenience wrapper for add_filter().
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return void
|
||||
*/
|
||||
public function addResultFilter($callback) {
|
||||
$this->addFilter('request_update_result', $callback, 10, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getHeaderNames() {
|
||||
return array(
|
||||
'Name' => 'Theme Name',
|
||||
'ThemeURI' => 'Theme URI',
|
||||
'Description' => 'Description',
|
||||
'Author' => 'Author',
|
||||
'AuthorURI' => 'Author URI',
|
||||
'Version' => 'Version',
|
||||
'Template' => 'Template',
|
||||
'Status' => 'Status',
|
||||
'Tags' => 'Tags',
|
||||
'TextDomain' => 'Text Domain',
|
||||
'DomainPath' => 'Domain Path',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
34
update/Puc/v4p1/Update.php
Executable file
34
update/Puc/v4p1/Update.php
Executable file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
if ( !class_exists('Puc_v4p1_Update', false) ):
|
||||
|
||||
/**
|
||||
* A simple container class for holding information about an available update.
|
||||
*
|
||||
* @author Janis Elsts
|
||||
* @access public
|
||||
*/
|
||||
abstract class Puc_v4p1_Update extends Puc_v4p1_Metadata {
|
||||
public $slug;
|
||||
public $version;
|
||||
public $download_url;
|
||||
public $translations = array();
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getFieldNames() {
|
||||
return array('slug', 'version', 'download_url', 'translations');
|
||||
}
|
||||
|
||||
public function toWpFormat() {
|
||||
$update = new stdClass();
|
||||
|
||||
$update->slug = $this->slug;
|
||||
$update->new_version = $this->version;
|
||||
$update->package = $this->download_url;
|
||||
|
||||
return $update;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
825
update/Puc/v4p1/UpdateChecker.php
Executable file
825
update/Puc/v4p1/UpdateChecker.php
Executable file
@ -0,0 +1,825 @@
|
||||
<?php
|
||||
|
||||
if ( !class_exists('Puc_v4p1_UpdateChecker', false) ):
|
||||
|
||||
abstract class Puc_v4p1_UpdateChecker {
|
||||
protected $filterSuffix = '';
|
||||
protected $updateTransient = '';
|
||||
protected $translationType = ''; //"plugin" or "theme".
|
||||
|
||||
/**
|
||||
* Set to TRUE to enable error reporting. Errors are raised using trigger_error()
|
||||
* and should be logged to the standard PHP error log.
|
||||
* @var bool
|
||||
*/
|
||||
public $debugMode = false;
|
||||
|
||||
/**
|
||||
* @var string Where to store the update info.
|
||||
*/
|
||||
public $optionName = '';
|
||||
|
||||
/**
|
||||
* @var string The URL of the metadata file.
|
||||
*/
|
||||
public $metadataUrl = '';
|
||||
|
||||
/**
|
||||
* @var string Plugin or theme directory name.
|
||||
*/
|
||||
public $directoryName = '';
|
||||
|
||||
/**
|
||||
* @var string The slug that will be used in update checker hooks and remote API requests.
|
||||
* Usually matches the directory name unless the plugin/theme directory has been renamed.
|
||||
*/
|
||||
public $slug = '';
|
||||
|
||||
/**
|
||||
* @var Puc_v4p1_Scheduler
|
||||
*/
|
||||
public $scheduler;
|
||||
|
||||
/**
|
||||
* @var Puc_v4p1_UpgraderStatus
|
||||
*/
|
||||
protected $upgraderStatus;
|
||||
|
||||
/**
|
||||
* @var Puc_v4p1_StateStore
|
||||
*/
|
||||
protected $updateState;
|
||||
|
||||
public function __construct($metadataUrl, $directoryName, $slug = null, $checkPeriod = 12, $optionName = '') {
|
||||
$this->debugMode = (bool)(constant('WP_DEBUG'));
|
||||
$this->metadataUrl = $metadataUrl;
|
||||
$this->directoryName = $directoryName;
|
||||
$this->slug = !empty($slug) ? $slug : $this->directoryName;
|
||||
|
||||
$this->optionName = $optionName;
|
||||
if ( empty($this->optionName) ) {
|
||||
//BC: Initially the library only supported plugin updates and didn't use type prefixes
|
||||
//in the option name. Lets use the same prefix-less name when possible.
|
||||
if ( $this->filterSuffix === '' ) {
|
||||
$this->optionName = 'external_updates-' . $this->slug;
|
||||
} else {
|
||||
$this->optionName = $this->getUniqueName('external_updates');
|
||||
}
|
||||
}
|
||||
|
||||
$this->scheduler = $this->createScheduler($checkPeriod);
|
||||
$this->upgraderStatus = new Puc_v4p1_UpgraderStatus();
|
||||
$this->updateState = new Puc_v4p1_StateStore($this->optionName);
|
||||
|
||||
if ( did_action('init') ) {
|
||||
$this->loadTextDomain();
|
||||
} else {
|
||||
add_action('init', array($this, 'loadTextDomain'));
|
||||
}
|
||||
|
||||
$this->installHooks();
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function loadTextDomain() {
|
||||
//We're not using load_plugin_textdomain() or its siblings because figuring out where
|
||||
//the library is located (plugin, mu-plugin, theme, custom wp-content paths) is messy.
|
||||
$domain = 'plugin-update-checker';
|
||||
$locale = apply_filters(
|
||||
'plugin_locale',
|
||||
(is_admin() && function_exists('get_user_locale')) ? get_user_locale() : get_locale(),
|
||||
$domain
|
||||
);
|
||||
|
||||
$moFile = $domain . '-' . $locale . '.mo';
|
||||
$path = realpath(dirname(__FILE__) . '/../../languages');
|
||||
|
||||
if ($path && file_exists($path)) {
|
||||
load_textdomain($domain, $path . '/' . $moFile);
|
||||
}
|
||||
}
|
||||
|
||||
protected function installHooks() {
|
||||
//Insert our update info into the update array maintained by WP.
|
||||
add_filter('site_transient_' . $this->updateTransient, array($this,'injectUpdate'));
|
||||
|
||||
//Insert translation updates into the update list.
|
||||
add_filter('site_transient_' . $this->updateTransient, array($this, 'injectTranslationUpdates'));
|
||||
|
||||
//Clear translation updates when WP clears the update cache.
|
||||
//This needs to be done directly because the library doesn't actually remove obsolete plugin updates,
|
||||
//it just hides them (see getUpdate()). We can't do that with translations - too much disk I/O.
|
||||
add_action(
|
||||
'delete_site_transient_' . $this->updateTransient,
|
||||
array($this, 'clearCachedTranslationUpdates')
|
||||
);
|
||||
|
||||
//Rename the update directory to be the same as the existing directory.
|
||||
if ( $this->directoryName !== '.' ) {
|
||||
add_filter('upgrader_source_selection', array($this, 'fixDirectoryName'), 10, 3);
|
||||
}
|
||||
|
||||
//Allow HTTP requests to the metadata URL even if it's on a local host.
|
||||
add_filter('http_request_host_is_external', array($this, 'allowMetadataHost'), 10, 2);
|
||||
|
||||
//DebugBar integration.
|
||||
if ( did_action('plugins_loaded') ) {
|
||||
$this->maybeInitDebugBar();
|
||||
} else {
|
||||
add_action('plugins_loaded', array($this, 'maybeInitDebugBar'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current user has the required permissions to install updates.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function userCanInstallUpdates();
|
||||
|
||||
/**
|
||||
* Explicitly allow HTTP requests to the metadata URL.
|
||||
*
|
||||
* WordPress has a security feature where the HTTP API will reject all requests that are sent to
|
||||
* another site hosted on the same server as the current site (IP match), a local host, or a local
|
||||
* IP, unless the host exactly matches the current site.
|
||||
*
|
||||
* This feature is opt-in (at least in WP 4.4). Apparently some people enable it.
|
||||
*
|
||||
* That can be a problem when you're developing your plugin and you decide to host the update information
|
||||
* on the same server as your test site. Update requests will mysteriously fail.
|
||||
*
|
||||
* We fix that by adding an exception for the metadata host.
|
||||
*
|
||||
* @param bool $allow
|
||||
* @param string $host
|
||||
* @return bool
|
||||
*/
|
||||
public function allowMetadataHost($allow, $host) {
|
||||
static $metadataHost = 0; //Using 0 instead of NULL because parse_url can return NULL.
|
||||
if ( $metadataHost === 0 ) {
|
||||
$metadataHost = @parse_url($this->metadataUrl, PHP_URL_HOST);
|
||||
}
|
||||
|
||||
if ( is_string($metadataHost) && (strtolower($host) === strtolower($metadataHost)) ) {
|
||||
return true;
|
||||
}
|
||||
return $allow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the scheduler.
|
||||
*
|
||||
* This is implemented as a method to make it possible for plugins to subclass the update checker
|
||||
* and substitute their own scheduler.
|
||||
*
|
||||
* @param int $checkPeriod
|
||||
* @return Puc_v4p1_Scheduler
|
||||
*/
|
||||
abstract protected function createScheduler($checkPeriod);
|
||||
|
||||
/**
|
||||
* Check for updates. The results are stored in the DB option specified in $optionName.
|
||||
*
|
||||
* @return Puc_v4p1_Update|null
|
||||
*/
|
||||
public function checkForUpdates() {
|
||||
$installedVersion = $this->getInstalledVersion();
|
||||
//Fail silently if we can't find the plugin/theme or read its header.
|
||||
if ( $installedVersion === null ) {
|
||||
$this->triggerError(
|
||||
sprintf('Skipping update check for %s - installed version unknown.', $this->slug),
|
||||
E_USER_WARNING
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
$state = $this->updateState;
|
||||
$state->setLastCheckToNow()
|
||||
->setCheckedVersion($installedVersion)
|
||||
->save(); //Save before checking in case something goes wrong
|
||||
|
||||
$state->setUpdate($this->requestUpdate());
|
||||
$state->save();
|
||||
|
||||
return $this->getUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the update checker state from the DB.
|
||||
*
|
||||
* @return Puc_v4p1_StateStore
|
||||
*/
|
||||
public function getUpdateState() {
|
||||
return $this->updateState->lazyLoad();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset update checker state - i.e. last check time, cached update data and so on.
|
||||
*
|
||||
* Call this when your plugin is being uninstalled, or if you want to
|
||||
* clear the update cache.
|
||||
*/
|
||||
public function resetUpdateState() {
|
||||
$this->updateState->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the details of the currently available update, if any.
|
||||
*
|
||||
* If no updates are available, or if the last known update version is below or equal
|
||||
* to the currently installed version, this method will return NULL.
|
||||
*
|
||||
* Uses cached update data. To retrieve update information straight from
|
||||
* the metadata URL, call requestUpdate() instead.
|
||||
*
|
||||
* @return Puc_v4p1_Update|null
|
||||
*/
|
||||
public function getUpdate() {
|
||||
$update = $this->updateState->getUpdate();
|
||||
|
||||
//Is there an update available?
|
||||
if ( isset($update) ) {
|
||||
//Check if the update is actually newer than the currently installed version.
|
||||
$installedVersion = $this->getInstalledVersion();
|
||||
if ( ($installedVersion !== null) && version_compare($update->version, $installedVersion, '>') ){
|
||||
return $update;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the latest update (if any) from the configured API endpoint.
|
||||
*
|
||||
* Subclasses should run the update through filterUpdateResult before returning it.
|
||||
*
|
||||
* @return Puc_v4p1_Update An instance of Update, or NULL when no updates are available.
|
||||
*/
|
||||
abstract public function requestUpdate();
|
||||
|
||||
/**
|
||||
* Filter the result of a requestUpdate() call.
|
||||
*
|
||||
* @param Puc_v4p1_Update|null $update
|
||||
* @param array|WP_Error|null $httpResult The value returned by wp_remote_get(), if any.
|
||||
* @return Puc_v4p1_Update
|
||||
*/
|
||||
protected function filterUpdateResult($update, $httpResult = null) {
|
||||
//Let plugins/themes modify the update.
|
||||
$update = apply_filters($this->getUniqueName('request_update_result'), $update, $httpResult);
|
||||
|
||||
if ( isset($update, $update->translations) ) {
|
||||
//Keep only those translation updates that apply to this site.
|
||||
$update->translations = $this->filterApplicableTranslations($update->translations);
|
||||
}
|
||||
|
||||
return $update;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently installed version of the plugin or theme.
|
||||
*
|
||||
* @return string|null Version number.
|
||||
*/
|
||||
abstract public function getInstalledVersion();
|
||||
|
||||
/**
|
||||
* Trigger a PHP error, but only when $debugMode is enabled.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $errorType
|
||||
*/
|
||||
protected function triggerError($message, $errorType) {
|
||||
if ($this->debugMode) {
|
||||
trigger_error($message, $errorType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full name of an update checker filter, action or DB entry.
|
||||
*
|
||||
* This method adds the "puc_" prefix and the "-$slug" suffix to the filter name.
|
||||
* For example, "pre_inject_update" becomes "puc_pre_inject_update-plugin-slug".
|
||||
*
|
||||
* @param string $baseTag
|
||||
* @return string
|
||||
*/
|
||||
public function getUniqueName($baseTag) {
|
||||
$name = 'puc_' . $baseTag;
|
||||
if ($this->filterSuffix !== '') {
|
||||
$name .= '_' . $this->filterSuffix;
|
||||
}
|
||||
return $name . '-' . $this->slug;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------
|
||||
* PUC filters and filter utilities
|
||||
* -------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Register a callback for one of the update checker filters.
|
||||
*
|
||||
* Identical to add_filter(), except it automatically adds the "puc_" prefix
|
||||
* and the "-$slug" suffix to the filter name. For example, "request_info_result"
|
||||
* becomes "puc_request_info_result-your_plugin_slug".
|
||||
*
|
||||
* @param string $tag
|
||||
* @param callable $callback
|
||||
* @param int $priority
|
||||
* @param int $acceptedArgs
|
||||
*/
|
||||
public function addFilter($tag, $callback, $priority = 10, $acceptedArgs = 1) {
|
||||
add_filter($this->getUniqueName($tag), $callback, $priority, $acceptedArgs);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------
|
||||
* Inject updates
|
||||
* -------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Insert the latest update (if any) into the update list maintained by WP.
|
||||
*
|
||||
* @param stdClass $updates Update list.
|
||||
* @return stdClass Modified update list.
|
||||
*/
|
||||
public function injectUpdate($updates) {
|
||||
//Is there an update to insert?
|
||||
$update = $this->getUpdate();
|
||||
|
||||
if ( !$this->shouldShowUpdates() ) {
|
||||
$update = null;
|
||||
}
|
||||
|
||||
if ( !empty($update) ) {
|
||||
//Let plugins filter the update info before it's passed on to WordPress.
|
||||
$update = apply_filters($this->getUniqueName('pre_inject_update'), $update);
|
||||
$updates = $this->addUpdateToList($updates, $update->toWpFormat());
|
||||
} else {
|
||||
//Clean up any stale update info.
|
||||
$updates = $this->removeUpdateFromList($updates);
|
||||
}
|
||||
|
||||
return $updates;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stdClass|null $updates
|
||||
* @param stdClass|array $updateToAdd
|
||||
* @return stdClass
|
||||
*/
|
||||
protected function addUpdateToList($updates, $updateToAdd) {
|
||||
if ( !is_object($updates) ) {
|
||||
$updates = new stdClass();
|
||||
$updates->response = array();
|
||||
}
|
||||
|
||||
$updates->response[$this->getUpdateListKey()] = $updateToAdd;
|
||||
return $updates;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stdClass|null $updates
|
||||
* @return stdClass|null
|
||||
*/
|
||||
protected function removeUpdateFromList($updates) {
|
||||
if ( isset($updates, $updates->response) ) {
|
||||
unset($updates->response[$this->getUpdateListKey()]);
|
||||
}
|
||||
return $updates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the key that will be used when adding updates to the update list that's maintained
|
||||
* by the WordPress core. The list is always an associative array, but the key is different
|
||||
* for plugins and themes.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getUpdateListKey();
|
||||
|
||||
/**
|
||||
* Should we show available updates?
|
||||
*
|
||||
* Usually the answer is "yes", but there are exceptions. For example, WordPress doesn't
|
||||
* support automatic updates installation for mu-plugins, so PUC usually won't show update
|
||||
* notifications in that case. See the plugin-specific subclass for details.
|
||||