__('Primary', 'drop') )); } function ct_drop_register_widget_areas(){ /* register footer widget area */ hybrid_register_sidebar( array( 'name' => __( 'Subsidiary', 'drop' ), 'id' => 'subsidiary', 'description' => __( 'Widgets in this area will be shown in the footer', 'drop' ) ) ); } add_action('widgets_init','ct_drop_register_widget_areas'); // takes user input from the customizer and outputs linked social media icons function ct_drop_social_media_icons() { $social_sites = ct_drop_customizer_social_media_array(); // any inputs that aren't empty are stored in $active_sites array foreach($social_sites as $social_site) { if( strlen( get_theme_mod( $social_site ) ) > 0 ) { $active_sites[] = $social_site; } } // for each active social site, add it as a list item if(!empty($active_sites)) { echo "
" . __('Categories:','drop') . ""; foreach($categories as $category) { $output .= 'name ) ) . '">'.$category->cat_name.''.$separator; } echo trim($output, $separator); echo "
"; } } // Outputs the tags the post used with their names hyperlinked to their permalink function ct_drop_tags_display() { $tags = get_the_tags(); $separator = ' '; $output = ''; if($tags){ echo "" . __('Tagged as:','drop') . ""; foreach($tags as $tag) { $output .= 'name ) ) . '">'.$tag->name.''.$separator; } echo trim($output, $separator); echo "
"; } } /* added to customize the comments. Same as default except -> added use of gravatar images for comment authors */ function ct_drop_customize_comments( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; global $post; ?>'; $fields['url'] = '
'; return $fields; } add_filter('comment_form_default_fields','ct_drop_update_fields'); function ct_drop_update_comment_field($comment_field) { $comment_field = '
'; return $comment_field; } add_filter('comment_form_field_comment','ct_drop_update_comment_field'); // remove allowed tags text after comment form function ct_drop_remove_comments_notes_after($defaults){ $defaults['comment_notes_after']=''; return $defaults; } add_action('comment_form_defaults', 'ct_drop_remove_comments_notes_after'); // for 'read more' tag excerpts function ct_drop_excerpt() { global $post; // check for the more tag $ismore = strpos( $post->post_content, ''); /* if there is a more tag, edit the link to keep reading * works for both manual excerpts and read more tags */ if($ismore) { $read_more_link = __('Read the Post','drop'); $read_more_link .= "" . get_the_title() . ""; the_content($read_more_link); } // otherwise the excerpt is automatic, so output it else { the_excerpt(); } } // for custom & automatic excerpts function ct_drop_excerpt_read_more_link($output) { global $post; return $output . "
" . __('Read the Post','drop') . "" . get_the_title() . "
"; } add_filter('the_excerpt', 'ct_drop_excerpt_read_more_link'); // switch [...] to ellipsis on automatic excerpt function ct_drop_new_excerpt_more( $more ) { return '…'; } add_filter('excerpt_more', 'ct_drop_new_excerpt_more'); // turns of the automatic scrolling to the read more link function ct_drop_remove_more_link_scroll( $link ) { $link = preg_replace( '|#more-[0-9]+|', '', $link ); return $link; } add_filter( 'the_content_more_link', 'ct_drop_remove_more_link_scroll' ); // change the custom excerpt length function ct_drop_custom_excerpt_length( $length ) { return 35; } add_filter( 'excerpt_length', 'ct_drop_custom_excerpt_length', 999 ); // Adds navigation through pages in the loop function ct_drop_post_navigation() { if ( current_theme_supports( 'loop-pagination' ) ) loop_pagination(); } // adds the url from the image credit box to the post and makes it clickable function ct_drop_add_image_credit_link() { global $post; $link = get_post_meta( $post->ID, 'ct-image-credit-link', true ); if(!empty($link)) { echo "" . __('image credit:','drop') . make_clickable($link)."
"; } } // for displaying featured images including mobile versions and default versions function ct_drop_featured_image() { global $post; // if blog or archive, lazy load smaller image if(is_home() || is_archive()){ if (has_post_thumbnail( $post->ID ) ) { $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'blog' ); $image = $image[0]; echo " "; } } elseif (has_post_thumbnail( $post->ID ) ) { $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); $image = $image[0]; echo ""; } } /* add a smaller size for the blog page */ if( function_exists('add_image_size')){ add_image_size('blog', 600, 400); } // adds title to homepage add_filter( 'wp_title', 'ct_drop_add_homepage_title' ); function ct_drop_add_homepage_title( $title ) { if( empty( $title ) && ( is_home() || is_front_page() ) ) { return get_bloginfo( 'title' ) . ' | ' . get_bloginfo( 'description' ); } return $title; } // calls pages for menu if menu not set function ct_drop_wp_page_menu() { wp_page_menu(array("menu_class" => "menu-unset")); } /* adds 'not-front' to body on non-front pages */ function ct_drop_body_class( $classes ) { if ( ! is_front_page() ) { $classes[] = 'not-front'; } return $classes; } add_filter( 'body_class', 'ct_drop_body_class' ); function ct_drop_post_class_update($classes){ $remove = array(); $remove[] = 'entry'; if ( ! is_singular() ) { foreach ( $classes as $key => $class ) { if ( in_array( $class, $remove ) ){ unset( $classes[ $key ] ); $classes[] = 'excerpt'; } } } return $classes; } add_filter( 'post_class', 'ct_drop_post_class_update' ); // fix for bug with Disqus saying comments are closed if ( function_exists( 'dsq_options' ) ) { remove_filter( 'comments_template', 'dsq_comments_template' ); add_filter( 'comments_template', 'dsq_comments_template', 99 ); // You can use any priority higher than '10' } function ct_drop_get_gravatar_url($get_avatar){ preg_match("/src='(.*?)'/i", $get_avatar, $matches); return $matches[1]; } // outputs the user's uploaded profile picture with Gravatar fallback function ct_drop_profile_image_output(){ // if post author has profile image set if(get_option('ct_drop_profile_image_upload')) { // get the id based on the image's URL $image_id = ct_drop_get_image_id(get_option('ct_drop_profile_image_upload')); // retrieve the thumbnail size of profile image $image_thumb = wp_get_attachment_image($image_id, 'thumbnail'); // display the image echo $image_thumb; } else { echo get_avatar( get_the_author_meta( 'ID' ), 72 ); } } // retrieves the attachment ID from the file URL function ct_drop_get_image_id($url) { // Split the $url into two parts with the wp-content directory as the separator $parsed_url = explode( parse_url( WP_CONTENT_URL, PHP_URL_PATH ), $url ); // Get the host of the current site and the host of the $url, ignoring www $this_host = str_ireplace( 'www.', '', parse_url( home_url(), PHP_URL_HOST ) ); $file_host = str_ireplace( 'www.', '', parse_url( $url, PHP_URL_HOST ) ); // Return nothing if there aren't any $url parts or if the current host and $url host do not match if ( ! isset( $parsed_url[1] ) || empty( $parsed_url[1] ) || ( $this_host != $file_host ) ) { return; } // Now we're going to quickly search the DB for any attachment GUID with a partial path match // Example: /uploads/2013/05/test-image.jpg global $wpdb; $attachment = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->prefix}posts WHERE guid RLIKE %s;", $parsed_url[1] ) ); // Returns null if no attachment is found return $attachment[0]; } /** * Class for adding a new field to the options-general.php page */ class ct_drop_add_profile_image_upload { /** * Class constructor */ public function __construct() { add_filter( 'admin_init' , array( &$this , 'register_fields' ) ); } /** * Add new fields to wp-admin/options-general.php page */ public function register_fields() { register_setting( 'general', 'ct_drop_profile_image_upload', 'esc_attr' ); add_settings_field( 'ct_drop_profile_image_upload', '', array( &$this, 'fields_html' ), 'general' ); } /** * HTML for extra settings */ public function fields_html() { $value = get_option( 'ct_drop_profile_image_upload', '' ); ?>