functions.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. <?php
  2. function head_scripts() {
  3. $scriptdir_start = "\t";
  4. $scriptdir_start .= '<script type="text/javascript" src="';
  5. $scriptdir_start .= get_bloginfo('template_directory');
  6. $scriptdir_start .= '/js/';
  7. $scriptdir_end = '"></script>';
  8. $scripts .= $scriptdir_start . 'ui.js' . $scriptdir_end . "\n";
  9. print apply_filters('head_scripts', $scripts);
  10. }
  11. add_action('wp_head','head_scripts');
  12. remove_action('wp_head', 'rsd_link');
  13. remove_action('wp_head', 'wlwmanifest_link');
  14. remove_action('wp_head', 'wp_generator');
  15. remove_action( 'wp_head', 'feed_links_extra', 3 );
  16. remove_action( 'wp_head', 'feed_links', 2 );
  17. remove_action( 'wp_head', 'index_rel_link' );
  18. remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );
  19. remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );
  20. remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 );
  21. remove_action('init', 'wp_admin_bar_init');
  22. add_action( 'show_admin_bar', '__return_false' );
  23. /**
  24. * TwentyTen functions and definitions
  25. *
  26. * Sets up the theme and provides some helper functions. Some helper functions
  27. * are used in the theme as custom template tags. Others are attached to action and
  28. * filter hooks in WordPress to change core functionality.
  29. *
  30. * The first function, twentyten_setup(), sets up the theme by registering support
  31. * for various features in WordPress, such as post thumbnails, navigation menus, and the like.
  32. *
  33. * When using a child theme (see http://codex.wordpress.org/Theme_Development), you can
  34. * override certain functions (those wrapped in a function_exists() call) by defining
  35. * them first in your child theme's functions.php file. The child theme's functions.php
  36. * file is included before the parent theme's file, so the child theme functions would
  37. * be used.
  38. *
  39. * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
  40. * to a filter or action hook. The hook can be removed by using remove_action() or
  41. * remove_filter() and you can attach your own function to the hook.
  42. *
  43. * In this example, since both hooks are attached using the default priority (10), the first
  44. * one attached (which would be the child theme) will run. We can remove the parent theme's
  45. * hook only after it is attached, which means we need to wait until setting up the child theme:
  46. *
  47. * <code>
  48. * add_action( 'after_setup_theme', 'my_child_theme_setup' );
  49. * function my_child_theme_setup() {
  50. * // We are replacing twentyten_setup() with my_child_theme_setup()
  51. * remove_action( 'after_setup_theme', 'twentyten_setup' );
  52. * // We are providing our own filter for excerpt_length (or using the unfiltered value)
  53. * remove_filter( 'excerpt_length', 'twentyten_excerpt_length' );
  54. * ...
  55. * }
  56. * </code>
  57. *
  58. * For more information on hooks, see http://codex.wordpress.org/Plugin_API.
  59. *
  60. * @package WordPress
  61. * @subpackage Twenty Ten
  62. * @since 3.0.0
  63. */
  64. /**
  65. * Set the content width based on the theme's design and stylesheet.
  66. *
  67. * Used to set the width of images and content. Should be equal to the width the theme
  68. * is designed for, generally via the style.css stylesheet.
  69. */
  70. if ( ! isset( $content_width ) )
  71. $content_width = 640;
  72. /** Tell WordPress to run twentyten_setup() when the 'after_setup_theme' hook is run. */
  73. add_action( 'after_setup_theme', 'twentyten_setup' );
  74. /**
  75. * Sets up theme defaults and registers support for various WordPress features.
  76. *
  77. * Note that this function is hooked into the after_setup_theme hook, which runs
  78. * before the init hook. The init hook is too late for some features, such as indicating
  79. * support post thumbnails.
  80. *
  81. * To override twentyten_setup() in a child theme, remove the action hook and add your own
  82. * function tied to the after_setup_theme hook.
  83. *
  84. * @uses add_theme_support() To add support for post thumbnails, navigation menus, and automatic feed links.
  85. * @uses add_custom_background() To add support for a custom background.
  86. * @uses add_editor_style() To style the visual editor.
  87. * @uses load_theme_textdomain() For translation/localization support.
  88. * @uses add_custom_image_header() To add support for a custom header.
  89. * @uses register_default_headers() To register the default custom header images provided with the theme.
  90. * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
  91. *
  92. * @since 3.0.0
  93. */
  94. function twentyten_setup() {
  95. // This theme styles the visual editor with editor-style.css to match the theme style.
  96. add_editor_style();
  97. // This theme uses post thumbnails
  98. add_theme_support( 'post-thumbnails' );
  99. // This theme uses wp_nav_menu()
  100. add_theme_support( 'nav-menus' );
  101. // Add default posts and comments RSS feed links to head
  102. add_theme_support( 'automatic-feed-links' );
  103. // Make theme available for translation
  104. // Translations can be filed in the /languages/ directory
  105. load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' );
  106. $locale = get_locale();
  107. $locale_file = TEMPLATEPATH . "/languages/$locale.php";
  108. if ( is_readable( $locale_file ) )
  109. require_once( $locale_file );
  110. // This theme allows users to set a custom background
  111. add_custom_background();
  112. // Your changeable header business starts here
  113. define( 'HEADER_TEXTCOLOR', '' );
  114. // No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
  115. define( 'HEADER_IMAGE', '%s/images/headers/forestfloor.jpg' );
  116. // The height and width of your custom header. You can hook into the theme's own filters to change these values.
  117. // Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values.
  118. define('HEADER_IMAGE_WIDTH', apply_filters('kirby_header_image_width', '840'));
  119. define('HEADER_IMAGE_HEIGHT', apply_filters('kirby_header_image_height', '254'));
  120. // We'll be using post thumbnails for custom header images on posts and pages.
  121. // We want them to be 940 pixels wide by 198 pixels tall (larger images will be auto-cropped to fit).
  122. set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
  123. // Don't support text inside the header image.
  124. define( 'NO_HEADER_TEXT', true );
  125. // Add a way for the custom header to be styled in the admin panel that controls
  126. // custom headers. See twentyten_admin_header_style(), below.
  127. add_custom_image_header( '', 'twentyten_admin_header_style' );
  128. // ... and thus ends the changeable header business.
  129. // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
  130. register_default_headers( array (
  131. 'berries' => array (
  132. 'url' => '%s/images/headers/berries.jpg',
  133. 'thumbnail_url' => '%s/images/headers/berries-thumbnail.jpg',
  134. 'description' => __( 'Berries', 'twentyten' )
  135. ),
  136. 'cherryblossom' => array (
  137. 'url' => '%s/images/headers/cherryblossoms.jpg',
  138. 'thumbnail_url' => '%s/images/headers/cherryblossoms-thumbnail.jpg',
  139. 'description' => __( 'Cherry Blossoms', 'twentyten' )
  140. ),
  141. 'concave' => array (
  142. 'url' => '%s/images/headers/concave.jpg',
  143. 'thumbnail_url' => '%s/images/headers/concave-thumbnail.jpg',
  144. 'description' => __( 'Concave', 'twentyten' )
  145. ),
  146. 'fern' => array (
  147. 'url' => '%s/images/headers/fern.jpg',
  148. 'thumbnail_url' => '%s/images/headers/fern-thumbnail.jpg',
  149. 'description' => __( 'Fern', 'twentyten' )
  150. ),
  151. 'forestfloor' => array (
  152. 'url' => '%s/images/headers/forestfloor.jpg',
  153. 'thumbnail_url' => '%s/images/headers/forestfloor-thumbnail.jpg',
  154. 'description' => __( 'Forest Floor', 'twentyten' )
  155. ),
  156. 'inkwell' => array (
  157. 'url' => '%s/images/headers/inkwell.jpg',
  158. 'thumbnail_url' => '%s/images/headers/inkwell-thumbnail.jpg',
  159. 'description' => __( 'Inkwell', 'twentyten' )
  160. ),
  161. 'path' => array (
  162. 'url' => '%s/images/headers/path.jpg',
  163. 'thumbnail_url' => '%s/images/headers/path-thumbnail.jpg',
  164. 'description' => __( 'Path', 'twentyten' )
  165. ),
  166. 'sunset' => array (
  167. 'url' => '%s/images/headers/sunset.jpg',
  168. 'thumbnail_url' => '%s/images/headers/sunset-thumbnail.jpg',
  169. 'description' => __( 'Sunset', 'twentyten' )
  170. )
  171. ) );
  172. }
  173. if ( ! function_exists( 'twentyten_admin_header_style' ) ) :
  174. /**
  175. * Styles the header image displayed on the Appearance > Header admin panel.
  176. *
  177. * Referenced via add_custom_image_header() in twentyten_setup().
  178. *
  179. * @since 3.0.0
  180. */
  181. function twentyten_admin_header_style() {
  182. ?>
  183. <style type="text/css">
  184. #headimg {
  185. height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
  186. width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
  187. }
  188. #headimg h1, #headimg #desc {
  189. display: none;
  190. }
  191. </style>
  192. <?php
  193. }
  194. endif;
  195. if ( ! function_exists( 'twentyten_the_page_number' ) ) :
  196. /**
  197. * Prints the page number currently being browsed, with a vertical bar before it.
  198. *
  199. * Used in Twenty Ten's header.php to add the page number to the <title> HTML tag.
  200. *
  201. * @since 3.0.0
  202. */
  203. function twentyten_the_page_number() {
  204. global $paged; // Contains page number.
  205. if ( $paged >= 2 )
  206. echo ' | ' . sprintf( __( 'Page %s' , 'twentyten' ), $paged );
  207. }
  208. endif;
  209. /**
  210. * Sets the post excerpt length to 40 characters.
  211. *
  212. * To override this length in a child theme, remove the filter and add your own
  213. * function tied to the excerpt_length filter hook.
  214. *
  215. * @return int
  216. */
  217. function twentyten_excerpt_length( $length ) {
  218. return 40;
  219. }
  220. add_filter( 'excerpt_length', 'twentyten_excerpt_length' );
  221. /**
  222. * Sets the "read more" link to something pretty.
  223. *
  224. * To override this link in a child theme, remove the filter and add your own
  225. * function tied to the excerpt_more filter hook.
  226. *
  227. * @since 3.0.0
  228. * @return string A pretty 'Continue reading' link.
  229. */
  230. function twentyten_excerpt_more( $more ) {
  231. return '&nbsp;&hellip; <a href="'. get_permalink() . '">' . __('Continue&nbsp;reading&nbsp;<span class="meta-nav">&rarr;</span>', 'twentyten') . '</a>';
  232. }
  233. add_filter( 'excerpt_more', 'twentyten_excerpt_more' );
  234. function new_excerpt_length($length) {
  235. return 176;
  236. }
  237. add_filter('excerpt_length', 'new_excerpt_length');
  238. /**
  239. * Remove inline styles printed when the gallery shortcode is used.
  240. *
  241. * Galleries are styled by the theme in Twenty Ten's style.css.
  242. *
  243. * @return string The gallery style filter, with the styles themselves removed.
  244. */
  245. function twentyten_remove_gallery_css( $css ) {
  246. return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
  247. }
  248. add_filter( 'gallery_style', 'twentyten_remove_gallery_css' );
  249. if ( ! function_exists( 'twentyten_comment' ) ) :
  250. /**
  251. * Template for comments and pingbacks.
  252. *
  253. * To override this walker in a child theme without modifying the comments template
  254. * simply create your own twentyten_comment(), and that function will be used instead.
  255. *
  256. * Used as a callback by wp_list_comments() for displaying the comments.
  257. *
  258. * @since 3.0.0
  259. */
  260. function twentyten_comment( $comment, $args, $depth ) {
  261. $GLOBALS ['comment'] = $comment; ?>
  262. <?php if ( '' == $comment->comment_type ) : ?>
  263. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  264. <div id="comment-<?php comment_ID(); ?>">
  265. <div class="comment-author vcard">
  266. <?php echo get_avatar( $comment, 40 ); ?>
  267. <?php printf( __( '<cite class="fn">%s</cite> <span class="says">says:</span>', 'twentyten' ), get_comment_author_link() ); ?>
  268. </div>
  269. <?php if ( $comment->comment_approved == '0' ) : ?>
  270. <em><?php _e( 'Your comment is awaiting moderation.', 'twentyten' ); ?></em>
  271. <br />
  272. <?php endif; ?>
  273. <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"><?php printf( __( '%1$s at %2$s', 'twentyten' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'twentyten' ),' ','' ); ?></div>
  274. <div class="comment-body"><?php comment_text(); ?></div>
  275. <div class="reply">
  276. <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  277. </div>
  278. </div>
  279. <?php else : ?>
  280. <li class="post pingback">
  281. <p><?php _e( 'Pingback: ', 'twentyten' ); ?><?php comment_author_link(); ?><?php edit_comment_link ( __('edit', 'twentyten'), '&nbsp;&nbsp;', '' ); ?></p>
  282. <?php endif;
  283. }
  284. endif;
  285. if ( ! function_exists( 'twentyten_cat_list' ) ) :
  286. /**
  287. * Returns the list of categories
  288. *
  289. * Returns the list of categories based on if we are or are
  290. * not browsing a category archive page.
  291. *
  292. * @uses twentyten_term_list
  293. *
  294. * @return string
  295. */
  296. function twentyten_cat_list() {
  297. return twentyten_term_list( 'category', ', ', __( 'Posted in %s', 'twentyten' ), __( 'Also posted in %s', 'twentyten' ) );
  298. }
  299. endif;
  300. if ( ! function_exists( 'twentyten_tag_list' ) ) :
  301. /**
  302. * Returns the list of tags
  303. *
  304. * Returns the list of tags based on if we are or are not
  305. * browsing a tag archive page
  306. *
  307. * @uses twentyten_term_list
  308. *
  309. * @return string
  310. */
  311. function twentyten_tag_list() {
  312. return twentyten_term_list( 'post_tag', ', ', __( 'Tagged %s', 'twentyten' ), __( 'Also tagged %s', 'twentyten' ) );
  313. }
  314. endif;
  315. if ( ! function_exists( 'twentyten_term_list' ) ) :
  316. /**
  317. * Returns the list of taxonomy items in multiple ways
  318. *
  319. * Returns the list of taxonomy items differently based on
  320. * if we are browsing a term archive page or a different
  321. * type of page. If browsing a term archive page and the
  322. * post has no other taxonomied terms, it returns empty
  323. *
  324. * @return string
  325. */
  326. function twentyten_term_list( $taxonomy, $glue = ', ', $text = '', $also_text = '' ) {
  327. global $wp_query, $post;
  328. $current_term = $wp_query->get_queried_object();
  329. $terms = wp_get_object_terms( $post->ID, $taxonomy );
  330. // If we're viewing a Taxonomy page..
  331. if ( isset( $current_term->taxonomy ) && $taxonomy == $current_term->taxonomy ) {
  332. // Remove the term from display.
  333. foreach ( (array) $terms as $key => $term ) {
  334. if ( $term->term_id == $current_term->term_id ) {
  335. unset( $terms[$key] );
  336. break;
  337. }
  338. }
  339. // Change to Also text as we've now removed something from the terms list.
  340. $text = $also_text;
  341. }
  342. $tlist = array();
  343. $rel = 'category' == $taxonomy ? 'rel="category"' : 'rel="tag"';
  344. foreach ( (array) $terms as $term ) {
  345. $tlist[] = '<a href="' . get_term_link( $term, $taxonomy ) . '" title="' . esc_attr( sprintf( __( 'View all posts in %s', 'twentyten' ), $term->name ) ) . '" ' . $rel . '>' . $term->name . '</a>';
  346. }
  347. if ( ! empty( $tlist ) )
  348. return sprintf( $text, join( $glue, $tlist ) );
  349. return '';
  350. }
  351. endif;
  352. /**
  353. * Register widgetized areas, including two sidebars and four widget-ready columns in the footer.
  354. *
  355. * To override twentyten_widgets_init() in a child theme, remove the action hook and add your own
  356. * function tied to the init hook.
  357. * @uses register_sidebar
  358. */
  359. function twentyten_widgets_init() {
  360. // Area 1
  361. register_sidebar( array (
  362. 'name' => 'Primary Widget Area',
  363. 'id' => 'primary-widget-area',
  364. 'description' => __( 'The primary widget area' , 'twentyten' ),
  365. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  366. 'after_widget' => "</li>",
  367. 'before_title' => '<h3 class="widget-title">',
  368. 'after_title' => '</h3>',
  369. ) );
  370. // Area 2
  371. register_sidebar( array (
  372. 'name' => 'Secondary Widget Area',
  373. 'id' => 'secondary-widget-area',
  374. 'description' => __( 'The secondary widget area' , 'twentyten' ),
  375. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  376. 'after_widget' => "</li>",
  377. 'before_title' => '<h3 class="widget-title">',
  378. 'after_title' => '</h3>',
  379. ) );
  380. // Area 3
  381. register_sidebar( array (
  382. 'name' => 'First Footer Widget Area',
  383. 'id' => 'first-footer-widget-area',
  384. 'description' => __( 'The first footer widget area' , 'twentyten' ),
  385. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  386. 'after_widget' => "</li>",
  387. 'before_title' => '<h3 class="widget-title">',
  388. 'after_title' => '</h3>',
  389. ) );
  390. // Area 4
  391. register_sidebar( array (
  392. 'name' => 'Second Footer Widget Area',
  393. 'id' => 'second-footer-widget-area',
  394. 'description' => __( 'The second footer widget area' , 'twentyten' ),
  395. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  396. 'after_widget' => "</li>",
  397. 'before_title' => '<h3 class="widget-title">',
  398. 'after_title' => '</h3>',
  399. ) );
  400. // Area 5
  401. register_sidebar( array (
  402. 'name' => 'Third Footer Widget Area',
  403. 'id' => 'third-footer-widget-area',
  404. 'description' => __( 'The third footer widget area' , 'twentyten' ),
  405. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  406. 'after_widget' => "</li>",
  407. 'before_title' => '<h3 class="widget-title">',
  408. 'after_title' => '</h3>',
  409. ) );
  410. // Area 6
  411. register_sidebar( array (
  412. 'name' => 'Fourth Footer Widget Area',
  413. 'id' => 'fourth-footer-widget-area',
  414. 'description' => __( 'The fourth footer widget area' , 'twentyten' ),
  415. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  416. 'after_widget' => "</li>",
  417. 'before_title' => '<h3 class="widget-title">',
  418. 'after_title' => '</h3>',
  419. ) );
  420. }
  421. add_action( 'init', 'twentyten_widgets_init' );
  422. // add last modified column to posts
  423. add_action ( 'manage_posts_custom_column', 'rkv_post_columns_data', 10, 2 );
  424. add_filter ( 'manage_edit-post_columns', 'rkv_post_columns_display' );
  425. function rkv_post_columns_data( $column, $post_id ) {
  426. switch ( $column ) {
  427. case 'modified':
  428. $m_orig = get_post_field( 'post_modified', $post_id, 'raw' );
  429. $m_stamp = strtotime( $m_orig );
  430. $modified = date('n/j/y @ g:i a', $m_stamp );
  431. $modr_id = get_post_meta( $post_id, '_edit_last', true );
  432. $auth_id = get_post_field( 'post_author', $post_id, 'raw' );
  433. $user_id = !empty( $modr_id ) ? $modr_id : $auth_id;
  434. $user_info = get_userdata( $user_id );
  435. echo '<p class="mod-date">';
  436. echo '<em>'.$modified.'</em><br />';
  437. echo 'by <strong>'.$user_info->display_name.'<strong>';
  438. echo '</p>';
  439. break;
  440. // end all case breaks
  441. }
  442. }
  443. function rkv_post_columns_display( $columns ) {
  444. $columns['modified'] = 'Last Modified';
  445. return $columns;
  446. }
  447. // hide wp update nags
  448. add_action('after_setup_theme','remove_core_updates');
  449. function remove_core_updates()
  450. {
  451. if(! current_user_can('update_core')){return;}
  452. add_action('init', create_function('$a',"remove_action( 'init', 'wp_version_check' );"),2);
  453. add_filter('pre_option_update_core','__return_null');
  454. add_filter('pre_site_transient_update_core','__return_null');
  455. }