Changeset 3247171
- Timestamp:
- 02/26/2025 02:09:22 PM (13 months ago)
- Location:
- easy-custom-404/trunk
- Files:
-
- 2 edited
-
easy-custom-404.php (modified) (5 diffs)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
easy-custom-404/trunk/easy-custom-404.php
r3241034 r3247171 1 <?php1 <?php 2 2 /** 3 3 Plugin Name: Easy Custom 404 Page 4 4 Description: Allows you to select a custom page to display instead of the default 404 error. 5 Version: 1. 05 Version: 1.10 6 6 Author: ReorMadrid 7 7 Author URI: https://www.reormadrid.com … … 12 12 */ 13 13 14 // No se permite cargar directamente 15 // D on't load directly14 // No se permite cargar directamente. 15 // Direct access is not allowed. 16 16 if ( ! defined( 'ABSPATH' ) ) { 17 die( '-1' );17 die( '-1' ); 18 18 } 19 19 20 // Menú añadido en la administración21 // Menu added to administration22 function easy_ easy_custom_404_settings() {20 // Menú en administración. 21 // Administration menu. 22 function easy_custom_404_settings() { 23 23 add_options_page( 24 24 'Easy Custom 404 Error Page', … … 26 26 'manage_options', 27 27 'easy_custom-404-page', 28 'easy_ easy_custom_404_settings_page'28 'easy_custom_404_settings_page' 29 29 ); 30 30 } 31 add_action('admin_menu', 'easy_ easy_custom_404_settings');31 add_action('admin_menu', 'easy_custom_404_settings'); 32 32 33 // Añadimos el acceso a la configuración y selección de la página 40434 // We added access to the configuration and selection of the 404 page35 function easy_ easy_custom_404_settings_page() {33 // Configuración de la página 404 en la administración. 34 // 404 Page configuration in the administration panel. 35 function easy_custom_404_settings_page() { 36 36 if (isset($_POST['easy_custom_404'])) { 37 check_admin_referer('easy_custom_404_nonce'); // Verificación de seguridad37 check_admin_referer('easy_custom_404_nonce'); // Seguridad 38 38 update_option('easy_custom_404', intval($_POST['easy_custom_404'])); 39 echo '<div class="updated"><p>' . esc_html__('Configura tion saved. Thank you.', 'easy-custom-404') . '</p></div>';39 echo '<div class="updated"><p>' . esc_html__('Configuración guardada.', 'easy-custom-404') . '</p></div>'; 40 40 } 41 41 $selected_page = get_option('easy_custom_404'); … … 43 43 ?> 44 44 <div class="wrap"> 45 <h1><?php esc_html_e('Configur e Your Custom 404 Page', 'easy-custom-404'); ?></h1>45 <h1><?php esc_html_e('Configurar Página 404 Personalizada', 'easy-custom-404'); ?></h1> 46 46 <form method="post"> 47 47 <?php wp_nonce_field('easy_custom_404_nonce'); ?> 48 <label for="easy_custom_404"><?php esc_html_e('Selec t a page:', 'easy-custom-404'); ?></label>48 <label for="easy_custom_404"><?php esc_html_e('Selecciona una página:', 'easy-custom-404'); ?></label> 49 49 <select name="easy_custom_404" id="easy_custom_404_page"> 50 <option value="">-- <?php esc_html_e('Selec t a page', 'easy-custom-404'); ?> --</option>50 <option value="">-- <?php esc_html_e('Seleccionar página', 'easy-custom-404'); ?> --</option> 51 51 <?php foreach ($pages as $page) { ?> 52 52 <option value="<?php echo esc_attr($page->ID); ?>" <?php selected($selected_page, $page->ID); ?>> … … 59 59 </form> 60 60 </div> 61 <?php61 <?php 62 62 } 63 63 64 // Si hay error 404 mandamos al usuario a la página que hemos seleccionado 65 // If there is a 404 error, we send the user to the page we have selected. 66 function easy_easy_custom_404_redirect() { 64 function easy_custom_404_template() { 67 65 if (is_404()) { 68 $easy_custom_404 = get_option('easy_custom_404'); 69 if ($easy_custom_404) { 70 wp_redirect(get_permalink($easy_custom_404), 301); 66 $custom_404_page_id = get_option('easy_custom_404'); 67 if ($custom_404_page_id) { 68 // Marcamos la cabecera de la página como 404 para que Google y demás buscadores lo reconozan bien. 69 // We mark the page header as 404 so that Google and other search engines recognize it correctly. 70 status_header(404); 71 nocache_headers(); 72 // Cargamos la pagina seleccionada. 73 // We load the selected page. 74 global $wp_query; 75 $wp_query->query([ 76 'page_id' => $custom_404_page_id, 77 'post_type' => 'page' 78 ]); 79 // Cargamos la plantilla estándar del tema. 80 // We load the theme's standard template. 81 include get_page_template(); 71 82 exit(); 72 83 } 73 84 } 74 85 } 75 add_action('template_redirect', 'easy_ easy_custom_404_redirect');86 add_action('template_redirect', 'easy_custom_404_template'); -
easy-custom-404/trunk/readme.txt
r3245821 r3247171 1 1 === Easy Custom 404 Page === 2 Tags: 404, error 404, 404 page, custom 404, not found 3 Author: ReorMadrid 4 Author URI: https://www.reormadrid.com 2 5 Contributors: reormadrid 3 Tags: 404, error 404, 404 page, custom 404, not found4 Author URI: https://www.reormadrid.com5 6 Requires at least: 5.1 6 7 Tested up to: 6.7 7 8 Requires PHP: 7.0 8 Stable tag: 1. 09 Stable tag: 1.10 9 10 License: GPLv2 or later 10 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 40 41 41 42 1. Go to Plugins › Add New. 42 2. Search for * Easy Custom 404 Page ReorMadrid*.43 2. Search for * Easy Custom 404 Page *. 43 44 3. Find this plugin, download it, and activate it. 44 45 4. Go to Settings and Easy Custom 404 Error Page. … … 48 49 49 50 1. Ve a Plugins › Agregar nuevo. 50 2. Busca * Easy Custom 404 Page ReorMadrid*.51 2. Busca * Easy Custom 404 Page *. 51 52 3. Busca este plugin, instálalo y actívalo. 52 53 4. Ve a ajustes y entra en Easy Custom 404 Error Page. … … 62 63 * Initial version. 63 64 65 = 1.10 = 66 67 * Modified function to force status header to 404. 68 64 69 == Upgrade Notice ==
Note: See TracChangeset
for help on using the changeset viewer.