Skip to content

Instantly share code, notes, and snippets.

@MogulChris
MogulChris / style.css
Created November 2, 2023 20:18
Elementor new menu widget - mobile dropdown slide-in effect
@media screen and (max-width:767px){
body .elementor-widget-n-menu .e-n-menu[data-layout=dropdown] .e-n-menu-toggle[aria-expanded=false]+.e-n-menu-wrapper {
left:100vw;
transition:left 0.3s ease-in-out;
display:flex;
max-height:unset;
}
body .elementor-widget-n-menu .e-n-menu[data-layout=dropdown] .e-n-menu-toggle[aria-expanded=true]+.e-n-menu-wrapper {
left:-40px;
transition:left 0.3s ease-in-out;
@MogulChris
MogulChris / border-image.html
Created October 29, 2023 19:45
CSS border image notes
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>title</title>
<style>
button {
appearance: none;
background-color: transparent;
@MogulChris
MogulChris / functions.php
Created March 15, 2023 02:56
Custom 'Save submission' action for Jupiter X forms
<?php
/*
This is a quick a dirty way of saving JupiterX form submissions to your database, similar to how you can save the Elementor Pro ones.
I like the Jupiter X form widget because I work with its Hubspot action a lot, which Elementor Pro doesn't have. However the lack of local save sucks.
It seemed easier to implement saving submissions in the JX widget than Hubspot in the EPro one.
*/
//Include the action class. You can save it where you want and adjust the path below
include_once(get_stylesheet_directory() . '/inc/localsave.php');
@MogulChris
MogulChris / functions.php
Created November 3, 2022 01:05
Adjusting the JupiterX WooComemrce Product Gallery thumbnails
<?php
//change the image size used in thumbnails
add_filter( 'woocommerce_get_image_size_gallery_thumbnail', function( $size ) {
return array(
'width' => 300,
'height' => 200,
'crop' => 1,
);
@MogulChris
MogulChris / functions.php
Created July 14, 2022 22:36
Add term meta to WordPress terms when created
<?php
//replace my_taxonomy with your own taxonomy slug
//The hook create_{$taxonomy} is fired when terms are created in $taxonomy
function my_taxonomy_meta_add($term_id, $tax_term_id){
//here you can add whatever meta you need
add_term_meta($term_id,'_date_created',time());
}
add_action('create_my_taxonomy','my_taxonomy_meta_add',10,3);
@MogulChris
MogulChris / worker.js
Created April 19, 2022 01:55
Cloudflare service worker to redirect to country subdirectories
//Based on https://community.cloudflare.com/t/geoip-redirection-worker/14414
//This assumes you have region-specific sites set up like so
//www.company.com - global landing page where this worker runs
//www.company.com/us/
//www.company.com/au/
//in our case we are only changing paths/dubdirectories, not domains. Map country codes to subdirectories.
@MogulChris
MogulChris / wpsl-export.php
Created March 27, 2022 22:07
Basic csv export for WP Store Locator
<?php
//bootstrap WP
require_once('wp-load.php');//I have this file saved in the site root
$stores = get_posts([
'post_type' => 'wpsl_stores',
'posts_per_page' => -1,
'post_status' => 'any'
]);
@MogulChris
MogulChris / functions.php
Created January 26, 2022 21:23
Filtering the 'Edit with Elementor' admin menu
<?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
@MogulChris
MogulChris / find-replace-elementor.sql
Created January 24, 2022 00:52
MySQL / PHPMyAdmin find and replace of Elementor data
# 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":"\\\\/"%';
@MogulChris
MogulChris / style.css
Created January 12, 2022 20:13
Hubspot cookies popup nicer styling
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; }