How to wp_upload_bits() to a sub-folder?

wp_upload_bits() uses wp_upload_dir() which fires the upload_dir filter allowing you to modify the upload directory’s path, sub-directory and URL. So you can use that filter to “force” wp_upload_bits() to use a custom path by doing something like: // Demo to get the image data. $url=”https://logo.clearbit.com/starcomww.com”; $content = file_get_contents( $url ); $_filter = true; // For … Read more

Protecting direct access to PDF and ZIP unless user logged in (without plugin)

RewriteCond %{REQUEST_FILENAME} -s RewriteRule ^wp-content/uploads/([^/]*\.(pdf|zip))$ filecheck.php?file=$1 [QSA,L] This actually looks OK, except if you have additional subdirectories within the /uploads directory? An alternative is to include an additional condition on the original rule that only rewrites the request if the request ends in .pdf or .zip. For example: RewriteCond %{REQUEST_URI} \.(pdf|zip)$ [NC] RewriteCond %{REQUEST_FILENAME} -s … Read more

How to use media upload on theme option page?

You are most likely to save the url of the image and not the whole image tag, and there is a great tutorial that explains just how to use the media uploader in your own theme or plugin: http://www.webmaster-source.com/2010/01/08/using-the-wordpress-uploader-in-your-plugin-or-theme/ update In case of using this in a meta box you will need the post id … Read more

Separate Media Library for each user

Built in features The Media Library has major updates with the upcoming version. You can see the changes in the slides by Daryl Koopersmith here. You can read the announcement and discussion on “Make”. Your request for “tags/categories” is already built into 3.5. Note The difference between themes and plugins is pretty easy: Display vs. … Read more

How to modify wp.media to get and display multiple images

So, this works. I’d be happy to implement and credit improvements! /** * @Script: WordPress Multiple Image Selection in jQuery * @Version: 0.1 * @Author: CK MacLeod * @Author URI: http://ckmacleod.com * @License: GPL3 */ jQuery(document).ready( function( $ ) { var myplugin_media_upload; $(‘#myplugin-change-image’).click(function(e) { e.preventDefault(); // If the uploader object has already been created, reopen … Read more

Media not actually deleted on disk when click “Permanent Delete”

So, after several attempts… it is a problem (or a feature) of the WPML multilanguage plugin. To start with, I have set up correctly the user permissions, as @WebElaine mentioned. Just in case something was not configures properly. More information on the following articles: Permissions to wp-content folder in Windows Server 2012 https://www.chillies.co.za/news/4421/The-Correct-Permissions-for-WordPress-on-IIS/ https://www.customfitonline.com/news/2013/6/20/solve-wordpress-on-windows-server-problems/ In … Read more

print_media_templates not applied in media manager plugin

Ok I’ve figured some things out by now: I was not returning the rendered image into anything In the javascript I have a render function media.view.AttachmentsBrowser = media.view.AttachmentsBrowser.extend({ render: function(){ var that = this; if(this.collection){ if(this.collection.models.length > 0){ this.clearImages(); _.each(this.collection.models, function (item){ //old way: that.renderImage(item); //now: this.$el.find(‘#lastli’).before(that.renderImage(item)); }, this); } } } }); Obviously my … Read more

Proper way to add a button to the top menu of the media library?

So, this is the only way I’ve found so far and it’s ugly, however WordPress offers no means of modifying this through filters that I can find in core. I present, the hacky “do-it-through-Javascript” method: add_action( ‘load-upload.php’, function(){ $js = <<<JAVASCRIPT jQuery(document).ready(function($){ setTimeout(function() { $(‘.wp-filter .button:last’ ).after($(‘<button class=”button”>Hi</button>’)); }, 1000); }); JAVASCRIPT; add_filter( ‘admin_footer’, function() … Read more

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