Skip to content

Instantly share code, notes, and snippets.

View halgatewood's full-sized avatar

Hal Gatewood halgatewood

View GitHub Profile
<?php
$weather_settings = new stdclass;
$weather_settings->location = 'Edmond, OK';
$weather_settings->owm_city_id = 4535740;
$weather_settings->transient_name = 'awe-edmond-weather-c';
$weather_settings->forecast_days = 5;
$weather_settings->units_query = 'metric';
$city_id = awe_get_ip_city_id( $weather );
@halgatewood
halgatewood / awe_by_latlon.php
Last active June 7, 2016 21:11
Get Weather Widget by Latitude and Longitude
$weather = awesome_weather_logic( array(
'location' => 'Phoenix',
'allow_user_to_change' => 1,
'longlat_triggered' => 1,
'longlat_location' => '33.448377,-112.074037'
));
@halgatewood
halgatewood / awe-strip.php
Created June 7, 2016 05:40
An experimental strip layout for the Awesome Weather Widget Pro
<style>
/* STRIP */
.awe_strip { padding: 0; width: 100%;}
.awe_strip .awesome-weather-header { margin-left: -10px; padding: 10px 15px; }
.awe_strip .awesome-weather-strip-line { padding: 10px; white-space: nowrap; display: block; padding-right: 50px; text-transform: uppercase; overflow: hidden; overflow-x: scroll; }
.awe_strip .awesome-weather-strip-stat { padding: 0 10px; }
.awe_strip .awesome-weather-strip-line strong { padding-right: 5px; }
.awe_strip .awesome-weather-form { top: 5px; left: 5px; right: 35px; bottom: 5px; }
@halgatewood
halgatewood / weather_data_owm.php
Last active June 7, 2016 04:26
Extracting Weather Data from Awesome Weather Pro
<?php
include( dirname(__FILE__) . "/../../plugins/awesome-weather-pro/pro/openweathermaps/funcs.php");
$weather_settings = new stdclass;
$weather_settings->location = 'Edmond, OK';
$weather_settings->owm_city_id = 4535740;
$weather_settings->transient_name = 'awe-edmond-weather-c';
$weather_settings->forecast_days = 5;
$weather_settings->units_query = 'metric';
$video_obj = get_field('vimeo_field');
if( !has_post_thumbnail() AND $video_obj )
{
Generate_Featured_Image( $video_obj->thumbnail_large, get_the_ID() );
}
@halgatewood
halgatewood / acf_vimeo_thumbnail_save_post.php
Last active January 23, 2017 15:03
Set the WordPress Post Thumbnail automatically from my ACF Vimeo Field: https://halgatewood.com/downloads/acf-vimeo-field
if( !function_exists('Generate_Featured_Image') )
{
// FUNCTION FOUND ON GITHUB
function Generate_Featured_Image( $image_url, $post_id )
{
$upload_dir = wp_upload_dir();
$image_data = file_get_contents($image_url);
$filename = basename($image_url);
if(wp_mkdir_p($upload_dir['path'])) $file = $upload_dir['path'] . '/' . $filename;
else $file = $upload_dir['basedir'] . '/' . $filename;
@halgatewood
halgatewood / acf_vimeo_video_object.php
Last active May 13, 2016 18:58
How to use the ACF Vimeo Field to return Data from the Video
<?php $vimeo_video = get_field('vimeo_id'); ?>
<img src="<?php echo $vimeo_video->thumbnail_medium; ?>">
<h1><?php echo $vimeo_video->title; ?></h1>
<p><?php echo $vimeo_video->description; ?> | <?php echo $vimeo_video->length; ?></p>
<iframe src="https://player.vimeo.com/video/<?php echo $vimeo_video->id; ?>" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
@halgatewood
halgatewood / hg_testimonial_rotator.html
Last active April 12, 2016 16:17
The HTML structure of my Testimonial Rotator
<div id="testimonial_rotator_wrap_5166" class="testimonial_rotator_wrap with-prevnext">
<div id="testimonial_rotator_5166" class="testimonial_rotator hreview-aggregate cycletwo-slideshow format-rotator template-default" data-cycletwo-timeout="5000" data-cycletwo-speed="1000" data-cycletwo-pause-on-hover="true" data-cycletwo-center-horz="true" data-cycletwo-center-vert="true" data-cycletwo-swipe="true" data-cycletwo-fx="scrollHorz" data-cycletwo-auto-height="calc" data-cycletwo-next="#testimonial_rotator_wrap_5166 .testimonial_rotator_next" data-cycletwo-prev="#testimonial_rotator_wrap_5166 .testimonial_rotator_prev" data-cycletwo-slides="> div.slide" data-cycletwo-log="false" >
<div class="slide slide1 testimonial_rotator_slide hreview itemreviewed item has-image cf-tr">
<div class="testimonial_rotator_img img"><img width="150" height="150" src="" class="attachment-thumbnail size-thumbnail wp-post-image" alt="" /></div>
<div class="text testimonial_rotator_description">
<h3 class="testimon
@halgatewood
halgatewood / awe-temponly.php
Created March 29, 2016 17:20
Awesome Weather Widget PRO - Get the Current Temperature only.
<?php if( isset($weather->data['current']['temp']) ) echo $weather->data['current']['temp']; ?>
function hg_dequeue_style()
{
wp_dequeue_style('awesome-weather');
wp_deregister_style('awesome-weather');
wp_enqueue_style( 'awesome-weather', '/wp-content/plugins/awesome-weather-pro/awesome-weather.css' );
}
add_filter( 'wp_print_styles', 'hg_dequeue_style', 100 );