Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Frontier Theme Setup & Functions.
- * @package Frontier
- *
- */
- $frontier_version = "1.0.6";
- /*-------------------------------------
- Setup Theme Options
- --------------------------------------*/
- if ( !function_exists( 'optionsframework_init' ) ) {
- define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/includes/options-framework/' );
- require_once dirname( __FILE__ ) . '/includes/options-framework/options-framework.php';
- }
- /*-------------------------------------
- Register Styles & Scripts
- --------------------------------------*/
- function frontier_enqueue_styles() {
- global $frontier_version;
- $protocol = is_ssl() ? 'https' : 'http';
- wp_enqueue_style( 'frontier-font', $protocol . '://fonts.googleapis.com/css?family=Roboto+Condensed|Varela', array(), null );
- wp_enqueue_style( 'frontier-icon', get_template_directory_uri() . '/includes/genericons/genericons.css', array() );
- wp_enqueue_style( 'frontier-main', get_stylesheet_uri(), array(), $frontier_version );
- if ( frontier_option('responsive_disable', 0) != 1 ) wp_enqueue_style( 'frontier-responsive', get_template_directory_uri() . '/responsive.css', array(), $frontier_version );
- if ( frontier_option('slider_enable') == 1 ) wp_enqueue_script( 'basic-slider', get_template_directory_uri() . '/includes/slider/bjqs-1.3.min.js', array( 'jquery' ), '0', true );
- if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' );
- }
- add_action( 'wp_enqueue_scripts', 'frontier_enqueue_styles' );
- /*-------------------------------------
- Frontier Theme Setup
- --------------------------------------*/
- function frontier_theme_setup() {
- global $content_width, $frontier_container, $frontier_header,
- $frontier_content, $frontier_side_left, $frontier_side_right;
- // Get needed values for layout
- frontier_get_layout_values();
- load_theme_textdomain( 'frontier', get_template_directory() . '/languages' );
- register_nav_menu( 'frontier-menu-top', __( 'Top Bar', 'frontier' ) );
- register_nav_menu( 'frontier-menu-primary', __( 'Primary', 'frontier' ) );
- add_theme_support( 'automatic-feed-links' );
- add_theme_support( 'custom-background', array(
- 'default-color' => '505050',
- 'default-image' => get_template_directory_uri() . '/images/honeycomb.png',
- ) );
- add_theme_support( 'custom-header', array(
- 'default-image' => '',
- 'random-default' => false,
- 'width' => $frontier_container,
- 'height' => $frontier_header,
- 'flex-height' => true,
- 'flex-width' => true,
- 'header-text' => false,
- 'uploads' => true,
- ) );
- add_theme_support( 'post-thumbnails' );
- add_image_size( 'thumb-200x120', 200, 120, true );
- add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list' ) );
- // Set $content_width + allowance for default border & padding
- if ( !isset( $content_width ) ) $content_width = ( frontier_option('content_width', 612) - 42 );
- // Print CSS for layout
- add_action( 'wp_head', 'frontier_print_layout' );
- add_action( 'wp_head', 'frontier_print_layout_page' );
- // Print CSS for header image
- if ( !( get_header_image() == '' ) ) add_action( 'wp_head', 'frontier_header_image' );
- // Print CSS for colors
- if ( frontier_option('colors_enable') == 1 ) add_action( 'wp_head', 'frontier_custom_colors' );
- // Print Custom CSS if available
- if ( frontier_option('custom_css') ) add_action( 'wp_head', 'frontier_print_custom_css', 990 );
- if ( frontier_option('favicon') ) add_action( 'wp_head', 'frontier_favicon' );
- if ( frontier_option('head_codes') ) add_action( 'wp_head', 'frontier_head_codes' );
- if ( frontier_option('footer_codes') ) add_action( 'wp_footer', 'frontier_footer_codes' );
- if ( frontier_option('editor_style_disable') != 1 ) frontier_editor_style();
- if ( frontier_option('slider_enable') == 1 ) {
- add_action( 'wp_footer', 'frontier_slider_script', 20 );
- if ( frontier_option('slider_stretch') == 'stretch' ) add_action( 'wp_head', 'frontier_slider_stretch' );
- }
- }
- add_action( 'after_setup_theme', 'frontier_theme_setup' );
- /*-------------------------------------
- Set Default Title
- --------------------------------------*/
- function frontier_wp_title( $title, $sep ) {
- global $paged, $page;
- if ( is_feed() )
- return $title;
- $title .= get_bloginfo( 'name' );
- $site_description = get_bloginfo( 'description', 'display' );
- if ( $site_description && ( is_home() || is_front_page() ) )
- $title = "$title $sep $site_description";
- if ( $paged >= 2 || $page >= 2 )
- $title = "$title $sep " . sprintf( __( 'Page %s', 'frontier' ), max( $paged, $page ) );
- return $title;
- }
- add_filter( 'wp_title', 'frontier_wp_title', 10, 2 );
- /*----------------------------------------
- Add Class to Parent Menu Items
- -----------------------------------------*/
- function frontier_menu_class( $items ) {
- $parents = array();
- foreach ( $items as $item ) {
- if ( $item->menu_item_parent && $item->menu_item_parent > 0 ) $parents[] = $item->menu_item_parent;
- }
- foreach ( $items as $item ) {
- if ( in_array( $item->ID, $parents ) ) $item->classes[] = 'parent-menu-item';
- }
- return $items;
- }
- add_filter( 'wp_nav_menu_objects', 'frontier_menu_class' );
- function frontier_page_menu_class( $css_class, $page, $depth, $args ) {
- if (!empty($args['has_children']))
- $css_class[] = 'parent-menu-item';
- return $css_class;
- }
- add_filter( 'page_css_class', 'frontier_page_menu_class', 10, 4 );
- /*----------------------------------------
- Custom Entries to the Admin Bar
- -----------------------------------------*/
- function frontier_admin_bar_menu() {
- if ( current_user_can( 'edit_theme_options' ) ) {
- global $wp_admin_bar;
- $wp_admin_bar->add_menu( array(
- 'parent' => false,
- 'id' => 'frontier_admin_bar',
- 'title' => __('Frontier Options', 'frontier'),
- 'href' => admin_url( 'themes.php?page=options-framework')
- ));
- $wp_admin_bar->add_menu( array(
- 'parent' => 'appearance',
- 'id' => 'theme_editor_admin_bar',
- 'title' => __('Editor', 'frontier'),
- 'href' => admin_url( 'theme-editor.php')
- ));
- $wp_admin_bar->add_menu( array(
- 'parent' => 'appearance',
- 'id' => 'plugins_admin_bar',
- 'title' => __('Plugins', 'frontier'),
- 'href' => admin_url( 'plugins.php')
- ));
- }
- }
- add_action( 'admin_bar_menu', 'frontier_admin_bar_menu', 88 );
- /*----------------------------------------
- Register Sidebars
- -----------------------------------------*/
- function frontier_register_sidebars() {
- switch ( frontier_option('column_layout', 'col-cs') ) {
- case 'col-c' :
- frontier_register_sidebars_extra();
- break;
- case 'col-sc' :
- register_sidebar(array(
- 'name' => __('Sidebar Left', 'frontier'),
- 'id' => 'widgets_sidebar_left',
- 'before_widget' => '<div id="%1$s" class="widget-sidebar widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h4 class="widget-title">',
- 'after_title' => '</h4>') );
- frontier_register_sidebars_extra();
- break;
- case 'col-cs' :
- register_sidebar(array(
- 'name' => __('Sidebar Right', 'frontier'),
- 'id' => 'widgets_sidebar_right',
- 'description' => __('The Right Sidebar. The best sidebar a kid could have. Use it wisely.', 'frontier'),
- 'before_widget' => '<div id="%1$s" class="widget-sidebar widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h4 class="widget-title">',
- 'after_title' => '</h4>') );
- frontier_register_sidebars_extra();
- break;
- case 'col-ssc' :
- case 'col-css' :
- case 'col-scs' :
- register_sidebar(array(
- 'name' => __('Sidebar Left', 'frontier'),
- 'id' => 'widgets_sidebar_left',
- 'before_widget' => '<div id="%1$s" class="widget-sidebar widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h4 class="widget-title">',
- 'after_title' => '</h4>') );
- register_sidebar(array(
- 'name' => __('Sidebar Right', 'frontier'),
- 'id' => 'widgets_sidebar_right',
- 'description' => __('The Right Sidebar. The best sidebar a kid could have ;)', 'frontier'),
- 'before_widget' => '<div id="%1$s" class="widget-sidebar widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h4 class="widget-title">',
- 'after_title' => '</h4>') );
- frontier_register_sidebars_extra();
- break;
- }
- }
- add_action( 'widgets_init', 'frontier_register_sidebars' );
- function frontier_register_sidebars_extra() {
- $widget_areas = frontier_option('widget_areas');
- if ($widget_areas['body'] == 1) {
- register_sidebar(array(
- 'name' => __('Body', 'frontier'),
- 'id' => 'widgets_body',
- 'description' => __('Widgets outside of the container. If used, you\'ll have to position the widgets with css.', 'frontier'),
- 'before_widget' => '<div id="%1$s" class="widget-body widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h4 class="widget-title">',
- 'after_title' => '</h4>') );
- }
- if ($widget_areas['header'] == 1) {
- register_sidebar(array(
- 'name' => __('Header', 'frontier'),
- 'id' => 'widgets_header',
- 'description' => __('Widgets to appear on the header. Ideal for horizontal ads or banners.', 'frontier'),
- 'before_widget' => '<div id="%1$s" class="widget-header widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h4 class="widget-title">',
- 'after_title' => '</h4>') );
- }
- if ($widget_areas['below_menu'] == 1) {
- register_sidebar(array(
- 'name' => __('Below Menu', 'frontier'),
- 'id' => 'widgets_below_menu',
- 'description' => __('Full-width widgets that appear under the main menu. Ideal for horizontal ads or banners.', 'frontier'),
- 'before_widget' => '<div id="%1$s" class="widget-below-menu widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h4 class="widget-title">',
- 'after_title' => '</h4>') );
- }
- if ($widget_areas['before_content'] == 1) {
- register_sidebar(array(
- 'name' => __('Before Content', 'frontier'),
- 'id' => 'widgets_before_content',
- 'before_widget' => '<div id="%1$s" class="widget-before-content widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h4 class="widget-title">',
- 'after_title' => '</h4>') );
- }
- if ($widget_areas['after_content'] == 1) {
- register_sidebar(array(
- 'name' => __('After Content', 'frontier'),
- 'id' => 'widgets_after_content',
- 'before_widget' => '<div id="%1$s" class="widget-after-content widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h4 class="widget-title">',
- 'after_title' => '</h4>') );
- }
- if ($widget_areas['footer'] == 1) {
- register_sidebar(array(
- 'name' => __('Footer', 'frontier'),
- 'id' => 'widgets_footer',
- 'description' => __('Widgets are arranged into 3 columns.', 'frontier'),
- 'before_widget' => '<div id="%1$s" class="widget-footer widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h4 class="widget-title">',
- 'after_title' => '</h4>') );
- }
- if ($widget_areas['post_header'] == 1) {
- register_sidebar(array(
- 'name' => __('Post - Header', 'frontier'),
- 'id' => 'widgets_before_post',
- 'before_widget' => '<div id="%1$s" class="widget-before-post widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h4 class="widget-title">',
- 'after_title' => '</h4>') );
- }
- if ($widget_areas['post_before_content'] == 1) {
- register_sidebar(array(
- 'name' => __('Post - Before Content', 'frontier'),
- 'id' => 'widgets_before_post_content',
- 'before_widget' => '<div id="%1$s" class="widget-before-post-content widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h4 class="widget-title">',
- 'after_title' => '</h4>') );
- }
- if ($widget_areas['post_after_content'] == 1) {
- register_sidebar(array(
- 'name' => __('Post - After Content', 'frontier'),
- 'id' => 'widgets_after_post_content',
- 'before_widget' => '<div id="%1$s" class="widget-after-post-content widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h4 class="widget-title">',
- 'after_title' => '</h4>') );
- }
- if ($widget_areas['post_footer'] == 1) {
- register_sidebar(array(
- 'name' => __('Post - Footer', 'frontier'),
- 'id' => 'widgets_after_post',
- 'before_widget' => '<div id="%1$s" class="widget-after-post widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h4 class="widget-title">',
- 'after_title' => '</h4>') );
- }
- }
- /*-------------------------------------
- Get Layout Values - Theme Setup
- --------------------------------------*/
- function frontier_get_layout_values() {
- global $frontier_container, $frontier_header, $frontier_content,
- $frontier_side_left, $frontier_side_right;
- $frontier_content = frontier_option('content_width', 612);
- $frontier_header = frontier_option('header_height', 140);
- $frontier_side_left = frontier_option('sidebar_width_left', 280);
- $frontier_side_right = frontier_option('sidebar_width_right', 328);
- switch ( frontier_option('column_layout', 'col-cs') ) {
- case 'col-c' :
- $frontier_container = $frontier_content;
- break;
- case 'col-sc' :
- $frontier_container = $frontier_content + $frontier_side_left;
- break;
- case 'col-cs' :
- $frontier_container = $frontier_content + $frontier_side_right;
- break;
- case 'col-ssc' :
- case 'col-css' :
- case 'col-scs' :
- $frontier_container = $frontier_content + $frontier_side_left + $frontier_side_right;
- break;
- }
- }
- /*-------------------------------------
- Layout CSS - Theme Setup
- --------------------------------------*/
- function frontier_print_layout() {
- global $frontier_version, $frontier_container, $frontier_header,
- $frontier_content, $frontier_side_left, $frontier_side_right;
- echo '
- <meta property="Frontier Theme" content="' . $frontier_version . '" />
- <style type="text/css" media="screen">
- #container {width:' . $frontier_container . 'px;}
- #header {min-height:' . $frontier_header . 'px;}
- #content {
- width:' . $frontier_content . 'px;
- max-width:' . $frontier_content . 'px;
- }
- #sidebar-left {
- width:' . $frontier_side_left . 'px;
- max-width:' . $frontier_side_left . 'px;
- }
- #sidebar-right {
- width:' . $frontier_side_right . 'px;
- max-width:' . $frontier_side_right . 'px;
- }
- </style>' . "\n";
- }
- /*-------------------------------------
- Layout CSS for Pages - Theme Setup
- --------------------------------------*/
- function frontier_print_layout_page() {
- global $frontier_container, $frontier_side_left, $frontier_side_right;
- $width_cs = $frontier_container - $frontier_side_right;
- $width_sc = $frontier_container - $frontier_side_left;
- $width_scs = $frontier_container - ($frontier_side_left + $frontier_side_right);
- echo '
- <style type="text/css" media="screen">
- .page-template-page-cs-php #content {width:' . $width_cs . 'px; max-width:' . $width_cs . 'px;}
- .page-template-page-sc-php #content {width:' . $width_sc . 'px; max-width:' . $width_sc . 'px;}
- .page-template-page-scs-php #content {width:' . $width_scs . 'px; max-width:' . $width_scs . 'px;}
- </style>' . "\n\n";
- }
- /*-------------------------------------
- Header BG CSS - Theme Setup
- --------------------------------------*/
- function frontier_header_image() {
- global $frontier_container, $frontier_header;
- echo '
- <style type="text/css" media="screen">
- #header {
- background-image: url(' . get_header_image() . ');
- background-size: ' . $frontier_container . 'px ' . $frontier_header . 'px;
- }</style>' . "\n";
- }
- /*-------------------------------------
- Custom Colors CSS - Theme Setup
- --------------------------------------*/
- function frontier_custom_colors() {
- $colormotif = frontier_option('color_motif');
- $colortopbar = frontier_option('color_top_bar');
- $colorheader = frontier_option('color_header');
- $colormenu = frontier_option('color_menu_main');
- $colorbottombar = frontier_option('color_bottom_bar');
- $colorlinks = frontier_option('color_links');
- $colorlinkshover = frontier_option('color_links_hover');
- echo '<style type="text/css" media="screen">
- #header {background-color:' . $colorheader . ';}
- #menu-main {background-color:' . $colormenu . ';}
- .menu-main {
- border-left: 1px solid ' . frontier_alter_color( $colormenu, -40 ) . ';
- border-right: 1px solid ' . frontier_alter_color( $colormenu, 30 ) . ';
- }
- .menu-main > li, .menu-main > ul > .page_item {
- border-left: 1px solid ' . frontier_alter_color( $colormenu, 30 ) . ';
- border-right: 1px solid ' . frontier_alter_color( $colormenu, -40 ) . ';
- }
- #top-bar {background-color:' . $colortopbar . ';}
- #bottom-bar {background-color:' . $colorbottombar . ';}
- .blog-view, .comment-author-admin .comment-body, .bypostauthor .comment-body {border-top: 6px solid ' . $colormotif . ';}
- #comments .reply .comment-reply-link, .widget-title, .widget .search-form .search-submit, .page-nav > *,
- .author-info-box .title, .comment-nav > *, #wp-calendar caption {background-color:' . $colormotif . ';}
- .genericon {color:' . $colormotif . ';}
- a {color:' . $colorlinks . ';}
- a:hover {color:' . $colorlinkshover . ';}
- </style>' . "\n\n";
- }
- function frontier_alter_color($hex, $steps) {
- $steps = max(-255, min(255, $steps));
- $hex = str_replace('#', '', $hex);
- if (strlen($hex) == 3) {
- $hex = str_repeat(substr($hex,0,1), 2).str_repeat(substr($hex,1,1), 2).str_repeat(substr($hex,2,1), 2);
- }
- $r = hexdec(substr($hex,0,2));
- $g = hexdec(substr($hex,2,2));
- $b = hexdec(substr($hex,4,2));
- $r = max(0,min(255,$r + $steps));
- $g = max(0,min(255,$g + $steps));
- $b = max(0,min(255,$b + $steps));
- $r_hex = str_pad(dechex($r), 2, '0', STR_PAD_LEFT);
- $g_hex = str_pad(dechex($g), 2, '0', STR_PAD_LEFT);
- $b_hex = str_pad(dechex($b), 2, '0', STR_PAD_LEFT);
- return '#'.$r_hex.$g_hex.$b_hex;
- }
- /*-------------------------------------
- Custom CSS - Theme Setup
- --------------------------------------*/
- function frontier_print_custom_css() {
- echo "\n" . '<!-- Custom CSS -->' . "\n" . '<style type="text/css" media="screen">' . "\n";
- echo frontier_option('custom_css');
- echo "\n" . '</style>' . "\n" . '<!-- Custom CSS End -->' . "\n\n";
- }
- /*-------------------------------------
- Favicon - Theme Setup
- --------------------------------------*/
- function frontier_favicon() {
- echo '<link rel="icon" href="' . esc_url( frontier_option('favicon') ) . '" type="image/x-icon" />' . "\n";
- }
- /*-------------------------------------
- Custom Codes - Theme Setup
- --------------------------------------*/
- function frontier_head_codes() {
- echo "\n" . '<!-- Custom Head Codes -->' . "\n";
- echo frontier_option('head_codes');
- echo "\n" . '<!-- Custom Head Codes End -->' . "\n\n";
- }
- function frontier_footer_codes() {
- echo "\n" . '<!-- Custom Footer Codes -->' . "\n";
- echo frontier_option('footer_codes');
- echo "\n" . '<!-- Custom Footer Codes End -->' . "\n\n";
- }
- /*----------------------------------------
- Post Editor Style - Theme Setup
- -----------------------------------------*/
- function frontier_editor_style() {
- add_filter( 'mce_css', 'frontier_editor_width' );
- add_editor_style( array( 'includes/editor-style.css', 'includes/content-width.php' ) );
- }
- function frontier_editor_width( $mce_css ) {
- global $content_width;
- $mce_css = str_replace( 'includes/content-width.php', add_query_arg( 'content_width', $content_width, 'includes/content-width.php' ), $mce_css );
- return $mce_css;
- }
- /*-------------------------------------
- Get Slider Template
- --------------------------------------*/
- function frontier_get_slider($slider_position) {
- if ( !( (is_home() || is_front_page()) && (frontier_option('slider_enable') == 1) ) ) return;
- if ( (frontier_option('slider_position') == 'before_main') && ($slider_position == 'main') ) {
- echo '<div id="slider" class="slider-main">';
- get_template_part('slider');
- echo '</div>';
- }
- if ( (frontier_option('slider_position') == 'before_content') && ($slider_position == 'content') ) {
- echo '<div id="slider" class="slider-content">';
- get_template_part('slider');
- echo '</div>';
- }
- }
- /*-------------------------------------
- Slider Script - Theme Setup
- --------------------------------------*/
- function frontier_slider_script() {
- global $frontier_container, $frontier_content;
- if (frontier_option('slider_position') == 'before_main') $slider_width = $frontier_container;
- if (frontier_option('slider_position') == 'before_content') $slider_width = $frontier_content;
- ?>
- <script type="text/javascript">
- jQuery(document).ready(function($){
- $('#basic-slider').bjqs({
- animtype : 'fade',
- width : <?php echo $slider_width; ?>,
- height : <?php echo frontier_option('slider_height'); ?>,
- animduration : <?php echo frontier_option('slider_slide_speed'); ?>,
- animspeed : <?php echo frontier_option('slider_pause_time'); ?>,
- automatic : true,
- showcontrols : true,
- nexttext : '<span class="slider-next"></span>',
- prevtext : '<span class="slider-prev"></span>',
- showmarkers : false,
- usecaptions : true,
- responsive : true
- });
- });
- </script>
- <?php
- }
- /*-------------------------------------
- Slider Stretch - Theme Setup
- --------------------------------------*/
- function frontier_slider_stretch() {
- echo '<style type="text/css">.bjqs-slide a, .bjqs-slide img {height: 100%; width: 100%;}</style>' . "\n";
- }
- /*----------------------------------------
- Remove extra width on wp-caption
- -----------------------------------------*/
- function frontier_img_caption_filter($val, $attr, $content = null) {
- extract(shortcode_atts(array(
- 'id' => '',
- 'align' => 'alignnone',
- 'width' => '',
- 'caption' => ''
- ), $attr));
- if ( 1 > (int) $width || empty($caption) )
- return $val;
- if ( $id ) $id = 'id="' . esc_attr($id) . '" ';
- return '<div ' . $id . 'class="wp-caption ' . esc_attr($align) . '" style="width: ' . ((int) $width + 10) . 'px">' . do_shortcode( $content ) . '<p class="wp-caption-text">' . $caption . '</p></div>';
- }
- add_filter( 'img_caption_shortcode', 'frontier_img_caption_filter', 10, 3 );
- /*-------------------------------------
- Valid HTML5 Remove rel from Cat
- --------------------------------------*/
- function frontier_remove_category_rel($output) {
- $output = str_replace(' rel="category tag"', '', $output);
- return $output;
- }
- add_filter('wp_list_categories', 'frontier_remove_category_rel');
- add_filter('the_category', 'frontier_remove_category_rel');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement