Skip to content

Instantly share code, notes, and snippets.

View DevWael's full-sized avatar
👨‍💻
WordPress-ing

Ahmad Wael DevWael

👨‍💻
WordPress-ing
View GitHub Profile
@DevWael
DevWael / data.txt
Created January 5, 2020 17:13
serialized_data
a:669:{s:8:"last_tab";s:0:"";s:20:"show-loading-overlay";s:0:"";s:7:"wrapper";s:4:"wide";s:6:"layout";s:9:"fullwidth";s:7:"sidebar";s:12:"blog-sidebar";s:14:"header-wrapper";s:4:"full";s:14:"banner-wrapper";s:4:"wide";s:19:"breadcrumbs-wrapper";s:4:"full";s:12:"main-wrapper";s:4:"wide";s:14:"footer-wrapper";s:4:"full";s:14:"sticky-sidebar";s:1:"1";s:19:"show-mobile-sidebar";s:1:"1";s:22:"show-content-type-skin";s:1:"1";s:18:"show-category-skin";s:1:"1";s:8:"gmap_api";s:39:"AIzaSyDTVOtdFjlQjNx-jbJZb3vtgglwqLKhXbQ";s:8:"html-top";s:0:"";s:11:"html-banner";s:0:"";s:16:"html-content-top";s:0:"";s:22:"html-content-inner-top";s:0:"";s:25:"html-content-inner-bottom";s:0:"";s:19:"html-content-bottom";s:0:"";s:11:"html-bottom";s:0:"";s:9:"logo-type";s:0:"";s:9:"logo-text";s:0:"";s:4:"logo";a:9:{s:3:"url";s:102:"https://package.innoshop.org/wp-content/uploads/2019/12/innoshop-first-theme-low-products-2-needs1.png";s:2:"id";s:4:"3132";s:6:"height";s:3:"417";s:5:"width";s:4:"1427";s:9:"thumbnail";s:110:"https://package.i
@DevWael
DevWael / allowed_html_tags.php
Created November 19, 2019 16:11
array list of allowed html tags to use with wp_kses() function
<?php
function dw_allowed_html_tags() {
$allowed_tags = array(
'a' => array(
'class' => array(),
'href' => array(),
'rel' => array(),
'title' => array(),
),
@DevWael
DevWael / update_plugin_programatically.php
Created November 17, 2019 17:01
Update WordPress Plugin Programatically.
<?php
function replace_plugin() {
// modify these variables with your new/old plugin values
$plugin_slug = 'wp-reset/wp-reset.php';
$plugin_zip = 'https://downloads.wordpress.org/plugin/wp-reset.latest-stable.zip';
$old_plugin_slug = 'reset-wp/reset-wp.php';
echo 'If things are not done in a minute <a href="plugins.php">click here to return to Plugins page</a><br><br>';
echo 'Starting ...<br><br>';
@DevWael
DevWael / saudi states.php
Created November 13, 2019 15:40
saudi arabia states array
<?php
$states = array(
'RIY' => esc_html__('Riyadh','porto'),
'MEC' => esc_html__('Mecca','porto'),
'MED' => esc_html__('Medina','porto'),
'BUR' => esc_html__('Buraydah','porto'),
'TAB' => esc_html__('Tabuk','porto'),
'DAM' => esc_html__('Dammam','porto'),
'AL ' => esc_html__('Al Ahsa','porto'),
@DevWael
DevWael / saudi_states.php
Last active November 13, 2019 15:42
saudi arabia states array
<?php
$states = array(
'RIY' => esc_html__('Riyadh','porto'),
'MEC' => esc_html__('Mecca','porto'),
'MED' => esc_html__('Medina','porto'),
'BUR' => esc_html__('Buraydah','porto'),
'TAB' => esc_html__('Tabuk','porto'),
'DAM' => esc_html__('Dammam','porto'),
'AL ' => esc_html__('Al Ahsa','porto'),
@DevWael
DevWael / woocommerce_saudi_kuwait_states.php
Created November 7, 2019 11:22
add saudi arabia and kuwait states to woocommerce
<?php
add_filter( 'woocommerce_states', 'dw_woocommerce_states' );
function dw_woocommerce_states( $states ) {
$states['KW'] = array(
'KWQ' => __('Dasmān','porto'),
'KWA' => __('Sharq','porto'),
'KWZ' => __('Mirgāb','porto'),
'KWW' => __('Jibla','porto'),
@DevWael
DevWael / check_woocommerce_cart.php
Created August 7, 2019 10:00
check if woocommerce cart is empty or not
<?php
function is_empty_cart() {
if ( ! class_exists( 'woocommerce' ) ) {
return false; //Woocpmmerce isn't isntalled
}
if ( sizeof( WC()->cart->get_cart() ) > 0 ) {
return false; //Cart is not empty
}
@DevWael
DevWael / generate_uuid.php
Created July 23, 2019 12:48
function to generate uuid in php
<?php
function prefix_generate_uuid() {
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
// 16 bits for "time_mid"
mt_rand( 0, 0xffff ),
@DevWael
DevWael / total_orders_count.php
Created July 9, 2019 11:48
get all orders count in woocommerce website
<?php
function prefix_orders_count() {
if ( ! class_exists( 'woocommerce' ) ) {
return false;
}
$args = [
'posts_per_page' => - 1,
'post_type' => 'shop_order',
'post_status' => 'any',
@DevWael
DevWael / wc_top_customers.php
Created July 9, 2019 10:12
List top woocommerce customers by their total spent
<?php
function prefix_top_customers_with_total_spend( $length = 5 ) {
if ( ! class_exists( 'woocommerce' ) ) {
return;
}
$data = [];
$args = [
'role' => 'customer',
'number' => - 1,
'fields' => 'ID'