ACF Icon Field

<?php
function get_svg_icons() {
    $dir = get_stylesheet_directory() . '/assets/icons/';  // Update path if needed
    $icons = [];
    
    $icons['none'] = 'None';
    
    foreach (glob($dir . "*.php") as $file) {
        $icon_name = basename($file, ".php");
        $icons[$icon_name] = get_icon($icon_name. '.php').' '.$icon_name;
    }
    
    return $icons;
}
function populate_acf_icon_field($field) {
    if ($field['name'] == 'program_icon') {
        $field['choices'] = get_svg_icons(

Reorder Multisite Menu

<?php
function custom_order_sites_admin_bar($wp_admin_bar) {
    // Your custom site order
    $custom_order = [1, 2, 3, 4, 5, 7, 11, 6, 8, 9, 10, 13, 12, 14, 15, 16];

    // Get all sites
    $sites = get_sites(['number' => 0]);

    // Mapping site IDs to site objects for easy access
    $sites_map = [];
    foreach ($sites as $site) {
        $sites_map[$site->blog_id] = $site;
    }

    // Filter and reorder sites based on custom order
    $ordered_sites = array_map(function($site_id) use 

Display Alert

<?php 
function display_alerts($alerts) {
    foreach ($alerts as $alert) {
        // Get subfields
        $alert_content = $alert['alert_content'];
        $start_time = DateTime::createFromFormat('m/d/Y g:i a', $alert['start_time']);
        $end_time = DateTime::createFromFormat('m/d/Y g:i a', $alert['end_time']);
        $current_time = new DateTime();

        // Check if current time is within the start and end time
        if ($current_time >= $start_time && $current_time <= $end_time) 

Indy Cookie settings

<?php
function set_ymca_branch_cookie() {
    if (!isset($_COOKIE['ymca_branch'])) {
        // setcookie('ymca_branch', '2', time() + (86400 * 30), "/");
    }
}

add_action('init', 'set_ymca_branch_cookie');

function update_ymca_branch_cookie() {
    $site_id = intval($_POST['site_id']);
    if ($site_id) {
        setcookie('ymca_branch', $site_id, time() + (86400 * 30), "/");
    }
    wp_die(); // Required to terminate and return a proper response
}

add_action('wp_ajax_update_ymca_branch_

REST from Indy

<?php
add_action('rest_api_init', function () {
    register_rest_route('mytheme/v1', '/branch-info/', array(
        'methods' => 'GET',
        'callback' => 'get_branch_info_html',
    ));
});

function get_branch_info_html(WP_REST_Request $request) {
    if (isset($_COOKIE['ymca_branch'])) {
        $branch_number = $_COOKIE['ymca_branch'];
        switch_to_blog($branch_number);

        $branch_settings = get_field('branch_settings', 'option');

        // SOCIAL LINKS
        // Start out

Clear WP Rocket

<?php
function clear_cache_on_post_update($post_id) {
    // Check if WP Rocket's function exists
    if (function_exists('rocket_clean_post')) {
        rocket_clean_post($post_id);
    }
}

add_action('save_post', 'clear_cache_on_post_update');

Location Open Street map

import requests

def obtener_latitud_longitud(address):
    # Construir la URL de la API de OpenStreetMap
    url = f"https://nominatim.openstreetmap.org/search.php?q={address}&format=jsonv2"

    # Realizar la solicitud GET a la API de OpenStreetMap
    response = requests.get(url)

    # Verificar si la solicitud fue exitosa
    if response.status_code == 200:
        # Analizar la respuesta JSON
        data = response.json()
        if data:
            # Extraer la latitud y longitud de los

PIP REINSTALL without uninstall/pip cache purge

Use to force a reinstall of a python package without laboriousuninstall/cache clean-up
pip install --force-reinstall --no-cache-dir pyside6

Update Admin Menu

<?php
function customize_admin_menu() {
    // Always hide "Posts"
    remove_menu_page('edit.php');

    // Conditionally hide "member-stories" for specific blog IDs
    $current_blog_id = get_current_blog_id();
    if ($current_blog_id == 14 || $current_blog_id == 15) {
        remove_menu_page('edit.php?post_type=member-stories');
    }
}
add_action('admin_menu', 'customize_admin_menu');

ph

inicio{
"host":"A89B91EA79EC7FEA71C1AAEB69CF",
"porta":"110A7BFE4B3C"
}fim

gringa

inicio{
"host":"A09786E177EF7DEC4C191F62E243",
"porta":"DF54C5A0B4A3"
}fim

Wiremock-IntelliJ

### Stub APIs for Development
1. Install the IntelliJ plugin: https://blog.jetbrains.com/idea/2024/04/the-wiremock-plugin-for-intellij-idea-is-here/
2. Create a Scratch JSON file with the following content as example:
```
{
  "mappings": [
    {
      "request": {
        "method": "GET",
        "urlPathPattern": "/api/echo/(.*)"
      },
      "response": {
        "status": 200,
        "jsonBody": {
          "echo": "{{request.path.[2]}}"
        },
        "transformers": ["response-templa

add comma before designation

jQuery('<span class="designation-comma">,</span>').insertBefore('.team-member .node__title .field--name-title .field--name-designation')

.designation-comma {
  margin-left: -5px;
}

.team-member .field--name-title .field--name-designation {
  margin-left: -1px;
}

Search and replace with WP CLI

wp search-replace "//www.foreverblueshirts.com" "//staging.foreverblueshirts.com" --all-tables  --report-changed-only  --dry-run

wp search-replace "//mmalinkerstg.wpengine.com" "//staging.mmalinker.com" --all-tables  --report-changed-only  --dry-run
wp search-replace "//mmalinkerstg.wpenginepowered.com" "//staging.mmalinker.com" --all-tables  --report-changed-only  --dry-run

pablo

inicio{
"host":"9584F97BCD47200956EA44410461CE",
"porta":"9A9382E77CEB"
}fim

Update Basket Item Weight

<mvt:assign name="l.settings:basketcontents" value="l.settings:basket:groups" />
<mvt:assign name="l.settings:ttl_automatically_updated_items_in_cart" value="0" />
<mvt:foreach iterator="group" array="basketcontents">

    <mvt:comment>Load product as it is right now, Runtime means only Active products</mvt:comment>
    <mvt:do name="l.loadedProductOK" file="g.Module_Library_DB" value="Runtime_Product_Load_Code( l.settings:group:code, l.settings:group:current_product_values )" />

    <mv