Location: everywhere
Hierarchical category menu shortcode
/** * Upgraded: Hierarchical category menu shortcode with: * – Collapsed-by-default children * – Per-branch toggle (checkbox styled like radio) * – Multiple branches can be open concurrently * – Auto-expand active branch path (ancestors of current) * – localStorage…Continue reading
canonical category URLs
/** * Shortcode: [atk_filter_menu] * Outputs a list of real WooCommerce product categories linking to /shop/filter/{slug}/ */ add_shortcode(‘atk_filter_menu’, function ($atts) { $atts = shortcode_atts([ ‘parent’ => ”, // optional parent term ID (or leave blank for all top-level) ‘show_count’ =>…Continue reading
Add Custom Fields to Products.php
/** * Merchatura – Simple per-product custom fields (v4.2) ✅ Conditional Logic added * * Adds per-field conditional rules that work: * – In admin (inline rule builder under each field) * – On the product page (hide/show live) *…Continue reading
Allow SVG Files Upload
/** * Allow SVG uploads for administrator users. * * @param array $upload_mimes Allowed mime types. * * @return mixed */ add_filter( ‘upload_mimes’, function ( $upload_mimes ) { // By default, only administrator users are allowed to add SVGs. //…Continue reading
Enable Payment on Account
/** * WooCommerce: Role-based + Guest payment methods UI + logic * * – Adds a “Payment Methods” tab under WooCommerce > Settings. * – Shows a matrix of User Roles (down the left) vs Active Payment Methods (across the…Continue reading
Roles.php
// ✅ Add “Roles” menu for shop_manager_-_reseller_admin add_action(‘admin_menu’, function () { $user = wp_get_current_user(); if (!in_array(‘shop_manager_-_reseller_admin’, (array) $user->roles)) return; add_menu_page( ‘Create Customer Role’, ‘Roles’, ‘manage_product_terms’, ‘create-customer-role’, ‘render_custom_role_form’, ‘dashicons-groups’, 56 ); }); // ✅ Render form and role list function render_custom_role_form()…Continue reading
Shop Manager – Reseller Admin.js
// ✅ Add required capabilities to shop_manager_-_reseller_admin add_action(‘init’, function () { $role = get_role(‘shop_manager_-_reseller_admin’); if ($role) { $caps = [ ‘manage_product_terms’, ‘edit_roles’, ]; foreach ($caps as $cap) { if (!$role->has_cap($cap)) { $role->add_cap($cap); } } } }); // ✅ Add Categories…Continue reading
Register New Users as Customers
function set_default_user_role_customer($user_id) { $user = new WP_User($user_id); // Check if the user has no roles (which can happen in Multisite) if (empty($user->roles)) { $user->set_role(‘customer’); } } add_action(‘user_register’, ‘set_default_user_role_customer’); function remove_subscriber_role() { remove_role(‘subscriber’); } add_action(‘init’, ‘remove_subscriber_role’);Continue reading
Nav Cat Sort by Post Count
/** * Sort Primary menu category items by post count (DESC). * Multisite-safe, cached, and preserves menu structure. */ if (!defined(‘ABSPATH’)) { exit; } // ———- Config ———- if (!defined(‘RW_PRIMARY_MENU_LOCATION’)) { define(‘RW_PRIMARY_MENU_LOCATION’, ‘primary’); // change if your theme uses a…Continue reading