Posts

Woocommerce : Add Body class to product page if the current product is in the cart

 function ywp_check_product_is_in_cart( $product_id ) {     if ( ! WC()->cart->is_empty() ) {         foreach( WC()->cart->get_cart() as $cart_item ) {             $cart_item_ids = array( $cart_item['product_id'], $cart_item['variation_id'] );             if( in_array( $product_id, $cart_item_ids ) ) {                 return true;             }         }         return false;     }     return false; } add_filter( 'body_class', 'ywp_body_class_for_cart_items' ); function ywp_body_class_for_cart_items( $classes ) {     // Check user currently is in product page     if( ! is_singular( 'product' ) ) {         return $classes;     }     if( ywp_check_product_is_in_cart( get_the_id() ) ) {   ...

Understanding the Default WordPress .htaccess File: Functions and Configuration

The default WordPress .htaccess file is a crucial component of a WordPress site's configuration. This post delves into its significance, explaining its functions and how it influences site behavior. From handling permalinks to enhancing security, the .htaccess file plays a pivotal role in customizing site settings. This guide provides a comprehensive overview of the default directives in the WordPress .htaccess file and how they impact website performance. Whether you're a beginner seeking to grasp the basics or an experienced user looking for advanced customization tips, this post covers it all. Dive in to discover the power of the .htaccess file and learn how to leverage it for an optimized and secure WordPress site. # BEGIN WordPress RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress 

Exceeding Maximum Execution Time Error (30s)

 Increase the time limit As a last resort, you could temporarily extend the time limit, using either ini_set('max_execution_time', '300'); //300 seconds = 5 minutes or set_time_limit(300); In php.ini, like this: max_execution_time = 360; Maximum execution time of each script, in seconds (I CHANGED THIS VALUE) max_input_time = 120; Maximum amount of time each script may spend parsing request data ;max_input_nesting_level = 64; Maximum input variable nesting level memory_limit = 128M; Maximum amount of memory a script may consume (128MB by default)

Export commands in MySQL

 Use the mysqldump utility to export the database. The command is used as follows: mysqldump -uUSERNAME -p DB_NAME > exported.sql To export a specific table, you can use the following command: $ mysqldump -u USER_NAME -p DB_NAME table1 table2 > file_name To export multiple databases, you can use the following command: $ mysqldump -u USER_NAME -p ---databases DB_NAME1 DB_Name2 DB_Name3> file_name To prevent a table from being exported, use the following command: $ mysqldump -u USER_NAME -p DB_NAME --ignore-table=DB_NAME.TABLE_NAME > file_name

Setting up Virtual Hosts in XAMPP

Step 1) C:\WINDOWS\system32\drivers\etc\ Open the "hosts" file : 127.0.0.1       localhost 127.0.0.1       nownow.com 127.0.0.1       xpendy.in ::1             localhost Step 2) xampp\apache\conf\extra\httpd-vhosts.conf <VirtualHost *:80>     ServerAdmin admin@nownow.com     DocumentRoot "C:/xamppnew/htdocs"     ServerName nownow.com     ErrorLog "logs/nownow.com.log"     CustomLog "logs/nownow.com-access.log" common </VirtualHost> <VirtualHost *:80>     ServerAdmin admin@xpendy.in     DocumentRoot "C:/xamppnew/htdocs/xpendy"     ServerName xpendy.in     ErrorLog "logs/xpendy.in.log"     CustomLog "logs/xpendy.in-access.log" common </VirtualHost> Step 3) Restart XAMPP and now run :

Got a packet bigger than max_allowed_packet

 Also, change the my.cnf or my.ini file (usually found in /etc/mysql/) or(C:\xampp\mysql\bin\) under the mysqld section and set: max_allowed_packet=100M or you could run these commands in a MySQL console connected to that same server: set global net_buffer_length=1000000;  set global max_allowed_packet=1000000000;

PHP Artisan Tinker toolkit

 Provide us Intractive Shell For application by which we can make Opreations in Application # Craete,Update,Delete, Get and all coding things C:\xamppnew\htdocs\laravel>php artisan tinker Psy Shell v0.11.20 (PHP 8.2.4 — cli) by Justin Hileman > env('SESSION_DRIVER') = "file" > env('DB_CONNECTION') = "mysql" > User::all(): > User::create(['name'=>'test','email' => 'terst@gmail.com','password' => '123456']);