Skip to content

Instantly share code, notes, and snippets.

@patric-boehner
patric-boehner / gf.php
Last active November 27, 2023 19:28
Set Gravity Forms price field value based on custom field
<?php
// Set product price if dyncialy populate vlaue is set to 'workshop_price'
add_filter( 'gform_field_value_workshop_price', 'cf_custom_product_price', 10, 2 );
function cf_custom_product_price( $value, $field ) {
global $post;
// Get the workshop price
$quantity = get_post_meta( $post->ID, 'workshop_price', true );
@patric-boehner
patric-boehner / inline-svg.php
Created July 4, 2019 01:39
Include inline SVG files.
<?php
function pb_load_inline_svg( $filename ) {
// Add the path to your SVG directory inside your theme.
$svg_path = '/assets/svg/';
$file_end = '.svg';
//Check the SVG file exists
if ( ! file_exists( CHILD_DIR . $svg_path . $filename . $file_end ) ) {
@patric-boehner
patric-boehner / video-embed.js
Created February 1, 2019 22:06
Lazy Load Youtube Video based of URL from CMB2
//* Lightweight Youtube Emebeds
//**********************************************
// https://www.labnol.org/internet/light-youtube-embeds/27941/
document.addEventListener("DOMContentLoaded",
function() {
var div, n,
v = document.getElementsByClassName("youtube-player");
for (n = 0; n < v.length; n++) {
div = document.createElement("div");
@patric-boehner
patric-boehner / sidebar.php
Last active December 15, 2018 05:55
Add a list of child pages to the Genesis theme sidebar
<? php
// Don't include opening php tag
// Add subpages to sidebar
function pb_add_sub_pages_navigation() {
// Don't do anything if not a page
if ( ! is_page() ) {
return;
}
@patric-boehner
patric-boehner / breadcrumbs.php
Last active December 15, 2018 05:42
Change Genesis theme breadcrumbs for parent page using specific page template
<? php
// Don't include opening php tag
// Filter breadcrumbs for parent template pages
add_filter( 'genesis_page_crumb', 'pb_change_parent_page_template_title_for_breadcrumb' );
function pb_change_parent_page_template_title_for_breadcrumb( $crumb ) {
// If not our specificed page template, abort.
if ( ! is_page_template( 'templates/page-book.php' ) ) {
$ dandelion --config=staging.yml deploy
$ dandelion --config=production.yml deploy
@patric-boehner
patric-boehner / header-gallery.php
Created July 3, 2018 05:17
A header gallery with different image sizes based on position to reduce file size.
@patric-boehner
patric-boehner / featured-image-text.php
Created June 9, 2018 21:13
Change the default featured image text for a custom post type
@patric-boehner
patric-boehner / editor-placeholder.php
Last active June 9, 2018 21:13
Change the title placeholder text for a custom post type
<?php
// Don't include opening php tag
//* Change Post Editor Placeholder Text
//**********************
add_filter( 'enter_title_here', 'pb_change_placeholder_title_text' );
function pb_change_placeholder_title_text( $title ){
$screen = get_current_screen();
@patric-boehner
patric-boehner / comments.php
Created June 9, 2018 21:01
Remove website commet field
<?php
// Don't include opening php function
// Remove website comment field
add_filter('comment_form_default_fields', 'pb_remove_comment_url');
function pb_remove_comment_url( $fields ) {
unset( $fields['url'] );
return $fields;