Skip to content

Instantly share code, notes, and snippets.

View mrizwan47's full-sized avatar
👋
Open to work

Rizwan mrizwan47

👋
Open to work
View GitHub Profile
@mrizwan47
mrizwan47 / php-html-css-js-minifier.php
Last active August 19, 2016 15:54 — forked from taufik-nurrohman/php-html-css-js-minifier.php
PHP Function to Minify HTML, CSS and JavaScript
<?php
/**
* ----------------------------------------------------------------------------------------
* Based on `https://github.com/mecha-cms/mecha-cms/blob/master/engine/plug/converter.php`
* ----------------------------------------------------------------------------------------
*/
@mrizwan47
mrizwan47 / delete-all-woocommerce-products.php
Last active October 14, 2016 20:07 — forked from mikaelz/delete-all-woocommerce-products.php
Remove all WooCommerce products from database via SQL
<?php
global $wpdb;
$wpdb->query("DELETE FROM $wpdb->terms WHERE term_id IN (SELECT term_id FROM $wpdb->term_taxonomy WHERE taxonomy LIKE 'pa_%')");
$wpdb->query("DELETE FROM $wpdb->term_taxonomy WHERE taxonomy LIKE 'pa_%'");
$wpdb->query("DELETE FROM $wpdb->term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM $wpdb->term_taxonomy)");
$wpdb->query("DELETE FROM $wpdb->term_relationships WHERE object_id IN (SELECT ID FROM $wpdb->posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id IN (SELECT ID FROM $wpdb->posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM $wpdb->posts WHERE post_type IN ('product','product_variation')");
$wpdb->query("DELETE pm FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
@mrizwan47
mrizwan47 / wc_change_sales_price.php
Last active June 27, 2022 00:10
Change woocommerce sales price programmatically
<?php
// Your Product ID
$product_id = 57;
$ecd_product = new WC_Product( $product_id );
/**
* Check if product exists
*/
if( $ecd_product->exists() ){
<?php
$dashicons = array(
'&#xf333;' => 'dashicons-menu',
'&#xf319;' => 'dashicons-admin-site',
'&#xf226;' => 'dashicons-dashboard',
'&#xf109;' => 'dashicons-admin-post',
'&#xf104;' => 'dashicons-admin-media',
'&#xf103;' => 'dashicons-admin-links',
'&#xf105;' => 'dashicons-admin-page',
'&#xf101;' => 'dashicons-admin-comments',
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mrizwan47
mrizwan47 / docker-compose.yaml
Created December 31, 2020 14:30
Docker for WordPress
version: '3'
services:
# Database
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
- /Volumes/DATA/Development/rizwan_47/sample-project/misc/database:/mysql-db/ # Change path before semicolon here
@mrizwan47
mrizwan47 / terminal.sh
Created February 15, 2021 17:53
Quick WP Installation on Ubuntu/Linux
# Download Latest WordPress
wget https://wordpress.org/latest.zip
# Unzip WP Zip file
unzip latest.zip
# (optional) change directory to something else
mv wordpress new_name
@mrizwan47
mrizwan47 / add_users.sql
Last active July 8, 2021 18:00
Create new WP user in wpengine through phpmyadmin
INSERT INTO
`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`)
VALUES (
NULL, 'rizwan', MD5('PASSWORD_HERE'), 'Riz', '[email protected]', '', NOW(), '', '0', 'Rizwan');
SET @WPUserID = LAST_INSERT_ID();
@mrizwan47
mrizwan47 / commands
Created September 19, 2021 12:32
systemd service for jupyter notebook
systemctl daemon-reload
systemctl enable jupyter.service
systemctl start jupyter.service
@mrizwan47
mrizwan47 / function.php
Created March 28, 2022 10:19
PHP - Get google uule by location name
// Following the direction from https://moz.com/blog/geolocation-the-ultimate-tip-to-emulate-local-search
function convert_uule( $location_name )
{
// Code for length that resets at 64
$len = strlen($location_name) % 64;
// uule mapping array
$uule_map = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';