-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmycred-module-br-social-share.php
180 lines (162 loc) · 9.41 KB
/
mycred-module-br-social-share.php
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
if ( ! defined( 'myCRED_VERSION' ) ) exit;
/**
* myCRED_Module_Social_Share class
* @since 2.2
* @version 1.0
*/
if ( ! class_exists( 'myCRED_Module_OB_Social_Share' ) ) :
class myCRED_Module_BR_Social_Share extends myCRED_Module
{
/**
* Construct
* @since 2.2
* @version 1.0
*/
public function __construct( $type = MYCRED_DEFAULT_TYPE_KEY ) {
parent::__construct( 'myCRED_Module_BR_Social_Share', array(
'module_name' => 'br_social_share',
'defaults' => array(
'enable_open_badge_ss' => 0,
'facebook' => '1',
'twitter' => '1',
'linkedin' => '1',
'pinterest' => '1',
'button_style' => 'button_style',
'enable_fb' => '1',
'enable_twitter' => '1',
'enable_li' => '1',
'enable_pt' => '1'
),
'accordion' => false,
'register' => false,
'add_to_core' => true
), $type );
}
/**
* Load
* @since 2.2
* @version 1.0
*/
public function load()
{
add_action( 'mycred_admin_open_badge_setting', array( $this, 'after_general_settings' ), 20 );
add_filter( 'mycred_save_core_prefs', array( $this, 'sanitize_extra_settings' ), 80, 3 );
}
/**
* Settings Page
* @since 2.2
* @version 1.0
*/
public function after_general_settings( $mycred = NULL )
{
$settings = $this->br_social_share;
?>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="form-group">
<div class="checkbox" >
<label for="<?php echo esc_attr( $this->field_id( 'enable_open_badge_ss' ) ); ?>">
<input type="checkbox" name="<?php echo esc_attr( $this->field_name( 'enable_open_badge_ss' ) ); ?>" id="<?php echo esc_attr( $this->field_id( 'enable_open_badge_ss' ) ); ?>" <?php checked( $settings['enable_open_badge_ss'], 1 ); ?> value="1">
Enable Open Badge Social Sharing
</label>
</div>
</div>
<div class="form-group">
<div class="checkbox" >
<label for="<?php echo esc_attr( $this->field_id( 'enable_fb' ) ); ?>">
<input type="checkbox" name="<?php echo esc_attr( $this->field_name( 'enable_fb' ) ); ?>" id="<?php echo esc_attr( $this->field_id( 'enable_fb' ) ); ?>" <?php checked( $settings['enable_fb'], 1 ); ?> value="1">
Show Facebook button
</label>
</div>
</div>
<div class="form-group">
<div class="checkbox" >
<label for="<?php echo esc_attr( $this->field_id( 'enable_twitter' ) ); ?>">
<input type="checkbox" name="<?php echo esc_attr( $this->field_name( 'enable_twitter' ) ); ?>" id="<?php echo esc_attr( $this->field_id( 'enable_twitter' ) ); ?>" <?php checked( $settings['enable_twitter'], 1 ); ?> value="1">
Show Twitter button
</label>
</div>
</div>
<div class="form-group">
<div class="checkbox" >
<label for="<?php echo esc_attr( $this->field_id( 'enable_li' ) ); ?>">
<input type="checkbox" name="<?php echo esc_attr( $this->field_name( 'enable_li' ) ); ?>" id="<?php echo esc_attr( $this->field_id( 'enable_li' ) ); ?>" <?php checked( $settings['enable_li'], 1 ); ?> value="1">
Show LinkedIn button
</label>
</div>
</div>
<div class="form-group">
<div class="checkbox" >
<label for="<?php echo esc_attr( $this->field_id( 'enable_pt' ) ); ?>">
<input type="checkbox" name="<?php echo esc_attr( $this->field_name( 'enable_pt' ) ); ?>" id="<?php echo esc_attr( $this->field_id( 'enable_pt' ) ); ?>" <?php checked( $settings['enable_pt'], 1 ); ?> value="1">
Show Pinterest button
</label>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<h3>Social Sharing button style</h3>
<div class="form-group clearfix">
<label>
<input type="radio" name="<?php echo esc_attr( $this->field_name( 'button_style' ) ); ?>" <?php echo $this->is_checked( 'button_style' ) ? 'checked' : ''; ?> value="button_style">Button Style
</label>
<button type="button" class="mycred-social-icons mycred-social-icon-facebook"><a href="javascript:void(0)">facebook</a></button>
<button type="button" class="mycred-social-icons mycred-social-icon-twitter"><a href="javascript:void(0)">twitter</a></button>
<button type="button" class="mycred-social-icons mycred-social-icon-linkedin"><a href="javascript:void(0)">linkedin</a></button>
<button type="button" class="mycred-social-icons mycred-social-icon-pinterest"><a href="javascript:void(0)">pinterest</a></button>
</div>
<div class="form-group clearfix">
<label>
<input type="radio" name="<?php echo esc_attr( $this->field_name( 'button_style' ) ); ?>" <?php echo $this->is_checked( 'icon_style' ) ? 'checked' : ''; ?> value="icon_style">Icon Style
</label>
<a href="javascript:void(0)" class="mycred-social-icons mycred-social-icon-facebook"></a>
<a href="javascript:void(0)" class="mycred-social-icons mycred-social-icon-twitter"></a>
<a href="javascript:void(0)" class="mycred-social-icons mycred-social-icon-linkedin"></a>
<a href="javascript:void(0)" class="mycred-social-icons mycred-social-icon-pinterest"></a>
</div>
<div class="form-group clearfix">
<label>
<input type="radio" name="<?php echo esc_attr( $this->field_name( 'button_style' ) ); ?>" <?php echo $this->is_checked( 'text_style' ) ? 'checked' : ''; ?> value="text_style">Text Style
</label>
<button type="button" class="facebook social-text"><a href="javascript:void(0)">facebook</a></button>
<button type="button" class="twitter social-text"><a href="javascript:void(0)">twitter</a></button>
<button type="button" class="linkedin social-text"><a href="javascript:void(0)">linkedin</a></button>
<button type="button" class="pinterest social-text"><a href="javascript:void(0)">pinterest</a></button>
</div>
</div>
</div>
<?php
}
public function is_checked( $key )
{
if( $this->br_social_share['button_style'] == $key )
return true;
return false;
}
public function sanitize_extra_settings( $new_data, $data, $core )
{
$new_data['br_social_share']['enable_open_badge_ss'] = ( isset( $data['br_social_share']['enable_open_badge_ss'] ) ) ? $data['br_social_share']['enable_open_badge_ss'] : '0';
$new_data['br_social_share']['button_style'] = ( isset( $data['br_social_share']['button_style'] ) ) ? $data['br_social_share']['button_style'] : 'button_style';
$new_data['br_social_share']['enable_fb'] = ( isset( $data['br_social_share']['enable_fb'] ) ) ? $data['br_social_share']['enable_fb'] : '0';
$new_data['br_social_share']['enable_twitter'] = ( isset( $data['br_social_share']['enable_twitter'] ) ) ? $data['br_social_share']['enable_twitter'] : '0';
$new_data['br_social_share']['enable_li'] = ( isset( $data['br_social_share']['enable_li'] ) ) ? $data['br_social_share']['enable_li'] : '0';
$new_data['br_social_share']['enable_pt'] = ( isset( $data['br_social_share']['enable_pt'] ) ) ? $data['br_social_share']['enable_pt'] : '0';
return apply_filters( 'mycred_brss_sanitize_settings', $new_data, $data, $core );
}
}
endif;
add_action( 'wp_loaded', 'mycred_load_br_social_share');
if( !function_exists( 'mycred_load_br_social_share' ) ):
function mycred_load_br_social_share()
{
//Activate only if badges active
if( class_exists( 'myCRED_Badge' ) )
{
$mycred_open_badge_socail_share = new myCRED_Module_BR_Social_Share();
$mycred_open_badge_socail_share->load();
}
}
endif;