Move Elements on Mouse Move

TweenMax used for smooth movement

$('[data-parallaxit]').each(function(){
    var $this = $(this),
    movement = $this.data('parallax-value');
    $(window).mousemove(function(e) {
        $win = $(this),
        relX = e.pageX - $win.offset().left,
        relY = e.pageY - $win.offset().top;

        TweenMax.to($this, 1, {
            x: (relX - $win.width() / 2) / $win.width() * movement,
            y: (relY - $win.height() / 2) / $win.height() * movement
        });
    });
});

For jQuery click on this example here

Advertisements

Input Field on focus Label out Effect

HTML



<div class="textfield">
  <label class="">Full name</label>
  <input type="text" name="fullname" value="">
</div>



jQuery

$('input[type="text"]').each(function(){
	checkfield($(this));
}).on('focus', function(){
	$(this).closest('.textfield').find('label').addClass('focused');
}).on('blur', function(){
	checkfield($(this));
});

$('.textfield label').on('click', function(){
	$(this).next('input').focus();
});

function checkfield($this){
	var parent = $this.closest('.textfield').find('label');
		if($this.val() == ''){
		parent.removeClass('focused');
	}else{
		parent.addClass('focused'); 
	}
}


CSS

.textfield {
    position: relative;
}
.textfield label {
    position: absolute;
    background: none;
    margin: 0;
    font-size: 14px;
    top: 14px;
    text-transform: uppercase;
    letter-spacing: 4px;
    font-weight: 500;
    left: 18px;
    transition: all 0.2s ease-in-out;
    -o-transition: all 0.2s ease-in-out;
    -ms-transition: all 0.2s ease-in-out;
    -moz-transition: all 0.2s ease-in-out;
    -webkit-transition: all 0.2s ease-in-out;
}
input[type="text"]{
    border: 1px solid #a0bad9;
    background: #ffffff;
    border-radius: 4px;
    width: 50%;
    color: #64767f;
    font-size: 13px;
    line-height: 14px;
    margin: 0;
    padding: 12px 15px;
}
.textfield label.focused {
  top: -15px;
  font-size: 10px;
}

Example

Create Custom Widget

Creating the widget

class speedy_widget extends WP_Widget {
 
	function __construct() {
		parent::__construct(
			// Base ID of your widget
			'speedy_widget', 
			 
			// Widget name will appear in UI
			__('Speedy Widget', 'speedy_widget_domain'), 
			 
			// Widget description
			array( 'description' => __( 'Sample widget based on Speedy Tutorial', 'speedy_widget_domain' ), ) 
		);
	}
	 
	// Creating widget front-end
	 
	public function widget( $args, $instance ) {
		$title = apply_filters( 'widget_title', $instance['title'] );

		// before and after widget arguments are defined by themes
		echo $args['before_widget'];
		if ( ! empty( $title ) )
		echo $args['before_title'] . $title . $args['after_title'];
		 
		// This is where you run the code and display the output
		echo __( 'Hello, World!', 'speedy_widget_domain' );
		echo $args['after_widget'];
	}
			 
	// Widget Backend 
	public function form( $instance ) {
		if ( isset( $instance[ 'title' ] ) ) {
			$title = $instance[ 'title' ];
		}
		else {
			$title = __( 'New title', 'speedy_widget_domain' );
		}
		// Widget admin form
		?>
		

			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> 
			<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
		

	<?php 
	}
		 
	// Updating widget replacing old instances with new
	public function update( $new_instance, $old_instance ) {
		$instance = array();
		$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
		return $instance;
	}

}


Register and load the widget

function speedy_load_widget() {
    register_widget( 'speedy_widget' );
}
add_action( 'widgets_init', 'speedy_load_widget' );

Unregister Post Type

Add in function.php

function delete_post_type(){
  	unregister_post_type('POST TYPE NAME');
}
add_action('init','delete_post_type', 100);

Maintenance Mode without Plugin

Add in function.php

// Activate WordPress Maintenance Mode
function wp_maintenance_mode(){
    if(!current_user_can('edit_themes') || !is_user_logged_in()){
        wp_die('<h1>Website under Maintenance</h1><br>We are performing scheduled maintenance. We will be back on-line shortly!');
    }
}
add_action('get_header', 'wp_maintenance_mode');

Wp Config Settings

MySQL settings

define( 'DB_NAME',     'database_name_here' );
define( 'DB_USER',     'username_here' );
define( 'DB_PASSWORD', 'password_here' );
define( 'DB_HOST',     'localhost' );
define( 'DB_CHARSET',  'utf8mb4' );


MySQL database table prefix.

$table_prefix = 'wp_';


SSL

define( 'FORCE_SSL_LOGIN', true );
define( 'FORCE_SSL_ADMIN', true );


Custom WordPress URL.

define( 'WP_SITEURL',     'http://example.com/blog' );
define( 'WP_HOME',        'http://example.com/blog' );
define( 'WP_CONTENT_URL', 'http://example.com/blog' );
define( 'UPLOADS',        'http://example.com/blog/upload' );


Disable Post Revisions.

define( 'WP_POST_REVISIONS', false );


Media Trash.

define( 'MEDIA_TRASH', true );
define( 'EMPTY_TRASH_DAYS', '2' );


Remove Theme Editor

define( 'DISALLOW_FILE_EDIT', true );


Repair and optimize database

In your browser, go to the URL http://yoursite.com/wp-admin/maint/repair.php

define( 'WP_ALLOW_REPAIR', true);


DISALLOW_FILE_MODS

Disables plugin and theme updates and installation through the Dashboard. It also disables all file modifications within the Dashboard, thus removing the Theme Editor and Plugin Editor.

define( 'DISALLOW_FILE_MODS', true );


Updates

define( 'AUTOMATIC_UPDATER_DISABLED', true ); // Disable all automatic updates:

define( 'WP_AUTO_UPDATE_CORE', false ); // Disable all core updates:

define( 'WP_AUTO_UPDATE_CORE', 'minor' ); // Enable core updates for minor releases (default)


Multi Site

define( 'WP_ALLOW_MULTISITE', true );


PHP Memory

define( 'WP_MEMORY_LIMIT', '128' );
define( 'WP_MAX_MEMORY_LIMIT', '400' );


WordPress Cache

define( 'WP_CACHE', true );


Compression

define('SCRIPT_DEBUG', true); //loads the development (non-minified) versions of all scripts and CSS, and disables compression and concatenation
define( 'COMPRESS_CSS',        false ); //disables compression of CSS
define( 'COMPRESS_SCRIPTS',    false ); //disables compression of scripts
define( 'CONCATENATE_SCRIPTS', false ); //disables compression and concatenation of scripts and CSS
define( 'ENFORCE_GZIP',        true ); //forces gzip for compression (default is deflate)


CRON

define( 'DISABLE_WP_CRON',      'true' );
define( 'ALTERNATE_WP_CRON',    'true' );


Cleanup Image Edits Overwrite

define( 'IMAGE_EDIT_OVERWRITE', true );


Absolute path to the WordPress directory.

if ( !defined('ABSPATH') )
	define('ABSPATH', dirname(__FILE__) . '/');

Get Url Query String

The following code will return a JavaScript Object containing the URL parameters:

function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

For example, if you have the URL:

http://www.example.com/?me=myValue&name2=SomeOtherValue

This code will return:

{
"me" : "myValue",
"name2" : "SomeOtherValue"
}

var me = getUrlVars()["me"];
var name2 = getUrlVars()["name2"];