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 | |
/** | |
* Convert numbers to english | |
* | |
* @param $input | |
* | |
* @return array|string | |
*/ | |
function ywp_convert_numbers_to_latin( $input ): array|string { | |
$arabic = [ '٩', '٨', '٧', '٦', '٥', '٤', '٣', '٢', '١', '٠' ]; |
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 | |
$taxonomies = array( | |
'category', // for posts categories | |
'post_tag', // for posts tags | |
'product_tag', // for wc products tags | |
'product_cat', // for wc products categories | |
'product_brand', // for woocommerce brand plugin | |
'brand', // for yith product brand |
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 a custom field to woocommerce registeration form | |
*/ | |
add_action( 'woocommerce_register_form', 'ywp_add_name_field_ro_wc_register_form' ); | |
function ywp_add_name_field_ro_wc_register_form() { | |
woocommerce_form_field( | |
'ywp_register_fname', | |
array( | |
'type' => 'text', |
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 | |
/** | |
* add shortcode to wp | |
*/ | |
add_shortcode( 'stock_status', 'display_product_stock_status' ); | |
function display_product_stock_status( $atts) { | |
$atts = shortcode_atts( | |
array('id' => get_the_ID() ), | |
$atts, |
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 | |
/** | |
* Show weight and dementions end of additional information | |
*/ | |
remove_action( 'woocommerce_product_additional_information', 'wc_display_product_attributes', 10 ); | |
add_action( 'woocommerce_product_additional_information', 'ywp_display_product_attributes', 10 ); | |
function ywp_display_product_attributes( $product ) { | |
$product_attributes = array(); |
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 | |
/** | |
* Hook on auth_cookie_expiration | |
* The code goes in your theme/child theme functions.php | |
* You can also use this plugin: https://wordpress.org/plugins/code-snippets/ | |
*/ | |
add_filter ( 'auth_cookie_expiration', 'ywp_change_remember_me' ); | |
function ywp_change_remember_me( $expire ) { | |
return YEAR_IN_SECONDS; |
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
# For posts categories | |
SELECT t.term_id AS id, | |
t.name AS 'Term Title', | |
t.slug AS 'Slug' | |
FROM wp_terms t | |
LEFT JOIN wp_term_taxonomy tt | |
ON t.term_id = tt.term_id | |
WHERE tt.taxonomy = 'category' | |
ORDER BY name; |