Changeset 1472214
- Timestamp:
- 08/11/2016 10:34:07 AM (10 years ago)
- File:
-
- 1 edited
-
404page/trunk/404page.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
404page/trunk/404page.php
r1400463 r1472214 4 4 Plugin URI: http://smartware.cc/free-wordpress-plugins/404page/ 5 5 Description: Custom 404 the easy way! Set any page as custom 404 error page. No coding needed. Works with (almost) every Theme. 6 Version: 2. 16 Version: 2.2 DEV 7 7 Author: smartware.cc, Peter's Plugins 8 8 Author URI: http://smartware.cc … … 45 45 $this->plugin_name = '404page'; 46 46 $this->plugin_slug = '404page'; 47 $this->version = '2. 1';47 $this->version = '2.2 DEV'; 48 48 $this->get_settings(); 49 49 $this->init(); … … 62 62 private function init() { 63 63 64 register_activation_hook( __FILE__, array( $this, 'init_admin_notice' ) );65 66 64 if ( !is_admin() ) { 67 65 68 66 add_action( 'init', array( $this, 'set_mode' ) ); 67 add_action( 'pre_get_posts' ,array ( $this, 'exclude_404page_from_search' ) ); 69 68 70 69 } else { … … 79 78 } 80 79 81 if ( 'NOT_DISMISSED' == get_option( '404page_notice_dismissed', 'NOT_DISMISSED' ) ) {82 add_action( 'admin_notices', array( $this, 'admin_notice' ) );83 add_action( 'wp_ajax_nopriv_404page_dismiss_admin_notice', array( $this, 'dismiss_admin_notice' ) );84 add_action( 'wp_ajax_404page_dismiss_admin_notice', array( $this, 'dismiss_admin_notice' ) );85 }86 80 } 87 81 … … 171 165 add_action( 'wp', array( $this, 'do_404_header' ) ); 172 166 add_filter( 'body_class', array( $this, 'add_404_body_class' ) ); 167 add_filter( 'template_include', array( $this, 'change_404_template' ), 999 ); 173 168 174 169 $posts[] = get_post( $pageid ); … … 209 204 } 210 205 206 // this function overrides the page template in compatibilty mode 207 function change_404_template( $template ) { 208 return $this->template; 209 } 210 211 211 // send a 404 HTTP header - Standard Mode 212 212 function do_404_header_standard_mode() { … … 335 335 global $pagenow; 336 336 if( 'edit.php' == $pagenow && ( get_query_var( 'post_type' ) && 'page' == get_query_var( 'post_type' ) ) && !current_user_can( 'create_users' ) ) { 337 $query->set( 'post__not_in', array( $this->settings['404page_page_id'] ) ); 338 } 339 return $query; 340 } 341 342 // this function hides the selected page from search 343 function exclude_404page_from_search( $query ) { 344 if ( $query->is_search ) { 337 345 $query->set( 'post__not_in', array( $this->settings['404page_page_id'] ) ); 338 346 } … … 386 394 </div> 387 395 <?php 388 }389 390 // show a dismissible notice391 function admin_notice() {392 if ( current_user_can( 'manage_options' ) ) {393 echo '<div class="notice notice-info is-dismissible" id="404page_admin_notice"><p><strong>404page Plugin:</strong> ';394 if ( defined( 'CUSTOMIZR_VER' ) ) {395 // Customizr Theme396 _e( 'Customizr Theme detected. The 404page Plugin works in Customizr Compatibility Mode.', '404page' );397 } elseif ( defined( 'ICL_SITEPRESS_VERSION' ) ) {398 // WPML399 _e( 'WPML Plugin detected. Operating Method is set to Compatibility Mode automatically to make the 404page Plugin work with WPML.', '404page' );400 } elseif ( defined( 'POLYLANG_VERSION' ) ) {401 // Polylang402 _e( 'Polylang Plugin detected. Operating Method is set to Compatibility Mode automatically to make the 404page Plugin work with Polylang.', '404page' );403 } elseif ( defined( 'SITEORIGIN_PANELS_VERSION' ) ) {404 // Page Builder by SiteOrigin405 _e( 'Page Builder by SiteOrigin Plugin detected. Operating Method is set to Compatibility Mode automatically to make the 404page Plugin work with Page Builder by SiteOrigin.', '404page' );406 } elseif ( class_exists( 'bbPress' ) ) {407 // bbPress408 _e( 'bbPress Plugin detected. Operating Method is set to Compatibility Mode automatically to make the 404page Plugin work with bbPress.', '404page' );409 } elseif ( function_exists( 'wpsupercache_activate' ) ) {410 // WP Super Cache411 _e( 'WP Super Cache Plugin detected. Please check Settings!', '404page' );412 } else {413 _e( 'Please check Operating Method.', '404page' );414 }415 echo '<br /><a href="' . admin_url( 'themes.php?page=404pagesettings' ) . '">' . __( 'Settings', '404page' ) . '</a>';416 echo '</p></div>';417 }418 }419 420 // dismiss the notice (AJAX)421 function dismiss_admin_notice() {422 update_option( '404page_notice_dismissed', 'DISMISSED' );423 }424 425 // Reset dismiss state for notice on plugin activation426 function init_admin_notice( $network_wide ) {427 global $wpdb;428 if ( is_multisite() && $network_wide ) {429 $current_blog = $wpdb->blogid;430 $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );431 foreach ( $blog_ids as $blog_id ) {432 switch_to_blog( $blog_id );433 delete_option( '404page_notice_dismissed' );434 }435 switch_to_blog( $current_blog );436 } else {437 delete_option( '404page_notice_dismissed' );438 }439 396 } 440 397
Note: See TracChangeset
for help on using the changeset viewer.