Skip to content

Instantly share code, notes, and snippets.

View evanfraser's full-sized avatar

Evan Fraser evanfraser

View GitHub Profile
@evanfraser
evanfraser / populate-acf-field-with-gform-ids.php
Created December 12, 2022 19:43
Populate ACF select field options with Gravity Forms forms
<?php
add_filter('acf/load_field/name=gravity_form_id', function($field) {
if (class_exists('GFFormsModel')) {
$choices = [];
foreach (\GFFormsModel::get_forms() as $form) {
$choices[$form->id] = $form->title;
}
@evanfraser
evanfraser / toolbox-plugin.php
Created May 21, 2020 16:08
Squadbox plugin blank template
<?php
/**
* Plugin Name: PLUGIN_NAME_HERE
* Plugin URI: PLUGIN_URI_HERE
* Description: PLUGIN_DESC_HERE
* Version: 0.0.1
* Author: AUTHOR_HERE
* Author URI: AUTHOR_URI_HERE
* Text Domain: TEXT_DOMAIN_HERE
*/
// Add image title dynamically
jQuery(document).ready(function($) {
$("img").attr("title", function() {
return $(this).attr("alt");
});
});
<?php
/**
* Shortcode: EDD Product Version
*
* [edd_product_version]
* You can add id="post_id_here" to display the version number of a defined product.
*/
function shortcode_edd_product_version($atts) {
$atts = shortcode_atts(array(
@evanfraser
evanfraser / deactivate-yoast-11-schema.php
Created January 2, 2020 22:36
Deactivate Yoast's Schema output
<?php
add_filter('wpseo_json_ld_output', '__return_empty_array');
<?php
/**
* Get Post Category
*
* Shortcode: [post_category]
*/
function shortcode_post_category($atts=array()) {
// get taxonomy by post type
$tax = get_object_taxonomies(get_post_type());
@evanfraser
evanfraser / gravity-forms-button.php
Last active July 13, 2022 17:21
Change Gravity Forms submit input to a button element
<?php
function form_submit_button ($button, $form) {
$button = str_replace("input", "button", $button);
$button = str_replace("/", "", $button);
$button .= "{$form['button']['text']}</button>";
return $button;
}
add_filter('gform_submit_button', 'form_submit_button', 10, 5);
@evanfraser
evanfraser / wp-page-sitemap.php
Last active February 14, 2018 17:33
WordPress Page Sitemap Shortcode
<?php
/**
* Page Sitemap
* [page_sitemap title="" class=""]
*/
function yourfunction_page_sitemap($atts) {
ob_start();
extract( shortcode_atts( array(