-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomment_form_main.php
More file actions
executable file
·146 lines (129 loc) · 4.3 KB
/
comment_form_main.php
File metadata and controls
executable file
·146 lines (129 loc) · 4.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
class Comment_Form_Main {
/**
* array with plugin options and settings
*
* @since 1.0.0
*/
public $options = array();
/**
* initialize the plugin
*
* @since 1.0
*/
public function __construct() {
// load options
// load plugin text domain
add_action('plugins_loaded', array($this, 'load_plugin_textdomain'));
}
/**
* get and load plugin options
*
* @since 1.0.0
*
* @param str $field which option to return
* empty to return all of them
*/
public function options($field = false){
$defaults = $this->get_default_options();
$options = wp_parse_args(get_option('commentform_settings', array()), $defaults);
$this->options = $options;
if($field != '' && isset($options[$field])) {
return $options[$field];
} elseif($field != false && !isset($options[$field])) {
return false;
} else {
return $options;
}
}
/**
* pro badge wrap generator
*
* @since 1.0.0
*
*/
public function generate_unlock_badge() {
$images_url = plugin_dir_url( SNAZZY_COMMENTS__FILE__ ) . 'admin/assets/images/'; ?>
<?php if (!sc_fs()->is__premium_only()) : ?>
<a href="" target="_blank" class="unlock-pill">
<img src="<?php echo esc_url( $images_url . 'lock.svg' ) ?>" alt="">
Unlock
</a>
<?php endif; ?>
<?php }
/**
* checkbox component element wrap generator
*
* @since 1.0.0
*
*
*/
public function generate_checkbox($name, $value, $checked_attr, $is_pro, $label) { ?>
<label class="checkbox-wrapper <?php echo $is_pro ? ( sc_fs()->is__premium_only() ? '' : 'disabled' ) : '' ?>">
<input type="checkbox"
name="<?php echo $name ?>"
value="<?php echo $value ?>"
<?php echo $checked_attr ?>
<?php echo $is_pro ? ( sc_fs()->is__premium_only() ? '' : 'disabled' ) : '' ?>>
<span class="thumb"></span>
<?php if ( !empty( $label ) ) : ?>
<span><?php _e($label, 'snazzy-comments') ?></span>
<?php endif; ?>
<?php echo $is_pro ? $this->generate_unlock_badge() : null; ?>
</label>
<?php }
/**
* toggle switch component element wrap generator
*
* @since 1.0.0
*
*
*/
public function generate_toggle($name, $value, $checked_attr, $is_pro, $label, ?string $showHideElementSelector) { ?>
<div class="toggle-switch">
<input type="checkbox"
name="<?php echo $name ?>"
value="<?php echo $value ?>"
<?php echo $checked_attr ?>
<?php echo $is_pro ? ( sc_fs()->is__premium_only() ? '' : 'disabled' ) : '' ?>
<?php echo $showHideElementSelector ? 'data-show-hide-elements="' . $showHideElementSelector . '"' : ''?>>
<?php if ( !empty( $label ) ) : ?>
<span><?php _e($label, 'snazzy-comments') ?></span>
<?php endif; ?>
<?php echo $is_pro ? $this->generate_unlock_badge() : null; ?>
</div>
<?php }
/**
* prepare default options
*
* @since 1.0.0
*/
public function get_default_options(){
$req = get_option( 'require_name_email' );
$required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' );
$defaults = array(
'hide_notes_after' => 0,
'hide_notes_before' => 0,
'cookies_consent' => 0,
'remove_email' => false,
'remove_email_css' => false,
'hide_url' => 0,
'hide_url_css' => false,
'remove_cookies' => false,
'remove_cookies_css' => false,
'text_after' => '',
'text_before' => '',
'cookies_text' => '',
'two_columns' => false
);
return $defaults;
}
/**
* Load the plugin text domain for translation.
*
* @since 1.2.0
*/
public function load_plugin_textdomain() {
load_plugin_textdomain("commentform", false, dirname(plugin_basename(__FILE__)) . '/languages/');
}
}