Advertisement
darrenbachan

Untitled

Jun 3rd, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.33 KB | None | 0 0
  1. <?php
  2.     // Register Nav Walker class_alias
  3.     require_once('wp_bootstrap_navwalker.php');
  4.  
  5.     // Theme Support
  6.     function syau_theme_setup () {
  7.         // Add Featured Image Support
  8.         add_theme_support('post-thumbnails');
  9.  
  10.         // Nav Menus
  11.         register_nav_menus(array (
  12.             'primary' => __('Main Menu'),
  13.             'hamburger' => __('Mobile Menu'),
  14.             'footer' => __('Footer Menu')
  15.         ));
  16.  
  17.         // Switch default core markup for search form, comment form, and comments to output valid HTML5
  18.         add_theme_support( 'html5', array(
  19.             'search-form',
  20.             'comment-form',
  21.             'comment-list',
  22.             'gallery',
  23.             'caption',
  24.         ) );
  25.  
  26.         //Enable support for Post Formats
  27.         add_theme_support( 'post-formats', array(
  28.             'aside',
  29.             'image',
  30.             'video',
  31.             'quote',
  32.             'link',
  33.         ) );
  34.  
  35.         // Set up the WordPress core custom background feature.
  36.         add_theme_support( 'custom-background', apply_filters( 'darren_bachan_custom_background_args', array(
  37.             'default-color' => 'ffffff',
  38.             'default-image' => '',
  39.         ) ) );
  40.     }
  41.  
  42.     add_action('after_setup_theme', 'syau_theme_setup');
  43.  
  44.     //Add Our Widget Locations
  45.     function ourWidgetsInit () {
  46.  
  47.         register_sidebar( array(
  48.             'name'          => esc_html__( 'Sidebar', 'darren-bachan' ),
  49.             'id'            => 'sidebar-1',
  50.             'description'   => esc_html__( 'Add widgets here.', 'darren-bachan' ),
  51.             'before_widget' => '<section id="%1$s" class="widget %2$s">',
  52.             'after_widget'  => '</section>',
  53.             'before_title'  => '<h3 class="widget-title">',
  54.             'after_title'   => '</h3>',
  55.         ) );
  56.  
  57.         register_sidebar( array(
  58.             'name' => 'Footer Area 1',
  59.             'id' => 'footer1'
  60.         ));
  61.  
  62.     }
  63.  
  64.     add_action('widgets_init', 'ourWidgetsInit');
  65.  
  66.     // Enqueue Scripts & Styles
  67.     function syau_theme_scripts() {
  68.  
  69.         // Deregister the included library
  70.         wp_deregister_script( 'jquery' );
  71.          
  72.         // Register the library again
  73.         wp_register_script( 'jquery', get_template_directory_uri() . "/js/jquery-2.2.2.min.js", array(), '' , true );
  74.         wp_enqueue_script('jquery');
  75.  
  76.         wp_enqueue_script( 'typed', get_template_directory_uri() . "/js/typed.min.js", array(), '' , true );
  77.         wp_enqueue_script( 'owl-carousel', get_template_directory_uri() . "/js/owl.carousel.min.js", array(), '' , true );
  78.         wp_enqueue_script( 'bootstrap', get_template_directory_uri() . "/js/bootstrap.min.js", array(), '' , true );
  79.         wp_enqueue_script( 'animation-scroll', get_template_directory_uri() . "/js/animatescroll.js", array(), '' , true );
  80.         wp_enqueue_script( 'animation-slide', get_template_directory_uri() . "/js/animation-slide.js", array(), '' , true );
  81.         wp_enqueue_script( 'main-js', get_template_directory_uri() . "/js/main.js", array(), '' , true );
  82.  
  83.         wp_enqueue_style( 'bootstrap', get_template_directory_uri()."/css/bootstrap.css", '', '' );
  84.         wp_enqueue_style( 'fonts', get_template_directory_uri()."/css/fonts.css", '', '' );
  85.         wp_enqueue_style( 'font-awesome', get_template_directory_uri()."/css/font-awesome.css", '', '' );
  86.         wp_enqueue_style( 'flag-icon', get_template_directory_uri()."/css/flag-icon.css", '', '' );
  87.         wp_enqueue_style( 'hamburger', get_template_directory_uri()."/css/hamburger.css", '', '' );
  88.         wp_enqueue_style( 'owl-carousel', get_template_directory_uri()."/css/owl.carousel.css", '', '' );
  89.         wp_enqueue_style( 'owl-theme', get_template_directory_uri()."/css/owl.theme.default.min.css", '', '' );
  90.         wp_enqueue_style( 'main-css', get_template_directory_uri()."/style.css", '', '' );
  91.  
  92.         if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  93.             wp_enqueue_script( 'comment-reply' );
  94.         }
  95.     }
  96.  
  97.     add_action( 'wp_enqueue_scripts', 'syau_theme_scripts' );
  98.  
  99.     // Customizer File
  100.     require get_template_directory(). '/inc/customizer.php';
  101.  
  102.     // Grab First Paragraph Of Text And Ignore Images For Excerpt
  103.     function awesome_excerpt($text, $raw_excerpt) {
  104.         if( ! $raw_excerpt ) {
  105.             $content = apply_filters( 'the_content', get_the_content() );
  106.             $text = substr( $content, 0, strpos( $content, '</p>' ) + 4 );
  107.         }
  108.         $text = preg_replace("/<img[^>]+\>/i", "", $text);
  109.         return $text;
  110.     }
  111.     add_filter( 'wp_trim_excerpt', 'awesome_excerpt', 10, 2 );
  112.  
  113.     // Empty <p> Fix On Images
  114.     function filter_ptags_on_images($content){
  115.        return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
  116.     }
  117.  
  118.     add_filter('the_content', 'filter_ptags_on_images');
  119.  
  120.     // Change Author Permalinks
  121.     function change_author_permalinks() {
  122.         global $wp_rewrite;
  123.         $wp_rewrite->author_base = 'member';
  124.         $wp_rewrite->author_structure = '/' . $wp_rewrite->author_base. '/%author%';
  125.     }
  126.     add_action('init','change_author_permalinks');
  127.  
  128.     // Custom Comments Styling
  129.     function mytheme_comment($comment, $args, $depth) {
  130.         if ( 'div' === $args['style'] ) {
  131.             $tag       = 'div';
  132.             $add_below = 'comment';
  133.         } else {
  134.             $tag       = 'li';
  135.             $add_below = 'div-comment';
  136.         }
  137.         ?>
  138.         <<?php echo $tag ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">
  139.         <?php if ( 'div' != $args['style'] ) : ?>
  140.             <div id="div-comment-<?php comment_ID() ?>" class="comment-body">
  141.         <?php endif; ?>
  142.         <div class="comment-author vcard">
  143.             <?php if ( $args['avatar_size'] != 0 ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
  144.             <?php printf( __( '<cite class="fn">%s</cite> <span class="says">says:</span>' ), get_comment_author_link() ); ?>
  145.         </div>
  146.         <?php if ( $comment->comment_approved == '0' ) : ?>
  147.              <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></em>
  148.               <br />
  149.         <?php endif; ?>
  150.  
  151.         <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>">
  152.             <?php
  153.             /* translators: 1: date, 2: time */
  154.             printf( __('%1$s at %2$s'), get_comment_date(),  get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)' ), '  ', '' );
  155.             ?>
  156.         </div>
  157.  
  158.         <?php comment_text(); ?>
  159.  
  160.         <div class="reply">
  161.             <?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  162.         </div>
  163.         <?php if ( 'div' != $args['style'] ) : ?>
  164.         </div>
  165.         <?php endif; ?>
  166.         <?php
  167.         }
  168.  
  169. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement