. add_theme_support('automatic-feed-links'); // This theme uses wp_nav_menu() in one location. register_nav_menu('primary', __('Primary Menu', 'jc-one-lite')); // Add support for custom backgrounds if ( version_compare( $wp_version, '3.4', '>=' ) ) add_theme_support( 'custom-background' ); else add_custom_background(); // Add support for custom headers if ( version_compare( $wp_version, '3.4', '>=' ) ) add_theme_support( 'custom-header' ); else add_custom_image_header(); // Add support for Featured Images add_theme_support('post-thumbnails'); set_post_thumbnail_size(200, 100, true); add_image_size('large-feature', 500, 375, true); // Used for large feature (header) images add_image_size('small-feature', 800, 200, true); // Used for small feature (header) images // set the good content width if (jc_get_option('sidebar') != 'no'){ global $content_width; $content_width = 560; } // Add Shortcodes if (jc_get_option('sc') != 'no'){ require_once(get_template_directory().'/include/shortcode.php'); // Enable Shortcodes in excerpts and widgets add_filter('widget_text', 'do_shortcode'); add_filter('the_excerpt', 'do_shortcode'); add_filter('get_the_excerpt', 'do_shortcode'); } if (jc_get_option('sc_wpauto') == 'no'){ remove_filter('the_content', 'wpautop'); remove_filter('the_content', 'wptexturize'); } else { remove_filter('the_content', 'wpautop'); remove_filter('the_content', 'wptexturize'); add_filter('the_content', 'jc_sc_wpautop', 99); add_filter('widget_text', 'jc_sc_wpautop', 99); add_filter('the_excerpt', 'jc_sc_wpautop', 99); add_filter('get_the_excerpt', 'jc_sc_wpautop', 99); } if (is_admin()){ add_action('init', 'jc_init_theme_options'); add_action('admin_menu', 'jc_theme_menu'); add_action('admin_menu', 'jc_admin_load'); add_action('admin_menu', 'jc_admin_resources'); if (is_admin() && isset($_GET['activated'])) { jc_init_default_themes_options(true); } } else { add_action('wp_enqueue_scripts', 'jc_load_js'); add_action('wp_head', 'jc_wp_head'); add_action('wp_footer', 'jc_wp_footer'); } // Under Construction Feature global $pagenow; if (!(is_admin() || $pagenow == 'wp-login.php')){ if (!is_user_logged_in()) { if (jc_get_option('under_contruction') == 'yes'){ add_action('template_redirect', jc_under_contruction()); } } } } } // jc_one_setup function jc_load_options() { global $jc_options; if (count($jc_options) == 0){ // load theme options $jc_options = get_option('jc_theme_options', false); if (!is_array($jc_options) || (is_array($jc_options) && count($jc_options) == 0)) { jc_init_default_themes_options(); } } } function jc_get_option($key, $default=false) { global $jc_options; $ret = $default; if (is_array($jc_options) && array_key_exists($key, $jc_options)){ $ret = $jc_options[$key]; } return $ret; } function jc_add_option($key, $value) { return jc_update_option($key, $value); } function jc_update_option($key, $value) { global $jc_options; if (is_array($jc_options)){ $jc_options[$key] = $value; return true; } return false; } function jc_delete_option($key) { global $jc_options; if (is_array($jc_options) && array_key_exists($key, $jc_options)){ unset($jc_options[$key]); return true; } return false; } function jc_sc_wpautop($content) { $new_content = ''; $pattern_full = '{(\[raw\].*?\[/raw\])}is'; $pattern_contents = '{\[raw\](.*?)\[/raw\]}is'; $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE); foreach ($pieces as $piece) { if (preg_match($pattern_contents, $piece, $matches)) { $new_content .= $matches[1]; } else { $new_content .= wptexturize(wpautop($piece)); } } return $new_content; } /** * Add Static Javascript And CSS Library */ function jc_load_js(){ // Enqueue Javascript if(!is_admin()) { wp_enqueue_script('jquery'); if (file_exists(get_template_directory()."/js/libs/modernizr-2.0.6.min.js")) { wp_enqueue_script('jc-one-modernizr', get_template_directory_uri() . '/js/libs/modernizr-2.0.6.min.js', array('jquery')); } if (file_exists(get_template_directory()."/js/plugins.js")) { wp_enqueue_script('jc-one-plugins', get_template_directory_uri() . '/js/plugins.js', array('jquery', 'jc-one-modernizr')); } if (file_exists(get_template_directory()."/js/script.js")) { wp_enqueue_script('jc-one-script', get_template_directory_uri() . '/js/script.js', array('jquery', 'jc-one-modernizr')); } if (file_exists(get_template_directory()."/styles/".jc_get_option('stylesheet'))) { wp_enqueue_style('jc-one-custom-style', get_template_directory_uri()."/styles/".jc_get_option('stylesheet')); } } } /** * Add Custom Javascript And CSS in head */ function jc_wp_head(){ $css = jc_get_option('css'); $js = jc_get_option('js'); $out = ''; if ($css != '') $out .= ''."\n"; if ($js != '') $out .= '\n"; echo $out; } /** * Add Custom Javascript in footer */ function jc_wp_footer(){ ?> __('Main Sidebar', 'jc-one-lite'), 'id' => 'primary', 'before_widget' => '", 'before_title' => '

', 'after_title' => '

', )); } if (jc_get_option('footer_sidebar') != 'no'){ register_sidebar(array( 'name' => __('Footer Sidebar 1', 'jc-one-lite'), 'id' => 'footer_1', 'before_widget' => '", 'before_title' => '

', 'after_title' => '

', )); register_sidebar(array( 'name' => __('Footer Sidebar 2', 'jc-one-lite'), 'id' => 'footer_2', 'before_widget' => '", 'before_title' => '

', 'after_title' => '

', )); register_sidebar(array( 'name' => __('Footer Sidebar 3', 'jc-one-lite'), 'id' => 'footer_3', 'before_widget' => '", 'before_title' => '

', 'after_title' => '

', )); } } add_action('widgets_init', 'jc_register_sidebar'); /** * Creates a nicely formatted and more specific title element text * for output in head of document, based on current view. */ function jc_wp_title( $title, $sep ) { global $paged, $page; if ( is_feed() ) return $title; // Add the site name. $title .= get_bloginfo( 'name' ); // Add the site description for the home/front page. $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) $title = "$title $sep $site_description"; // Add a page number if necessary. if ( $paged >= 2 || $page >= 2 ) $title = "$title $sep " . sprintf( __( 'Page %s', 'jc-one-lite' ), max( $paged, $page ) ); return $title; } add_filter( 'wp_title', 'jc_wp_title', 10, 2 ); /** * enqueue comment-reply */ function jc_enqueue_comment_reply() { if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'jc_enqueue_comment_reply' ); /** * Test if a sidebar is activated * * 4 sidebars can be used in the theme, in 2 locations : 1 in sidebar / 3 in footer * Test if the sidebars are activated for a single post/page or is empty * * @param string $context the location : sidebar or footer * @return boolean if there is a sidebar to display */ function jc_has_sidebar($context) { global $post; if (is_page() || is_single()) { $sidebar = get_post_meta($post->ID, '_sidebar', true); if (isset($sidebar) && $sidebar == "0") return false; } if ($context == 'primary') return (jc_get_option('sidebar') == 'yes' && is_active_sidebar('primary')); if ($context == 'footer') return (jc_get_option('footer_sidebar') == 'yes' && (is_active_sidebar('footer_1') || is_active_sidebar('footer_2') || is_active_sidebar('footer_3'))); return false; } /** * Display social icons in the footer. * */ function jc_one_get_social($before='') { $out = ''; $socials = array ( 'twitter' => 'Twitter', 'facebook' => 'Facebook', 'myspace' => 'MySpace', 'flickr' => 'Flickr', 'skype' => 'Skype', 'youtube' => 'Youtube', 'vimeo' => 'Vimeo', 'dailymotion' => 'Daily Motion' ); foreach ($socials as $sid => $sname) { $temp = jc_get_option($sid); if (isset($temp) && trim($temp) != ''){ $out .= '
  • '.$sname.'
  • '; } } if ($out != ''){ $out = $before.$out.$after; } return $out; } /** * Sets the post excerpt length to 50 words. * */ function jc_one_excerpt_length($length) { return 50; } add_filter('excerpt_length', 'jc_one_excerpt_length'); function jc_one_get_the_excerpt($length=100, $end=' ...') { $out = get_the_excerpt(); if (strlen($out) > $length) $out = substr($out, 0, $length).$end; return $out; } /** * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. */ function jc_one_page_menu_args($args) { $args['show_home'] = true; return $args; } add_filter('wp_page_menu_args', 'jc_one_page_menu_args'); /** * Display navigation to next/previous pages when applicable */ function jc_one_content_nav($nav_id, $context='loop') { global $wp_query; if ($context == 'loop'){ if ($wp_query->max_num_pages > 1) { ?>

    comment_type) : case 'pingback' : case 'trackback' : ?>

    ', ''); ?>

    id="li-comment-">
    — %2$s', 'jc-one-lite'), sprintf('%s', get_comment_author_link()), sprintf('', esc_url(get_comment_link($comment->comment_ID)), get_comment_time('c'), /* translators: 1: date, 2: time */ sprintf(__('%1$s at %2$s', 'jc-one-lite'), get_comment_date(), get_comment_time()) ) ); ?> ', ''); ?>
    comment_approved == '0') : ?>
    __('Reply ', 'jc-one-lite'), 'depth' => $depth, 'max_depth' => $args['max_depth']))); ?>