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' => '', 'before_title' => '