-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Moves files into separate directories * Adds login script middleware. #9
- Loading branch information
1 parent
4816f95
commit 396615d
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
|
||
namespace Underpin_Scripts\Factories; | ||
|
||
|
||
use Underpin\Abstracts\Middleware; | ||
use Underpin_Scripts\Abstracts\Script; | ||
use function Underpin\underpin; | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
class Enqueue_Login_Script extends Middleware { | ||
|
||
public $description = 'Sets up script params necessary for AJAX and REST requests'; | ||
public $name = 'REST Middleware'; | ||
|
||
function do_actions() { | ||
if ( $this->loader_item instanceof Script ) { | ||
add_action( 'login_enqueue_scripts', [ $this->loader_item, 'enqueue' ] ); | ||
} else { | ||
underpin()->logger()->log( 'warning', 'rest_middleware_action_failed_to_run', 'Middleware action failed to run. Rest_Middleware expects to run on a Script loader.', [ | ||
'loader' => get_class( $this->loader_item ), | ||
'expects' => 'Underpin_Scripts\Abstracts\Script', | ||
] ); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters