Admin Privileges Being Returned

add_action(‘init’, function () { if (current_user_can(‘administrator’)) { $role = get_role(‘administrator’); if ($role) { // Capabilities related to editing pages, posts, and more $capabilities = [ ‘edit_posts’, ‘edit_others_posts’, ‘edit_published_posts’, ‘edit_pages’, ‘edit_others_pages’, ‘edit_published_pages’, ‘publish_posts’, ‘publish_pages’, ‘delete_posts’, ‘delete_others_posts’, ‘delete_published_posts’, ‘delete_pages’, ‘delete_others_pages’, ‘delete_published_pages’, ‘read’,…Continue reading

One-Time Backfill for Existing Posts

add_action(‘init’, function () { if (!current_user_can(‘manage_options’) || !isset($_GET[‘run_related_organization_sync’])) return; $target_post_type = ‘post’; // e.g., ‘team’, ‘staff’, etc. $posts = get_posts([ ‘post_type’ => $target_post_type, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘fields’ => ‘ids’, ]); foreach ($posts as $post_id) { $external_ids_raw =…Continue reading

Is Production Server

function is_production_server(){ $isProduction = true; $triggerWords = [‘.loc’, ‘localhost’, ‘.local’, ‘staging.’, ‘.staging’, ‘.testing’, ‘.dev’, ‘.test’, ‘.cloud’]; // edit triggerWords for your setup, these as fairly standard identifiers of non production env // the goal is to check the root url…Continue reading

POST PURGE

add_action(‘init’, function () { if (!current_user_can(‘delete_posts’)) return; // Run only if you explicitly visit this URL: if (!isset($_GET[‘delete_all_posts’])) return; $post_types = [‘post’]; // You can change this to [‘post’, ‘product’, ‘your_cpt’] foreach ($post_types as $type) { $posts = get_posts([ ‘post_type’…Continue reading

CHAPTER CREATION – Form Logic & AJAX Handlers – Snippet 2/2

// ===================================================== // PAT CHAPTER CREATION SYSTEM – SNIPPET 2: FORM LOGIC & AJAX HANDLERS (FIXED) // Fixed AJAX calls to use working handlers and proper element targeting // Add to Code Snippets – Run everywhere // ===================================================== // Prevent…Continue reading

NexSouk Performance & Accessibility Optimizer

// =============================== // ✅ NexSouk.com Performance & Accessibility Optimizer // =============================== add_action(‘init’, function() { // ✅ Remove emoji scripts remove_action(‘wp_head’, ‘print_emoji_detection_script’, 7); remove_action(‘wp_print_styles’, ‘print_emoji_styles’); // ✅ Reduce Heartbeat API frequency (to lower backend resource usage) add_filter(‘heartbeat_settings’, function($settings) { $settings[‘interval’] =…Continue reading

LearnDash Course Search Widget

/** * Author: Sumaiya, Anytype Documentation: https://object.any.coop/bafyreifrops5tp5h7anwsa7k7k4rphi5nvz62sgnxhdidfogjcspk3afli?spaceId=bafyreih4bocrmskuomcrks3sjwpnzxpbxvxwgto23vof3umg2fywdqzjmy.31bq39w6q8ru7&inviteId=bafybeifc55atash7zlqcjd3fv425bkwl7z5zstcxdilct5hstlng73xwci#6kKA3QiwnksqLbpcJ4T6UhmQ5BHzgJUfbpn1QLnkv5Lv * * LearnDash Course Search Widget – Popup Modal Version * * This snippet creates a WordPress shortcode to display a dynamic search widget for LearnDash courses. * Shortcode: [learndash_search_widget] * * Features:…Continue reading