Skip to content

Instantly share code, notes, and snippets.

View halgatewood's full-sized avatar

Hal Gatewood halgatewood

View GitHub Profile
@halgatewood
halgatewood / pmpro-expire-at-end-of-year.php
Created November 20, 2013 16:09
Expire all membership levels at the end of the year. If the user registers after October (10 variable on line 8) then they'll expire in the next year.
/// EXPIRATION DATE
function my_pmpro_checkout_level($level)
{
$expiration_year = date('Y');
$current_month = date('n');
// IF OCT, NOV, DEC, EXPIRE NEXT YEAR
if($current_month >= 10) { $expiration_year++; }
$expiration_date = $expiration_year . "-12-31";
@halgatewood
halgatewood / hg_day_night_weather_images.php
Created March 23, 2018 15:52
Creating weather background images based on day and night using the 24 hour clock. Requires new images for the night time.
function hg_awesome_weather_bg_ext()
{
// 24 HOUR CLOCK:
// LESS THAN 8 AM OR GREATER THAN 9 PM
if( get_the_time('G') < 8 || get_the_time('21') > 9 )
{
return "night.jpg";
}
<?php if( isset($weather->data['current'])) { ?>
<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-abbr"><?php echo $weather->t->now; ?></div>
<div class="awesome-weather-forecast-day-temp"><?php echo $weather->data['current']['temp']; ?></div>
</div>
<?php } ?>
@halgatewood
halgatewood / awe_mps_to_knots.php
Created November 8, 2017 03:38
Converting mps to knots with the Awesome Weather Widget Free Plugin
function hg_awesome_weather_wind_speed( $data, $speed, $direction )
{
$data['speed'] = round($data['speed'] * 1.94384);
$data['text'] = " knots";
return $data;
}
add_filter('awesome_weather_wind_speed', 'hg_awesome_weather_wind_speed', 10, 3);
@halgatewood
halgatewood / awe_show_weather.php
Last active November 7, 2017 19:32
How to show the simple weather in a PHP template for Awesome Weather Widget PRO
<?php
$where = new stdclass;
$where->location = "Dublin";
$where->owm_city_id = 2964574;
$where->units = "F";
$weather = get_awesome_weather_openweathermaps( $where );
if( isset($weather->data['current'])) { ?>
<div class="awe-weather">
<i class="<?php echo $weather->data['current']['icon']; ?>"></i>
<?php echo $weather->data['current']['temp']; ?>&deg; <?php echo $weather->data['current']['description']; ?>
@halgatewood
halgatewood / awe_video.php
Last active September 26, 2017 21:27
A simple custom template that has a background video. It is based off the Wide default template.
<?php $weather_name = awesome_weather_preset_condition_names_openweathermaps( $weather->data['current']['condition_code']); ?>
<style>
.awesome-weather-main-content {
position: relative;
z-index: 10;
}
.awesome-weather-video-background {
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
@halgatewood
halgatewood / awe-text.php
Last active September 26, 2017 21:17
A simple template for the Awesome Weather Widget Pro that shows text only. (68°F / 20°C Partly Cloudy)
<?php if( isset($weather->data['current'])) { ?>
<div class="awe-weather">
<?php if($weather->show_icons) { ?><i class="<?php echo $weather->data['current']['icon']; ?>"></i><?php } ?>
<?php echo $weather->data['current']['temp']; ?>&deg;F &nbsp;/&nbsp; <?php echo awe_f_to_c($weather->data['current']['temp']); ?>&deg;C
&nbsp; <?php echo $weather->data['current']['description']; ?>
</div>
<?php } ?>
/*----------Testimonial Slider Plugin------------ */
.testimonial_rotator .has-image .img img, .testimonial_rotator_single.has-image .img img {
width: 100%;
max-width: 150px;
height: auto;
border-radius: 100px;
}
.testimonial_rotator .has-image .img {
@halgatewood
halgatewood / bibletalk_alexa.js
Last active August 4, 2017 15:50
My Lambda Code for Alexa with support for the AudioPlayer
exports.handler = function (event, context)
{
try
{
if (event.session.application.applicationId !== "YOUR APP ID")
{
context.fail("Invalid Application ID");
}
@halgatewood
halgatewood / bibletalk_event_handler.php
Last active August 4, 2017 15:48
Alexa Code for handling AudioPlayer Events
/*
DATABASE STRUCTURE
CREATE TABLE `alexa_events` (
`id` bigint(33) NOT NULL,
`user_id` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`item_id` int(33) NOT NULL,
`offsetInMilliseconds` int(33) NOT NULL,
`status` varchar(25) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;