functions.php 19 KB

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