Skip to content

Instantly share code, notes, and snippets.

View rodgtr1's full-sized avatar

Travis Rodgers rodgtr1

View GitHub Profile
@rodgtr1
rodgtr1 / index.php
Last active April 12, 2018 02:22
Change Excerpt Length on Specific Instance
//15 is the amount of words & change three dots to whatever you want at the end of the excerpt
<?php echo wp_trim_words( get_the_excerpt(), 15, '...' ); ?>
@rodgtr1
rodgtr1 / functions.php
Created April 12, 2018 02:23
Create Default Fallback Image For Jetpack Related Posts
function jp_custom_image( $media, $post_id, $args ) {
if ( $media ) {
return $media;
} else {
$permalink = get_permalink( $post_id );
$url = apply_filters( 'jetpack_photon_url', 'https://example.com/wp-content/uploads/2017/07/example-image.jpg' );
return array( array(
'type' => 'image',
'from' => 'custom_fallback',
@rodgtr1
rodgtr1 / index.php
Created April 12, 2018 02:24
Add a Read More Link to Post Excerpt
// Add Read More link to Excerpt
function new_excerpt_more($more) {
global $post;
return '… <a href="'. get_permalink($post->ID) . '">' . 'Read More &raquo;' . '</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
@rodgtr1
rodgtr1 / functions.php
Last active April 12, 2018 02:25
Display Featured Image & Custom Size - Genesis
// Register a custom image size for Singular Featured images
//Choose custom image size and remember to Regenerate Thumbnails
add_image_size( 'singular-featured-thumb', 768, 450, true );
//Hook to add image before entry content
add_action( 'genesis_before_entry_content', 'tm_display_featured_image' );
//Function to display image
function tm_display_featured_image() {
@rodgtr1
rodgtr1 / functions.php
Created April 12, 2018 02:26
Add a Custom Favicon - Genesis
/** Adding custom Favicon */
add_filter( 'genesis_pre_load_favicon', 'custom_favicon' );
function custom_favicon( $favicon_url ) {
return 'http://example.com/wp-content/uploads/favicon.png';
}
@rodgtr1
rodgtr1 / functions.php
Created April 12, 2018 02:27
Change Default Search Text - Genesis
//Change default search text
function themeprefix_search_button_text( $text ) {
return ( 'Custom search phrase...');
}
add_filter( 'genesis_search_text', 'themeprefix_search_button_text' );
@rodgtr1
rodgtr1 / bitcoin_price_alert.py
Created June 27, 2018 02:27
Bitcoin email alerts when the price drops to a specific amount
import requests
import time
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import smtplib
import getpass
def send_email():
# create message object instance
msg = MIMEMultipart()
@rodgtr1
rodgtr1 / awsCLIAutomation.sh
Created July 2, 2021 14:13
Script to authenticate with AWS CLI with MFA token
#!/bin/bash
set -e
# specify your MFA_DEVICE_ARN
MFA_DEVICE_ARN=YOURMFAARN
PATH_TO_CREDENTIALS_FILE=/path/to/.aws/credentials
echo $PATH_TO_CREDENTIALS_FILE
#1H = 3600
#2H = 7200
#3H = 10800
@rodgtr1
rodgtr1 / uptimeMonitor.sh
Created July 2, 2021 14:17
Uptime Monitor for Ghost (or really any Linux service)
#!/bin/bash
#ver. 4
##this script will check mysql and apache
##if that service is not running
##it will start the service and send an email to you
##if the restart does not work, it sends an email and then exits
##set the path ##this works for Ubuntu 14.04 and 16.04
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
@rodgtr1
rodgtr1 / bitbucket-pipelines.yml
Created July 10, 2021 17:29
Bitbucket Pipeline to SFTP Files Up To WordPress Server
pipelines:
branches:
master:
- step:
name: Deploy to staging
deployment: staging
script:
- pipe: atlassian/sftp-deploy:0.5.7
variables:
USER: $SFTP_USERNAME