1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/** |
3
|
|
|
* @package Freemius |
4
|
|
|
* @copyright Copyright (c) 2015, Freemius, Inc. |
5
|
|
|
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 |
6
|
|
|
* @since 1.2.2.7 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
10
|
|
|
exit; |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class Zerif_Customizer_Theme_Info_Main |
15
|
|
|
* |
16
|
|
|
* @since 1.0.0 |
17
|
|
|
* @access public |
18
|
|
|
*/ |
19
|
|
|
class FS_Customizer_Support_Section extends WP_Customize_Section { |
|
|
|
|
20
|
|
|
|
21
|
|
|
function __construct( $manager, $id, $args = array() ) { |
|
|
|
|
22
|
|
|
$manager->register_section_type( 'FS_Customizer_Support_Section' ); |
23
|
|
|
|
24
|
|
|
parent::__construct( $manager, $id, $args ); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* The type of customize section being rendered. |
29
|
|
|
* |
30
|
|
|
* @since 1.0.0 |
31
|
|
|
* @access public |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
public $type = 'freemius-support-section'; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var Freemius |
38
|
|
|
*/ |
39
|
|
|
public $fs = null; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Add custom parameters to pass to the JS via JSON. |
43
|
|
|
* |
44
|
|
|
* @since 1.0.0 |
45
|
|
|
*/ |
46
|
|
|
public function json() { |
47
|
|
|
$json = parent::json(); |
48
|
|
|
|
49
|
|
|
$is_contact_visible = $this->fs->is_page_visible( 'contact' ); |
50
|
|
|
$is_support_visible = $this->fs->is_page_visible( 'support' ); |
51
|
|
|
|
52
|
|
|
$json['theme_title'] = $this->fs->get_plugin_name(); |
53
|
|
|
|
54
|
|
|
if ( $is_contact_visible && $is_support_visible ) { |
55
|
|
|
$json['theme_title'] .= ' ' . $this->fs->get_text( 'support' ); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
if ( $is_contact_visible ) { |
59
|
|
|
$json['contact'] = array( |
60
|
|
|
'label' => $this->fs->get_text( 'contact-us' ), |
61
|
|
|
'url' => $this->fs->contact_url(), |
62
|
|
|
); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
if ( $is_support_visible ) { |
66
|
|
|
$json['support'] = array( |
67
|
|
|
'label' => $this->fs->get_text( 'support-forum' ), |
68
|
|
|
'url' => $this->fs->get_support_forum_url() |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
return $json; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Outputs the Underscore.js template. |
77
|
|
|
* |
78
|
|
|
* @since 1.0.0 |
79
|
|
|
*/ |
80
|
|
|
protected function render_template() { |
81
|
|
|
?> |
82
|
|
|
<li id="fs_customizer_support" |
83
|
|
|
class="accordion-section control-section control-section-{{ data.type }} cannot-expand"> |
84
|
|
|
<h3 class="accordion-section-title"> |
85
|
|
|
<span>{{ data.theme_title }}</span> |
86
|
|
|
<# if ( data.contact && data.support ) { #> |
87
|
|
|
<div class="button-group"> |
88
|
|
|
<# } #> |
89
|
|
|
<# if ( data.contact ) { #> |
90
|
|
|
<a class="button" href="{{ data.contact.url }}" target="_blank">{{ data.contact.label }} </a> |
91
|
|
|
<# } #> |
92
|
|
|
<# if ( data.support ) { #> |
93
|
|
|
<a class="button" href="{{ data.support.url }}" target="_blank">{{ data.support.label }} </a> |
94
|
|
|
<# } #> |
95
|
|
|
<# if ( data.contact && data.support ) { #> |
96
|
|
|
</div> |
97
|
|
|
<# } #> |
98
|
|
|
</h3> |
99
|
|
|
</li> |
100
|
|
|
<?php |
101
|
|
|
} |
102
|
|
|
} |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.