Plugin Directory

Changeset 3247171


Ignore:
Timestamp:
02/26/2025 02:09:22 PM (13 months ago)
Author:
reormadrid
Message:

readme.txt

Location:
easy-custom-404/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • easy-custom-404/trunk/easy-custom-404.php

    r3241034 r3247171  
    1 <?php
     1 <?php
    22/**
    33   Plugin Name: Easy Custom 404 Page
    44   Description: Allows you to select a custom page to display instead of the default 404 error.
    5    Version: 1.0
     5   Version: 1.10
    66   Author: ReorMadrid
    77   Author URI: https://www.reormadrid.com
     
    1212 */
    1313
    14 // No se permite cargar directamente
    15 // Don't load directly
     14// No se permite cargar directamente.
     15// Direct access is not allowed.
    1616if ( ! defined( 'ABSPATH' ) ) {
    17     die( '-1' );
     17    die( '-1' );
    1818}
    1919
    20 // Menú añadido en la administración
    21 // Menu added to administration
    22 function easy_easy_custom_404_settings() {
     20// Menú en administración.
     21// Administration menu.
     22function easy_custom_404_settings() {
    2323    add_options_page(
    2424        'Easy Custom 404 Error Page',
     
    2626        'manage_options',
    2727        'easy_custom-404-page',
    28         'easy_easy_custom_404_settings_page'
     28        'easy_custom_404_settings_page'
    2929    );
    3030}
    31 add_action('admin_menu', 'easy_easy_custom_404_settings');
     31add_action('admin_menu', 'easy_custom_404_settings');
    3232
    33 // Añadimos el acceso a la configuración y selección de la página 404
    34 // We added access to the configuration and selection of the 404 page
    35 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.
     35function easy_custom_404_settings_page() {
    3636    if (isset($_POST['easy_custom_404'])) {
    37         check_admin_referer('easy_custom_404_nonce'); // Verificación de seguridad
     37        check_admin_referer('easy_custom_404_nonce'); // Seguridad
    3838        update_option('easy_custom_404', intval($_POST['easy_custom_404']));
    39         echo '<div class="updated"><p>' . esc_html__('Configuration saved. Thank you.', 'easy-custom-404') . '</p></div>';
     39        echo '<div class="updated"><p>' . esc_html__('Configuración guardada.', 'easy-custom-404') . '</p></div>';
    4040    }
    4141    $selected_page = get_option('easy_custom_404');
     
    4343    ?>
    4444    <div class="wrap">
    45         <h1><?php esc_html_e('Configure Your Custom 404 Page', 'easy-custom-404'); ?></h1>
     45        <h1><?php esc_html_e('Configurar Página 404 Personalizada', 'easy-custom-404'); ?></h1>
    4646        <form method="post">
    4747            <?php wp_nonce_field('easy_custom_404_nonce'); ?>
    48             <label for="easy_custom_404"><?php esc_html_e('Select a page:', 'easy-custom-404'); ?></label>
     48            <label for="easy_custom_404"><?php esc_html_e('Selecciona una página:', 'easy-custom-404'); ?></label>
    4949            <select name="easy_custom_404" id="easy_custom_404_page">
    50                 <option value="">-- <?php esc_html_e('Select a page', 'easy-custom-404'); ?> --</option>
     50                <option value="">-- <?php esc_html_e('Seleccionar página', 'easy-custom-404'); ?> --</option>
    5151                <?php foreach ($pages as $page) { ?>
    5252                    <option value="<?php echo esc_attr($page->ID); ?>" <?php selected($selected_page, $page->ID); ?>>
     
    5959        </form>
    6060    </div>
    61     <?php
     61<?php
    6262}
    6363
    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() {
     64function easy_custom_404_template() {
    6765    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();
    7182            exit();
    7283        }
    7384    }
    7485}
    75 add_action('template_redirect', 'easy_easy_custom_404_redirect');
     86add_action('template_redirect', 'easy_custom_404_template');
  • easy-custom-404/trunk/readme.txt

    r3245821 r3247171  
    11=== Easy Custom 404 Page ===
     2Tags: 404, error 404, 404 page, custom 404, not found
     3Author: ReorMadrid
     4Author URI: https://www.reormadrid.com
    25Contributors: reormadrid
    3 Tags: 404, error 404, 404 page, custom 404, not found
    4 Author URI: https://www.reormadrid.com
    56Requires at least: 5.1
    67Tested up to: 6.7
    78Requires PHP: 7.0
    8 Stable tag: 1.0
     9Stable tag: 1.10
    910License: GPLv2 or later
    1011License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4041
    41421. Go to Plugins › Add New.
    42 2. Search for * Easy Custom 404 Page ReorMadrid *.
     432. Search for * Easy Custom 404 Page *.
    43443. Find this plugin, download it, and activate it.
    44454. Go to Settings and Easy Custom 404 Error Page.
     
    4849
    49501. Ve a Plugins › Agregar nuevo.
    50 2. Busca * Easy Custom 404 Page ReorMadrid *.
     512. Busca * Easy Custom 404 Page *.
    51523. Busca este plugin, instálalo y actívalo.
    52534. Ve a ajustes y entra en Easy Custom 404 Error Page.
     
    6263* Initial version.
    6364
     65= 1.10 =
     66
     67* Modified function to force status header to 404.
     68
    6469== Upgrade Notice ==
Note: See TracChangeset for help on using the changeset viewer.