This file contains hidden or 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 | |
// Our custom error handler | |
function nettuts_error_handler($number, $message, $file, $line, $vars){ | |
$email = " | |
<p>An error ($number) occurred on line | |
<strong>$line</strong> and in the <strong>file: $file.</strong> | |
<p> $message </p>"; | |
$email .= "<pre>" . print_r($vars, 1) . "</pre>"; |
This file contains hidden or 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 | |
$username=$_POST["username"]; | |
$age=$_POST["age"]; | |
etc. | |
?> | |
<?php | |
$expected=array('username','age','city','street'); | |
foreach($expected as $key){ | |
if(!empty($_POST[$key])){ |
This file contains hidden or 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 | |
$image = file_get_contents('http://www.url.com/image.jpg'); | |
file_put_contents('/images/image.jpg', $image); //save the image on your server |
This file contains hidden or 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 data_uri($file, $mime) { | |
$contents=file_get_contents($file); | |
$base64=base64_encode($contents); | |
echo "data:$mime;base64,$base64"; | |
} |
This file contains hidden or 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 twtreplace($content) { | |
$twtreplace = preg_replace('/([^a-zA-Z0-9-_&])@([0-9a-zA-Z_]+)/',"$1<a href=\"http://twitter.com/$2\" target=\"_blank\" rel=\"nofollow\">@$2</a>",$content); | |
return $twtreplace; | |
} | |
add_filter('the_content', 'twtreplace'); | |
add_filter('comment_text', 'twtreplace'); |
This file contains hidden or 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
<meta charset="utf-8"> | |
<title>---</title> | |
<!-- Behavioral Meta Data --> | |
<meta name="apple-mobile-web-app-capable" content="yes"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> | |
<!-- Core Meta Data --> | |
<meta name="author" content="---"> | |
<meta name="description" content="---"> |
This file contains hidden or 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_link_url() { | |
$content = get_the_content(); | |
$has_url = get_url_in_content( $content ); | |
return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() ); | |
} |
This file contains hidden or 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 __my_registration_redirect(){ | |
return home_url( '/my-page' ); | |
} | |
add_filter( 'registration_redirect', '__my_registration_redirect' ); |
This file contains hidden or 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 | |
add_filter( 'jpeg_quality', 'smashing_jpeg_quality' ); | |
function smashing_jpeg_quality() { | |
return 100; | |
} |
This file contains hidden or 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 | |
add_action( 'init', 'smashing_session_start' ); | |
function smashing_session_start() { | |
if ( !session_id() ) { | |
session_start(); | |
} | |
} |