Skip to content

Commit

Permalink
= 4.2.7.5.1 =
Browse files Browse the repository at this point in the history
  • Loading branch information
tungnxt89 committed Jan 21, 2025
1 parent b809284 commit ee8c9c3
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions inc/class-lp-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public function __construct() {
return;
}

if ( is_admin() ) {
return;
}

add_action( 'init', array( $this, 'add_rewrite_tags' ), 1000 );
add_action( 'init', array( $this, 'add_rewrite_endpoints' ) );
add_filter( 'option_rewrite_rules', [ $this, 'update_option_rewrite_rules' ], 1 );
Expand Down Expand Up @@ -286,23 +290,31 @@ public function add_rewrite_rules_profile( &$rules ) {
*
* @return mixed|array
* @since 4.2.2
* @version 1.0.2
* @version 1.0.3
* @see get_option() hook in this function.
*/
public function update_option_rewrite_rules( $wp_rules ) {
// Check it is called from WP_Rewrite class
$debug_backtrace = debug_backtrace();
if ( ! isset( $debug_backtrace[4] )
|| ! isset( $debug_backtrace[4]['class'] )
|| $debug_backtrace[4]['class'] != WP_Rewrite::class ) {

// Find call from WP_Rewrite class
$found = false;
foreach ( $debug_backtrace as $trace ) {
if ( isset( $trace['class'] ) && $trace['class'] == WP_Rewrite::class ) {
$found = true;
break;
}
}

if ( ! $found ) {
return $wp_rules;
}

static $handled = false;
/*static $handled = false;
if ( $handled ) {
return $wp_rules;
}
$handled = true;
$handled = true;*/

if ( ! is_array( $wp_rules ) ) {
return $wp_rules;
Expand Down

0 comments on commit ee8c9c3

Please sign in to comment.