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 | |
/** | |
* 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
#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
//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
<?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
//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 | |
$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
div#hs-eu-cookie-confirmation div#hs-eu-cookie-confirmation-inner { display:flex; align-items:center;justify-content:space-between;} | |
body div#hs-eu-cookie-confirmation div#hs-eu-cookie-confirmation-inner div#hs-eu-policy-wording { margin-bottom:0;padding-right:30px;} | |
body div#hs-eu-cookie-confirmation div#hs-eu-cookie-confirmation-inner div#hs-eu-policy-wording p { margin:10px 0;} | |
body div#hs-eu-cookie-confirmation div#hs-eu-cookie-confirmation-inner div#hs-en-cookie-confirmation-buttons-area { margin-top:0 !important; } |
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
# Points to note: | |
# 1. Elementor data is saved as JSON in wp_postmeta with meta_key _elementor_data | |
# 2. The LIKE operator needs four backslashes for every one in the JSON data you are looking for. | |
# 3. The REPLACE function needs two backslashes for every one in the find / replace strings. | |
# 4. Eg: Searching for buttons with a particular label and linking to "/" - I want to change their links to /case-studies | |
update `wp_3_postmeta` set meta_value = REPLACE(meta_value, '"button_label":"View All","button_link":"\\/','"button_label":"View All","button_link":"\\/case-studies') WHERE meta_key = '_elementor_data' AND meta_value LIKE '%"button_label":"View All","button_link":"\\\\/"%'; |
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 | |
function example_admin_bar_settings($settings){ | |
//print_r($settings); | |
foreach($settings['elementor_edit_page']['children'] as $id => $item){ | |
//$id is the post id, perform whatever checks you want | |