Skip to content

Instantly share code, notes, and snippets.

View shrinkray's full-sized avatar
:octocat:
Focusing

Greg Miller shrinkray

:octocat:
Focusing
View GitHub Profile
@shrinkray
shrinkray / .gitignore
Created December 18, 2019 13:33
A gitignore to use with git where root is in root of WP install, from WP Engine
# Include your project-specific ignores in this file
# Read about how to use .gitignore: https://help.github.com/articles/ignoring-files
# THEME LEVEL FILES
wp-content/themes/root-inc/vendor
wp-content/themes/root-inc/.config.codekit3
# Reference Files
wp-content/themes/root-inc/brand-colors.css
#Added gitignore_global to ignore .DS_Store instances
wp-content/themes/root-inc/videos
/**
* Add to remove the Heartbeat (missing) in Query Monitor
*/
add_filter( 'wpe_heartbeat_allowed_pages', function( $pages ) {
global $pagenow;
$pages[] = $pagenow;
return $pages;
});
@shrinkray
shrinkray / single-template.php
Last active November 18, 2019 05:23
The have_posts() call
/**
* Some Templates are found to be missing this loop call and the pages return empty
*/
<?php
if (have_posts()) : while (have_posts()) : the_post();
get_header();
@shrinkray
shrinkray / download.php
Last active November 15, 2019 23:18
How to set a link to download a document
<!--
In this link, use the HTML download attribute to specify that the
target will be downloaded when a user clicks on the hyperlink.
The download attribute is only used if the href attribute is set.
-->
<a class="btn-conversion blue3 d-flex"
href="https://www.rootinc.com/pdfs/Gary_Speaker_Sheet.pdf"
download
@shrinkray
shrinkray / contact.php
Last active November 18, 2019 01:35
With a Gravity Form added, script adds input inside Form and replaces DOM input with button
<?php
$id_or_title = 12;
$tabindex = true;
gravity_form( $id_or_title, $display_title = false,
$display_description = true,
$display_inactive = false,
$field_values = null,
$ajax = false,
$tabindex,
@shrinkray
shrinkray / query-console.js
Created November 8, 2019 15:21
A quick, in-browser console trick for getting content from an HTML page.
/**
* In this example, I wanted to create a list of names of Custom Fields.
*/
const titles = document.querySelectorAll('.row-title');
for ( const title of titles ) {
// Because it is returned in the browser, we're getting the VM numbering thing in console log
// Experiment with a way to drop these in an array instead.
@shrinkray
shrinkray / template.php
Created November 6, 2019 15:00
Example using esc_url
<a class="btn-conversion blue3 btn-form" id="form-submit"
href="<?php echo esc_url(get_bloginfo('url') . '/pdfs/whitepapers/How-To-For-Org-Change.pdf'); ?>"
target="_blank">
<span class="fa-stack fa-lg">
<i class="fa fa-square fa-stack-2x" aria-hidden="true"></i>
<i class="fa fa-cloud-download fa-stack-1x fa-inverse" aria-hidden="true"></i>
</span>
<span class="conversion-text">Download Now!</span>
</a>
@shrinkray
shrinkray / index.php
Created October 30, 2019 13:04
Display the featured image with the alt tag using get_the_post_thumbnail_url();
/**
* To display the featured image with the alt tag
*
* @link: https://developer.wordpress.org/reference/functions/get_the_post_thumbnail_url/
* @author: https://profiles.wordpress.org/thelilmercoder/
*/
$thumbnail = get_the_post_thumbnail_url();
if ( $thumbnail ) {
@shrinkray
shrinkray / index.php
Created October 30, 2019 03:48
Differences between site URL functions
/** Differences between site URL functions
*
* IMAGES
*
* bloginfo('template_directory'); Returns the wp-content url
* This is the full URL https://[root-domain]/wp-content/themes/[theme-folder]/images/opt-in-2.png
*/
<img src="<?php bloginfo('template_directory'); ?>/images/opt-in-4.png" class="pbl">
@shrinkray
shrinkray / setup.php
Created September 6, 2019 02:03
Set a high priority for Theme Assets add_action call for enqueuing theme scripts to fix console error where ACF appears before jQuery
/**
* THEME ASSETS
*
* Note: 999 is setting late Priority. This is to circumvent issue where ACF code appears before jquery for some dumb reason.
* @priority 999
*/
add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\\assets', 999 );