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
//How to fix “this file type is not permitted for security reasons” in WordPress | |
function enable_extended_upload ( $mime_types =array() ) { | |
// The MIME types listed here will be allowed in the media library. | |
// You can add as many MIME types as you want. | |
$mime_types['gz'] = 'application/x-gzip'; | |
$mime_types['zip'] = 'application/zip'; | |
$mime_types['rtf'] = 'application/rtf'; | |
$mime_types['ppt'] = 'application/mspowerpoint'; |
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
/* Dynamically add options to select field */ | |
// Assuming 'custom-select' is the class of select field | |
<select class="custom-select"> | |
<option value="a">A</option> | |
<option value="b">B</option> | |
<option value="c">C</option> | |
</select> |
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
* To replace all runs of white spaces in a string with ( _ ) underscore => /\s+/g | |
-> Replace adjacent white spaces with a single underscore | |
* To replace whitespace in a string with underscore => / /g | |
-> Replace each white space with a single underscore. Each adjacent white spaces will be replaced |
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
// Replace multiple strings with multiple values | |
var str = "I have a cat, a dog, and a goat."; | |
var mapObj = { | |
cat:"monkey", | |
dog:"goat", | |
goat:"cat" | |
}; | |
str = str.replace(/cat|dog|goat/gi, function(matched){ |
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
function readURL(input){ | |
if (input.files && input.files[0]) { | |
var reader = new FileReader(); | |
reader.onload = function (e) { | |
//e.target.result ->contain image url in encoded form | |
//Do action with e.target.result here. Dont place outside onload function. won't work | |
}; | |
reader.readAsDataURL(input.files[0]); | |
} | |
} |
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
// Remove all data attributes of an element | |
$.each( $("element-selected").data(), function(i){ | |
$("div").removeAttr("data-" + i); | |
}); |
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 | |
$mailer = WC()->mailer(); | |
$mails = $mailer->get_emails(); | |
$emails = wc()->mailer()->emails; // Contains all WooCommerce email classes with details | |
?> |
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 | |
// Change product title for products in shop page | |
remove_action( 'woocommerce_shop_loop_item_title','woocommerce_template_loop_product_title', 10 ); | |
function change_product_title() { | |
$additional_text = ' More info'; | |
echo '<h2 class="woocommerce-loop-product__title">' . get_the_title() .$additional_text.'</h2>'; | |
} | |
add_action('woocommerce_shop_loop_item_title','change_product_title'); |
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 | |
$val = preg_replace('/&.*?;/', '', $val); |
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 strSlice($str, $start, $end) { | |
$end = $end - $start; | |
return substr($str, $start, $end); | |
} | |
$name = 'migthegreek'; | |
// Get substr from index 3 to 6 | |
echo strSlice($name, 3, 6); |