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
public static function benchmark($func1,$func2='',$no=100,$e=true,$f1args=null,$f2args=null) { | |
$exists1 = (is_array($func1)) ? method_exists($func1[0],$func1[1] ) : function_exists($func1); | |
$exists2 = (is_array($func2)) ? method_exists($func2[0],$func2[1]) : function_exists($func2); | |
if( ! $exists1 ) return false; | |
$result ='<pre>'; | |
// Run the function(s) given no# of time. | |
$f1total = 0; | |
$f2total = 0; | |
$f1p = 0; | |
$f2p = 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
<?php | |
function get_random_post_link() { | |
$args = array( | |
'orderby' => 'rand', | |
'posts_per_page' => '1', | |
); | |
$wp_query = new WP_Query( $args ); | |
if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_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 eo_get_a_rand_postlink() { | |
global $wpdb; | |
$rand_post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY RAND() LIMIT 1"); | |
return get_permalink($rand_post_id); | |
} |
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 $pobjtaxes = get_object_taxonomies( $tcptyp, 'object' ); | |
foreach( $pobjtaxes as $pobjk => $pobjtax ) { | |
$ptxargs = array( | |
'orderby' => 'name', | |
'order' => 'ASC', | |
'fields' => 'id=>name' | |
); | |
$pterms = get_terms($pobjk, $ptxargs); | |
?> | |
<div class="form-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
function eo_del_qy_trans($post_id,$post,$update) { | |
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return; | |
global $wpdb; | |
$ptyp = $post->post_type; | |
// Find and delete all query transients involved in this post type | |
$trans_name = $ptyp . '_qy_res'; | |
$like = '%' . $wpdb->esc_like( $trans_name ) . '%'; | |
$qs = $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE %s", $like ); | |
$qy_trans_names = $wpdb->get_results( $qs, ARRAY_N ); | |
foreach ( $qy_trans_names as $qyt ) { |
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 header("Content-type: text/html; charset=utf-8"); | |
// require( 'xyz.php' ); | |
// global $abc; | |
set_time_limit(20000); | |
// kaçar kaçar ? | |
$getc = 100; | |
$offset = (isset($_GET['offset'] ) ) ? intval( $_GET['offset'] ) : 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
/** Yeni durumu kayıt et **/ | |
function hp_kargolandi_status_register() { | |
register_post_status( 'wc-kargolandi', array( | |
'label' => 'Kargolanmış', | |
'public' => true, | |
'exclude_from_search' => false, | |
'show_in_admin_all_list' => true, | |
'show_in_admin_status_list' => true, | |
'label_count' => _n_noop( 'Kargolanmış <span class="count">(%s)</span>', 'Kargolanmış <span class="count">(%s)</span>' ) | |
) ); |
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 coldiff($R1,$G1,$B1,$R2,$G2,$B2){ | |
return max($R1,$R2) - min($R1,$R2) + | |
max($G1,$G2) - min($G1,$G2) + | |
max($B1,$B2) - min($B1,$B2); | |
} | |
function brghtdiff($R1,$G1,$B1,$R2,$G2,$B2){ | |
$BR1 = (299 * $R1 + 587 * $G1 + 114 * $B1) / 1000; | |
$BR2 = (299 * $R2 + 587 * $G2 + 114 * $B2) / 1000; |
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 to retrieve cached query result from database - Esp. handy for complicated queries. | |
* Assumes both will produce same result based on $args, ie. if WP_Query has the exact same arguments with the query to be requested | |
* - Parameter - | - Default - | - Description - | |
* $args = array | WP_Query($args) | no default, required; | |
* $exp = int | 86400 (1 day) | freshness, get new results if stored result is older than given time period in seconds. | | |
* $q_uid = string | NULL | unique query_id, used as suffix . If a result transient with this id exists it will be retrieved. | |
* $strict = boolean | false | ignore all assumptions, do a strict check. | |
* $d = boolean | false | Debug, prints a debug message informing if its read from cache, or performed a wp_query like it normally would. |
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 my_billing_postcode( $address_fields ) { | |
$address_fields['postcode']['required'] = false; | |
$address_fields['postcode']['label'] = "Posta Kodu"; | |
return $address_fields; | |
} | |
add_filter( 'woocommerce_default_address_fields', 'my_billing_postcode' ); |
OlderNewer