Enqueue Jquery

This is how to enqueue jquery and several other scripts that depend on jQuery. Paste the following into your functions.php file: /** * Add jQuery */ function add_jquery_script() { wp_deregister_script( ‘jquery’ ); wp_register_script( ‘jquery’, ‘https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js’); wp_enqueue_script( ‘jquery’ ); } add_action(‘wp_enqueue_scripts’, ‘add_jquery_script’); function my_scripts_method() { wp_enqueue_script( ‘custom-script’, get_template_directory_uri() . ‘/js/theme.script.js’, array( ‘jquery’ ) ); wp_enqueue_script( ‘jquery-easing’, Read More…

Jquery no conflict $ instead of Jquery

If you really like the short $ instead of jQuery, you can use the following wrapper around your code: jQuery(document).ready(function($) { // Inside of this function, $() will work as an alias for jQuery() // and other libraries also using $ will not be accessible under this shortcut });

PHP debugging

For debugging PHP this function is your friend. It will output whatever you have in the () to the browser and then stop the script. print_r($form_data); exit();

WP_http(); SSL

WordPress verifies the  SSL cert when you use  $request = new WP_Http(); Sometimes it throws an error because it doesn’t recognize the SSL. To fix it add this code to the functions.php file. add_filter(‘https_ssl_verify’, ‘__return_false’);

Document.ready vs window.load

I implemented a custom slider plugin called flexslider2 by woothemes and It worked in chrome and safari, but not firefox and IE. I figured out that if I moved my javascript/jQuery code that is used to call call the slider from jQuery(document).ready(function() { } to $(window).load(function() { } it fixed the problem

Firefox absolute positioning

Firefox absolute positioning doesn’t work in table cells. you have to change display:table-cells to display:block. Of course then you have to change your css to get it to look like you want it to again.

Redirect to Homepage Snippet

//redirect admins to the dashboard and other users to the homepage function my_login_redirect( $redirect_to, $request, $user ){ //is there a user to check? if( is_array( $user->roles ) ) { //check for admins if( in_array( “administrator”, $user->roles ) ) { // redirect them to the default place return home_url( ‘/wp-admin/’ ); } else { return home_url(); Read More…