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
add_filter( 'woocommerce_general_settings', 'add_order_number_start_setting' ); | |
/* | |
woocommerce_general_settings | |
woocommerce_catalog_settings | |
woocommerce_page_settings | |
woocommerce_inventory_settings | |
woocommerce_tax_settings | |
woocommerce_shipping_settings | |
woocommerce_payment_gateways_settings |
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
// Random Generator | |
function gen_rand(length, type ) { | |
var mode = type || 0; | |
/* | |
* @length , Length of Random output | |
* @type , Mode of Random Generator | |
0 = mixed string mode | |
1 = digits | |
2 = string |
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
$num = 123; | |
$format = 'ABC-####-09'; | |
print preg_replace('/(#+)/e', 'str_pad($num, strlen("$1"), 0, STR_PAD_LEFT)', $format); |
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
// map: an instance of google.maps.Map object | |
// latlng: an array of google.maps.LatLng objects | |
// latlng: needs lat, long as interger , so must parse them to interger first. | |
var latlngbounds = new google.maps.LatLngBounds(); | |
for (var i = 0; i < latlng.length; i++) { | |
latlngbounds.extend(latlng[i]); | |
} | |
map.fitBounds(latlngbounds); |
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
// <url><posttype_slug><taxonomy> | |
function my_custom_post_work() { | |
$labels = array( | |
'name' => _x( 'Work', 'post type general name' ), | |
'singular_name' => _x( 'Work', 'post type singular name' ), | |
'add_new' => _x( 'Add New', 'book' ), | |
'add_new_item' => __( 'Add New Work' ), | |
'edit_item' => __( 'Edit Work' ), | |
'new_item' => __( 'New Work' ), | |
'all_items' => __( 'All Work' ), |
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
/* ----------------------------------------------------- | |
* Page - Checks child subset to enable widget in sidebar | |
-------------------------------------------------- */ | |
function has_page_child_set( $page_check ) { | |
global $post; | |
//global $page_check; | |
//$page_check = $name; |
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 | |
$args = array( | |
'post_type'=> 'services', | |
'areas' => 'painting', | |
'order' => 'ASC' | |
); | |
$the_query = new WP_Query( $args ); | |
if($the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); |
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 improved_trim_excerpt($text) { | |
global $post; | |
if ( '' == $text ) { | |
$text = get_the_content(''); | |
$text = apply_filters('the_content', $text); | |
$text = str_replace('\]\]\>', ']]>', $text); | |
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text); | |
$text = strip_tags($text, '<p>'); | |
$excerpt_length = 80; | |
$words = explode(' ', $text, $excerpt_length + 1); |
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 str_lreplace($needle, $replace, $haystack) | |
{ | |
/* | |
int strrpos ( string $haystack , string $needle [, int $offset = 0 ] ) | |
Find the numeric position of the last occurrence of needle in the haystack string. | |
*/ | |
$pos = strrpos($haystack, $needle); | |
if($pos !== false) | |
{ | |
$subject = substr_replace($haystack, $replace, $pos, strlen($needle)); |
NewerOlder