Ubuntu 14.04 – PHP Version Upgraded

php -v

Shows:

PHP 5.6.25-2+deb.sury.org~trusty+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologiescode

In the page the php code phpinfo();

phpinfo();

Shows:
PHP Version 5.5.9-1ubuntu4.19

Now to correct this you need to:

sudo a2dismod php5
sudo a2enmod php5.6
sudo service apache2 restart

Cheers

Zip and UnZip with FTP

Find here the PHP script, just upload.

 

  • Upload zipCF.php on the directory which you want to make zip file
  • Open zipCF.php with your browser
  • Provide a Name for the zip file
  • Click on Create Zip file
  • It will create the zip file if everything is ok and provide a success message just below the submit button
  • If you see the success message, go to ftp client or browse direct url to zip file from your browser
  • Download the newly created zip file
  • Use it anyhow you need
  • Delete zipCF.php file from your server to avoid security issues

 

How can I import a database with MySQL from terminal?

Prompt for password:

 mysql -u username -p databasename < filename.sql  

Enter password directly (not secure):

 mysql -u username -pPlainPassword databasename filename.sql 

Example:

mysql -u root -p wp_users < wp_users.sql

mysql -u root -pPassword123 wp_users --default-character-set=utf8 < wp_users.sql

See also:
4.5.1.5. Executing SQL Statements from a Text File

How to Fix Drop Down Menu not Working on iPad


jQuery(document).ready(function($){

    if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
     $(".main-navigation li:has(ul) > a").bind('touchstart',function(e){

        e.stopPropagation();
    	e.preventDefault();

		if($(this).hasClass("oneTouch")){
  			$(this).removeClass("oneTouch");
  			window.location = $(this).attr("href");
  		}
		else{
			$(this).addClass("oneTouch");
		}

     });
    }

});

» Read more

Bootstrap 3 Carousel randomize item (Snippet)

$('#myCarousel.carousel[data-type="multi"] .item').each(function(){

  $('#myCarousel.carousel[data-type="multi"] .item').removeClass('active').eq(Math.floor((Math.random() * $('#myCarousel.carousel[data-type="multi"] .item').length))).addClass("active");    
  var next = $(this).next();
  
    
  if (!next.length) {
    next = $(this).siblings(':first');
  }
  next.children(':first-child').clone().appendTo($(this));
  
  for (var i=0;i<4;i++) {
    next=next.next();
    if (!next.length) {
        next = $(this).siblings(':first');
  	}
    
    next.children(':first-child').clone().appendTo($(this));
  }
});


Superslides for Mobile

To make the superslide script work also for mobile in addition to the left & right arrow key add this snippet:

$("#slideshow").on("touchstart", function(event){
        var xClick = event.originalEvent.touches[0].pageX;
    $(this).one("touchmove", function(event){
        var xMove = event.originalEvent.touches[0].pageX;
        if( Math.floor(xClick - xMove) > 5 ){
            $(this).superslides('animate', 'next');
        }
        else if( Math.floor(xClick - xMove) < -5 ){
            $(this).superslides('animate', 'prev');
        }
    });
    $("#slideshow").on("touchend", function(){
            $(this).off("touchmove");
    });
});

Include Bootstrap Styles and Scripts In A WordPress Theme From CDN

If you are using WordPress then it’s not a good idea to directly link your stylesheet and JavaScript in the header.php (or footer.php) file. Instead WordPress includes enqueue functions to add them to your theme which is the proper way to add jQuery and other scripts.

The following 2 functions should be added to your functions.php file to include the required files. It adds the Bootstrap stylesheet & the default theme stylesheet (uncomment the ‘my-style’ line in the pwwp_enqueue_my_scripts() function to enqueue default stylesheet) in the head and the Bootstrap JavaScript & jQuery in the footer. It also tells WordPress that the Bootstrap JavaScript file depends on jQuery being loaded for it to function.

function tc_enqueue_my_scripts() {
    // jQuery is stated as a dependancy of bootstrap-js - it will be loaded by WordPress before the BS scripts 
    wp_enqueue_script( 'bootstrap-js', '//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js', array('jquery'), true); // all the bootstrap javascript goodness
}
add_action('wp_enqueue_scripts', 'tc_enqueue_my_scripts');

function tc_enqueue_my_styles() {
    wp_enqueue_style( 'bootstrap', '//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' );

    // this will add the stylesheet from it's default theme location if your theme doesn't already
    //wp_enqueue_style( 'my-style', get_template_directory_uri() . '/style.css');
}
add_action('wp_enqueue_scripts', 'tc_enqueue_my_styles');