Skip to content

Instantly share code, notes, and snippets.

@raideus
raideus / my_homepage_scripts.php
Created April 13, 2012 17:12
Register & Enqueue scripts for a particular page (Wordpress)
<?php
function my_homepage_scripts() {
if ( is_front_page() ) {
// jQuery Cycle plugin
wp_register_script( 'jquery-cycle', get_template_directory_uri() . '/js/libs/jquery.cycle.all.js', array( 'jquery' ), '2012-03-13T10:15', false );
wp_enqueue_script( 'jquery-cycle' );
// Custom settings for jQuery Cycle
wp_register_script( 'jquery-cycle-settings', get_template_directory_uri() . '/js/jquery-cycle-settings.js', array( 'jquery-cycle', 'jquery' ), '2012-04-13T10:15', false );
@raideus
raideus / wp-no-image-links.php
Created April 26, 2012 17:35
Stop WordPress from linking images by default
@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 / 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 / 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-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-editor-styles.css
Created May 6, 2012 14:02
Override WordPress TinyMCE Editor Styles
#tinymce {
background: white;
}
#tinymce a {
color: #ff0000;
}
@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 / wp-remove-links-menu.php
Created May 22, 2012 22:45
Remove Links Menu from WordPress Dashboard
@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') ) {