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 | |
/ * Convert an address into latitude longitude */ | |
function getLatLong($address){ | |
$_url = sprintf('http://maps.google.com/maps?output=js&q=%s',rawurlencode($address)); | |
$_result = false; | |
if($_result = file_get_contents($_url)) { | |
if(strpos($_result,'errortips') > 1 || strpos($_result,'Did you mean:') !== false) return false; | |
preg_match('!center:\s*{lat:\s*(-?\d+\.\d+),lng:\s*(-?\d+\.\d+)}!U', $_result, $_match); |
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 file_get_contents_curl($url) { | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_HEADER, 0); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser. | |
curl_setopt($ch, CURLOPT_URL, $url); | |
$data = curl_exec($ch); |
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 dkc_add_css_on_pages() { | |
echo ' | |
#csp-dialog-msgid[style], #csp-dialog-msgid-plural[style] {font-size:14px!important; font-family:"Lucida Console"!important; color:#333; padding:10px;background:#D8E8F5;border:none;line-height:18px!important } | |
#csp-dialog-msgstr[style], #csp-dialog-msgstr-0[style], #csp-dialog-msgstr-1[style] {font-size:14px!important; font-family:"Lucida Console"!important; color:#000; background:#FAFCFE;border:none;padding:10px;line-height:18px!important } | |
#csp-dialog-msgstr[style]:focus, #csp-dialog-msgstr-0[style]:focus, #csp-dialog-msgstr-1[style]:focus {font-size:14px!important;-webkit-box-shadow: 0px 1px 0px 2px #A6BFD3; box-shadow: 0px 1px 0px 2px #A6BFD3;: 0px 0px 10px 2px #A6BFD3;background:#f7f7f7} | |
#csp-dialog-body strong {color:#85B7E0} |
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 hex2rgb($hex) { | |
$hex = str_replace("#", "", $hex); | |
if(strlen($hex) == 3) { | |
$r = hexdec(substr($hex,0,1).substr($hex,0,1)); | |
$g = hexdec(substr($hex,1,1).substr($hex,1,1)); | |
$b = hexdec(substr($hex,2,1).substr($hex,2,1)); | |
} 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 | |
// Shortcode implementation | |
function magic_stuff($atts) { | |
// turn on output buffering to capture script output | |
ob_start(); | |
// include file (contents will get saved in output buffer) | |
include(TEMPLATEPATH.'/wp-content/prugins/magic-plugin/magic-code.php'); |
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 make_filename_hash($filename) { | |
$nomedosite = get_bloginfo('name'); | |
$info = pathinfo($filename); | |
$ext = empty($info['extension']) ? '' : '.' . $info['extension']; | |
$name = basename($filename, $ext); | |
return $nomedosite.'_'.md5($name) . $ext; | |
} | |
add_filter('sanitize_file_name', 'make_filename_hash', 10); |
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 sort_categories_by_title($x) { | |
if (is_category()) { //can set specific ones | |
$x->query_vars['orderby'] = 'title'; | |
$x->query_vars['order'] = 'ASC'; | |
} | |
} | |
add_action('pre_get_posts', 'sort_categories_by_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 | |
function get_ID_by_slug($page_slug) { | |
$page = get_page_by_path($page_slug); | |
if ($page) { | |
return $page->ID; | |
} else { | |
return null; | |
} | |
} | |
;?> |
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 mark_first_post( $classes ) | |
{ | |
remove_filter( current_filter(), __FUNCTION__ ); | |
$classes[] = 'first-post'; | |
return $classes; | |
} | |
add_filter( 'post_class', 'mark_first_post' ); |
OlderNewer