Skip to content

Instantly share code, notes, and snippets.

@zackpyle
zackpyle / _scroll-shadow.js
Last active June 24, 2024 20:06
Add an inset shadow to a a scrollable div, and remove the shadow once you reach the bottom of the scroll
jQuery(document).ready(function($) {
// Add shadow class to containers and remove when you scroll to the bottom
const $recurringEventsLists = $('.recurring-events-list');
function checkScrollAndHeight() {
const $this = $(this);
// Check if the content height is greater than the max-height of the container
if ($this.prop('scrollHeight') > $this.height()) {
@zackpyle
zackpyle / team-bootstrap-modal.html
Created June 21, 2024 14:47
Team CPT + Bootstrap Modal
<div class="team-member wrapcenter">
<div class="headshot-wrapper">
<img class="team-headshot" src="[wpbb post:featured_image size='medium' display='url']">
<!-- Button trigger modal -->
<button type="button" aria-label="Read more about [wpbb post:title]" class="modal-btn" data-toggle="modal" data-target="#[wpbb post:slug]">
Learn More <span class="sr-only">about [wpbb post:title]</span>
</button>
</div>
<h3 class="team-name">[wpbb post:title]</h3>
<p class="team-position">[wpbb post:acf type='text' name='team_position']</p>
@zackpyle
zackpyle / first-name-shortcode.php
Created June 5, 2024 19:10
Get First Name (aka first word in page title)
<?php
add_shortcode( 'first_name', 'get_first_name' );
function get_first_name() {
$title = get_the_title();
$full_name_seperate = explode( ' ', $title );
return $full_name_seperate[0];
}
@zackpyle
zackpyle / fluent-forms-radio-button-acf-relationship.php
Last active June 5, 2024 19:33
Set the value of a Fluent Form radio field with an ACF Relationship field from the current page
<?php
add_filter('fluentform/rendering_field_data_input_radio', function ($data, $form) {
if ($form->id != 3) { // Form ID
return $data;
}
// Set which field to do this on
if (\FluentForm\Framework\Helpers\ArrayHelper::get($data, 'attributes.name') != 'FF_FORM_FIELD_NAME') { // Form field name here
return $data;
@zackpyle
zackpyle / modify-bb-post-autosuggest-dropdown.php
Last active May 4, 2024 00:19
Add URL to Beaver Builder Post module auto suggest dropdown
<?php
// Modify the data returned for BB post module auto suggest queries to include post URLs
add_filter('fl_builder_auto_suggest_posts_lookup', function ( $data ) {
foreach ( $data as $key => $post ) {
$post_object = get_post( $post['value'] );
// If the post object exists, append the URL path to the title
if ( $post_object ) {
$permalink = get_permalink( $post['value'] );
@zackpyle
zackpyle / fluent-forms-post-type-checkbox.php
Last active April 24, 2024 16:25
In Fluent Forms, set the values of a checkbox to a post type's posts
<?php
add_filter('fluentform/rendering_field_data_input_checkbox', function ($data, $form) {
if ($form->id != 1) { // Form ID
return $data;
}
// Set which field to do this on
if (\FluentForm\Framework\Helpers\ArrayHelper::get($data, 'attributes.name') != 'products') { // Field name
return $data;
@zackpyle
zackpyle / fluent-forms-dynamic-submit-button-text.php
Last active April 24, 2024 21:42
Fluent Forms - Use custom shortcode attr and FF SmartCode to pass dynamic Submit Button text
<?php
// Register Fluent Forms SmartCode
add_filter('fluentform/editor_shortcodes', function ($smartCodes) {
$smartCodes[0]['shortcodes']['{submit_button_text}'] = 'Dynamic Submit Button Text';
return $smartCodes;
});
// Use text from submit_button_text attribute on the form's shortcode
add_filter('fluentform/editor_shortcode_callback_submit_button_text', function ($value, $form) {
@zackpyle
zackpyle / beaver-themer-location-singular-class.php
Created April 7, 2024 18:22
Add Beaver Themer's location setting for Singular template as a body class of single-post_type to help with styling the Themer Layout
<?php
add_filter('body_class', function ($classes) {
if (is_singular('fl-theme-layout')) {
$current_post_id = get_the_ID();
$layout_type = get_post_meta($current_post_id, '_fl_theme_layout_type', true);
$location_settings = get_post_meta($current_post_id, '_fl_theme_builder_locations', true);
// Proceed only if the layout type is 'singular'
if ($layout_type === 'singular' && !empty($location_settings) && is_array($location_settings)) {
@zackpyle
zackpyle / default-acf-value-by-post-type.php
Last active March 8, 2024 16:40
Set a different default #ACF value based on the post type
<?php
add_filter('acf/load_field/key=YOUR_FIELD_KEY_HERE', function ($field) {
if (get_post_type() == 'post') {
$field['default_value'] = 'YOUR_DEFAULT_VALUE_HERE';
}
return $field;
});
@zackpyle
zackpyle / bb-dropdown-custom-order.php
Created February 19, 2024 14:28
Create a custom order for the Beaver Builder admin bar dropdown #beaverbuilder
<?php
add_filter( 'fl_theme_builder_current_page_layouts', function( $layouts ) {
// Custom order
$custom_order = ['header', 'singular', 'archive', '404', 'part' , 'footer'];
$sorted_layouts = [];
// Populate sorted_layouts based on custom_order
foreach ($custom_order as $type) {
if (isset($layouts[$type])) {