123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- class Keyring_Service_Example extends Keyring_Service {
- const NAME = 'example';
- const LABEL = 'Example Service';
- function __construct() {
-
- parent::__construct();
-
-
-
-
- add_action( 'keyring_example_request_ui', array( $this, 'request_ui' ) );
- add_action( 'keyring_example_verify_ui', array( $this, 'verify_ui' ) );
-
-
-
-
- $this->requires_token( false );
- }
-
- function request_token() {
-
- }
-
- function get_display( Keyring_Access_Token $token ) {
- return $token->token;
- }
-
- function request_ui() {
- Keyring::admin_page_header();
- echo '<p>This is just an example of how you could display some sort of custom UI if you needed to.</p>';
- echo '<p>Clicking the button below will generate a random token and store it as an example.</p>';
- echo '<p class="submitbox">';
- echo '<a href="' . esc_url( Keyring_Util::admin_url( 'example', array( 'action' => 'verify' ) ) ) . '" class="button-primary">' . __( 'Continue', 'keyring' ) . '</a>';
- echo '<a href="' . esc_attr( $_SERVER['HTTP_REFERER'] ) . '" class="submitdelete" style="margin-left:2em;">Abort</a>';
- echo '</p>';
- Keyring::admin_page_footer();
- }
-
- function verify_token() {
-
- $token = sha1( time() . mt_rand( 0, 1000 ) . time() );
- $meta = array( 'time' => time(), 'user' => get_current_user() );
- $this->store_token( $token, $meta );
- }
-
- function request( $url, array $params = array() ) {
-
- }
-
- function verify_ui() {
- Keyring::admin_page_header();
- echo '<p>As an example, we just randomly generated a token and saved it in the token store. When you go back to your Connections listing, you should see it listed there under "Example Service".</p>';
- echo '<p><a href="' . esc_url( Keyring_Util::admin_url() ) . '" class="button-primary">' . __( 'Done', 'keyring' ) . '</a>';
- Keyring::admin_page_footer();
- }
- }
- add_action( 'keyring_load_services', array( 'Keyring_Service_Example', 'init' ) );
|