mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-16 23:00:21 +00:00
Coding Standards: Upgrade WPCS to 1.0.0
WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues. This change includes three notable additions: - Multiline function calls must now put each parameter on a new line. - Auto-formatting files is now part of the `grunt precommit` script. - Auto-fixable coding standards issues will now cause Travis failures. Fixes #44600. git-svn-id: https://develop.svn.wordpress.org/trunk@43571 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
+329
-316
@@ -263,12 +263,12 @@ function _cleanup_image_add_caption( $matches ) {
|
||||
* @param string $html
|
||||
*/
|
||||
function media_send_to_editor( $html ) {
|
||||
?>
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var win = window.dialogArguments || opener || parent || top;
|
||||
win.send_to_editor( <?php echo wp_json_encode( $html ); ?> );
|
||||
</script>
|
||||
<?php
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -368,7 +368,7 @@ function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrid
|
||||
$content .= ' ' . sprintf( __( 'Genre: %s.' ), $meta['genre'] );
|
||||
}
|
||||
|
||||
// Use image exif/iptc data for title and caption defaults if possible.
|
||||
// Use image exif/iptc data for title and caption defaults if possible.
|
||||
} elseif ( 0 === strpos( $type, 'image/' ) && $image_meta = wp_read_image_metadata( $file ) ) {
|
||||
if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
|
||||
$title = $image_meta['title'];
|
||||
@@ -388,7 +388,8 @@ function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrid
|
||||
'post_title' => $title,
|
||||
'post_content' => $content,
|
||||
'post_excerpt' => $excerpt,
|
||||
), $post_data
|
||||
),
|
||||
$post_data
|
||||
);
|
||||
|
||||
// This should never be set as it would then overwrite an existing attachment.
|
||||
@@ -458,7 +459,8 @@ function media_handle_sideload( $file_array, $post_id, $desc = null, $post_data
|
||||
'post_parent' => $post_id,
|
||||
'post_title' => $title,
|
||||
'post_content' => $content,
|
||||
), $post_data
|
||||
),
|
||||
$post_data
|
||||
);
|
||||
|
||||
// This should never be set as it would then overwrite an existing attachment.
|
||||
@@ -484,24 +486,24 @@ function media_handle_sideload( $file_array, $post_id, $desc = null, $post_data
|
||||
*/
|
||||
function wp_iframe( $content_func /* ... */ ) {
|
||||
_wp_admin_html_begin();
|
||||
?>
|
||||
?>
|
||||
<title><?php bloginfo( 'name' ); ?> › <?php _e( 'Uploads' ); ?> — <?php _e( 'WordPress' ); ?></title>
|
||||
<?php
|
||||
<?php
|
||||
|
||||
wp_enqueue_style( 'colors' );
|
||||
// Check callback name for 'media'
|
||||
if ( ( is_array( $content_func ) && ! empty( $content_func[1] ) && 0 === strpos( (string) $content_func[1], 'media' ) )
|
||||
wp_enqueue_style( 'colors' );
|
||||
// Check callback name for 'media'
|
||||
if ( ( is_array( $content_func ) && ! empty( $content_func[1] ) && 0 === strpos( (string) $content_func[1], 'media' ) )
|
||||
|| ( ! is_array( $content_func ) && 0 === strpos( $content_func, 'media' ) ) ) {
|
||||
wp_enqueue_style( 'deprecated-media' );
|
||||
}
|
||||
wp_enqueue_style( 'ie' );
|
||||
?>
|
||||
wp_enqueue_style( 'deprecated-media' );
|
||||
}
|
||||
wp_enqueue_style( 'ie' );
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
|
||||
var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup',
|
||||
isRtl = <?php echo (int) is_rtl(); ?>;
|
||||
</script>
|
||||
<?php
|
||||
<?php
|
||||
/** This action is documented in wp-admin/admin-header.php */
|
||||
do_action( 'admin_enqueue_scripts', 'media-upload-popup' );
|
||||
|
||||
@@ -536,43 +538,43 @@ isRtl = <?php echo (int) is_rtl(); ?>;
|
||||
/** This action is documented in wp-admin/admin-header.php */
|
||||
do_action( 'admin_head' );
|
||||
|
||||
if ( is_string( $content_func ) ) {
|
||||
/**
|
||||
* Fires in the admin header for each specific form tab in the legacy
|
||||
* (pre-3.5.0) media upload popup.
|
||||
*
|
||||
* The dynamic portion of the hook, `$content_func`, refers to the form
|
||||
* callback for the media upload type. Possible values include
|
||||
* 'media_upload_type_form', 'media_upload_type_url_form', and
|
||||
* 'media_upload_library_form'.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*/
|
||||
do_action( "admin_head_{$content_func}" );
|
||||
}
|
||||
if ( is_string( $content_func ) ) {
|
||||
/**
|
||||
* Fires in the admin header for each specific form tab in the legacy
|
||||
* (pre-3.5.0) media upload popup.
|
||||
*
|
||||
* The dynamic portion of the hook, `$content_func`, refers to the form
|
||||
* callback for the media upload type. Possible values include
|
||||
* 'media_upload_type_form', 'media_upload_type_url_form', and
|
||||
* 'media_upload_library_form'.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*/
|
||||
do_action( "admin_head_{$content_func}" );
|
||||
}
|
||||
|
||||
$body_id_attr = '';
|
||||
if ( isset( $GLOBALS['body_id'] ) ) {
|
||||
$body_id_attr = ' id="' . $GLOBALS['body_id'] . '"';
|
||||
}
|
||||
?>
|
||||
$body_id_attr = '';
|
||||
if ( isset( $GLOBALS['body_id'] ) ) {
|
||||
$body_id_attr = ' id="' . $GLOBALS['body_id'] . '"';
|
||||
}
|
||||
?>
|
||||
</head>
|
||||
<body<?php echo $body_id_attr; ?> class="wp-core-ui no-js">
|
||||
<script type="text/javascript">
|
||||
document.body.className = document.body.className.replace('no-js', 'js');
|
||||
</script>
|
||||
<?php
|
||||
<?php
|
||||
$args = func_get_args();
|
||||
$args = array_slice( $args, 1 );
|
||||
call_user_func_array( $content_func, $args );
|
||||
|
||||
/** This action is documented in wp-admin/admin-footer.php */
|
||||
do_action( 'admin_print_footer_scripts' );
|
||||
?>
|
||||
?>
|
||||
<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -754,7 +756,7 @@ function media_upload_form_handler() {
|
||||
}
|
||||
|
||||
if ( isset( $_POST['insert-gallery'] ) || isset( $_POST['update-gallery'] ) ) {
|
||||
?>
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var win = window.dialogArguments || opener || parent || top;
|
||||
win.tb_remove();
|
||||
@@ -1069,7 +1071,8 @@ function image_size_input_fields( $post, $check = '' ) {
|
||||
* include 'Thumbnail', 'Medium', 'Large', 'Full Size'.
|
||||
*/
|
||||
$size_names = apply_filters(
|
||||
'image_size_names_choose', array(
|
||||
'image_size_names_choose',
|
||||
array(
|
||||
'thumbnail' => __( 'Thumbnail' ),
|
||||
'medium' => __( 'Medium' ),
|
||||
'large' => __( 'Large' ),
|
||||
@@ -1781,9 +1784,15 @@ function get_compat_media_markup( $attachment_id, $args = null ) {
|
||||
$form_fields = apply_filters( 'attachment_fields_to_edit', $form_fields, $post );
|
||||
|
||||
unset(
|
||||
$form_fields['image-size'], $form_fields['align'], $form_fields['image_alt'],
|
||||
$form_fields['post_title'], $form_fields['post_excerpt'], $form_fields['post_content'],
|
||||
$form_fields['url'], $form_fields['menu_order'], $form_fields['image_url']
|
||||
$form_fields['image-size'],
|
||||
$form_fields['align'],
|
||||
$form_fields['image_alt'],
|
||||
$form_fields['post_title'],
|
||||
$form_fields['post_excerpt'],
|
||||
$form_fields['post_content'],
|
||||
$form_fields['url'],
|
||||
$form_fields['menu_order'],
|
||||
$form_fields['image_url']
|
||||
);
|
||||
|
||||
/** This filter is documented in wp-admin/includes/media.php */
|
||||
@@ -1943,123 +1952,123 @@ function media_upload_form( $errors = null ) {
|
||||
if ( ! $max_upload_size ) {
|
||||
$max_upload_size = 0;
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
<div id="media-upload-notice">
|
||||
<?php
|
||||
<?php
|
||||
|
||||
if ( isset( $errors['upload_notice'] ) ) {
|
||||
echo $errors['upload_notice'];
|
||||
}
|
||||
if ( isset( $errors['upload_notice'] ) ) {
|
||||
echo $errors['upload_notice'];
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
</div>
|
||||
<div id="media-upload-error">
|
||||
<?php
|
||||
<?php
|
||||
|
||||
if ( isset( $errors['upload_error'] ) && is_wp_error( $errors['upload_error'] ) ) {
|
||||
echo $errors['upload_error']->get_error_message();
|
||||
}
|
||||
if ( isset( $errors['upload_error'] ) && is_wp_error( $errors['upload_error'] ) ) {
|
||||
echo $errors['upload_error']->get_error_message();
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
if ( is_multisite() && ! is_upload_space_available() ) {
|
||||
<?php
|
||||
if ( is_multisite() && ! is_upload_space_available() ) {
|
||||
/**
|
||||
* Fires when an upload will exceed the defined upload space quota for a network site.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*/
|
||||
do_action( 'upload_ui_over_quota' );
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires when an upload will exceed the defined upload space quota for a network site.
|
||||
* Fires just before the legacy (pre-3.5.0) upload interface is loaded.
|
||||
*
|
||||
* @since 3.5.0
|
||||
* @since 2.6.0
|
||||
*/
|
||||
do_action( 'upload_ui_over_quota' );
|
||||
return;
|
||||
}
|
||||
do_action( 'pre-upload-ui' );
|
||||
|
||||
/**
|
||||
* Fires just before the legacy (pre-3.5.0) upload interface is loaded.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
do_action( 'pre-upload-ui' );
|
||||
$post_params = array(
|
||||
'post_id' => $post_id,
|
||||
'_wpnonce' => wp_create_nonce( 'media-form' ),
|
||||
'type' => $_type,
|
||||
'tab' => $_tab,
|
||||
'short' => '1',
|
||||
);
|
||||
|
||||
$post_params = array(
|
||||
'post_id' => $post_id,
|
||||
'_wpnonce' => wp_create_nonce( 'media-form' ),
|
||||
'type' => $_type,
|
||||
'tab' => $_tab,
|
||||
'short' => '1',
|
||||
);
|
||||
/**
|
||||
* Filters the media upload post parameters.
|
||||
*
|
||||
* @since 3.1.0 As 'swfupload_post_params'
|
||||
* @since 3.3.0
|
||||
*
|
||||
* @param array $post_params An array of media upload parameters used by Plupload.
|
||||
*/
|
||||
$post_params = apply_filters( 'upload_post_params', $post_params );
|
||||
|
||||
/**
|
||||
* Filters the media upload post parameters.
|
||||
*
|
||||
* @since 3.1.0 As 'swfupload_post_params'
|
||||
* @since 3.3.0
|
||||
*
|
||||
* @param array $post_params An array of media upload parameters used by Plupload.
|
||||
*/
|
||||
$post_params = apply_filters( 'upload_post_params', $post_params );
|
||||
/*
|
||||
* Since 4.9 the `runtimes` setting is hardcoded in our version of Plupload to `html5,html4`,
|
||||
* and the `flash_swf_url` and `silverlight_xap_url` are not used.
|
||||
*/
|
||||
$plupload_init = array(
|
||||
'browse_button' => 'plupload-browse-button',
|
||||
'container' => 'plupload-upload-ui',
|
||||
'drop_element' => 'drag-drop-area',
|
||||
'file_data_name' => 'async-upload',
|
||||
'url' => $upload_action_url,
|
||||
'filters' => array(
|
||||
'max_file_size' => $max_upload_size . 'b',
|
||||
),
|
||||
'multipart_params' => $post_params,
|
||||
);
|
||||
|
||||
/*
|
||||
* Since 4.9 the `runtimes` setting is hardcoded in our version of Plupload to `html5,html4`,
|
||||
* and the `flash_swf_url` and `silverlight_xap_url` are not used.
|
||||
*/
|
||||
$plupload_init = array(
|
||||
'browse_button' => 'plupload-browse-button',
|
||||
'container' => 'plupload-upload-ui',
|
||||
'drop_element' => 'drag-drop-area',
|
||||
'file_data_name' => 'async-upload',
|
||||
'url' => $upload_action_url,
|
||||
'filters' => array(
|
||||
'max_file_size' => $max_upload_size . 'b',
|
||||
),
|
||||
'multipart_params' => $post_params,
|
||||
);
|
||||
|
||||
// Currently only iOS Safari supports multiple files uploading but iOS 7.x has a bug that prevents uploading of videos
|
||||
// when enabled. See #29602.
|
||||
if ( wp_is_mobile() && strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false &&
|
||||
// Currently only iOS Safari supports multiple files uploading but iOS 7.x has a bug that prevents uploading of videos
|
||||
// when enabled. See #29602.
|
||||
if ( wp_is_mobile() && strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false &&
|
||||
strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false ) {
|
||||
|
||||
$plupload_init['multi_selection'] = false;
|
||||
}
|
||||
$plupload_init['multi_selection'] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the default Plupload settings.
|
||||
*
|
||||
* @since 3.3.0
|
||||
*
|
||||
* @param array $plupload_init An array of default settings used by Plupload.
|
||||
*/
|
||||
$plupload_init = apply_filters( 'plupload_init', $plupload_init );
|
||||
/**
|
||||
* Filters the default Plupload settings.
|
||||
*
|
||||
* @since 3.3.0
|
||||
*
|
||||
* @param array $plupload_init An array of default settings used by Plupload.
|
||||
*/
|
||||
$plupload_init = apply_filters( 'plupload_init', $plupload_init );
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
<?php
|
||||
// Verify size is an int. If not return default value.
|
||||
$large_size_h = absint( get_option( 'large_size_h' ) );
|
||||
if ( ! $large_size_h ) {
|
||||
$large_size_h = 1024;
|
||||
}
|
||||
$large_size_w = absint( get_option( 'large_size_w' ) );
|
||||
if ( ! $large_size_w ) {
|
||||
$large_size_w = 1024;
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
// Verify size is an int. If not return default value.
|
||||
$large_size_h = absint( get_option( 'large_size_h' ) );
|
||||
if ( ! $large_size_h ) {
|
||||
$large_size_h = 1024;
|
||||
}
|
||||
$large_size_w = absint( get_option( 'large_size_w' ) );
|
||||
if ( ! $large_size_w ) {
|
||||
$large_size_w = 1024;
|
||||
}
|
||||
?>
|
||||
var resize_height = <?php echo $large_size_h; ?>, resize_width = <?php echo $large_size_w; ?>,
|
||||
wpUploaderInit = <?php echo wp_json_encode( $plupload_init ); ?>;
|
||||
</script>
|
||||
|
||||
<div id="plupload-upload-ui" class="hide-if-no-js">
|
||||
<?php
|
||||
/**
|
||||
* Fires before the upload interface loads.
|
||||
*
|
||||
* @since 2.6.0 As 'pre-flash-upload-ui'
|
||||
* @since 3.3.0
|
||||
*/
|
||||
do_action( 'pre-plupload-upload-ui' );
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Fires before the upload interface loads.
|
||||
*
|
||||
* @since 2.6.0 As 'pre-flash-upload-ui'
|
||||
* @since 3.3.0
|
||||
*/
|
||||
do_action( 'pre-plupload-upload-ui' );
|
||||
?>
|
||||
<div id="drag-drop-area">
|
||||
<div class="drag-drop-inside">
|
||||
<p class="drag-drop-info"><?php _e( 'Drop files here' ); ?></p>
|
||||
@@ -2067,15 +2076,15 @@ do_action( 'pre-plupload-upload-ui' );
|
||||
<p class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="<?php esc_attr_e( 'Select Files' ); ?>" class="button" /></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
/**
|
||||
* Fires after the upload interface loads.
|
||||
*
|
||||
* @since 2.6.0 As 'post-flash-upload-ui'
|
||||
* @since 3.3.0
|
||||
*/
|
||||
do_action( 'post-plupload-upload-ui' );
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Fires after the upload interface loads.
|
||||
*
|
||||
* @since 2.6.0 As 'post-flash-upload-ui'
|
||||
* @since 3.3.0
|
||||
*/
|
||||
do_action( 'post-plupload-upload-ui' );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div id="html-upload-ui" class="hide-if-js">
|
||||
@@ -2094,18 +2103,18 @@ do_action( 'post-plupload-upload-ui' );
|
||||
<a href="#" onclick="try{top.tb_remove();}catch(e){}; return false;"><?php _e( 'Cancel' ); ?></a>
|
||||
</p>
|
||||
<div class="clear"></div>
|
||||
<?php
|
||||
/**
|
||||
* Fires after the upload button in the media upload interface.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
do_action( 'post-html-upload-ui' );
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Fires after the upload button in the media upload interface.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
do_action( 'post-html-upload-ui' );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<p class="max-upload-size"><?php printf( __( 'Maximum upload file size: %s.' ), esc_html( size_format( $max_upload_size ) ) ); ?></p>
|
||||
<?php
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Fires on the post upload UI screen.
|
||||
@@ -2148,16 +2157,16 @@ function media_upload_type_form( $type = 'file', $errors = null, $id = null ) {
|
||||
if ( get_user_setting( 'uploader' ) ) {
|
||||
$form_class .= ' html-uploader';
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form">
|
||||
<?php submit_button( '', 'hidden', 'save', false ); ?>
|
||||
<?php submit_button( '', 'hidden', 'save', false ); ?>
|
||||
<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
|
||||
<?php wp_nonce_field( 'media-form' ); ?>
|
||||
<?php wp_nonce_field( 'media-form' ); ?>
|
||||
|
||||
<h3 class="media-title"><?php _e( 'Add media files from your computer' ); ?></h3>
|
||||
|
||||
<?php media_upload_form( $errors ); ?>
|
||||
<?php media_upload_form( $errors ); ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function($){
|
||||
@@ -2169,25 +2178,25 @@ jQuery(function($){
|
||||
});
|
||||
</script>
|
||||
<div id="media-items">
|
||||
<?php
|
||||
<?php
|
||||
|
||||
if ( $id ) {
|
||||
if ( ! is_wp_error( $id ) ) {
|
||||
add_filter( 'attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2 );
|
||||
echo get_media_items( $id, $errors );
|
||||
} else {
|
||||
echo '<div id="media-upload-error">' . esc_html( $id->get_error_message() ) . '</div></div>';
|
||||
exit;
|
||||
if ( $id ) {
|
||||
if ( ! is_wp_error( $id ) ) {
|
||||
add_filter( 'attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2 );
|
||||
echo get_media_items( $id, $errors );
|
||||
} else {
|
||||
echo '<div id="media-upload-error">' . esc_html( $id->get_error_message() ) . '</div></div>';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
</div>
|
||||
|
||||
<p class="savebutton ml-submit">
|
||||
<?php submit_button( __( 'Save all changes' ), '', 'save', false ); ?>
|
||||
<?php submit_button( __( 'Save all changes' ), '', 'save', false ); ?>
|
||||
</p>
|
||||
</form>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2216,11 +2225,11 @@ function media_upload_type_url_form( $type = null, $errors = null, $id = null )
|
||||
if ( get_user_setting( 'uploader' ) ) {
|
||||
$form_class .= ' html-uploader';
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form">
|
||||
<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
|
||||
<?php wp_nonce_field( 'media-form' ); ?>
|
||||
<?php wp_nonce_field( 'media-form' ); ?>
|
||||
|
||||
<h3 class="media-title"><?php _e( 'Insert media from another website' ); ?></h3>
|
||||
|
||||
@@ -2240,10 +2249,10 @@ var addExtImage = {
|
||||
if ( f.alt.value )
|
||||
alt = f.alt.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
|
||||
|
||||
<?php
|
||||
<?php
|
||||
/** This filter is documented in wp-admin/includes/media.php */
|
||||
if ( ! apply_filters( 'disable_captions', '' ) ) {
|
||||
?>
|
||||
if ( ! apply_filters( 'disable_captions', '' ) ) {
|
||||
?>
|
||||
if ( f.caption.value ) {
|
||||
caption = f.caption.value.replace(/\r\n|\r/g, '\n');
|
||||
caption = caption.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(a){
|
||||
@@ -2252,7 +2261,7 @@ if ( ! apply_filters( 'disable_captions', '' ) ) {
|
||||
|
||||
caption = caption.replace(/\s*\n\s*/g, '<br />');
|
||||
}
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
cls = caption ? '' : ' class="'+t.align+'"';
|
||||
|
||||
@@ -2318,20 +2327,20 @@ jQuery(document).ready( function($) {
|
||||
|
||||
<div id="media-items">
|
||||
<div class="media-item media-blank">
|
||||
<?php
|
||||
/**
|
||||
* Filters the insert media from URL form HTML.
|
||||
*
|
||||
* @since 3.3.0
|
||||
*
|
||||
* @param string $form_html The insert from URL form HTML.
|
||||
*/
|
||||
echo apply_filters( 'type_url_form_media', wp_media_insert_url_form( $type ) );
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Filters the insert media from URL form HTML.
|
||||
*
|
||||
* @since 3.3.0
|
||||
*
|
||||
* @param string $form_html The insert from URL form HTML.
|
||||
*/
|
||||
echo apply_filters( 'type_url_form_media', wp_media_insert_url_form( $type ) );
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2360,7 +2369,7 @@ function media_upload_gallery_form( $errors ) {
|
||||
if ( get_user_setting( 'uploader' ) ) {
|
||||
$form_class .= ' html-uploader';
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function($){
|
||||
@@ -2373,18 +2382,18 @@ jQuery(function($){
|
||||
</script>
|
||||
<div id="sort-buttons" class="hide-if-no-js">
|
||||
<span>
|
||||
<?php _e( 'All Tabs:' ); ?>
|
||||
<?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:' ); ?>
|
||||
<?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_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="gallery-form">
|
||||
<?php wp_nonce_field( 'media-form' ); ?>
|
||||
<?php //media_upload_form( $errors ); ?>
|
||||
<?php wp_nonce_field( 'media-form' ); ?>
|
||||
<?php //media_upload_form( $errors ); ?>
|
||||
<table class="widefat">
|
||||
<thead><tr>
|
||||
<th><?php _e( 'Media' ); ?></th>
|
||||
@@ -2393,19 +2402,23 @@ jQuery(function($){
|
||||
</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 ); ?>
|
||||
<?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' ), 'savebutton', 'save', false, array(
|
||||
'id' => 'save-all',
|
||||
'style' => 'display: none;',
|
||||
)
|
||||
);
|
||||
?>
|
||||
<?php
|
||||
submit_button(
|
||||
__( 'Save all changes' ),
|
||||
'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'] ); ?>" />
|
||||
@@ -2488,7 +2501,7 @@ submit_button(
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2534,7 +2547,7 @@ function media_upload_library_form( $errors ) {
|
||||
|
||||
list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query( $q );
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
<form id="filter" method="get">
|
||||
<input type="hidden" name="type" value="<?php echo esc_attr( $type ); ?>" />
|
||||
@@ -2550,127 +2563,127 @@ function media_upload_library_form( $errors ) {
|
||||
</p>
|
||||
|
||||
<ul class="subsubsub">
|
||||
<?php
|
||||
$type_links = array();
|
||||
$_num_posts = (array) wp_count_attachments();
|
||||
$matches = wp_match_mime_types( array_keys( $post_mime_types ), array_keys( $_num_posts ) );
|
||||
foreach ( $matches as $_type => $reals ) {
|
||||
foreach ( $reals as $real ) {
|
||||
if ( isset( $num_posts[ $_type ] ) ) {
|
||||
$num_posts[ $_type ] += $_num_posts[ $real ];
|
||||
} else {
|
||||
$num_posts[ $_type ] = $_num_posts[ $real ];
|
||||
<?php
|
||||
$type_links = array();
|
||||
$_num_posts = (array) wp_count_attachments();
|
||||
$matches = wp_match_mime_types( array_keys( $post_mime_types ), array_keys( $_num_posts ) );
|
||||
foreach ( $matches as $_type => $reals ) {
|
||||
foreach ( $reals as $real ) {
|
||||
if ( isset( $num_posts[ $_type ] ) ) {
|
||||
$num_posts[ $_type ] += $_num_posts[ $real ];
|
||||
} else {
|
||||
$num_posts[ $_type ] = $_num_posts[ $real ];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// If available type specified by media button clicked, filter by that type
|
||||
if ( empty( $_GET['post_mime_type'] ) && ! empty( $num_posts[ $type ] ) ) {
|
||||
$_GET['post_mime_type'] = $type;
|
||||
list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
|
||||
}
|
||||
if ( empty( $_GET['post_mime_type'] ) || $_GET['post_mime_type'] == 'all' ) {
|
||||
$class = ' class="current"';
|
||||
} else {
|
||||
$class = '';
|
||||
}
|
||||
$type_links[] = '<li><a href="' . esc_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
'post_mime_type' => 'all',
|
||||
'paged' => false,
|
||||
'm' => false,
|
||||
)
|
||||
)
|
||||
) . '"' . $class . '>' . __( 'All Types' ) . '</a>';
|
||||
foreach ( $post_mime_types as $mime_type => $label ) {
|
||||
$class = '';
|
||||
|
||||
if ( ! wp_match_mime_types( $mime_type, $avail_post_mime_types ) ) {
|
||||
continue;
|
||||
// If available type specified by media button clicked, filter by that type
|
||||
if ( empty( $_GET['post_mime_type'] ) && ! empty( $num_posts[ $type ] ) ) {
|
||||
$_GET['post_mime_type'] = $type;
|
||||
list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
|
||||
}
|
||||
|
||||
if ( isset( $_GET['post_mime_type'] ) && wp_match_mime_types( $mime_type, $_GET['post_mime_type'] ) ) {
|
||||
if ( empty( $_GET['post_mime_type'] ) || $_GET['post_mime_type'] == 'all' ) {
|
||||
$class = ' class="current"';
|
||||
} else {
|
||||
$class = '';
|
||||
}
|
||||
|
||||
$type_links[] = '<li><a href="' . esc_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
'post_mime_type' => $mime_type,
|
||||
'post_mime_type' => 'all',
|
||||
'paged' => false,
|
||||
'm' => false,
|
||||
)
|
||||
)
|
||||
) . '"' . $class . '>' . sprintf( translate_nooped_plural( $label[2], $num_posts[ $mime_type ] ), '<span id="' . $mime_type . '-counter">' . number_format_i18n( $num_posts[ $mime_type ] ) . '</span>' ) . '</a>';
|
||||
}
|
||||
/**
|
||||
* Filters the media upload mime type list items.
|
||||
*
|
||||
* Returned values should begin with an `<li>` tag.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @param string[] $type_links An array of list items containing mime type link HTML.
|
||||
*/
|
||||
echo implode( ' | </li>', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . '</li>';
|
||||
unset( $type_links );
|
||||
?>
|
||||
) . '"' . $class . '>' . __( 'All Types' ) . '</a>';
|
||||
foreach ( $post_mime_types as $mime_type => $label ) {
|
||||
$class = '';
|
||||
|
||||
if ( ! wp_match_mime_types( $mime_type, $avail_post_mime_types ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( isset( $_GET['post_mime_type'] ) && wp_match_mime_types( $mime_type, $_GET['post_mime_type'] ) ) {
|
||||
$class = ' class="current"';
|
||||
}
|
||||
|
||||
$type_links[] = '<li><a href="' . esc_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
'post_mime_type' => $mime_type,
|
||||
'paged' => false,
|
||||
)
|
||||
)
|
||||
) . '"' . $class . '>' . sprintf( translate_nooped_plural( $label[2], $num_posts[ $mime_type ] ), '<span id="' . $mime_type . '-counter">' . number_format_i18n( $num_posts[ $mime_type ] ) . '</span>' ) . '</a>';
|
||||
}
|
||||
/**
|
||||
* Filters the media upload mime type list items.
|
||||
*
|
||||
* Returned values should begin with an `<li>` tag.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @param string[] $type_links An array of list items containing mime type link HTML.
|
||||
*/
|
||||
echo implode( ' | </li>', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . '</li>';
|
||||
unset( $type_links );
|
||||
?>
|
||||
</ul>
|
||||
|
||||
<div class="tablenav">
|
||||
|
||||
<?php
|
||||
$page_links = paginate_links(
|
||||
array(
|
||||
'base' => add_query_arg( 'paged', '%#%' ),
|
||||
'format' => '',
|
||||
'prev_text' => __( '«' ),
|
||||
'next_text' => __( '»' ),
|
||||
'total' => ceil( $wp_query->found_posts / 10 ),
|
||||
'current' => $q['paged'],
|
||||
)
|
||||
);
|
||||
<?php
|
||||
$page_links = paginate_links(
|
||||
array(
|
||||
'base' => add_query_arg( 'paged', '%#%' ),
|
||||
'format' => '',
|
||||
'prev_text' => __( '«' ),
|
||||
'next_text' => __( '»' ),
|
||||
'total' => ceil( $wp_query->found_posts / 10 ),
|
||||
'current' => $q['paged'],
|
||||
)
|
||||
);
|
||||
|
||||
if ( $page_links ) {
|
||||
echo "<div class='tablenav-pages'>$page_links</div>";
|
||||
}
|
||||
?>
|
||||
if ( $page_links ) {
|
||||
echo "<div class='tablenav-pages'>$page_links</div>";
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="alignleft actions">
|
||||
<?php
|
||||
<?php
|
||||
|
||||
$arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC";
|
||||
$arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC";
|
||||
|
||||
$arc_result = $wpdb->get_results( $arc_query );
|
||||
$arc_result = $wpdb->get_results( $arc_query );
|
||||
|
||||
$month_count = count( $arc_result );
|
||||
$selected_month = isset( $_GET['m'] ) ? $_GET['m'] : 0;
|
||||
$month_count = count( $arc_result );
|
||||
$selected_month = isset( $_GET['m'] ) ? $_GET['m'] : 0;
|
||||
|
||||
if ( $month_count && ! ( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) {
|
||||
?>
|
||||
if ( $month_count && ! ( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) {
|
||||
?>
|
||||
<select name='m'>
|
||||
<option<?php selected( $selected_month, 0 ); ?> value='0'><?php _e( 'All dates' ); ?></option>
|
||||
<?php
|
||||
foreach ( $arc_result as $arc_row ) {
|
||||
if ( $arc_row->yyear == 0 ) {
|
||||
continue;
|
||||
}
|
||||
$arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
|
||||
<?php
|
||||
foreach ( $arc_result as $arc_row ) {
|
||||
if ( $arc_row->yyear == 0 ) {
|
||||
continue;
|
||||
}
|
||||
$arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
|
||||
|
||||
if ( $arc_row->yyear . $arc_row->mmonth == $selected_month ) {
|
||||
$default = ' selected="selected"';
|
||||
} else {
|
||||
$default = '';
|
||||
}
|
||||
if ( $arc_row->yyear . $arc_row->mmonth == $selected_month ) {
|
||||
$default = ' selected="selected"';
|
||||
} else {
|
||||
$default = '';
|
||||
}
|
||||
|
||||
echo "<option$default value='" . esc_attr( $arc_row->yyear . $arc_row->mmonth ) . "'>";
|
||||
echo esc_html( $wp_locale->get_month( $arc_row->mmonth ) . " $arc_row->yyear" );
|
||||
echo "</option>\n";
|
||||
}
|
||||
?>
|
||||
echo "<option$default value='" . esc_attr( $arc_row->yyear . $arc_row->mmonth ) . "'>";
|
||||
echo esc_html( $wp_locale->get_month( $arc_row->mmonth ) . " $arc_row->yyear" );
|
||||
echo "</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php submit_button( __( 'Filter »' ), '', 'post-query-submit', false ); ?>
|
||||
<?php submit_button( __( 'Filter »' ), '', 'post-query-submit', false ); ?>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -2680,8 +2693,8 @@ foreach ( $arc_result as $arc_row ) {
|
||||
|
||||
<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="library-form">
|
||||
|
||||
<?php wp_nonce_field( 'media-form' ); ?>
|
||||
<?php //media_upload_form( $errors ); ?>
|
||||
<?php wp_nonce_field( 'media-form' ); ?>
|
||||
<?php //media_upload_form( $errors ); ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
@@ -2696,15 +2709,15 @@ jQuery(function($){
|
||||
</script>
|
||||
|
||||
<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( null, $errors ); ?>
|
||||
<?php add_filter( 'attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2 ); ?>
|
||||
<?php echo get_media_items( null, $errors ); ?>
|
||||
</div>
|
||||
<p class="ml-submit">
|
||||
<?php submit_button( __( 'Save all changes' ), 'savebutton', 'save', false ); ?>
|
||||
<?php submit_button( __( 'Save all changes' ), 'savebutton', 'save', false ); ?>
|
||||
<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
|
||||
</p>
|
||||
</form>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2868,15 +2881,15 @@ function media_upload_max_image_resize() {
|
||||
$a = '<a href="' . esc_url( admin_url( 'options-media.php' ) ) . '" target="_blank">';
|
||||
$end = '</a>';
|
||||
}
|
||||
?>
|
||||
?>
|
||||
<p class="hide-if-no-js"><label>
|
||||
<input name="image_resize" type="checkbox" id="image_resize" value="true"<?php echo $checked; ?> />
|
||||
<?php
|
||||
<?php
|
||||
/* translators: 1: link start tag, 2: link end tag, 3: width, 4: height */
|
||||
printf( __( 'Scale images to match the large size selected in %1$simage options%2$s (%3$d × %4$d).' ), $a, $end, (int) get_option( 'large_size_w', '1024' ), (int) get_option( 'large_size_h', '1024' ) );
|
||||
?>
|
||||
?>
|
||||
</label></p>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2925,7 +2938,7 @@ function edit_form_image_editor( $post ) {
|
||||
} else {
|
||||
$not_open_style = ' style="display:none"';
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
<div class="imgedit-response" id="imgedit-response-<?php echo $attachment_id; ?>"></div>
|
||||
|
||||
@@ -2937,9 +2950,9 @@ function edit_form_image_editor( $post ) {
|
||||
<?php
|
||||
if ( $open ) {
|
||||
wp_image_editor( $attachment_id );}
|
||||
?>
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
<?php
|
||||
elseif ( $attachment_id && wp_attachment_is( 'audio', $post ) ) :
|
||||
|
||||
wp_maybe_generate_attachment_metadata( $post );
|
||||
@@ -3024,7 +3037,7 @@ function edit_form_image_editor( $post ) {
|
||||
if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) {
|
||||
echo ': ' . __( 'Displayed on attachment pages.' );
|
||||
}
|
||||
?>
|
||||
?>
|
||||
</label>
|
||||
<?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?>
|
||||
|
||||
@@ -3055,7 +3068,7 @@ function attachment_submitbox_metadata() {
|
||||
$media_dims = apply_filters( 'media_meta', $media_dims, $post );
|
||||
|
||||
$att_url = wp_get_attachment_url( $post->ID );
|
||||
?>
|
||||
?>
|
||||
<div class="misc-pub-section misc-pub-attachment">
|
||||
<label for="attachment_url"><?php _e( 'File URL:' ); ?></label>
|
||||
<input type="text" class="widefat urlfield" readonly="readonly" name="attachment_url" id="attachment_url" value="<?php echo esc_attr( $att_url ); ?>" />
|
||||
@@ -3077,7 +3090,7 @@ function attachment_submitbox_metadata() {
|
||||
} else {
|
||||
echo strtoupper( str_replace( 'image/', '', $post->post_mime_type ) );
|
||||
}
|
||||
?>
|
||||
?>
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
@@ -3122,7 +3135,7 @@ function attachment_submitbox_metadata() {
|
||||
if ( empty( $meta[ $key ] ) ) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
?>
|
||||
<div class="misc-pub-section misc-pub-mime-meta misc-pub-<?php echo sanitize_html_class( $key ); ?>">
|
||||
<?php echo $label; ?> <strong>
|
||||
<?php
|
||||
@@ -3137,10 +3150,10 @@ function attachment_submitbox_metadata() {
|
||||
echo esc_html( $meta[ $key ] );
|
||||
break;
|
||||
}
|
||||
?>
|
||||
?>
|
||||
</strong>
|
||||
</div>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
$fields = array(
|
||||
@@ -3166,20 +3179,20 @@ function attachment_submitbox_metadata() {
|
||||
if ( empty( $meta['audio'][ $key ] ) ) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
?>
|
||||
<div class="misc-pub-section misc-pub-audio misc-pub-<?php echo sanitize_html_class( $key ); ?>">
|
||||
<?php echo $label; ?> <strong><?php echo esc_html( $meta['audio'][ $key ] ); ?></strong>
|
||||
</div>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( $media_dims ) :
|
||||
?>
|
||||
?>
|
||||
<div class="misc-pub-section misc-pub-dimensions">
|
||||
<?php _e( 'Dimensions:' ); ?> <strong><?php echo $media_dims; ?></strong>
|
||||
</div>
|
||||
<?php
|
||||
<?php
|
||||
endif;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user