Skip to content

Instantly share code, notes, and snippets.

View halgatewood's full-sized avatar

Hal Gatewood halgatewood

View GitHub Profile
@halgatewood
halgatewood / awe_get_yahoo_woeid.php
Last active August 29, 2015 14:05
How to programmatically get the Yahoo WOEID when using the Awesome Weather Widget Pro WordPress Plugin.
$woeid = false;
$location = "Madrid"; // SET THIS TO YOUR SEARCH CITY
$awe_location_cache_name = "awe_location_cache_" . $location;
if( get_transient( $awe_location_cache_name ) )
{
$woeid = get_transient( $awe_location_cache_name );
}
else
{
@halgatewood
halgatewood / awesome-weather-data.php
Created August 27, 2014 02:25
An example output of the $weather variable that is set to custom templates in the Awesome Weather Widget PRO: https://halgatewood.com/docs/plugins/awesome-weather-widget/creating-custom-templates/
stdClass Object
(
[transient_name] => awe_4544349_f_en_f5
[city_slug] => oklahoma-city
[api_query] => id=4544349
[location] => Oklahoma City
[woeid] =>
[owm_city_id] => 4544349
[template] => custom
[custom_template_name] => hal
@halgatewood
halgatewood / awesome-weather-cache.php
Last active August 29, 2015 14:07
Update the awesome weather widget transient timeout
function hg_awesome_weather_cache()
{
return 3600; // IN SECONDS
}
add_filter('awesome_weather_cache', 'hg_awesome_weather_cache');
[stripe_donate]
[stripe_donate mode="test"]
@halgatewood
halgatewood / gist:383a791efba1332d6698
Last active August 29, 2015 14:08
Base example layout of the user-amount layout for the Stripe Donations for WordPress plugin:
<!-- id: bibletalk -->
<div class="hg-stripe-donation-wrap hg-stripe-donation-layout-user-amount">
<div id="hg-stripe-donation-success-bibletalk" class="hg-stripe-donation-message-box hg-stripe-donation-success-message-box"></div>
<div id="hg-stripe-donation-error-bibletalk" class="hg-stripe-donation-message-box hg-stripe-donation-error-message-box"></div>
<div id="hg-stripe-donate-form-bibletalk" class="hg-stripe-donate-form-user-amount">
<p>
Amount: $ <input type="text" id="hg-stripe-donate-amount-bibletalk" name="hg-ajax-donate-amount" value="0" style="width:75px;">&nbsp;
<button id="hg-stripe-donate-button-bibletalk" class="hg-stripe-donation-button">Donate</button>
</p>
@halgatewood
halgatewood / remove-wp-comment-tab.php
Created February 22, 2015 05:54
Remove the Comments Tab from the WordPress admin.
// REMOVE COMMENTS TAB IN WORDPRESS ADMIN
function hg_remove_comment_menu() { remove_menu_page('edit-comments.php'); }
add_action('admin_menu', 'hg_remove_comment_menu');
@halgatewood
halgatewood / yt_get_video_url.php
Last active August 29, 2015 14:15
Get the streaming video (mp4) for your public YouTube videos. -- Download YouTube videos PHP script.
function get_youtube_video_url( $youtube_id )
{
$data = trim(urldecode(file_get_contents('https://youtube.com/get_video_info?video_id=' . $youtube_id)));
$d = parse_str($data, $info);
$stream_map = trim($info['url_encoded_fmt_stream_map']);
if( !$stream_map ) return false;
if( substr( $stream_map, 0, 4 ) != "url=" )
<div class="awesome-weather-forecast awe_days_<?php echo $weather->forecast_days ?> awecf">
<!-- TODAYS WEATHER -->
<div class="awesome-weather-forecast-day">
<?php if($weather->show_icons) { ?><i class="<?php echo $weather->data['current']['icon']; ?>">"></i><?php } ?>
<div class="awesome-weather-forecast-day-temp"><?php echo $weather->data['current']['temp']; ?><sup><?php echo $weather->units_display; ?></sup></div>
<div class="awesome-weather-forecast-day-abbr">TODAY</div>
</div>
<?php foreach( $weather_forecast as $forecast ) { ?>
<?php
function get_youtube_video_url( $youtube_id )
{
$data = trim(urldecode(file_get_contents('https://youtube.com/get_video_info?video_id=' . $youtube_id)));
$d = parse_str($data, $info);
$stream_map = trim($info['url_encoded_fmt_stream_map']);
if( !$stream_map ) return false;