-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.php
executable file
·208 lines (161 loc) · 7.91 KB
/
boot.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<?php
define('BIZPANDA_SOCIAL_LOCKER_DIR', dirname(__FILE__));
define('BIZPANDA_SOCIAL_LOCKER_URL', plugins_url( null, __FILE__ ));
if ( is_admin() ) require BIZPANDA_SOCIAL_LOCKER_DIR . '/admin/boot.php';
global $bizpanda;
/**
* Registers the Email Locker item.
*
* @since 1.0.0
*/
function opanda_register_social_locker( $items ) {
global $sociallocker;
$title = __('Social Locker', 'sociallocker');
$items['social-locker'] = array(
'name' => 'social-locker',
'type' => 'premium',
'title' => $title,
'help' => opanda_get_help_url('sociallocker'),
'description' => __('<p>Asks users to "pay with a like" or share to unlock content.</p><p>Perfect way to get more followers, attract social traffic and improve some social metrics.</p>', 'sociallocker'),
'shortcode' => 'sociallocker',
'plugin' => $sociallocker
);
return $items;
}
add_filter('opanda_items', 'opanda_register_social_locker', 1);
/**
* Adds options to print at the frontend.
*
* @since 1.0.0
*/
function opanda_social_locker_options( $options, $id ) {
global $post;
$options['groups'] = array('social-buttons');
$options['socialButtons'] = array();
$buttonOrder = 'twitter-tweet,facebook-like,google-plus';
$actualUrls = opanda_get_option('actual_urls', false);
$postUrl = !empty($post) ? get_permalink( $post->ID ) : null;
$postUrl = $actualUrls ? null : $postUrl;
$fbLikeUrl = opanda_get_dynamic_url( $id, 'facebook_like_url', $postUrl);
$fbShareUrl = opanda_get_dynamic_url( $id, 'facebook_share_url', $postUrl);
$twTweetUrl = opanda_get_dynamic_url( $id, 'twitter_tweet_url', $postUrl);
$twFollowUrl = opanda_get_dynamic_url( $id, 'twitter_follow_url', $postUrl);
$glPlusUrl = opanda_get_dynamic_url( $id, 'google_plus_url', $postUrl);
$glShareUrl = opanda_get_dynamic_url( $id, 'google_share_url', $postUrl);
$lnShareUrl = opanda_get_dynamic_url( $id, 'linkedin_share_url', $postUrl);
$options['socialButtons']['counters'] = opanda_get_item_option($id, 'show_counters', false, 1);
$options['socialButtons']['order'] = opanda_get_item_option($id, 'buttons_order', false, $buttonOrder);
$options['socialButtons']['facebook'] = array(
'appId' => opanda_get_option('facebook_appid', '117100935120196'),
'lang' => opanda_get_option('lang', 'en_GB'),
'version' => opanda_get_option('facebook_version', 'v1.0'),
'like' => array(
'url' => $fbLikeUrl,
'title' => opanda_get_item_option($id, 'facebook_like_title' ),
'theConfirmIssue' => opanda_get_item_option($id, 'facebook_like_confirm_issue' )
)
);
$options['socialButtons']['facebook']['share'] = array(
'url' => $fbShareUrl,
'shareDialog' => opanda_get_item_option($id, 'facebook_share_dialog' ),
'counter' => opanda_get_item_option($id, 'facebook_share_counter_url' ),
'title' => opanda_get_item_option($id, 'facebook_share_title' ),
'name' => opanda_get_item_option($id, 'facebook_share_message_name' ),
'caption' => opanda_get_item_option($id, 'facebook_share_message_caption' ),
'description' => opanda_get_item_option($id, 'facebook_share_message_description' ),
'image' => opanda_get_item_option($id, 'facebook_share_message_image' )
);
$options['socialButtons']['twitter'] = array(
'lang' => opanda_get_option('short_lang', 'en'),
'tweet' => array(
'url' => $twTweetUrl,
'text' => opanda_get_item_option($id, 'twitter_tweet_text' ),
'counturl' => opanda_get_item_option($id, 'twitter_tweet_counturl' ),
'title' => opanda_get_item_option($id, 'twitter_tweet_title' ),
'via' => opanda_get_item_option($id, 'twitter_tweet_via' )
)
);
$options['socialButtons']['twitter']['follow'] = array(
'url' => $twFollowUrl,
'title' => opanda_get_item_option($id, 'twitter_follow_title' ),
'hideScreenName' => opanda_get_item_option($id, 'twitter_follow_hide_name', false, false )
);
$options['socialButtons']['google'] = array(
'lang' => opanda_get_option('google_lang', opanda_get_option('short_lang', 'en' )),
'plus' => array(
'url' => $glPlusUrl,
'title' => opanda_get_item_option($id, 'google_plus_title' )
)
);
$options['socialButtons']['google']['share'] = array(
'url' => $glShareUrl,
'title' => opanda_get_item_option($id, 'google_share_title' )
);
$options['socialButtons']['youtube']['subscribe'] = array(
'clientId' => get_option( 'opanda_google_client_id' ),
'channelId' => opanda_get_item_option($id, 'google_youtube_channel_id' ),
'title' => opanda_get_item_option($id, 'google_youtube_title' )
);
$options['socialButtons']['linkedin'] = array(
'share' => array(
'url' => $lnShareUrl,
'title' => opanda_get_item_option($id, 'linkedin_share_title' )
)
);
$allowedButtons = array('facebook-like', 'facebook-share', 'twitter-tweet', 'twitter-follow', 'google-plus', 'google-share', 'youtube-subscribe', 'linkedin-share');
$allowedButtons = apply_filters('opanda_social-locker_allowed_buttons', $allowedButtons);
if ( $options['socialButtons']['order'] ) {
$options['socialButtons']['order'] = explode( ',', $options['socialButtons']['order'] );
}
if ( empty( $options['socialButtons']['order'] ) ) {
unset( $options['socialButtons']['order'] );
} else {
$filteredButtons = array();
foreach( $options['socialButtons']['order'] as $buttonName ) {
if ( !in_array( $buttonName, $allowedButtons ) ) continue;
$filteredButtons[] = $buttonName;
}
$options['socialButtons']['order'] = $filteredButtons;
}
// - Replaces shortcodes in the locker message and twitter text
$postTitle = $post != null ? $post->post_title : '';
$postUrl = $post != null ? get_permalink($post->ID) : '';
if ( !empty( $options['socialButtons']['twitter']['tweet']['text'] ) ) {
$options['socialButtons']['twitter']['tweet']['text'] = str_replace('[post_title]', $postTitle, $options['socialButtons']['twitter']['tweet']['text'] );
}
return $options;
}
add_filter('opanda_social-locker_item_options', 'opanda_social_locker_options', 10, 2);
/**
* Requests assets for email locker.
*/
function opanda_social_locker_assets( $lockerId, $options, $fromBody, $fromHeader ) {
OPanda_AssetsManager::requestLockerAssets();
// Miscellaneous
OPanda_AssetsManager::requestTextRes(array(
'misc_close',
'misc_or_wait'
));
if ( isset( $options['opanda_buttons_order'] ) && strpos( $options['opanda_buttons_order'], 'facebook' ) !== false ) {
OPanda_AssetsManager::requestFacebookSDK();
}
}
add_action('opanda_request_assets_for_social-locker', 'opanda_social_locker_assets', 10, 4);
/**
* A shortcode for the Social Locker
*
* @since 1.0.0
*/
class OPanda_SocialLockerShortcode extends OPanda_LockerShortcode {
/**
* Shortcode name
* @var string
*/
public $shortcodeName = array(
'sociallocker', 'sociallocker-1', 'sociallocker-2', 'sociallocker-3', 'sociallocker-4', 'sociallocker-bulk'
);
protected function getDefaultId() {
return get_option('opanda_default_social_locker_id');
}
}
FactoryShortcodes320::register( 'OPanda_SocialLockerShortcode', $bizpanda );