Skip to content

Instantly share code, notes, and snippets.

View loorlab's full-sized avatar
💻
💥👩‍🚀👨‍🚀💥

LOOR Lab loorlab

💻
💥👩‍🚀👨‍🚀💥
View GitHub Profile
@loorlab
loorlab / disable_WooCommerce_WP.php
Last active June 29, 2025 01:43
Disable WooCommerce - Exclude Pages
<?php
// functions.php - Plugin
// Disable WooCommerce
function dw_conditional_woocommerce_assets() {
if (function_exists('is_woocommerce')) {
// Verifica si estamos en una página WooCommerce esencial
$is_woocommerce_page = is_woocommerce() || is_cart() || is_checkout() || is_account_page();
// Handles específicos a remover si no estamos en una página WooCommerce
@loorlab
loorlab / report_transients_WP.bash
Created May 18, 2025 05:03
Report Transients Bash WP .sh
#!/bin/bash
# Crear nombre de archivo con fecha actual
FECHA=$(date +"%Y-%m-%d_%H-%M")
ARCHIVO="transients_report_$FECHA.csv"
# Crear encabezado del CSV
echo "Nombre,Valor,Expira_en" > $ARCHIVO
# Obtener lista de transients en formato json
@loorlab
loorlab / transients_CSV_WP_CLI.bash
Created May 18, 2025 05:01
Transients to CSV - WP CLI
# Exportar todos los transients a CSV
wp transient list --format=json | jq -r 'map([.name, .expiration]) | map(join(",")) | .[]' > transients_export.csv
@loorlab
loorlab / ACF_fields_related_WP_CLI.bash
Created May 17, 2025 19:04
ACF fields related to each other - WP CLI
@loorlab
loorlab / list_ACF_groups_fields_CPT_WP_CLI.bash
Created May 16, 2025 23:49
Show all groups and fields associated with the CPT person (all in one) - WP CLI
wp eval '
$field_groups = acf_get_field_groups(["post_type" => "person"]);
foreach ($field_groups as $group) {
echo "Grupo: {$group["title"]} (key: {$group["key"]})\n";
$fields = acf_get_fields($group["key"]);
if ($fields) {
foreach ($fields as $field) {
echo " - {$field["label"]} ({$field["name"]}) tipo: {$field["type"]}\n";
}
@loorlab
loorlab / display_custom_fields_CPT_WP_CLI.bash
Created May 16, 2025 23:43
Display in console the custom fields used by the CPT person - WP CLI
wp eval '
$posts = get_posts([
"post_type" => "person",
"posts_per_page" => 500,
"fields" => "ids"
]);
$keys = [];
foreach ($posts as $id) {
@loorlab
loorlab / list_terms_taxonomy_WP_CLI.bash
Created May 16, 2025 23:16
List terms from the persons_categories taxonomy - WP CLI
wp term list persons_categories --format=table
wp term list persons_categories --format=csv > persons_categories.csv
wp term list persons_categories --format=json
@loorlab
loorlab / display_all_taxonomies_CPT_post_WP_CLI.bash
Created May 16, 2025 23:12
Displays all taxonomies associated with the post's CPT and what terms are assigned to them. - WP CLI
wp eval '
$post_id = 53972; // ID
$post_type = get_post_type($post_id);
$taxonomies = get_object_taxonomies($post_type);
foreach ($taxonomies as $tax) {
$terms = get_the_terms($post_id, $tax);
echo "Taxonomía: $tax\n";
if (!empty($terms)) {
foreach ($terms as $term) {
echo "- {$term->name} (ID: {$term->term_id})\n";
@loorlab
loorlab / taxonomies-CPT-WP_CLI.bash
Created May 16, 2025 23:07
View the taxonomies associated with a CPT (e.g., person) - WP CLI
wp eval 'print_r( get_object_taxonomies("person") );'
@loorlab
loorlab / count_total_number_records_by_comma_WIN.bash
Created May 16, 2025 21:47
Count the total number of records in a comma-separated file (no-index.txt) in WIN, Bash console
expr $(tr -cd ',' < no-index.txt | wc -c) + 1