Skip to content

Instantly share code, notes, and snippets.

View chuckreynolds's full-sized avatar
🤖
building things

Chuck Reynolds chuckreynolds

🤖
building things
View GitHub Profile
@jchristopher
jchristopher / functions.php
Created January 15, 2016 02:19
Programmatically tell SearchWP your license key without having to enter it into the license key field
<?php
add_filter( 'searchwp_license_key', function(){
return 'MJqNKfmhT3gVG6kpeyjXvM'; // your license key (found on your payment receipt)
});
@nathanrice
nathanrice / functions.php
Created January 6, 2016 16:41
Add back blogPosting Schema to Genesis sites
<?php
/*
Add back Schema.org/blogPosting microdata to post entries.
Replace all instances of "themedemo" with something unique to your site.
User input is required in the last function. Be sure to fill these fields in with your own information.
Instances where you need to fill in information will be marked with a comment that indicates so.
*/
@chuckreynolds
chuckreynolds / wordpress-publish-facebook-recrawl.php
Created November 11, 2015 10:34
Ping Facebook Graph to crawl (scrape) or rescrape the URL if a scheduled post goes live or a draft is published. Depending on this specific need I may just do it on any time status goes to publish regardless of the old status.
<?php
/**
* If post goes from "future" (scheduled) or "draft" to "publish" then alert facebook to (re)crawl it.
* @see https://codex.wordpress.org/Post_Status_Transitions#transition_post_status_Hook
*/
function chuck_notify_facebook_scraper( $new_status, $old_status, $post ) {
if ( $new_status != 'publish' ) {
return;
}
@danielpataki
danielpataki / cached-posts.php
Last active July 24, 2019 10:57
WordPress REST API
public function get_remote_posts() {
$posts = get_transient( 'remote_posts' );
if( empty( $posts ) ) {
$response = wp_remote_get( 'http://mysite.com/wp-json/wp/v2/posts/' );
if( is_wp_error( $response ) ) {
return array();
}
$posts = json_decode( wp_remote_retrieve_body( $response ) );
@johnbillion
johnbillion / wp_mail.md
Last active January 27, 2024 14:06
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This documentation has moved here: https://github.com/johnbillion/wp_mail

@neilgee
neilgee / slick-init-multiple-page-genesis.php
Last active April 25, 2019 23:50
Slick Carousel Enqueued and USed with ACF
<?php // <~ keep me in
add_action('genesis_entry_content','themeprefix_team_slider' );
//Fields
//team_portfolio = Gallery Field
function themeprefix_team_slider() {
$images = get_field('team_portfolio');//add your correct filed name
if( $images ): ?>
<div class="team-items">
@chriscct7
chriscct7 / gist:d7d077afb01011b1839d
Last active January 24, 2024 04:20
Plugins that need to be updated to be ready for the move to PHP 5 constructors

Important Notice for WordPress Plugins Using PHP 4 Style Constructors

The ability to use PHP 4 style constructors is getting removed from PHP. Without an update, many plugins will eventually no longer work (this is PHP breaking this backwards compatibility, not WordPress)

One of the more common uses of the PHP 4 style constructor (as opposed to PHP 5 style __construct() ) are plugins with widgets calling WP_Widget::WP_Widget() and/or parent::WP_Widget() and/or {object}->WP_Widget()

Note: Starting in WordPress 4.3, regardless of the PHP version in use on a server, WordPress will throw a deprecated notice when one of the PHP 4 style constructors is called specifically for widgets.

Basically instead of doing these:

@chuckreynolds
chuckreynolds / common-terminal-commands.md
Last active September 3, 2021 20:17
Common linux / terminal commands I always use but forget. So fuck it I'm saving em here

common terminal commands

ubuntu updates & clean

  • sudo apt update && sudo apt upgrade -y
  • sudo apt autoremove && sudo apt clean

copy mac public ssh key

  • pbcopy < ~/.ssh/id_rsa.pub

edit host file and flush dns after

@pat-eason
pat-eason / get_posts_terms_fields.php
Last active April 14, 2016 08:24
WordPress post+terms+fields query
<?php
//create our mega query with post data, meta fields, and taxonomies
function get_posts_terms_fields($params=null){
global $wpdb;
$defaults=array(
'posts_per_page' => 5,
'offset' => 0,
'category' => '',
'category_name' => '',
<?php
/**
* Adding all Asynchronous Javascripts to posts and pages
*/
function add_bulk_async_sdk() { ?>
<script>
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
add = function(url, id) {