Removing SWFObject Border around Flash®
If you’re like me and use SWFObject to embed flash into your web pages, then you’ve noticed the thin border around the swf when it has focus. Well that can easily be removed by using a little CSS.
object { outline:none; }
That’s it! Hope it helps.
MoreChanging the Wordpress Admin Logo
One of the most useful snippets I’ve found gives you the ability to change the Wordpress admin logo.
/** * Custom admin logo & remove thank you footer */ add_action('admin_head', 'adminLogo'); function adminLogo() { echo '<style type="text/css"> #header-logo { background-image: url('.get_bloginfo('wpurl').'LOGOIMAGE.png) !important; } #footer-left { display: none; } </style>'; }
*Note: The logo image should be 30 x 31 pixels in order to display properly
MoreAccessing Wordpress Databases
One of the more useful things I’ve learned while developing with Wordpress is the use of the $wpdb class which allows you to use the Wordpress database functions in your plugin without including the header and footer. This is useful when you’re using a bit of jQuery or AJAX to submit a form and get a call back w/o getting all the Wordpress headers and HTML.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | // Wordpress root directory (from plugin's directory) $path = '../../../'; include_once($path . 'wp-config.php'); include_once($path . 'wp-load.php'); include_once($path . 'wp-includes/wp-db.php'); function attachments() { global $wpdb; $sql = "SELECT * FROM ".$wpdb->posts." WHERE post_type = 'attachment'"; $rows = $wpdb->get_results($sql); $html = ''; foreach($rows as $row) { $html .= '<div><a href="'.$row->guid.'">'.$row->post_title.'</a></div>'; } return $html; } // Outputs a list of the attachments (media files) echo attachments(); // |
TinyMCE in WordPress Plugin
I’ve been to the edge of the internet and back, before I found this tidbit of code that will allow you to use TinyMCE in your WordPress plugins!
1. Add the following code to your plugin
1 2 3 4 5 6 7 8 9 10 11 12 | add_filter('admin_head','myplugin_tinymce'); function myplugin_tinymce() { wp_admin_css('thickbox'); wp_print_scripts('jquery-ui-core'); wp_print_scripts('jquery-ui-tabs'); wp_print_scripts('post'); wp_print_scripts('editor'); add_thickbox(); wp_print_scripts('media-upload'); if (function_exists('wp_tiny_mce')) { wp_tiny_mce(); } } |
2. Call the editor in your plugin
1 | the_editor($content_to_load); |
Never Stop Learning
I’ve been a developer for over 10 years now and I stumbled upon an extremely simple bit of coding that I’ve never either seen or realized was out there. It’s so simple that I feel like a complete n00b for not knowing this!
More
