Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 29 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| Application | |
0.00% |
0 / 29 |
|
0.00% |
0 / 1 |
72 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 29 |
|
0.00% |
0 / 1 |
72 | |||
| 1 | <?php |
| 2 | namespace NewfoldLabs\WP\Module\Onboarding; |
| 3 | |
| 4 | use NewfoldLabs\WP\Module\Onboarding\Compatibility\Status; |
| 5 | use NewfoldLabs\WP\Module\Onboarding\RestApi\RestApi; |
| 6 | use NewfoldLabs\WP\Module\Onboarding\Services\PluginService; |
| 7 | use NewfoldLabs\WP\ModuleLoader\Container; |
| 8 | use NewfoldLabs\WP\Module\Onboarding\Data\Options; |
| 9 | use NewfoldLabs\WP\Module\Onboarding\Services\StatusService; |
| 10 | |
| 11 | use function NewfoldLabs\WP\ModuleLoader\container; |
| 12 | |
| 13 | /** |
| 14 | * Primary instantiation of Onboarding Application. |
| 15 | */ |
| 16 | final class Application { |
| 17 | |
| 18 | /** |
| 19 | * The Plugin container. |
| 20 | * |
| 21 | * @var Container |
| 22 | */ |
| 23 | protected $container; |
| 24 | |
| 25 | /** |
| 26 | * Arguments for Onboarding. |
| 27 | * |
| 28 | * @var array |
| 29 | */ |
| 30 | protected $args; |
| 31 | |
| 32 | /** |
| 33 | * Setup module container and register functionality using WordPress Action Hooks. |
| 34 | * |
| 35 | * @param Container $container - Newfold Labs Module Container |
| 36 | */ |
| 37 | public function __construct( Container $container ) { |
| 38 | $this->container = $container; |
| 39 | |
| 40 | $defaults = array( |
| 41 | 'option_name' => 'nfd_onboarding', |
| 42 | 'admin_screen_id' => container()->plugin()->id, |
| 43 | 'admin_app_url' => \admin_url( 'admin.php?page=nfd-onboarding' ), |
| 44 | ); |
| 45 | |
| 46 | $this->args = \wp_parse_args( |
| 47 | $container->has( 'onboarding' ) ? $container['onboarding'] : array(), |
| 48 | $defaults |
| 49 | ); |
| 50 | |
| 51 | if ( is_readable( NFD_ONBOARDING_DIR . '/vendor/autoload.php' ) ) { |
| 52 | require_once NFD_ONBOARDING_DIR . '/vendor/autoload.php'; |
| 53 | } |
| 54 | |
| 55 | \do_action( 'nfd_module_onboarding_pre_init' ); |
| 56 | |
| 57 | // Reset the stored Compatibility Status every time WP Core is updated. |
| 58 | \add_action( '_core_updated_successfully', array( Status::class, 'reset' ) ); |
| 59 | |
| 60 | \add_filter( 'login_redirect', array( LoginRedirect::class, 'wplogin' ), 10, 3 ); |
| 61 | \add_filter( 'newfold_sso_success_url', array( LoginRedirect::class, 'sso' ), 10 ); |
| 62 | \add_filter( |
| 63 | Options::get_option_name( 'redirect' ) . '_disable', |
| 64 | array( LoginRedirect::class, 'remove_handle_redirect_action' ) |
| 65 | ); |
| 66 | |
| 67 | if ( defined( '\\WP_CLI' ) && \WP_CLI ) { |
| 68 | new WP_CLI(); |
| 69 | } |
| 70 | |
| 71 | if ( Permissions::is_authorized_admin() || Permissions::rest_is_authorized_admin() ) { |
| 72 | new RestAPI(); |
| 73 | new WP_Admin(); |
| 74 | new ExternalRedirectInterceptor(); |
| 75 | } |
| 76 | |
| 77 | if ( Permissions::is_authorized_admin() ) { |
| 78 | StatusService::track(); |
| 79 | } |
| 80 | |
| 81 | \do_action( 'nfd_module_onboarding_post_init' ); |
| 82 | } |
| 83 | } |