Install WordPress plugins without providing FTP access

1. In wp-config.php add define(‘FS_METHOD’, ‘direct’);
2. Make server writable the directories wp-content/, wp-content/plugins/
3. Install the plugin (copy the plugin dir into the wp-content/plugins dir).
4. Remove server writable right from directories wp-content/, wp-content/plugins/

Hope this will solve your problem.

How to create simple parallax effect.

It is really simple to create parallax effect on your site. Add this script to your html head.


In your body tag add -> onload=”onLoad()”. This will automatically start the script on page load. Here is some css you will need for example to work:

body{background: url("/image/bg-texture-1200.png") repeat-x top center; width: 100%;  background-color: #E9F5FA; background-attachment: fixed;}

PHP function for downloading images from http

This function will download images from another site , resize them and put suffix (if needed).

function download_resized_jpeg($filename,$width,$height,$suffix){
	$name = explode('/',$filename);
	$newfilename = end($name);

	// Content type
	//header('Content-Type: image/jpeg');

	list($width_orig, $height_orig, $type) = getimagesize($filename);

	$ratio_orig = $width_orig/$height_orig;

	if ($width/$height > $ratio_orig) {
	   $width = $height*$ratio_orig;
	} else {
	   $height = $width/$ratio_orig;
	}

	// Resample
	$image_p = imagecreatetruecolor($width, $height);
	if ($type == 1)
    {
        $image = imagecreatefromgif($filename);
    }
    elseif ($type == 2)
    {
        $image = imagecreatefromjpeg($filename);
    }
    elseif ($type == 3)
    {
        $image = imagecreatefrompng($filename);
    }
    else
    {
        $image = imagecreatefromwbmp($filename);
    }
	
	if($type==1 or $type==3) //this code below should preserve transparency but I couldn't try it out for now...
    {
        imagealphablending($image_p, false);
        imagesavealpha($image_p, true);
        imagecolortransparent($image_p, imagecolorallocatealpha($image_p, 0, 0, 0, 127));
    }
	
	imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);

	// Output
	if ($type == 1)
        imagegif ($image_p, "../pictures/$newfilename$suffix".".gif", 100);
    elseif ($type == 2)
        imagejpeg($image_p, "../pictures/$newfilename$suffix".".jpg", 100);
    elseif ($type == 3)
        imagepng ($image_p, "../pictures/$newfilename$suffix".".png", 0);
    else
        imagewbmp ($image_p, "../pictures/$newfilename$suffix".".bmp", 100);
}

Passing values in JS in objects is by reference

Passing in a primitive type variable like a string or a number, the value is passed in by value. Passing in an object, however, passes it in by reference.

Here is an example:

 

Multiple background images in CSS

This example will show how to make multiple backgrounds for one div. It is perfect for headers and menus and it contains 3 parts ( left, middle, right ).

.box-header{background-image: url(images/left-orange.png),url(images/right-orange.png);background-repeat: no-repeat,no-repeat;background-position: 0% 0%, 100% 0%;height: 25px;line-height: 23px; text-align:center; width: 99%;margin-bottom: -14px;    position: relative; font-size: 15px; font-weight:bold; margin-top: 20px;}
.box-header::after{background-image: url(images/orange-mid.png); background-repeat: repeat-x;  display:block; width: 91.5%; content:""; height: 24px; margin-top: -23px; margin-left: 14px;}

What is this (IIFE) construct in javascript?

Immediately-Invoked Function Expression, or shorter: IIFE. It executes immediately after it’s created.
This pattern is often used when trying to avoid polluting the global namespace, because all the variables used in the function are not visible outside its scope. It’s good to use when we have multiple functions with the same name.




The output will be 5.