From 8ea4d51fd265790c19f3457b4e9180e313e2218a Mon Sep 17 00:00:00 2001 From: rafa Date: Sat, 27 Jun 2026 11:18:50 -0400 Subject: [PATCH] feat(#8): buscador visible (MVP nativo) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fea-search.php: barra de búsqueda visible en móvil (donde el menú colapsa y oculta el buscador del menú); multiidioma por Polylang. - set_search_template.php: template FSE 'search' con resultados en rejilla de tarjetas (reutiliza el layout de archive #63) en vez del patrón del tema que los mostraba 'todos seguidos'. Co-Authored-By: Claude Opus 4.8 --- scripts/set_search_template.php | 86 +++++++++++++++++++ .../wp-content/mu-plugins/fea-search.php | 61 +++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 scripts/set_search_template.php create mode 100644 wordpress/wp-content/mu-plugins/fea-search.php diff --git a/scripts/set_search_template.php b/scripts/set_search_template.php new file mode 100644 index 0000000..3d5473d --- /dev/null +++ b/scripts/set_search_template.php @@ -0,0 +1,86 @@ + + + +
+ + + + + + +
+
+ +

Lo siento, no se ha encontrado nada. Por favor, prueba a buscar con otras palabras clave.

+ +
+ + + + +
+ + + +
+ + + + + + + + +
+ + + + + +
+
+
+ + + +HTML; + +$existing = get_posts(['post_type' => 'wp_template', 'name' => 'search', 'post_status' => 'any', 'posts_per_page' => 1]); +if ($existing) { + $id = $existing[0]->ID; + echo "Template 'search' existe (post $id) → " . ($apply ? "actualizando" : "[dry] actualizaría") . "\n"; + if ($apply) wp_update_post(['ID' => $id, 'post_content' => $content]); +} else { + echo ($apply ? "Creando" : "[dry] crearía") . " wp_template 'search' (theme $theme)\n"; + if ($apply) { + $id = wp_insert_post([ + 'post_type' => 'wp_template', + 'post_status' => 'publish', + 'post_name' => 'search', + 'post_title' => 'Search Results', + 'post_content' => $content, + ], true); + if (is_wp_error($id)) { echo "ERROR: " . $id->get_error_message() . "\n"; return; } + wp_set_object_terms($id, $theme, 'wp_theme'); + echo " creado post $id\n"; + } +} +if (function_exists('wp_cache_flush')) wp_cache_flush(); +echo ($apply ? "APLICADO" : "DRY-RUN") . "\n"; diff --git a/wordpress/wp-content/mu-plugins/fea-search.php b/wordpress/wp-content/mu-plugins/fea-search.php new file mode 100644 index 0000000..55d4c88 --- /dev/null +++ b/wordpress/wp-content/mu-plugins/fea-search.php @@ -0,0 +1,61 @@ +/. + $base = home_url('/'); + if (function_exists('pll_current_language')) { + $lang = pll_current_language(); + $default = function_exists('pll_default_language') ? pll_default_language() : 'es'; + if ($lang && $lang !== $default) $base = home_url('/' . $lang . '/'); + } + $action = esc_url($base); + $q = esc_attr(get_search_query()); + $ph = esc_attr__('Buscar reflexiones, artículos, autores…', 'default'); + $svg = ''; + return ''; +} + +/** Inyecta la barra al final del template part 'header'. */ +add_filter('render_block', function ($html, $block) { + if (is_admin()) return $html; + if (($block['blockName'] ?? '') !== 'core/template-part') return $html; + // El home usa el part 'cabecera-portada'; el resto del sitio usa 'header'. + if (!in_array($block['attrs']['slug'] ?? '', ['header', 'cabecera-portada'], true)) return $html; + return $html . fea_search_form_html(); +}, 20, 2); + +add_action('wp_head', function () { + ?> + +