functions.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  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(); <strong>deprecated</strong> since version 3.4.0!
  112. add_theme_support( 'custom-background');
  113. // Your changeable header business starts here
  114. define( 'HEADER_TEXTCOLOR', '' );
  115. // No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
  116. define( 'HEADER_IMAGE', '%s/images/headers/forestfloor.jpg' );
  117. // The height and width of your custom header. You can hook into the theme's own filters to change these values.
  118. // Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values.
  119. define('HEADER_IMAGE_WIDTH', apply_filters('kirby_header_image_width', '840'));
  120. define('HEADER_IMAGE_HEIGHT', apply_filters('kirby_header_image_height', '254'));
  121. // We'll be using post thumbnails for custom header images on posts and pages.
  122. // We want them to be 940 pixels wide by 198 pixels tall (larger images will be auto-cropped to fit).
  123. set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
  124. // Don't support text inside the header image.
  125. define( 'NO_HEADER_TEXT', true );
  126. // Add a way for the custom header to be styled in the admin panel that controls
  127. // custom headers. See twentyten_admin_header_style(), below.
  128. //add_custom_image_header( '', 'twentyten_admin_header_style' );<strong>deprecated</strong> since version 3.4.0!
  129. add_theme_support( 'custom-header');
  130. // ... and thus ends the changeable header business.
  131. // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
  132. register_default_headers( array (
  133. 'berries' => array (
  134. 'url' => '%s/images/headers/berries.jpg',
  135. 'thumbnail_url' => '%s/images/headers/berries-thumbnail.jpg',
  136. 'description' => __( 'Berries', 'twentyten' )
  137. ),
  138. 'cherryblossom' => array (
  139. 'url' => '%s/images/headers/cherryblossoms.jpg',
  140. 'thumbnail_url' => '%s/images/headers/cherryblossoms-thumbnail.jpg',
  141. 'description' => __( 'Cherry Blossoms', 'twentyten' )
  142. ),
  143. 'concave' => array (
  144. 'url' => '%s/images/headers/concave.jpg',
  145. 'thumbnail_url' => '%s/images/headers/concave-thumbnail.jpg',
  146. 'description' => __( 'Concave', 'twentyten' )
  147. ),
  148. 'fern' => array (
  149. 'url' => '%s/images/headers/fern.jpg',
  150. 'thumbnail_url' => '%s/images/headers/fern-thumbnail.jpg',
  151. 'description' => __( 'Fern', 'twentyten' )
  152. ),
  153. 'forestfloor' => array (
  154. 'url' => '%s/images/headers/forestfloor.jpg',
  155. 'thumbnail_url' => '%s/images/headers/forestfloor-thumbnail.jpg',
  156. 'description' => __( 'Forest Floor', 'twentyten' )
  157. ),
  158. 'inkwell' => array (
  159. 'url' => '%s/images/headers/inkwell.jpg',
  160. 'thumbnail_url' => '%s/images/headers/inkwell-thumbnail.jpg',
  161. 'description' => __( 'Inkwell', 'twentyten' )
  162. ),
  163. 'path' => array (
  164. 'url' => '%s/images/headers/path.jpg',
  165. 'thumbnail_url' => '%s/images/headers/path-thumbnail.jpg',
  166. 'description' => __( 'Path', 'twentyten' )
  167. ),
  168. 'sunset' => array (
  169. 'url' => '%s/images/headers/sunset.jpg',
  170. 'thumbnail_url' => '%s/images/headers/sunset-thumbnail.jpg',
  171. 'description' => __( 'Sunset', 'twentyten' )
  172. )
  173. ) );
  174. }
  175. if ( ! function_exists( 'twentyten_admin_header_style' ) ) :
  176. /**
  177. * Styles the header image displayed on the Appearance > Header admin panel.
  178. *
  179. * Referenced via add_custom_image_header() in twentyten_setup().
  180. *
  181. * @since 3.0.0
  182. */
  183. function twentyten_admin_header_style() {
  184. ?>
  185. <style type="text/css">
  186. #headimg {
  187. height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
  188. width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
  189. }
  190. #headimg h1, #headimg #desc {
  191. display: none;
  192. }
  193. </style>
  194. <?php
  195. }
  196. endif;
  197. if ( ! function_exists( 'twentyten_the_page_number' ) ) :
  198. /**
  199. * Prints the page number currently being browsed, with a vertical bar before it.
  200. *
  201. * Used in Twenty Ten's header.php to add the page number to the <title> HTML tag.
  202. *
  203. * @since 3.0.0
  204. */
  205. function twentyten_the_page_number() {
  206. global $paged; // Contains page number.
  207. if ( $paged >= 2 )
  208. echo ' | ' . sprintf( __( 'Page %s' , 'twentyten' ), $paged );
  209. }
  210. endif;
  211. /**
  212. * Sets the post excerpt length to 40 characters.
  213. *
  214. * To override this length in a child theme, remove the filter and add your own
  215. * function tied to the excerpt_length filter hook.
  216. *
  217. * @return int
  218. */
  219. function twentyten_excerpt_length( $length ) {
  220. return 40;
  221. }
  222. add_filter( 'excerpt_length', 'twentyten_excerpt_length' );
  223. /**
  224. * Sets the "read more" link to something pretty.
  225. *
  226. * To override this link in a child theme, remove the filter and add your own
  227. * function tied to the excerpt_more filter hook.
  228. *
  229. * @since 3.0.0
  230. * @return string A pretty 'Continue reading' link.
  231. */
  232. function twentyten_excerpt_more( $more ) {
  233. return '&nbsp;&hellip; <a href="'. get_permalink() . '">' . __('Continue&nbsp;reading&nbsp;<span class="meta-nav">&rarr;</span>', 'twentyten') . '</a>';
  234. }
  235. add_filter( 'excerpt_more', 'twentyten_excerpt_more' );
  236. function new_excerpt_length($length) {
  237. return 176;
  238. }
  239. add_filter('excerpt_length', 'new_excerpt_length');
  240. /**
  241. * Remove inline styles printed when the gallery shortcode is used.
  242. *
  243. * Galleries are styled by the theme in Twenty Ten's style.css.
  244. *
  245. * @return string The gallery style filter, with the styles themselves removed.
  246. */
  247. function twentyten_remove_gallery_css( $css ) {
  248. return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
  249. }
  250. add_filter( 'gallery_style', 'twentyten_remove_gallery_css' );
  251. if ( ! function_exists( 'twentyten_comment' ) ) :
  252. /**
  253. * Template for comments and pingbacks.
  254. *
  255. * To override this walker in a child theme without modifying the comments template
  256. * simply create your own twentyten_comment(), and that function will be used instead.
  257. *
  258. * Used as a callback by wp_list_comments() for displaying the comments.
  259. *
  260. * @since 3.0.0
  261. */
  262. function twentyten_comment( $comment, $args, $depth ) {
  263. $GLOBALS ['comment'] = $comment; ?>
  264. <?php if ( '' == $comment->comment_type ) : ?>
  265. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  266. <div id="comment-<?php comment_ID(); ?>">
  267. <div class="comment-author vcard">
  268. <?php echo get_avatar( $comment, 40 ); ?>
  269. <?php printf( __( '<cite class="fn">%s</cite> <span class="says">says:</span>', 'twentyten' ), get_comment_author_link() ); ?>
  270. </div>
  271. <?php if ( $comment->comment_approved == '0' ) : ?>
  272. <em><?php _e( 'Your comment is awaiting moderation.', 'twentyten' ); ?></em>
  273. <br />
  274. <?php endif; ?>
  275. <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>
  276. <div class="comment-body"><?php comment_text(); ?></div>
  277. <div class="reply">
  278. <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  279. </div>
  280. </div>
  281. <?php else : ?>
  282. <li class="post pingback">
  283. <p><?php _e( 'Pingback: ', 'twentyten' ); ?><?php comment_author_link(); ?><?php edit_comment_link ( __('edit', 'twentyten'), '&nbsp;&nbsp;', '' ); ?></p>
  284. <?php endif;
  285. }
  286. endif;
  287. if ( ! function_exists( 'twentyten_cat_list' ) ) :
  288. /**
  289. * Returns the list of categories
  290. *
  291. * Returns the list of categories based on if we are or are
  292. * not browsing a category archive page.
  293. *
  294. * @uses twentyten_term_list
  295. *
  296. * @return string
  297. */
  298. function twentyten_cat_list() {
  299. return twentyten_term_list( 'category', ', ', __( 'Posted in %s', 'twentyten' ), __( 'Also posted in %s', 'twentyten' ) );
  300. }
  301. endif;
  302. if ( ! function_exists( 'twentyten_tag_list' ) ) :
  303. /**
  304. * Returns the list of tags
  305. *
  306. * Returns the list of tags based on if we are or are not
  307. * browsing a tag archive page
  308. *
  309. * @uses twentyten_term_list
  310. *
  311. * @return string
  312. */
  313. function twentyten_tag_list() {
  314. return twentyten_term_list( 'post_tag', ', ', __( 'Tagged %s', 'twentyten' ), __( 'Also tagged %s', 'twentyten' ) );
  315. }
  316. endif;
  317. if ( ! function_exists( 'twentyten_term_list' ) ) :
  318. /**
  319. * Returns the list of taxonomy items in multiple ways
  320. *
  321. * Returns the list of taxonomy items differently based on
  322. * if we are browsing a term archive page or a different
  323. * type of page. If browsing a term archive page and the
  324. * post has no other taxonomied terms, it returns empty
  325. *
  326. * @return string
  327. */
  328. function twentyten_term_list( $taxonomy, $glue = ', ', $text = '', $also_text = '' ) {
  329. global $wp_query, $post;
  330. $current_term = $wp_query->get_queried_object();
  331. $terms = wp_get_object_terms( $post->ID, $taxonomy );
  332. // If we're viewing a Taxonomy page..
  333. if ( isset( $current_term->taxonomy ) && $taxonomy == $current_term->taxonomy ) {
  334. // Remove the term from display.
  335. foreach ( (array) $terms as $key => $term ) {
  336. if ( $term->term_id == $current_term->term_id ) {
  337. unset( $terms[$key] );
  338. break;
  339. }
  340. }
  341. // Change to Also text as we've now removed something from the terms list.
  342. $text = $also_text;
  343. }
  344. $tlist = array();
  345. $rel = 'category' == $taxonomy ? 'rel="category"' : 'rel="tag"';
  346. foreach ( (array) $terms as $term ) {
  347. $tlist[] = '<a href="' . get_term_link( $term, $taxonomy ) . '" title="' . esc_attr( sprintf( __( 'View all posts in %s', 'twentyten' ), $term->name ) ) . '" ' . $rel . '>' . $term->name . '</a>';
  348. }
  349. if ( ! empty( $tlist ) )
  350. return sprintf( $text, join( $glue, $tlist ) );
  351. return '';
  352. }
  353. endif;
  354. /**
  355. * Register widgetized areas, including two sidebars and four widget-ready columns in the footer.
  356. *
  357. * To override twentyten_widgets_init() in a child theme, remove the action hook and add your own
  358. * function tied to the init hook.
  359. * @uses register_sidebar
  360. */
  361. function twentyten_widgets_init() {
  362. // Area 1
  363. register_sidebar( array (
  364. 'name' => 'Primary Widget Area',
  365. 'id' => 'primary-widget-area',
  366. 'description' => __( 'The primary widget area' , 'twentyten' ),
  367. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  368. 'after_widget' => "</li>",
  369. 'before_title' => '<h3 class="widget-title">',
  370. 'after_title' => '</h3>',
  371. ) );
  372. // Area 2
  373. register_sidebar( array (
  374. 'name' => 'Secondary Widget Area',
  375. 'id' => 'secondary-widget-area',
  376. 'description' => __( 'The secondary widget area' , 'twentyten' ),
  377. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  378. 'after_widget' => "</li>",
  379. 'before_title' => '<h3 class="widget-title">',
  380. 'after_title' => '</h3>',
  381. ) );
  382. // Area 3
  383. register_sidebar( array (
  384. 'name' => 'First Footer Widget Area',
  385. 'id' => 'first-footer-widget-area',
  386. 'description' => __( 'The first footer widget area' , '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. // Area 4
  393. register_sidebar( array (
  394. 'name' => 'Second Footer Widget Area',
  395. 'id' => 'second-footer-widget-area',
  396. 'description' => __( 'The second footer widget area' , 'twentyten' ),
  397. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  398. 'after_widget' => "</li>",
  399. 'before_title' => '<h3 class="widget-title">',
  400. 'after_title' => '</h3>',
  401. ) );
  402. // Area 5
  403. register_sidebar( array (
  404. 'name' => 'Third Footer Widget Area',
  405. 'id' => 'third-footer-widget-area',
  406. 'description' => __( 'The third footer widget area' , 'twentyten' ),
  407. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  408. 'after_widget' => "</li>",
  409. 'before_title' => '<h3 class="widget-title">',
  410. 'after_title' => '</h3>',
  411. ) );
  412. // Area 6
  413. register_sidebar( array (
  414. 'name' => 'Fourth Footer Widget Area',
  415. 'id' => 'fourth-footer-widget-area',
  416. 'description' => __( 'The fourth footer widget area' , 'twentyten' ),
  417. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  418. 'after_widget' => "</li>",
  419. 'before_title' => '<h3 class="widget-title">',
  420. 'after_title' => '</h3>',
  421. ) );
  422. }
  423. add_action( 'init', 'twentyten_widgets_init' );
  424. // add last modified column to posts
  425. add_action ( 'manage_posts_custom_column', 'rkv_post_columns_data', 10, 2 );
  426. add_filter ( 'manage_edit-post_columns', 'rkv_post_columns_display' );
  427. function rkv_post_columns_data( $column, $post_id ) {
  428. switch ( $column ) {
  429. case 'modified':
  430. $m_orig = get_post_field( 'post_modified', $post_id, 'raw' );
  431. $m_stamp = strtotime( $m_orig );
  432. $modified = date('n/j/y @ g:i a', $m_stamp );
  433. $modr_id = get_post_meta( $post_id, '_edit_last', true );
  434. $auth_id = get_post_field( 'post_author', $post_id, 'raw' );
  435. $user_id = !empty( $modr_id ) ? $modr_id : $auth_id;
  436. $user_info = get_userdata( $user_id );
  437. echo '<p class="mod-date">';
  438. echo '<em>'.$modified.'</em><br />';
  439. echo 'by <strong>'.$user_info->display_name.'<strong>';
  440. echo '</p>';
  441. break;
  442. // end all case breaks
  443. }
  444. }
  445. function rkv_post_columns_display( $columns ) {
  446. $columns['modified'] = 'Last Modified';
  447. return $columns;
  448. }
  449. // hide wp update nags
  450. //add_action('after_setup_theme','remove_core_updates');
  451. function remove_core_updates()
  452. {
  453. if(! current_user_can('update_core')){return;}
  454. add_action('init', create_function('$a',"remove_action( 'init', 'wp_version_check' );"),2);
  455. add_filter('pre_option_update_core','__return_null');
  456. add_filter('pre_site_transient_update_core','__return_null');
  457. }