Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Register Nav Walker class_alias
- require_once('wp_bootstrap_navwalker.php');
- // Theme Support
- function syau_theme_setup () {
- // Add Featured Image Support
- add_theme_support('post-thumbnails');
- // Nav Menus
- register_nav_menus(array (
- 'primary' => __('Main Menu'),
- 'hamburger' => __('Mobile Menu'),
- 'footer' => __('Footer Menu')
- ));
- // 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',
- ) );
- //Enable support for Post Formats
- add_theme_support( 'post-formats', array(
- 'aside',
- 'image',
- 'video',
- 'quote',
- 'link',
- ) );
- // Set up the WordPress core custom background feature.
- add_theme_support( 'custom-background', apply_filters( 'darren_bachan_custom_background_args', array(
- 'default-color' => 'ffffff',
- 'default-image' => '',
- ) ) );
- }
- add_action('after_setup_theme', 'syau_theme_setup');
- //Add Our Widget Locations
- function ourWidgetsInit () {
- register_sidebar( array(
- 'name' => esc_html__( 'Sidebar', 'darren-bachan' ),
- 'id' => 'sidebar-1',
- 'description' => esc_html__( 'Add widgets here.', 'darren-bachan' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => 'Footer Area 1',
- 'id' => 'footer1'
- ));
- }
- add_action('widgets_init', 'ourWidgetsInit');
- // Enqueue Scripts & Styles
- function syau_theme_scripts() {
- // Deregister the included library
- wp_deregister_script( 'jquery' );
- // Register the library again
- wp_register_script( 'jquery', get_template_directory_uri() . "/js/jquery-2.2.2.min.js", array(), '' , true );
- wp_enqueue_script('jquery');
- wp_enqueue_script( 'typed', get_template_directory_uri() . "/js/typed.min.js", array(), '' , true );
- wp_enqueue_script( 'owl-carousel', get_template_directory_uri() . "/js/owl.carousel.min.js", array(), '' , true );
- wp_enqueue_script( 'bootstrap', get_template_directory_uri() . "/js/bootstrap.min.js", array(), '' , true );
- wp_enqueue_script( 'animation-scroll', get_template_directory_uri() . "/js/animatescroll.js", array(), '' , true );
- wp_enqueue_script( 'animation-slide', get_template_directory_uri() . "/js/animation-slide.js", array(), '' , true );
- wp_enqueue_script( 'main-js', get_template_directory_uri() . "/js/main.js", array(), '' , true );
- wp_enqueue_style( 'bootstrap', get_template_directory_uri()."/css/bootstrap.css", '', '' );
- wp_enqueue_style( 'fonts', get_template_directory_uri()."/css/fonts.css", '', '' );
- wp_enqueue_style( 'font-awesome', get_template_directory_uri()."/css/font-awesome.css", '', '' );
- wp_enqueue_style( 'flag-icon', get_template_directory_uri()."/css/flag-icon.css", '', '' );
- wp_enqueue_style( 'hamburger', get_template_directory_uri()."/css/hamburger.css", '', '' );
- wp_enqueue_style( 'owl-carousel', get_template_directory_uri()."/css/owl.carousel.css", '', '' );
- wp_enqueue_style( 'owl-theme', get_template_directory_uri()."/css/owl.theme.default.min.css", '', '' );
- wp_enqueue_style( 'main-css', get_template_directory_uri()."/style.css", '', '' );
- if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
- wp_enqueue_script( 'comment-reply' );
- }
- }
- add_action( 'wp_enqueue_scripts', 'syau_theme_scripts' );
- // Customizer File
- require get_template_directory(). '/inc/customizer.php';
- // Grab First Paragraph Of Text And Ignore Images For Excerpt
- function awesome_excerpt($text, $raw_excerpt) {
- if( ! $raw_excerpt ) {
- $content = apply_filters( 'the_content', get_the_content() );
- $text = substr( $content, 0, strpos( $content, '</p>' ) + 4 );
- }
- $text = preg_replace("/<img[^>]+\>/i", "", $text);
- return $text;
- }
- add_filter( 'wp_trim_excerpt', 'awesome_excerpt', 10, 2 );
- // Empty <p> Fix On Images
- function filter_ptags_on_images($content){
- return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
- }
- add_filter('the_content', 'filter_ptags_on_images');
- // Change Author Permalinks
- function change_author_permalinks() {
- global $wp_rewrite;
- $wp_rewrite->author_base = 'member';
- $wp_rewrite->author_structure = '/' . $wp_rewrite->author_base. '/%author%';
- }
- add_action('init','change_author_permalinks');
- // Custom Comments Styling
- function mytheme_comment($comment, $args, $depth) {
- if ( 'div' === $args['style'] ) {
- $tag = 'div';
- $add_below = 'comment';
- } else {
- $tag = 'li';
- $add_below = 'div-comment';
- }
- ?>
- <<?php echo $tag ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">
- <?php if ( 'div' != $args['style'] ) : ?>
- <div id="div-comment-<?php comment_ID() ?>" class="comment-body">
- <?php endif; ?>
- <div class="comment-author vcard">
- <?php if ( $args['avatar_size'] != 0 ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
- <?php printf( __( '<cite class="fn">%s</cite> <span class="says">says:</span>' ), get_comment_author_link() ); ?>
- </div>
- <?php if ( $comment->comment_approved == '0' ) : ?>
- <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></em>
- <br />
- <?php endif; ?>
- <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>">
- <?php
- /* translators: 1: date, 2: time */
- printf( __('%1$s at %2$s'), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)' ), ' ', '' );
- ?>
- </div>
- <?php comment_text(); ?>
- <div class="reply">
- <?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
- </div>
- <?php if ( 'div' != $args['style'] ) : ?>
- </div>
- <?php endif; ?>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement