* @copyright Copyright (c) 2013-2017, Arthur Gareginyan
* @link http://mycyberuniverse.com/anarcho-notepad.html
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
/* Ladies and Gentlemans, boys and girls let's start our engine */
function anarcho_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', 'anarcho_setup' );
/**
* Upgrade DB settings
*
* @since 2.31
*/
function anarcho_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 );
}
anarcho_upgrade_settings();
//Adding backwards compatibility for title-tag less than WordPress version 4.1
if ( ! function_exists( '_wp_render_title_tag' ) ) {
function anarcho_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', 'anarcho_add_help_button' );
/* Enqueue additional stylesheet for admin screens */
function anarcho_include_admin_style() {
wp_enqueue_style( 'anarcho_admin_styles', get_template_directory_uri() . '/inc/admin.css' );
}
add_action( 'admin_init', 'anarcho_include_admin_style' );
/* Add the Upgrade notice */
require get_template_directory() . '/inc/upgrade_notice.php';
/* Add IE conditional HTML5 shim to header */
function anarcho_add_ie_html5_shim () {
global $is_IE;
if ( $is_IE )
echo '';
}
add_action( 'wp_head', 'anarcho_add_ie_html5_shim' );
/* Add Theme Customizer functionality */
require get_template_directory() . '/inc/customizer.php';
/* This feature enables widgets area in the sidebar */
function anarcho_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', 'anarcho_widgets_init' );
/* This feature enables widgets area in the footer */
function anarcho_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', 'anarcho_widgets_footer_init' );
/* Adds a custom default avatar */
function anarcho_avatar( $avatar_defaults ) {
$myavatar = get_stylesheet_directory_uri() . '/images/anarchy-symbol.png';
$avatar_defaults[$myavatar] = 'Anarcho symbol';
return $avatar_defaults;
}
add_filter( 'avatar_defaults', 'anarcho_avatar' );
/* Include Font-Awesome iconic font */
function anarcho_include_font_awesome_styles() {
wp_register_style( 'font_awesome_styles', get_template_directory_uri() . '/fonts/font-awesome-4.7.0/css/font-awesome.min.css', 'screen' );
wp_enqueue_style( 'font_awesome_styles' );
}
add_action( 'wp_enqueue_scripts', 'anarcho_include_font_awesome_styles' );
/* Display block "About the Author" */
function anarcho_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 anarcho_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( '