Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 46 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
||
| 1 | <?php |
| 2 | |
| 3 | use NewfoldLabs\WP\Module\SSO\SSO_AJAX_Handler; |
| 4 | use NewfoldLabs\WP\Module\SSO\SSO_Hosting_Login; |
| 5 | use NewfoldLabs\WP\Module\SSO\SSO_REST_Controller; |
| 6 | |
| 7 | new SSO_AJAX_Handler(); |
| 8 | new SSO_Hosting_Login(); |
| 9 | |
| 10 | add_action( |
| 11 | 'rest_api_init', |
| 12 | function () { |
| 13 | $instance = new SSO_REST_Controller(); |
| 14 | $instance->register_routes(); |
| 15 | } |
| 16 | ); |
| 17 | |
| 18 | add_action( |
| 19 | 'cli_init', |
| 20 | function () { |
| 21 | WP_CLI::add_command( |
| 22 | 'newfold sso', |
| 23 | 'NewfoldLabs\WP\Module\SSO\SSO_CLI', |
| 24 | array( |
| 25 | 'shortdesc' => 'Single sign-on functionality for WordPress.', |
| 26 | 'longdesc' => 'Handle single sign-on from Newfold hosting platforms and get magic link.' . |
| 27 | PHP_EOL . 'Associative Args: --username --role --email --id --min=MINUTES_UNTIL_EXPIRE --url-only', |
| 28 | ) |
| 29 | ); |
| 30 | } |
| 31 | ); |
| 32 | |
| 33 | add_action( |
| 34 | 'init', |
| 35 | function () { |
| 36 | load_plugin_textdomain( |
| 37 | 'wp-module-sso', |
| 38 | false, |
| 39 | NFD_SSO_DIR . '/languages' |
| 40 | ); |
| 41 | }, |
| 42 | 100 |
| 43 | ); |
| 44 | |
| 45 | add_action( |
| 46 | 'login_message', |
| 47 | function () { |
| 48 | $error = sanitize_key( $_GET['error'] ?? '' ); |
| 49 | if ( ! empty( $error ) ) { |
| 50 | $message = ''; |
| 51 | switch ( $error ) { |
| 52 | case 'invalid_username': |
| 53 | $message = __( 'SSO failed: username cannot contain invalid characters.', 'wp-module-sso' ); |
| 54 | break; |
| 55 | default: |
| 56 | $message = __( 'An unknown error occurred. Please try again.', 'wp-module-sso' ); |
| 57 | break; |
| 58 | } |
| 59 | return "<div class='login-error' style='color: red; font-weight: bold;'>{$message}</div>"; |
| 60 | } |
| 61 | } |
| 62 | ); |