'loop-container',
'footer' => 'overflow-container',
'render' => 'ct_author_infinite_scroll_render'
) );
require_once( trailingslashit( get_template_directory() ) . 'theme-options.php' );
foreach ( glob( trailingslashit( get_template_directory() ) . 'inc/*' ) as $filename ) {
include $filename;
}
load_theme_textdomain( 'author', get_template_directory() . '/languages' );
register_nav_menus( array(
'primary' => __( 'Primary', 'author' )
) );
}
}
add_action( 'after_setup_theme', 'ct_author_theme_setup', 10 );
function ct_author_register_widget_areas() {
// after post content
register_sidebar( array(
'name' => __( 'Primary Sidebar', 'author' ),
'id' => 'primary',
'description' => __( 'Widgets in this area will be shown in the sidebar', 'author' ),
'before_widget' => '',
'before_title' => '
'
) );
}
add_action( 'widgets_init', 'ct_author_register_widget_areas' );
if ( ! function_exists( 'ct_author_customize_comments' ) ) {
function ct_author_customize_comments( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
$comment_type = $comment->comment_type;
?>
id="li-comment-">
';
$fields['email'] =
'';
$fields['url'] =
'';
return $fields;
}
}
add_filter( 'comment_form_default_fields', 'ct_author_update_fields' );
if ( ! function_exists( 'ct_author_update_comment_field' ) ) {
function ct_author_update_comment_field( $comment_field ) {
$comment_field =
'';
return $comment_field;
}
}
add_filter( 'comment_form_field_comment', 'ct_author_update_comment_field' );
if ( ! function_exists( 'ct_author_remove_comments_notes_after' ) ) {
function ct_author_remove_comments_notes_after( $defaults ) {
$defaults['comment_notes_after'] = '';
return $defaults;
}
}
add_action( 'comment_form_defaults', 'ct_author_remove_comments_notes_after' );
if ( ! function_exists( 'ct_author_excerpt' ) ) {
function ct_author_excerpt() {
global $post;
$show_full_post = get_theme_mod( 'full_post' );
$read_more_text = get_theme_mod( 'read_more_text' );
$ismore = strpos( $post->post_content, '' );
if ( ( $show_full_post == 'yes' ) && ! is_search() ) {
if ( $ismore ) {
// Has to be written this way because i18n text CANNOT be stored in a variable
if ( ! empty( $read_more_text ) ) {
the_content( wp_kses_post( $read_more_text ) . " " . get_the_title() . "" );
} else {
the_content( __( 'Continue reading', 'author' ) . " " . get_the_title() . "" );
}
} else {
the_content();
}
} elseif ( $ismore ) {
if ( ! empty( $read_more_text ) ) {
the_content( wp_kses_post( $read_more_text ) . " " . get_the_title() . "" );
} else {
the_content( __( 'Continue reading', 'author' ) . " " . get_the_title() . "" );
}
} else {
the_excerpt();
}
}
}
if ( ! function_exists( 'ct_author_excerpt_read_more_link' ) ) {
function ct_author_excerpt_read_more_link( $output ) {
global $post;
$read_more_text = get_theme_mod( 'read_more_text' );
if ( ! empty( $read_more_text ) ) {
return $output . "" . wp_kses_post( $read_more_text ) . " " . get_the_title() . "
";
} else {
return $output . "" . __( 'Continue reading', 'author' ) . " " . get_the_title() . "
";
}
}
}
add_filter( 'the_excerpt', 'ct_author_excerpt_read_more_link' );
function ct_author_custom_excerpt_length( $length ) {
$new_excerpt_length = get_theme_mod( 'excerpt_length' );
if ( ! empty( $new_excerpt_length ) && $new_excerpt_length != 25 ) {
return $new_excerpt_length;
} elseif ( $new_excerpt_length === 0 ) {
return 0;
} else {
return 25;
}
}
add_filter( 'excerpt_length', 'ct_author_custom_excerpt_length', 99 );
if ( ! function_exists( 'ct_author_new_excerpt_more' ) ) {
function ct_author_new_excerpt_more( $more ) {
$new_excerpt_length = get_theme_mod( 'excerpt_length' );
$excerpt_more = ( $new_excerpt_length === 0 ) ? '' : '…';
return $excerpt_more;
}
}
add_filter( 'excerpt_more', 'ct_author_new_excerpt_more' );
if ( ! function_exists( 'ct_author_remove_more_link_scroll' ) ) {
function ct_author_remove_more_link_scroll( $link ) {
$link = preg_replace( '|#more-[0-9]+|', '', $link );
return $link;
}
}
add_filter( 'the_content_more_link', 'ct_author_remove_more_link_scroll' );
if ( ! function_exists( 'ct_author_featured_image' ) ) {
function ct_author_featured_image() {
global $post;
$featured_image = '';
if ( has_post_thumbnail( $post->ID ) ) {
if ( is_singular() ) {
$featured_image = '' . get_the_post_thumbnail( $post->ID, 'full' ) . '
';
} else {
$featured_image = '';
}
}
$featured_image = apply_filters( 'ct_author_featured_image', $featured_image );
if ( $featured_image ) {
echo $featured_image;
}
}
}
if ( ! function_exists( 'ct_author_social_array' ) ) {
function ct_author_social_array() {
$social_sites = array(
'twitter' => 'author_twitter_profile',
'facebook' => 'author_facebook_profile',
'google-plus' => 'author_googleplus_profile',
'pinterest' => 'author_pinterest_profile',
'linkedin' => 'author_linkedin_profile',
'youtube' => 'author_youtube_profile',
'vimeo' => 'author_vimeo_profile',
'tumblr' => 'author_tumblr_profile',
'instagram' => 'author_instagram_profile',
'flickr' => 'author_flickr_profile',
'dribbble' => 'author_dribbble_profile',
'rss' => 'author_rss_profile',
'reddit' => 'author_reddit_profile',
'soundcloud' => 'author_soundcloud_profile',
'spotify' => 'author_spotify_profile',
'vine' => 'author_vine_profile',
'yahoo' => 'author_yahoo_profile',
'behance' => 'author_behance_profile',
'codepen' => 'author_codepen_profile',
'delicious' => 'author_delicious_profile',
'stumbleupon' => 'author_stumbleupon_profile',
'deviantart' => 'author_deviantart_profile',
'digg' => 'author_digg_profile',
'github' => 'author_github_profile',
'hacker-news' => 'author_hacker-news_profile',
'foursquare' => 'author_foursquare_profile',
'slack' => 'author_slack_profile',
'slideshare' => 'author_slideshare_profile',
'skype' => 'author_skype_profile',
'whatsapp' => 'author_whatsapp_profile',
'qq' => 'author_qq_profile',
'wechat' => 'author_wechat_profile',
'xing' => 'author_xing_profile',
'500px' => 'author_500px_profile',
'paypal' => 'author_paypal_profile',
'steam' => 'author_steam_profile',
'vk' => 'author_vk_profile',
'weibo' => 'author_weibo_profile',
'tencent-weibo' => 'author_tencent_weibo_profile',
'email' => 'author_email_profile'
);
return apply_filters( 'ct_author_social_array_filter', $social_sites );
}
}
if ( ! function_exists( 'ct_author_social_icons_output' ) ) {
function ct_author_social_icons_output() {
$social_sites = ct_author_social_array();
$square_icons = array(
'linkedin',
'twitter',
'vimeo',
'youtube',
'pinterest',
'rss',
'reddit',
'tumblr',
'steam',
'xing',
'github',
'google-plus',
'behance',
'facebook'
);
foreach ( $social_sites as $social_site => $profile ) {
if ( strlen( get_theme_mod( $social_site ) ) > 0 ) {
$active_sites[ $social_site ] = $social_site;
}
}
if ( ! empty( $active_sites ) ) {
echo "";
}
}
}
/*
* WP will apply the ".menu-primary-items" class & id to the containing instead of
* making styling difficult and confusing. Using this wrapper to add a unique class to make styling easier.
*/
function ct_author_wp_page_menu() {
wp_page_menu( array(
"menu_class" => "menu-unset",
"depth" => - 1
)
);
}
// used in header.php for primary avatar and comments
function ct_author_output_avatar() {
$avatar_method = get_theme_mod( 'avatar_method' );
$avatar = '';
if ( $avatar_method == 'gravatar' ) {
$avatar = get_avatar( get_option( 'admin_email' ) );
// use regex to grab source from markup
$avatar = ct_author_get_avatar_url( $avatar );
} elseif ( $avatar_method == 'upload' ) {
$avatar = get_theme_mod( 'avatar' );
}
return $avatar;
}
function ct_author_get_avatar_url( $get_avatar ) {
// WP User Avatar switches the use of quotes
if ( class_exists( 'WP_User_Avatar' ) ) {
preg_match( '/src="([^"]*)"/i', $get_avatar, $matches );
} else {
preg_match( "/src='([^']*)'/i", $get_avatar, $matches );
}
return $matches[1];
}
function ct_author_nav_dropdown_buttons( $item_output, $item, $depth, $args ) {
if ( $args->theme_location == 'primary' ) {
if ( in_array( 'menu-item-has-children', $item->classes ) || in_array( 'page_item_has_children', $item->classes ) ) {
$item_output = str_replace( $args->link_after . '', $args->link_after . '', $item_output );
}
}
return $item_output;
}
add_filter( 'walker_nav_menu_start_el', 'ct_author_nav_dropdown_buttons', 10, 4 );
function ct_author_custom_css_output() {
$custom_css = get_theme_mod( 'custom_css' );
if ( $custom_css ) {
$custom_css = wp_filter_nohtml_kses( $custom_css );
wp_add_inline_style( 'ct-author-style', $custom_css );
wp_add_inline_style( 'ct-author-style-rtl', $custom_css );
}
}
add_action( 'wp_enqueue_scripts', 'ct_author_custom_css_output', 20 );
function ct_author_body_class( $classes ) {
global $post;
$full_post = get_theme_mod( 'full_post' );
if ( $full_post == 'yes' ) {
$classes[] = 'full-post';
}
if ( is_singular() ) {
$classes[] = 'singular';
if ( is_singular( 'page' ) ) {
$classes[] = 'singular-page';
$classes[] = 'singular-page-' . $post->ID;
} elseif ( is_singular( 'post' ) ) {
$classes[] = 'singular-post';
$classes[] = 'singular-post-' . $post->ID;
} elseif ( is_singular( 'attachment' ) ) {
$classes[] = 'singular-attachment';
$classes[] = 'singular-attachment-' . $post->ID;
}
}
return $classes;
}
add_filter( 'body_class', 'ct_author_body_class' );
function ct_author_post_class( $classes ) {
$classes[] = 'entry';
return $classes;
}
add_filter( 'post_class', 'ct_author_post_class' );
function ct_author_reset_customizer_options() {
if ( empty( $_POST['author_reset_customizer'] ) || 'author_reset_customizer_settings' !== $_POST['author_reset_customizer'] ) {
return;
}
if ( ! wp_verify_nonce( $_POST['author_reset_customizer_nonce'], 'author_reset_customizer_nonce' ) ) {
return;
}
if ( ! current_user_can( 'edit_theme_options' ) ) {
return;
}
$mods_array = array(
'avatar_method',
'avatar',
'logo_upload',
'full_post',
'excerpt_length',
'read_more_text',
'comments_display',
'custom_css'
);
$social_sites = ct_author_social_array();
// add social site settings to mods array
foreach ( $social_sites as $social_site => $value ) {
$mods_array[] = $social_site;
}
$mods_array = apply_filters( 'ct_author_mods_to_remove', $mods_array );
foreach ( $mods_array as $theme_mod ) {
remove_theme_mod( $theme_mod );
}
$redirect = admin_url( 'themes.php?page=author-options' );
$redirect = add_query_arg( 'author_status', 'deleted', $redirect );
// safely redirect
wp_safe_redirect( $redirect );
exit;
}
add_action( 'admin_init', 'ct_author_reset_customizer_options' );
function ct_author_delete_settings_notice() {
if ( isset( $_GET['author_status'] ) ) {
?>
' . __( "Featured Post", "author" ) . '';
}
}
add_action( 'archive_post_before', 'ct_author_sticky_post_marker' );
function ct_author_add_meta_elements() {
$meta_elements = '';
$meta_elements .= sprintf( '' . "\n", get_bloginfo( 'charset' ) );
$meta_elements .= '' . "\n";
$theme = wp_get_theme( get_template() );
$template = sprintf( '' . "\n", esc_attr( $theme->get( 'Name' ) ), esc_attr( $theme->get( 'Version' ) ) );
$meta_elements .= $template;
echo $meta_elements;
}
add_action( 'wp_head', 'ct_author_add_meta_elements', 1 );
// Move the WordPress generator to a better priority.
remove_action( 'wp_head', 'wp_generator' );
add_action( 'wp_head', 'wp_generator', 1 );
function ct_author_infinite_scroll_render() {
while ( have_posts() ) {
the_post();
get_template_part( 'content', 'archive' );
}
}
function ct_author_get_content_template() {
/* Blog */
if ( is_home() ) {
get_template_part( 'content', 'archive' );
} /* Post */
elseif ( is_singular( 'post' ) ) {
get_template_part( 'content' );
} /* Page */
elseif ( is_page() ) {
get_template_part( 'content', 'page' );
} /* Attachment */
elseif ( is_attachment() ) {
get_template_part( 'content', 'attachment' );
} /* Archive */
elseif ( is_archive() ) {
get_template_part( 'content', 'archive' );
} /* Custom Post Type */
else {
get_template_part( 'content' );
}
}