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
#301 Redirects for .htaccess | |
#Redirect a single page: | |
Redirect 301 /pagename.php http://www.domain.com/pagename.html | |
#Redirect an entire site: | |
Redirect 301 / http://www.domain.com/ | |
#Redirect an entire site to a sub folder | |
Redirect 301 / http://www.domain.com/subfolder/ |
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 | |
// From https://remicorson.com/mastering-woocommerce-products-custom-fields/ | |
// Display Fields | |
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' ); | |
// Save Fields | |
add_action( 'woocommerce_process_product_meta', 'woo_add_custom_general_fields_save' ); |
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 | |
/** | |
* Forcibly disable ajax add to cart | |
*/ | |
add_filter( 'woocommerce_product_supports', 'yanco_disable_ajax_add_to_cart_supports', 10, 3 ); | |
function yanco_disable_ajax_add_to_cart_supports( $supports_ajax, $feature, $product ) { | |
if ( 'ajax_add_to_cart' == $feature ) { | |
$supports_ajax = 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
# Gets all product category term IDs | |
SELECT wp_terms.term_id | |
FROM wp_terms | |
LEFT JOIN wp_term_taxonomy ON wp_terms.term_id = wp_term_taxonomy.term_id | |
WHERE wp_term_taxonomy.taxonomy = 'product_cat' | |
# Use the list of IDs from above into IN ( ) using commaseparation | |
# This will return all the product IDs which are associated to product categories | |
SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id IN( ) |
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 | |
add_filter( 'sensei_course_slug', 'yanco_sensei_course_slug', 1000 ); | |
function yanco_sensei_course_slug( ) { | |
return 'kursus'; | |
} | |
add_filter( 'sensei_lesson_slug', 'yanco_sensei_lesson_slug', 1000 ); | |
function yanco_sensei_lesson_slug() { | |
return 'lektion'; |
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 | |
$posts = get_posts( array( | |
'numberposts' => -1, | |
'post_type' => 'student', | |
'post_status' => 'publish', | |
'meta_query' => array( | |
'relation' => 'AND', | |
array( | |
'key' => 'acf_student_group', |
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 | |
// Remember to insert the {$field_name} | |
add_filter('acf/update_value/name={$field_name}', 'yanco_check_change_of_field_value', 10, 3); | |
function yanco_check_change_of_field_value( $value, $post_id, $field) { | |
$old_value = get_post_meta($post_id, $field['name'], true); | |
if ($old_value != $value) { |
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 | |
add_filter( 'gettext', 'yanco_filter_gettext', 10, 3 ); | |
function yanco_filter_gettext( $translated, $original, $domain ) { | |
// Use the text string exactly as it is in the translation file | |
if ( $translated == '' ) { | |
$translated = ''; | |
} |
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 yanco_has_active_subscription( $user_id = '' ) { | |
if( function_exists( 'wcs_user_has_subscription' ) ) { | |
// When a $user_id is not specified, get the current user Id | |
if( '' == $user_id && is_user_logged_in() ) { | |
$user_id = get_current_user_id(); | |
} | |
// User not logged in we return 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
{ | |
"name": "SERVER", | |
"profiles": { | |
"development": { | |
"host": "", | |
"username": "", | |
"password": "", | |
"remotePath": "", | |
"uploadOnSave": true, |