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 https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => esc_html__( 'Primary', 'ampface' ),
) );
/*
* 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',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'ampface_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
/**
* Add support for core custom logo.
*
* @link https://codex.wordpress.org/Theme_Logo
*/
add_theme_support( 'custom-logo', array(
'height' => 250,
'width' => 250,
'flex-width' => true,
'flex-height' => true,
) );
}
endif;
add_action( 'after_setup_theme', 'ampface_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 ampface_content_width() {
// This variable is intended to be overruled from themes.
// Open WPCS issue: {@link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1043}.
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
$GLOBALS['content_width'] = apply_filters( 'ampface_content_width', 640 );
}
add_action( 'after_setup_theme', 'ampface_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function ampface_widgets_init() {
register_sidebar(
array(
'name' => __( 'Sidebar Left', 'ampface' ),
'id' => 'sidebar-left',
'description' => __( 'Add widgets here to appear in your left sidebar.', 'ampface' ),
'before_widget' => '',
'before_title' => '
',
)
);
register_sidebar(
array(
'name' => __( 'Sidebar Right', 'ampface' ),
'id' => 'sidebar-right',
'description' => __( 'Add widgets here to appear in your right sidebar.', 'ampface' ),
'before_widget' => '',
'before_title' => '',
)
);
register_sidebar(
array(
'name' => __( 'Content Bottom 1', 'ampface' ),
'id' => 'content-bottom-1',
'description' => __( 'Appears at the bottom of the content on posts and pages.', 'ampface' ),
'before_widget' => '',
'before_title' => '',
)
);
register_sidebar(
array(
'name' => __( 'Content Bottom 2', 'ampface' ),
'id' => 'content-bottom-2',
'description' => __( 'Appears at the bottom of the content on posts and pages.', 'ampface' ),
'before_widget' => '',
'before_title' => '',
)
);
register_sidebar( array(
'name' => __( 'ampFaceSlider', 'ampface' ),
'id' => 'ampfaceslider',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '',
) );
register_sidebar( array(
'name' => 'Footer 1 Widget',
'id' => 'footer_1',
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => 'Footer 2 Widget',
'id' => 'footer_2',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => 'Footer 3 Widget',
'id' => 'footer_3',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => 'Color 1 Widget',
'id' => 'color_1',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => 'Color 2 Widget',
'id' => 'color_2',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => 'Color 3 Widget',
'id' => 'color_3',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => 'Top 1 Widget',
'id' => 'top_1',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => 'Top 2 Widget',
'id' => 'top_2',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => 'Top 3 Widget',
'id' => 'top_3',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => 'Base 1 Widget',
'id' => 'base_1',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => 'Base 2 Widget',
'id' => 'base_2',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => 'Base 3 Widget',
'id' => 'base_3',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
}
add_action( 'widgets_init', 'ampface_widgets_init' );
/**
* Enqueue scripts and styles.
*/
function ampface_scripts() {
wp_enqueue_style( 'ampface-style', get_stylesheet_uri() );
wp_enqueue_script( 'ampface-js', get_template_directory_uri() . '/assets/js/index.js', array() );
wp_script_add_data( 'ampface-js', 'async', true );
wp_enqueue_style( 'ampface-style', get_stylesheet_uri() );
wp_enqueue_script( 'ampface-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'ampface_scripts' );
/**
* Implement the Custom Header feature.
*/
require get_template_directory() . '/inc/custom-header.php';
/**
* Custom template tags for this theme.
*/
/**
* Functions which enhance the theme by hooking into WordPress.
*/
require get_template_directory() . '/inc/template-functions.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Load Jetpack compatibility file.
*/
if ( defined( 'JETPACK__VERSION' ) ) {
require get_template_directory() . '/inc/jetpack.php';
}
/**
* AMPFace Defaults
*/
function ampface_defaults( $setting ) {
$defaults = array(
'default_setting_ampface_base_width' => __( 'narrow','ampface' ),
'default_link_color' => __( '#3e7fb7','ampface' ),
);
return isset ($defaults[$setting]) ? $defaults[$setting] : false;
}
function ampFace_customize_css() { ?>
max_num_pages <= 1 )
return;
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
$max = intval( $wp_query->max_num_pages );
/** Add current page to the array */
if ( $paged >= 1 )
$links[] = $paged;
/** Add the pages around the current page to the array */
if ( $paged >= 3 ) {
$links[] = $paged - 1;
$links[] = $paged - 2;
}
if ( ( $paged + 2 ) <= $max ) {
$links[] = $paged + 2;
$links[] = $paged + 1;
}
echo '' . "\n";
/** Previous Post Link */
if ( get_previous_posts_link() )
printf( '- %s
' . "\n", get_previous_posts_link() );
/** Link to first page, plus ellipses if necessary */
if ( ! in_array( 1, $links ) ) {
$class = 1 == $paged ? ' class="active"' : '';
printf( '- %s
' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
if ( ! in_array( 2, $links ) )
echo '- ..
';
}
/** Link to current page, plus 2 pages in either direction if necessary */
sort( $links );
foreach ( (array) $links as $link ) {
$class = $paged == $link ? ' class="active"' : '';
printf( '- %s
' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
}
/** Link to last page, plus ellipses if necessary */
if ( ! in_array( $max, $links ) ) {
if ( ! in_array( $max - 1, $links ) )
echo '- ..
' . "\n";
$class = $paged == $max ? ' class="active"' : '';
printf( '- %s
' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
}
/** Next Post Link */
if ( get_next_posts_link() )
printf( '- %s
' . "\n", get_next_posts_link() );
echo '
' . "\n";
}
/** end af navigation */
/**
* Filters the default archive titles.
*/
function ampface_archivetitles() {
if ( is_category() ) {
$title = __( '', 'ampface' ) . '' . single_term_title( '', false ) . '';
} elseif ( is_tag() ) {
$title = __( 'Tags: ', 'ampface' ) . '' . single_term_title( '', false ) . '';
} elseif ( is_author() ) {
$title = __( 'Authors: ', 'ampface' ) . '' . get_the_author_meta( 'display_name' ) . '';
} elseif ( is_year() ) {
$title = __( 'Yearly Archives: ', 'ampface' ) . '' . get_the_date( _x( 'Y', 'yearly archives date format', 'ampface' ) ) . '';
} elseif ( is_month() ) {
$title = __( 'Monthly Archives: ', 'ampface' ) . '' . get_the_date( _x( 'F Y', 'monthly archives date format', 'ampface' ) ) . '';
} elseif ( is_day() ) {
$title = __( 'Daily Archives: ', 'ampface' ) . '' . get_the_date() . '';
} elseif ( is_post_type_archive() ) {
$title = __( 'Post Type Archives: ', 'ampface' ) . '' . post_type_archive_title( '', false ) . '';
} elseif ( is_tax() ) {
$tax = get_taxonomy( get_queried_object()->taxonomy );
/* translators: %s: Taxonomy singular name */
$title = sprintf( esc_html__( '%s Archives:', 'ampface' ), $tax->labels->singular_name );
} else {
$title = __( '', 'ampface' );
}
return $title;
}
add_filter( 'get_the_archive_title', 'ampface_archivetitles' );
add_theme_support( 'amp', array(
'paired' => true,
) );
add_editor_style( 'style.css' );