Skip to content

Instantly share code, notes, and snippets.

@raideus
raideus / php-auto-includer.php
Created June 11, 2012 21:48
PHP Auto Include
<?php
/* --------------------------------------------------------------------
:: Auto-Includer
Loads PHP files from the /includes/ directory. For WordPress sites,
this code would go in your functions.php file.
-------------------------------------------------------------------- */
foreach (glob(__DIR__ . '/includes/*.php') as $my_theme_filename) {
@raideus
raideus / wp-remove-admin-menus.php
Created May 22, 2012 22:54
Remove Unwanted Menu Items from the WordPress Dashboard
<?php
/* --------------------------------------------------------------------
Remove Unwanted Menu Items from the WordPress Dashboard
- Requires WordPress 3.1+
-------------------------------------------------------------------- */
function sb_remove_admin_menus (){
// Check that the built-in WordPress function remove_menu_page() exists in the current installation
if ( function_exists('remove_menu_page') ) {
@raideus
raideus / wp-remove-links-menu.php
Created May 22, 2012 22:45
Remove Links Menu from WordPress Dashboard
@raideus
raideus / wp-absolute-sidebar-urls.php
Created May 10, 2012 22:24
WordPress Absolute Sidebar URLs
<?php
/* --------------------------------------------------------------------------------
Add Shortcode Support in Widgets
** Props to http://hackadelic.com/the-right-way-to-shortcodize-wordpress-widgets
-----------------------------------------------------------------------------------*/
if ( !is_admin() ):
add_filter('widget_text', 'do_shortcode', 11);
endif;
@raideus
raideus / wordpress-editor-styles.css
Created May 6, 2012 14:02
Override WordPress TinyMCE Editor Styles
#tinymce {
background: white;
}
#tinymce a {
color: #ff0000;
}
@raideus
raideus / wordpress-add-editor-style.php
Created May 6, 2012 13:56
Apply Your WordPress Theme Styles in the WYSIWYG Editor
<?php
// Add styles to the WYSIWYG editor. Function finds stylesheet from the root of the current theme's folder.
add_editor_style('style.css');
?>
@raideus
raideus / wordpress-fluid-images.js
Created April 29, 2012 17:35
jQuery script for implementing fluid images on a WordPress site
jQuery(document).ready(function($) {
// Remove width & height attributes from images (added by default in WordPress)
$('img').removeAttr('width').removeAttr('height');
// Remove style attribute on image captions, which sets a fixed width by default
$('.wp-caption').removeAttr('style');
});
@raideus
raideus / wordpress-fluid-images.css
Created April 29, 2012 17:29
CSS for implementing fluid images on a WordPress site.
img,
.wp-caption {
max-width: 100%;
}
@raideus
raideus / wp-enqueue-scripts-example1.php
Created April 27, 2012 16:43
Example of using wp_enqueue_scripts() in WordPress
<?php
// Create a function to enqueue our scripts
function add_my_scripts() {
// Enqueue the modernizr script file and specify that it should be placed in the <head>
wp_enqueue_script( 'modernizr', get_template_directory_uri() . '/js/libs/modernizr-2.5.3.min.js', array(), '2.5.2', false );
}
@raideus
raideus / wp-no-image-links.php
Created April 26, 2012 17:35
Stop WordPress from linking images by default