Here’s my functions.php:
<?php
// This will bring in the Genesis Parent files needed:
require_once( TEMPLATEPATH . '/lib/init.php' );
// Setup Child Theme
define( 'Child_Theme_Name', __( 'Shell Global', 'shellglobal' ) );
define( 'Child_Theme_Url', 'localhost' );
define( 'Child_Theme_Version', '1.0' );
// Add HTML5 markup structure from parent Genesis framework
add_theme_support( 'html5' );
// Add HTML5 responsive recognition from parent Genesis framework
add_theme_support( 'genesis-responsive-viewport' );
// Include jQuery script when building pages
if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 1);
function my_jquery_enqueue() {
wp_deregister_script('jquery');
wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js", false, null);
wp_enqueue_script('jquery');
}
// This will bring the CSS across from parent Genesis theme:
add_action( 'wp_enqueue_scripts', 'my_child_theme_scripts', 2 );
function my_child_theme_scripts() {
wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' );
wp_enqueue_script( 'global-js', get_stylesheet_directory_uri() . '/global.js');
if (is_page_template( 'login-page.php' )) {
wp_enqueue_style( 'custom-login-css', get_stylesheet_directory_uri() . '/custom-login.css');
wp_enqueue_script( 'custom-login-js', get_stylesheet_directory_uri() . '/custom-login.js');
}
}
// Remove the wp-admin bar at top of browser when logged in for everyone on all pages
show_admin_bar(false);
// Remove the Genesis site header on all pages
remove_action( 'genesis_header', 'genesis_header_markup_open', 5 );
remove_action( 'genesis_header', 'genesis_do_header' );
remove_action( 'genesis_header', 'genesis_header_markup_close', 15 );
// Remove the Genesis site Footer on all pages
remove_action('genesis_footer', 'genesis_do_footer');
remove_action('genesis_footer', 'genesis_footer_markup_open', 5);
remove_action('genesis_footer', 'genesis_footer_markup_close', 15);
/*
The below restricts access to the WordPress Admin Area to
only users who we want to be there. When logging to wp-login.php this
code will check if the user is an administrator and if they are not WordPress
will redirect them back to the website home page. */
function restrict_admin()
{
if ( ! current_user_can( 'manage_options' ) && '/wp-admin/admin-ajax.php' != $_SERVER['PHP_SELF'] ) {
wp_redirect( site_url() );
}
}
add_action( 'admin_init', 'restrict_admin', 1 );
?>