Friday, March 11, 2022

How to Delete All Products in WooCommerce using SQL Command?

  1. Log in to the phpMyAdmin portal
  2. Select the database that has all the products to be deleted. Make sure, that you backup your database before executing the SQL statement!
  3. Than select table {prefix}_posts and run the SQL statement as shown.


DELETE relations.*, taxes.*, terms.*

FROM metro4u_term_relationships AS relations

INNER JOIN metro4u_term_taxonomy AS taxes

ON relations.term_taxonomy_id=taxes.term_taxonomy_id

INNER JOIN metro4u_terms AS terms

ON taxes.term_id=terms.term_id

WHERE object_id IN (SELECT ID FROM metro4u_posts WHERE post_type IN ('product','product_variation'));


DELETE FROM metro4u_postmeta WHERE post_id IN (SELECT ID FROM metro4u_posts WHERE post_type IN ('product','product_variation'));

DELETE FROM metro4u_posts WHERE post_type IN ('product','product_variation');


Note: "metro4u" is a prefix. Set your Database Table prefix

Friday, February 25, 2022

How to change root pasword using ssh command

 The procedure to change the root user password on Ubuntu Linux:

Type the following command to become root user and issue passwd:

sudo -i

passwd

OR set a password for root user in a single command:

sudo passwd root

Test it your root password by typing the following command:

su -

Wednesday, January 5, 2022

Friday, December 31, 2021

Git Configuration and Commit Command

Git Configuration :


git config --global user.email "you@example.com"

git config --global user.name "Your Name"


Commit comman for Mac:

git reset --mixed origin/main 
git add * 
git commit -m "This is a new commit for what I originally planned to be amended" 
git push origin main

Commit comman for Windows:


git add * or git add --all
git commit -m"first message"
git remote add origin "LINK"
git push -u origin master

Tuesday, December 28, 2021

Track from where method is being called in codeigniter


For example, suppose your function name is test, use below code
Code:

function test( )
{
$backtrace = debug_backtrace();

print_r( $backtrace );
}
It will print the details from where the test method is being called.

How to Allow WebP Upload in WordPress using Function

//enable upload for webp image files.

function webp_upload_mimes($existing_mimes) {

    $existing_mimes['webp'] = 'image/webp';

    return $existing_mimes;

}

add_filter('mime_types', 'webp_upload_mimes');


//enable preview / thumbnail for webp image files.

function webp_is_displayable($result, $path) {

    if ($result === false) {

        $displayable_image_types = array( IMAGETYPE_WEBP );

        $info = @getimagesize( $path );


        if (empty($info)) {

            $result = false;

        } elseif (!in_array($info[2], $displayable_image_types)) {

            $result = false;

        } else {

            $result = true;

        }

    }


    return $result;

}

add_filter('file_is_displayable_image', 'webp_is_displayable', 10, 2);

function webp_upload_mimes($existing_mimes) {
    $existing_mimes['webp'] = 'image/webp';
    return $existing_mimes;
}
add_filter('mime_types', 'webp_upload_mimes');

//enable preview / thumbnail for webp image files.
function webp_is_displayable($result, $path) {
    if ($result === false) {
        $displayable_image_types = array( IMAGETYPE_WEBP );
        $info = @getimagesize( $path );

        if (empty($info)) {
            $result = false;
        } elseif (!in_array($info[2], $displayable_image_types)) {
            $result = false;
        } else {
            $result = true;
        }
    }

    return $result;
}
add_filter('file_is_displayable_image', 'webp_is_displayable', 10, 2);

Tuesday, November 23, 2021

How to use Siteground SSH in MacOS terminal

On Siteground the steps are as follows:
Logon to your account at Siteground.
Open Site Tools for your website.
Go to Devs = SSH Keys Manager.
Enter a Key name (e.g. privatekey)
Generate a Password
Click the Create button.
Go to3dots=Manage IP access to limit the IP addresses that can use this connection.
Go to3dots= Private Key and copy it to your clipboard.
On your local machine, open your preferred Terminal
Browse to /path/to/your/privatekey
Create new file, call it myschool and paste the Private key.
Run the following commands
chmod 600 privatekey
ssh-add privatekey
Back in the Site Tools = SSH Keys Manager, go to3dots= SSH Credentials to discover the username and hostname to use.
Now you can run the following command, in order to gain SSH access

ssh username@privatekey -p12345

Office 2021 Activation using command

  @echo off title Activate Microsoft Office 2021 (ALL versions) for FREE - office.com&cls&echo =====================================...