2005-02-07 07:46:41 +00:00
|
|
|
<?php
|
2007-12-25 20:48:01 +00:00
|
|
|
/**
|
|
|
|
* Sets up the default filters and actions for most
|
|
|
|
* of the WordPress hooks.
|
|
|
|
*
|
|
|
|
* If you need to remove a default hook, this file will
|
|
|
|
* give you the priority for which to use to remove the
|
|
|
|
* hook.
|
|
|
|
*
|
|
|
|
* Not all of the default hooks are found in default-filters.php
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
*/
|
2005-02-07 07:46:41 +00:00
|
|
|
|
2007-08-20 22:50:04 +00:00
|
|
|
// Strip, trim, kses, special chars for string saves
|
|
|
|
$filters = array('pre_term_name', 'pre_comment_author_name', 'pre_link_name', 'pre_link_target',
|
|
|
|
'pre_link_rel', 'pre_user_display_name', 'pre_user_first_name', 'pre_user_last_name',
|
|
|
|
'pre_user_nickname');
|
|
|
|
foreach ( $filters as $filter ) {
|
|
|
|
add_filter($filter, 'strip_tags');
|
|
|
|
add_filter($filter, 'trim');
|
|
|
|
add_filter($filter, 'wp_filter_kses');
|
|
|
|
add_filter($filter, 'wp_specialchars', 30);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Kses only for textarea saves
|
|
|
|
$filters = array('pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description');
|
|
|
|
foreach ( $filters as $filter ) {
|
|
|
|
add_filter($filter, 'wp_filter_kses');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Email
|
|
|
|
$filters = array('pre_comment_author_email', 'pre_user_email');
|
|
|
|
foreach ( $filters as $filter ) {
|
|
|
|
add_filter($filter, 'trim');
|
|
|
|
add_filter($filter, 'sanitize_email');
|
|
|
|
add_filter($filter, 'wp_filter_kses');
|
|
|
|
}
|
|
|
|
|
2007-10-03 16:16:55 +00:00
|
|
|
// Save URL
|
2007-08-20 22:50:04 +00:00
|
|
|
$filters = array('pre_comment_author_url', 'pre_user_url', 'pre_link_url', 'pre_link_image',
|
2007-10-03 16:16:55 +00:00
|
|
|
'pre_link_rss');
|
|
|
|
foreach ( $filters as $filter ) {
|
|
|
|
add_filter($filter, 'strip_tags');
|
|
|
|
add_filter($filter, 'trim');
|
|
|
|
add_filter($filter, 'sanitize_url');
|
|
|
|
add_filter($filter, 'wp_filter_kses');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Display URL
|
|
|
|
$filters = array('user_url', 'link_url', 'link_image', 'link_rss', 'comment_url');
|
2007-08-20 22:50:04 +00:00
|
|
|
foreach ( $filters as $filter ) {
|
|
|
|
add_filter($filter, 'strip_tags');
|
|
|
|
add_filter($filter, 'trim');
|
|
|
|
add_filter($filter, 'clean_url');
|
|
|
|
add_filter($filter, 'wp_filter_kses');
|
|
|
|
}
|
2006-05-26 22:47:13 +00:00
|
|
|
|
2007-08-24 14:44:26 +00:00
|
|
|
// Slugs
|
|
|
|
$filters = array('pre_term_slug');
|
|
|
|
foreach ( $filters as $filter ) {
|
|
|
|
add_filter($filter, 'sanitize_title');
|
|
|
|
}
|
|
|
|
|
2008-02-02 19:22:14 +00:00
|
|
|
// Keys
|
|
|
|
$filters = array('pre_post_type');
|
|
|
|
foreach ( $filters as $filter ) {
|
|
|
|
add_filter($filter, 'sanitize_user');
|
|
|
|
}
|
|
|
|
|
2005-02-07 07:46:41 +00:00
|
|
|
// Places to balance tags on input
|
2007-08-20 22:50:04 +00:00
|
|
|
$filters = array('content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content');
|
|
|
|
foreach ( $filters as $filter ) {
|
|
|
|
add_filter( $filter, 'balanceTags', 50);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Format strings for display.
|
2007-09-20 18:23:33 +00:00
|
|
|
$filters = array('comment_author', 'term_name', 'link_name', 'link_description',
|
2007-09-05 03:11:04 +00:00
|
|
|
'link_notes', 'bloginfo', 'wp_title');
|
2007-08-20 22:50:04 +00:00
|
|
|
foreach ( $filters as $filter ) {
|
|
|
|
add_filter($filter, 'wptexturize');
|
|
|
|
add_filter($filter, 'convert_chars');
|
|
|
|
add_filter($filter, 'wp_specialchars');
|
|
|
|
}
|
|
|
|
|
2007-09-20 18:23:33 +00:00
|
|
|
// Format text area for display.
|
|
|
|
$filters = array('term_description');
|
|
|
|
foreach ( $filters as $filter ) {
|
|
|
|
add_filter($filter, 'wptexturize');
|
|
|
|
add_filter($filter, 'convert_chars');
|
|
|
|
add_filter($filter, 'wpautop');
|
|
|
|
}
|
|
|
|
|
2007-08-29 21:10:20 +00:00
|
|
|
// Format for RSS
|
|
|
|
$filters = array('term_name_rss');
|
|
|
|
foreach ( $filters as $filter ) {
|
|
|
|
add_filter($filter, 'convert_chars');
|
|
|
|
}
|
|
|
|
|
2007-08-20 22:50:04 +00:00
|
|
|
// Display filters
|
|
|
|
add_filter('the_title', 'wptexturize');
|
2005-02-07 07:46:41 +00:00
|
|
|
add_filter('the_title', 'convert_chars');
|
|
|
|
add_filter('the_title', 'trim');
|
|
|
|
|
2007-08-20 22:50:04 +00:00
|
|
|
add_filter('the_content', 'wptexturize');
|
2005-02-07 07:46:41 +00:00
|
|
|
add_filter('the_content', 'convert_smilies');
|
|
|
|
add_filter('the_content', 'convert_chars');
|
|
|
|
add_filter('the_content', 'wpautop');
|
2008-03-23 17:02:11 +00:00
|
|
|
add_filter('the_content', 'prepend_attachment');
|
2005-02-07 07:46:41 +00:00
|
|
|
|
2007-08-20 22:50:04 +00:00
|
|
|
add_filter('the_excerpt', 'wptexturize');
|
2005-02-07 07:46:41 +00:00
|
|
|
add_filter('the_excerpt', 'convert_smilies');
|
|
|
|
add_filter('the_excerpt', 'convert_chars');
|
|
|
|
add_filter('the_excerpt', 'wpautop');
|
2005-02-15 00:21:21 +00:00
|
|
|
add_filter('get_the_excerpt', 'wp_trim_excerpt');
|
|
|
|
|
2007-08-20 22:50:04 +00:00
|
|
|
add_filter('comment_text', 'wptexturize');
|
|
|
|
add_filter('comment_text', 'convert_chars');
|
|
|
|
add_filter('comment_text', 'make_clickable', 9);
|
|
|
|
add_filter('comment_text', 'force_balance_tags', 25);
|
|
|
|
add_filter('comment_text', 'convert_smilies', 20);
|
|
|
|
add_filter('comment_text', 'wpautop', 30);
|
|
|
|
|
|
|
|
add_filter('comment_excerpt', 'convert_chars');
|
|
|
|
|
|
|
|
add_filter('list_cats', 'wptexturize');
|
|
|
|
add_filter('single_post_title', 'wptexturize');
|
2005-02-07 07:46:41 +00:00
|
|
|
|
2008-02-22 05:53:47 +00:00
|
|
|
add_filter('wp_sprintf', 'wp_sprintf_l', 10, 2);
|
|
|
|
|
2005-04-05 17:25:57 +00:00
|
|
|
// RSS filters
|
|
|
|
add_filter('the_title_rss', 'strip_tags');
|
|
|
|
add_filter('the_title_rss', 'ent2ncr', 8);
|
2006-07-26 17:43:15 +00:00
|
|
|
add_filter('the_title_rss', 'wp_specialchars');
|
2005-04-05 17:25:57 +00:00
|
|
|
add_filter('the_content_rss', 'ent2ncr', 8);
|
|
|
|
add_filter('the_excerpt_rss', 'convert_chars');
|
|
|
|
add_filter('the_excerpt_rss', 'ent2ncr', 8);
|
|
|
|
add_filter('comment_author_rss', 'ent2ncr', 8);
|
|
|
|
add_filter('comment_text_rss', 'ent2ncr', 8);
|
2007-08-20 22:50:04 +00:00
|
|
|
add_filter('comment_text_rss', 'wp_specialchars');
|
2005-04-05 17:25:57 +00:00
|
|
|
add_filter('bloginfo_rss', 'ent2ncr', 8);
|
|
|
|
add_filter('the_author', 'ent2ncr', 8);
|
|
|
|
|
2006-02-18 07:40:43 +00:00
|
|
|
// Misc filters
|
|
|
|
add_filter('option_ping_sites', 'privacy_ping_filter');
|
2006-08-24 22:33:16 +00:00
|
|
|
add_filter('option_blog_charset', 'wp_specialchars');
|
2007-03-23 17:45:40 +00:00
|
|
|
add_filter('option_home', '_config_wp_home');
|
|
|
|
add_filter('option_siteurl', '_config_wp_siteurl');
|
2008-02-11 17:45:18 +00:00
|
|
|
add_filter('tiny_mce_before_init', '_mce_set_direction');
|
2007-08-20 22:50:04 +00:00
|
|
|
add_filter('pre_kses', 'wp_pre_kses_less_than');
|
|
|
|
add_filter('sanitize_title', 'sanitize_title_with_dashes');
|
2007-08-27 06:34:18 +00:00
|
|
|
add_action('check_comment_flood', 'check_comment_flood_db', 10, 3);
|
2007-08-20 22:50:04 +00:00
|
|
|
add_filter('comment_flood_filter', 'wp_throttle_comment_flood', 10, 3);
|
|
|
|
add_filter('pre_comment_content', 'wp_rel_nofollow', 15);
|
|
|
|
add_filter('comment_email', 'antispambot');
|
2008-06-29 08:20:25 +00:00
|
|
|
add_filter('option_tag_base', '_wp_filter_taxonomy_base');
|
|
|
|
add_filter('option_category_base', '_wp_filter_taxonomy_base');
|
2008-09-15 16:26:37 +00:00
|
|
|
add_filter( 'the_posts', '_close_comments_for_old_posts' );
|
2008-09-28 03:31:26 +00:00
|
|
|
add_filter( 'comments_open', '_close_comments_for_old_post', 10, 2 );
|
|
|
|
add_filter( 'pings_open', '_close_comments_for_old_post', 10, 2 );
|
2008-12-07 09:12:28 +00:00
|
|
|
add_filter( 'editable_slug', 'urldecode' );
|
2006-11-30 08:48:56 +00:00
|
|
|
|
2008-09-28 03:31:26 +00:00
|
|
|
// Atom SSL support
|
2007-11-17 11:21:34 +00:00
|
|
|
add_filter('atom_service_url','atom_service_url_filter');
|
|
|
|
|
2005-04-05 17:25:57 +00:00
|
|
|
// Actions
|
2009-01-26 12:59:10 +00:00
|
|
|
add_action('wp_head', 'wp_enqueue_scripts', 1);
|
2009-01-19 05:04:58 +00:00
|
|
|
add_action('wp_head', 'feed_links_extra', 3);
|
2005-11-07 09:47:51 +00:00
|
|
|
add_action('wp_head', 'rsd_link');
|
2007-10-05 17:29:34 +00:00
|
|
|
add_action('wp_head', 'wlwmanifest_link');
|
2006-09-18 23:40:19 +00:00
|
|
|
add_action('wp_head', 'locale_stylesheet');
|
2008-02-22 19:59:12 +00:00
|
|
|
add_action('publish_future_post', 'check_and_publish_future_post', 10, 1);
|
2006-02-18 07:40:43 +00:00
|
|
|
add_action('wp_head', 'noindex', 1);
|
2009-01-26 12:59:10 +00:00
|
|
|
add_action('wp_head', 'wp_print_styles', 8);
|
|
|
|
add_action('wp_head', 'wp_print_head_scripts', 9);
|
2007-10-06 06:55:24 +00:00
|
|
|
add_action('wp_head', 'wp_generator');
|
2009-01-26 12:59:10 +00:00
|
|
|
add_action('wp_footer', 'wp_print_footer_scripts');
|
2006-03-07 22:34:05 +00:00
|
|
|
if(!defined('DOING_CRON'))
|
2009-02-07 13:32:34 +00:00
|
|
|
add_action('sanitize_comment_cookies', 'wp_cron');
|
2006-03-12 22:57:00 +00:00
|
|
|
add_action('do_feed_rdf', 'do_feed_rdf', 10, 1);
|
|
|
|
add_action('do_feed_rss', 'do_feed_rss', 10, 1);
|
|
|
|
add_action('do_feed_rss2', 'do_feed_rss2', 10, 1);
|
|
|
|
add_action('do_feed_atom', 'do_feed_atom', 10, 1);
|
2006-03-30 07:36:54 +00:00
|
|
|
add_action('do_pings', 'do_all_pings', 10, 1);
|
2006-05-22 22:06:06 +00:00
|
|
|
add_action('do_robots', 'do_robots');
|
2006-06-22 20:52:12 +00:00
|
|
|
add_action('sanitize_comment_cookies', 'sanitize_comment_cookies');
|
2009-01-26 12:59:10 +00:00
|
|
|
add_action('admin_print_scripts', 'print_head_scripts', 20);
|
|
|
|
add_action('admin_print_footer_scripts', 'print_footer_scripts', 20);
|
|
|
|
add_action('admin_print_styles', 'print_admin_styles', 20);
|
2007-03-12 21:31:24 +00:00
|
|
|
add_action('init', 'smilies_init', 5);
|
2007-05-01 01:58:18 +00:00
|
|
|
add_action( 'plugins_loaded', 'wp_maybe_load_widgets', 0 );
|
2007-05-12 22:06:31 +00:00
|
|
|
add_action( 'shutdown', 'wp_ob_end_flush_all', 1);
|
2008-05-29 22:21:36 +00:00
|
|
|
add_action( 'pre_post_update', 'wp_save_post_revision' );
|
2007-07-12 16:00:51 +00:00
|
|
|
add_action('publish_post', '_publish_post_hook', 5, 1);
|
|
|
|
add_action('future_post', '_future_post_hook', 5, 2);
|
|
|
|
add_action('future_page', '_future_post_hook', 5, 2);
|
|
|
|
add_action('save_post', '_save_post_hook', 5, 2);
|
|
|
|
add_action('transition_post_status', '_transition_post_status', 5, 3);
|
2007-08-20 22:50:04 +00:00
|
|
|
add_action('comment_form', 'wp_comment_form_unfiltered_html_nonce');
|
|
|
|
// Redirect Old Slugs
|
|
|
|
add_action('template_redirect', 'wp_old_slug_redirect');
|
|
|
|
add_action('edit_post', 'wp_check_for_changed_slugs');
|
|
|
|
add_action('edit_form_advanced', 'wp_remember_old_slug');
|
2008-10-31 22:47:07 +00:00
|
|
|
add_action('init', '_show_post_preview');
|
2007-05-01 01:13:06 +00:00
|
|
|
|
2007-10-05 17:29:34 +00:00
|
|
|
?>
|