This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Force another page or post (like an archive) to update when any post (of post-type) is saved | |
* @param Hook save_post_{$post_type} | |
* @param Callback | |
*/ | |
add_action('save_post_property', 'clear_cache_for_property_archive', 10, 2); | |
function clear_cache_for_property_archive($post_id, $post){ | |
$pages_to_clear = [87,91]; // list of page/post ids that should be updated | |
foreach($pages_to_clear as $page_id){ | |
$page = get_post($page_id, 'OBJECT'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Iterates over an array and returns true if any are found | |
function itemInStr(str, arr) { | |
return arr.some(item => str.includes(item)); | |
} | |
// uses Regex to test if a string is in the array, returns true if found | |
function testItemInStr(str,arr){ | |
let regex = new RegExp(arr.join("|"), "i"); | |
return regex.test(str); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* Filter the thumbnail for Providers based on taxonomy | |
* @param mixed $thumbnail_id | |
* @param mixed $post | |
* @return mixed | |
*/ | |
function PREFIX_filter_provider_thumbnail($thumbnail_id, $post) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Filters the uploads directory to use a custom structure for select post types | |
*/ | |
class Custom_Uploads_Handler { | |
public function __construct() { | |
// initialize upload filters |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_post_id_by_slug( $post_name, $post_type = 'post' ) { | |
global $wpdb; | |
// Prepare the SQL query to retrieve the post ID by post_name and post_type | |
$query = $wpdb->prepare( " | |
SELECT ID | |
FROM $wpdb->posts | |
WHERE post_name = %s | |
AND post_type = %s | |
AND post_status = 'publish' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* HubSpot Embedded Form Accessibility Pollyfills | |
* | |
* This script fixes the HubSpot HTML blunders that make their embedded forms inaccessible for assistive technology. | |
* - Replaces/removes improper use of <fieldset>, <legend>, <label>, and role attributes. | |
* - Note - this can cause forms configured for mulitple column field layouts to break - you will need to adjust your CSS accordingly. | |
**/ | |
hubspotFormA11y = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function arrayToObject(arr) { | |
return arr.reduce((acc, curr) => { | |
acc[curr.name] = curr.value; | |
return acc; | |
}, {}); | |
} | |
// Example usage: | |
const inputArray = [ | |
{ name: "firstName", value: "John" }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function elementor_password_form_page() { | |
// Elementor Template ID | |
$template_id = 3785; // Replace with your Elementor template ID | |
// Check if Elementor is active and the template exists | |
if (defined('ELEMENTOR_VERSION') && \Elementor\Plugin::$instance->templates_manager->get_source('local')->get_item($template_id)) { | |
// Render the Elementor template | |
return \Elementor\Plugin::$instance->frontend->get_builder_content_for_display($template_id, true); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function observeElementAddedToDOM(elementId, callback) { | |
// Select the target node | |
var targetNode = document; | |
// Options for the observer (which mutations to observe) | |
var config = { childList: true, subtree: true }; | |
// Callback function to execute when mutations are observed | |
var observerCallback = function(mutationsList, observer) { | |
for(var mutation of mutationsList) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* WordPress stores all meta fields as strings, which causes problems for ordering by numbers. When using Pods::find() directly, this issue can be addressed by casting the field as a decimal, as shown here: https://github.com/pods-framework/pods-code-library/blob/master/example/classes/Pods/find/examples/orderby-number.php | |
* | |
* In shortcodes, this strategy is not possible, as MySQL functions can not be used in the WordPress post editor. Instead, you can use the "pods_shortcode_findrecords_params" params filter, as shown below: | |
*/ | |
/** | |
* Example to order by a price field properly. | |
*/ |
NewerOlder