Settings_Page::on_load()
Page on_load callback
Source
File: includes/libs/admin/page/settings-page.class.php
	public function on_load() {
		$options = $this->options_obj()->get_options();
		$this->vimeo_oauth = new Vimeo_Oauth(
			$options['vimeo_consumer_key'],
			$options['vimeo_secret_key'],
			$options['oauth_token'],
			// you must use this instead of menu_page_url() to avoid API error
			admin_url( 'edit.php?post_type=' . $this->cpt->get_post_type() . '&page=' . $this->get_menu_slug() )
		);
		if( $this->set_unauth_token() ) {
			$options = $this->options_obj()->get_options( true );
		}
		/**
		 * Action triggered on settings page load event.
		 *
		 * @param Options $options Vimeotheque\Options\Options object reference.
		 */
		do_action( 'vimeotheque\admin\page\settings_load', $this->options_obj() );
		if( isset( $_POST['cvm_wp_nonce'] ) ){
			if( check_admin_referer('cvm-save-plugin-settings', 'cvm_wp_nonce') ){
				/**
				 * Action running before the settings are saved.
				 */
				do_action( 'vimeotheque\admin\before_settings_save' );
				$updated_settings = $this->update_settings();
				/**
				 * Action running after the settings are saved.
				 *
				 * @param array $updated_settings The saved settings array.
				 */
				do_action( 'vimeotheque\admin\after_settings_save', $updated_settings );
				/**
				 * Action running before the player settings are saved.
				 */
				do_action( 'vimeotheque\admin\before_player_settings_save' );
				$player_settings = $this->update_player_settings();
				/**
				 * Action running after the player settings are saved.
				 *
				 * @param array $player_settings The player settings saved in database.
				 */
				do_action( 'vimeotheque\admin\after_player_settings_save', $player_settings );
			}
			wp_redirect( 'edit.php?post_type=' . $this->cpt->get_post_type() . '&page=cvm_settings' );
			die();
		}
		if( isset( $_GET[ 'clear_oauth' ] ) && 'true' == $_GET[ 'clear_oauth' ] ){
			if( check_admin_referer( 'cvm-clear-oauth-token', 'cvm_nonce' ) ){
				$options['vimeo_consumer_key'] = '';
				$options['vimeo_secret_key'] = '';
				$options['oauth_token']	= '';
				$options['oauth_secret'] = '';
				$options['vimeo_access_granted'] = false;
				$this->options_obj()->update_options( $options );
			}
			wp_redirect( 'edit.php?post_type=' . $this->cpt->get_post_type() . '&page=cvm_settings' );
			die();
		}
		$this->_enqueue_assets();
	}
			