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 | |
/** | |
* Slideshow shortcode usage: [gallery type="slideshow"] or the older [slideshow] | |
*/ | |
if(!class_exists('zl_add_jetPack_slideshow')){ | |
class zl_add_jetPack_slideshow { | |
public $instance_count = 0; | |
function __construct() { |
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 | |
/** | |
* ----------------------------------------------------------------------------------------- | |
* Based on `https://github.com/mecha-cms/mecha-cms/blob/master/system/kernel/converter.php` | |
* ----------------------------------------------------------------------------------------- | |
*/ | |
// HTML Minifier | |
function minify_html($input) { |
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 | |
// Read more API Documentation @ https://www.flickr.com/services/api/ | |
$xml = simplexml_load_file("https://api.flickr.com/services/rest/?method=flickr.people.getPublicPhotos&user_id={YOUR USER ID}&per_page=[NUMBER OF PHOTOS TO FETCH]&api_key={REQUIRED!!! YOUR API KEY}&&format=rest"); | |
$output = "<div>"; | |
foreach($xml->children()->children() as $child) { | |
$imgsrc = "http://farm" . $child['farm'] . ".static.flickr.com/" . $child['server']. "/" . $child['id'] . "_" . $child['secret'] . "_s.jpg"; // More about image size suffixes: https://www.flickr.com/services/api/misc.urls.html | |
$fullsize = "http://farm" . $child['farm'] . ".static.flickr.com/" . $child['server']. "/" . $child['id'] . "_" . $child['secret'] . "_o.(jpg|gif|png)"; | |
$output .= "<a href='".$imgsrc."'>"; | |
$output .= "<img src='".$imgsrc."' />"; | |
$output .= "</a>"; |
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 | |
set_time_limit(0); | |
//This is the file where we save the information | |
$fp = fopen (dirname(__FILE__) . '/filename.rar', 'w+'); | |
//Here is the file we are downloading, replace spaces with %20 | |
$ch = curl_init(str_replace(" ","%20", 'http://someserver.crot/filename.rar')); | |
curl_setopt($ch, CURLOPT_TIMEOUT, 50); |
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 | |
//returns a big old hunk of JSON from a non-private IG account page. | |
function scrape_insta($username) { | |
$insta_source = file_get_contents('http://instagram.com/'.$username); | |
$shards = explode('window._sharedData = ', $insta_source); | |
$insta_json = explode(';</script>', $shards[1]); | |
$insta_array = json_decode($insta_json[0], TRUE); | |
return $insta_array; | |
} |
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 | |
$instagramusername = 'azhari.subroto'; | |
$args = array( | |
'timeout' => 360, | |
'httpversion' => '1.1' | |
); | |
$response = wp_remote_get('http://instagram.com/'.$instagramusername, $args); | |
// Check for error | |
if ( is_wp_error( $response ) ) { |
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 | |
// assuming file.zip is in the same directory as the executing script. | |
$file = 'file.zip'; | |
// get the absolute path to $file | |
$path = pathinfo(realpath($file), PATHINFO_DIRNAME); | |
$zip = new ZipArchive; | |
$res = $zip->open($file); | |
if ($res === TRUE) { |
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 zl_fancy_number($n, $precision = 1) { | |
if ($n < 1000) { | |
// Anything less than a thousand | |
$n_format = number_format($n); | |
} elseif ($n > 1000 && $n < 10000) { | |
$n_format = number_format($n / 1000, $precision) . 'K'; | |
} elseif ($n < 1000000000) { | |
// Anything less than a billion | |
$n_format = number_format($n / 1000000, $precision) . 'M'; |
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 themeslug_query_vars( $qvars ) { | |
$vars[] = 'headertype'; | |
return $vars; | |
} | |
add_filter( 'query_vars', 'themeslug_query_vars' , 10, 1 ); |
OlderNewer