This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global $wpdb; | |
return intval( $wpdb->get_var( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value LIKE '%/$filename'" ) ); | |
courtesy: https://poanchen.github.io/blog/2017/04/10/how-to-check-if-an-image-already-existed-in-wp-content-upload-directory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_the_user_ip() | |
{ | |
if (!empty($_SERVER['HTTP_CLIENT_IP'])) { | |
//check ip from share internet | |
$ip = $_SERVER['HTTP_CLIENT_IP']; | |
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { | |
//to check ip is pass from proxy | |
$ip = $_SERVER['HTTP_X_FORWARDED_FOR']; | |
} else { | |
$ip = $_SERVER['REMOTE_ADDR']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$post_types = [ | |
'faqs' => [ | |
'post_slug' => 'faqs', | |
'post_title' => 'Faqs', | |
'taxonomy_name' => 'faqs-category', | |
'dashicons' => 'dashicons-admin-site-alt3', | |
'taxonomy' => false, | |
'thumbnail' => false | |
], | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('woocommerce_cart_contents_count', 'get_total_cart_count'); | |
function get_total_cart_count($count) | |
{ | |
return count(WC()->cart->get_cart()); // easy! | |
} | |
function ajaxify_cart_count_fragments($fragments) | |
{ | |
// Turn on output buffering |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$fileName = "contact-list-" . date('Y-m-d') . ".xls"; | |
ob_end_clean(); | |
$fields = array('ID', 'Name', 'Email', 'Phone', 'Request For', 'Job Address', 'Work Type', 'About Job', 'Created At'); | |
// $output = fopen('php://output', 'w'); | |
// fputcsv($output, $fields); | |
$excelData = implode("\t", array_values($fields)) . "\n"; | |
function filterData(&$str){ | |
$str = preg_replace("/\t/", "\\t", $str); | |
$str = preg_replace("/\r?\n/", "\\n", $str); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function create_custom_post_types() | |
{ | |
$post_type = [ | |
'wps-service' => [ | |
'name' => 'Services', | |
'title' => true, | |
'slug' => 'wps-service', | |
'is_category' => true, | |
'taxonomy' => 'wps-service-taxonomy', | |
'icon' => 'dashicons-networking', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require dirname(__FILE__).'/wp-blog-header.php'; | |
$wpdb->query("DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%')"); | |
$wpdb->query("DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%'"); | |
$wpdb->query("DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy)"); | |
$wpdb->query("DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))"); | |
$wpdb->query("DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))"); | |
$wpdb->query("DELETE FROM wp_posts WHERE post_type IN ('product','product_variation')"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function extend_admin_search( $query ) { | |
// Extend search for document post type | |
$post_type = 'document'; | |
// Custom fields to search for | |
$custom_fields = array( | |
"_file_name", | |
); | |
if( ! is_admin() ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://intl-tel-input.com/node_modules/intl-tel-input/examples/gen/country-sync.html | |
https://intl-tel-input.com/ |
NewerOlder