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 | |
$post_id = 142; //post of type elementor_library | |
$document = \ElementorPro\Plugin::elementor()->documents->get( $post_id ); | |
$document->print_content(); |
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
//Search fields indexed by post type. Yes, I should do this in a tidier way. | |
global $search_index_fields; | |
$search_index_fields = array( | |
'still_image' => array('people','business','location','format_original','author','notes'), | |
'audio' => array('people','business','transcript','format_original','author','additional'), | |
'video' => array('people','business','format_original','transcript','author','additional'), | |
'person' => array('name','known_as','maiden_name','military_identification','birthplace','parents','partner','children','deathplace','biography'), | |
'text' => array('people','business','location','format_original','author','notes','publisher','transcript') | |
); |
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 | |
//1. Get all attachment IDs | |
//2. Check if the ID appears as a simple meta value, or as a meta value like "[id]" (including quotes, to catch serialized values) or like wp-image-[id] (for wysiwyg ACF fields and such) | |
//3. Check if the ID appears in post_content like wp-image-[id] | |
//TODO - WordPress galleries. N/A in my case but probably needs its own check. | |
//If an ID does not appear in the above scenarios, get it gone. | |
require_once('wp-load.php'); |
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
//See https://www.smashingmagazine.com/2019/04/mutationobserver-api-guide/ | |
var target = document.querySelector('#wrap'); //the parent element you wish to watch | |
var my_callback_done = false; //flag to avoid running our callback repeatedly | |
// 1. Create an observer instance | |
var observer = new MutationObserver(function(mutations) { | |
if(my_callback_done) return; | |
//Do things here |
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
#1. find files matching a pattern | |
#2. use mogrify to resize them. | |
# -quality 94 = jpeg quality. | |
# -verbose so you can tell where it's at in the directory tree | |
# -resize 2000x\> = resize to a maximum of 2000px wide, automatic height (2000x). Only resize larger images, no upscaling (>). Because > is a special character it is escaped with \ | |
# Aspect ratio is automatically maintained. | |
#3. write new image in place | |
#TEST THIS THOROUGHLY AND KEEP A BACKUP OF YOUR ORIGINAL DIRECTORY TREE | |
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 | |
/** | |
* When a user visits the home page, redirect certain roles elsewhere | |
*/ | |
function redirect_roles_from_homepage(){ | |
if(!is_front_page() || !is_user_logged_in()) return; | |
$redirects = [ | |
//role => url |
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
[ | |
{ | |
"key": "group_5f5940423422e", | |
"title": "Title image", | |
"fields": [ | |
{ | |
"key": "field_5f59406a7ebf9", | |
"label": "Title image", | |
"name": "title_image", | |
"type": "image", |
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 | |
//Wonky formatting on WooCommerce pages and only on WooCommerce pages? P tags where you don't want P tags? | |
function remove_autop_for_wc(){ | |
remove_filter('woocommerce_short_description','wpautop'); | |
} | |
add_action( 'init', 'remove_autop_for_wc', 999999 ); | |
?> |
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 | |
// The issue: | |
// You want to use WP Bakery for your WooCommerce shop page. | |
// You can enable WP Bakery for that page, but custom Design Options are not showing. | |
// The explanation: | |
// WP Bakery keeps those custom design changes as a CSS string, stored as post meta on the page you are using for your shop page. | |
// Unfortunately that CSS is not being output by your theme, hence your custom design changes are not working. |
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
$('a[href*="#"]:not([href="#"])').click(function() { | |
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { | |
var target = $(this.hash); | |
target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); | |
if (target.length) { | |
offset = 100; //px, enough to clear the sticky nav menu | |
$('html,body').animate({ scrollTop: target.offset().top - offset }, 600); | |
return false; | |
} | |
} |