TitanFrameworkOptionAweber::display()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 23
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 23
rs 9.0856
cc 2
eloc 16
nc 1
nop 0
1
<?php
2
3
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
5
class TitanFrameworkOptionAweber extends TitanFrameworkOption {
6
7
	public $defaultSecondarySettings = array(
8
		'placeholder' => '', // show this when blank
9
		'is_password' => false,
10
	);
11
12
	/*public function __construct() {
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
13
		add_action( 'wp_ajax_tf_check_license', array( $this, 'check_license' ) );
14
	}*/
15
16
	/*
17
	 * Display for options and meta
18
	 */
19
	public function display() {
20
21
		$url = WPBO_Aweber::get_authorization_url();
22
23
		$this->echoOptionHeader();
24
		printf("<input class=\"regular-text wpbo-aweber\" name=\"%s\" placeholder=\"%s\" id=\"%s\" type=\"%s\" value=\"%s\" />",
25
			$this->getID(),
26
			$this->settings['placeholder'],
27
			$this->getID(),
28
			$this->settings['is_password'] ? 'password' : 'text',
29
			esc_attr( $this->getValue() ) );
30
31
		printf( " <a href=\"%s\" id=\"wpbo-aweber-auth\" class=\"button-secondary\" target=\"_blank\">%s</a>", $url, __( 'Authorize', 'wpbo' ) ); ?>
32
33
		<div id="tav-license-status">
34
			<div id="tav-license-status-empty" style="display: none; color: red;" class="tav-license-status"><p><?php _e( 'You did not enter your Envato purchase code.', 'wpbp' ); ?></p></div>
35
			<div id="tav-license-status-error" style="display: none; color: red;" class="tav-license-status"><p><?php _e( 'Validation of your Envato purchase code failed.', 'wpbp' ); ?></p></div>
36
			<div id="tav-license-status-ajaxfail" style="display: none; color: red;" class="tav-license-status"><p><?php _e( 'We were not able to check your Envato purchase code. Please try again later.', 'wpbp' ); ?></p></div>
37
			<div id="tav-license-status-valid" style="display: none; color: green;" class="tav-license-status"><p><?php _e( 'The license you entered is valid.', 'wpbp' ); ?></p></div>
38
		</div>
39
40
		<?php $this->echoOptionFooter();
41
	}
42
43
	/*
44
	 * Display for theme customizer
45
	 */
46
	public function registerCustomizerControl( $wp_customize, $section, $priority = 1 ) {
47
		$wp_customize->add_control( new TitanFrameworkCustomizeControl( $wp_customize, $this->getID(), array(
48
			'label' => $this->settings['name'],
49
			'section' => $section->settings['id'],
50
			'settings' => $this->getID(),
51
			'description' => $this->settings['desc'],
52
			'priority' => $priority,
53
		) ) );
54
	}
55
}