media_upload_html_bypass

Definition:
function media_upload_html_bypass($flash = true) {}

Source code

function media_upload_html_bypass($flash = true) {

	echo '<p class="upload-html-bypass hide-if-no-js">';

	_e('You are using the Browser uploader.');

	if ( $flash ) {

		// the user manually selected the browser uploader, so let them switch back to Flash

		echo ' ';

		printf( __('Try the <a href="%s">Flash uploader</a> instead.'), esc_url(add_query_arg('flash', 1)) );

	}

	echo "</p>\n";

}

2379

media_upload_header

Definition:
function media_upload_header() {}

Source code

function media_upload_header() {

	?>

	<script type="text/javascript">post_id = <?php echo intval($_REQUEST['post_id']); ?>;</script>

	<div id="media-upload-header">

	<?php the_media_upload_tabs(); ?>

	</div>

	<?php

}

2377

media_upload_gallery_form

Definition:
function media_upload_gallery_form($errors) {}

Parameters

  • unknown_type $errors

Defined filters

  • media_upload_form_url
    apply_filters('media_upload_form_url', $form_action_url, $type)

Source code

function media_upload_gallery_form($errors) {

	global $redir_tab, $type;



	$redir_tab = 'gallery';

	media_upload_header();



	$post_id = intval($_REQUEST['post_id']);

	$form_action_url = admin_url("media-upload.php?type=$type&tab=gallery&post_id=$post_id");

	$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);

?>



<script type="text/javascript">

<!--

jQuery(function($){

	var preloaded = $(".media-item.preloaded");

	if ( preloaded.length > 0 ) {

		preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});

		updateMediaForm();

	}

});

-->

</script>

<div id="sort-buttons" class="hide-if-no-js">

<span>

<?php _e('All Tabs:'); ?>

<a href="#" id="showall"><?php _e('Show'); ?></a>

<a href="#" id="hideall" style="display:none;"><?php _e('Hide'); ?></a>

</span>

<?php _e('Sort Order:'); ?>

<a href="#" id="asc"><?php _e('Ascending'); ?></a> |

<a href="#" id="desc"><?php _e('Descending'); ?></a> |

<a href="#" id="clear"><?php _ex('Clear', 'verb'); ?></a>

</div>

<form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="media-upload-form validate" id="gallery-form">

<?php wp_nonce_field('media-form'); ?>

<?php //media_upload_form( $errors ); ?>

<table class="widefat" cellspacing="0">

<thead><tr>

<th><?php _e('Media'); ?></th>

<th class="order-head"><?php _e('Order'); ?></th>

<th class="actions-head"><?php _e('Actions'); ?></th>

</tr></thead>

</table>

<div id="media-items">

<?php add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); ?>

<?php echo get_media_items($post_id, $errors); ?>

</div>



<p class="ml-submit">

<?php submit_button( __( 'Save all changes' ), 'button savebutton', 'save', false, array( 'id' => 'save-all', 'style' => 'display: none;' ) ); ?>

<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />

<input type="hidden" name="type" value="<?php echo esc_attr( $GLOBALS['type'] ); ?>" />

<input type="hidden" name="tab" value="<?php echo esc_attr( $GLOBALS['tab'] ); ?>" />

</p>



<div id="gallery-settings" style="display:none;">

<div class="title"><?php _e('Gallery Settings'); ?></div>

<table id="basic" class="describe"><tbody>

	<tr>

	<th scope="row" class="label">

		<label>

		<span class="alignleft"><?php _e('Link thumbnails to:'); ?></span>

		</label>

	</th>

	<td class="field">

		<input type="radio" name="linkto" id="linkto-file" value="file" />

		<label for="linkto-file" class="radio"><?php _e('Image File'); ?></label>



		<input type="radio" checked="checked" name="linkto" id="linkto-post" value="post" />

		<label for="linkto-post" class="radio"><?php _e('Attachment Page'); ?></label>

	</td>

	</tr>



	<tr>

	<th scope="row" class="label">

		<label>

		<span class="alignleft"><?php _e('Order images by:'); ?></span>

		</label>

	</th>

	<td class="field">

		<select id="orderby" name="orderby">

			<option value="menu_order" selected="selected"><?php _e('Menu order'); ?></option>

			<option value="title"><?php _e('Title'); ?></option>

			<option value="ID"><?php _e('Date/Time'); ?></option>

			<option value="rand"><?php _e('Random'); ?></option>

		</select>

	</td>

	</tr>



	<tr>

	<th scope="row" class="label">

		<label>

		<span class="alignleft"><?php _e('Order:'); ?></span>

		</label>

	</th>

	<td class="field">

		<input type="radio" checked="checked" name="order" id="order-asc" value="asc" />

		<label for="order-asc" class="radio"><?php _e('Ascending'); ?></label>



		<input type="radio" name="order" id="order-desc" value="desc" />

		<label for="order-desc" class="radio"><?php _e('Descending'); ?></label>

	</td>

	</tr>



	<tr>

	<th scope="row" class="label">

		<label>

		<span class="alignleft"><?php _e('Gallery columns:'); ?></span>

		</label>

	</th>

	<td class="field">

		<select id="columns" name="columns">

			<option value="1">1</option>

			<option value="2">2</option>

			<option value="3" selected="selected">3</option>

			<option value="4">4</option>

			<option value="5">5</option>

			<option value="6">6</option>

			<option value="7">7</option>

			<option value="8">8</option>

			<option value="9">9</option>

		</select>

	</td>

	</tr>

</tbody></table>



<p class="ml-submit">

<input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="insert-gallery" id="insert-gallery" value="<?php esc_attr_e( 'Insert gallery' ); ?>" />

<input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="update-gallery" id="update-gallery" value="<?php esc_attr_e( 'Update gallery settings' ); ?>" />

</p>

</div>

</form>

<?php

}

2375

media_upload_gallery

Definition:
function media_upload_gallery() {}

Source code

function media_upload_gallery() {

	$errors = array();



	if ( !empty($_POST) ) {

		$return = media_upload_form_handler();



		if ( is_string($return) )

			return $return;

		if ( is_array($return) )

			$errors = $return;

	}



	wp_enqueue_script('admin-gallery');

	return wp_iframe( 'media_upload_gallery_form', $errors );

}

2373

media_upload_form_handler

Definition:
function media_upload_form_handler() {}

Defined filters

  • attachment_fields_to_save
    apply_filters('attachment_fields_to_save', $post, $attachment)
  • media_send_to_editor
    apply_filters('media_send_to_editor', $html, $send_id, $attachment)

Source code

function media_upload_form_handler() {

	check_admin_referer('media-form');



	$errors = null;



	if ( isset($_POST['send']) ) {

		$keys = array_keys($_POST['send']);

		$send_id = (int) array_shift($keys);

	}



	if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {

		$post = $_post = get_post($attachment_id, ARRAY_A);

		$post_type_object = get_post_type_object( $post[ 'post_type' ] );



		if ( !current_user_can( $post_type_object->cap->edit_post, $attachment_id ) )

			continue;



		if ( isset($attachment['post_content']) )

			$post['post_content'] = $attachment['post_content'];

		if ( isset($attachment['post_title']) )

			$post['post_title'] = $attachment['post_title'];

		if ( isset($attachment['post_excerpt']) )

			$post['post_excerpt'] = $attachment['post_excerpt'];

		if ( isset($attachment['menu_order']) )

			$post['menu_order'] = $attachment['menu_order'];



		if ( isset($send_id) && $attachment_id == $send_id ) {

			if ( isset($attachment['post_parent']) )

				$post['post_parent'] = $attachment['post_parent'];

		}



		$post = apply_filters('attachment_fields_to_save', $post, $attachment);



		if ( isset($attachment['image_alt']) ) {

			$image_alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true);

			if ( $image_alt != stripslashes($attachment['image_alt']) ) {

				$image_alt = wp_strip_all_tags( stripslashes($attachment['image_alt']), true );

				// update_meta expects slashed

				update_post_meta( $attachment_id, '_wp_attachment_image_alt', addslashes($image_alt) );

			}

		}



		if ( isset($post['errors']) ) {

			$errors[$attachment_id] = $post['errors'];

			unset($post['errors']);

		}



		if ( $post != $_post )

			wp_update_post($post);



		foreach ( get_attachment_taxonomies($post) as $t ) {

			if ( isset($attachment[$t]) )

				wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false);

		}

	}



	if ( isset($_POST['insert-gallery']) || isset($_POST['update-gallery']) ) { ?>

		<script type="text/javascript">

		/* <![CDATA[ */

		var win = window.dialogArguments || opener || parent || top;

		win.tb_remove();

		/* ]]> */

		</script>

		<?php

		exit;

	}



	if ( isset($send_id) ) {

		$attachment = stripslashes_deep( $_POST['attachments'][$send_id] );



		$html = $attachment['post_title'];

		if ( !empty($attachment['url']) ) {

			$rel = '';

			if ( strpos($attachment['url'], 'attachment_id') || get_attachment_link($send_id) == $attachment['url'] )

				$rel = " rel='attachment wp-att-" . esc_attr($send_id) . "'";

			$html = "<a href='{$attachment['url']}'$rel>$html</a>";

		}



		$html = apply_filters('media_send_to_editor', $html, $send_id, $attachment);

		return media_send_to_editor($html);

	}

2371