AnsPress_Avatar_Hook::option_form()

Description #

Register options of Avatar addon.

Changelog #

VersionDescription
4.1.0Introduced.

Source #

File: addons/free/avatar.php

	public static function option_form() {
		$opt = ap_opt();

		ob_start();
		?>
			<script type="text/javascript">
				jQuery(document).ready(function($){
					$('#ap-clear-avatar').click(function(e){
						e.preventDefault();
						$.ajax({
							url: '<?php echo admin_url( "admin-ajax.php" ); ?>',
							data: {
								action: 'ap_clear_avatar_cache',
								__nonce: '<?php echo wp_create_nonce( "clear_avatar_cache" ); ?>'
							},
							success: function(data){
								if(data==='success') alert('All avatar deleted');
							}
						});
					});
				});
			</script>
		<?php
		$js = ob_get_clean();

		$form = array(
			'submit_label' => __( 'Save add-on options', 'anspress-question-answer' ),
			'fields' => array(
				'clear_avatar_cache' => array(
					'label' => __( 'Clear Cache', 'anspress-question-answer' ),
					'html' => '<div class="ap-form-fields-in"><a id="ap-clear-avatar" href="#" class="button">' . __( 'Clear avatar cache', 'anspress-question-answer' ) . '</a></div>' .$js,
				),
				'avatar_font' => array(
					'label'   => __( 'Font family', 'anspress-question-answer' ),
					'desc'    => __( 'Select font family for avatar letters.', 'anspress-question-answer' ),
					'type'    => 'select',
					'options' => array(
						'calibri'         => 'Calibri',
						'Pacifico'        => 'Pacifico',
						'OpenSans'        => 'Open Sans',
						'Glegoo-Bold'     => 'Glegoo Bold',
						'DeliusSwashCaps' => 'Delius Swash Caps',
					),
					'value' => $opt['avatar_font'],
				),
				'avatar_force' => array(
					'label' => __( 'Force avatar', 'anspress-question-answer' ),
					'desc'  => __( 'Show AnsPress avatars by default instead of gravatar fallback. Useful in localhost development.', 'anspress-question-answer' ),
					'type'  => 'checkbox',
					'value' => $opt['avatar_force'],
				),
			),
		);

		return $form;
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment