__( 'Main Navigation', 'sharonchin' ), 'header-menu' => __( 'Header Menu', 'sharonchin' ), 'footer-menu' => __( 'Footer Menu', 'sharonchin' ) ) ); /* Add Image sizes */ add_image_size( 'archive-item', 275, 225, true ); // Hard Crop Mode add_image_size( 'lilypad', 342, 9999); // Soft Crop Mode add_image_size( 'slider', 620, 9999); // Soft Crop Mode add_image_size( 'mini-thumbnail', 9999, 60); // Soft Crop Mode } // sharonchin_setup endif; add_action( 'after_setup_theme', 'sharonchin_setup' ); /** * Returns the options object for Sharon Chin Theme. * * @author Automattic * @since 1.3.0 - 06.04.2012 * * @return stdClass Theme Options */ function sharonchin_options() { return (object) wp_parse_args( get_option( 'sharonchin_theme_options', array() ), sharonchin_get_default_theme_options() ); } /** * Returns the default options for Sharon Chin Theme. * * @author Automattic * @since 1.3.0 - 06.04.2012 * * @return void */ function sharonchin_get_default_theme_options() { $default_theme_options = array( 'theme_layout' => 'content-sidebar', 'navbar_site_name' => false, 'navbar_searchform' => true, 'navbar_inverse' => true, 'navbar_position' => 'static', ); return apply_filters( 'sharonchin_default_theme_options', $default_theme_options ); } /** * Adds Sharon Chin Theme layout classes to the array of body classes. * * @author WordPress.org * @since 1.3.0 - 06.04.2012 * * @return void */ function sharonchin_layout_classes( $existing_classes ) { $classes = array( sharonchin_options()->theme_layout ); $classes = apply_filters( 'sharonchin_layout_classes', $classes ); return array_merge( $existing_classes, $classes ); } add_filter( 'body_class', 'sharonchin_layout_classes' ); /** * Adds Custom Background support * * @author Konstantin Obenland * @since 1.2.5 - 11.04.2012 * * @return void */ function sharonchin_custom_background_setup() { $args = apply_filters( 'sharonchin_custom_background_args', array( 'default-color' => 'EFEFEF', ) ); add_theme_support( 'custom-background', $args ); } add_action( 'after_setup_theme', 'sharonchin_custom_background_setup' ); /** * Register the sidebars. * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @return void */ function sharonchin_widgets_init() { if ( function_exists('register_sidebar') ) { register_sidebar( array( 'name' => __( 'Main Sidebar', 'sharonchin' ), 'id' => 'main', 'before_widget' => '', 'before_title' => '', ) ); } include_once( 'inc/sharonchin-image-meta-widget.php' ); register_widget( 'SharonChin_Image_Meta_Widget' ); include_once( 'inc/sharonchin-gallery-widget.php' ); register_widget( 'SharonChin_Gallery_Widget' ); } add_action( 'widgets_init', 'sharonchin_widgets_init' ); /** * Registration of theme scripts and styles * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @return void */ function sharonchin_register_scripts_styles() { if ( ! is_admin() ) { $theme_version = sharonchin_version(); $suffix = ( defined('SCRIPT_DEBUG') AND SCRIPT_DEBUG ) ? '' : '.min'; $bootstrap_css_dependencies = array(); /** * Scripts */ // Use less just in local server. if( WP_DEBUG === true ){ // Register the bootstrap.less wp_register_style( 'lesscss', get_stylesheet_directory_uri() . '/less/bootstrap.less', //$bootstrap_css_dependencies, array(), '2.3.2' ); } else { /** * Styles */ wp_register_style( 'tw-bootstrap', get_template_directory_uri() . "/css/bootstrap{$suffix}.css", array(), '2.0.3' ); wp_register_style( 'sharonchin', get_template_directory_uri() . "/style{$suffix}.css", array('tw-bootstrap'), $theme_version ); } } } add_action( 'init', 'sharonchin_register_scripts_styles' ); /** * Properly enqueue frontend scripts * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @return void */ function sharonchin_print_scripts() { $suffix = ( defined('SCRIPT_DEBUG') AND SCRIPT_DEBUG ) ? '' : '.min'; wp_enqueue_script( 'jquery' ); wp_enqueue_script('tw-bootstrap', get_template_directory_uri() . "/js/bootstrap{$suffix}.js"); wp_enqueue_script('sharonchin', get_template_directory_uri() . "/js/sharonchin{$suffix}.js"); wp_enqueue_script( 'masonry' , get_stylesheet_directory_uri() . "/js/masonry.pkgd{$suffix}.js"); wp_enqueue_script('imagesloaded', get_stylesheet_directory_uri() . "/js/imagesloaded.pkgd{$suffix}.js"); wp_enqueue_script('sharon', get_stylesheet_directory_uri() . "/js/sharon.js"); if( WP_DEBUG === true ){ wp_enqueue_script( 'delete-cache', get_stylesheet_directory_uri() . '/js/delete_cache.js'); wp_enqueue_script('lessjs', get_stylesheet_directory_uri() . '/js/less-1.4.1.min.js'); wp_enqueue_style('lesscss'); } else { wp_enqueue_style('sharon-bootstrap'); } wp_enqueue_style('sharonchin'); } add_action( 'wp_enqueue_scripts', 'sharonchin_print_scripts' ); /** * Add headers to the less files! * * @author Roberto Ulloa * @since 1.0.0 - 12.07.2013 * * @return void */ function sharonchin_enqueue_less_styles($tag, $handle) { global $wp_styles; $match_pattern = '/\.less$/U'; if ( preg_match( $match_pattern, $wp_styles->registered[$handle]->src ) ) { $handle = $wp_styles->registered[$handle]->handle; $media = $wp_styles->registered[$handle]->args; $href = $wp_styles->registered[$handle]->src . '?ver=' . $wp_styles->registered[$handle]->ver; $rel = isset($wp_styles->registered[$handle]->extra['alt']) && $wp_styles->registered[$handle]->extra['alt'] ? 'alternate stylesheet' : 'stylesheet/less'; $title = isset($wp_styles->registered[$handle]->extra['title']) ? "title='" . esc_attr( $wp_styles->registered[$handle]->extra['title'] ) . "'" : ''; $tag = ""; } return $tag; } add_filter( 'style_loader_tag', 'sharonchin_enqueue_less_styles', 5, 2); /** * Adds IE specific scripts * * Respond.js has to be loaded after Theme styles * * @author Konstantin Obenland * @since 1.7.0 - 11.06.2012 * * @return void */ function sharonchin_print_ie_scripts() { ?> navbar_position ) { $top_bottom = str_replace( 'navbar-fixed-', '', sharonchin_options()->navbar_position ); $css = "body > .container{margin-{$top_bottom}:68px;}@media(min-width: 980px){body > .container{margin-{$top_bottom}:58px;}}"; if ( is_admin_bar_showing() AND 'top' == $top_bottom ) $css .= '.navbar.navbar-fixed-top{margin-top:28px;}'; if ( function_exists( 'wp_add_inline_style' ) ) wp_add_inline_style( 'sharonchin', $css ); else echo "\n"; } } add_action( 'wp_enqueue_scripts', 'sharonchin_print_styles' ); if ( ! function_exists( 'sharonchin_credits' ) ) : /** * Prints HTML with meta information for the current post-date/time and author, * comment and edit link * * @author Konstantin Obenland * @since 1.2.2 - 07.04.2012 * * @return void */ function sharonchin_credits() { printf( '' . __( '© %1$s %3$s, all rights reserved.', 'sharonchin' ) . '', date( 'Y' ), home_url( '/' ), get_bloginfo( 'name' ) ); } endif; /** * Returns the blogname if no title was set. * * @author Konstantin Obenland * @since 1.1.0 - 18.03.2012 * * @param string $title * @param string $sep * * @return string */ function sharonchin_wp_title( $title, $sep ) { if ( ! is_feed() ) { $title .= get_bloginfo( 'name' ); if ( is_front_page() ) { $title .= " {$sep} " . get_bloginfo( 'description' ); } } return $title; } add_filter( 'wp_title', 'sharonchin_wp_title', 1, 2 ); /** * Returns a "Read More" link for excerpts * * @author Roberto Ulloa * @since 1.0.0 - 14.06.2013 * * @param string $more * * @return string */ function sharonchin_continue_reading_link() { return ' ' . __( 'Read more ', 'sharonchin' ) . ''; } /** * Get the wp_nav_menu() fallback, wp_page_menu(), to show a home link. * * @author WordPress.org * @since 1.0.0 - 05.02.2012 * * @param array $args * * @return array */ function sharonchin_page_menu_args( $args ) { $args['show_home'] = true; return $args; } add_filter( 'wp_page_menu_args', 'sharonchin_page_menu_args' ); /** * Filter in a link to a content ID attribute for the next/previous image links on image attachment pages * * @author Automattic * @since 1.0.0 - 05.02.2012 * * @param string $url * @param int $id * * @return string */ function sharonchin_enhanced_image_navigation( $url, $id ) { if ( is_attachment() AND wp_attachment_is_image( $id ) ) { $image = get_post( $id ); if ( $image->post_parent AND $image->post_parent != $id ) $url .= '#primary'; } return $url; } add_filter( 'attachment_link', 'sharonchin_enhanced_image_navigation', 10, 2 ); /** * Displays comment list, when there are any * * @author Konstantin Obenland * @since 1.7.0 - 16.06.2012 * * @return void */ function sharonchin_comments_list() { if ( post_password_required() ) : ?>

' . get_the_title() . '' ); ?>

    'sharonchin_comment' ) ); ?>

'
', 'comment_notes_before' => '', 'comment_notes_after' => '
' . allowed_tags() . '
' ) . '
', 'title_reply' => '' . __( 'Leave a reply', 'sharonchin' ) . '', 'title_reply_to' => '' . __( 'Leave a reply to %s', 'sharonchin' ). '', 'must_log_in' => '
' . sprintf( __( 'You must be logged in to post a comment.', 'sharonchin' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( get_the_ID() ) ) ) ) . '
', 'logged_in_as' => '
' . sprintf( __( 'Logged in as %2$s. Log out?', 'sharonchin' ), admin_url( 'profile.php' ), wp_get_current_user()->display_name, wp_logout_url( apply_filters( 'the_permalink', get_permalink( get_the_ID() ) ) ) ) . '
', ), $defaults ); } add_filter( 'comment_form_defaults', 'sharonchin_comment_form_defaults' ); if ( ! function_exists( 'sharonchin_comment' ) ) : /** * Template for comments and pingbacks. * * To override this walker in a child theme without modifying the comments template * simply create your own sharonchin_comment(), and that function will be used instead. * * Used as a callback by wp_list_comments() for displaying the comments. * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @param object $comment Comment data object. * @param array $args * @param int $depth Depth of comment in reference to parents. * * @return void */ function sharonchin_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; if ( 'pingback' == $comment->comment_type OR 'trackback' == $comment->comment_type ) : ?>
  • >

     ', '' ); ?>

  • >
    ">

    said on %2$s:', 'sharonchin' ), 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', 'sharonchin' ), get_comment_date(), get_comment_time() ) ) ); edit_comment_link( __( 'Edit', 'sharonchin' ), ' ', '' ); ?>

    comment_approved ) : ?>
    __( 'Reply ', 'sharonchin' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
    '; } add_action( 'comment_form_top', 'sharonchin_comment_form_top' ); /** * Adds markup to the comment form which is needed to make it work with Bootstrap * needs * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @param string $html * * @return string */ function sharonchin_comment_form() { echo '
  • '; } add_action( 'comment_form', 'sharonchin_comment_form' ); /** * Custom author form field for the comments form * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @param string $html * * @return string */ function sharonchin_comment_form_field_author( $html ) { $commenter = wp_get_current_commenter(); $req = get_option( 'require_name_email' ); $aria_req = ( $req ? " aria-required='true'" : '' ); return '
    ' . ( $req ? '

    ' . __('required', 'sharonchin') . '

    ' : '' ) . '
    '; } add_filter( 'comment_form_field_author', 'sharonchin_comment_form_field_author'); /** * Custom HTML5 email form field for the comments form * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @param string $html * * @return string */ function sharonchin_comment_form_field_email( $html ) { $commenter = wp_get_current_commenter(); $req = get_option( 'require_name_email' ); $aria_req = ( $req ? " aria-required='true'" : '' ); return '

    ' . ( $req ? '' . __('required', 'sharonchin') . ', ' : '' ) . __( 'will not be published', 'sharonchin' ) . '

    '; } add_filter( 'comment_form_field_email', 'sharonchin_comment_form_field_email'); /** * Custom HTML5 url form field for the comments form * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @param string $html * * @return string */ function sharonchin_comment_form_field_url( $html ) { $commenter = wp_get_current_commenter(); return '
    '; } add_filter( 'comment_form_field_url', 'sharonchin_comment_form_field_url'); /** * Adjusts an attechment link to hold the class of 'thumbnail' and make it look * pretty * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @param string $link * @param int $id Post ID. * @param string $size Default is 'thumbnail'. Size of image, either array or string. * @param bool $permalink Default is false. Whether to add permalink to image. * @param bool $icon Default is false. Whether to include icon. * @param string $text Default is false. If string, then will be link text. * * @return string */ function sharonchin_get_attachment_link( $link, $id, $size, $permalink, $icon, $text ) { return ( ! $text ) ? str_replace( ' 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'figure', 'icontag' => 'div', 'captiontag' => 'figcaption', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => '' ), $attr ) ); $id = intval( $id ); if ( 'RAND' == $order ) $orderby = 'none'; if ( $include ) { $include = preg_replace( '/[^0-9,]+/', '', $include ); $_attachments = get_posts( array( 'include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) ); $attachments = array(); foreach ( $_attachments as $key => $val ) { $attachments[$val->ID] = $_attachments[$key]; } } elseif ( $exclude ) { $exclude = preg_replace( '/[^0-9,]+/', '', $exclude ); $attachments = get_children( array( 'post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) ); } else { $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) ); } if ( empty( $attachments ) ) return; if ( is_feed() ) { $output = "\n"; foreach ( $attachments as $att_id => $attachment ) $output .= wp_get_attachment_link( $att_id, $size, true ) . "\n"; return $output; } $itemtag = tag_escape( $itemtag ); $captiontag = tag_escape( $captiontag ); $columns = intval( min( array( 8, $columns ) ) ); $float = (is_rtl()) ? 'right' : 'left'; if ( 4 > $columns ) $size = 'full'; $selector = "gallery-{$instance}"; $size_class = sanitize_html_class( $size ); $output = "\n"; return $output; } add_filter( 'post_gallery', 'sharonchin_post_gallery', 10, 2 ); /** * HTML 5 caption for pictures * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @param string $empty * @param array $attr * @param string $content * * @return string */ function sharonchin_img_caption_shortcode( $empty, $attr, $content ) { extract( shortcode_atts( array( 'id' => '', 'align' => 'alignnone', 'width' => '', 'caption' => '' ), $attr ) ); if ( 1 > (int) $width OR empty( $caption ) ) { return $content; } if ( $id ) { $id = 'id="' . $id . '" '; } return '
    ' . do_shortcode( str_replace( 'class="thumbnail', 'class="', $content ) ) . '
    ' . $caption . '
    '; } add_filter( 'img_caption_shortcode', 'sharonchin_img_caption_shortcode', 10, 3 ); /** * Returns a password form which dispalys nicely with Bootstrap * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @param string $form * * @return string Sharon Chin Theme password form */ function sharonchin_the_password_form( $form ) { return '
    '. __( 'This post is password protected. To view it please enter your password below:', 'sharonchin' ) . '
    '; } add_filter( 'the_password_form', 'sharonchin_the_password_form' ); /** * Modifies the category dropdown args for widgets on 404 pages * * @author Konstantin Obenland * @since 1.5.0 - 19.05.2012 * * @param array $args * * @return array */ function sharonchin_widget_categories_dropdown_args( $args ) { if ( is_404() ) { $args = wp_parse_args( $args, array( 'orderby' => 'count', 'order' => 'DESC', 'show_count' => 1, 'title_li' => '', 'number' => 10 ) ); } return $args; } add_filter( 'widget_categories_dropdown_args', 'sharonchin_widget_categories_dropdown_args' ); /** * Adds the .thumbnail class when images are sent to editor * * @author Konstantin Obenland * @since 2.0.0 - 29.08.2012 * * @param string $html * @param int $id * @param string $caption * @param string $title * @param string $align * @param string $url * @param string $size * @param string $alt * * @return string Image HTML */ function sharonchin_image_send_to_editor( $html, $id, $caption, $title, $align, $url, $size, $alt ) { if ( $url ) { $html = str_replace( '
    get( 'Version' ); } else { $theme_data = wp_get_theme( get_template_directory() . '/style.css' ); $theme_version = $theme_data['Version']; } return $theme_version; } /** * Related with a bug discussed in this post * http://wordpress.stackexchange.com/questions/71157/undefined-property-stdclasslabels-in-general-template-php-post-type-archive * @author Roberto Ulloa * @since 1.0.0 - 10.07.2013 * * @return void */ function sharonchin_wpse_71157_parse_query( $wp_query ) { if ( $wp_query->is_post_type_archive && $wp_query->is_tax ) $wp_query->is_post_type_archive = false; } add_action( 'parse_query', 'sharonchin_wpse_71157_parse_query' ); /* End of file functions.php */ /* Location: ./wp-content/themes/sharonchin/functions.php */