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
// ^([0-9a-zA-Z\._])+@([a-zA-Z0-9])+\.([0-9A-Za-z]){2,4}([\.a-zA-Z0-9]){0,3}+$ | |
// example : (jQuery) Javascript | |
function validateEmail(email){ | |
var pattren = new RegExp("^([0-9a-zA-Z\._])+@([a-zA-Z0-9])+\.([0-9A-Za-z]){2,4}([\.a-zA-Z0-9]){0,3}+$"); | |
if(pttren.test(email)){ | |
return true; | |
} else |
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 | |
/** | |
* @param : $template_name | |
* @Author : Azi Baloch | |
* Description : this function will recognize that is the wordpress current page | |
* using N template or not . | |
* eg . i want to add body id depending on template then i can use this function | |
* to check the currently being used template | |
**/ |
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 timeToString($time) { | |
$t = $time / 60; | |
$t = number_format($t, 2); | |
// Result 1.5; | |
$__t = explode('.', $t); | |
$m = "0.".$__t[1]; | |
$m * 60; | |
$m = $m*60; |
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
SELECT p.* FROM knr_posts p, knr_term_taxonomy tt, knr_term_relationships tr | |
WHERE p.ID=tr.`object_id` | |
AND tt.`term_id`=tr.`term_taxonomy_id` | |
AND (p.post_type = 'recipe_cpt' OR | |
AND p.post_status = 'publish' | |
AND tt.`term_taxonomy_id`=7 |
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 customDateString($return = false){ | |
$date = ""; | |
$dayName = date("l"); | |
$dayNumber = date('d'); | |
$monthName = date('F'); | |
$year = date("Y"); | |
$st = array(1,31); | |
$nd = array(2,22); |
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 | |
$pat = 'if\(.*\)\s?\{\n?(.*\s\n?)+\}' | |
$matches = array(); | |
$code = 'if($var != $var2) { | |
// code | |
}'; | |
$isFound = preg_match($pat,$code,$matches); |
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
/** | |
* @param bool $return | |
* @return mixed | |
*/ | |
function get_current_template_name($return = FALSE) { | |
$files = get_included_files(); | |
$result = null; | |
$e = 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
<?php | |
$g = null; | |
function generate_unique_name(){ | |
global $g; | |
if(is_null($g)) { | |
return $g = (((rand()*rand())+rand())); | |
} | |
return ++$g; | |
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 Center method to jquery | |
jQuery.fn.center = function () { | |
this.css("position","absolute"); | |
this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) + | |
$(window).scrollTop()) + "px"); | |
this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) + | |
$(window).scrollLeft()) + "px"); | |
return this; | |
} | |
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 | |
/** | |
* @param string $pages | |
* @param int $range | |
* @param WP_Query|null $custom_query | |
* @author Azi Baloch <www.azibaloch.com> | |
*/ | |
function wp_print_numaric_pagination( $pages = '', $range = 4, $custom_query = null) { | |
global $paged; |
OlderNewer