1 | <?php
|
---|
2 | /**
|
---|
3 | * Sets up the default filters and actions for most
|
---|
4 | * of the WordPress hooks.
|
---|
5 | *
|
---|
6 | * If you need to remove a default hook, this file will
|
---|
7 | * give you the priority for which to use to remove the
|
---|
8 | * hook.
|
---|
9 | *
|
---|
10 | * Not all of the default hooks are found in default-filters.php
|
---|
11 | *
|
---|
12 | * @package WordPress
|
---|
13 | */
|
---|
14 |
|
---|
15 | // Strip, trim, kses, special chars for string saves
|
---|
16 | $filters = array('pre_term_name', 'pre_comment_author_name', 'pre_link_name', 'pre_link_target',
|
---|
17 | 'pre_link_rel', 'pre_user_display_name', 'pre_user_first_name', 'pre_user_last_name',
|
---|
18 | 'pre_user_nickname');
|
---|
19 | foreach ( $filters as $filter ) {
|
---|
20 | add_filter($filter, 'strip_tags');
|
---|
21 | add_filter($filter, 'trim');
|
---|
22 | add_filter($filter, 'wp_filter_kses');
|
---|
23 | add_filter($filter, '_wp_specialchars', 30);
|
---|
24 | }
|
---|
25 |
|
---|
26 | // Kses only for textarea saves
|
---|
27 | $filters = array('pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description');
|
---|
28 | foreach ( $filters as $filter ) {
|
---|
29 | add_filter($filter, 'wp_filter_kses');
|
---|
30 | }
|
---|
31 |
|
---|
32 | // Email
|
---|
33 | $filters = array('pre_comment_author_email', 'pre_user_email');
|
---|
34 | foreach ( $filters as $filter ) {
|
---|
35 | add_filter($filter, 'trim');
|
---|
36 | add_filter($filter, 'sanitize_email');
|
---|
37 | add_filter($filter, 'wp_filter_kses');
|
---|
38 | }
|
---|
39 |
|
---|
40 | // Save URL
|
---|
41 | $filters = array('pre_comment_author_url', 'pre_user_url', 'pre_link_url', 'pre_link_image',
|
---|
42 | 'pre_link_rss');
|
---|
43 | foreach ( $filters as $filter ) {
|
---|
44 | add_filter($filter, 'strip_tags');
|
---|
45 | add_filter($filter, 'trim');
|
---|
46 | add_filter($filter, 'esc_url_raw');
|
---|
47 | add_filter($filter, 'wp_filter_kses');
|
---|
48 | }
|
---|
49 |
|
---|
50 | // Display URL
|
---|
51 | $filters = array('user_url', 'link_url', 'link_image', 'link_rss', 'comment_url');
|
---|
52 | foreach ( $filters as $filter ) {
|
---|
53 | add_filter($filter, 'strip_tags');
|
---|
54 | add_filter($filter, 'trim');
|
---|
55 | add_filter($filter, 'esc_url');
|
---|
56 | add_filter($filter, 'wp_filter_kses');
|
---|
57 | }
|
---|
58 |
|
---|
59 | // Slugs
|
---|
60 | $filters = array('pre_term_slug');
|
---|
61 | foreach ( $filters as $filter ) {
|
---|
62 | add_filter($filter, 'sanitize_title');
|
---|
63 | }
|
---|
64 |
|
---|
65 | // Keys
|
---|
66 | $filters = array('pre_post_type');
|
---|
67 | foreach ( $filters as $filter ) {
|
---|
68 | add_filter($filter, 'sanitize_user');
|
---|
69 | }
|
---|
70 |
|
---|
71 | // Places to balance tags on input
|
---|
72 | $filters = array('content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content');
|
---|
73 | foreach ( $filters as $filter ) {
|
---|
74 | add_filter( $filter, 'balanceTags', 50);
|
---|
75 | }
|
---|
76 |
|
---|
77 | // Format strings for display.
|
---|
78 | $filters = array('comment_author', 'term_name', 'link_name', 'link_description',
|
---|
79 | 'link_notes', 'bloginfo', 'wp_title', 'widget_title');
|
---|
80 | foreach ( $filters as $filter ) {
|
---|
81 | add_filter($filter, 'wptexturize');
|
---|
82 | add_filter($filter, 'convert_chars');
|
---|
83 | add_filter($filter, 'esc_html');
|
---|
84 | }
|
---|
85 |
|
---|
86 | // Format text area for display.
|
---|
87 | $filters = array('term_description');
|
---|
88 | foreach ( $filters as $filter ) {
|
---|
89 | add_filter($filter, 'wptexturize');
|
---|
90 | add_filter($filter, 'convert_chars');
|
---|
91 | add_filter($filter, 'wpautop');
|
---|
92 | }
|
---|
93 |
|
---|
94 | // Format for RSS
|
---|
95 | $filters = array('term_name_rss');
|
---|
96 | foreach ( $filters as $filter ) {
|
---|
97 | add_filter($filter, 'convert_chars');
|
---|
98 | }
|
---|
99 |
|
---|
100 | // Display filters
|
---|
101 | add_filter('the_title', 'wptexturize');
|
---|
102 | add_filter('the_title', 'convert_chars');
|
---|
103 | add_filter('the_title', 'trim');
|
---|
104 |
|
---|
105 | add_filter('the_content', 'wptexturize');
|
---|
106 | add_filter('the_content', 'convert_smilies');
|
---|
107 | add_filter('the_content', 'convert_chars');
|
---|
108 | add_filter('the_content', 'wpautop');
|
---|
109 | add_filter('the_content', 'prepend_attachment');
|
---|
110 |
|
---|
111 | add_filter('the_excerpt', 'wptexturize');
|
---|
112 | add_filter('the_excerpt', 'convert_smilies');
|
---|
113 | add_filter('the_excerpt', 'convert_chars');
|
---|
114 | add_filter('the_excerpt', 'wpautop');
|
---|
115 | add_filter('get_the_excerpt', 'wp_trim_excerpt');
|
---|
116 |
|
---|
117 | add_filter('comment_text', 'wptexturize');
|
---|
118 | add_filter('comment_text', 'convert_chars');
|
---|
119 | add_filter('comment_text', 'make_clickable', 9);
|
---|
120 | add_filter('comment_text', 'force_balance_tags', 25);
|
---|
121 | add_filter('comment_text', 'convert_smilies', 20);
|
---|
122 | add_filter('comment_text', 'wpautop', 30);
|
---|
123 |
|
---|
124 | add_filter('comment_excerpt', 'convert_chars');
|
---|
125 |
|
---|
126 | add_filter('list_cats', 'wptexturize');
|
---|
127 | add_filter('single_post_title', 'wptexturize');
|
---|
128 |
|
---|
129 | add_filter('wp_sprintf', 'wp_sprintf_l', 10, 2);
|
---|
130 |
|
---|
131 | // RSS filters
|
---|
132 | add_filter('the_title_rss', 'strip_tags');
|
---|
133 | add_filter('the_title_rss', 'ent2ncr', 8);
|
---|
134 | add_filter('the_title_rss', 'esc_html');
|
---|
135 | add_filter('the_content_rss', 'ent2ncr', 8);
|
---|
136 | add_filter('the_excerpt_rss', 'convert_chars');
|
---|
137 | add_filter('the_excerpt_rss', 'ent2ncr', 8);
|
---|
138 | add_filter('comment_author_rss', 'ent2ncr', 8);
|
---|
139 | add_filter('comment_text_rss', 'ent2ncr', 8);
|
---|
140 | add_filter('comment_text_rss', 'esc_html');
|
---|
141 | add_filter('bloginfo_rss', 'ent2ncr', 8);
|
---|
142 | add_filter('the_author', 'ent2ncr', 8);
|
---|
143 |
|
---|
144 | // Misc filters
|
---|
145 | add_filter('option_ping_sites', 'privacy_ping_filter');
|
---|
146 | add_filter('option_blog_charset', '_wp_specialchars'); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop
|
---|
147 | add_filter('option_home', '_config_wp_home');
|
---|
148 | add_filter('option_siteurl', '_config_wp_siteurl');
|
---|
149 | add_filter('tiny_mce_before_init', '_mce_set_direction');
|
---|
150 | add_filter('pre_kses', 'wp_pre_kses_less_than');
|
---|
151 | add_filter('sanitize_title', 'sanitize_title_with_dashes');
|
---|
152 | add_action('check_comment_flood', 'check_comment_flood_db', 10, 3);
|
---|
153 | add_filter('comment_flood_filter', 'wp_throttle_comment_flood', 10, 3);
|
---|
154 | add_filter('pre_comment_content', 'wp_rel_nofollow', 15);
|
---|
155 | add_filter('comment_email', 'antispambot');
|
---|
156 | add_filter('option_tag_base', '_wp_filter_taxonomy_base');
|
---|
157 | add_filter('option_category_base', '_wp_filter_taxonomy_base');
|
---|
158 | add_filter( 'the_posts', '_close_comments_for_old_posts' );
|
---|
159 | add_filter( 'comments_open', '_close_comments_for_old_post', 10, 2 );
|
---|
160 | add_filter( 'pings_open', '_close_comments_for_old_post', 10, 2 );
|
---|
161 | add_filter( 'editable_slug', 'urldecode' );
|
---|
162 |
|
---|
163 | // Atom SSL support
|
---|
164 | add_filter('atom_service_url','atom_service_url_filter');
|
---|
165 |
|
---|
166 | // Actions
|
---|
167 | add_action('wp_head', 'wp_enqueue_scripts', 1);
|
---|
168 | add_action('wp_head', 'feed_links_extra', 3);
|
---|
169 | add_action('wp_head', 'rsd_link');
|
---|
170 | add_action('wp_head', 'wlwmanifest_link');
|
---|
171 | add_action('wp_head', 'index_rel_link');
|
---|
172 | add_action('wp_head', 'parent_post_rel_link', 10, 0);
|
---|
173 | add_action('wp_head', 'start_post_rel_link', 10, 0);
|
---|
174 | add_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
|
---|
175 | add_action('wp_head', 'locale_stylesheet');
|
---|
176 | add_action('publish_future_post', 'check_and_publish_future_post', 10, 1);
|
---|
177 | add_action('wp_head', 'noindex', 1);
|
---|
178 | add_action('wp_head', 'wp_print_styles', 8);
|
---|
179 | add_action('wp_head', 'wp_print_head_scripts', 9);
|
---|
180 | add_action('wp_head', 'wp_generator');
|
---|
181 | add_action('wp_footer', 'wp_print_footer_scripts');
|
---|
182 | if(!defined('DOING_CRON'))
|
---|
183 | add_action('sanitize_comment_cookies', 'wp_cron');
|
---|
184 | add_action('do_feed_rdf', 'do_feed_rdf', 10, 1);
|
---|
185 | add_action('do_feed_rss', 'do_feed_rss', 10, 1);
|
---|
186 | add_action('do_feed_rss2', 'do_feed_rss2', 10, 1);
|
---|
187 | add_action('do_feed_atom', 'do_feed_atom', 10, 1);
|
---|
188 | add_action('do_pings', 'do_all_pings', 10, 1);
|
---|
189 | add_action('do_generic_ping', 'generic_ping', 10, 1);
|
---|
190 | add_action('do_robots', 'do_robots');
|
---|
191 | add_action('sanitize_comment_cookies', 'sanitize_comment_cookies');
|
---|
192 | add_action('admin_print_scripts', 'print_head_scripts', 20);
|
---|
193 | add_action('admin_print_footer_scripts', 'print_footer_scripts', 20);
|
---|
194 | add_action('admin_print_styles', 'print_admin_styles', 20);
|
---|
195 | add_action('init', 'smilies_init', 5);
|
---|
196 | add_action( 'plugins_loaded', 'wp_maybe_load_widgets', 0 );
|
---|
197 | add_action( 'shutdown', 'wp_ob_end_flush_all', 1);
|
---|
198 | add_action( 'pre_post_update', 'wp_save_post_revision' );
|
---|
199 | add_action('publish_post', '_publish_post_hook', 5, 1);
|
---|
200 | add_action('future_post', '_future_post_hook', 5, 2);
|
---|
201 | add_action('future_page', '_future_post_hook', 5, 2);
|
---|
202 | add_action('save_post', '_save_post_hook', 5, 2);
|
---|
203 | add_action('transition_post_status', '_transition_post_status', 5, 3);
|
---|
204 | add_action('comment_form', 'wp_comment_form_unfiltered_html_nonce');
|
---|
205 | // Redirect Old Slugs
|
---|
206 | add_action('template_redirect', 'wp_old_slug_redirect');
|
---|
207 | add_action('edit_post', 'wp_check_for_changed_slugs');
|
---|
208 | add_action('edit_form_advanced', 'wp_remember_old_slug');
|
---|
209 | add_action('init', '_show_post_preview');
|
---|
210 |
|
---|
211 | add_filter('pre_option_gmt_offset','wp_timezone_override_offset');
|
---|
212 |
|
---|
213 | ?>
|
---|