WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )
apply_filters( "hook_name", "what_to_filter" )
.Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 3 times in this file.
Line | Code |
---|---|
217 | // Save the data |
218 | $id = wp_insert_attachment($object, $file); |
219 |
|
220 | $upload = array('file' => $file, 'id' => $id); |
221 |
|
222 | list($width, $height, $type, $attr) = getimagesize( $file ); |
223 |
|
224 | if ( $width == HEADER_IMAGE_WIDTH && $height == HEADER_IMAGE_HEIGHT ) { |
225 | set_theme_mod('header_image', $url); |
226 | $header = apply_filters('wp_create_file_in_uploads', $header); // For replication |
227 | return $this->finished(); |
228 | } elseif ( $width > HEADER_IMAGE_WIDTH ) { |
229 | $oitar = $width / HEADER_IMAGE_WIDTH; |
230 | $image = wp_crop_image($file, 0, 0, $width, $height, HEADER_IMAGE_WIDTH, $height / $oitar, false, str_replace(basename($file), 'midsize-'.basename($file), $file)); |
231 | $image = apply_filters('wp_create_file_in_uploads', $image); // For replication |
232 |
|
233 | $url = str_replace(basename($url), basename($image), $url); |
234 | $width = $width / $oitar; |
235 | $height = $height / $oitar; |
236 | } else { |
237 | $oitar = 1; |
238 | } |
239 | ?> |
240 |
|
Line | Code |
267 | function step_3() { |
268 | if ( $_POST['oitar'] > 1 ) { |
269 | $_POST['x1'] = $_POST['x1'] * $_POST['oitar']; |
270 | $_POST['y1'] = $_POST['y1'] * $_POST['oitar']; |
271 | $_POST['width'] = $_POST['width'] * $_POST['oitar']; |
272 | $_POST['height'] = $_POST['height'] * $_POST['oitar']; |
273 | } |
274 |
|
275 | $header = wp_crop_image($_POST['attachment_id'], $_POST['x1'], $_POST['y1'], $_POST['width'], $_POST['height'], HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT); |
276 | $header = apply_filters('wp_create_file_in_uploads', $header); // For replication |
277 |
|
278 | $parent = get_post($_POST['attachment_id']); |
279 |
|
280 | $parent_url = $parent->guid; |
281 |
|
282 | $url = str_replace(basename($parent_url), basename($header), $parent_url); |
283 |
|
284 | set_theme_mod('header_image', $url); |
285 |
|