Cursor suddenly jumping from textarea

If we use typejs in our document this type of issue will occur find below code to fix.
$(“.textarea”).bind(‘keypress’, function(e) {
if(e.which == 32){
var textarea_val = $(“.textarea”),
val_ask = textarea_val.val();
textarea_val.focus().val(“”).val(val_ask);
}
});

Advertisement

HTTPS redirection code for htaccess

/*Total website redirect to HTTPS*/

ExpiresActive On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]


/*Redirect specific page to HTTPS*/

ExpiresActive On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTPS} !=on [NC]
RewriteCond %{REQUEST_URI} /page_path/
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

array_slice function for array pagination

array_slice function we will use for array pagination to get some part of array

$items = array(1,2,3,4,5,6,7,8,9,10);
$limit = 3;

$qty_items = count($items);
$qty_pages = ceil($qty_items / $limit);

$curr_page = isset($_GET[‘page’]) ? $_GET[‘page’] : 1;
$next_page = $curr_page < $qty_pages ? $curr_page + 1 : null;
$prev_page = $curr_page > 1 ? $curr_page – 1 : null;

$offset = ($curr_page – 1) * $limit;
$items = array_slice($items, $offset, $limit);

$items // Array of elements

$offset // how many elements leave at the time of fetching

$limit //get number of elements from array

Pagination code

for($i = 1; $i <= $qty_pages; $i++){

echo $i;

}

ceil() function return integer number.

Change label & placeholder in woo-commerce checkout billing form

Please find below code to change label & placeholder in woo-commerce checkout billing form

add_filter( ‘woocommerce_checkout_fields’ , ‘custom_override_checkout_fields’ );
function custom_override_checkout_fields( $fields ) {
unset($fields[‘billing’][‘billing_last_name’]);
$fields[‘billing’][‘billing_first_name’][‘placeholder’] = ‘Contact Name’;
$fields[‘billing’][‘billing_first_name’][‘label’] = ‘Contact Name’;
return $fields;
}

Sorry, it seems there are no available payment methods which support subscriptions. Please contact us if you require assistance or wish to make alternate arrangements.

When getting this type of issue please check site SSL is enable or not.

Stripe is enabled, but the force SSL option is disabled; your checkout may not be secure! Please enable SSL and ensure your server has a valid SSL certificate – Stripe will only work in test mode.

Delete all files or directories from specified path using php

Please find below code for remove files and directories using PHP.

$folder = “test/test2/test3”; or $folder = “test/test.txt”;
deleteDirectory($folder);
function deleteDirectory($dir) {
if (!file_exists($dir)) { return true; }
if (!is_dir($dir) || is_link($dir)) {
return unlink($dir);
}
foreach (scandir($dir) as $item) {
if ($item == ‘.’ || $item == ‘..’) { continue; }
if (!deleteDirectory($dir . “/” . $item, false)) {
chmod($dir . “/” . $item, 0777);
if (!deleteDirectory($dir . “/” . $item, false)) return false;
};
}
return rmdir($dir);
}