This file contains 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
/** | |
* Check the validity of an Iranian national code | |
* | |
* @param string $code The national code to be validated. | |
* @return bool True if the code is valid, false otherwise. | |
*/ | |
function check_national_code($code) | |
{ | |
// Check if the input code is a 10-digit number | |
if (!preg_match('/^[0-9]{10}$/', $code)) { |
This file contains 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
/** | |
* @snippet Add iranian national code in the checkout with editing in admin | |
* @author Rasool Vahdati | |
* @compatible WooCommerce 6 | |
*/ | |
/** | |
* Check the validity of an Iranian national code | |
* | |
* @param string $code The national code to be validated. |
This file contains 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
/** | |
* @snippet Add iranian national code in the checkout with display in admin | |
* @author Rasool Vahdati | |
* @compatible WooCommerce 6 | |
*/ | |
/** | |
* Check the validity of an Iranian national code | |
* | |
* @param string $code The national code to be validated. |
This file contains 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
/** | |
* @snippet Calculate Total Sales By Product Category | |
* @author Rasool Vahdati | |
* @compatible WooCommerce 7 | |
*/ | |
/** | |
* Retrieve orders containing products from a specific category - Written by Rodolfo Melogli | |
* | |
* @param string $cat_slug The slug of the product category. |
This file contains 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
/** | |
* @snippet Calculate Orders Count By Product Category | |
* @author Rasool Vahdati | |
* @compatible WooCommerce 7 | |
*/ | |
/** | |
* Retrieve orders containing products from a specific category - Written by Rodolfo Melogli | |
* | |
* @param string $cat_slug The slug of the product category. |
This file contains 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
// Setting SOAP configuration to disable WSDL caching and adjust socket timeout | |
ini_set('soap.wsdl_cache_enabled', 0); // Disable WSDL caching | |
ini_set('soap.wsdl_cache_ttl', 900); // Set the time to live for cached WSDL files to 900 seconds (15 minutes) | |
ini_set('default_socket_timeout', 15); // Set the default socket timeout to 15 seconds | |
// Define parameters for the SOAP request | |
$params = array('param1'=>$param1); | |
// Define the WSDL URL | |
$wsdl = 'http://service_url/method?WSDL'; |
This file contains 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 | |
function tidaweb_upload_base64_image( $base64_image_data, $base64_file_name ) | |
{ | |
// check and get path of upload directory | |
$upload_dir = wp_upload_dir(); | |
$upload_path = str_replace( '/', DIRECTORY_SEPARATOR, $upload_dir['path'] ) . DIRECTORY_SEPARATOR; | |
$img = $base64_image_data; | |
if(strpos($img, 'image/jpg') !== false) | |
{ |
This file contains 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 | |
function tidaweb_image_url_to_base64( $attach_id ) | |
{ | |
// get image src -> $image_info[0] | |
$image_info = wp_get_attachment_image_src( $attach_id, 'full' ); | |
$image_file = file_get_contents( $image_info[0] ); | |
// get filename from url | |
$filename = basename( get_attached_file( $attach_id ) ); | |
$image_file_type = wp_check_filetype( $filename ); |