jQuery: Using window url parameter

Let’s say we have passed a parameter to URL: www.mysite.com/?page=test

To collect the data form parameter we can use this function:

function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};

use of this code:

getUrlParameter('page');

or

if (getUrlParameter('page') == 'test'){
// do something
}

Increase WordPress upload file size limit

Have you tried to upload file, theme more than 8MB & it showed “The link you followed has expired.”? This is due to the upload file size limit in WP or your php.ini.

Here is how we can solve the problem in three ways. If one doesn’t work, try another one:

  1. Change .htaccess file:
    Go to root folder of your website. Find .htaccess file; if you can’t find, create one. Add the following code:

    php_value upload_max_filesize 64M
    php_value post_max_size 64M
    php_value max_execution_time 300
    php_value max_input_time 300
  2. Change php.ini file:
    Go to root folder of your website. Find php.ini file; if you can’t find, create one. Add the following code:

    upload_max_filesize = 64M
    post_max_size = 64M
    max_execution_time = 300
  3. Change functions.php file:
    Find this file from theme folder. Add the following code:

    @ini_set( 'upload_max_size' , '64M' );
    @ini_set( 'post_max_size', '64M');
    @ini_set( 'max_execution_time', '300' );

    Hopefully this will solve your problem.

Ref:

  1. wpbeginner.com
  2. wordpress.org

 

 

Momentum Scrolling iOS Device

iOS has default scrolling animation on Safari. When you flick the website up or down, it keeps going for a sec, then slow down & stop. This animation stop work when you use overflow:hidden. But you can add it back. Here is the code
html,body {
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
overflow-x: hidden;
overflow-y: scroll; /* must be scroll */
-webkit-overflow-scrolling: touch;
}