'333333', 'border' => '444444', 'text' => '111111', 'link' => '00adef', 'url' => '00adef', ); break; case 'black-green': $themecolors = array( 'bg' => '333333', 'border' => '444444', 'text' => '111111', 'link' => '3b96df', 'url' => '3b96df', ); break; case 'black-red': $themecolors = array( 'bg' => '333333', 'border' => '444444', 'text' => '111111', 'link' => 'ff3333', 'url' => 'ff3333', ); break; case 'sea-blue': $themecolors = array( 'bg' => 'bbd5db', 'border' => 'f0fef5', 'text' => '111111', 'link' => '8b9898', 'url' => '8b9898', ); break; case 'white-rose': $themecolors = array( 'bg' => 'ffffff', 'border' => 'ff0000', 'text' => '111111', 'link' => 'ff3333', 'url' => 'ff3333', ); break; default: $themecolors = array( 'bg' => '7dbaea', 'border' => 'd8eaf9;', 'text' => '111111', 'link' => '3c96df', 'url' => '3c96df', ); break; } } /** * Tell WordPress to run selecta_setup() when the 'after_setup_theme' hook is run. */ add_action( 'after_setup_theme', 'selecta_setup' ); function selecta_setup() { // This theme has an options page that lets users pick layout, color scheme, featured post title text and configure a twitter icon //require_once( dirname( __FILE__ ) . '/inc/theme-options.php' ); // Add default posts and comments RSS feed links to head add_theme_support( 'automatic-feed-links' ); // This theme supports post formats. add_theme_support( 'post-formats', array( 'aside', 'audio', 'image', 'quote', 'gallery', 'video', 'chat' ) ); // Make theme available for translation // Translations can be filed in the /languages/ directory load_theme_textdomain( 'selecta', get_template_directory() . '/languages' ); // This theme uses wp_nav_menu() in one location. register_nav_menus( array( 'primary' => __( 'Primary Menu', 'selecta' ), ) ); // This theme allows users to set a custom background. add_theme_support( 'custom-background' ); // This theme allows users to upload a custom header. add_theme_support( 'custom-header', apply_filters( 'selecta_custom_header_args', array( 'default-image' => '', 'width' => 940, 'height' => 150, 'wp-head-callback' => '', 'admin-head-callback' => 'selecta_admin_header_style', ) ) ); // This theme uses post thumbnails. add_theme_support( 'post-thumbnails' ); add_image_size( 'normal', 190, 110, true ); // normal thumbnail size // Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. function selecta_page_menu_args($args) { $args['show_home'] = true; return $args; } add_filter( 'wp_page_menu_args', 'selecta_page_menu_args' ); add_theme_support( 'print-style' ); } // Load up the theme options require( dirname( __FILE__ ) . '/inc/theme-options.php' ); // Get selecta options function selecta_get_options() { $defaults = array( 'color_scheme' => 'blue', 'theme_slider' => 'no', 'theme_latest_posts' => 'no' ); $options = get_option( 'selecta_theme_options', $defaults ); return $options; } // Register our color schemes and add them to the style queue function selecta_color_registrar() { $options = selecta_get_options(); $color_scheme = $options['color_scheme']; if ( ! empty( $color_scheme ) && $color_scheme != 'blue' ) { wp_register_style( $color_scheme, get_template_directory_uri() . '/colors/' . $color_scheme . '.css', array( 'selecta' ), null ); wp_enqueue_style( $color_scheme ); } } add_action( 'wp_enqueue_scripts', 'selecta_color_registrar' ); // Load scripts. function selecta_scripts() { wp_enqueue_style( 'selecta', get_stylesheet_uri() ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' ); if ( is_front_page() ) { wp_enqueue_script( 'functions-js', get_template_directory_uri().'/js/functions.js', array( 'jquery'), '20110829' ); } } add_action( 'wp_enqueue_scripts', 'selecta_scripts' ); /** * Audio helper script. * * If an audio shortcode exists we will enqueue javascript * that replaces all non-supported audio player instances * with text links. * * @uses shortcode_exists(); */ function selecta_audio_script() { if ( shortcode_exists( 'audio' ) ) return; if ( ! is_singular() || has_post_format( 'audio' ) ) wp_enqueue_script( 'selecta-audio', get_template_directory_uri() . '/js/audio.js', array(), '20130521' ); } add_action( 'wp_enqueue_scripts', 'selecta_audio_script' ); /** * Styles the header image displayed on the Appearance > Header admin panel. */ define( 'HEADER_TEXTCOLOR', '' ); define( 'NO_HEADER_TEXT', true ); function selecta_admin_header_style() { ?> __( 'Default Sidebar', 'selecta' ), 'id' => 'sidebar-1', 'description' => __( 'The primary widget area.', 'selecta' ), 'before_widget' => '
  • ', 'after_widget' => '
  • ', 'before_title' => '

    ', 'after_title' => '

    ' ) ); register_sidebar( array ( 'name' => __( 'First Footer Widget Area', 'selecta' ), 'id' => 'sidebar-2', 'description' => __( 'The first footer widget area.', 'selecta' ), 'before_widget' => '
  • ', 'after_widget' => '
  • ', 'before_title' => '

    ', 'after_title' => '

    ' ) ); register_sidebar( array ( 'name' => __( 'Second Footer Widget Area', 'selecta' ), 'id' => 'sidebar-3', 'description' => __( 'The second footer widget area.', 'selecta' ), 'before_widget' => '
  • ', 'after_widget' => '
  • ', 'before_title' => '

    ', 'after_title' => '

    ' ) ); register_sidebar( array ( 'name' => __( 'Third Footer Widget Area', 'selecta' ), 'id' => 'sidebar-4', 'description' => __( 'The third footer widget area.', 'selecta' ), 'before_widget' => '
  • ', 'after_widget' => '
  • ', 'before_title' => '

    ', 'after_title' => '

    ' ) ); } add_action( 'init', 'selecta_widgets_init' ); /** * Removes the default styles that are packaged with the Recent Comments widget. */ function selecta_remove_recent_comments_style() { global $wp_widget_factory; if ( isset( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'] ) ) { remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) ); } } add_action( 'widgets_init', 'selecta_remove_recent_comments_style' ); /** * Prints HTML with meta information for the current post (date, category, tags and permalink). */ function selecta_post_meta() { $posted_in = ''; // Retrieves tag list of current post, separated by commas. $tag_list = get_the_tag_list( '', ', ' ); if ( $tag_list && ! is_wp_error( $tag_list ) ) { $posted_in = __( 'Posted by on %5$s in %6$s and tagged %7$s.', 'selecta' ); } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) { $posted_in = __( 'Posted by on %5$s in %6$s.', 'selecta' ); } // If $tag_list contains WP Error, empty before passing to printf() if ( is_wp_error( $tag_list ) ) { $tag_list = ''; } // Prints the string, replacing the placeholders. printf( $posted_in, esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_attr( sprintf( __( 'View all posts by %s', 'selecta' ), get_the_author() ) ), esc_html( get_the_author() ), esc_url( get_permalink() ), esc_attr( get_the_date() ), get_the_category_list( ', ' ), $tag_list ); } /** * Prints the post date. */ function selecta_entry_date() { printf( __( '%3$s', 'selecta' ), esc_url( get_permalink() ), esc_attr( get_the_time() ), esc_attr( get_the_date() ) ); } /** * Display navigation to next/previous pages when applicable */ function selecta_content_nav( $nav_id ) { global $wp_query; if ( $wp_query->max_num_pages > 1 ) : ?> $charlength ) { $subex = substr( $excerpt, 0, $charlength-5 ); $exwords = explode( " ", $subex ); $excut = -( strlen( $exwords[ count( $exwords ) -1 ] ) ); if( $excut < 0 ) { echo substr( $subex, 0, $excut ); } else { echo $subex; } echo "[...]"; } else { echo $excerpt; } } /** * Return the first audio file found for a post. * * @param int $post_id ID for parent post. */ function selecta_audio_grabber( $post_id ) { if ( function_exists( 'get_attached_media' ) ) { $media = get_attached_media( 'audio', $post_id ); return array_shift( $media ); } $audios = get_children( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'post_mime_type' => 'audio', 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', ) ); $audios = (array) apply_filters( 'get_attached_media', $audios, 'audio', get_post( $post_id ) ); return array_shift( $audios ); } /** * Get a short-form mime type for an audio file to display as a class attribute. * * @param int ID of an attachment * @return string A short representation of the file's mime type. */ function selecta_post_classes( $classes ) { if ( has_post_format( 'audio' ) ) { $audio = selecta_audio_grabber( get_the_ID() ); if ( is_object( $audio ) ) { $mime = str_replace( 'audio/', '', get_post_mime_type( $audio->ID ) ); if ( in_array( $mime, array( 'mp3', 'ogg', 'wav', ) ) ) $classes[] = $mime; } } return $classes; } add_filter( 'post_class', 'selecta_post_classes' ); if ( ! function_exists( 'the_post_format_audio' ) ) : /** * Shiv for the_post_format_audio(). * * the_post_format_audio() was introduced to WordPress in version 3.6. To * provide backward compatibility with previous versions, we will define our * own version of this function. * * @todo Remove this function when WordPress 3.8 is released. * * @param string $name The name of the shortcode. * @return bool True if shortcode exists; False otherwise. */ function the_post_format_audio() { $audio = selecta_audio_grabber( get_the_ID() ); if ( is_object( $audio ) ) : $url = wp_get_attachment_url( $audio->ID ); ?>
    tag based on what is being viewed. * * @since Selecta 1.0 */ function selecta_wp_title( $title, $sep ) { global $page, $paged; if ( is_feed() ) return $title; // Add the blog name $title .= get_bloginfo( 'name' ); // Add the blog description for the home/front page. $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) $title .= " $sep $site_description"; // Add a page number if necessary: if ( $paged >= 2 || $page >= 2 ) $title .= " $sep " . sprintf( __( 'Page %s', 'selecta' ), max( $paged, $page ) ); return $title; } add_filter( 'wp_title', 'selecta_wp_title', 10, 2 );