Name ); define( 'C_VERSION', $theme_data->Version ); define( 'C_ROOT', get_template_directory_uri() ); define( 'C_CORE', get_template_directory_uri().'/core' ); /** * Activation */ add_action( 'after_switch_theme', 'broadwell_activate' ); function broadwell_activate() { If ( is_admin() ) { /* Set an activation flag to trigger one-time setup tasks. */ if ( !get_option( 'broadwell_status' ) ) { update_option( 'broadwell_status', 'First Run' ); } else { update_option( 'broadwell_status', 'Reactivation' ); } /* Carry out one-time setup tasks. */ If ( 'First Run'===get_option( 'broadwell_status' ) OR 'Reactivation'===get_option( 'broadwell_status' ) ) { /* Show Pointer to Customize Menu */ add_action( 'admin_enqueue_scripts', 'broadwell_enqueue_pointer_script_style' ); /* Initialize theme settings if they don't already exist */ if ( 'First Run'===get_option( 'broadwell_status' ) OR !get_option( 'theme_mods_broadwell' ) ) { broadwell_initialize_settings(); } /* Set specific pages for Front Page and Blog */ $front_page = C_NAME.' - Front Page'; $blog_home = C_NAME.' - Blog Home'; if( !get_page_by_title( $blog_home ) ) { wp_insert_post( array( 'post_name' => 'blog', 'post_title' => $blog_home, 'post_status' => 'publish', 'post_type' => 'page', 'post_content' => 'Do not delete this page while '.C_NAME.' is the active theme.', ) ); } if( !get_page_by_title( $front_page ) ) { wp_insert_post( array( 'post_name' => 'front', 'post_title' => $front_page, 'post_status' => 'publish', 'post_type' => 'page', 'post_content' => 'Do not delete this page while '.C_NAME.' is the active theme.', ) ); } update_option ( 'show_on_front', 'page' ); /* Just a placeholder for the admin screen since the theme has a front-page.php template. */ $homepage = get_page_by_title( $front_page ); update_option ( 'page_on_front', $homepage->ID ); $blog = get_page_by_title( $blog_home ); update_option( 'page_for_posts', $blog->ID ); } /* Unset the flag now that one-time setup tasks are done */ update_option( 'broadwell_status', 'Activated' ); } } /** * Theme Setup */ add_action( 'after_setup_theme', 'broadwell_setup', 10 ); if ( ! function_exists( 'broadwell_setup' ) ) { function broadwell_setup() { /* Load TextDomain at theme level. */ load_theme_textdomain( 'broadwell', C_ROOT. '/languages' ); /* Add default posts and comments RSS feed links to head. */ add_theme_support( 'automatic-feed-links' ); /* Let Wordpress handle the title tag */ add_theme_support( 'title-tag' ); /* * Enable support for Post Thumbnails on posts and pages. * * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails */ add_theme_support( 'post-thumbnails' ); /* * 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. * See http://codex.wordpress.org/Post_Formats */ add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link', ) ); /* * Apply theme styles to the editor */ add_editor_style( C_ROOT.'/css/editor-style.css' ); } } /** * Sidebar & Footer Widget */ add_action( 'widgets_init', 'broadwell_widgets_init' ); function broadwell_widgets_init() { register_sidebar(array( 'name' => __('Main Sidebar', 'broadwell' ), 'description' => __('Only visible on posts and pages', 'broadwell' ), 'id' => 'sidebar-1', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '' ) ); register_sidebar(array( 'name' => __('Footer Widget', 'broadwell' ), 'description' => __('The right column in the site footer.', 'broadwell' ), 'id' => 'footer-widget', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '' ) ); } /** * Styles & Scripts */ add_action( 'wp_enqueue_scripts', 'broadwell_scripts' ); function broadwell_scripts() { /* CSS */ wp_enqueue_style( 'broadwell-roboto', '//fonts.googleapis.com/css?family=Roboto:400,700' ); wp_enqueue_style( 'broadwell-ssp', '//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700' ); wp_enqueue_style( 'broadwell-mdi-icons', C_ROOT . '/material-design/css/material-design-iconic-font.min.css' ); wp_enqueue_style( 'broadwell-style', get_stylesheet_uri() ); wp_enqueue_style( 'broadwell-dynamic', C_ROOT . '/css/dynamic.css' ); /* JS */ wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'broadwell-head', C_ROOT . '/js/head.min.js', null, null, true ); wp_enqueue_script( 'bootstrap-js', C_ROOT . '/bootstrap/js/bootstrap.min.js', array( 'jquery' ), 'v3.3.5', true ); wp_enqueue_script( 'broadwell-scripts', C_ROOT . '/js/broadwell.js',array( 'jquery' ), null, true ); wp_enqueue_script( 'broadwell-navigation', C_ROOT . '/js/navigation.js', array(), '20120206', true ); wp_enqueue_script( 'broadwell-skip-link-focus-fix', C_ROOT . '/js/skip-link-focus-fix.js', array(), '20130115', true ); wp_enqueue_script( 'broadwell-succint', C_ROOT . '/js/succinct.min.js',array( 'jquery' ), null, true ); wp_enqueue_script( 'broadwell-center', C_ROOT . '/js/flex-center.js',array( 'jquery' ), null, true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } /** * Includes from Underscores */ /* Custom template tags for this theme. */ require get_template_directory() . '/inc/template-tags.php'; /* Custom functions that act independently of the theme templates.*/ require get_template_directory() . '/inc/extras.php'; /* Load Jetpack compatibility file. */ require get_template_directory() . '/inc/jetpack.php'; /** * Includes specific to the theme */ /* Bootstrap integration */ require get_template_directory() . '/inc/functions-strap.php'; /* Theme Settings */ require get_template_directory() . '/core/broadwell-settings.php'; /* Theme Functions */ require get_template_directory() . '/core/broadwell-functions.php'; /** * Deactivation */ add_action( 'switch_theme', 'broadwell_deactivate' ); function broadwell_deactivate() { update_option( 'broadwell_status','Deactivated' ); }