This repository has been archived by the owner on Oct 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
sharing-admin.php
210 lines (189 loc) · 14.1 KB
/
sharing-admin.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
209
210
<?php
if (!defined('ABSPATH')) {
exit();
}
require_once 'wechat.php';
class Bosima_WeChat_Page_Sharing_Admin
{
const NONCENAME='bosima-wechat-appconfig-update';
public static function init()
{
add_action('admin_menu', array('Bosima_WeChat_Page_Sharing_Admin', 'admin_menu'));
load_plugin_textdomain( 'wechat-page-sharing', false, dirname( plugin_basename( __FILE__ ) ) . '/trans' );
}
public static function admin_menu()
{
add_options_page('微信分享插件配置', '微信分享设置', 'manage_options', 'wechat-appid-config', array('Bosima_WeChat_Page_Sharing_Admin', 'display_page'));
}
public static function display_page()
{
if (!current_user_can('manage_options')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
// variables for the field and option names
$hidden_field_name = 'wechat_submit_hidden';
$appid_field_name = 'wechat_appid';
$appsecrect_field_name = 'wechat_appsecrect';
$sharing_page_title_field_name='sharing_page_title';
$sharing_page_description_field_name='sharing_page_description';
$sharing_tag_title_field_name='sharing_tag_title';
$sharing_tag_description_field_name='sharing_tag_description';
$sharing_search_title_field_name='sharing_search_title';
$sharing_search_description_field_name='sharing_search_description';
$sharing_archive_title_field_name='sharing_archive_title';
$sharing_archive_description_field_name='sharing_archive_description';
$sharing_img_option_field_name='sharing_img_option';
$sharing_home_title_field_name='sharing_home_title';
$sharing_home_description_field_name='sharing_home_description';
$sharing_home_img_useicon_field_name='sharing_home_img_useicon';
$sharing_single_title_field_name='sharing_single_title';
$sharing_single_description_field_name='sharing_single_description';
$sharing_category_title_field_name='sharing_category_title';
$weChat = Bosima_WeChat::getInstance();
$config = $weChat->getWeChatConfig();
// See if the user has posted us some information
// If they did, this hidden field will be set to 'Y'
if (isset($_POST[$hidden_field_name]) && $_POST[$hidden_field_name] == 'Y') {
check_admin_referer(self::NONCENAME);
// Read their posted value
$config->appId = sanitize_text_field($_POST[$appid_field_name]);
$config->appSecrect = sanitize_text_field($_POST[$appsecrect_field_name]);
$config->sharing_page_title=sanitize_text_field($_POST[$sharing_page_title_field_name]);
$config->sharing_page_description=sanitize_text_field($_POST[$sharing_page_description_field_name]);
$config->sharing_tag_title=sanitize_text_field($_POST[$sharing_tag_title_field_name]);
$config->sharing_tag_description=sanitize_text_field($_POST[$sharing_tag_description_field_name]);
$config->sharing_search_title=sanitize_text_field($_POST[$sharing_search_title_field_name]);
$config->sharing_search_description=sanitize_text_field($_POST[$sharing_search_description_field_name]);
$config->sharing_archive_title=sanitize_text_field($_POST[$sharing_archive_title_field_name]);
$config->sharing_archive_description=sanitize_text_field($_POST[$sharing_archive_description_field_name]);
$config->sharing_img_option=sanitize_text_field($_POST[$sharing_img_option_field_name]);
$config->sharing_home_img_useicon=sanitize_text_field($_POST[$sharing_home_img_useicon_field_name]);
$config->sharing_home_title=sanitize_text_field($_POST[$sharing_home_title_field_name]);
$config->sharing_home_description=sanitize_text_field($_POST[$sharing_home_description_field_name]);
$config->sharing_single_title=sanitize_text_field($_POST[$sharing_single_title_field_name]);
$config->sharing_single_description=sanitize_text_field($_POST[$sharing_single_description_field_name]);
$config->sharing_category_title=sanitize_text_field($_POST[$sharing_category_title_field_name]);
// Save the posted value in the database
$weChat->updateAllConfig();
// Put an settings updated message on the screen
?>
<div class="updated"><p><strong><?php _e('settings saved.', 'wechat-page-sharing'); ?></strong></p></div>
<?php
}
$wechat_appid = esc_attr($config->appId);
$wechat_appsecrect = esc_attr($config->appSecrect);
$sharing_page_title = esc_attr($config->sharing_page_title);
$sharing_page_description = esc_attr($config->sharing_page_description);
$sharing_tag_title = esc_attr($config->sharing_tag_title);
$sharing_tag_description = esc_attr($config->sharing_tag_description);
$sharing_search_title = esc_attr($config->sharing_search_title);
$sharing_search_description = esc_attr($config->sharing_search_description);
$sharing_archive_title = esc_attr($config->sharing_archive_title);
$sharing_archive_description = esc_attr($config->sharing_archive_description);
$sharing_img_option = esc_attr($config->sharing_img_option);
$sharing_home_title = esc_attr($config->sharing_home_title);
$sharing_home_img_useicon = esc_attr($config->sharing_home_img_useicon);
$sharing_home_description = esc_attr($config->sharing_home_description);
$sharing_single_description = esc_attr($config->sharing_single_description);
$sharing_single_title = esc_attr($config->sharing_single_title);
$sharing_category_title = esc_attr($config->sharing_category_title);
$out_ip = Bosima_WeChat::getOutIp();
echo '<div class="wrap">';
echo '<h2>'.__('WeChat Page Sharing Plugin Settings', 'wechat-page-sharing').'</h2>'; ?>
<form name="form1" method="post" action="">
<?php wp_nonce_field(self::NONCENAME) ?>
<input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
<h3><?php _e('Plugin Instructions', 'wechat-page-sharing'); ?> </h3>
<p><span style="font-size:14px;font-weight:bold">1.</span> <?php _e('Instructions Setp 1 Content', 'wechat-page-sharing'); ?></p>
<p><span style="font-size:14px;font-weight:bold">2.</span> <?php _e('Instructions Setp 2 Content', 'wechat-page-sharing'); ?><?php echo $out_ip ?></p>
<p><span style="font-size:14px;font-weight:bold">3.</span> <?php _e('Instructions Setp 3 Content', 'wechat-page-sharing'); ?><script type="text/javascript">document.write(document.domain)</script></p>
<p><span style="font-size:14px;font-weight:bold">4.</span> <?php _e('Instructions Setp 4 Content', 'wechat-page-sharing'); ?></p>
<p><span style="font-size:14px;font-weight:bold">5.</span> <?php _e('Instructions Setp 5 Content', 'wechat-page-sharing'); ?></p>
<p><?php _e('Have Fun', 'wechat-page-sharing'); ?></p>
<hr />
<h3><?php _e('WeChat Settings', 'wechat-page-sharing'); ?> </h3>
<p><?php _e('WeChat AppId:', 'wechat-page-sharing'); ?>
<input type="text" name="<?php echo $appid_field_name; ?>" value="<?php echo $wechat_appid; ?>" size="30">
</p>
<p><?php _e('WeChat AppSecrect:', 'wechat-page-sharing'); ?>
<input type="text" name="<?php echo $appsecrect_field_name; ?>" value="<?php echo $wechat_appsecrect; ?>" size="40">
</p>
<!--<p><?php _e('Server Outbound IP:', 'wechat-page-sharing'); ?>
<?php
echo $out_ip;
?>
</p>
-->
<hr />
<h3><?php _e('Template Settings', 'wechat-page-sharing'); ?> </h3>
<?php _e('Sharing Template Memo', 'wechat-page-sharing'); ?>
<p><?php _e('Sharing Home Title Template:', 'wechat-page-sharing'); ?>
<input type="text" name="<?php echo $sharing_home_title_field_name; ?>" value="<?php echo $sharing_home_title; ?>" size="75">
<?php _e('Valid Variable Label:', 'wechat-page-sharing'); ?> {blog_name} {blog_sub_name}
</p>
<p><?php _e('Sharing Home Description Template:', 'wechat-page-sharing'); ?>
<input type="text" name="<?php echo $sharing_home_description_field_name; ?>" value="<?php echo $sharing_home_description; ?>" size="75">
<?php _e('Valid Variable Label:', 'wechat-page-sharing'); ?> {blog_name} {blog_sub_name}
</p>
<p><?php _e('Sharing Home Image Use Site Icon:', 'wechat-page-sharing'); ?>
<input type="radio" name="<?php echo $sharing_home_img_useicon_field_name; ?>" value="1" <?php if($sharing_home_img_useicon=="1"){ echo "checked='checked'"; } ?>> <?php _e('Use', 'wechat-page-sharing'); ?>
<input type="radio" name="<?php echo $sharing_home_img_useicon_field_name; ?>" value="0" <?php if($sharing_home_img_useicon=="0"){ echo "checked='checked'"; } ?>> <?php _e('Not Use', 'wechat-page-sharing'); ?>
</p>
<p><?php _e('Sharing Category Title Template:', 'wechat-page-sharing'); ?>
<input type="text" name="<?php echo $sharing_category_title_field_name; ?>" value="<?php echo $sharing_category_title; ?>" size="75">
<?php _e('Valid Variable Label:', 'wechat-page-sharing'); ?> {blog_name} {blog_sub_name} {category_name}
</p>
<p><?php _e('Sharing Single Title Template:', 'wechat-page-sharing'); ?>
<input type="text" name="<?php echo $sharing_single_title_field_name; ?>" value="<?php echo $sharing_single_title; ?>" size="75">
<?php _e('Valid Variable Label:', 'wechat-page-sharing'); ?> {blog_name} {blog_sub_name} {post_title}
</p>
<p><?php _e('Sharing Single Description Template:', 'wechat-page-sharing'); ?>
<input type="text" name="<?php echo $sharing_single_description_field_name; ?>" value="<?php echo $sharing_single_description; ?>" size="75">
<?php _e('Valid Variable Label:', 'wechat-page-sharing'); ?> {blog_name} {blog_sub_name} {post_title} {post_excerpt}
</p>
<p><?php _e('Sharing Page Title Template:', 'wechat-page-sharing'); ?>
<input type="text" name="<?php echo $sharing_page_title_field_name; ?>" value="<?php echo $sharing_page_title; ?>" size="75">
<?php _e('Valid Variable Label:', 'wechat-page-sharing'); ?> {blog_name} {blog_sub_name} {post_title}
</p>
<p><?php _e('Sharing Page Description Template:', 'wechat-page-sharing'); ?>
<input type="text" name="<?php echo $sharing_page_description_field_name; ?>" value="<?php echo $sharing_page_description; ?>" size="75">
<?php _e('Valid Variable Label:', 'wechat-page-sharing'); ?> {blog_name} {blog_sub_name} {post_title}
</p>
<p><?php _e('Sharing Tag Title Template:', 'wechat-page-sharing'); ?>
<input type="text" name="<?php echo $sharing_tag_title_field_name; ?>" value="<?php echo $sharing_tag_title; ?>" size="75">
<?php _e('Valid Variable Label:', 'wechat-page-sharing'); ?> {blog_name} {blog_sub_name} {tag_con}
</p>
<p><?php _e('Sharing Tag Description Template:', 'wechat-page-sharing'); ?>
<input type="text" name="<?php echo $sharing_tag_description_field_name; ?>" value="<?php echo $sharing_tag_description; ?>" size="75">
<?php _e('Valid Variable Label:', 'wechat-page-sharing'); ?> {blog_name} {blog_sub_name} {tag_con}
</p>
<p><?php _e('Sharing Archive Title Template:', 'wechat-page-sharing'); ?>
<input type="text" name="<?php echo $sharing_archive_title_field_name; ?>" value="<?php echo $sharing_archive_title; ?>" size="75">
<?php _e('Valid Variable Label:', 'wechat-page-sharing'); ?> {blog_name} {blog_sub_name} {archive_date}
</p>
<p><?php _e('Sharing Archive Description Template:', 'wechat-page-sharing'); ?>
<input type="text" name="<?php echo $sharing_archive_description_field_name; ?>" value="<?php echo $sharing_archive_description; ?>" size="75">
<?php _e('Valid Variable Label:', 'wechat-page-sharing'); ?> {blog_name} {blog_sub_name} {archive_date}
</p>
<p><?php _e('Sharing Search Title Template:', 'wechat-page-sharing'); ?>
<input type="text" name="<?php echo $sharing_search_title_field_name; ?>" value="<?php echo $sharing_search_title; ?>" size="75">
<?php _e('Valid Variable Label:', 'wechat-page-sharing'); ?> {blog_name} {blog_sub_name} {search_con}
</p>
<p><?php _e('Sharing Search Description Template:', 'wechat-page-sharing'); ?>
<input type="text" name="<?php echo $sharing_search_description_field_name; ?>" value="<?php echo $sharing_search_description; ?>" size="75">
<?php _e('Valid Variable Label:', 'wechat-page-sharing'); ?> {blog_name} {blog_sub_name} {search_con}
</p>
<p><?php _e('Sharing Image Option:', 'wechat-page-sharing'); ?>
<input type="radio" name="<?php echo $sharing_img_option_field_name; ?>" value="1" <?php if($sharing_img_option=="1"){ echo "checked='checked'"; } ?>> <?php _e('Post Featued Image', 'wechat-page-sharing'); ?>
<input type="radio" name="<?php echo $sharing_img_option_field_name; ?>" value="0" <?php if($sharing_img_option=="0"){ echo "checked='checked'"; } ?>> <?php _e('Post First Image', 'wechat-page-sharing'); ?>
<?php _e('Sharing Image Option Memo:', 'wechat-page-sharing'); ?>
</p>
<hr />
<p class="submit">
<input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" />
</p>
</form>
</div>
<?php
}
}