🔥 HOT: Changeset/ - Complete Album!

Changeset 3161639


Ignore:
Timestamp:
10/02/2024 05:48:35 PM (15 months ago)
Author:
jchristopher
Message:

Version 11.4.8

Location:
404page/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • 404page/trunk/404page.php

    r3152985 r3161639  
    33 * Plugin Name: Smart Custom 404 Error Page
    44 * Description: Custom 404 the easy way! Set any page as a custom 404 error page -- no coding needed. <a href="https://www.nerdpress.net/announcing-404-page/">Now managed by NerdPress!</a>
    5  * Version: 11.4.7
     5 * Version: 11.4.8
    66 * Requires at least: 4.0
    77 * Requires PHP: 5.4
  • 404page/trunk/block.php

    r3152985 r3161639  
    77 *
    88 **/
    9  
     9
    1010if ( ! defined( 'ABSPATH' ) ) {
    1111    exit; // Exit if accessed directly
     
    1313
    1414add_action( 'init', function() {
    15    
     15
    1616    if ( function_exists('register_block_type_from_metadata' ) ) {
    17        
     17
    1818        register_block_type_from_metadata( __DIR__, [
    1919            'render_callback' => function( $atts ) {
  • 404page/trunk/functions.php

    r3152985 r3161639  
    77 *
    88 **/
    9  
     9
    1010if ( ! defined( 'ABSPATH' ) ) {
    1111    exit; // Exit if accessed directly
    1212}
    1313
    14  
     14
    1515// this function can be used by a theme to check if there's an active custom 404 page
    1616function pp_404_is_active() {
    17  
     17
    1818  return pp_404page()->pp_404_is_active();
    19  
     19
    2020}
    2121
     
    2323// this function can be used by a theme to activate native support
    2424function pp_404_set_native_support() {
    25  
     25
    2626  pp_404page()->pp_404_set_native_support();
    27  
     27
    2828}
    2929
     
    3131// this function can be used by a theme to get the title of the custom 404 page in native support
    3232function pp_404_get_the_title() {
    33  
     33
    3434  return pp_404page()->pp_404_get_the_title();
    35  
     35
    3636}
    3737
     
    3939// this function can be used by a theme to print out the title of the custom 404 page in native support
    4040function pp_404_the_title() {
    41  
     41
    4242  pp_404page()->pp_404_the_title();
    43  
     43
    4444}
    4545
     
    4747// this function can be used by a theme to get the content of the custom 404 page in native support
    4848function pp_404_get_the_content() {
    49  
     49
    5050  return pp_404page()->pp_404_get_the_content();
    51  
     51
    5252}
    5353
     
    5555// this function can be used by a theme to print out the content of the custom 404 page in native support
    5656function pp_404_the_content() {
    57  
     57
    5858  return pp_404page()->pp_404_the_content();
    59  
     59
    6060}
    6161
     
    6363// this function returns the page id of the selected 404 page - in a multilingual environment this returs the id of the page in the current language
    6464function pp_404_get_page_id() {
    65  
     65
    6666  return pp_404page()->get_page_id();
    67  
     67
    6868}
    6969
     
    7171// this function returns an array of page ids in all languages
    7272function pp_404_get_all_page_ids() {
    73  
     73
    7474  return pp_404page()->get_all_page_ids();
    75  
     75
    7676}
    7777
     
    8484 * @param  string $type
    8585 * @return string
    86  */     
     86 */
    8787function pp_404_get_the_url( $type ) {
    8888
    8989    $url = '';
    90    
     90
    9191    if ( is_array( $type ) ) {
    92        
     92
    9393        $type = $type[0];
    94        
     94
    9595    }
    96    
     96
    9797    if ( 'page' == $type ) {
    98      
     98
    9999        $url = trim( pp_404page()->get_404_url( 'path' ), '/' );
    100      
     100
    101101    } elseif ( 'domainpath' == $type ) {
    102    
     102
    103103        $url = pp_404page()->get_404_url( 'host' ) . pp_404page()->get_404_url( 'path' );
    104      
     104
    105105    } else {
    106        
     106
    107107        $url = pp_404page()->get_404_url( 'full' );
    108      
     108
    109109    }
    110  
    111  
    112     return $url;
    113    
     110
     111
     112    return esc_url( $url );
     113
    114114}
  • 404page/trunk/inc/class-404page.php

    r3152985 r3161639  
    2020 */
    2121if ( !class_exists( 'PP_404Page' ) ) {
    22  
    23  
     22
     23
    2424  class PP_404Page extends PPF09_Plugin {
    25    
    26    
     25
     26
    2727    /**
    2828     * Native Mode
     
    3333     */
    3434    private $native;
    35    
     35
    3636    private $template;
    3737    private $postid;
    38    
    39    
     38
     39
    4040    /**
    4141     * Admin Class
     
    4747     */
    4848    private $admin;
    49    
    50    
     49
     50
    5151    /**
    5252     * Block Editor Class
     
    5858     */
    5959    private $blockeditor;
    60    
    61    
     60
     61
    6262    /**
    6363     * Classic Editor Class
     
    6969     */
    7070    private $classiceditor;
    71    
    72    
     71
     72
    7373    /**
    7474     * Deprecated Class
     
    8080     */
    8181    private $deprecated;
    82    
    83    
     82
     83
    8484    /**
    8585     * URL that caused the 404 error
     
    9090     */
    9191    private $error_url;
    92    
    93    
    94     /**
    95      * Init the Class 
     92
     93
     94    /**
     95     * Init the Class
    9696     *
    9797     * @since 11.0.0
     
    9999     */
    100100    public function plugin_init() {
    101      
     101
    102102      // settings defaults
    103103      // @since 11.0.0
     
    112112        'method'             => 'STD'
    113113      );
    114      
     114
    115115      // since 11.0.0 we use add_settings_class() to load the settings
    116116      $this->add_settings_class( 'PP_404Page_Settings', 'class-404page-settings', $this, $defaults );
    117      
     117
    118118      // @since 11.0.0
    119119      $this->add_action( 'init' );
    120     } 
    121    
    122    
    123     /**
    124      * do plugin init 
     120    }
     121
     122
     123    /**
     124     * do plugin init
    125125     * this runs after init action has fired to ensure everything is loaded properly
    126126     * was init() before 11.0.0
    127127     */
    128128    function action_init() {
    129      
     129
    130130      // moved from add_text_domain() in v 11.0.0
    131131      load_plugin_textdomain( '404page' );
    132      
    133      
     132
     133
    134134      // change old stuff to new stuff for backward compatibility
    135135      // since v 11.0.0
    136136      $this->deprecated = $this->add_sub_class_always( 'PP_404Page_Deprecated',         'class-404page-deprecated',          $this );
    137      
     137
    138138      // load the following subclasses only on backend
    139       // using add_sub_class_backend() sinde v 11 
     139      // using add_sub_class_backend() sinde v 11
    140140      $this->admin         = $this->add_sub_class_backend( 'PP_404Page_Admin',         'class-404page-admin',          $this, $this->settings() );
    141141      $this->blockeditor   = $this->add_sub_class_backend( 'PP_404Page_BlockEditor',   'class-404page-block-editor',   $this, $this->settings() );
    142142      $this->classiceditor = $this->add_sub_class_backend( 'PP_404Page_ClassicEditor', 'class-404page-classic-editor', $this, $this->settings() );
    143      
     143
    144144      // as of v 2.2 always call set_mode
    145145      // as of v 2.4 we do not need to add an init action hook
    146      
     146
    147147      if ( !is_admin() && $this->settings()->get( 'page_id' ) > 0 ) {
    148        
     148
    149149        // as of v 3.0 we once check if there's a 404 page set and not in all functions separately
    150150        $this->set_mode();
    151151        add_action( 'pre_get_posts', array ( $this, 'exclude_404page' ) );
    152152        add_filter( 'get_pages', array ( $this, 'remove_404page_from_array' ), 10, 2 );
    153        
     153
    154154        // Stop URL guessing if activated
    155155        if ( $this->settings()->get( 'no_url_guessing' ) ) {
    156156          add_filter( 'redirect_canonical' ,array ( $this, 'no_url_guessing' ) );
    157157        }
    158        
    159        
     158
     159
    160160        // Remove 404 error page from XML sitemaps
    161161        // only if "Send an 404 error if the page is accessed directly by its URL" is active
    162162        if ( $this->settings()->get( 'fire_error' ) ) {
    163          
     163
    164164          // YOAST sitemap
    165165          // @since 6
    166          
     166
    167167          // we do not need to check if Yoast Sitemap feature is activated because the filter only fires if it is active
    168168          add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', function ( $alreadyExcluded ) {
     
    171171            return array_merge( $alreadyExcluded, $this->get_all_page_ids() );
    172172          }, 999 );
    173          
    174          
     173
     174
    175175          // Jetpack sitemap
    176176          // @since 11.1.2
    177          
     177
    178178          // we do not need to check if Jetpack Sitemap feature is activated because the filter only fires if it is active
    179179          add_filter( 'jetpack_sitemap_skip_post', function ( $skip, $post ) {
     
    183183            return $skip;
    184184          }, 999, 2 );
    185          
    186         }
    187        
    188       }
    189      
    190        
     185
     186        }
     187
     188      }
     189
     190
    191191      if ( class_exists( 'PP_404Page_Admin' ) ) {
    192  
     192
    193193        // load classes only if in admin
    194194        // @since 10
    195195        // using class_exists( 'PP_404Page_Admin' ) instead of is_admin() as of v 10.3 for compatibilty with iThemes Sync
    196        
     196
    197197        //$this->admin = new PP_404Page_Admin( $this, $this->settings );
    198198        //$this->blockeditor = new PP_404Page_BlockEditor( $this );
    199199        //$this->classiceditor = new PP_404Page_ClassicEditor( $this );
    200        
     200
    201201        // Remove 404 page from post list if activated
    202202        // not moved to PP_404Page_Admin because we also need exclude_404page() in frontend
     
    204204          add_action( 'pre_get_posts' ,array ( $this, 'exclude_404page' ) );
    205205        }
    206        
    207       }
    208      
    209     }
    210    
    211    
    212     /**
    213      * init filters 
     206
     207      }
     208
     209    }
     210
     211
     212    /**
     213     * init filters
    214214     */
    215215    function set_mode() {
    216      
     216
    217217      $this->settings()->set_method();
    218            
     218
    219219      if ( defined( 'CUSTOMIZR_VER' ) ) {
    220        
    221         // Customizr Compatibility Mode 
     220
     221        // Customizr Compatibility Mode
    222222
    223223        // @since 3.1
    224224        add_filter( 'body_class', array( $this, 'add_404_body_class_customizr_mode' ) );
    225        
     225
    226226        add_filter( 'tc_404_header_content', array( $this, 'show404title_customizr_mode' ), 999 );
    227227        add_filter( 'tc_404_content', array( $this, 'show404_customizr_mode' ), 999 );
    228228        add_filter( 'tc_404_selectors', array( $this, 'show404articleselectors_customizr_mode' ), 999 );
    229        
     229
    230230        // send http 410 instead of http 404 if requested resource is in trash
    231231        // @since 3.2
     
    233233        // @since 11.3.0
    234234        if ( $this->settings()->get( 'http410_if_trashed' ) || $this->settings()->get( 'http410_always' ) ) {
    235