WordPress 3.5 Media Manager – add a button

This block of code will add a button right next to the “Insert into post” one. When clicked, it will send selected images to WP editor, each wrapped inside your template HTML: var wpMediaFramePost = wp.media.view.MediaFrame.Post; wp.media.view.MediaFrame.Post = wpMediaFramePost.extend( { mainInsertToolbar: function( view ) { “use strict”; wpMediaFramePost.prototype.mainInsertToolbar.call(this, view); var controller = this; this.selectionStatusToolbar( view … Read more

Resize the WP media Uploader iFrame

The default media box has hard coded HTML values so in order to alter the CSS for it you you have 2 options. Enqueue your own CSS and override the values Disable media-views.css completely and load a custom stylesheet. To enqueue your own style: function blah_admin_css() { wp_enqueue_style( ‘blah_admin_css’, path to your custom.css ); } … Read more

Adding wp_enqueue_media(); causes problem

There’s not enough information to really determine what is happening, but the best course of action is to make sure your code is only added to the options page, so it can’t interfere with anything on the edit page. You can use get_current_screen for that, like this: add_action( ‘current_screen’, ‘wpse113256_this_screen’ ); function wpse113256_this_screen() { $current_screen … Read more

Different upload path per file type

Change upload directory for PDF Files seems to be a good stepping stone forward. Although untested, looking at the code my adaptation would be along the lines of… <?php add_filter(‘wp_handle_upload_prefilter’, ‘custom_media_library_pre_upload’); add_filter(‘wp_handle_upload’, ‘custom_media_library_post_upload’); function custom_media_library_pre_upload($file){ add_filter(‘upload_dir’, ‘custom_media_library_custom_upload_dir’); return $file; } function custom_media_library_post_upload($fileinfo){ remove_filter(‘upload_dir’, ‘custom_media_library_custom_upload_dir’); return $fileinfo; } function custom_media_library_custom_upload_dir($path){ $extension = substr(strrchr($_POST[‘name’],’.’),1); if ( !empty( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)