Guest User

frontier functions.php

a guest
Sep 24th, 2013
39
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * Frontier Theme Setup & Functions.
  4.  * @package Frontier
  5.  *
  6.  */
  7. $frontier_version = "1.0.6";
  8.  
  9. /*-------------------------------------
  10.     Setup Theme Options
  11. --------------------------------------*/
  12. if ( !function_exists( 'optionsframework_init' ) ) {
  13.     define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/includes/options-framework/' );
  14.     require_once dirname( __FILE__ ) . '/includes/options-framework/options-framework.php';
  15. }
  16.  
  17. /*-------------------------------------
  18.     Register Styles & Scripts
  19. --------------------------------------*/
  20. function frontier_enqueue_styles() {
  21.     global $frontier_version;
  22.     $protocol = is_ssl() ? 'https' : 'http';
  23.     wp_enqueue_style( 'frontier-font', $protocol . '://fonts.googleapis.com/css?family=Roboto+Condensed|Varela', array(), null );
  24.     wp_enqueue_style( 'frontier-icon', get_template_directory_uri() . '/includes/genericons/genericons.css', array() );
  25.     wp_enqueue_style( 'frontier-main', get_stylesheet_uri(), array(), $frontier_version );
  26.     if ( frontier_option('responsive_disable', 0) != 1 ) wp_enqueue_style( 'frontier-responsive', get_template_directory_uri() . '/responsive.css', array(), $frontier_version );
  27.     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 );
  28.     if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' );
  29. }
  30. add_action( 'wp_enqueue_scripts', 'frontier_enqueue_styles' );
  31.  
  32.  
  33. /*-------------------------------------
  34.     Frontier Theme Setup
  35. --------------------------------------*/
  36. function frontier_theme_setup() {
  37.     global  $content_width, $frontier_container, $frontier_header,
  38.             $frontier_content, $frontier_side_left, $frontier_side_right;
  39.    
  40.     // Get needed values for layout
  41.     frontier_get_layout_values();
  42.  
  43.     load_theme_textdomain( 'frontier', get_template_directory() . '/languages' );
  44.  
  45.     register_nav_menu( 'frontier-menu-top', __( 'Top Bar', 'frontier' ) );
  46.     register_nav_menu( 'frontier-menu-primary', __( 'Primary', 'frontier' ) );
  47.  
  48.     add_theme_support( 'automatic-feed-links' );
  49.  
  50.     add_theme_support( 'custom-background', array(
  51.         'default-color' => '505050',
  52.         'default-image' => get_template_directory_uri() . '/images/honeycomb.png',
  53.     ) );
  54.  
  55.     add_theme_support( 'custom-header', array(
  56.         'default-image'          => '',
  57.         'random-default'         => false,
  58.         'width'                  => $frontier_container,
  59.         'height'                 => $frontier_header,  
  60.         'flex-height'            => true,
  61.         'flex-width'             => true,
  62.         'header-text'            => false,
  63.         'uploads'                => true,
  64.     ) );
  65.  
  66.     add_theme_support( 'post-thumbnails' );
  67.     add_image_size( 'thumb-200x120', 200, 120, true );
  68.  
  69.     add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list' ) );
  70.  
  71.     // Set $content_width + allowance for default border & padding
  72.     if ( !isset( $content_width ) ) $content_width = ( frontier_option('content_width', 612) - 42 );
  73.  
  74.     // Print CSS for layout
  75.     add_action( 'wp_head', 'frontier_print_layout' );
  76.     add_action( 'wp_head', 'frontier_print_layout_page' );
  77.  
  78.     // Print CSS for header image
  79.     if ( !( get_header_image() == '' ) ) add_action( 'wp_head', 'frontier_header_image' );
  80.  
  81.     // Print CSS for colors
  82.     if ( frontier_option('colors_enable') == 1 ) add_action( 'wp_head', 'frontier_custom_colors' );
  83.  
  84.     // Print Custom CSS if available
  85.     if ( frontier_option('custom_css') ) add_action( 'wp_head', 'frontier_print_custom_css', 990 );
  86.  
  87.     if ( frontier_option('favicon') ) add_action( 'wp_head', 'frontier_favicon' );
  88.     if ( frontier_option('head_codes') ) add_action( 'wp_head', 'frontier_head_codes' );
  89.     if ( frontier_option('footer_codes') ) add_action( 'wp_footer', 'frontier_footer_codes' );
  90.     if ( frontier_option('editor_style_disable') != 1 ) frontier_editor_style();
  91.    
  92.     if ( frontier_option('slider_enable') == 1 ) {
  93.         add_action( 'wp_footer', 'frontier_slider_script', 20 );
  94.         if ( frontier_option('slider_stretch') == 'stretch' ) add_action( 'wp_head', 'frontier_slider_stretch' );
  95.     }
  96.  
  97. }
  98. add_action( 'after_setup_theme', 'frontier_theme_setup' );
  99.  
  100.  
  101. /*-------------------------------------
  102.     Set Default Title
  103. --------------------------------------*/
  104. function frontier_wp_title( $title, $sep ) {
  105.     global $paged, $page;
  106.  
  107.     if ( is_feed() )
  108.         return $title;
  109.  
  110.     $title .= get_bloginfo( 'name' );
  111.  
  112.     $site_description = get_bloginfo( 'description', 'display' );
  113.     if ( $site_description && ( is_home() || is_front_page() ) )
  114.         $title = "$title $sep $site_description";
  115.  
  116.     if ( $paged >= 2 || $page >= 2 )
  117.         $title = "$title $sep " . sprintf( __( 'Page %s', 'frontier' ), max( $paged, $page ) );
  118.  
  119.     return $title;
  120. }
  121. add_filter( 'wp_title', 'frontier_wp_title', 10, 2 );
  122.  
  123.  
  124. /*----------------------------------------
  125.     Add Class to Parent Menu Items
  126. -----------------------------------------*/
  127. function frontier_menu_class( $items ) {
  128.     $parents = array();
  129.     foreach ( $items as $item ) {
  130.         if ( $item->menu_item_parent && $item->menu_item_parent > 0 ) $parents[] = $item->menu_item_parent;
  131.     }
  132.     foreach ( $items as $item ) {
  133.         if ( in_array( $item->ID, $parents ) ) $item->classes[] = 'parent-menu-item';
  134.     }
  135.     return $items;
  136. }
  137. add_filter( 'wp_nav_menu_objects', 'frontier_menu_class' );
  138.  
  139. function frontier_page_menu_class( $css_class, $page, $depth, $args ) {
  140.     if (!empty($args['has_children']))
  141.         $css_class[] = 'parent-menu-item';
  142.     return $css_class;
  143. }
  144. add_filter( 'page_css_class', 'frontier_page_menu_class', 10, 4 );
  145.  
  146.  
  147. /*----------------------------------------
  148.     Custom Entries to the Admin Bar
  149. -----------------------------------------*/
  150. function frontier_admin_bar_menu() {
  151.     if ( current_user_can( 'edit_theme_options' ) ) {
  152.         global $wp_admin_bar;
  153.         $wp_admin_bar->add_menu( array(
  154.             'parent' => false,
  155.             'id' => 'frontier_admin_bar',
  156.             'title' => __('Frontier Options', 'frontier'),
  157.             'href' => admin_url( 'themes.php?page=options-framework')
  158.         ));
  159.         $wp_admin_bar->add_menu( array(
  160.             'parent' => 'appearance',
  161.             'id' => 'theme_editor_admin_bar',  
  162.             'title' => __('Editor', 'frontier'),
  163.             'href' => admin_url( 'theme-editor.php')
  164.         ));
  165.         $wp_admin_bar->add_menu( array(
  166.             'parent' => 'appearance',
  167.             'id' => 'plugins_admin_bar',    
  168.             'title' => __('Plugins', 'frontier'),
  169.             'href' => admin_url( 'plugins.php')
  170.         ));
  171.     }
  172. }
  173. add_action( 'admin_bar_menu', 'frontier_admin_bar_menu', 88 );
  174.  
  175.  
  176. /*----------------------------------------
  177.     Register Sidebars
  178. -----------------------------------------*/
  179. function frontier_register_sidebars() {
  180.  
  181.     switch ( frontier_option('column_layout', 'col-cs') ) {
  182.         case 'col-c' :
  183.             frontier_register_sidebars_extra();
  184.             break;
  185.  
  186.         case 'col-sc' :
  187.             register_sidebar(array(
  188.                 'name'          => __('Sidebar Left', 'frontier'),
  189.                 'id'            => 'widgets_sidebar_left',
  190.                 'before_widget' => '<div id="%1$s" class="widget-sidebar widget %2$s">',
  191.                 'after_widget'  => '</div>',
  192.                 'before_title'  => '<h4 class="widget-title">',
  193.                 'after_title'   => '</h4>') );
  194.  
  195.             frontier_register_sidebars_extra();
  196.             break;
  197.  
  198.         case 'col-cs' :
  199.             register_sidebar(array(
  200.                 'name'          => __('Sidebar Right', 'frontier'),
  201.                 'id'            => 'widgets_sidebar_right',
  202.                 'description'   => __('The Right Sidebar. The best sidebar a kid could have. Use it wisely.', 'frontier'),
  203.                 'before_widget' => '<div id="%1$s" class="widget-sidebar widget %2$s">',
  204.                 'after_widget'  => '</div>',
  205.                 'before_title'  => '<h4 class="widget-title">',
  206.                 'after_title'   => '</h4>') );
  207.  
  208.             frontier_register_sidebars_extra();
  209.             break;
  210.  
  211.         case 'col-ssc' :
  212.         case 'col-css' :
  213.         case 'col-scs' :
  214.             register_sidebar(array(
  215.                 'name'          => __('Sidebar Left', 'frontier'),
  216.                 'id'            => 'widgets_sidebar_left',
  217.                 'before_widget' => '<div id="%1$s" class="widget-sidebar widget %2$s">',
  218.                 'after_widget'  => '</div>',
  219.                 'before_title'  => '<h4 class="widget-title">',
  220.                 'after_title'   => '</h4>') );
  221.  
  222.             register_sidebar(array(
  223.                 'name'          => __('Sidebar Right', 'frontier'),
  224.                 'id'            => 'widgets_sidebar_right',
  225.                 'description'   => __('The Right Sidebar. The best sidebar a kid could have ;)', 'frontier'),
  226.                 'before_widget' => '<div id="%1$s" class="widget-sidebar widget %2$s">',
  227.                 'after_widget'  => '</div>',
  228.                 'before_title'  => '<h4 class="widget-title">',
  229.                 'after_title'   => '</h4>') );
  230.  
  231.             frontier_register_sidebars_extra();
  232.             break;
  233.     }
  234. }
  235. add_action( 'widgets_init', 'frontier_register_sidebars' );
  236.  
  237. function frontier_register_sidebars_extra() {
  238.     $widget_areas = frontier_option('widget_areas');
  239.     if ($widget_areas['body'] == 1) {
  240.     register_sidebar(array(
  241.         'name'          => __('Body', 'frontier'),
  242.         'id'            => 'widgets_body',
  243.         'description'   => __('Widgets outside of the container. If used, you\'ll have to position the widgets with css.', 'frontier'),
  244.         'before_widget' => '<div id="%1$s" class="widget-body widget %2$s">',
  245.         'after_widget'  => '</div>',
  246.         'before_title'  => '<h4 class="widget-title">',
  247.         'after_title'   => '</h4>') );
  248.     }
  249.     if ($widget_areas['header'] == 1) {
  250.     register_sidebar(array(
  251.         'name'          => __('Header', 'frontier'),
  252.         'id'            => 'widgets_header',
  253.         'description'   => __('Widgets to appear on the header. Ideal for horizontal ads or banners.', 'frontier'),
  254.         'before_widget' => '<div id="%1$s" class="widget-header widget %2$s">',
  255.         'after_widget'  => '</div>',
  256.         'before_title'  => '<h4 class="widget-title">',
  257.         'after_title'   => '</h4>') );
  258.     }
  259.     if ($widget_areas['below_menu'] == 1) {
  260.     register_sidebar(array(
  261.         'name'          => __('Below Menu', 'frontier'),
  262.         'id'            => 'widgets_below_menu',
  263.         'description'   => __('Full-width widgets that appear under the main menu. Ideal for horizontal ads or banners.', 'frontier'),
  264.         'before_widget' => '<div id="%1$s" class="widget-below-menu widget %2$s">',
  265.         'after_widget'  => '</div>',
  266.         'before_title'  => '<h4 class="widget-title">',
  267.         'after_title'   => '</h4>') );
  268.     }
  269.     if ($widget_areas['before_content'] == 1) {
  270.     register_sidebar(array(
  271.         'name'          => __('Before Content', 'frontier'),
  272.         'id'            => 'widgets_before_content',
  273.         'before_widget' => '<div id="%1$s" class="widget-before-content widget %2$s">',
  274.         'after_widget'  => '</div>',
  275.         'before_title'  => '<h4 class="widget-title">',
  276.         'after_title'   => '</h4>') );
  277.     }
  278.     if ($widget_areas['after_content'] == 1) {
  279.     register_sidebar(array(
  280.         'name'          => __('After Content', 'frontier'),
  281.         'id'            => 'widgets_after_content',
  282.         'before_widget' => '<div id="%1$s" class="widget-after-content widget %2$s">',
  283.         'after_widget'  => '</div>',
  284.         'before_title'  => '<h4 class="widget-title">',
  285.         'after_title'   => '</h4>') );
  286.     }
  287.     if ($widget_areas['footer'] == 1) {
  288.     register_sidebar(array(
  289.         'name'          => __('Footer', 'frontier'),
  290.         'id'            => 'widgets_footer',
  291.         'description'   => __('Widgets are arranged into 3 columns.', 'frontier'),
  292.         'before_widget' => '<div id="%1$s" class="widget-footer widget %2$s">',
  293.         'after_widget'  => '</div>',
  294.         'before_title'  => '<h4 class="widget-title">',
  295.         'after_title'   => '</h4>') );
  296.     }
  297.     if ($widget_areas['post_header'] == 1) {
  298.     register_sidebar(array(
  299.         'name'          => __('Post - Header', 'frontier'),
  300.         'id'            => 'widgets_before_post',
  301.         'before_widget' => '<div id="%1$s" class="widget-before-post widget %2$s">',
  302.         'after_widget'  => '</div>',
  303.         'before_title'  => '<h4 class="widget-title">',
  304.         'after_title'   => '</h4>') );
  305.     }
  306.     if ($widget_areas['post_before_content'] == 1) {
  307.     register_sidebar(array(
  308.         'name'          => __('Post - Before Content', 'frontier'),
  309.         'id'            => 'widgets_before_post_content',
  310.         'before_widget' => '<div id="%1$s" class="widget-before-post-content widget %2$s">',
  311.         'after_widget'  => '</div>',
  312.         'before_title'  => '<h4 class="widget-title">',
  313.         'after_title'   => '</h4>') );
  314.     }
  315.     if ($widget_areas['post_after_content'] == 1) {
  316.     register_sidebar(array(
  317.         'name'          => __('Post - After Content', 'frontier'),
  318.         'id'            => 'widgets_after_post_content',
  319.         'before_widget' => '<div id="%1$s" class="widget-after-post-content widget %2$s">',
  320.         'after_widget'  => '</div>',
  321.         'before_title'  => '<h4 class="widget-title">',
  322.         'after_title'   => '</h4>') );
  323.     }
  324.     if ($widget_areas['post_footer'] == 1) {
  325.     register_sidebar(array(
  326.         'name'          => __('Post - Footer', 'frontier'),
  327.         'id'            => 'widgets_after_post',
  328.         'before_widget' => '<div id="%1$s" class="widget-after-post widget %2$s">',
  329.         'after_widget'  => '</div>',
  330.         'before_title'  => '<h4 class="widget-title">',
  331.         'after_title'   => '</h4>') );
  332.     }
  333. }
  334.  
  335. /*-------------------------------------
  336.     Get Layout Values - Theme Setup
  337. --------------------------------------*/
  338. function frontier_get_layout_values() {
  339.     global  $frontier_container, $frontier_header, $frontier_content,
  340.             $frontier_side_left, $frontier_side_right;
  341.  
  342.     $frontier_content = frontier_option('content_width', 612);
  343.     $frontier_header = frontier_option('header_height', 140);
  344.     $frontier_side_left = frontier_option('sidebar_width_left', 280);
  345.     $frontier_side_right = frontier_option('sidebar_width_right', 328);
  346.  
  347.     switch ( frontier_option('column_layout', 'col-cs') ) {
  348.         case 'col-c' :
  349.             $frontier_container = $frontier_content;
  350.             break;
  351.  
  352.         case 'col-sc' :
  353.             $frontier_container = $frontier_content + $frontier_side_left;
  354.             break;
  355.  
  356.         case 'col-cs' :
  357.             $frontier_container = $frontier_content + $frontier_side_right;
  358.             break;
  359.  
  360.         case 'col-ssc' :
  361.         case 'col-css' :
  362.         case 'col-scs' :
  363.             $frontier_container = $frontier_content + $frontier_side_left + $frontier_side_right;
  364.             break;
  365.     }
  366. }
  367.  
  368. /*-------------------------------------
  369.     Layout CSS - Theme Setup
  370. --------------------------------------*/
  371. function frontier_print_layout() {
  372.     global  $frontier_version, $frontier_container, $frontier_header,
  373.             $frontier_content, $frontier_side_left, $frontier_side_right;
  374. echo '
  375. <meta property="Frontier Theme" content="' . $frontier_version . '" />
  376. <style type="text/css" media="screen">
  377.     #container {width:' . $frontier_container . 'px;}
  378.     #header {min-height:' . $frontier_header . 'px;}
  379.     #content {
  380.         width:' . $frontier_content . 'px;
  381.         max-width:' . $frontier_content . 'px;
  382.     }
  383.     #sidebar-left {
  384.         width:' . $frontier_side_left . 'px;
  385.         max-width:' . $frontier_side_left . 'px;
  386.     }
  387.     #sidebar-right {
  388.         width:' . $frontier_side_right . 'px;
  389.         max-width:' . $frontier_side_right . 'px;
  390.     }
  391. </style>' . "\n";
  392. }
  393.  
  394. /*-------------------------------------
  395.     Layout CSS for Pages - Theme Setup
  396. --------------------------------------*/
  397. function frontier_print_layout_page() {
  398.     global  $frontier_container, $frontier_side_left, $frontier_side_right;
  399.     $width_cs = $frontier_container - $frontier_side_right;
  400.     $width_sc = $frontier_container - $frontier_side_left;
  401.     $width_scs = $frontier_container - ($frontier_side_left + $frontier_side_right);
  402. echo '
  403. <style type="text/css" media="screen">
  404.     .page-template-page-cs-php #content {width:' . $width_cs . 'px; max-width:' . $width_cs . 'px;}
  405.     .page-template-page-sc-php #content {width:' . $width_sc . 'px; max-width:' . $width_sc . 'px;}
  406.     .page-template-page-scs-php #content {width:' . $width_scs . 'px; max-width:' . $width_scs . 'px;}
  407. </style>' . "\n\n";
  408. }
  409.  
  410. /*-------------------------------------
  411.     Header BG CSS - Theme Setup
  412. --------------------------------------*/
  413. function frontier_header_image() {
  414.     global $frontier_container, $frontier_header;
  415. echo '
  416. <style type="text/css" media="screen">
  417. #header {
  418.     background-image: url(' . get_header_image() . ');
  419.     background-size: ' . $frontier_container . 'px ' . $frontier_header . 'px;
  420. }</style>' . "\n";
  421. }
  422.  
  423. /*-------------------------------------
  424.     Custom Colors CSS - Theme Setup
  425. --------------------------------------*/
  426. function frontier_custom_colors() {
  427.     $colormotif = frontier_option('color_motif');
  428.     $colortopbar = frontier_option('color_top_bar');
  429.     $colorheader = frontier_option('color_header');
  430.     $colormenu = frontier_option('color_menu_main');
  431.     $colorbottombar = frontier_option('color_bottom_bar');
  432.     $colorlinks = frontier_option('color_links');
  433.     $colorlinkshover = frontier_option('color_links_hover');
  434.  
  435. echo '<style type="text/css" media="screen">
  436.     #header {background-color:' . $colorheader . ';}
  437.  
  438.     #menu-main {background-color:' . $colormenu . ';}
  439.     .menu-main {
  440.         border-left: 1px solid ' . frontier_alter_color( $colormenu, -40 ) . ';
  441.         border-right: 1px solid ' . frontier_alter_color( $colormenu, 30 ) . ';
  442.     }
  443.     .menu-main > li, .menu-main > ul > .page_item {
  444.         border-left: 1px solid ' . frontier_alter_color( $colormenu, 30 ) . ';
  445.         border-right: 1px solid ' . frontier_alter_color( $colormenu, -40 ) . ';
  446.     }
  447.  
  448.     #top-bar {background-color:' . $colortopbar . ';}
  449.     #bottom-bar {background-color:' . $colorbottombar . ';}
  450.  
  451.     .blog-view, .comment-author-admin .comment-body, .bypostauthor .comment-body {border-top: 6px solid ' . $colormotif . ';}
  452.     #comments .reply .comment-reply-link, .widget-title, .widget .search-form .search-submit, .page-nav > *,
  453.     .author-info-box .title, .comment-nav > *, #wp-calendar caption {background-color:' . $colormotif . ';}
  454.     .genericon {color:' . $colormotif . ';}
  455.  
  456.     a {color:' . $colorlinks . ';}
  457.     a:hover {color:' . $colorlinkshover . ';}
  458. </style>' . "\n\n";
  459. }
  460.  
  461. function frontier_alter_color($hex, $steps) {
  462.     $steps = max(-255, min(255, $steps));
  463.  
  464.     $hex = str_replace('#', '', $hex);
  465.     if (strlen($hex) == 3) {
  466.         $hex = str_repeat(substr($hex,0,1), 2).str_repeat(substr($hex,1,1), 2).str_repeat(substr($hex,2,1), 2);
  467.     }
  468.  
  469.     $r = hexdec(substr($hex,0,2));
  470.     $g = hexdec(substr($hex,2,2));
  471.     $b = hexdec(substr($hex,4,2));
  472.  
  473.     $r = max(0,min(255,$r + $steps));
  474.     $g = max(0,min(255,$g + $steps));  
  475.     $b = max(0,min(255,$b + $steps));
  476.  
  477.     $r_hex = str_pad(dechex($r), 2, '0', STR_PAD_LEFT);
  478.     $g_hex = str_pad(dechex($g), 2, '0', STR_PAD_LEFT);
  479.     $b_hex = str_pad(dechex($b), 2, '0', STR_PAD_LEFT);
  480.  
  481.     return '#'.$r_hex.$g_hex.$b_hex;
  482. }
  483.  
  484. /*-------------------------------------
  485.     Custom CSS - Theme Setup
  486. --------------------------------------*/
  487. function frontier_print_custom_css() {
  488.     echo "\n" . '<!-- Custom CSS -->' . "\n" . '<style type="text/css" media="screen">' . "\n";
  489.     echo frontier_option('custom_css');
  490.     echo "\n" . '</style>' . "\n" . '<!-- Custom CSS End -->' . "\n\n";
  491. }
  492.  
  493. /*-------------------------------------
  494.     Favicon - Theme Setup
  495. --------------------------------------*/
  496. function frontier_favicon() {
  497.     echo '<link rel="icon" href="' . esc_url( frontier_option('favicon') ) . '" type="image/x-icon" />' . "\n";
  498. }
  499.  
  500. /*-------------------------------------
  501.     Custom Codes - Theme Setup
  502. --------------------------------------*/
  503. function frontier_head_codes() {
  504.     echo "\n" . '<!-- Custom Head Codes -->' . "\n";
  505.     echo frontier_option('head_codes');
  506.     echo "\n" . '<!-- Custom Head Codes End -->' . "\n\n";
  507. }
  508. function frontier_footer_codes() {
  509.     echo "\n" . '<!-- Custom Footer Codes -->' . "\n";
  510.     echo frontier_option('footer_codes');
  511.     echo "\n" . '<!-- Custom Footer Codes End -->' . "\n\n";
  512. }
  513.  
  514. /*----------------------------------------
  515.     Post Editor Style - Theme Setup
  516. -----------------------------------------*/
  517. function frontier_editor_style() {
  518.     add_filter( 'mce_css', 'frontier_editor_width' );
  519.     add_editor_style( array( 'includes/editor-style.css', 'includes/content-width.php' ) );
  520. }
  521.  
  522. function frontier_editor_width( $mce_css ) {
  523.     global $content_width;
  524.     $mce_css = str_replace( 'includes/content-width.php', add_query_arg( 'content_width', $content_width, 'includes/content-width.php' ), $mce_css );
  525.     return $mce_css;
  526. }
  527.  
  528. /*-------------------------------------
  529.     Get Slider Template
  530. --------------------------------------*/
  531. function frontier_get_slider($slider_position) {
  532.     if ( !( (is_home() || is_front_page()) && (frontier_option('slider_enable') == 1) ) ) return;
  533.  
  534.     if ( (frontier_option('slider_position') == 'before_main') && ($slider_position == 'main') ) {
  535.         echo '<div id="slider" class="slider-main">';
  536.         get_template_part('slider');
  537.         echo '</div>';
  538.     }
  539.  
  540.     if ( (frontier_option('slider_position') == 'before_content') && ($slider_position == 'content') ) {
  541.         echo '<div id="slider" class="slider-content">';
  542.         get_template_part('slider');
  543.         echo '</div>';
  544.     }
  545. }
  546.  
  547. /*-------------------------------------
  548.     Slider Script - Theme Setup
  549. --------------------------------------*/
  550. function frontier_slider_script() {
  551.     global  $frontier_container, $frontier_content;
  552.     if (frontier_option('slider_position') == 'before_main') $slider_width = $frontier_container;
  553.     if (frontier_option('slider_position') == 'before_content') $slider_width = $frontier_content;
  554. ?>
  555. <script type="text/javascript">
  556. jQuery(document).ready(function($){
  557.     $('#basic-slider').bjqs({
  558.         animtype : 'fade',
  559.         width : <?php echo $slider_width; ?>,
  560.         height : <?php echo frontier_option('slider_height'); ?>,
  561.         animduration : <?php echo frontier_option('slider_slide_speed'); ?>,
  562.         animspeed : <?php echo frontier_option('slider_pause_time'); ?>,
  563.         automatic : true,
  564.         showcontrols : true,
  565.         nexttext : '<span class="slider-next"></span>',
  566.         prevtext : '<span class="slider-prev"></span>',
  567.         showmarkers : false,
  568.         usecaptions : true,
  569.         responsive : true
  570.     });
  571. });
  572. </script>
  573. <?php
  574. }
  575.  
  576. /*-------------------------------------
  577.     Slider Stretch - Theme Setup
  578. --------------------------------------*/
  579. function frontier_slider_stretch() {
  580.     echo '<style type="text/css">.bjqs-slide a, .bjqs-slide img {height: 100%; width: 100%;}</style>' . "\n";
  581. }
  582.  
  583. /*----------------------------------------
  584.     Remove extra width on wp-caption
  585. -----------------------------------------*/
  586. function frontier_img_caption_filter($val, $attr, $content = null) {
  587.     extract(shortcode_atts(array(
  588.         'id'      => '',
  589.         'align'   => 'alignnone',
  590.         'width'   => '',
  591.         'caption' => ''
  592.     ), $attr));
  593.      
  594.     if ( 1 > (int) $width || empty($caption) )
  595.         return $val;
  596.  
  597.     if ( $id ) $id = 'id="' . esc_attr($id) . '" ';
  598.  
  599.     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>';
  600. }
  601. add_filter( 'img_caption_shortcode', 'frontier_img_caption_filter', 10, 3 );
  602.  
  603.  
  604. /*-------------------------------------
  605.     Valid HTML5 Remove rel from Cat
  606. --------------------------------------*/
  607. function frontier_remove_category_rel($output) {
  608.     $output = str_replace(' rel="category tag"', '', $output);
  609.     return $output;
  610. }
  611. add_filter('wp_list_categories', 'frontier_remove_category_rel');
  612. add_filter('the_category', 'frontier_remove_category_rel');
RAW Paste Data