WordPress Codes
Super Snippets Bundle with the Switchboard
1) Download the Snippets bundle (loaded with awesome must-have snippets)
1a) If you only require the Switchboard, then just download that
2) Unzip the file
3) Go to Code Snippets > Import
4) Import the unzipped file
5) Activate the Snippets Switchboard
It is recommended that any separate snippets for font clamp, pageauditor, pagezoomer, landmarker, maskcurver, are removed before activating the new snippets inside the bundle.
The Filter Builder Version 5.1
1) Download the file
2) Unzip the file
3) Go to Code Snippets > Import
4) Import the unzipped file
Use extra codes below for additional expansions.
i) Off Canvas Reopen (keeps reopening Off Canvas if selecting filters). This should be added to Elementor Custom Codes.
PixRefiner - version 3.6
How to add (after taking a backup):
1) Install the Code Snippets Plugin
2) Click Add New
3) Copy the below code
4) Click Save and Activate
Export-and-Import-V4
1) Unzip and add the Code Snippet to your source or destination site
2) Go to Tools to use Elementor V4 Export
3) Either Export or Import the Blueprint below (after unzipping)
elementor-flight-deck
1) Unzip the file first to get the JSON
2) Go to the Code Snippets Plugin > Import
3) Add the JSON
4) Then Activate
v4-heading-paragraph-span
1) Unzip the file first to get the JSON
2) Go to the Code Snippets Plugin > Import
3) Add the JSON
4) Then Activate
product-colour-variations
How to add (after taking a backup):
1) Install the Code Snippets Plugin
2) Click Add New
3) Copy the below snippet
4) Click Save and Activate
5) Add a HTML widget into the Single Product template, and then paste the 2nd code.
6) Add the CSS to the ‘Add to Cart’ widget.
/**
* Woo Variation Radios + Auto Colour Swatches (reads term meta key: "color")
* - Keeps the original
/* Hide the default dropdowns for product variations */
.woocommerce div.product form.cart .variations select {
display: none;
}
/* Radios wrapper */
selector .ws-var-radios{
display:flex;
flex-wrap:wrap;
gap:25px;
}
/* Attribute Title alignment */
.woocommerce div.product form.cart .variations th {
text-align: left;
}
/* Each option */
.ws-var-radio{
--ws-swatch: #fff; /*if no colour*/
display:inline-flex;
align-items:center;
gap:6px;
cursor:pointer;
user-select:none;
}
/* Hide native radio */
.ws-var-radio input[type="radio"]{
position:absolute;
opacity:0;
pointer-events:none;
}
/* Visible swatch dot */
.ws-var-radio .ws-swatch{
width:15px;
height:15px;
border-radius:50px;
background: var(--ws-swatch);
display:inline-block;
outline:1px solid #d0d0ce;
}
/* Checked state */
.ws-var-radio input[type="radio"]:checked + .ws-swatch{
outline:2px solid #1e1e1e;
}
/* Keyboard focus */
.ws-var-radio input[type="radio"]:focus-visible + .ws-swatch{
outline:1px solid #1e1e1e;
}
/* Reset / Clear variations link */
.woocommerce div.product form.cart .reset_variations {
display: inline-block; /* allows margin + hover area */
margin-top: 15px; /* spacing above */
font-size: 16px; /* font size */
font-weight: 400;
color: #007E9A; /* text colour */
}
/* Hover state for Reset / Clear */
.woocommerce a.reset_variations:hover {
color: #1e1e1e; /* hover colour */
}
/* Set prices and stock colour */
.woocommerce div.product p.price,
.woocommerce div.product span.price,
.woocommerce-variation-price {
color: #1e1e1e;
}
.woocommerce div.product .stock {
color: #1e1e1e;
}
.woocommerce div.product form.cart .variations th,
.woocommerce div.product form.cart .variations td {
padding: 0 0 8px 0;
background: #fff;
line-height: 0em;
}
/* Make PayPal buttons match Add to Cart button width */
.woocommerce .wc-ppcp-button-container,
.woocommerce .paypal-buttons {
max-width: 50%;
}
.ppc-button-wrapper {margin-top: 20px;
}
PDFView v.1.2 (Old Version)
PDFViewer v2.1
Site to Social
LoadPrimer
LandMarker
PageZoomer
SiteMapper
Currency/Number ACF Formatter
WooCommerce Recent Sales
Loop Map
Appt-Booker
Main Image Slider
Wishlist
Shortcode to use:
[ws_wishlist_heart size=”36″ off=”#000″ on=”#ff0050″]
WP Sidebar Hiding
taxonomy-dropdowns
/* EXAMPLE Shortcode
[filter_dropdown
class="tax1"
taxonomy="poster-type"
placeholder="All Types"
border_color="#d0d0ce"
border_radius="25px"
padding="10px 25px"
font_size="16px"
font_color="#444"
font_weight="600"
background_color="#f4f4f4"
chevron_color="#999"
exclude="uncategorized,paid"
]
EXAMPLE RESET Shortcode
[filter_reset_all
placeholder="Reset All Filters"
border_color="#d0d0ce"
border_radius="25px"
font_size="16px"
font_color="#444"
font_weight="600"
padding="10px 25px"
background_color="#fff"
hover_background_color="#444"
hover_font_color="#fff"
hover_border_color="#444"
]
*/
function custom_taxonomy_filter_dropdown_shortcode($atts) {
static $instance_id = 0;
$instance_id++;
$atts = shortcode_atts([
'class' => 'filter-to-dropdown',
'placeholder' => 'All Categories',
'taxonomy' => 'category',
'border_color' => '#ededed',
'font_size' => '18px',
'font_color' => '#444',
'font_weight' => '400',
'background_color' => '#f4f4f4',
'chevron_color' => '#444',
'border_radius' => '25px',
'padding' => '10px 25px', // 🎯 dropdown padding control
'exclude' => '',
], $atts);
$select_id = 'custom-taxonomy-dropdown-' . $instance_id;
$excluded_slugs = array_filter(array_map('trim', explode(',', $atts['exclude'])));
ob_start();
?>
'Reset All',
'border_color' => '#ededed',
'font_size' => '18px',
'font_color' => '#444',
'font_weight' => '400',
'background_color' => '#f4f4f4',
'border_radius' => '25px',
'padding' => '10px 25px', // 🎯 reset button padding control
'hover_background_color' => '#e0e0e0', // 🎯 New
'hover_font_color' => '#222222', // 🎯 New
'hover_border_color' => '#d0d0d0', // 🎯 New
], $atts);
$unique_id = uniqid('reset_button_');
ob_start();
?>
elementor-base-code
/* Div Block element.
Sets minimum width of 30px, adds 10px padding, and displays as a block-level element. */
.elementor .e-div-block-base {
min-width: 30px;
padding: 10px;
display: block;
}
/* Flexbox element.
Creates a flex container with horizontal row layout and 10px padding. */
.elementor .e-flexbox-base {
padding: 10px;
display: flex;
flex-direction: row;
}
/* Tabs wrapper element.
Stacks tab menu and content vertically with 30px gap spacing. */
.elementor .e-tabs-base {
padding-block-start: 0px;
display: flex;
flex-direction: column;
gap: 30px;
}
/* Tabs menu wrapper.
Displays tab buttons using flexbox and centres them horizontally. */
.elementor .e-tabs-menu-base {
display: flex;
justify-content: center;
}
/* Individual tab button element.
Sets width, colours, padding, borders, background, and cursor styling. */
.elementor .e-tab-base {
width: 160px;
color: #0C0D0E;
cursor: pointer;
padding: 8px;
border-width: 2px;
border-color: #E0E0E0;
border-style: solid;
background-color: #FFFFFF;
display: block;
}
/* Selected tab state.
Changes border colour for the active tab and removes outline width. */
.elementor .e-tab-base.e--selected {
border-color: #0C0D0E;
outline-width: 0px;
}
/* Focused tab state.
Changes border colour when tab receives focus and removes outline width. */
.elementor .e-tab-base:focus {
border-color: #0C0D0E;
outline-width: 0px;
}
/* Hovered or keyboard-focused tab state.
Changes tab background colour on hover or visible focus. */
.elementor .e-tab-base:hover,
.elementor .e-tab-base:focus-visible {
background-color: #E0E0E0;
}
/* Tabs content wrapper.
Displays tab content area as a block-level element. */
.elementor .e-tabs-content-area-base {
display: block;
}
/* Individual tab content panel.
Sets minimum width, adds 10px padding, and displays as block. */
.elementor .e-tab-content-base {
min-width: 30px;
padding: 10px;
display: block;
}
/* Form wrapper element.
Creates flexbox form layout with wrapping, spacing, alignment, and 20px padding. */
.elementor .e-form-base {
padding: 20px;
display: flex;
flex-direction: row;
gap: 10px;
flex-wrap: wrap;
align-content: start;
align-items: flex-start;
}
/* Checkbox row inside forms.
Removes padding, adds 8px gap, and vertically aligns items. */
.elementor .e-form-base .e-form-checkbox-row {
padding: 0px;
gap: 8px;
align-items: center;
}
/* Form success message.
Styles success notification with green colours and hides it by default. */
.elementor .e-form-success-message-base {
font-size: 12px;
color: #2F532E;
text-align: center;
padding: 12px;
background-color: #D4E9D6;
display: none;
}
/* Form error message.
Styles error notification with red colours and hides it by default. */
.elementor .e-form-error-message-base {
font-size: 12px;
color: #870000;
text-align: center;
padding: 12px;
background-color: #ffdede;
display: none;
}
/* Heading element.
Removes default heading margin spacing. */
.elementor .e-heading-base {
margin: 0px;
}
/* Heading link element.
Removes default browser link styling and enables pointer cursor. */
.elementor .e-heading-link-base {
all: unset;
cursor: pointer;
}
/* Image link wrapper.
Makes linked image width fit content and inherit display behaviour. */
.elementor .e-image-link-base {
width: fit-content;
display: inherit;
}
/* Image element.
Displays image as a block-level element. */
.elementor .e-image-base {
display: block;
}
/* Paragraph element.
Removes default paragraph margins. */
.elementor .e-paragraph-base {
margin: 0px;
}
/* Paragraph link element.
Removes default browser link styling and enables pointer cursor. */
.elementor .e-paragraph-link-base {
all: unset;
cursor: pointer;
}
/* SVG element.
Sets default SVG dimensions and displays inline-block. */
.elementor .e-svg-base {
width: 65px;
height: 65px;
display: inline-block;
}
/* Button element.
Adds padding, blue background, border radius, centre alignment, and inline-block display. */
.elementor .e-button-base {
text-align: center;
padding-block-start: 12px;
padding-block-end: 12px;
padding-inline-start: 24px;
padding-inline-end: 24px;
border-radius: 2px;
border-width: 0px;
background-color: #375EFB;
display: inline-block;
}
/* YouTube embed element.
Maintains 16:9 aspect ratio and hides overflow. */
.elementor .e-youtube-base {
overflow: hidden;
aspect-ratio: 16/9;
}
/* Divider element.
Creates a 1px high black divider using background colour. */
.elementor .e-divider-base {
height: 1px;
border-width: 0px;
border-color: transparent;
border-style: none;
background-color: #000;
}
/* Self-hosted video element.
Limits width to viewport, maintains 16:9 ratio, and displays inline-block. */
.elementor .e-self-hosted-video-base {
max-width: 100vw;
aspect-ratio: 16/9;
display: inline-block;
}
/* Standard form input field.
Sets input height, font size, colours, and border styling. */
.elementor .e-form-input-base {
height: 36px;
font-size: 12px;
color: #0c0d0e;
border-radius: 0px;
border-color: #D6D5D5;
}
/* Focused form input field.
Darkens border colour and removes browser outline. */
.elementor .e-form-input-base:focus {
border-color: #706F6F;
outline-style: none;
}
/* Form input placeholder text.
Sets placeholder text colour. */
.elementor .e-form-input-base::placeholder {
color: #9DA5AE;
}
/* Form label element.
Sets label font size and text colour. */
.elementor .e-form-label-base {
font-size: 14px;
color: #0c0d0e;
}
/* Textarea field element.
Sets font size and border styling. */
.elementor .e-form-textarea-base {
font-size: 12px;
border-radius: 0px;
border-color: #D6D5D5;
}
/* Focused textarea field.
Darkens border colour and removes browser outline. */
.elementor .e-form-textarea-base:focus {
border-color: #706F6F;
outline-style: none;
}
/* Textarea placeholder text.
Sets placeholder text colour. */
.elementor .e-form-textarea-base::placeholder {
color: #9DA5AE;
}
/* Form submit button element.
Creates black button with centred content, padding, and white text. */
.elementor .e-form-submit-button-base {
color: #fff;
padding-block-start: 10px;
padding-block-end: 10px;
padding-inline-start: 28px;
padding-inline-end: 30px;
border-radius: 0px;
border-width: 0px;
background-color: #000;
display: flex;
justify-content: center;
align-items: center;
}
/* Hovered or focused submit button.
Changes background colour on hover or keyboard focus. */
.elementor .e-form-submit-button-base:hover,
.elementor .e-form-submit-button-base:focus-visible {
background-color: #323232;
}
/* Checkbox input element.
Creates custom checkbox styling, sizing, borders, transitions, and removes browser appearance. */
.elementor .e-form-checkbox-base {
width: 1.15em;
height: 1.15em;
color: #ffffff;
border-radius: 0px;
border-width: 1px;
border-color: #D6D5D5;
border-style: solid;
background-color: transparent;
transition: background-color 200ms;
display: grid;
justify-items: center;
align-items: center;
appearance: none;
}
/* Focused checkbox element.
Darkens border colour and removes browser outline. */
.elementor .e-form-checkbox-base:focus {
border-color: #706F6F;
outline-style: none;
}
/* Checked checkbox state.
Changes checkbox background colour when selected. */
.elementor .e-form-checkbox-base:checked {
background-color: #69727D;
}
/* Checkbox checkmark pseudo-element.
Creates custom checkmark shape using clip-path and opacity transition. */
.elementor .e-form-checkbox-base::before {
width: 65%;
height: 65%;
background-color: currentColor;
opacity: 0%;
transform-origin: 0% 100% 0px;
transition: opacity 200ms;
content: "";
clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
/* Visible checkbox checkmark state.
Shows checkmark when checkbox is checked. */
.elementor .e-form-checkbox-base:checked::before {
opacity: 100%;
}
/* Radio button element.
Creates custom circular radio button and removes browser appearance. */
.elementor .e-form-radio-button-base {
width: 1.15em;
height: 1.15em;
color: #ffffff;
border-radius: 50%;
border-width: 1px;
border-color: #D6D5D5;
border-style: solid;
background-color: transparent;
display: grid;
justify-items: center;
align-items: center;
appearance: none;
}
/* Focused radio button.
Darkens border colour and removes browser outline. */
.elementor .e-form-radio-button-base:focus {
border-color: #706F6F;
outline-style: none;
}
/* Checked radio button state.
Keeps background transparent when selected. */
.elementor .e-form-radio-button-base:checked {
background-color: transparent;
}
/* Radio button inner dot pseudo-element.
Creates inner selected dot using opacity transition. */
.elementor .e-form-radio-button-base::before {
width: 65%;
height: 65%;
border-radius: 50%;
background-color: #706F6F;
opacity: 0%;
transition: opacity 200ms;
content: "";
}
/* Visible radio button selected dot.
Shows inner dot when radio button is selected. */
.elementor .e-form-radio-button-base:checked::before {
opacity: 100%;
}
/* Date picker field element.
Sets sizing, borders, colours, and typography for date input. */
.elementor .e-form-date-picker-base {
width: 100%;
height: 36px;
font-size: 12px;
color: #0c0d0e;
border-radius: 0px;
border-width: 1px;
border-color: #D6D5D5;
border-style: solid;
}
/* Focused date picker field.
Darkens border colour and removes browser outline. */
.elementor .e-form-date-picker-base:focus {
border-color: #706F6F;
outline-style: none;
}
/* Time picker field element.
Sets sizing, borders, colours, and typography for time input. */
.elementor .e-form-time-picker-base {
width: 100%;
height: 36px;
font-size: 12px;
color: #0c0d0e;
border-radius: 0px;
border-width: 1px;
border-color: #D6D5D5;
border-style: solid;
}
/* Focused time picker field.
Darkens border colour and removes browser outline. */
.elementor .e-form-time-picker-base:focus {
border-color: #706F6F;
outline-style: none;
}
/* Select dropdown field element.
Sets border styling, typography, and transparent background. */
.elementor .e-form-select-base {
font-size: 12px;
border-width: 1px;
border-color: #D6D5D5;
border-style: solid;
background-color: transparent;
}
/* Focused select dropdown field.
Darkens border colour and removes browser outline. */
.elementor .e-form-select-base:focus {
border-color: #706F6F;
outline-style: none;
}
/* File upload field element.
Sets sizing, typography, colours, and border styling. */
.elementor .e-form-file-upload-base {
height: 36px;
font-size: 12px;
color: #0c0d0e;
border-radius: 0px;
border-color: #D6D5D5;
}
/* Focused file upload field.
Darkens border colour and removes browser outline. */
.elementor .e-form-file-upload-base:focus {
border-color: #706F6F;
outline-style: none;
}
image-mask-merge
/* Make the gap length animatable */
@property --g {
syntax: "";
inherits: true;
initial-value: 20px;
}
img {
--g: 20px;
--_g: var(--g)/calc(50% - var(--g)) calc(50% - var(--g))
no-repeat conic-gradient(#000 0 0);
-webkit-mask:
left var(--_i,) top var(--_g),
bottom var(--_i,) left var(--_g),
top var(--_i,) right var(--_g),
right var(--_i,) bottom var(--_g);
mask:
left var(--_i,) top var(--_g),
bottom var(--_i,) left var(--_g),
top var(--_i,) right var(--_g),
right var(--_i,) bottom var(--_g);
transition: filter .3s linear;
cursor: pointer;
/* Hook into scroll */
view-timeline-name: --gapScroll;
view-timeline-axis: block;
animation: gap-shrink 1 linear both;
animation-timeline: --gapScroll;
animation-range: cover 45% cover 60%;
}
/* Animate the CSS var based on scroll */
@keyframes gap-shrink {
from { --g: 20px; }
to { --g: 0px; }
}
/* ===== Mobile override ===== */
@media (max-width: 767px) {
img {
--g: 20px; /* force a fixed gap (or set to 0px if you want no gap) */
animation: none; /* stop the scroll animation */
}
}
drag-and-drop-ordering
/**
* Universal Admin Reorder (PATCHED)
* Fixes:
* - DO NOT force posts_per_page = -1 (keeps pagination fast)
* - DO NOT interfere with admin-ajax (Quick Edit / inline-save)
* - Save Quick Edit menu_order WITHOUT wp_update_post recursion
* - Minor hardening + cleanup for columns/bulk actions across supported post types
*/
/**
* 1) Enable menu_order support for all public post types including WooCommerce Products
*/
add_action('init', function () {
$post_types = get_post_types(['public' => true], 'names');
foreach ($post_types as $pt) {
// Add "page-attributes" support (menu_order lives here in WP UI)
if (!post_type_supports($pt, 'page-attributes')) {
add_post_type_support($pt, 'page-attributes');
}
// Ensure products also have it (some setups omit it)
if ($pt === 'product' && !post_type_supports($pt, 'page-attributes')) {
add_post_type_support($pt, 'page-attributes');
}
}
}, 20);
/**
* 2) Default admin post order by menu_order when supported and no explicit sort selected
* PATCH: do NOT set posts_per_page = -1, and do NOT run during AJAX (Quick Edit)
*/
add_action('pre_get_posts', function ($q) {
if (!is_admin() || !$q->is_main_query()) return;
// Critical: do not touch admin-ajax requests (Quick Edit / inline-save etc.)
if (wp_doing_ajax()) return;
// Only on list table screens (edit.php)
if (!function_exists('get_current_screen')) return;
$screen = get_current_screen();
if (!$screen || $screen->base !== 'edit') return;
$post_type = $q->get('post_type');
if (!$post_type) return;
// Some admin screens provide array post_type – normalize
if (is_array($post_type)) {
$post_type = reset($post_type);
}
if (!post_type_supports($post_type, 'page-attributes')) return;
// If user chose an orderby that isn't menu_order, respect it
$orderby = isset($_GET['orderby']) ? sanitize_key($_GET['orderby']) : '';
if ($orderby && $orderby !== 'menu_order') return;
$q->set('orderby', 'menu_order');
$q->set('order', 'ASC');
// PATCH: keep pagination (no posts_per_page = -1)
}, 20);
/**
* 3) Enqueue jQuery UI Sortable
*/
add_action('admin_enqueue_scripts', function () {
wp_enqueue_script('jquery-ui-sortable');
});
/**
* 4) Add reorder toggle button and script (edit.php only)
*/
add_action('admin_footer-edit.php', function () {
if (!function_exists('get_current_screen')) return;
$screen = get_current_screen();
if (!$screen || empty($screen->post_type)) return;
if (!post_type_supports($screen->post_type, 'page-attributes')) return;
$nonce = wp_create_nonce('universal_order_nonce');
$post_type = esc_js($screen->post_type);
?>
Reorder Mode Active: Drag the handles to reorder items. Changes save automatically. Click "Toggle Reorder" again when done.
Saving order...
$post_type,
'posts_per_page' => -1,
'post_status' => ['publish', 'draft', 'pending', 'future', 'private'],
'orderby' => 'menu_order',
'order' => 'ASC',
'fields' => 'ids',
];
$all_ids = get_posts($args);
if (!in_array($post_id, $all_ids, true)) {
wp_send_json_error('Post ID not found');
}
$from = array_search($post_id, $all_ids, true);
array_splice($all_ids, $from, 1);
array_splice($all_ids, $new_index, 0, $post_id);
// Fast update (avoid triggering save_post hooks repeatedly)
global $wpdb;
foreach ($all_ids as $index => $id) {
$wpdb->update(
$wpdb->posts,
['menu_order' => (int) $index],
['ID' => (int) $id],
['%d'],
['%d']
);
clean_post_cache((int) $id);
}
wp_send_json_success('Order saved');
});
/**
* 6) WooCommerce respects menu_order when selected
*/
add_filter('woocommerce_default_catalog_orderby_options', function ($options) {
$options['menu_order'] = 'Default sorting';
return $options;
});
add_filter('woocommerce_get_catalog_ordering_args', function ($args) {
if (isset($_GET['orderby']) && $_GET['orderby'] === 'menu_order') {
$args['orderby'] = 'menu_order title';
$args['order'] = 'ASC';
}
return $args;
});
/**
* 7) Add drag handle and "Order" columns to admin tables
* PATCH: avoid duplicate manage_edit-{$pt}_columns filters by using one filter to add both
*/
add_action('admin_init', function () {
$post_types = get_post_types(['public' => true], 'names');
foreach ($post_types as $pt) {
if (!post_type_supports($pt, 'page-attributes')) continue;
// Add drag handle + Order column
add_filter("manage_edit-{$pt}_columns", function ($columns) {
// Insert handle at start
$columns = array_merge(['reorder_handle' => ''], $columns);
// Add order column (near end)
$columns['menu_order'] = 'Order';
return $columns;
});
// Populate columns
add_action("manage_{$pt}_posts_custom_column", function ($column, $post_id) {
if ($column === 'menu_order') {
$order = (int) get_post_field('menu_order', $post_id);
echo '' . esc_html($order + 1) . '';
} elseif ($column === 'reorder_handle') {
echo '';
}
}, 10, 2);
// Make Order column sortable
add_filter("manage_edit-{$pt}_sortable_columns", function ($columns) {
$columns['menu_order'] = 'menu_order';
return $columns;
});
}
});
/**
* 8) Add bulk actions for order management (ALL supported post types)
* PATCH: apply to every page-attributes-supported post type, not just post/page.
*/
add_filter('bulk_actions-edit-post', 'universal_order_add_bulk_actions');
add_filter('bulk_actions-edit-page', 'universal_order_add_bulk_actions');
add_action('admin_init', function () {
$post_types = get_post_types(['public' => true], 'names');
foreach ($post_types as $pt) {
if (in_array($pt, ['post', 'page'], true)) continue;
if (!post_type_supports($pt, 'page-attributes')) continue;
add_filter("bulk_actions-edit-{$pt}", 'universal_order_add_bulk_actions');
}
});
function universal_order_add_bulk_actions($bulk_actions) {
if (!function_exists('get_current_screen')) return $bulk_actions;
$screen = get_current_screen();
if ($screen && !empty($screen->post_type) && post_type_supports($screen->post_type, 'page-attributes')) {
$bulk_actions['reset_order'] = 'Reset Order';
$bulk_actions['reverse_order'] = 'Reverse Order';
}
return $bulk_actions;
}
/**
* 9) Handle bulk actions (ALL supported post types)
*/
add_filter('handle_bulk_actions-edit-post', 'universal_order_handle_bulk_actions', 10, 3);
add_filter('handle_bulk_actions-edit-page', 'universal_order_handle_bulk_actions', 10, 3);
add_action('admin_init', function () {
$post_types = get_post_types(['public' => true], 'names');
foreach ($post_types as $pt) {
if (in_array($pt, ['post', 'page'], true)) continue;
if (!post_type_supports($pt, 'page-attributes')) continue;
add_filter("handle_bulk_actions-edit-{$pt}", 'universal_order_handle_bulk_actions', 10, 3);
}
});
function universal_order_handle_bulk_actions($sendback, $doaction, $post_ids) {
if ($doaction !== 'reset_order' && $doaction !== 'reverse_order') {
return $sendback;
}
if (!function_exists('get_current_screen')) return $sendback;
$screen = get_current_screen();
if (!$screen || empty($screen->post_type)) return $sendback;
$args = [
'post_type' => $screen->post_type,
'posts_per_page' => -1,
'post_status' => ['publish', 'draft', 'pending', 'future', 'private'],
'orderby' => $doaction === 'reverse_order' ? 'menu_order' : 'date',
'order' => $doaction === 'reverse_order' ? 'DESC' : 'ASC',
'fields' => 'ids',
];
$all_ids = get_posts($args);
global $wpdb;
foreach ($all_ids as $index => $id) {
$wpdb->update(
$wpdb->posts,
['menu_order' => (int) $index],
['ID' => (int) $id],
['%d'],
['%d']
);
clean_post_cache((int) $id);
}
$sendback = add_query_arg('bulk_order_updated', count($all_ids), $sendback);
return $sendback;
}
/**
* 10) Display admin notice for bulk actions
*/
add_action('admin_notices', function () {
if (!empty($_REQUEST['bulk_order_updated']) && !empty($_REQUEST['_wp_http_referer'])) {
$count = (int) $_REQUEST['bulk_order_updated'];
echo '';
echo sprintf('Order updated for %d item%s.', $count, $count !== 1 ? 's' : '');
echo '
';
?>
update(
$wpdb->posts,
['menu_order' => $new_order],
['ID' => (int) $post_id],
['%d'],
['%d']
);
clean_post_cache((int) $post_id);
}, 10, 1);
fluid-font-clamp-calculator - v.4
mask-curver - v2.0.1
apple-liquid-glass
There are 2 versions below. The first is more refractive glass like than the second, but try them out.
Note that the CSS at the top before adding the SVG script should be added to Custom CSS for the element/container.
// Code 1
// CSS
selector {
backdrop-filter: url(#liquid-prism-intense);
-webkit-backdrop-filter: url(#liquid-prism-intense);
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 50px;
color: white;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
transition: all 0.3s ease;
}
selector:hover {
transform: scale(1.02);
}
// Add to HTML Widget
// Code 2
// CSS
selector {
backdrop-filter: url(#liquid-prism-intense2);
-webkit-backdrop-filter: url(#liquid-prism-intense2);
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 50px;
color: white;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
transition: all 0.3s ease;
}
selector:hover {
transform: scale(1.02);
}
// Add to HTML Widget
quote-form
/* Code to add the Quote Selector */
Web Design Quote Calculator
Web Design Quote Calculator
Select your requirements to get an estimated quote
Website Options
Base Website Package
Includes responsive design, contact form
$1,500
($225 per additional page)
Additional Features
Select the features you need for your website
E-commerce Functionality
Online store with payment processing
+ $2,000
SEO Optimization
On-page SEO and keyword optimization
+ $800
+$100 per additional page
Performance Optimization
Speed and loading time improvements
+ $600
Investigation/Makeover
Analysis and redesign of existing site
+ $1,200
Your Estimated Quote
Based on your selections:
- Base Website Package: $1,500
Estimated Cost:
$1,500
This is an estimate. Contact us for a detailed quote.
/* Code to link Quote Fields to Elementor Form */
trigger-scroll
stop-lazy-load-preload
// Disable lazy load AND preload specific image IDs
add_filter('wp_img_tag_add_loading_attr', 'custom_disable_lazyload_for_lcp_images', 10, 3);
add_filter('wp_preload_resources', 'custom_preload_lcp_images');
// Define your LCP image attachment IDs here
function get_lcp_image_ids() {
return [36792, 36791]; // Add or remove IDs as needed
}
// 1. Disable Lazy Loading for LCP images
function custom_disable_lazyload_for_lcp_images($value, $image, $context) {
if (in_array($context, ['the_content', 'widget', 'elementor', 'post'])) {
foreach (get_lcp_image_ids() as $image_id) {
$image_url = wp_get_attachment_image_url($image_id, 'large');
if ($image_url && strpos($image, ' src="' . $image_url . '"') !== false) {
return false;
}
}
}
return $value;
}
// 2. Preload the same images in the
function custom_preload_lcp_images($hints) {
if (is_front_page() || is_singular()) {
foreach (get_lcp_image_ids() as $image_id) {
$image_url = wp_get_attachment_image_url($image_id, 'large');
$mime = get_post_mime_type($image_id);
$type = $mime ?: 'image/jpeg'; // Safer fallback
if ($image_url) {
$hints[] = [
'href' => $image_url,
'as' => 'image',
'type' => $type,
];
}
}
}
return $hints;
}
pageauditor
/**
* Copyright (c) 2025 Imran Siddiq. All rights reserved.
*
* This code is proprietary and confidential. Unauthorized copying, reproduction, redistribution, modification, public display,
* or resale of this code, in whole or in part, is strictly prohibited without prior written permission from the creator, Imran Siddiq.
*
* For licensing inquiries, contact: info@websquadron.co.uk.
*/
// IMPORTANT NOTE: Clicking on the Audit Pane Title 'Built Audit' allows you to drag the pane.
// This tool is to be used when Editing with Elementor
// Using the Audit when viewing in Preview will show extra WordPress issues that should not be used.
function add_landmark_audit_guide() {
static $landmark_audit_loaded = false;
if ($landmark_audit_loaded) return;
$landmark_audit_loaded = true;
// --- Access control: must be logged in, be Admin/Editor AND be on allow list.
if ( ! is_user_logged_in() ) return;
$user = wp_get_current_user();
$uid = (int) $user->ID;
$uemail = strtolower($user->user_email);
$ulogin = strtolower(
$user->user_login);
// 1) Role gate (Admin/Editor)
$has_role = current_user_can('manage_options') || current_user_can('edit_others_pages');
if ( ! $has_role ) return;
// 2) Optional block-list (deny even if otherwise allowed)
$blocked_emails = [
'info@websquadron.co.uk',
// 'someone@domain.com',
];
if ( in_array($uemail, array_map('strtolower',$blocked_emails), true) ) return;
// 3) Allow-list: only these users can see the Audit
$allow_emails = [
'teammate@yourdomain.com',
'teammate@yourdomain.com',
// add more…
];
$allow_ids = [1, 23]; // numeric WP user IDs
$allow_usernames = ['alice','bob'];
$allowed = in_array($uemail, array_map('strtolower',$allow_emails), true)
|| in_array($uid, $allow_ids, true)
|| in_array($ulogin, array_map('strtolower',$allow_usernames), true);
if ( ! $allowed ) return;
echo "";
?>
menu-inline-styling
/* These styles must be GLOBAL - outside media queries */
/* Normal, Focused, Active, Highlighted */
.elementor-nav-menu--dropdown .menu_button > .elementor-item,
.elementor-nav-menu--dropdown .menu_button > .elementor-item:focus,
.elementor-nav-menu--dropdown .menu_button > .elementor-item:active,
.elementor-nav-menu--dropdown .menu_button > .elementor-item.elementor-item-active.highlighted.focused.selected {
background-color: #ff0050 !important;
color: #fff !important;
font-weight: 600;
text-align: start;
display: inline-flex;
padding: 5px 10px;
margin: 8px -5px 20px 20px;
border-radius: 5px;
transition: background-color 0.3s ease, color 0.3s ease;}
/* HOVER state */
.elementor-nav-menu--dropdown .menu_button:hover > .elementor-item {
background-color: #000 !important;
color: #fff !important;}
/* FLEX styles only for mobile */
@media (max-width: 768px) {
.elementor-nav-menu--dropdown .elementor-nav-menu {
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: flex-start;}
.elementor-nav-menu--dropdown .elementor-nav-menu > li {
width: 100%;}
.elementor-nav-menu--dropdown .elementor-nav-menu > .menu_button {
width: auto;
flex: 0 0 auto;}
}
gallery-stagger-animation
skip-to-content-fix
add_action('wp_footer', function () {
?>
conditional-logic-simple
flip-desktop-click-mobile-click
flip-desktop-hover-mobile-click
page-breadcrumbs
function dynamic_custom_breadcrumbs() {
global $post;
$separator = ' / ';
$breadcrumbs = [];
if ($post->post_parent) {
$ancestors = array_reverse(get_post_ancestors($post->ID));
foreach ($ancestors as $ancestor_id) {
$breadcrumbs[] = '' . get_the_title($ancestor_id) . '';
}
}
$breadcrumbs[] = '' . get_the_title() . '';
echo '' . implode($separator, $breadcrumbs) . '';
}
add_shortcode('breadcrumbs', 'dynamic_custom_breadcrumbs');
tab-nav-button
breadcrumb-shop
// Force "Shop" instead of "Home" in WooCommerce breadcrumbs with a specific URL
add_filter('woocommerce_get_breadcrumb', 'force_shop_breadcrumb_link', 20);
function force_shop_breadcrumb_link($crumbs) {
// Define the specific Shop URL
$shop_page_url = 'https://test.websquadron.co.uk/shop';
// Ensure the first breadcrumb is "Shop" instead of "Home"
if (!empty($crumbs) && isset($crumbs[0][0]) && strtolower($crumbs[0][0]) === 'home') {
$crumbs[0] = array('Shop', $shop_page_url);
}
return $crumbs;
}
staggered-loop
redirection
add_action('template_redirect', function() {
$redirects = [
'/old-page-url/' => '/new-page-url/',
'/pix/' => '/pix2/',
];
$current = $_SERVER['REQUEST_URI'];
if (isset($redirects[$current])) {
wp_redirect(home_url($redirects[$current]), 301);
exit;
}
});
cover-pdf
embed-pdf
important-info
function add_important_information_widget() {
wp_add_dashboard_widget(
'important_information_widget',
'Important Information',
'important_information_widget_content'
);
}
add_action( 'wp_dashboard_setup', 'add_important_information_widget' );
function important_information_widget_content() {
echo '';
echo 'Web Contact
';
echo '';
echo '- Web Designer: Imran Siddiq
';
echo '- Email: info@websquadron.co.uk
';
echo '- Website: https://learn.websquadron.co.uk
';
echo '
';
echo 'Care Plan
';
echo '';
echo '- £90 Monthly
';
echo '- Incl. Plugin Updates, SSL Certificate, Backups, & 3 Minor Revisions.
';
echo '- Major Revisions start at £60 and will be agreed prior to work.
';
echo '- Consultations can be booked at £80 per 30 mins, or £150 per hour.
';
echo '
';
echo 'Licenses
';
echo '';
echo '- Domain - Auto-Renew 123-Reg - April
';
echo '- Hosting - Auto-Renew Elementor Hosting - April
';
echo '- Builder - Auto-Renew Elementor Pro - May
';
echo '- Filters - Auto-Renew Gridbuilder - June
';
echo '
';
echo '';
}
pause-container-bg-video
current-query-sort
add_action( 'elementor/query/customorder', function( $query ) {
$query->set( 'orderby', 'date' );
// $query->set( 'orderby', 'title' );
// $query->set( 'orderby', 'menu_order' );
$query->set( 'order', 'ASC' );
});
pause-video-widget
off-canvas-same-pane-anchor
ACF-Text-Editor
function acf_field_shortcode($atts) {
$atts = shortcode_atts(array(
'field' => '',
'post_id' => false,
), $atts, 'acf');
if (function_exists('get_field')) {
$field_value = get_field($atts['field'], $atts['post_id']);
// If the field is an array (like a select, relationship, or taxonomy field)
if (is_array($field_value)) {
$output = [];
foreach ($field_value as $item) {
if (is_numeric($item)) {
// Check if it's a post ID
$post = get_post($item);
if ($post) {
$output[] = get_the_title($post->ID);
continue;
}
// Check if it's a taxonomy term ID
$term = get_term($item);
if (!is_wp_error($term) && !empty($term)) {
$output[] = $term->name;
continue;
}
}
// If it's not a number, just add the value
$output[] = $item;
}
return esc_html(implode(', ', $output));
}
// If it's a single post ID, get the post title
if (is_numeric($field_value)) {
$post = get_post($field_value);
if ($post) {
return esc_html(get_the_title($post->ID));
}
$term = get_term($field_value);
if (!is_wp_error($term) && !empty($term)) {
return esc_html($term->name);
}
}
return esc_html($field_value);
}
return '';
}
add_shortcode('acf', 'acf_field_shortcode');
stroke-and-non-stroke
We Design, Build and Maintain Affordable Websites
off-canvas-apple-mobile-menu
colour-contrast-checker-wcag
add_action('admin_menu', 'contrast_checker_menu');
add_action('admin_init', 'contrast_checker_settings');
function contrast_checker_menu() {
add_options_page('Contrast Checker', 'Contrast Checker', 'manage_options', 'contrast-checker', 'contrast_checker_page');
}
function contrast_checker_settings() {
add_settings_section('contrast_checker_section', 'Contrast Checker - Web Content Accessibility Guidelines (WCAG) 2.1 ', null, 'contrast-checker');
add_settings_field('background_color', 'Background Color', 'background_color_callback', 'contrast-checker', 'contrast_checker_section');
add_settings_field('text_color', 'Foreground Color', 'foreground_color_callback', 'contrast-checker', 'contrast_checker_section');
add_settings_field('font_size', 'Font Size (px)', 'font_size_callback', 'contrast-checker', 'contrast_checker_section');
register_setting('contrast_checker_group', 'background_color');
register_setting('contrast_checker_group', 'text_color');
register_setting('contrast_checker_group', 'font_size'); // Ensures font size persists
}
function background_color_callback() {
$background_color = get_option('background_color', '#FFFFFF');
echo ''; // Reduce gap
echo '';
echo '' . esc_attr($background_color) . '';
}
function foreground_color_callback() {
$foreground_color = get_option('text_color', '#000000');
echo ''; // Reduce gap
echo '';
echo '' . esc_attr($foreground_color) . '';
}
function font_size_callback() {
$font_size = get_option('font_size', '16');
echo ''; // Reduce gap
echo '';
echo 'px';
}
function contrast_checker_page() {
?>
Contrast Checker
Tips for AA and AAA
1. Larger Fonts of 24px can pass the AA rule.
2. If you need to test Non-text elements, increase the font to 24px.
3. Inactive/disabled UI components do not require contrast compliance.
4. Logos and branding are exempt from contrast rules.
What is AA?
AA requires a contrast ratio of at least 4.5:1 for normal text (less than 24px) and 3:1 for large text (minimum 24px). Non-text elements (like buttons, icons, form fields, focus indicators, etc should be at least 3.1.
What is AAA?
AAA requires a contrast ratio of at least 7:1 for normal text (less than 24px) and 4.5:1 for large text (minimum 24px). Non-text elements (like buttons, icons, form fields, focus indicators, etc should be at least 4.5.1.
= 24) ? 3.0 : 4.5; // Large text is 24px or larger
$aaa_threshold = ($font_size >= 24) ? 4.5 : 7.0; // Large text is 24px or larger
// Calculate the current contrast ratio
$contrast_ratio = contrast_ratio($bg_luminance, $txt_luminance);
// Determine if the current colors pass AA and AAA
$aa_pass = ($contrast_ratio >= $aa_threshold) ? 'Yes' : 'No';
$aaa_pass = ($contrast_ratio >= $aaa_threshold) ? 'Yes' : 'No';
// Calculate suggested foreground colors for AA and AAA compliance
$suggested_aa = adjust_foreground_color($bg_rgb, $txt_rgb, $aa_threshold);
$suggested_aaa = adjust_foreground_color($bg_rgb, $txt_rgb, $aaa_threshold);
// Calculate suggested background colors for AA and AAA compliance
$suggested_bg_aa = adjust_background_color($bg_rgb, $txt_rgb, $aa_threshold);
$suggested_bg_aaa = adjust_background_color($bg_rgb, $txt_rgb, $aaa_threshold);
// Calculate the contrast ratio for the suggested colors
$suggested_aa_rgb = hex_to_rgb($suggested_aa);
$suggested_aa_luminance = luminance($suggested_aa_rgb);
$suggested_aa_ratio = contrast_ratio($bg_luminance, $suggested_aa_luminance);
$suggested_aaa_rgb = hex_to_rgb($suggested_aaa);
$suggested_aaa_luminance = luminance($suggested_aaa_rgb);
$suggested_aaa_ratio = contrast_ratio($bg_luminance, $suggested_aaa_luminance);
$suggested_bg_aa_rgb = hex_to_rgb($suggested_bg_aa);
$suggested_bg_aa_luminance = luminance($suggested_bg_aa_rgb);
$suggested_bg_aa_ratio = contrast_ratio($suggested_bg_aa_luminance, $txt_luminance);
$suggested_bg_aaa_rgb = hex_to_rgb($suggested_bg_aaa);
$suggested_bg_aaa_luminance = luminance($suggested_bg_aaa_rgb);
$suggested_bg_aaa_ratio = contrast_ratio($suggested_bg_aaa_luminance, $txt_luminance);
// Return the results
return '
Contrast Ratio: ' . round($contrast_ratio, 2) . '
AA Compliant: ' . $aa_pass . '
AAA Compliant: ' . $aaa_pass . '
Suggested Foreground Color for AA:
' . $suggested_aa . '
Contrast Ratio: ' . round($suggested_aa_ratio, 2) . '
Suggested Background Color for AA:
' . $suggested_bg_aa . '
Contrast Ratio: ' . round($suggested_bg_aa_ratio, 2) . '
Suggested Foreground Color for AAA:
' . $suggested_aaa . '
Contrast Ratio: ' . round($suggested_aaa_ratio, 2) . '
Suggested Background Color for AAA:
' . $suggested_bg_aaa . '
Contrast Ratio: ' . round($suggested_bg_aaa_ratio, 2) . '
';
}
// Function to adjust the background color to meet the target contrast ratio
function adjust_background_color($bg_rgb, $txt_rgb, $target_ratio) {
$txt_luminance = luminance($txt_rgb);
$step = 0.02; // Adjust step value for precision and performance
// Incrementally adjust the RGB values to find a compliant color
for ($i = 0; $i <= 1; $i += $step) {
$test_rgb = adjust_rgb_lightness($bg_rgb, $i);
$test_luminance = luminance($test_rgb);
if (contrast_ratio($test_luminance, $txt_luminance) >= $target_ratio) {
return rgb_to_hex($test_rgb);
}
$test_rgb = adjust_rgb_lightness($bg_rgb, -$i);
$test_luminance = luminance($test_rgb);
if (contrast_ratio($test_luminance, $txt_luminance) >= $target_ratio) {
return rgb_to_hex($test_rgb);
}
}
return "#FFFFFF"; // fallback to white if no suitable color found
}
function hex_to_rgb($hex) {
$hex = ltrim($hex, '#');
$r = hexdec(substr($hex, 0, 2)) / 255;
$g = hexdec(substr($hex, 2, 2)) / 255;
$b = hexdec(substr($hex, 4, 2)) / 255;
return array($r, $g, $b);
}
function rgb_to_hex($rgb) {
return sprintf("#%02x%02x%02x", round($rgb[0] * 255), round($rgb[1] * 255), round($rgb[2] * 255));
}
function luminance($rgb) {
list($r, $g, $b) = $rgb;
$r = ($r <= 0.03928) ? $r / 12.92 : pow(($r + 0.055) / 1.055, 2.4);
$g = ($g <= 0.03928) ? $g / 12.92 : pow(($g + 0.055) / 1.055, 2.4);
$b = ($b <= 0.03928) ? $b / 12.92 : pow(($b + 0.055) / 1.055, 2.4);
return 0.2126 * $r + 0.7152 * $g + 0.0722 * $b;
}
function contrast_ratio($l1, $l2) {
$lighter = max($l1, $l2);
$darker = min($l1, $l2);
return ($lighter + 0.05) / ($darker + 0.05);
}
function adjust_foreground_color($bg_rgb, $txt_rgb, $target_ratio) {
$bg_luminance = luminance($bg_rgb);
$step = 0.02; // Adjust step value for precision and performance
// Incrementally adjust the RGB values to find a compliant color
for ($i = 0; $i <= 1; $i += $step) {
$test_rgb = adjust_rgb_lightness($txt_rgb, $i);
$test_luminance = luminance($test_rgb);
if (contrast_ratio($test_luminance, $bg_luminance) >= $target_ratio) {
return rgb_to_hex($test_rgb);
}
$test_rgb = adjust_rgb_lightness($txt_rgb, -$i);
$test_luminance = luminance($test_rgb);
if (contrast_ratio($test_luminance, $bg_luminance) >= $target_ratio) {
return rgb_to_hex($test_rgb);
}
}
return "#000000"; // fallback to black if no suitable color found
}
function adjust_rgb_lightness($rgb, $adjustment) {
return array(
min(1, max(0, $rgb[0] + $adjustment)),
min(1, max(0, $rgb[1] + $adjustment)),
min(1, max(0, $rgb[2] + $adjustment))
);
}
Hide-AI-User-Setting
add_action('admin_footer', function () {
?>
open-off-canvas-page-load
center-focus-carousel
horizontal-scroll
title-tabs-styling
Drag & Drop Editing
Build perfectly designed websites
Create exactly what you want.
image-swap
shipping-methods-based-on-cart-totals
add_filter( 'woocommerce_package_rates', 'gncy_hide_shipping_based_on_threshold', 10, 2 );
function gncy_hide_shipping_based_on_threshold( $rates, $package ) {
$threshold = 40; // Threshold for hiding and showing shipping methods
$subtotal = WC()->cart->get_subtotal(); // Get the cart subtotal
if ( $subtotal > $threshold ) {
// Hide flat rate when subtotal exceeds the threshold
if ( isset( $rates['flat_rate:4'] ) ) {
unset( $rates['flat_rate:4'] );
}
} else {
// Hide free shipping when subtotal is below the threshold
if ( isset( $rates['free_shipping:3'] ) ) {
unset( $rates['free_shipping:3'] );
}
// Add the custom message to the cart totals section
add_action( 'woocommerce_after_cart_totals', 'gncy_add_free_shipping_message' );
}
return $rates;
}
// Add the custom message directly below cart totals
function gncy_add_free_shipping_message() {
echo '
Free Shipping when you spend $40+
';
}
css-colour-history-elementor-top
function add_custom_script_with_history_and_width_to_elementor() {
?>
show-hide-click
tooltips
Transform your CSSCSS - Cascading Style Sheet levels with the Web SquadronWeb Agency, Content Creator, Pepsi-Max Lover Course.
dropdown-scrollable-links
Option A
Option A
Option B
Option C
Option D
Option E
Option F
featured-image-quick-edit
// Add Featured Image Column
// Add Featured Image Column for All Post Types
add_filter('manage_posts_columns', function ($columns) {
$columns['featured_image'] = __('Featured Image');
return $columns;
});
add_filter('manage_edit-post_columns', function ($columns) {
$columns['featured_image'] = __('Featured Image');
return $columns;
});
add_filter('manage_edit-{post_type}_columns', function ($columns) {
$columns['featured_image'] = __('Featured Image');
return $columns;
}, 10, 2);
// Display Featured Image in the Column for All Post Types
add_action('manage_posts_custom_column', function ($column, $post_id) {
if ($column === 'featured_image') {
echo get_the_post_thumbnail($post_id, [50, 50]) ?: __('No Image');
}
}, 10, 2);
add_action('manage_{post_type}_custom_column', function ($column, $post_id) {
if ($column === 'featured_image') {
echo get_the_post_thumbnail($post_id, [50, 50]) ?: __('No Image');
}
}, 10, 2);
// Add Featured Image Field to Quick Edit for All Post Types
add_action('quick_edit_custom_box', function ($column_name, $post_type) {
if ($column_name === 'featured_image') {
?>
");
});
frame.open();
});
// Pre-fill Quick Edit
$(document).on("click", ".editinline", function () {
var $row = $(this).closest("tr");
var featuredImageId = $row.find(".featured_image img").data("id");
var $quickEditRow = $("#the-list").siblings("#inline-edit");
$quickEditRow.find(".featured_image_id").val(featuredImageId);
$quickEditRow.find(".featured-image-preview").html($row.find(".featured_image img").clone());
});
});
');
}
});
before-after-slider
remove-woocommerce-checkout-fields-2025
/**
* Customize WooCommerce checkout fields based on product types in the cart.
*/
add_filter('woocommerce_checkout_fields', 'intelligent_customize_checkout_fields');
function intelligent_customize_checkout_fields($fields) {
// Fields to remove for Non-Virtual and Non-Downloadable products
$non_virtual_remove = [
'billing' => ['billing_company', 'billing_phone'],
'shipping' => ['shipping_company'],
'order' => ['order_comments']
];
// Fields to remove for Virtual products
$virtual_remove = [
'billing' => [
'billing_company', 'billing_address_1', 'billing_address_2',
'billing_postcode', 'billing_country', 'billing_state', 'billing_city'
],
'shipping' => [
'shipping_company', 'shipping_address_1', 'shipping_address_2',
'shipping_postcode', 'shipping_country', 'shipping_state', 'shipping_city', 'shipping_first_name', 'shipping_last_name'
],
'order' => ['order_comments']
];
// Fields to remove for Downloadable products
$downloadable_remove = [
'billing' => [
'billing_company', 'billing_address_1', 'billing_address_2',
'billing_postcode', 'billing_country', 'billing_state', 'billing_city', 'billing_phone'
],
'shipping' => [
'shipping_company', 'shipping_address_1', 'shipping_address_2',
'shipping_postcode', 'shipping_country', 'shipping_state', 'shipping_city', 'shipping_first_name', 'shipping_last_name'
],
'order' => ['order_comments']
];
// Determine the product types in the cart
$has_virtual = false;
$has_downloadable = false;
$has_non_virtual = false;
foreach (WC()->cart->get_cart() as $cart_item) {
$product = $cart_item['data'];
if ($product->is_virtual()) {
$has_virtual = true;
}
if ($product->is_downloadable()) {
$has_downloadable = true;
}
if (!$product->is_virtual() && !$product->is_downloadable()) {
$has_non_virtual = true;
}
}
// Apply field removal logic based on cart contents
if ($has_non_virtual) {
foreach ($non_virtual_remove as $section => $fields_to_remove) {
foreach ($fields_to_remove as $field) {
unset($fields[$section][$field]);
}
}
}
if ($has_virtual) {
foreach ($virtual_remove as $section => $fields_to_remove) {
foreach ($fields_to_remove as $field) {
unset($fields[$section][$field]);
}
}
}
if ($has_downloadable) {
foreach ($downloadable_remove as $section => $fields_to_remove) {
foreach ($fields_to_remove as $field) {
unset($fields[$section][$field]);
}
}
}
// Disable order notes field for virtual or downloadable products
if ($has_virtual || $has_downloadable) {
add_filter('woocommerce_enable_order_notes_field', '__return_false');
}
return $fields;
}
// Remove shipping and additional fields sections for Virtual or Downloadable products
add_action('woocommerce_before_checkout_form', 'hide_unnecessary_sections', 10);
function hide_unnecessary_sections() {
$has_virtual = false;
$has_downloadable = false;
// Check cart contents for product types
foreach (WC()->cart->get_cart() as $cart_item) {
$product = $cart_item['data'];
if ($product->is_virtual()) {
$has_virtual = true;
}
if ($product->is_downloadable()) {
$has_downloadable = true;
}
}
// Conditionally hide sections
if ($has_virtual || $has_downloadable) {
?>
mega-menu-page-slug
inverted-border-radius-css
/* Ensure consistent rendering of elements */
*, *::before, *::after {
box-sizing: border-box;
}
.c13, .c13::before,
.c23, .c23::before,
.c33, .c33::before,
.c43, .c43::before,
.c53, .c53::before,
.c63, .c63::before {
backface-visibility: hidden;
transform: translateZ(0) translate(0, 0); /* Ensures pixel snapping */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
will-change: transform, clip-path;
}
.c13, .c23, .c33, .c43, .c53, .c63 {
clip-path: inset(0); /* Restricts content within the boundaries */
will-change: transform, clip-path;
}
.c13::before {
content: '';
position: absolute;
background-color: transparent; /* Ensures only shadows are visible */
border-radius: 100px 0px 0px 100px;
box-shadow:
0px 0px 0px 50px #FFF, /* Slight negative offset for top shadow to remove 1px gap */
0px 0px 0px 0px #FFF; /* No bottom shadow */
pointer-events: none;
clip-path: inset(0); /* Keeps everything confined */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.c23::before {
content: '';
position: absolute;
background-color: transparent; /* Ensures only shadows are visible */
border-radius: 0px 100px 0px 0px;
box-shadow:
0px 0px 0px 50px #FFF, /* Slight negative offset for top shadow to remove 1px gap */
0px 0px 0px 0px #FFF; /* No bottom shadow */
pointer-events: none;
clip-path: inset(0); /* Keeps everything confined */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.c33 {
background-color: #FFF;
border-radius: 0 0 0 50px;
will-change: transform, clip-path;
}
.c43 {
background-color: #FFF;
border-radius: 0 50px 0 0;
will-change: transform, clip-path;
}
.c53::before {
content: '';
position: absolute;
background-color: transparent; /* Ensures only shadows are visible */
border-radius: 0px 0px 0px 100px;
box-shadow:
0px 0px 0px 50px #FFF, /* Slight negative offset for top shadow to remove 1px gap */
0px 0px 0px 0px #FFF; /* No bottom shadow */
pointer-events: none;
clip-path: inset(0); /* Keeps everything confined */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.c63::before {
content: '';
position: absolute;
background-color: transparent; /* Ensures only shadows are visible */
border-radius: 0 100px 100px 0;
box-shadow:
0px 0px 0px 50px #FFF, /* Slight negative offset for top shadow to remove 1px gap */
0px 0px 0px 0px #FFF; /* No bottom shadow */
pointer-events: none;
clip-path: inset(0); /* Keeps everything confined */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
image-mask-css
/* Ensure consistent rendering of elements */
*, *::before, *::after {
box-sizing: border-box;
}
.c1 {
background-color: #FFF;
border-radius: 0 0 100px 0;
will-change: transform, clip-path;
}
.c4 {
background-color: #FFF;
border-radius: 100px 0 0 0;
will-change: transform, clip-path;
}
.c1, .c1::before,
.c2, .c2::before,
.c3, .c3::before,
.c4, .c4::before {
backface-visibility: hidden;
transform: translateZ(0) translate(0, 0); /* Ensures pixel snapping */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.c1, .c2, .c3, .c4 {
clip-path: inset(0); /* Restricts content within the boundaries */
will-change: transform, clip-path;
}
.c2::before {
content: '';
position: absolute;
background-color: transparent; /* Ensures only shadows are visible */
border-radius: 50px 50px 50px 0px;
box-shadow:
0px 0px 0px 50px #FFF, /* Slight negative offset for top shadow to remove 1px gap */
0px 0px 0px 0px #FFF; /* No bottom shadow */
pointer-events: none;
clip-path: inset(0); /* Keeps everything confined */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.c3::before {
content: '';
position: absolute;
background-color: transparent; /* Ensures only shadows are visible */
border-radius: 50px 0px 50px 50px;
box-shadow:
0px 0px 0px 50px #FFF, /* Slight negative offset for top shadow */
0px 0px 0px 0px #FFF; /* No bottom shadow */
pointer-events: none;
clip-path: inset(0); /* Keeps everything confined */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
toggle-3-items-inside-alternate
Free
Plus
Pro
image-mask-css-2
/* Ensure consistent rendering of elements */
*, *::before, *::after {
box-sizing: border-box;
}
.c12 {
background-color: #FFF;
border-radius: 0 0 50px 0;
will-change: transform, clip-path;
}
.c12, .c12::before,
.c22, .c22::before,
.c32, .c32::before,
.c42, .c42::before {
backface-visibility: hidden;
transform: translateZ(0) translate(0, 0); /* Ensures pixel snapping */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.c12, .c22, .c32, .c42 {
clip-path: inset(0); /* Restricts content within the boundaries */
will-change: transform, clip-path;
}
.c22::before {
content: '';
position: absolute;
background-color: transparent; /* Ensures only shadows are visible */
border-radius: 100px 100px 0px 0px;
box-shadow:
0px 0px 0px 50px #FFF, /* Slight negative offset for top shadow to remove 1px gap */
0px 0px 0px 0px #FFF; /* No bottom shadow */
pointer-events: none;
clip-path: inset(0); /* Keeps everything confined */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.c32::before {
content: '';
position: absolute;
background-color: transparent; /* Ensures only shadows are visible */
border-radius: 100px 0px 0px 100px;
box-shadow:
0px 0px 0px 50px #FFF, /* Slight negative offset for top shadow */
0px 0px 0px 0px #FFF; /* No bottom shadow */
pointer-events: none;
z-index: 1;
clip-path: inset(0); /* Keeps everything confined */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.c42::before {
content: '';
position: absolute;
background-color: transparent; /* Ensures only shadows are visible */
border-radius: 0px 0px 100px 0px;
box-shadow:
0px 0px 0px 50px #FFF, /* Slight negative offset for top shadow */
0px 0px 0px 0px #FFF; /* No bottom shadow */
pointer-events: none;
clip-path: inset(0); /* Keeps everything confined */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
vertical-carousel
toggle-3-items-inside
Free
Plus
Pro
toggle-3-items-above-alternate
Free
Plus
Pro
elementor-history-top-bar
// Add custom SVG icon to simulate CMD/CTRL + Shift + H on click
function add_custom_svg_icon_with_dual_key_simulation() {
?>
toggle-2-items-above
Monthly
Annually
toggle-3-items-above
Monthly
Quarterly
Annually
delete-unused-images aka 'Media Scanner v3.2'
read-more-single-post
Read More >
lms-course
auto-adjust-coupon
// Function to apply a dynamic discount based on the days left until 11th November, only for a specific product and coupon code
function apply_dynamic_discount_with_coupon( $cart ) {
// Set the start and end dates
$start_date = strtotime('2024-10-09');
$end_date = strtotime('2024-11-11');
$current_date = time();
// Get the applied coupons in the cart
$applied_coupons = $cart->get_applied_coupons();
// Check if the 'pepsimax' coupon is applied
if ( in_array( 'pepsimax', $applied_coupons ) ) {
// Check if the current date is between the start and end date
if ( $current_date >= $start_date && $current_date <= $end_date ) {
// Calculate the number of days left
$days_left = ceil(($end_date - $current_date) / (60 * 60 * 24)); // Convert seconds to days
// Calculate the discount percentage based on days left
$discount_percentage = 1 - ($days_left / 100); // Calculate the percentage to apply
// Loop through each cart item
foreach ( $cart->get_cart() as $cart_item_key => $cart_item ) {
// Check if the product ID is 5248
if ( $cart_item['product_id'] == 5248 ) {
// Get the sale price if available, otherwise use the regular price
$original_price = $cart_item['data']->get_sale_price() ? $cart_item['data']->get_sale_price() : $cart_item['data']->get_regular_price();
// Calculate the discounted price
$discounted_price = round($original_price * $discount_percentage, 1); // Round to 1 decimal place
// Set the new discounted price
$cart_item['data']->set_price( $discounted_price );
}
}
}
}
}
// Ensure the cart totals are updated after calculating the discount
add_action( 'woocommerce_before_calculate_totals', 'apply_dynamic_discount_with_coupon', 10, 1 );
sliding-child-container-reveal
front-end-forms-custom-elementor
off-canvas-animated-toggle-one-line
form-to-custom-fields
add_action( 'elementor_pro/forms/new_record', function( $record, $handler ) {
// Configuration Variables (Everything configurable is defined here)
$form_name = 'review_form'; // Form name as used in Elementor
$post_type = 'review'; // Post type where the form data will be saved
// Define your field mappings: Elementor form field ID => ACF custom field name
$field_mappings = array(
'r_name' => 'review_name', // Form field 'r_name' => ACF field 'review_name'
'r_review' => 'review_review', // Form field 'r_review' => ACF field 'review_review'
'r_image' => 'review_image', // Form field 'r_image' => ACF field 'review_image' (Image field)
);
// Specify which field from the mappings should be used as post title and content
$post_title_field = 'r_name'; // This form field will be used for the post title
$post_content_field = 'r_review'; // This form field will be used for the post content
// END OF CONFIGURABLE SECTION
// Check that it's the correct form
$submitted_form_name = $record->get_form_settings( 'form_name' );
if ( $submitted_form_name !== $form_name ) {
return; // If it's not the correct form, do nothing
}
// Get submitted form data
$raw_fields = $record->get( 'fields' );
$uploaded_files = $record->get( 'files' ); // Handle file uploads
// Prepare post title and content based on the field mappings
$post_title = isset($raw_fields[$post_title_field]['value']) ? wp_strip_all_tags($raw_fields[$post_title_field]['value']) : 'Untitled';
$post_content = isset($raw_fields[$post_content_field]['value']) ? $raw_fields[$post_content_field]['value'] : '';
// Insert a new post into the specified post type
$new_post = array(
'post_title' => $post_title, // Use mapped field for the post title
'post_content' => $post_content, // Use mapped field for the post content
'post_status' => 'publish',
'post_type' => $post_type, // Use configurable post type
);
$post_id = wp_insert_post( $new_post ); // Insert the post and get the post ID
// Log post creation for debugging
error_log( 'Post created with ID: ' . $post_id );
// Handle all fields including the image
if ( function_exists( 'update_field' ) ) {
foreach ( $field_mappings as $form_field => $acf_field ) {
// If it's a file (image) field, handle the upload
if ( isset($uploaded_files[$form_field]['path'][0]) && !empty($uploaded_files[$form_field]['path'][0]) ) {
// Get the file path and create an array for media upload
$file_path = $uploaded_files[$form_field]['path'][0];
$file_name = basename( $file_path );
$file_array = array(
'name' => $file_name,
'tmp_name' => $file_path,
);
// Upload the image into the WordPress media library
$attachment_id = media_handle_sideload( $file_array, $post_id );
// Check for errors during upload
if ( is_wp_error( $attachment_id ) ) {
error_log( 'Image upload error: ' . $attachment_id->get_error_message() );
} else {
// Attach the uploaded image to the custom field
update_field( $acf_field, $attachment_id, $post_id );
error_log( 'Image uploaded successfully with ID: ' . $attachment_id );
}
}
// If it's a text or non-file field, just update it as usual
elseif ( isset($raw_fields[$form_field]['value']) && !empty($raw_fields[$form_field]['value']) ) {
update_field( $acf_field, $raw_fields[$form_field]['value'], $post_id ); // Update each ACF field
}
}
}
}, 10, 2 );
off-canvas-animated-toggle-middle-bar
animated-nav-to-middle-slide
elementor-top-bar-pixel-width
// Description: Displays the responsive width of the preview in the Elementor editor
// Author: Carlos Béjinha
// Author URI: https://binformatica.pt
// ------------------------------------
// Info Width In Elementor Editor
function add_custom_script_to_elementor() {
?>
Multiple-Reveal-Select-Taxonomy-Filter
multiple-source-loop-grid
add_action( 'elementor/query/multiple_source', function( $query ) {
$query->set( 'post_type', ['post', 'team'] );
});
Hide-Child-Taxonomy-Until-Parent-Clicked
Elementor-Dynamic-Pop-Up-Loop
Elementor-Loop-Current-Query-Sort
add_action( 'elementor/query/customorder', function( $query ) {
$query->set( 'orderby', 'date' );
// $query->set( 'orderby', 'title' );
// $query->set( 'orderby', 'menu_order' );
$query->set( 'order', 'ASC' );
});
text-colour-palette
function my_custom_colors($init) {
// Define the custom colors: color code, description (as displayed in TinyMCE)
$custom_colors = '
"1C1C1B", "Black",
"4D4D4D", "Gray",
"F96966", "Red",
"2081A4", "Blue"
';
// Add the colors to the textcolor_map setting of TinyMCE
$init['textcolor_map'] = '[' . $custom_colors . ']';
// Set the number of rows in the TinyMCE color picker
$init['textcolor_rows'] = 2;
return $init;
}
add_filter('tiny_mce_before_init', 'my_custom_colors');
Just-Child-Taxonomy-Elementor
Email-Verfication
animated-nav-to-middle-line
animated-nav-to-cross
Form-PayPal-Many-Select
Form-PayPal
Calculated-Checkbox-PayPal
pop-up-day
off-canvas-animated-toggle-cross
Calculated-Dropdown
Calculated-Many-Selects
Calculated-Checkbox
Calculated-Basic
Colour-Transition
Password-Protect-Page-Style
function customize_password_protected_page() {
// Add Custom CSS
echo '';
// Add Custom JavaScript for Message
echo '';
}
add_action('wp_head', 'customize_password_protected_page');
// Add the Title Header and Additional Text with Link
function add_custom_password_title($content) {
if (post_password_required()) {
$title = 'Login to Access
';
$additional_info = 'If you do not have a password then go here: learn.websquadron.co.uk';
$content = $title . '' . $content . '' . $additional_info . '';
}
return $content;
}
add_filter('the_content', 'add_custom_password_title');
Stop-FOUC
add_action( 'wp_enqueue_scripts', function() {
if ( ! class_exists( '\Elementor\Core\Files\CSS\Post' ) ) {
return;
}
$template_id = 4040;
$css_file = new \Elementor\Core\Files\CSS\Post( $template_id );
$css_file->enqueue();
}, 500 );
Text-Background
/* Add this HTML firsy */
I am coloured text in a line.
/*Add this CSS */
.highlighted-text {
position: relative;
display: inline-block;
}
.highlighted-text::before {
content: '';
position: absolute;
top: 45%;
left: 0%;
right: 0%;
height: 60%;
background-color: #fac000;
transform: rotate(-1.5deg);
z-index: -1;
border-radius: 100px;
}
Highlight-Text
I am coloured text in a line.
Reduce-Cart-based-on-Items
add_action('woocommerce_before_calculate_totals', 'apply_discount_based_on_item_count', 10, 1);
function apply_discount_based_on_item_count($cart) {
// Only run this in the frontend and make sure we're not in the admin or doing ajax
if (is_admin() && !defined('DOING_AJAX')) return;
// Check if the action has already been fired to prevent multiple discount applications
if (did_action('woocommerce_before_calculate_totals') >= 2) return;
// Count the number of items in the cart
$item_count = $cart->get_cart_contents_count();
// Apply a $100 discount if there are 3 or more items
if ($item_count >= 3) {
$discount = 100;
// Add a negative fee to the cart to apply the discount
$cart->add_fee('Bulk Discount', -$discount, true);
}
}
Restrict-Course-Pages
function restrict_page_access() {
// Configuration
$access_rules = [
'course-1' => [
'product_ids' => [183],
'redirect' => 'https://websquadron.s3-tastewp.com/shop',
],
'course-2' => [
'product_ids' => [183, 186],
'redirect' => 'https://websquadron.s3-tastewp.com/contact',
],
'course-3' => [
'product_ids' => [190, 191],
'redirect' => 'https://websquadron.s3-tastewp.com/home',
],
];
// Get current user ID and check if the user is an administrator
$user_id = get_current_user_id();
$is_admin = current_user_can('administrator');
// If user is an administrator, skip restriction checks
if ($is_admin) {
return;
}
// Get the current page
$current_page = get_queried_object();
// Ensure $current_page is a WP_Post object
if (!($current_page instanceof WP_Post)) {
return;
}
// Iterate through access rules and apply restrictions
foreach ($access_rules as $slug => $rule) {
if ($current_page->post_name === $slug) {
// Check if user has purchased any of the required products
$has_purchased = false;
foreach ($rule['product_ids'] as $product_id) {
if (wc_customer_bought_product($user_id, $user_id, $product_id)) {
$has_purchased = true;
break;
}
}
// Redirect if the user hasn't purchased the required products
if (!$has_purchased) {
wp_redirect($rule['redirect']);
exit;
}
}
}
}
add_action('template_redirect', 'restrict_page_access');
Add-to-Cart-JS-Variation
Show-Page-Title-WordPress-Menu
function custom_page_title_shortcode() {
return get_the_title();
}
add_shortcode('current_page_title', 'custom_page_title_shortcode');
function execute_shortcodes_in_menus($menu_item) {
if (strpos($menu_item->title, '[') !== false && strpos($menu_item->title, ']') !== false) {
$menu_item->title = do_shortcode($menu_item->title);
}
return $menu_item;
}
add_filter('wp_nav_menu_objects', 'execute_shortcodes_in_menus');
css-radio-variation
/* Hide the select dropdowns for product variations */
.woocommerce div.product form.cart .variations select {
display: none;
}
selector label {
display: flex;
align-items: center;
margin-bottom: 5px; /* Adjust spacing between each option */
text-transform: capitalize; /* Converts text to uppercase */
}
selector input[type=radio] {
appearance: none;
margin-right: 10px; /* Space between circle and label text */
width: 20px; height: 20px;
border-radius: 50%; /* circle */
border: 2px solid #ccc;
outline: none;
align-self: center; /* Aligns the radio button vertically */
}
selector input[type=radio]:checked {
border-color: #FF0050;
background-color: #FF0050;
}
/* Background color adjustments for add-to-cart and variations */
selector .elementor-product-variable,
.woocommerce div.product form.cart .variations th,
.woocommerce div.product form.cart .variations td {
background-color: #ffffff; /* Set background to white */
}
/* Adjusting label margin in specific Elementor & WooCommerce contexts */
selector form.cart table.variations label {
margin-bottom: -20px; /* Adjust based on your layout needs */
}
CSS-Inline-Radio-Variation
/* Hide the select dropdowns for product variations */
.woocommerce div.product form.cart .variations select {
display: none;
}
/* Container for radio buttons and labels */
.variation-changes-container {
display: flex;
flex-wrap: wrap; /* Allows items to wrap to next line as needed */
gap: 15px; /* Space between items */
}
/* Attribute Title alignemnt*/
.woocommerce div.product form.cart .variations th {
text-align: left;
align-items: center;
}
/* Style for labels */
.variation-changes-container label {
display: flex;
align-items: center;
margin-bottom: 0px; /* Adjust spacing between each option, if necessary */
text-transform: capitalize; /* Converts text to uppercase */
}
/* Style for radio buttons */
.variation-changes-container input[type=radio] {
appearance: none;
margin-right: 7px; /* Space between circle and label text */
width: 20px; height: 20px;
border-radius: 50%; /* Circle */
border: 2px solid #ccc;
outline: none;
}
/* Style for checked radio buttons */
.variation-changes-container input[type=radio]:checked {
border-color: #FF0050;
background-color: #FF0050;
}
/* Background color adjustments for add-to-cart and variations */
.variation-changes-container .elementor-product-variable,
.woocommerce div.product form.cart .variations th,
.woocommerce div.product form.cart .variations td {
background-color: #ffffff; /* Set background to white */
}
Add-Product-on-Cart-Page
function cart_add() {
$product_id = 380; // Set the product ID you want to add to the cart
$add_to_cart_url = wc_get_cart_url() . '?add-to-cart=' . $product_id; // Construct the add-to-cart URL
echo '';
// Change the href attribute to the $add_to_cart_url
echo '';
}
add_action('woocommerce_after_cart_totals', 'cart_add', 10, 0);
Off-Canvas-Widget-Anchors
Colour-Circle-Radio-Variation
/* Hide the select dropdowns for product variations */
.woocommerce div.product form.cart .variations select {
display: none;
}
/* Container for radio buttons and labels */
.variation-changes-container {
display: flex;
flex-wrap: wrap; /* Allows items to wrap to next line as needed */
gap: 15px; /* Space between items */
}
/* Attribute Title alignment */
.woocommerce div.product form.cart .variations th {
text-align: left;
align-items: center;
}
/* Style for labels, indicating option colors */
.variation-changes-container label {
display: flex;
align-items: center;
margin-bottom: 0px; /* Adjust spacing between each option, if necessary */
text-transform: capitalize; /* Converts text to uppercase */
cursor: pointer;
}
/* Style for radio buttons */
.variation-changes-container input[type=radio] {
appearance: none;
margin-right: 7px; /* Space between circle and label text */
width: 20px; height: 20px;
border-radius: 50%; /* Circle */
border: 2px solid #CCC; /* Light grey border by default */
outline: none;
background-color: #FFF; /* Default background for unspecified options */
}
/* Style for checked radio buttons */
.variation-changes-container input[type=radio]:checked {
border-color: #000; /* Border color when selected */
background-color: #000;
}
/* Applying specific background colors for checked states */
.variation-changes-container label.red input[type=radio] {
background-color: #FF0050; /* Red background color when selected */
border: 0px solid #FF0050;
}
.variation-changes-container label.red input[type=radio]:checked {
background-color: #FF0050; /* Red background color when selected */
border: 4px solid #000;
}
.variation-changes-container label.blue input[type=radio] {
background-color: #0000FF; /* Red background color when selected */
border: 0px solid #0000FF;
}
.variation-changes-container label.blue input[type=radio]:checked {
background-color: #0000FF; /* Blue background color when selected */
border: 4px solid #000;
}
/* Background color adjustments for add-to-cart and variations */
.variation-changes-container .elementor-product-variable,
.woocommerce div.product form.cart .variations th,
.woocommerce div.product form.cart .variations td {
background-color: #ffffff; /* Set background to white */
}
Woocommerce-Single-Product-Variation-Radio
add_filter('woocommerce_dropdown_variation_attribute_options_html', 'variation_changes', 20, 2);
function variation_changes($html, $args) {
if (empty($args['options']) || !$args['product']) {
return $html; // Return original HTML if no options or product is provided
}
$name = !empty($args['name']) ? $args['name'] : 'attribute_' . sanitize_title($args['attribute']);
// Start the radio button markup
$radios = '';
// Loop through each option
foreach ($args['options'] as $option) {
// Generate a class name based on the option for specific styling
$class = sanitize_title($option); // Creates a valid HTML class from the option value
// Determine if the option is selected
$checked = checked($args['product']->get_variation_default_attribute($args['attribute']), $option, false);
// Create the radio button with a class for the label based on the option
$radios .= sprintf('
',
esc_attr($class),
esc_attr($name),
esc_attr($option),
$checked,
esc_html(apply_filters('woocommerce_variation_option_name', $option))
);
}
$radios .= ''; // End the radio button markup
return $html . $radios;
}
search-full-screen
Dropdown Button Links
Calculated-Many-Selects-PayPal
apple-dock
text-reveal-swap
text-rotate
Get noticed fast
Win more leads
Sell with ease
Build real trust
Grow every day
proportion-image-grow
animated-border-css
.box {
border: 10px solid transparent;
border-radius: 15px;
background:
linear-gradient(#fff, #fff) padding-box,
conic-gradient(
from var(--angle),
transparent 70%,
#ffa500 80%,
#ff4500 90%,
#ff0050 100%
) border-box;
animation: rotate 12s linear infinite;
/*animation-delay: 1s;*/
}
@keyframes rotate {
to { --angle: 360deg; }
}
@property --angle {
syntax: "";
initial-value: 0deg;
inherits: false;
}
lightbox-link
add_action('wp_footer', function(){ ?>
author-dynamic-acf
function ws_get_author_term_id_for_post($post_id = null) {
$post_id = $post_id ?: get_the_ID();
if (!$post_id) return 0;
// Add the field used for selecting the taxonomy
$val = get_field('author_details', $post_id);
if (is_numeric($val)) return (int) $val;
// Soft fallbacks if Return Value wasn't set to ID
if (is_object($val) && !empty($val->term_id)) return (int) $val->term_id;
if (is_array($val) && isset($val['term_id'])) return (int) $val['term_id'];
// Last resort: first assigned term in the taxonomy on this post
$terms = wp_get_post_terms($post_id, 'author_taxonomy');
if (!is_wp_error($terms) && !empty($terms[0]->term_id)) return (int) $terms[0]->term_id;
return 0;
}
/** [author_term_name] — the taxonomy title. */
add_shortcode('author_term_name', function () {
$term_id = ws_get_author_term_id_for_post();
if (!$term_id) return '';
$term = get_term($term_id, 'author_taxonomy');
return ($term && !is_wp_error($term)) ? esc_html($term->name) : '';
});
/** [author_title] — ACF term field "author_title". */
add_shortcode('author_title', function () {
$term_id = ws_get_author_term_id_for_post();
if (!$term_id) return '';
$title = get_field('author_title', 'term_' . $term_id);
return $title ? esc_html($title) : '';
});
/** [author_bio] — ACF term field "author_bio" (plain text). */
add_shortcode('author_bio', function () {
$term_id = ws_get_author_term_id_for_post();
if (!$term_id) return '';
$bio = get_field('author_bio', 'term_' . $term_id);
return $bio ? esc_html($bio) : '';
});
/** [author_bio2] — ACF term field "author_bio2" (WYSIWYG → allow HTML). */
add_shortcode('author_bio2', function () {
$term_id = ws_get_author_term_id_for_post();
if (!$term_id) return '';
$bio2 = get_field('author_bio2', 'term_' . $term_id);
if (!$bio2) return '';
// Keep author-entered formatting; sanitize through wp_kses_post
return wp_kses_post($bio2);
});
/** [author_link] — ACF term field "author_link" (prints the URL). */
add_shortcode('author_link', function () {
$term_id = ws_get_author_term_id_for_post();
if (!$term_id) return '';
$url = get_field('author_link', 'term_' . $term_id);
return $url ? esc_url($url) : '';
});
/** [author_image] — ACF term field "author_image" (prints an
). */
add_shortcode('author_image', function () {
$term_id = ws_get_author_term_id_for_post();
if (!$term_id) return '';
$img = get_field('author_image', 'term_' . $term_id); // image array expected
if (!empty($img['ID'])) {
$term = get_term($term_id, 'author_taxonomy');
$alt = get_field('author_title', 'term_' . $term_id) ?: ($term && !is_wp_error($term) ? $term->name : '');
return wp_get_attachment_image((int) $img['ID'], 'medium', false, ['alt' => esc_attr($alt)]);
}
return '';
});
aeo-ai-visibility-booster
/**
* AEO AI Visibility Booster - from Imran Siddiq - https://learn.websquadron.co.uk
*/
if ( ! defined('ABSPATH') ) exit;
class AIV_Clarity_Ultra {
const OPTION = 'aiv_ultra_settings';
const NONCE = 'aiv_ultra_nonce';
public function __construct() {
// 1) Disable WordPress core sitemaps entirely (/wp-sitemap.xml and friends)
add_filter('wp_sitemaps_enabled', '__return_false');
// 2) Kill canonical redirects for our virtual endpoints so WP (or plugins)
// won’t bounce /sitemap.xml or /llms.txt anywhere else.
add_filter('redirect_canonical', [$this, 'bypass_canonical_for_virtual'], 0, 2);
// (Extra belt & braces) If the core redirect helper is present, remove it.
add_action('init', function () {
if (function_exists('wp_sitemaps_redirect')) {
remove_action('template_redirect', 'wp_sitemaps_redirect');
}
}, 9);
add_action('admin_menu', [$this, 'menu']);
add_action('admin_init', [$this, 'maybe_save']);
// 3) Serve virtual files at the earliest possible moment on template_redirect.
add_action('template_redirect', [$this, 'serve_virtual_files'], 0);
add_filter('robots_txt', [$this, 'extend_robots_txt'], 99, 2);
add_action('wp_head', [$this, 'maybe_output_faq_schema'], 1);
add_action('wp_head', [$this, 'maybe_output_org_schema'], 2);
}
/* ---------------- Defaults & Settings ---------------- */
private function defaults() {
return [
// Business basics
'business_name' => '',
'phone' => '',
'logo_url' => '',
'locality' => '',
'country' => '',
'area_served' => 'Global',
'entity_type' => 'Organization', // or 'LocalBusiness'
// Key page paths (used in llms.txt) — “Updates” renamed to “Blog”
'path_services' => '/services',
'path_pricing' => '/pricing',
'path_faq' => '/faq',
'path_contact' => '/contact',
'path_blog' => '/blog', // rename from updates → blog
// Per-path descriptions (appear in llms.txt)
'desc_services' => 'Our main services.',
'desc_pricing' => 'Pricing & packages.',
'desc_faq' => 'Common questions & answers.',
'desc_contact' => 'How to reach us.',
'desc_blog' => 'Recent updates & wins.',
// Extra LLMS lines (path or full URL + 2+ spaces + description)
'extra_llms' => "",
// Sitemaps
'post_types' => [], // post types to include if we serve a sitemap
'sitemap_max_items' => 'all', // per type: number or "all"
'extra_urls' => '', // one per line (absolute or relative)
'exclude_urls' => '', // one per line (absolute or relative; supports trailing * for prefix)
'existing_sitemap' => '', // URL from SEO plugin (Yoast/RankMath/etc.)
// Virtual serving toggles
'serve_llms' => '1', // /llms.txt
'serve_sitemap' => '1', // /sitemap.xml
'extend_robots' => '1', // append guidance to virtual robots
// FAQ – Manual Q&A
'faq_text' => "Q: Do you offer free quotes?\nA: Yes, we reply within 24 hours.\n\nQ: Do you work evenings/weekends?\nA: We can arrange this by request.\n",
'faq_page_ids' => '', // inject manual JSON-LD on these page IDs
// FAQ – Auto from page content
'faq_auto_enable' => '0', // read on-page FAQ and build schema
'faq_mode' => 'preset_elementor', // elementor, gutenberg, simple, custom
'faq_container_class'=> 'aiv-faq', // class on the FAQ section (no dot)
'faq_q_selector' => 'h3', // for simple/custom
'faq_a_selector' => 'next', // 'next' = next paragraph after the question (for simple/custom)
'faq_auto_pages_ids' => '', // limit auto injection (blank = any page containing the class)
];
}
private function get_settings() {
$saved = get_option(self::OPTION, []);
$defs = $this->defaults();
// Back-compat: if an older option used path_updates, map it to blog
if (!empty($saved['path_updates']) && empty($saved['path_blog'])) {
$saved['path_blog'] = $saved['path_updates'];
}
if (!isset($saved['post_types']) || !is_array($saved['post_types'])) $saved['post_types'] = [];
return wp_parse_args($saved, $defs);
}
private function sanitize($in) {
$out = [];
$txt = [
// basics
'business_name','phone','logo_url','locality','country','area_served','entity_type',
// key paths
'path_services','path_pricing','path_faq','path_contact','path_blog',
// per-path descriptions
'desc_services','desc_pricing','desc_faq','desc_contact','desc_blog',
// extras
'extra_llms','extra_urls','exclude_urls','existing_sitemap','faq_text','faq_page_ids',
// faq auto
'faq_container_class','faq_q_selector','faq_a_selector','faq_auto_pages_ids',
'sitemap_max_items','faq_mode'
];
foreach ($txt as $k) {
if (!isset($in[$k])) { $out[$k] = ''; continue; }
if (in_array($k, ['extra_urls','exclude_urls','faq_text','extra_llms'], true)) {
$out[$k] = trim(str_replace("\r", '', $in[$k]));
} elseif (in_array($k, ['logo_url', 'existing_sitemap'], true)) {
$out[$k] = esc_url_raw($in[$k]);
} else {
$out[$k] = sanitize_text_field($in[$k]);
}
}
$allowed_types = ['Organization','LocalBusiness'];
$out['entity_type'] = in_array(($in['entity_type'] ?? 'Organization'), $allowed_types, true)
? $in['entity_type']
: 'Organization';
$out['post_types'] = isset($in['post_types']) && is_array($in['post_types'])
? array_values(array_unique(array_map('sanitize_key',$in['post_types']))) : [];
foreach (['serve_llms','serve_sitemap','extend_robots','faq_auto_enable'] as $k) {
$out[$k] = !empty($in[$k]) ? '1' : '0';
}
$out['faq_container_class'] = ltrim($out['faq_container_class'], '. ');
return $out;
}
/* ---------------- Admin UI ---------------- */
public function menu() {
add_management_page(
'AI Visibility',
'AI Visibility',
'manage_options',
'aiv-ultra',
[$this, 'render']
);
}
private function seo_plugin_notes() {
$notes = [];
if (defined('WPSEO_VERSION')) $notes[] = 'Yoast SEO detected';
if (defined('RANK_MATH_VERSION')) $notes[] = 'RankMath detected';
if (defined('SLIM_SEO_VERSION')) $notes[] = 'Slim SEO detected';
return $notes;
}
public function maybe_save() {
if (!current_user_can('manage_options')) return;
if (empty($_POST[self::NONCE]) || !wp_verify_nonce($_POST[self::NONCE], self::NONCE)) return;
if (!isset($_POST['aiv_save'])) return;
update_option(self::OPTION, $this->sanitize($_POST));
add_action('admin_notices', function(){
echo 'AI Visibility: Settings saved.
';
});
}
public function render() {
if (!current_user_can('manage_options')) return;
$s = $this->get_settings();
$home = rtrim(site_url(), '/');
$robots = $this->generate_robots_txt($s, $home);
$llms = $this->generate_llms_txt($s, $home);
$__groups = $this->gather_urls_by_type($s, $home);
$sitemap = $this->generate_sitemap_index_xml_from_groups($__groups, $home);
$faq_prev = $this->generate_faq_jsonld_preview($s); // preview of MANUAL pairs
$all_pts = get_post_types(['public' => true], 'objects');
unset($all_pts['attachment']);
$physical_robots_exists = file_exists(ABSPATH.'robots.txt');
$seo_notes = $this->seo_plugin_notes();
// Inline CSS: white panel, blue headers, 40px section spacing, 1.3em line-height, accordion styling
?>
AEO AI-Visibility Booster
Quick test links:
robots.txt •
sitemap.xml •
llms.txt
$items) {
$slug = sanitize_key($type);
$links[] = ''
. esc_html($slug . '-sitemap.xml') . '';
}
if (!empty($links)) {
echo ' • ' . implode(' • ', $links);
}
}
?>
Heads-up: . We’ll explain what to do if your SEO plugin also creates a robots.txt or sitemap.
Decision Helper (what to pick):
- Sitemap: If your SEO plugin gives you a sitemap URL, paste it below and UNcheck “Serve /sitemap.xml”. If you don’t have one, keep it checked so we provide it.
- robots.txt: SEO plugins usually output virtual robots.txt and not a physical file in your site. If you leave “Extend robots.txt” checked, it will add AI tool lines and will ensure no duplicate lines occur.
- FAQ Schema: You can use Manual (paste Q&A here) and/or Auto (we read your on-page FAQ accordion). If both are present on the same page, they’ll combine. Try not to duplicate the same questions.
norm_path($s[$k]);
}
$extra = [];
if (!empty($s['extra_urls'])) {
foreach (array_filter(array_map('trim', explode("\n", $s['extra_urls']))) as $line) {
if (preg_match('#^https?://#i', $line)) $extra[] = $line;
else $extra[] = $home . $this->norm_path($line);
}
}
return array_values(array_unique(array_merge($paths, $extra)));
}
private function site_urls_for_sitemap($s, $home) {
$urls = [ trailingslashit($home) ];
$max = strtolower(trim($s['sitemap_max_items'])) === 'all' ? -1 : max(1, (int)$s['sitemap_max_items']);
if (!empty($s['post_types'])) {
foreach ($s['post_types'] as $pt) {
$args = [
'post_type' => $pt,
'post_status' => 'publish',
'posts_per_page' => ($max === -1 ? -1 : $max),
'orderby' => 'date',
'order' => 'DESC',
'fields' => 'ids'
];
$ids = get_posts($args);
foreach ($ids as $id) $urls[] = get_permalink($id);
}
}
// Add “important” and “extra” URLs
$urls = array_merge($urls, $this->important_urls($s, $home));
// De-dup + tidy
$urls = array_values(array_unique(array_filter(array_map(function($u){
return rtrim(trim($u));
}, $urls))));
// Compile exclude regexes and filter
$exclude_regexes = $this->compile_exclude_patterns($s, $home);
if (!empty($exclude_regexes)) {
$urls = array_values(array_filter($urls, function($u) use ($exclude_regexes) {
return !$this->should_exclude_url($u, $exclude_regexes);
}));
}
return $urls;
}
private function parse_pairs_block($text) {
$pairs = [];
$text = trim($text);
if ($text === '') return $pairs;
$blocks = preg_split("/\n{2,}/", $text);
foreach ($blocks as $b) {
$q = $a = '';
foreach (preg_split("/\n/", trim($b)) as $line) {
if (stripos($line,'Q:')===0) $q = trim(substr($line,2));
if (stripos($line,'A:')===0) $a = trim(substr($line,2));
}
if ($q && $a) $pairs[] = ['q'=>$q,'a'=>$a];
}
return $pairs;
}
private function xml_escape($s) {
return htmlspecialchars($s, ENT_XML1|ENT_QUOTES, 'UTF-8');
}
// === NEW: group URLs by post type (and extras) ===
private function gather_urls_by_type($s, $home) {
$out = [];
$home_url = trailingslashit($home);
$max = strtolower(trim($s['sitemap_max_items'])) === 'all' ? -1 : max(1, (int)$s['sitemap_max_items']);
foreach ((array) $s['post_types'] as $pt) {
$args = [
'post_type' => $pt,
'post_status' => 'publish',
'posts_per_page' => ($max === -1 ? -1 : $max),
'orderby' => 'date',
'order' => 'DESC',
'fields' => 'ids'
];
$ids = get_posts($args);
$items = [];
foreach ($ids as $id) {
$u = get_permalink($id);
if (!$u) continue;
$items[] = [
'loc' => $u,
'lastmod' => get_post_modified_time('c', true, $id) ?: current_time('c'),
];
}
// Include homepage under "page" (optional)
if ($pt === 'page') {
$items[] = ['loc' => $home_url, 'lastmod' => current_time('c')];
}
// Apply your existing exclude rules
$exclude_regexes = $this->compile_exclude_patterns($s, $home);
if (!empty($exclude_regexes)) {
$items = array_values(array_filter($items, function($row) use ($exclude_regexes) {
return !$this->should_exclude_url($row['loc'], $exclude_regexes);
}));
}
// De-dup
$seen = [];
$items = array_values(array_filter($items, function($row) use (&$seen){
$k = rtrim($row['loc'], '/');
if (isset($seen[$k])) return false;
$seen[$k] = true;
return true;
}));
if (!empty($items)) $out[$pt] = $items;
}
// Add “important/extra” URLs as their own bucket
$extras = array_map(function($u) {
return ['loc'=>$u, 'lastmod'=>current_time('c')];
}, $this->important_urls($s, $home));
if (!empty($extras)) {
$out['extra'] = isset($out['extra']) ? array_merge($out['extra'],$extras) : $extras;
}
return $out;
}
// === NEW: build the XML index that points to /-sitemap.xml
private function generate_sitemap_index_xml_from_groups(array $groups, $home) {
$xml = "\n";
$xml .= "\n";
foreach ($groups as $type => $items) {
$child = trailingslashit($home) . sanitize_key($type) . "-sitemap.xml";
$last = '1970-01-01T00:00:00+00:00';
foreach ($items as $row) {
if (!empty($row['lastmod']) && $row['lastmod'] > $last) $last = $row['lastmod'];
}
$xml .= " \n";
$xml .= " ".$this->xml_escape($child)." \n";
$xml .= " {$last} \n";
$xml .= " \n";
}
$xml .= " \n";
return $xml;
}
// === NEW: build a per-type URLset
private function generate_type_sitemap_xml($type, array $items) {
$xml = "\n";
$xml .= "\n";
foreach ($items as $row) {
$loc = $this->xml_escape($row['loc']);
$lm = $row['lastmod'] ?: current_time('c');
$xml .= " \n";
$xml .= " {$loc} \n";
$xml .= " {$lm} \n";
$xml .= " \n";
}
$xml .= " \n";
return $xml;
}
// === NEW: optional human-friendly text outputs
private function generate_sitemap_index_txt_from_groups(array $groups, $home) {
$lines = [];
foreach ($groups as $type => $items) {
$child = trailingslashit($home) . sanitize_key($type) . "-sitemap.xml";
$last = '1970-01-01T00:00:00+00:00';
foreach ($items as $row) if (!empty($row['lastmod']) && $row['lastmod'] > $last) $last = $row['lastmod'];
$lines[] = sprintf("%s\t%s\t%s", $type, $child, $last);
}
return implode("\n", $lines) . "\n";
}
private function generate_type_sitemap_txt($type, array $items) {
$lines = [];
foreach ($items as $row) {
$lines[] = sprintf("%s\t%s", $row['loc'], $row['lastmod'] ?: '');
}
return implode("\n", $lines) . "\n";
}
private function compile_exclude_patterns($s, $home) {
$patterns = [];
$src = trim((string)($s['exclude_urls'] ?? ''));
if ($src === '') return $patterns;
$lines = array_filter(array_map('trim', explode("\n", str_replace("\r", '', $src))));
foreach ($lines as $p) {
// Make absolute (normalize everything)
if (!preg_match('#^https?://#i', $p)) {
$p = $home . $this->norm_path($p);
} else {
$p = rtrim($p, '/');
}
$is_prefix = substr($p, -1) === '*';
if ($is_prefix) $p = rtrim(substr($p, 0, -1), '/');
$quot = preg_quote($p, '#');
if ($is_prefix) {
// Match the URL itself or anything under it
$patterns[] = "#^{$quot}(?:/.*)?$#i";
} else {
// Exact URL, allow optional trailing slash
$patterns[] = "#^{$quot}/?$#i";
}
}
return $patterns;
}
private function should_exclude_url($url, array $regexes) {
$u = rtrim(trim($url), '/');
foreach ($regexes as $rx) {
if (@preg_match($rx, $u) && preg_match($rx, $u)) return true;
}
return false;
}
public function generate_robots_txt($s, $home) {
// pick ONE sitemap URL by precedence:
// 1) Existing sitemap (from SEO plugin) if provided
// 2) Our virtual /sitemap.xml if enabled
// 3) Core WP sitemap as a safe fallback
if (!empty($s['existing_sitemap'])) {
$map = trim($s['existing_sitemap']);
} elseif ($s['serve_sitemap'] === '1') {
$map = trailingslashit($home) . 'sitemap.xml';
} else {
$map = trailingslashit($home) . 'wp-sitemap.xml';
}
return
"User-agent: GPTBot\nAllow: /\n\n" .
"User-agent: PerplexityBot\nAllow: /\n\n" .
"User-agent: CCBot\nAllow: /\n\n" .
"User-agent: AnthropicBot\nAllow: /\n\n" .
"User-agent: Google-Extended\nAllow: /\n\n" .
"User-agent: Applebot-Extended\nAllow: /\n\n" .
"Sitemap: {$map}\n";
}
public function generate_llms_txt($s, $home) {
$out = [];
// helper to add a path+desc line safely
$add = function($path, $desc) use (&$out) {
$path = rtrim(trim($path));
$desc = trim((string)$desc);
if ($path === '') return;
// leave headings alone (shouldn't get here, but guard anyway)
if (preg_match('/^\s*#{1,6}\s+/', $path)) {
$out[] = ltrim($path);
return;
}
// if not absolute URL and not starting with '/', prefix it
if ($path[0] !== '/' && !preg_match('#^https?://#i', $path)) {
$path = '/'.$path;
}
$out[] = rtrim($path . ($desc !== '' ? " {$desc}" : ''));
};
// keep the 5 key paths at the top (if provided)
$add($s['path_services'], $s['desc_services']);
$add($s['path_pricing'], $s['desc_pricing']);
$add($s['path_faq'], $s['desc_faq']);
$add($s['path_contact'], $s['desc_contact']);
$add($s['path_blog'], $s['desc_blog']);
// Now process the free-form "extra_llms" block
if (!empty($s['extra_llms'])) {
$raw = str_replace("\r", '', (string)$s['extra_llms']);
$lines = explode("\n", $raw); // DO NOT trim/filter — preserves blank lines
foreach ($lines as $line) {
// preserve completely blank lines
if ($line === '') { $out[] = ''; continue; }
$r = rtrim($line);
// headings (e.g. "# Title", "## Section")
if (preg_match('/^\s*#{1,6}\s+/', $r)) {
$out[] = ltrim($r);
continue;
}
// path-or-url ␠␠ description (or tabs)
if (preg_match('/^\s*(\S+)\s{2,}(.+)\s*$/u', $r, $m) || preg_match('/^\s*(\S+)\t+(.+)\s*$/u', $r, $m)) {
$add($m[1], $m[2]);
continue;
}
// otherwise treat as a bare path/URL (no description)
$add($r, '');
}
}
// join with newlines; keep a trailing newline
return implode("\n", $out) . "\n";
}
public function generate_sitemap_xml($s, $home) {
$urls = $this->site_urls_for_sitemap($s, $home);
$xml = "\n";
$xml .= "\n";
foreach ($urls as $u) {
// Try to find the post ID for this URL so we can use its last modified date
$post_id = url_to_postid($u);
if ($post_id) {
$lastmod = get_post_modified_time('c', true, $post_id);
} else {
// fallback: current time if not a post (e.g., static URL)
$lastmod = current_time('c');
}
$xml .= " \n";
$xml .= " " . $this->xml_escape($u) . " \n";
$xml .= " {$lastmod} \n";
$xml .= " \n";
}
$xml .= " \n";
return $xml;
}
/* ---------------- FAQ Auto from Page Content ---------------- */
private function get_preset_selectors($mode) {
// Returns [q_selector, strategy, a_selector]
// strategy: 'next' | 'css' | 'elementor_nested' | 'gutenberg_details'
switch ($mode) {
case 'preset_elementor':
// Try the modern Nested Accordion first; fallback handled in extractor.
// elementor_nested strategy ignores these selectors and uses structure.
return [null, 'elementor_nested', null];
case 'preset_gutenberg':
// Gutenberg Details: Q
...A...
return ['.wp-block-details summary', 'gutenberg_details', null];
case 'simple_headings':
// Q
A
return ['h3', 'next', 'p'];
case 'custom_selectors':
default:
// User provides selectors; 'css' means "find Q by CSS; find A by CSS after Q"
return [null, 'css', null];
}
}
private function auto_faq_pairs_from_content($s, $content_html) {
$pairs = [];
if ($s['faq_auto_enable'] !== '1') return $pairs;
if (!class_exists('DOMDocument') || !class_exists('DOMXPath')) return $pairs; // Guard if ext-dom missing
$container_class = trim($s['faq_container_class']);
if ($container_class === '') return $pairs;
libxml_use_internal_errors(true);
$dom = new DOMDocument('1.0', 'UTF-8');
$html = ''.$content_html.'';
$dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
libxml_clear_errors();
$xpath = new DOMXPath($dom);
// Find the first container matching the CSS class token
$class_token = trim(preg_split('/\s+/', $container_class)[0]);
$container_nodes = $xpath->query("//*[contains(concat(' ', normalize-space(@class), ' '), ' " . $class_token . " ')]");
if (!$container_nodes || $container_nodes->length === 0) return $pairs;
$container = $container_nodes->item(0);
list($preset_q, $strategy, $preset_a) = $this->get_preset_selectors($s['faq_mode']);
// Helper to normalize inner text (strip tags, collapse whitespace)
$text_of = function(DOMNode $node) {
$txt = trim(preg_replace('/\s+/', ' ', $node->textContent ?? ''));
return $txt;
};
// ---------- ELEMENTOR NESTED ----------
if ($strategy === 'elementor_nested') {
// Try new Nested Accordion structure first
// details.e-n-accordion-item > summary.e-n-accordion-item-title
$details_nodes = $xpath->query('.//details[contains(concat(" ", normalize-space(@class), " "), " e-n-accordion-item ")]', $container);
if ($details_nodes && $details_nodes->length) {
foreach ($details_nodes as $det) {
// QUESTION: prefer inner .e-n-accordion-item-title-text if present
$sum = $xpath->query('./summary[contains(concat(" ", normalize-space(@class), " "), " e-n-accordion-item-title ")]', $det)->item(0);
if (!$sum) continue;
// Some Elementor skins wrap the title in .e-n-accordion-item-title-text
$title_text_node = $xpath->query('.//*[contains(concat(" ", normalize-space(@class), " "), " e-n-accordion-item-title-text ")]', $sum)->item(0);
$q_text = $text_of($title_text_node ?: $sum);
if ($q_text === '') continue;
// ANSWER: the sibling region inside the same
$region = $xpath->query('./*[@role="region"]', $det)->item(0);
if ($region) {
$a_text = $text_of($region);
if ($a_text !== '') $pairs[] = ['q' => $q_text, 'a' => $a_text];
}
}
}
// If nothing was found with nested, fallback to classic Elementor
if (empty($pairs)) {
$q_nodes = $xpath->query('.//div[contains(concat(" ", normalize-space(@class), " "), " elementor-accordion-title ")]', $container);
$a_nodes = $xpath->query('.//div[contains(concat(" ", normalize-space(@class), " "), " elementor-accordion-content ")]', $container);
if ($q_nodes && $a_nodes && $q_nodes->length && $a_nodes->length) {
$len = min($q_nodes->length, $a_nodes->length);
for ($i = 0; $i < $len; $i++) {
$q_text = $text_of($q_nodes->item($i));
$a_text = $text_of($a_nodes->item($i));
if ($q_text !== '' && $a_text !== '') $pairs[] = ['q' => $q_text, 'a' => $a_text];
}
}
}
return $pairs;
}
// ---------- GUTENBERG DETAILS ----------
if ($strategy === 'gutenberg_details') {
// Each .wp-block-details contains a and arbitrary content as the answer
$blocks = $xpath->query('.//details[contains(concat(" ", normalize-space(@class), " "), " wp-block-details ")]', $container);
if ($blocks && $blocks->length) {
foreach ($blocks as $det) {
$sum = $xpath->query('./summary', $det)->item(0);
if (!$sum) continue;
$q_text = $text_of($sum);
if ($q_text === '') continue;
// Answer: everything inside details except the summary
$answer_txt = '';
foreach (iterator_to_array($det->childNodes) as $child) {
if ($child->nodeType === XML_ELEMENT_NODE && strtolower($child->nodeName) === 'summary') continue;
$answer_txt .= ' ' . $text_of($child);
}
$answer_txt = trim($answer_txt);
if ($answer_txt !== '') $pairs[] = ['q' => $q_text, 'a' => $answer_txt];
}
}
return $pairs;
}
// ---------- SIMPLE HEADINGS (h3 + next p) ----------
if ($strategy === 'next') {
$q_sel = ($s['faq_mode']==='custom_selectors' ? trim($s['faq_q_selector']) : 'h3');
$a_sel = ($s['faq_mode']==='custom_selectors' ? trim(strtolower($s['faq_a_selector'])) : 'p');
if ($q_sel === '') $q_sel = 'h3';
$q_nodes = $xpath->query('.//'.$q_sel, $container);
if ($q_nodes && $q_nodes->length) {
foreach ($q_nodes as $qnode) {
$q_text = $text_of($qnode);
if ($q_text === '') continue;
$a_text = '';
$next = $qnode->nextSibling;
while ($next && $next->nodeType !== XML_ELEMENT_NODE) { $next = $next->nextSibling; }
if ($next && strtolower($next->nodeName) === $a_sel) $a_text = $text_of($next);
if ($a_text !== '') $pairs[] = ['q'=>$q_text, 'a'=>$a_text];
}
}
return $pairs;
}
// ---------- CUSTOM / GENERIC CSS PAIRING ----------
// Find Q nodes by CSS; find the first A node that appears after each Q
if ($strategy === 'css') {
$q_sel = trim($s['faq_q_selector']);
$a_sel = trim($s['faq_a_selector']);
if ($q_sel === '' || $a_sel === '') return $pairs;
$q_nodes = $xpath->query('.//'.$q_sel, $container);
$a_nodes = $xpath->query('.//'.$a_sel, $container);
if ($q_nodes && $q_nodes->length && $a_nodes && $a_nodes->length) {
foreach ($q_nodes as $qnode) {
$q_text = $text_of($qnode);
if ($q_text === '') continue;
$found_a = '';
foreach ($a_nodes as $cand) {
if ($this->node_is_after($cand, $qnode)) { $found_a = $text_of($cand); break; }
}
if ($found_a !== '') $pairs[] = ['q'=>$q_text, 'a'=>$found_a];
}
}
return $pairs;
}
return $pairs;
}
private function node_is_after(DOMNode $a, DOMNode $b) {
$pos = $b;
while ($pos = $pos->nextSibling) {
if ($pos->isSameNode($a)) return true;
if ($pos->hasChildNodes()) {
$stack = [$pos];
while ($stack) {
$n = array_pop($stack);
if ($n->isSameNode($a)) return true;
if ($n->hasChildNodes()) foreach (iterator_to_array($n->childNodes) as $ch) $stack[] = $ch;
}
}
}
return false;
}
private function build_faq_jsonld_from_pairs($pairs) {
$entities = [];
foreach ($pairs as $p) {
$q = wp_strip_all_tags($p['q']);
$a = wp_strip_all_tags($p['a']);
if ($q === '' || $a === '') continue;
$entities[] = [
"@type" => "Question",
"name" => $q,
"acceptedAnswer" => [
"@type" => "Answer",
"text" => $a
]
];
}
return [
"@context" => "https://schema.org",
"@type" => "FAQPage",
"mainEntity" => $entities
];
}
public function generate_faq_jsonld_preview($s) {
$pairs_manual = $this->parse_pairs_block($s['faq_text']);
$data = $this->build_faq_jsonld_from_pairs($pairs_manual);
return "";
}
/* ---------------- Output & Serving ---------------- */
public function bypass_canonical_for_virtual($redirect_url, $requested_url) {
$path = parse_url($requested_url ?: '', PHP_URL_PATH);
if (!$path && !empty($_SERVER['REQUEST_URI'])) {
$path = parse_url(home_url($_SERVER['REQUEST_URI']), PHP_URL_PATH);
}
$path = rtrim($path ?: '', '/');
$skip = [
'/sitemap.xml','/sitemap.txt','/llms.txt',
'/sitemap_index.xml','/sitemap-index.xml'
];
if (preg_match('#^/([a-z0-9_\-]+)-sitemap\.(xml|txt)$#i', $path)) {
return false; // don't canonical-redirect per-type sitemaps either
}
if (in_array($path, $skip, true)) {
return false;
}
return $redirect_url;
}
public function serve_virtual_files() {
$s = $this->get_settings();
$uri = parse_url($_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH);
$home = rtrim(site_url(), '/');
// llms.txt
if ($s['serve_llms']==='1' && rtrim($uri,'/') === '/llms.txt') {
nocache_headers();
header('Content-Type: text/plain; charset=utf-8');
echo $this->generate_llms_txt($s, $home);
exit;
}
if ($s['serve_sitemap'] === '1') {
$path = rtrim($uri, '/');
$groups = $this->gather_urls_by_type($s, $home);
// XML index
if ($path === '/sitemap.xml') {
nocache_headers();
header('Content-Type: application/xml; charset=utf-8');
echo $this->generate_sitemap_index_xml_from_groups($groups, $home);
exit;
}
// TXT index (human readable)
if ($path === '/sitemap.txt') {
nocache_headers();
header('Content-Type: text/plain; charset=utf-8');
echo $this->generate_sitemap_index_txt_from_groups($groups, $home);
exit;
}
// Per-type XML: /-sitemap.xml
if (preg_match('#^/([a-z0-9_\-]+)-sitemap\.xml$#i', $path, $m)) {
$type = sanitize_key($m[1]);
if (isset($groups[$type])) {
nocache_headers();
header('Content-Type: application/xml; charset=utf-8');
echo $this->generate_type_sitemap_xml($type, $groups[$type]);
exit;
}
}
// Per-type TXT: /-sitemap.txt
if (preg_match('#^/([a-z0-9_\-]+)-sitemap\.txt$#i', $path, $m)) {
$type = sanitize_key($m[1]);
if (isset($groups[$type])) {
nocache_headers();
header('Content-Type: text/plain; charset=utf-8');
echo $this->generate_type_sitemap_txt($type, $groups[$type]);
exit;
}
}
// RankMath-style aliases → redirect to our index
if (in_array($path, ['/sitemap_index.xml','/sitemap-index.xml'], true)) {
wp_redirect(trailingslashit($home).'sitemap.xml', 301);
exit;
}
}
}
public function extend_robots_txt($existing, $public) {
$s = $this->get_settings();
if ($s['extend_robots'] !== '1') return $existing;
// If a physical robots.txt exists, don't touch it
if (file_exists(ABSPATH.'robots.txt')) return $existing;
$home = rtrim(site_url(), '/');
// Build our custom block (already contains ONE Sitemap with the chosen URL)
$custom = $this->generate_robots_txt($s, $home);
// Normalize newlines
$out = preg_replace("/\r\n?/", "\n", trim((string) $existing));
// Remove ALL existing 'Sitemap:' lines so we can add exactly one
$out = preg_replace('/^\s*Sitemap:\s*\S+.*$/mi', '', $out);
$out = trim(preg_replace("/\n{2,}/", "\n\n", $out)); // collapse extra blanks
// Append our block
if ($out !== '') $out .= "\n\n";
$out .= trim($custom) . "\n";
// Final tidy
$out = preg_replace("/\n{3,}/", "\n\n", $out);
return rtrim($out) . "\n";
}
public function maybe_output_faq_schema() {
if (is_admin()) return;
$s = $this->get_settings();
$entities = [];
$manual_pairs = $this->parse_pairs_block($s['faq_text']);
$inject_ids = array_filter(array_map('absint', explode(',', $s['faq_page_ids'])));
if (!empty($inject_ids) && is_page() && in_array(get_queried_object_id(), $inject_ids, true)) {
$entities = array_merge($entities, $this->build_faq_jsonld_from_pairs($manual_pairs)['mainEntity']);
}
$auto_enabled = ($s['faq_auto_enable'] === '1' && class_exists('DOMDocument') && class_exists('DOMXPath'));
$limit_ids = array_filter(array_map('absint', explode(',', $s['faq_auto_pages_ids'])));
$auto_here = $auto_enabled && (empty($limit_ids) ? true : (is_page() && in_array(get_queried_object_id(), $limit_ids, true)));
if ($auto_here && is_singular()) {
global $post;
if ($post) {
$content = apply_filters('the_content', $post->post_content);
$auto_pairs= $this->auto_faq_pairs_from_content($s, $content);
if (!empty($auto_pairs)) {
$entities = array_merge($entities, $this->build_faq_jsonld_from_pairs($auto_pairs)['mainEntity']);
}
}
}
if (empty($entities)) return;
$json = [
"@context" => "https://schema.org",
"@type" => "FAQPage",
"mainEntity" => $entities
];
echo "\n\n";
}
public function maybe_output_org_schema() {
if (is_admin() || wp_doing_ajax() || wp_doing_cron()) return;
$s = $this->get_settings();
if (empty($s['business_name'])) return;
// Use the chosen type
$type = ($s['entity_type'] === 'LocalBusiness') ? 'LocalBusiness' : 'Organization';
$data = [
"@context" => "https://schema.org",
"@type" => $type,
"name" => $s['business_name'],
"url" => home_url('/'),
];
if (!empty($s['logo_url'])) $data['logo'] = esc_url($s['logo_url']);
if (!empty($s['phone'])) $data['telephone'] = $s['phone'];
if (!empty($s['locality']) || !empty($s['country'])) {
$data['address'] = ["@type" => "PostalAddress"];
if (!empty($s['locality'])) $data['address']['addressLocality'] = $s['locality'];
if (!empty($s['country'])) $data['address']['addressCountry'] = $s['country'];
}
if (!empty($s['area_served'])) $data['areaServed'] = $s['area_served'];
echo "\n\n";
}
}
new AIV_Clarity_Ultra();
calendly-popup
tags-list
/**
* Woo Product Tags — replace default tag box with a row-wrap checkbox picker
* - Hides the core "Product tags" meta box
* - Adds a custom meta box with wrap layout (pills)
* - Saves to the real product_tag taxonomy
*/
add_action('add_meta_boxes', function () {
// Remove the default WP tag meta box for product tags
remove_meta_box('tagsdiv-product_tag', 'product', 'side');
// Add our custom one
add_meta_box(
'ws_product_tag_checklist',
'Product tags',
'ws_render_product_tag_wrap_metabox',
'product',
'side',
'default'
);
}, 20);
function ws_render_product_tag_wrap_metabox($post) {
wp_nonce_field('ws_save_product_tag_checklist', 'ws_product_tag_checklist_nonce');
$taxonomy = 'product_tag';
$terms = get_terms([
'taxonomy' => $taxonomy,
'hide_empty' => false,
'orderby' => 'name',
'order' => 'ASC',
'number' => 500,
]);
if (is_wp_error($terms) || empty($terms)) {
echo 'No tags found.
';
return;
}
$selected_ids = wp_get_object_terms($post->ID, $taxonomy, ['fields' => 'ids']);
if (is_wp_error($selected_ids)) $selected_ids = [];
$selected_ids = array_map('intval', $selected_ids);
echo '
';
echo '';
foreach ($terms as $t) {
$checked = in_array((int)$t->term_id, $selected_ids, true) ? 'checked' : '';
printf(
'',
(int) $t->term_id,
$checked,
esc_html($t->name)
);
}
echo '';
echo 'Ticking here updates the real WooCommerce product tags.
';
}
add_action('save_post_product', function ($post_id) {
if (!isset($_POST['ws_product_tag_checklist_nonce']) ||
!wp_verify_nonce($_POST['ws_product_tag_checklist_nonce'], 'ws_save_product_tag_checklist')) {
return;
}
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
if (!current_user_can('edit_post', $post_id)) return;
$ids = isset($_POST['ws_product_tag_ids']) ? array_map('intval', (array) $_POST['ws_product_tag_ids']) : [];
// Set the REAL product_tag terms:
wp_set_object_terms($post_id, $ids, 'product_tag', false);
});
in-stock-name-change
/* Scope to ONLY Stock Status filter */
.ws-wc-filter-multiselect[data-query-arg="stock-status"]
.ws-wc-filter-multiselect-option span {
font-size: 0; /* hides the original text */
line-height: 0;
}
/* Recreate the visible label */
.ws-wc-filter-multiselect[data-query-arg="stock-status"]
.ws-wc-filter-multiselect-option span::before {
font-size: 16px; /* set to match your UI */
line-height: 1;
display: inline-block;
color: inherit; /* inherits normal text color */
}
/* INSTOCK -> Available */
.ws-wc-filter-multiselect[data-query-arg="stock-status"]
input[value="instock"] + span::before {
content: "Available";
}
/* OUTOFSTOCK -> Out of Stock */
.ws-wc-filter-multiselect[data-query-arg="stock-status"]
input[value="outofstock"] + span::before {
content: "Out of Stock";
}
/* Optional: keep ALL as "All" (or remove this if you want to rename it too) */
.ws-wc-filter-multiselect[data-query-arg="stock-status"]
input[value=""] + span::before {
content: "All";
}
off-canvas-filter-reopen
better-search-results
add_filter('query_vars', function($vars) {
$vars[] = 'e_search_props';
return $vars;
});
add_action('template_redirect', function() {
if (isset($_GET['e_search_props']) && isset($_GET['s'])) {
wp_redirect( remove_query_arg('e_search_props'), 301 );
exit;
}
});
quick-access
/**
* Quick Links (Dashboard Only) — Hardened (no critical errors)
*/
if ( ! defined('ABSPATH') ) exit;
class WSQA_Dashboard_Only_V6 {
const META_CATALOG = 'wsqa_catalog_v6'; // array: id => item
const META_SELECTED = 'wsqa_selected_v6'; // ordered array of ids
const PAGE_SLUG = 'wsqa-v6';
const AJAX_ACTION = 'wsqa_scan_v6';
const NONCE_ACTION = 'wsqa_v6_nonce';
public static function init() {
add_action('admin_menu', [__CLASS__, 'add_settings_page']);
add_action('wp_dashboard_setup', [__CLASS__, 'add_dashboard_widget']);
add_action('admin_enqueue_scripts', [__CLASS__, 'enqueue_assets']);
add_action('admin_head-index.php', [__CLASS__, 'dashboard_css']);
add_action('admin_init', [__CLASS__, 'handle_save']);
add_action('wp_ajax_' . self::AJAX_ACTION, [__CLASS__, 'ajax_scan_save']);
}
public static function add_settings_page() {
add_options_page(
'Quick Access',
'Quick Access',
'read',
self::PAGE_SLUG,
[__CLASS__, 'render_settings_page']
);
}
public static function add_dashboard_widget() {
wp_add_dashboard_widget(
'wsqa_widget_v6',
'Quick Access',
[__CLASS__, 'render_dashboard_widget']
);
}
public static function dashboard_css() {
?>
No quick links yet.';
echo '';
return;
}
$grouped = [];
foreach ($items as $it) {
$p = !empty($it['parent']) ? $it['parent'] : 'Other';
if (!isset($grouped[$p])) $grouped[$p] = [];
$grouped[$p][] = $it;
}
echo '';
foreach ($grouped as $parent => $links) {
echo '';
echo ''.esc_html($parent).'';
echo '';
foreach ($links as $l) {
if (!is_array($l)) continue;
$url = self::normalize_admin_url(isset($l['url']) ? $l['url'] : '');
$label = isset($l['label']) ? $l['label'] : '';
if ($url === '' || $label === '') continue;
echo '- ';
echo ''.esc_html($label).'';
echo '
';
}
echo '
';
}
echo '';
echo '';
}
public static function enqueue_assets($hook) {
if ($hook !== 'settings_page_' . self::PAGE_SLUG) return;
wp_enqueue_script('jquery-ui-sortable');
$nonce = wp_create_nonce(self::NONCE_ACTION);
$ajax = admin_url('admin-ajax.php');
$js = "
jQuery(function($){
function syncOrder(){
var order = [];
$('#wsqa6-selected li').each(function(){
var id = $(this).attr('data-id');
if (id) order.push(id);
});
$('#wsqa6_order').val(order.join(','));
}
$('#wsqa6-selected').sortable({ handle: '.wsqa6-handle', update: syncOrder });
function escapeHtml(s){
s = String(s || '');
return s.replace(/[&<>\"']/g, function(m){
return ({'&':'&','<':'<','>':'>','\"':'"',\"'\":'''}[m]);
});
}
$(document).on('click', '.wsqa6-remove', function(){
var li = $(this).closest('li');
var id = li.attr('data-id');
li.remove();
$('#wsqa6-catalog input[type=checkbox][value=\"'+id+'\"]').prop('checked', false);
syncOrder();
});
$(document).on('change', '#wsqa6-catalog input[type=checkbox]', function(){
var cb = $(this);
var id = cb.val();
var parent = cb.attr('data-parent') || 'Other';
var label = cb.attr('data-label') || '';
if (cb.is(':checked')) {
if ($('#wsqa6-selected li[data-id=\"'+id+'\"]').length) { syncOrder(); return; }
$('#wsqa6-selected').append(
' '
+ '☰'
+ ''+escapeHtml(parent)+' — '+escapeHtml(label)+''
+ ''
+ ' '
);
} else {
$('#wsqa6-selected li[data-id=\"'+id+'\"]').remove();
}
syncOrder();
});
function hashId(s){
s = String(s || '').toLowerCase();
var h = 0, i, chr;
for (i = 0; i < s.length; i++) { chr = s.charCodeAt(i); h = ((h << 5) - h) + chr; h |= 0; }
if (h < 0) h = h * -1;
return 'wsqa6_' + h;
}
function cleanText(t){
return String(t || '').replace(/\\s+/g, ' ').replace(/^\\s+|\\s+$/g,'');
}
function addItem(items, parent, label, url, source){
if (!label || !url) return;
var id = hashId(parent + '|' + label + '|' + url);
items.push({ id: id, parent: parent, label: label, url: url, source: source || '' });
}
function scrapeAdminMenu(){
var items = [];
var menu = document.getElementById('adminmenu');
if (!menu) return items;
var lis = menu.children;
for (var i=0; i a') || li.querySelector('a');
var parent = cleanText(topA ? topA.textContent : '') || 'Other';
var subs = li.querySelectorAll('ul.wp-submenu a');
for (var j=0; j 8) return;
if (typeof obj.title === 'string' && typeof obj.url === 'string') {
var label = cleanText(obj.title);
var url = obj.url;
if (label && url) addItem(out, 'Elementor', label, url, 'Elementor');
}
for (var k in obj){
if (!Object.prototype.hasOwnProperty.call(obj, k)) continue;
var v = obj[k];
if (v && typeof v === 'object') walkObject(v, out, depth + 1);
}
}
function scrapeElementorGlobals(){
var out = [];
var candidates = [ window.elementorCommonConfig, window.elementorAppProConfig, window.elementor ];
for (var i=0; i
Quick Access (Dashboard Only)
self::PAGE_SLUG,'updated'=>'1'], admin_url('options-general.php')));
exit;
}
/**
* Build a robust catalog from WordPress registered admin menu arrays ($menu / $submenu).
*/
private static function build_wp_admin_menu_items() {
if ( ! is_admin() ) return [];
global $menu, $submenu;
$out = [];
if ( ! is_array( $menu ) ) return $out;
foreach ( $menu as $m ) {
if ( ! is_array( $m ) || empty( $m[2] ) ) continue;
$parent_slug = (string) $m[2];
$parent_cap = isset( $m[1] ) ? (string) $m[1] : 'read';
$parent_label = isset( $m[0] ) ? wp_strip_all_tags( (string) $m[0] ) : '';
$parent_label = trim( preg_replace( '/\s+/', ' ', $parent_label ) );
if ( in_array($parent_slug, ['separator1','separator2','separator-last'], true) ) continue;
if ( $parent_label === '' ) continue;
if ( ! current_user_can( $parent_cap ) ) continue;
if ( isset( $submenu[ $parent_slug ] ) && is_array( $submenu[ $parent_slug ] ) ) {
foreach ( $submenu[ $parent_slug ] as $sm ) {
if ( ! is_array( $sm ) || empty( $sm[2] ) ) continue;
$label = isset( $sm[0] ) ? wp_strip_all_tags( (string) $sm[0] ) : '';
$label = trim( preg_replace( '/\s+/', ' ', $label ) );
if ( $label === '' ) continue;
$cap = isset( $sm[1] ) ? (string) $sm[1] : $parent_cap;
if ( ! current_user_can( $cap ) ) continue;
$url = self::normalize_admin_url( (string) $sm[2] );
if ( ! $url ) continue;
$out[] = self::make_item( $parent_label, $label, $url, 'Admin Menu', $cap );
}
}
}
$out = array_merge( $out, self::build_extra_admin_links() );
return $out;
}
/**
* Extra links for plugin UIs that don't register in WP's left admin menu ($submenu).
*/
private static function build_extra_admin_links() {
$out = [];
// Elementor "Custom Code" uses CPT elementor_snippet.
if ( post_type_exists( 'elementor_snippet' ) ) {
$pto = get_post_type_object( 'elementor_snippet' );
$cap = ( $pto && ! empty( $pto->cap->edit_posts ) ) ? $pto->cap->edit_posts : 'edit_posts';
if ( current_user_can( $cap ) ) {
$out[] = self::make_item(
'Elementor',
'Custom Code',
self::normalize_admin_url( 'edit.php?post_type=elementor_snippet' ),
'Elementor',
$cap
);
}
}
// Elementor Templates CPT.
if ( post_type_exists( 'elementor_library' ) ) {
$pto = get_post_type_object( 'elementor_library' );
$cap = ( $pto && ! empty( $pto->cap->edit_posts ) ) ? $pto->cap->edit_posts : 'edit_posts';
if ( current_user_can( $cap ) ) {
$out[] = self::make_item(
'Elementor',
'Templates',
self::normalize_admin_url( 'edit.php?post_type=elementor_library' ),
'Elementor',
$cap
);
}
}
return $out;
}
/**
* Normalize an admin URL/slug to an absolute URL.
*/
private static function normalize_admin_url( $url ) {
$url = trim( (string) $url );
if ( $url === '' ) return '';
if ( $url === '#' ) return '';
if ( stripos( $url, 'javascript:' ) === 0 ) return '';
if ( preg_match( '#^https?://#i', $url ) ) return $url;
return admin_url( ltrim( $url, '/' ) );
}
private static function make_item( $parent, $label, $url, $source, $cap = 'read' ) {
$parent = sanitize_text_field( (string) $parent );
$label = sanitize_text_field( (string) $label );
$url = esc_url_raw( (string) $url );
$source = sanitize_text_field( (string) $source );
$cap = sanitize_text_field( (string) $cap );
$id = substr( md5( $source . '|' . $url . '|' . $label ), 0, 12 );
return [
'id' => $id,
'parent' => $parent ?: 'Other',
'label' => $label ?: $url,
'url' => $url,
'source' => $source,
'cap' => $cap ?: 'read',
];
}
/**
* Merge posted items (from JS scanners) with server-side WP menu items, then save.
*/
private static function build_merged_catalog_from_request( $items ) {
$catalog = [];
foreach ( self::build_wp_admin_menu_items() as $it ) {
if ( empty( $it['id'] ) ) continue;
$catalog[ $it['id'] ] = $it;
}
if ( is_array( $items ) ) {
foreach ( $items as $it ) {
if ( ! is_array( $it ) ) continue;
$parent = isset( $it['parent'] ) ? sanitize_text_field( (string) $it['parent'] ) : 'Other';
$label = isset( $it['label'] ) ? sanitize_text_field( (string) $it['label'] ) : '';
$url = isset( $it['url'] ) ? self::normalize_admin_url( (string) $it['url'] ) : '';
$source = isset( $it['source'] ) ? sanitize_text_field( (string) $it['source'] ) : 'Scan';
$cap = isset( $it['cap'] ) ? sanitize_text_field( (string) $it['cap'] ) : 'read';
if ( $label === '' || $url === '' ) continue;
$id = substr( md5( $source . '|' . $url . '|' . $label ), 0, 12 );
if ( ! isset( $catalog[ $id ] ) ) {
$catalog[ $id ] = [
'id' => $id,
'parent' => $parent ?: 'Other',
'label' => $label,
'url' => esc_url_raw( $url ),
'source' => $source,
'cap' => $cap ?: 'read',
];
}
}
}
return $catalog;
}
public static function ajax_scan_save() {
check_ajax_referer(self::NONCE_ACTION);
$items = [];
if ( isset($_POST['items_json']) ) {
$decoded = json_decode(wp_unslash($_POST['items_json']), true);
if ( is_array($decoded) ) {
$items = $decoded;
}
}
$catalog = self::build_merged_catalog_from_request( $items );
// Force-add extra links every time
foreach ( self::build_extra_admin_links() as $it ) {
if ( is_array($it) && !empty($it['id']) ) {
$catalog[ $it['id'] ] = $it;
}
}
// Final sanitize before saving (prevents corrupt meta from ever being stored)
$catalog = self::sanitize_catalog($catalog);
update_user_meta(get_current_user_id(), self::META_CATALOG, $catalog);
wp_send_json_success();
}
/* =========================
HARDENING (prevents fatals)
========================= */
private static function sanitize_item($it) {
if (!is_array($it)) return null;
$id = isset($it['id']) ? sanitize_text_field((string)$it['id']) : '';
$parent = isset($it['parent']) ? sanitize_text_field((string)$it['parent']) : 'Other';
$label = isset($it['label']) ? sanitize_text_field((string)$it['label']) : '';
$url = isset($it['url']) ? (string)$it['url'] : '';
$source = isset($it['source']) ? sanitize_text_field((string)$it['source']) : '';
$cap = isset($it['cap']) ? sanitize_text_field((string)$it['cap']) : 'read';
$url = self::normalize_admin_url($url);
if ($id === '' || $label === '' || $url === '') return null;
return [
'id' => $id,
'parent' => $parent !== '' ? $parent : 'Other',
'label' => $label,
'url' => $url,
'source' => $source,
'cap' => $cap !== '' ? $cap : 'read',
];
}
private static function sanitize_catalog($raw) {
// Handle JSON-string meta from older versions
if (is_string($raw)) {
$maybe = json_decode($raw, true);
if (is_array($maybe)) $raw = $maybe;
}
if (!is_array($raw)) return [];
$clean = [];
foreach ($raw as $key => $it) {
if (!is_array($it)) continue;
$san = self::sanitize_item($it);
if (!$san) continue;
$clean[$san['id']] = $san;
}
return $clean;
}
private static function get_catalog() {
$raw = get_user_meta(get_current_user_id(), self::META_CATALOG, true);
return self::sanitize_catalog($raw);
}
private static function get_selected() {
$raw = get_user_meta(get_current_user_id(), self::META_SELECTED, true);
if (is_string($raw)) {
$maybe = json_decode($raw, true);
if (is_array($maybe)) $raw = $maybe;
}
if (!is_array($raw)) return [];
$out = [];
foreach ($raw as $v) {
$v = sanitize_text_field((string)$v);
if ($v !== '') $out[] = $v;
}
return $out;
}
}
WSQA_Dashboard_Only_V6::init();
product-gallery-layout
/* Classes to use
woo-images-bottom
woo-images-right */
.woocommerce-product-gallery__trigger {display: none;}
/* CONTROL PANEL */
.woo-images-bottom,
.woo-images-right{
--gap: 5px;
--thumb-top-gap: 0px;
--thumbs-side-gap: 10px;
--border-radius: 10px;
/* Desktop */
--desktop-width: 400px;
--desktop-height: 500px;
--desktop-cols: 4;
--desktop-side-cols: 2;
--desktop-side-rows: 4;
/* Tablet */
--tablet-width: 400px;
--tablet-height: 400px;
--tablet-cols: 5;
--tablet-side-cols: 2;
--tablet-side-rows: 5;
/* Mobile */
--mobile-width: 310px;
--mobile-height: 310px;
--mobile-cols: 6;
--mobile-side-cols: 2;
--mobile-side-rows: 5;
/* internal defaults (overridden by breakpoints) */
--width: var(--desktop-width);
--height: var(--desktop-height);
--cols: var(--desktop-cols);
--side-cols: var(--desktop-side-cols);
--side-rows: var(--desktop-side-rows);
}
/* Stop slide animation (both modes) */
.woo-images-bottom .woocommerce-product-gallery .flex-viewport,
.woo-images-bottom .woocommerce-product-gallery .flex-viewport *,
.woo-images-right .woocommerce-product-gallery .flex-viewport,
.woo-images-right .woocommerce-product-gallery .flex-viewport *{
transition-duration: 0s !important;
}
/* MAIN STAGE (ALL DEVICES) */
.woo-images-bottom .woocommerce-product-gallery .flex-viewport,
.woo-images-right .woocommerce-product-gallery .flex-viewport{
width: var(--width) !important;
height: var(--height) !important;
overflow: hidden !important;
border-radius: var(--border-radius) !important;
box-sizing: border-box !important;
}
.woo-images-bottom .woocommerce-product-gallery__image,
.woo-images-bottom .woocommerce-product-gallery__image > a,
.woo-images-right .woocommerce-product-gallery__image,
.woo-images-right .woocommerce-product-gallery__image > a{
height: var(--height) !important;
display: block !important;
}
.woo-images-bottom .woocommerce-product-gallery__image img,
.woo-images-right .woocommerce-product-gallery__image img{
width: 100% !important;
height: 100% !important;
object-fit: cover !important;
object-position: center center !important;
display: block !important;
}
/* Shared thumb image rules (both modes) */
.woo-images-bottom .woocommerce-product-gallery .flex-control-thumbs img,
.woo-images-right .woocommerce-product-gallery .flex-control-thumbs img{
width: 100% !important;
height: 100% !important;
object-fit: cover !important;
object-position: center center !important;
display: block !important;
border-radius: inherit !important;
}
/* BOTTOM MODE (row-first) */
.woo-images-bottom .woocommerce-product-gallery .flex-control-thumbs{
width: var(--width) !important;
max-width: var(--width) !important;
margin: var(--thumb-top-gap) 0 0 !important;
padding: 0 !important;
list-style: none !important;
display: flex !important;
flex-wrap: wrap !important;
column-gap: var(--gap) !important;
row-gap: var(--gap) !important;
justify-content: flex-start !important;
align-content: flex-start !important;
box-sizing: border-box !important;
}
.woo-images-bottom .woocommerce-product-gallery .flex-control-thumbs > li{
--cell: calc(
(var(--width) - (var(--gap) * (var(--cols) - 1)))
/ var(--cols)
);
flex: 0 0 var(--cell) !important;
max-width: var(--cell) !important;
aspect-ratio: 1 / 1 !important;
height: auto !important;
margin: 0 !important;
padding: 0 !important;
float: none !important;
overflow: hidden !important;
border-radius: var(--border-radius) !important;
min-width: 0 !important;
min-height: 0 !important;
box-sizing: border-box !important;
}
/* RIGHT MODE (column-first) */
.woo-images-right .woocommerce-product-gallery{
/* thumb size derived from height/rows */
--side-thumb: calc(
(var(--height) - (var(--gap) * (var(--side-rows) - 1)))
/ var(--side-rows)
);
/* panel width derived from cols */
--side-w: calc(
(var(--side-cols) * var(--side-thumb)) +
((var(--side-cols) - 1) * var(--gap))
);
display: grid !important;
grid-template-columns: var(--width) var(--side-w) !important;
column-gap: var(--thumbs-side-gap) !important;
align-items: start !important;
max-width: 100% !important;
}
/* main left */
.woo-images-right .woocommerce-product-gallery .flex-viewport{
grid-column: 1 !important;
grid-row: 1 !important;
}
/* thumbs right */
.woo-images-right .woocommerce-product-gallery .flex-control-thumbs{
grid-column: 2 !important;
grid-row: 1 !important;
width: var(--side-w) !important;
max-width: none !important;
height: var(--height) !important;
overflow-y: auto !important;
overflow-x: hidden !important;
margin: 0 !important;
padding: 0 !important;
list-style: none !important;
/* KEY: column-first fill */
display: grid !important;
grid-auto-flow: column !important;
grid-template-rows: repeat(var(--side-rows), var(--side-thumb)) !important;
grid-auto-columns: var(--side-thumb) !important;
column-gap: var(--gap) !important;
row-gap: var(--gap) !important;
align-content: start !important;
justify-content: start !important;
box-sizing: border-box !important;
}
.woo-images-right .woocommerce-product-gallery .flex-control-thumbs > li{
width: var(--side-thumb) !important;
height: var(--side-thumb) !important;
max-width: var(--side-thumb) !important;
margin: 0 !important;
padding: 0 !important;
float: none !important;
line-height: 0 !important;
overflow: hidden !important;
border-radius: var(--border-radius) !important;
box-sizing: border-box !important;
}
/* BREAKPOINT MAPPING (vars only) */
/* Mobile */
@media (max-width: 767px){
.woo-images-bottom,
.woo-images-right{
--width: var(--mobile-width);
--height: var(--mobile-height);
--cols: var(--mobile-cols);
--side-cols: var(--mobile-side-cols);
--side-rows: var(--mobile-side-rows);
}
}
/* Tablet */
@media (min-width: 768px) and (max-width: 1023px){
.woo-images-bottom,
.woo-images-right{
--width: var(--tablet-width);
--height: var(--tablet-height);
--cols: var(--tablet-cols);
--side-cols: var(--tablet-side-cols);
--side-rows: var(--tablet-side-rows);
}
}
/* Desktop */
@media (min-width: 1024px){
.woo-images-bottom,
.woo-images-right{
--width: var(--desktop-width);
--height: var(--desktop-height);
--cols: var(--desktop-cols);
--side-cols: var(--desktop-side-cols);
--side-rows: var(--desktop-side-rows);
}
}
extract-urls
/**
* Admin Tools -> Export URLs (CSV) for all public post types.
*/
add_action('admin_menu', function () {
add_management_page(
'Export URLs',
'Export URLs',
'manage_options',
'export-all-urls',
'ws_export_all_urls_page'
);
});
function ws_export_all_urls_page() {
if (!current_user_can('manage_options')) return;
$download_url = wp_nonce_url(
admin_url('tools.php?page=export-all-urls&ws_export_urls=1'),
'ws_export_urls'
);
echo '';
echo 'Export URLs
';
echo 'Download a CSV containing URLs for all public post types (posts, pages, products, and custom post types).
';
echo '';
echo '';
}
add_action('admin_init', function () {
if (empty($_GET['ws_export_urls'])) return;
if (!current_user_can('manage_options')) return;
check_admin_referer('ws_export_urls');
// Get all public post types (includes custom post types like products, FAQs, etc.)
$post_types = get_post_types(['public' => true], 'names');
// Query all published posts across all those types
$q = new WP_Query([
'post_type' => array_values($post_types),
'post_status' => 'publish',
'posts_per_page' => -1,
'fields' => 'ids',
'no_found_rows' => true,
]);
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=all-urls-' . date('Y-m-d') . '.csv');
$out = fopen('php://output', 'w');
fputcsv($out, ['ID', 'post_type', 'post_title', 'status', 'date', 'url']);
foreach ($q->posts as $post_id) {
fputcsv($out, [
$post_id,
get_post_type($post_id),
html_entity_decode(get_the_title($post_id), ENT_QUOTES, 'UTF-8'),
get_post_status($post_id),
get_post_time('Y-m-d H:i:s', true, $post_id),
get_permalink($post_id),
]);
}
fclose($out);
exit;
});
disable-right-click
-- Add to Custom Code
-- Set to body-end