Skip to content

Instantly share code, notes, and snippets.

@Mario-Duarte
Created January 29, 2019 23:17
Show Gist options
  • Save Mario-Duarte/7d5fc9fcd041638b15ae5a333e8c93df to your computer and use it in GitHub Desktop.
Save Mario-Duarte/7d5fc9fcd041638b15ae5a333e8c93df to your computer and use it in GitHub Desktop.

Revisions

  1. Mario-Duarte created this gist Jan 29, 2019.
    98 changes: 98 additions & 0 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,98 @@
    <?php

    function wpEnqueueScripts(){

    // Register styles
    wp_enqueue_style("style.css", get_stylesheet_directory_uri() . "/css/style.css");

    // Unregister wordpress vertion of jquery and add our Latest version
    wp_deregister_script( 'jquery' );
    wp_enqueue_script("jquery", get_stylesheet_directory_uri() . "/js/vendor/jquery.min.js");

    //Adds the main js
    wp_enqueue_script('main', get_template_directory_uri(). '/js/main.js', array('jquery','handlebars'));

    }
    add_action('wp_enqueue_scripts', 'wpEnqueueScripts');


    // Hides Admin bar on the site
    add_filter('show_admin_bar', '__return_false');

    // Remove version info from head and feeds
    function complete_version_removal() {
    return '';
    }
    add_filter('the_generator', 'complete_version_removal');

    // Change length of exerpts
    function new_excerpt_length($length) {
    return 120;
    }
    add_filter('excerpt_length', 'new_excerpt_length');

    // remove unnecessary header info
    add_action( 'init', 'remove_header_info' );
    function remove_header_info() {
    remove_action( 'wp_head', 'rsd_link' );
    remove_action( 'wp_head', 'wlwmanifest_link' );
    remove_action( 'wp_head', 'wp_generator' );
    remove_action( 'wp_head', 'start_post_rel_link' );
    remove_action( 'wp_head', 'index_rel_link' );
    remove_action( 'wp_head', 'adjacent_posts_rel_link' ); // for WordPress < 3.0
    remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' ); // for WordPress >= 3.0
    }

    // remove extra CSS that 'Recent Comments' widget injects
    add_action( 'widgets_init', 'remove_recent_comments_style' );
    function remove_recent_comments_style() {
    global $wp_widget_factory;
    remove_action( 'wp_head', array(
    $wp_widget_factory->widgets['WP_Widget_Recent_Comments'],
    'recent_comments_style'
    ) );
    }

    // Removes the [...] from the excertps
    function new_excerpt_more( $more ) {
    return '.';
    }
    add_filter('excerpt_more', 'new_excerpt_more');

    // add menu support
    add_theme_support('menus');
    // add widget support
    add_theme_support('widgets');
    // add featured image support
    add_theme_support('post-thumbnails');

    // Register man nav menu
    register_nav_menus( array(
    'header_menu' => __('Main Navigation'),
    'footer_menu' => __('Footer Navigation')
    ) );

    // Registers Widgets
    function upchurch_widgets_init() {
    register_sidebar( array(
    'name' => 'Footer copy info',
    'id' => 'footer_copy_info',
    'before_widget' => '',
    'after_widget' => '',
    'before_title' => '<h4>',
    'after_title' => '</h4>',
    ));
    }
    add_action('widgets_init', 'upchurch_widgets_init');

    // Adds Support to SVG in Media
    function cc_mime_types($mimes) {
    $mimes['svg'] = 'image/svg+xml';
    return $mimes;
    }
    add_filter('upload_mimes', 'cc_mime_types');

    // disable auto clean up on the wysiwyg
    remove_filter( 'the_content', 'wpautop' );

    ?>