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
| /** * Facebook Page Feed Parser * * @using cURL */ function fb_parse_feed( $page_id, $no = 5 ) { // URL to the Facebook page's RSS feed. $rss_url = 'http://www.facebook.com/feeds/page.php?id=' . $page_id . '&format=rss20'; $curl = curl_init(); // You need to query the feed as a browser. $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,"; $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; $header[] = "Cache-Control: max-age=0"; $header[] = "Connection: keep-alive"; $header[] = "Keep-Alive: 300"; $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"; $header[] = "Accept-Language: en-us,en;q=0.5"; $header[] = "Pragma: "; // browsers keep this blank. curl_setopt($curl, CURLOPT_URL, $rss_url); curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla'); curl_setopt($curl, CURLOPT_HTTPHEADER, $header); curl_setopt($curl, CURLOPT_REFERER, ''); curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate'); curl_setopt($curl, CURLOPT_AUTOREFERER, |
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
| /** | |
| * Add custom taxonomies | |
| * | |
| * Additional custom taxonomies can be defined here | |
| * http://codex.wordpress.org/Function_Reference/register_taxonomy | |
| */ | |
| function add_custom_taxonomies() { | |
| // Add new "Locations" taxonomy to Posts | |
| register_taxonomy('location', 'post', array( | |
| // Hierarchical taxonomy (like categories) |
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
| add_action('init', 'demo_register_post_type'); function demo_register_post_type() { register_post_type('demo', array( 'labels' => array( 'name' => 'Demos', 'singular_name' => 'Demo', 'add_new' => 'Add new demo', 'edit_item' => 'Edit demo', 'new_item' => 'New demo', 'view_item' => 'View demo', 'search_items' => 'Search demos', 'not_found' => 'No demos found', 'not_found_in_trash' => 'No demos found in Trash' ), 'public' => true, 'supports' => array( 'title', 'excerpt' ), 'taxonomies' => array('category', 'post_tag') // this is IMPORTANT ));} |
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
| // 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 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
| function html2txt($document){ | |
| $search = array('@<script[^>]*?>.*?</script>@si', // Strip out javascript | |
| '@<style[^>]*?>.*?</style>@siU', // Strip style tags properly | |
| '@<[?]php[^>].*?[?]>@si', //scripts php | |
| '@<[?][^>].*?[?]>@si', //scripts php | |
| '@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags | |
| '@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments including CDATA | |
| );$text = preg_replace($search, '', $document); | |
| return $text; | |
| } |
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
| function currency($from_Currency,$to_Currency,$amount) { | |
| $amount = urlencode($amount); | |
| $from_Currency = urlencode($from_Currency); | |
| $to_Currency = urlencode($to_Currency); | |
| $url = "http://www.google.com/ig/calculator?hl=en&q=$amount$from_Currency=?$to_Currency"; | |
| $ch = curl_init(); | |
| $timeout = 0; | |
| curl_setopt ($ch, CURLOPT_URL, $url); | |
| curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_USERAGENT , "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)"); |
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
| function getvat($price){ | |
| $vat = 21; // set vat amount | |
| return $price * ($vat / 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
| function age($date){ | |
| list($year,$month,$day) = explode("-",$date); | |
| $year_diff = date("Y") - $year; | |
| $month_diff = date("m") - $month; | |
| $day_diff = date("d") - $day; | |
| if ($day_diff < 0 || $month_diff < 0) $year_diff--; | |
| return $year_diff; | |
| } |