← Back
Editing: functions.php
<?php if ( ! function_exists( 'zoya_child_theme_enqueue_scripts' ) ) { /** * Function that enqueue theme's child style */ function zoya_child_theme_enqueue_scripts() { $main_style = 'zoya-main'; wp_enqueue_style( 'zoya-child-style', get_stylesheet_directory_uri() . '/style.css', array( $main_style ) ); } add_action( 'wp_enqueue_scripts', 'zoya_child_theme_enqueue_scripts' ); } // Añadimos un índice a los artículos function addIndex($content) { if (is_single()) { $pattern_h1 = '/<h1.*?>(.*?)<\/h1>/'; preg_match($pattern_h1, $content, $match_h1); $pattern_h2_h3 = '/<h([2-3]).*?>(.*?)<\/h[2-3]>/'; preg_match_all($pattern_h2_h3, $content, $matches_h2_h3, PREG_SET_ORDER); if (!empty($matches_h2_h3)) { $indice = '<div class="indice-articulo"><div><span>' . get_the_title() . '</span></div><ol class="indice">'; $nivelAnterior = 2; foreach ($matches_h2_h3 as $match) { $titulo = html_entity_decode(strip_tags($match[2])); $id = sanitize_title_with_dashes($titulo); $nivel = intval($match[1]); while ($nivel > $nivelAnterior) { $indice .= '<ul>'; $nivelAnterior++; } while ($nivel < $nivelAnterior) { $indice .= '</ul></li>'; $nivelAnterior--; } $indice .= '<li><a class="medir" id="indice" href="#' . esc_attr($id) . '">' . esc_html($titulo) . '</a>'; // Reemplazar el título original con el título con ID $content = str_replace($match[0], '<h' . $match[1] . ' id="' . esc_attr($id) . '">' . strip_tags(($match[2])) . '</h' . $match[1] . '>', $content); } // Cerrar las etiquetas UL restantes while ($nivelAnterior > 2) { $indice .= '</ul></li>'; $nivelAnterior--; } $indice .= '</ol></div>'; // Insertar el índice después del encabezado h1 si existe if (!empty($match_h1)) { $content = str_replace($match_h1[0], $match_h1[0] . $indice, $content); } else { $content = $indice . $content; } } } return $content; } add_filter('the_content', 'addIndex'); // LOGIN ****** function my_login_logo_url() {return home_url();} add_filter( 'login_headerurl', 'my_login_logo_url' ); function my_login_logo_url_title() {return 'MARYPAZ ®';} add_filter( 'login_headertitle', 'my_login_logo_url_title' ); function my_login_stylesheet() {wp_enqueue_style( 'login-custom-style', get_stylesheet_directory_uri(). '/css/login.css', array('login') );} add_action( 'login_enqueue_scripts', 'my_login_stylesheet' ); // LOGIN ****** // Cambiar URL de login a /wp/ add_action('init', 'custom_login_url'); function custom_login_url() { // Si accede a /wp/, mostrar wp-login.php if (strpos($_SERVER['REQUEST_URI'], '/wp/') !== false) { // 🎯 SOLUCIÓN: Definir las variables que wp-login espera, pero que faltan. if ( ! isset( $user_login ) ) { $user_login = ''; } if ( ! isset( $error ) ) { $error = ''; } require_once(ABSPATH . 'wp-login.php'); exit; } } // Bloquear acceso directo a wp-login.php y wp-admin add_action('init', 'block_default_login_urls'); function block_default_login_urls() { global $pagenow; $referer = $_SERVER['HTTP_REFERER'] ?? ''; // <--- SOLUCIÓN CLAVE (PHP 7.0+) // Bloquear wp-login.php (excepto si viene de /wp/) if ($pagenow == 'wp-login.php' && strpos($referer, '/wp/') === false) { wp_redirect(home_url('/404')); exit; } } add_filter( 'http_request_timeout', function( $timeout ) { return 60; // Aumenta el timeout a 60 segundos (el default es 5) } );
Save File
Cancel