get( 'Version' ) );
/* Ladies and Gentlemans, boys and girls let's start our engine */
function spacexchimp_theme_setup() {
global $content_width;
// Localization Init
load_theme_textdomain( 'anarcho-notepad', get_template_directory() . '/languages' );
// This feature enables Custom Backgrounds.
add_theme_support( 'custom-background', array(
'default-image' => get_template_directory_uri() . '/images/background.png'
));
// This feature enables Custom Header.
add_theme_support( 'custom-header', array(
'flex-width' => true,
'width' => 500,
'flex-height' => true,
'height' => 150,
//'default-text-color' => '#e5e5e5',
'header-text' => true,
//'default-image' => get_template_directory_uri() . '/images/logotype.png',
'uploads' => true,
));
// This feature enables Featured Images (also known as post thumbnails).
add_theme_support('post-thumbnails');
set_post_thumbnail_size(540,230,!1);
// This feature enables post and comment RSS feed links to
.
add_theme_support('automatic-feed-links');
// Add HTML5 elements
add_theme_support( 'html5', array( 'comment-list', 'search-form', 'comment-form', 'gallery', 'caption', ) );
// Add Title-tag
add_theme_support('title-tag');
// This feature enables menu.
register_nav_menus( array(
'primary' => __( 'Primary', 'anarcho-notepad' )
));
// This feature enables Link Manager in Admin page.
add_filter( 'pre_option_link_manager_enabled', '__return_true' );
}
add_action( 'after_setup_theme', 'spacexchimp_theme_setup' );
/**
* Upgrade DB settings
*
* @since 2.31
*/
function spacexchimp_theme_upgrade_settings() {
// Read saved theme settings
$settings_saved = get_option( 'theme_mods_anarcho-notepad' );
// Return if the upgrade has already been made
if ( isset($settings_saved['upgraded']) && $settings_saved['upgraded'] == 'yes' ) {
return;
}
// Make array with default values
$settings_default = array(
'enable_year_ribbons' => '',
'disable_ribbons' => '',
'enable_title_animation' => '',
'disable_paper_search' => '',
'disable_about_box' => '',
'disable_links_box' => '',
'disable_stickers' => '',
'disable_recent_sticker' => '',
'enable_breadcrumbs' => '',
'enable_page-nav' => '',
'disable_about_bio' => '',
'disable_scroll_to_top' => '',
'show_info_line' => '',
'disable_rss_icon' => '',
'num_recent_post' => '6',
'upgraded' => 'yes'
);
if ( !empty( $settings_saved ) ) {
// Merge array of saved settings with array of new default settings
$settings = array_merge( $settings_default, $settings_saved );
} else {
$settings = $settings_default;
}
// Save new setting with default values
update_option( 'theme_mods_anarcho-notepad', $settings );
}
spacexchimp_theme_upgrade_settings();
//Adding backwards compatibility for title-tag less than WordPress version 4.1
if ( ! function_exists( '_wp_render_title_tag' ) ) {
function spacexchimp_theme_render_title() {
?>
add_menu( array(
'parent' => 'top-secondary', // Off on the right side
'id' => 'anarcho-help' ,
'title' => __( 'Help' , 'anarcho-notepad' ),
'href' => admin_url( 'themes.php?page=theme_options' ),
'meta' => array(
'title' => __( 'Need help with Anarcho-Notepad? Click here!', 'anarcho-notepad' )
)
));
}
}
add_action ( 'wp_before_admin_bar_render', 'spacexchimp_theme_add_help_button' );
/* Add the Upgrade notice */
require get_template_directory() . '/inc/upgrade_notice.php';
/**
* Enqueue scripts and styles on the admin pages.
*/
function spacexchimp_theme_scripts_admin() {
// Load additional stylesheet for admin screens
wp_enqueue_style( 'anarcho-admin-css', get_template_directory_uri() . '/inc/admin.css', array(), SPACEXCHIMP_T001_VERSION, 'all' );
}
add_action( 'admin_enqueue_scripts', 'spacexchimp_theme_scripts_admin' );
/**
* Enqueue scripts and styles on the front end.
*/
function spacexchimp_theme_scripts_frontend() {
// Load JQuery library
wp_enqueue_script( 'jquery' );
// Load the Font-Awesome iconic font
wp_enqueue_style( 'anarcho-font-awesome-css', get_template_directory_uri() . '/fonts/font-awesome/css/font-awesome.css', array(), SPACEXCHIMP_T001_VERSION, 'screen' );
// Comments. Enable comment_reply
if ( is_singular() ) wp_enqueue_script( "comment-reply" );
// Scroll to Top Button. Load the smoothscroll.js
wp_enqueue_script( 'anarcho-smooth-scroll-js', get_template_directory_uri() . '/js/smoothscroll.js', array( 'jquery' ), SPACEXCHIMP_T001_VERSION, true );
}
add_action( 'wp_enqueue_scripts', 'spacexchimp_theme_scripts_frontend' );
/* Add Theme Customizer functionality */
require get_template_directory() . '/inc/customizer-arrays.php';
require get_template_directory() . '/inc/customizer.php';
/* This feature enables widgets area in the sidebar */
function spacexchimp_theme_widgets_init() {
register_sidebar(array(
'name' => __( 'Sidebar Area 1', 'anarcho-notepad' ),
'id' => 'sidebar-1',
'description' => __( 'Widgets in this area will be shown below "Pages".', 'anarcho-notepad' ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
));
register_sidebar(array(
'name' => __( 'Sidebar Area 2', 'anarcho-notepad' ),
'id' => 'sidebar-2',
'description' => __( 'Widgets in this area will be shown below "What is this place?".', 'anarcho-notepad' ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
));
register_sidebar(array(
'name' => __( 'Sidebar Area 3', 'anarcho-notepad' ),
'id' => 'sidebar-3',
'description' => __( 'Widgets in this area will be shown below "Friends & Links".', 'anarcho-notepad' ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
));
register_sidebar(array(
'name' => __( 'Sidebar Area 4', 'anarcho-notepad' ),
'id' => 'sidebar-4',
'description' => __( 'Widgets in this area will be shown below "Recent Posts".', 'anarcho-notepad' ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
));
}
add_action( 'widgets_init', 'spacexchimp_theme_widgets_init' );
/* This feature enables widgets area in the footer */
function spacexchimp_theme_widgets_footer_init() {
register_sidebar(array(
'name' => __( 'Footer Area 1', 'anarcho-notepad' ),
'id' => 'footer-1',
'description' => __( 'Widgets in this area will be shown left.', 'anarcho-notepad' ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
));
register_sidebar(array(
'name' => __( 'Footer Area 2', 'anarcho-notepad' ),
'id' => 'footer-2',
'description' => __( 'Widgets in this area will be shown center.', 'anarcho-notepad' ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
));
register_sidebar(array(
'name' => __( 'Footer Area 3', 'anarcho-notepad' ),
'id' => 'footer-3',
'description' => __( 'Widgets in this area will be shown right.', 'anarcho-notepad' ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
));
}
add_action( 'widgets_init', 'spacexchimp_theme_widgets_footer_init' );
/* Adds a custom default avatar */
function spacexchimp_theme_avatar( $avatar_defaults ) {
$myavatar = get_stylesheet_directory_uri() . '/images/anarchy-symbol.png';
$avatar_defaults[$myavatar] = 'Anarcho symbol';
return $avatar_defaults;
}
add_filter( 'avatar_defaults', 'spacexchimp_theme_avatar' );
/* Display block "About the Author" */
function spacexchimp_theme_author_bio() {
if ( get_theme_mod('disable_about_bio') !== '1' ) {
if ( ( get_the_author_meta( 'description' ) != '' ) ) {
echo esc_html( get_template_part( 'author-bio' ) );
}
}
}
/* Date Tag (Red ribbon) */
function spacexchimp_theme_date_tag() {
if ( get_theme_mod('disable_ribbons') !== '1' ) {
if ( get_theme_mod('enable_year_ribbons') !== '1' ) {
if ( is_home() || is_category() || is_archive() || is_search() ) {
printf( '',
esc_url( get_permalink() )
);
}
printf( '