__( 'Top Menu', 'brendah' ),
)
);
}
endif; // brendah_setup
add_action( 'after_setup_theme', 'brendah_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 brendah_content_width() {
$content_width = 700;
/**
* Filter Brendah content width of the theme.
*
* @since Brendah 1.0.0
*
* @param $content_width integer
*/
$GLOBALS['content_width'] = apply_filters( 'brendah_content_width', $content_width );
}
add_action( 'after_setup_theme', 'brendah_content_width', 0 );
/**
* Registers a widget area.
*
* @link https://developer.wordpress.org/reference/functions/register_sidebar/
*
* @since Brendah 1.0.0
*/
function brendah_widgets_init() {
//Main sidebar that appears to the rigt/left of the content area
register_sidebar( array(
'name' => __( 'Sidebar', 'brendah' ),
'id' => 'sidebar-1',
'description' => __( 'Add widgets here to appear in your sidebar.', 'brendah' ),
'before_widget' => '',
'before_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Footer', 'brendah' ),
'id' => 'sidebar-2',
'description' => __( 'Add widgets here to appear in your footer area.', 'brendah' ),
'before_widget' => '',
'before_title' => '',
) );
}
add_action( 'widgets_init', 'brendah_widgets_init' );
/**
* Replaces "[...]" (appended to automatically generated excerpts) with ... and
* a 'Continue reading' link.
*
* @since Brendah 1.0.0
*
* @return string 'Continue reading' link prepended with an ellipsis.
*/
function brendah_excerpt_more( $link ) {
if ( is_admin() ) {
return $link;
}
$link = sprintf( '%2$s
',
esc_url( get_permalink( get_the_ID() ) ),
/* translators: %s: Name of current post */
sprintf( __( 'Continue reading "%s" ', 'brendah' ), get_the_title( get_the_ID() ) )
);
return ' … ' . $link;
}
add_filter( 'excerpt_more', 'brendah_excerpt_more' );
/**
* Enques stylesheets and script files.
*
* @link https://developer.wordpress.org/reference/functions/register_sidebar/
*
* @since Brendah 1.0.0
*/
function brendah_scripts() {
//Google fonts
wp_enqueue_style( 'brendah-fonts', 'https://fonts.googleapis.com/css?family=Montserrat&display=swap' );
// Main theme stylesheet.
wp_enqueue_style( 'brendah-style', get_stylesheet_uri(), array(), '1.0.5' );
// Load the html5 shiv.
wp_enqueue_script( 'brendah-html5', get_template_directory_uri() . '/js/html5.min.js', array(), '3.7.3' );
wp_script_add_data( 'brendah-html5', 'conditional', 'lt IE 9' );
/*
* Main theme javascript file
* Contains the skip link focus fix; etc
*/
wp_enqueue_script( 'brendah-script', get_template_directory_uri() . '/js/brendah.js', array('jquery'), '1.0.5', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'brendah_scripts' );
if ( ! function_exists( 'brendah_post_thumbnail' ) ) :
/**
* Displays an optional post thumbnail.
*
* Wraps the post thumbnail in an anchor element on index views, or a div
* element when on single views.
*
*/
function brendah_post_thumbnail() {
if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
return;
}
if ( is_singular() ) :
?>
the_title_attribute( 'echo=0' ) ) ); ?>
%1$s%2$s %4$s ',
get_avatar( get_the_author_meta( 'user_email' ), $author_avatar_size ),
_x( 'Author', 'Used before post author name.', 'brendah' ),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
get_the_author()
);
}
//The date
if ( in_array( get_post_type(), array( 'post', 'attachment' ) ) ) {
brendah_entry_date();
}
if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
echo ' | ';
}
}
endif;
if ( ! function_exists( 'brendah_entry_date' ) ) :
/**
* Prints HTML with date information for current post.
*
* Create your own brendah_entry_date() function to override in a child theme.
*
* @since Brendah 1.0
*/
function brendah_entry_date() {
$time_string = '%2$s ';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '%2$s %4$s ';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
get_the_date(),
esc_attr( get_the_modified_date( 'c' ) ),
get_the_modified_date()
);
printf( ' | %1$s %3$s ',
_x( 'Posted on', 'Used before publish date.', 'brendah' ),
esc_url( get_permalink() ),
$time_string
);
}
endif;
/**
* Adds custom classes to the array of body classes.
*
*/
function brendah_body_classes( $classes ) {
// Adds a class of no-sidebar to sites without active sidebar or the chosen sidebar position.
if ( ! is_active_sidebar( 'sidebar-1' )) {
$classes[] = 'no-sidebar';
} else {
$classes[] = get_theme_mod( 'sidebar', 'right-sidebar' );
}
return $classes;
}
add_filter( 'body_class', 'brendah_body_classes' );
/**
* Filters the ajax live search template file
*
*/
function brendah_ajax_live_search_template( $template ) {
return '/template-parts/content-search.php';
}
add_filter( 'ajax-live-search-template', 'brendah_ajax_live_search_template' );
/**
* Add woocommerce support
*
*/
remove_action('woocommerce_before_main_content', 'woocommerce_output_content_wrapper',10);
remove_action('woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end',10);
add_action('woocommerce_before_main_content', 'brendah_woocommerce_output_content_wrapper', 10);
add_action('woocommerce_after_main_content', 'brendah_woocommerce_output_content_wrapper_end', 10);
function brendah_woocommerce_output_content_wrapper() {
?>
'',
'success' => 1,
'status' => __( 'Your comment has been sent for moderation. It should be approved soon!', 'brendah' )
);
wp_send_json( $return );
break;
case '1':
// Approved comment; generate comment output and notify post author.
$comment = get_comment( $comment_ID );
$comment_class = comment_class( 'brendah-ajax-comment', $comment_ID, $comment->comment_post_ID, false );
$comment_output = '
';
if ( $comment->comment_parent == 0 ) {
$output = $comment_output;
} else {
$output = "";
}
wp_notify_postauthor( $comment_ID );
$return = array(
'response'=>$output ,
'success' => 1,
'status'=> sprintf( __( 'Thanks for commenting! Your comment has been approved. Read your comment ', 'brendah' ), "#comment-$comment_ID" )
);
wp_send_json( $return );
break;
default:
// The comment status was not a valid value. Only 0 or 1 should be returned by the comment_post action.
$return = array(
'response' => '',
'success' => 0,
'status' => __( 'There was an error posting your comment. Try again later!', 'brendah' )
);
wp_send_json( $return );
}
}
}
/**
* Register the recommended plugins for this theme.
*
*/
function brendah_register_required_plugins() {
/*
* Array of plugin arrays. Required keys are name and slug.
* If the source is NOT from the .org repo, then source is also required.
*/
$plugins = array(
array(
'name' => 'Noptin — Newsletter Subscribe Forms And Widgets',
'slug' => 'newsletter-optin-box',
'required' => false,
),
);
/*
* Array of configuration settings.
*/
$config = array(
'id' => 'brendah', // Unique ID for hashing notices for multiple instances of TGMPA.
'default_path' => '', // Default absolute path to bundled plugins.
'menu' => 'tgmpa-install-plugins', // Menu slug.
'has_notices' => true, // Show admin notices or not.
'dismissable' => true, // If false, a user cannot dismiss the nag message.
'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
'is_automatic' => false, // Automatically activate plugins after installation or not.
'message' => '', // Message to output right before the plugins table.
);
tgmpa( $plugins, $config );
}
add_action( 'tgmpa_register', 'brendah_register_required_plugins' );
//tgmpa
require_once('inc/class-tgm-plugin-activation.php');
//Customizer settings
require_once('inc/customizer.php');
//Welcome page
require_once('inc/admin.php');