This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

functions.php-10_Nov

By: bcworkz on Nov 10th, 2013  |  syntax: PHP  |  size: 22.24 KB  |  views: 103  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. /**
  3.  * TwentyTen functions and definitions
  4.  *
  5.  * Sets up the theme and provides some helper functions. Some helper functions
  6.  * are used in the theme as custom template tags. Others are attached to action and
  7.  * filter hooks in WordPress to change core functionality.
  8.  *
  9.  * The first function, twentyten_setup(), sets up the theme by registering support
  10.  * for various features in WordPress, such as post thumbnails, navigation menus, and the like.
  11.  *
  12.  * When using a child theme (see http://codex.wordpress.org/Theme_Development and
  13.  * http://codex.wordpress.org/Child_Themes), you can override certain functions
  14.  * (those wrapped in a function_exists() call) by defining them first in your child theme's
  15.  * functions.php file. The child theme's functions.php file is included before the parent
  16.  * theme's file, so the child theme functions would be used.
  17.  *
  18.  * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
  19.  * to a filter or action hook. The hook can be removed by using remove_action() or
  20.  * remove_filter() and you can attach your own function to the hook.
  21.  *
  22.  * We can remove the parent theme's hook only after it is attached, which means we need to
  23.  * wait until setting up the child theme:
  24.  *
  25.  * <code>
  26.  * add_action( 'after_setup_theme', 'my_child_theme_setup' );
  27.  * function my_child_theme_setup() {
  28.  *     // We are providing our own filter for excerpt_length (or using the unfiltered value)
  29.  *     remove_filter( 'excerpt_length', 'twentyten_excerpt_length' );
  30.  *     ...
  31.  * }
  32.  * </code>
  33.  *
  34.  * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
  35.  *
  36.  * @package WordPress
  37.  * @subpackage Twenty_Ten
  38.  * @since Twenty Ten 1.0
  39.  */
  40.  
  41. /**
  42.  * Set the content width based on the theme's design and stylesheet.
  43.  *
  44.  * Used to set the width of images and content. Should be equal to the width the theme
  45.  * is designed for, generally via the style.css stylesheet.
  46.  */
  47. if ( ! isset( $content_width ) )
  48.         $content_width = 640;
  49.  
  50. /** Tell WordPress to run twentyten_setup() when the 'after_setup_theme' hook is run. */
  51. add_action( 'after_setup_theme', 'twentyten_setup' );
  52.  
  53. if ( ! function_exists( 'twentyten_setup' ) ):
  54. /**
  55.  * Sets up theme defaults and registers support for various WordPress features.
  56.  *
  57.  * Note that this function is hooked into the after_setup_theme hook, which runs
  58.  * before the init hook. The init hook is too late for some features, such as indicating
  59.  * support post thumbnails.
  60.  *
  61.  * To override twentyten_setup() in a child theme, add your own twentyten_setup to your child theme's
  62.  * functions.php file.
  63.  *
  64.  * @uses add_theme_support() To add support for post thumbnails, custom headers and backgrounds, and automatic feed links.
  65.  * @uses register_nav_menus() To add support for navigation menus.
  66.  * @uses add_editor_style() To style the visual editor.
  67.  * @uses load_theme_textdomain() For translation/localization support.
  68.  * @uses register_default_headers() To register the default custom header images provided with the theme.
  69.  * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
  70.  *
  71.  * @since Twenty Ten 1.0
  72.  */
  73. function twentyten_setup() {
  74.  
  75.         // This theme styles the visual editor with editor-style.css to match the theme style.
  76.         add_editor_style();
  77.  
  78.         // Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories.
  79.         add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
  80.  
  81.         // This theme uses post thumbnails
  82.         add_theme_support( 'post-thumbnails' );
  83.  
  84.         // Add default posts and comments RSS feed links to head
  85.         add_theme_support( 'automatic-feed-links' );
  86.  
  87.         // Make theme available for translation
  88.         // Translations can be filed in the /languages/ directory
  89.         load_theme_textdomain( 'twentyten', get_template_directory() . '/languages' );
  90.  
  91.         // This theme uses wp_nav_menu() in one location.
  92.         register_nav_menus( array(
  93.                 'primary' => __( 'Primary Navigation', 'twentyten' ),
  94.         ) );
  95.  
  96.         // This theme allows users to set a custom background.
  97.         add_theme_support( 'custom-background', array(
  98.                 // Let WordPress know what our default background color is.
  99.                 'default-color' => 'f1f1f1',
  100.         ) );
  101.  
  102.         // The custom header business starts here.
  103.  
  104.         $custom_header_support = array(
  105.                 // The default image to use.
  106.                 // The %s is a placeholder for the theme template directory URI.
  107.                 'default-image' => '%s/images/headers/path.jpg',
  108.                 // The height and width of our custom header.
  109.                 'width' => apply_filters( 'twentyten_header_image_width', 940 ),
  110.                 'height' => apply_filters( 'twentyten_header_image_height', 198 ),
  111.                 // Support flexible heights.
  112.                 'flex-height' => true,
  113.                 // Don't support text inside the header image.
  114.                 'header-text' => false,
  115.                 // Callback for styling the header preview in the admin.
  116.                 'admin-head-callback' => 'twentyten_admin_header_style',
  117.         );
  118.  
  119.         add_theme_support( 'custom-header', $custom_header_support );
  120.  
  121.         if ( ! function_exists( 'get_custom_header' ) ) {
  122.                 // This is all for compatibility with versions of WordPress prior to 3.4.
  123.                 define( 'HEADER_TEXTCOLOR', '' );
  124.                 define( 'NO_HEADER_TEXT', true );
  125.                 define( 'HEADER_IMAGE', $custom_header_support['default-image'] );
  126.                 define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] );
  127.                 define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] );
  128.                 add_custom_image_header( '', $custom_header_support['admin-head-callback'] );
  129.                 add_custom_background();
  130.         }
  131.  
  132.         // We'll be using post thumbnails for custom header images on posts and pages.
  133.         // We want them to be 940 pixels wide by 198 pixels tall.
  134.         // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
  135.         set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true );
  136.  
  137.         // ... and thus ends the custom header business.
  138.  
  139.         // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
  140.         register_default_headers( array(
  141.                 'berries' => array(
  142.                         'url' => '%s/images/headers/berries.jpg',
  143.                         'thumbnail_url' => '%s/images/headers/berries-thumbnail.jpg',
  144.                         /* translators: header image description */
  145.                         'description' => __( 'Berries', 'twentyten' )
  146.                 ),
  147.                 'cherryblossom' => array(
  148.                         'url' => '%s/images/headers/cherryblossoms.jpg',
  149.                         'thumbnail_url' => '%s/images/headers/cherryblossoms-thumbnail.jpg',
  150.                         /* translators: header image description */
  151.                         'description' => __( 'Cherry Blossoms', 'twentyten' )
  152.                 ),
  153.                 'concave' => array(
  154.                         'url' => '%s/images/headers/concave.jpg',
  155.                         'thumbnail_url' => '%s/images/headers/concave-thumbnail.jpg',
  156.                         /* translators: header image description */
  157.                         'description' => __( 'Concave', 'twentyten' )
  158.                 ),
  159.                 'fern' => array(
  160.                         'url' => '%s/images/headers/fern.jpg',
  161.                         'thumbnail_url' => '%s/images/headers/fern-thumbnail.jpg',
  162.                         /* translators: header image description */
  163.                         'description' => __( 'Fern', 'twentyten' )
  164.                 ),
  165.                 'forestfloor' => array(
  166.                         'url' => '%s/images/headers/forestfloor.jpg',
  167.                         'thumbnail_url' => '%s/images/headers/forestfloor-thumbnail.jpg',
  168.                         /* translators: header image description */
  169.                         'description' => __( 'Forest Floor', 'twentyten' )
  170.                 ),
  171.                 'inkwell' => array(
  172.                         'url' => '%s/images/headers/inkwell.jpg',
  173.                         'thumbnail_url' => '%s/images/headers/inkwell-thumbnail.jpg',
  174.                         /* translators: header image description */
  175.                         'description' => __( 'Inkwell', 'twentyten' )
  176.                 ),
  177.                 'path' => array(
  178.                         'url' => '%s/images/headers/path.jpg',
  179.                         'thumbnail_url' => '%s/images/headers/path-thumbnail.jpg',
  180.                         /* translators: header image description */
  181.                         'description' => __( 'Path', 'twentyten' )
  182.                 ),
  183.                 'sunset' => array(
  184.                         'url' => '%s/images/headers/sunset.jpg',
  185.                         'thumbnail_url' => '%s/images/headers/sunset-thumbnail.jpg',
  186.                         /* translators: header image description */
  187.                         'description' => __( 'Sunset', 'twentyten' )
  188.                 )
  189.         ) );
  190. }
  191. endif;
  192.  
  193. if ( ! function_exists( 'twentyten_admin_header_style' ) ) :
  194. /**
  195.  * Styles the header image displayed on the Appearance > Header admin panel.
  196.  *
  197.  * Referenced via add_custom_image_header() in twentyten_setup().
  198.  *
  199.  * @since Twenty Ten 1.0
  200.  */
  201. function twentyten_admin_header_style() {
  202. ?>
  203. <style type="text/css" id="twentyten-admin-header-css">
  204. /* Shows the same border as on front end */
  205. #headimg {
  206.         border-bottom: 1px solid #000;
  207.         border-top: 4px solid #000;
  208. }
  209. /* If header-text was supported, you would style the text with these selectors:
  210.         #headimg #name { }
  211.         #headimg #desc { }
  212. */
  213. </style>
  214. <?php
  215. }
  216. endif;
  217.  
  218. /**
  219.  * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
  220.  *
  221.  * To override this in a child theme, remove the filter and optionally add
  222.  * your own function tied to the wp_page_menu_args filter hook.
  223.  *
  224.  * @since Twenty Ten 1.0
  225.  */
  226. function twentyten_page_menu_args( $args ) {
  227.         if ( ! isset( $args['show_home'] ) )
  228.                 $args['show_home'] = true;
  229.         return $args;
  230. }
  231. add_filter( 'wp_page_menu_args', 'twentyten_page_menu_args' );
  232.  
  233. /**
  234.  * Sets the post excerpt length to 40 characters.
  235.  *
  236.  * To override this length in a child theme, remove the filter and add your own
  237.  * function tied to the excerpt_length filter hook.
  238.  *
  239.  * @since Twenty Ten 1.0
  240.  * @return int
  241.  */
  242. function twentyten_excerpt_length( $length ) {
  243.         return 40;
  244. }
  245. add_filter( 'excerpt_length', 'twentyten_excerpt_length' );
  246.  
  247. if ( ! function_exists( 'twentyten_continue_reading_link' ) ) :
  248. /**
  249.  * Returns a "Continue Reading" link for excerpts
  250.  *
  251.  * @since Twenty Ten 1.0
  252.  * @return string "Continue Reading" link
  253.  */
  254. function twentyten_continue_reading_link() {
  255.         return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) . '</a>';
  256. }
  257. endif;
  258.  
  259. /**
  260.  * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and twentyten_continue_reading_link().
  261.  *
  262.  * To override this in a child theme, remove the filter and add your own
  263.  * function tied to the excerpt_more filter hook.
  264.  *
  265.  * @since Twenty Ten 1.0
  266.  * @return string An ellipsis
  267.  */
  268. function twentyten_auto_excerpt_more( $more ) {
  269.         return ' &hellip;' . twentyten_continue_reading_link();
  270. }
  271. add_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );
  272.  
  273. /**
  274.  * Adds a pretty "Continue Reading" link to custom post excerpts.
  275.  *
  276.  * To override this link in a child theme, remove the filter and add your own
  277.  * function tied to the get_the_excerpt filter hook.
  278.  *
  279.  * @since Twenty Ten 1.0
  280.  * @return string Excerpt with a pretty "Continue Reading" link
  281.  */
  282. function twentyten_custom_excerpt_more( $output ) {
  283.         if ( has_excerpt() && ! is_attachment() ) {
  284.                 $output .= twentyten_continue_reading_link();
  285.         }
  286.         return $output;
  287. }
  288. add_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' );
  289.  
  290. /**
  291.  * Remove inline styles printed when the gallery shortcode is used.
  292.  *
  293.  * Galleries are styled by the theme in Twenty Ten's style.css. This is just
  294.  * a simple filter call that tells WordPress to not use the default styles.
  295.  *
  296.  * @since Twenty Ten 1.2
  297.  */
  298. add_filter( 'use_default_gallery_style', '__return_false' );
  299.  
  300. /**
  301.  * Deprecated way to remove inline styles printed when the gallery shortcode is used.
  302.  *
  303.  * This function is no longer needed or used. Use the use_default_gallery_style
  304.  * filter instead, as seen above.
  305.  *
  306.  * @since Twenty Ten 1.0
  307.  * @deprecated Deprecated in Twenty Ten 1.2 for WordPress 3.1
  308.  *
  309.  * @return string The gallery style filter, with the styles themselves removed.
  310.  */
  311. function twentyten_remove_gallery_css( $css ) {
  312.         return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
  313. }
  314. // Backwards compatibility with WordPress 3.0.
  315. if ( version_compare( $GLOBALS['wp_version'], '3.1', '<' ) )
  316.         add_filter( 'gallery_style', 'twentyten_remove_gallery_css' );
  317.  
  318. if ( ! function_exists( 'twentyten_comment' ) ) :
  319. /**
  320.  * Template for comments and pingbacks.
  321.  *
  322.  * To override this walker in a child theme without modifying the comments template
  323.  * simply create your own twentyten_comment(), and that function will be used instead.
  324.  *
  325.  * Used as a callback by wp_list_comments() for displaying the comments.
  326.  *
  327.  * @since Twenty Ten 1.0
  328.  */
  329. function twentyten_comment( $comment, $args, $depth ) {
  330.         $GLOBALS['comment'] = $comment;
  331.         switch ( $comment->comment_type ) :
  332.                 case '' :
  333.         ?>
  334.         <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  335.                 <div id="comment-<?php comment_ID(); ?>">
  336.                         <div class="comment-author vcard">
  337.                                 <?php echo get_avatar( $comment, 40 ); ?>
  338.                                 <?php printf( __( '%s <span class="says">says:</span>', 'twentyten' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
  339.                         </div><!-- .comment-author .vcard -->
  340.                         <?php if ( $comment->comment_approved == '0' ) : ?>
  341.                                 <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentyten' ); ?></em>
  342.                                 <br />
  343.                         <?php endif; ?>
  344.  
  345.                         <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
  346.                                 <?php
  347.                                         /* translators: 1: date, 2: time */
  348.                                         printf( __( '%1$s at %2$s', 'twentyten' ), get_comment_date(),  get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' );
  349.                                 ?>
  350.                         </div><!-- .comment-meta .commentmetadata -->
  351.  
  352.                         <div class="comment-body"><?php comment_text(); ?></div>
  353.  
  354.                         <div class="reply">
  355.                                 <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  356.                         </div><!-- .reply -->
  357.                 </div><!-- #comment-##  -->
  358.  
  359.         <?php
  360.                         break;
  361.                 case 'pingback'  :
  362.                 case 'trackback' :
  363.         ?>
  364.         <li class="post pingback">
  365.                 <p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' ); ?></p>
  366.         <?php
  367.                         break;
  368.         endswitch;
  369. }
  370. endif;
  371.  
  372. /**
  373.  * Register widgetized areas, including two sidebars and four widget-ready columns in the footer.
  374.  *
  375.  * To override twentyten_widgets_init() in a child theme, remove the action hook and add your own
  376.  * function tied to the init hook.
  377.  *
  378.  * @since Twenty Ten 1.0
  379.  * @uses register_sidebar
  380.  */
  381. function twentyten_widgets_init() {
  382.         // Area 1, located at the top of the sidebar.
  383.         register_sidebar( array(
  384.                 'name' => __( 'Primary Widget Area', 'twentyten' ),
  385.                 'id' => 'primary-widget-area',
  386.                 'description' => __( 'Add widgets here to appear in your sidebar.', 'twentyten' ),
  387.                 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  388.                 'after_widget' => '</li>',
  389.                 'before_title' => '<h3 class="widget-title">',
  390.                 'after_title' => '</h3>',
  391.         ) );
  392.  
  393.         // Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
  394.         register_sidebar( array(
  395.                 'name' => __( 'Secondary Widget Area', 'twentyten' ),
  396.                 'id' => 'secondary-widget-area',
  397.                 'description' => __( 'An optional secondary widget area, displays below the primary widget area in your sidebar.', 'twentyten' ),
  398.                 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  399.                 'after_widget' => '</li>',
  400.                 'before_title' => '<h3 class="widget-title">',
  401.                 'after_title' => '</h3>',
  402.         ) );
  403.  
  404.         // Area 3, located in the footer. Empty by default.
  405.         register_sidebar( array(
  406.                 'name' => __( 'First Footer Widget Area', 'twentyten' ),
  407.                 'id' => 'first-footer-widget-area',
  408.                 'description' => __( 'An optional widget area for your site footer.', 'twentyten' ),
  409.                 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  410.                 'after_widget' => '</li>',
  411.                 'before_title' => '<h3 class="widget-title">',
  412.                 'after_title' => '</h3>',
  413.         ) );
  414.  
  415.         // Area 4, located in the footer. Empty by default.
  416.         register_sidebar( array(
  417.                 'name' => __( 'Second Footer Widget Area', 'twentyten' ),
  418.                 'id' => 'second-footer-widget-area',
  419.                 'description' => __( 'An optional widget area for your site footer.', 'twentyten' ),
  420.                 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  421.                 'after_widget' => '</li>',
  422.                 'before_title' => '<h3 class="widget-title">',
  423.                 'after_title' => '</h3>',
  424.         ) );
  425.  
  426.         // Area 5, located in the footer. Empty by default.
  427.         register_sidebar( array(
  428.                 'name' => __( 'Third Footer Widget Area', 'twentyten' ),
  429.                 'id' => 'third-footer-widget-area',
  430.                 'description' => __( 'An optional widget area for your site footer.', 'twentyten' ),
  431.                 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  432.                 'after_widget' => '</li>',
  433.                 'before_title' => '<h3 class="widget-title">',
  434.                 'after_title' => '</h3>',
  435.         ) );
  436.  
  437.         // Area 6, located in the footer. Empty by default.
  438.         register_sidebar( array(
  439.                 'name' => __( 'Fourth Footer Widget Area', 'twentyten' ),
  440.                 'id' => 'fourth-footer-widget-area',
  441.                 'description' => __( 'An optional widget area for your site footer.', 'twentyten' ),
  442.                 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  443.                 'after_widget' => '</li>',
  444.                 'before_title' => '<h3 class="widget-title">',
  445.                 'after_title' => '</h3>',
  446.         ) );
  447. }
  448. /** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */
  449. add_action( 'widgets_init', 'twentyten_widgets_init' );
  450.  
  451. /**
  452.  * Removes the default styles that are packaged with the Recent Comments widget.
  453.  *
  454.  * To override this in a child theme, remove the filter and optionally add your own
  455.  * function tied to the widgets_init action hook.
  456.  *
  457.  * This function uses a filter (show_recent_comments_widget_style) new in WordPress 3.1
  458.  * to remove the default style. Using Twenty Ten 1.2 in WordPress 3.0 will show the styles,
  459.  * but they won't have any effect on the widget in default Twenty Ten styling.
  460.  *
  461.  * @since Twenty Ten 1.0
  462.  */
  463. function twentyten_remove_recent_comments_style() {
  464.         add_filter( 'show_recent_comments_widget_style', '__return_false' );
  465. }
  466. add_action( 'widgets_init', 'twentyten_remove_recent_comments_style' );
  467.  
  468. if ( ! function_exists( 'twentyten_posted_on' ) ) :
  469. /**
  470.  * Prints HTML with meta information for the current post-date/time and author.
  471.  *
  472.  * @since Twenty Ten 1.0
  473.  */
  474. function twentyten_posted_on() {
  475.         printf( __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'twentyten' ),
  476.                 'meta-prep meta-prep-author',
  477.                 sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
  478.                         get_permalink(),
  479.                         esc_attr( get_the_time() ),
  480.                         get_the_date()
  481.                 ),
  482.                 sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
  483.                         get_author_posts_url( get_the_author_meta( 'ID' ) ),
  484.                         esc_attr( sprintf( __( 'View all posts by %s', 'twentyten' ), get_the_author() ) ),
  485.                         get_the_author()
  486.                 )
  487.         );
  488. }
  489. endif;
  490.  
  491. if ( ! function_exists( 'twentyten_posted_in' ) ) :
  492. /**
  493.  * Prints HTML with meta information for the current post (category, tags and permalink).
  494.  *
  495.  * @since Twenty Ten 1.0
  496.  */
  497. function twentyten_posted_in() {
  498.         // Retrieves tag list of current post, separated by commas.
  499.         $tag_list = get_the_tag_list( '', ', ' );
  500.         if ( $tag_list ) {
  501.                 $posted_in = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
  502.         } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
  503.                 $posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
  504.         } else {
  505.                 $posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
  506.         }
  507.         // Prints the string, replacing the placeholders.
  508.         printf(
  509.                 $posted_in,
  510.                 get_the_category_list( ', ' ),
  511.                 $tag_list,
  512.                 get_permalink(),
  513.                 the_title_attribute( 'echo=0' )
  514.         );
  515. }
  516. endif;
  517.  
  518. /**
  519.  * Retrieves the IDs for images in a gallery.
  520.  *
  521.  * @uses get_post_galleries() first, if available. Falls back to shortcode parsing,
  522.  * then as last option uses a get_posts() call.
  523.  *
  524.  * @since Twenty Ten 1.6.
  525.  *
  526.  * @return array List of image IDs from the post gallery.
  527.  */
  528. function twentyten_get_gallery_images() {
  529.         $images = array();
  530.  
  531.         if ( function_exists( 'get_post_galleries' ) ) {
  532.                 $galleries = get_post_galleries( get_the_ID(), false );
  533.                 if ( isset( $galleries[0]['ids'] ) )
  534.                         $images = explode( ',', $galleries[0]['ids'] );
  535.         } else {
  536.                 $pattern = get_shortcode_regex();
  537.                 preg_match( "/$pattern/s", get_the_content(), $match );
  538.                 $atts = shortcode_parse_atts( $match[3] );
  539.                 if ( isset( $atts['ids'] ) )
  540.                         $images = explode( ',', $atts['ids'] );
  541.         }
  542.  
  543.         if ( ! $images ) {
  544.                 $images = get_posts( array(
  545.                         'fields'         => 'ids',
  546.                         'numberposts'    => 999,
  547.                         'order'          => 'ASC',
  548.                         'orderby'        => 'menu_order',
  549.                         'post_mime_type' => 'image',
  550.                         'post_parent'    => get_the_ID(),
  551.                         'post_type'      => 'attachment',
  552.                 ) );
  553.         }
  554.  
  555.         return $images;
  556. }
  557.  
  558.  
  559. //Save the extra comment field value kaas
  560. function bcw_handle_comment5($id) {
  561.   if (array_key_exists('kaas', $_POST))
  562.     update_comment_meta( $id, 'bcw_kaas', $_POST['kaas']);
  563.   if (array_key_exists('vlees', $_POST))
  564.     update_comment_meta( $id, 'bcw_vlees', $_POST['vlees']);
  565.   //keep adding more if--updates below as needed
  566. }
  567. add_action('wp_insert_comment', 'bcw_handle_comment5');
  568.  
  569. //Alter comment results if not admin to only have current user's comments
  570. //Place on functions.php
  571. add_filter('comments_array', 'bcw_current_user_comments');
  572. function bcw_current_user_comments( $comments ) {
  573.   if ( ! current_user_can('moderate_comments')) {
  574.     $comments = array_merge( array_filter( $comments, function( $comment ) {
  575.       if ( $comment->user_id == get_current_user_id() ) return true;
  576.       return;
  577.     }));
  578.   }
  579.   return $comments;
  580. }
  581.  
  582. //adjust comment count for single page visibility
  583. add_filter('get_comments_number', 'bcw_adjust_comment_count');
  584. function bcw_adjust_comment_count( $count ) {
  585.         global $wp_query;
  586.         if ( !is_single()) return $count;
  587.         return $wp_query->comment_count;
  588. }
  589.  
  590. // Front end comment delete
  591. add_action('init', 'bcw_front_delete');
  592. function bcw_front_delete() {
  593.         if (array_key_exists('bcw_task', $_GET)) {
  594.                 if ('del' == $_GET['bcw_task']) {
  595.                         check_admin_referer('del-comment');             //only accept valid requests
  596.                         global $wpdb;
  597.                         if ( current_user_can('moderate_comments') || $_GET['user_id'] == get_current_user_id()) {
  598.                                 wp_set_comment_status( $_GET['com_id'], 'trash');
  599.                                 // delete all associated meta
  600.                                 $wpdb->delete( $wpdb->commentmeta, array('comment_id' => $_GET['com_id']));
  601.                         }
  602.                 }
  603.         }
  604.         return;
  605. }
clone this paste RAW Paste Data