Nov
17
2017

Only allow access to specific wordpress upload types if logged in

I had an interesting problem earlier today where I’d created a custom WordPress plugin which was to be logged-in-user only, and happened to include some uploaded content. So in proper developer format, I made sure to leverage WordPress’ great media uploading capabilities as opposed to arbitrarily creating something to store files within the plugin directory, but soon discovered a problem! Though you could only browse the actual list of files if you were logged in, […]

Mar
17
2016

Query WordPress Database for Invalid Media Filenames

WordPress for some reason didn’t use to filter out invalid file names on upload, causing some interesting issues with charsets and rendering (specifically images not loading in browsers).  Using the following queries, you can easily find those items with invalid filenames, and their associated posts (which unfortunately means you’ll still have to replace them)… SELECT ID, post_title, post_content, post_parent, guid FROM wp_posts WHERE post_type = ‘attachment’ AND `post_status` = ‘inherit’ AND (guid LIKE ‘%.jpg’ OR […]

Jun
20
2013

Disable upgrade notification

Perfect for those ‘special’ inherited websites that aren’t forward compatible to prevent clients from breaking a website! Just add this to your theme functions.php file and rest a bit easier! add_filter( ‘pre_site_transient_update_core’, create_function( ‘$a’, "return null;" ) ); Source: http://wp-snippets.com/disable-wordpress-update/

Jun
19
2013

Add custom authormeta fields

Just drop this into your functions.php file, and call it a day! function added_user_profile( $contactmethods ) { $contactmethods[‘twitter’] = ‘Twitter’; $contactmethods[‘facebook’] = ‘Facebook’; return $contactmethods; } add_filter( ‘user_contactmethods’, ‘added_user_profile’, 10, 1 );

Jun
19
2013

Add TinyMCE Editor Anywhere

I had a difficult time finding a way that actually worked to add the TinyMCE editor used in the wp-admin area to textareas for my custom wordpress plugins, but after MUCH yelling, imaginary hair pulling, and some clever miracles, this is how you can add the tinymce editor to any textarea within wordpress (cheering!) add_filter( ‘wp_head’,’add_tinymce_editor’ ); function add_tinymce_editor() { wp_admin_css(‘thickbox’); wp_enqueue_script(‘post’); wp_enqueue_script(‘media-upload’); wp_enqueue_script(‘jquery’); wp_enqueue_script(‘jquery-ui-core’); wp_enqueue_script(‘jquery-ui-tabs’); wp_enqueue_script(‘tiny_mce’); wp_enqueue_script(‘editor’); wp_enqueue_script(‘editor-functions’); add_thickbox(); } After which you simply […]