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 to_24_hour($hours, $minutes, $seconds, $meridiem){ | |
$hours = sprintf('%02d',(int) $hours); | |
$minutes = sprintf('%02d',(int) $minutes); | |
$seconds = sprintf('%02d',(int) $seconds); | |
$meridiem = (strtolower($meridiem)=='am') ? 'am' : 'pm'; | |
return date('H:i:s', strtotime("{$hours}:{$minutes}:{$seconds} {$meridiem}")); | |
} | |
echo to_24_hour( 1, 2, 3, 'pm' ); // Returns 13:02:03 |
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 | |
for($m=1; $m<=12; ++$m){ | |
echo date('F', mktime(0, 0, 0, $m, 1)).'<br>'; | |
} |
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 list_posts_shortcode(){ | |
$my_query = new WP_Query( | |
array( | |
'post_type' => 'post', | |
'paged' => get_query_var('paged') | |
) | |
); | |
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 | |
// In your functions.php | |
/** | |
* Add custom field | |
*/ | |
function mytheme_attachment_fields( $fields, $post ) { | |
$meta = get_post_meta($post->ID, 'meta_link', true); | |
$fields['meta_link'] = 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 | |
/** | |
* Our example class | |
*/ | |
class Person { | |
/** | |
* Class properties to generate the setter and getter functions | |
*/ | |
protected $height; |
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 | |
$arr = array( 4 => 'apple', 7 => 'orange', 13 => 'plum' ) | |
echo reset($arr); //echoes "apple" |
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 | |
// URL to spreadsheet. Make sure to append ?alt=json to return contents in JSON format | |
$url = 'https://spreadsheets.google.com/feeds/list/0Ah0xU81penP1dFNLWk5YMW41dkcwa1JNQXk3YUJoOXc/od6/public/values?alt=json'; | |
$file= file_get_contents($url); | |
$json = json_decode($file); | |
echo '<pre>'.print_r($json, 1).'</pre>'; |
OlderNewer