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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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 webspec_get_title($my_id) { | |
$post_id_5369 = get_post($my_id); | |
$title = $post_id_5369->post_title; | |
$title = apply_filters('the_title', $title); | |
$title = str_replace(']]>', ']]>', $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
function webspec_get_content($my_id){ | |
$post_id_5369 = get_post($my_id); | |
$content = $post_id_5369->post_content; | |
$content = apply_filters('the_content', $content); | |
$content = str_replace(']]>', ']]>', $content); |
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 webspec_get_featured_img($id){ | |
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $id), 'single-post-thumbnail' ); | |
echo $image[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
Method 1: | |
function get_excerpt_outside_loop($post_id) { | |
$post_excerpt = get_page($post_id) -> post_excerpt; | |
echo $post_excerpt; | |
} |
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 echo get_template_directory_uri(); ?> |
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 for stripping out malicious bits | |
function cleanInput($input) { | |
$search = array( | |
'@<script[^>]*?>.*?</script>@si', // Strip out javascript | |
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags | |
'@<style[^>]*?>.*?</style>@siU', // Strip style tags properly | |
'@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments |
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
The function below use the latitude and longitude of two locations, and calculate the distance between them in both miles and metric units. | |
function getDistanceBetweenPointsNew($latitude1, $longitude1, $latitude2, $longitude2) { | |
$theta = $longitude1 - $longitude2; | |
$miles = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta))); | |
$miles = acos($miles); | |
$miles = rad2deg($miles); | |
$miles = $miles * 60 * 1.1515; | |
$feet = $miles * 5280; | |
$yards = $feet / 3; |
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
$email = $_POST['email']; | |
if(preg_match("~([a-zA-Z0-9!#$%&'*+-/=?^_`{|}~])@([a-zA-Z0-9-]).([a-zA-Z0-9]{2,4})~",$email)) { | |
echo 'This is a valid email.'; | |
} else{ | |
echo 'This is an invalid email.'; | |
} |
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 base64url_encode($plainText) { | |
$base64 = base64_encode($plainText); | |
$base64url = strtr($base64, '+/=', '-_,'); | |
return $base64url; | |
} | |
function base64url_decode($plainText) { | |
$base64url = strtr($plainText, '-_,', '+/='); | |
$base64 = base64_decode($base64url); | |
return $base64; |
OlderNewer