Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions lib/Nicholas.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ class Nicholas extends Underpin {
*/
protected $asset_url = '';

/**
* Compatibility mode.
*
* @since 1.1.1
*
* @var ?bool if in compatibility mode, otherwise false.
*/
protected $use_compatibility_mode = null;

/**
* Setup plugin params using the provided __FILE__
*
Expand Down Expand Up @@ -226,13 +235,15 @@ public static function flush_session_cache() {
* @return bool true if compatibility mode should be used, otherwise false.
*/
public function use_compatibility_mode() {
return true === $this->apply_filters( 'use_compatibility_mode', new Accumulator( [
'default' => false,
'url' => wp_parse_url( $_SERVER['REQUEST_URI'] ),
'valid_callback' => function ( $state ) {
return is_bool( $state );
},
] ) );
if ( ! isset( $this->use_compatibility_mode ) ) {
$this->use_compatibility_mode = true === $this->apply_filters( 'use_compatibility_mode', new Accumulator( [
'default' => false,
'url' => wp_parse_url( $_SERVER['REQUEST_URI'] ),
'valid_callback' => 'is_bool',
] ) );
}

return $this->use_compatibility_mode;
}

/**
Expand Down Expand Up @@ -358,7 +369,7 @@ public static function with_path( string $path, callable $callback ) {
$post_type->add_rewrite_rules();
}

foreach( get_taxonomies([],'objects') as $taxonomy ){
foreach ( get_taxonomies( [], 'objects' ) as $taxonomy ) {
$taxonomy->add_rewrite_rules();
}

Expand Down Expand Up @@ -399,9 +410,9 @@ protected function _setup() {
'description' => 'Clears the current session data when the server instructs it to-do so.',
// Enqueue Session manager on admin and login screens
'middlewares' => [
new \Underpin\Scripts\Factories\Enqueue_Admin_Script('admin_enqueue'),
new \Underpin\Scripts\Factories\Enqueue_Login_Script('login_enqueue')
]
new \Underpin\Scripts\Factories\Enqueue_Admin_Script( 'admin_enqueue' ),
new \Underpin\Scripts\Factories\Enqueue_Login_Script( 'login_enqueue' ),
],
] );

/**
Expand Down