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 | |
/** | |
* Filter for adding wrappers around embedded objects | |
*/ | |
function responsive_embeds( $content ) { | |
$content = preg_replace( "/<object/Si", '<div class="embed-container"><object', $content ); | |
$content = preg_replace( "/<\/object>/Si", '</object></div>', $content ); | |
/** | |
* Added iframe filtering, iframes are bad. |
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
/* | |
100 = thin | |
200 = extra-light | |
300 = light | |
400 = normal, book | |
500 = medium | |
600 = demi-bold | |
700 = bold | |
800 = heavy | |
900 = black |
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 slugify($string, $replace = array(), $delimiter = '-') { | |
// https://github.com/phalcon/incubator/blob/master/Library/Phalcon/Utils/Slug.php | |
if (!extension_loaded('iconv')) { | |
throw new Exception('iconv module not loaded'); | |
} | |
// Save the old locale and set the new locale to UTF-8 | |
$oldLocale = setlocale(LC_ALL, '0'); | |
setlocale(LC_ALL, 'en_US.UTF-8'); | |
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $string); |
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
<select name="timezone" id="timezone"> | |
<optgroup label="UTC -11:00"> | |
<option value="Pacific/Midway">UTC -11:00 Midway</option> | |
<option value="Pacific/Niue">UTC -11:00 Niue</option> | |
<option value="Pacific/Pago_Pago">UTC -11:00 Pago_Pago</option> | |
</optgroup> | |
<optgroup label="UTC -10:00"> | |
<option value="America/Adak">UTC -10:00 Adak</option> | |
<option value="Pacific/Honolulu">UTC -10:00 Honolulu</option> | |
<option value="Pacific/Johnston">UTC -10:00 Johnston</option> |
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 encodecsv($string) { | |
if(strpos($string, ',') !== false || strpos($string, '"') !== false || strpos($string, "\n") !== false) { | |
$string = '"' . str_replace('"', '""', $string) . '"'; | |
} | |
return $string; | |
} |
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 | |
public function view($filename = 'home') { | |
// Default values for every View | |
$data = array( | |
"app_title" => $this->app_title, | |
"app_tagline" => $this->app_tagline, | |
"app_url" => $this->app_url, | |
"app_version" => $this->app_version, | |
"user_name" => $this->user_name, | |
); |
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 return array ( | |
'url' => 'https://xaviesteve.com/', | |
'content' => '<!doctype html><html>...</html>', | |
'cookies' => '__cfduid=d3fa669e1069e72c2e47d127ab9b8e11f1465390629', | |
'http_code' => 200, | |
'content_type' => 'text/html; charset=UTF-8', | |
'header_size' => 578, | |
'request_size' => 229, | |
'filetime' => -1, | |
'ssl_verify_result' => 0, |
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
<html> | |
<head> | |
<title>RSS Feed Reader</title> | |
</head> | |
<body> | |
<?php | |
//Feed URLs | |
$feeds = array( | |
"http://maxburstein.com/rss", | |
"http://www.engadget.com/rss.xml", |
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 | |
/** | |
* Array: Find previous element (method 1) | |
* @source http://stackoverflow.com/questions/4792673/php-get-previous-array-element-knowing-current-array-key | |
*/ | |
$array = array( | |
12 => array('a','b'), | |
34 => array('c','d'), | |
56 => array('e','f') |
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 // Collection of useful php snippets | |
// html readable print_r for arrays | |
echo '<pre>'; | |
print_r($myarray); | |
echo '</pre>'; | |
?> |