easyiit_rand_fields.php
5.8 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
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
<?php
/**
* Plugin Name: 随机字段调用
* Plugin URI: #
* Description: 随机字段调用
* Version: 1.0.00
* Author: Goodao
* Author URI: #
*/
if (!defined('IMPORT_PATH')) define('IMPORT_PATH', plugin_dir_path(__FILE__));
add_action('admin_menu', 'rand_fields_init');
function rand_fields_init() {
add_submenu_page('easyiit_rand_fields', '变量设置', '变量设置', 7, 'easyiit_rand_fields', 'rand_fields');
}
function rand_fields() {
if(isset($_POST['dosubmit'])){
$rand_fields = $_POST['setting'];
$rand_fields['rand_pre'] = str_replace(['"',"\'\'"],'',$rand_fields['rand_pre']);
$rand_fields['rand_suffix'] = str_replace(['"',"\'\'"],'',$rand_fields['rand_suffix']);
$rand_fields['rand_l_suffix'] = str_replace(['"',"\'\'"],'',$rand_fields['rand_l_suffix']);
$rand_fields['rand_feedback'] = str_replace(['"',"\'\'"],'',$rand_fields['rand_feedback']);
update_option( "_rand_fields", $rand_fields );
echo '<div id="setting-error-settings_updated" class="updated settings-error"><p><strong>保存成功。</strong></p></div>';
}
$rand_fields = get_option("_rand_fields");
?>
<div class="wrap">
<form id="logins-filter" method="post">
<h2 class="title">随机字段调用</h2>
<table class="form-table permalink-structure">
<tbody>
<tr>
<th>
<label>随机前缀句子:</label>
</th>
<td>
<textarea name="setting[rand_pre]" rows="6" cols="200"><?php echo stripslashes($rand_fields['rand_pre']);?></textarea>
</td>
</tr>
<tr>
<th>
<label>随机后缀句子(短):</label>
</th>
<td>
<textarea name="setting[rand_suffix]" rows="6" cols="200"><?php echo stripslashes($rand_fields['rand_suffix']);?></textarea>
</td>
</tr>
<tr>
<th>
<label>随机后缀句子(长):</label>
</th>
<td>
<textarea name="setting[rand_l_suffix]" rows="6" cols="200"><?php echo stripslashes($rand_fields['rand_l_suffix']);?></textarea>
</td>
</tr>
<tr>
<th>
<label>随机Tag关键词(HTML):</label>
</th>
<td>
<textarea name="setting[rand_keywords]" rows="6" cols="200"><?php echo stripslashes($rand_fields['rand_keywords']);?></textarea>
</td>
</tr>
<tr>
<th>
<label>随机国家地区:</label>
</th>
<td>
<textarea name="setting[rand_country]" rows="6" cols="50"><?php echo stripslashes($rand_fields['rand_country']);?></textarea>
</td>
</tr>
<tr>
<th>
<label>随机Feedback内容:</label>
</th>
<td>
<textarea name="setting[rand_feedback]" rows="6" cols="200"><?php echo stripslashes($rand_fields['rand_feedback']);?></textarea>
</td>
</tr>
<tr>
<th>
<label>随机Feedback名字:</label>
</th>
<td>
<textarea name="setting[rand_feedback_name]" rows="6" cols="50"><?php echo stripslashes($rand_fields['rand_feedback_name']);?></textarea>
</td>
</tr>
<tr>
<th>
<label>随机Feedback时间:</label>
</th>
<td>
<textarea name="setting[rand_feedback_time]" rows="6" cols="50"><?php echo stripslashes($rand_fields['rand_feedback_time']);?></textarea>
</td>
</tr>
</tbody>
</table>
<p class="submit"><input type="submit" name="dosubmit" id="submit" class="button button-primary" value="保存更改"></p>
</form>
</div>
<div class="clear"></div>
<?php
}
function rand_pre_func( $atts ) {
$rand_fields = get_option("_rand_fields");
$rand_pre_arr = explode("\n",$rand_fields['rand_pre']);
return stripslashes($rand_pre_arr[array_rand($rand_pre_arr,1)]);
}
add_shortcode( 'rand_pre', 'rand_pre_func' );
function rand_suffix_func( $atts ) {
$rand_fields = get_option("_rand_fields");
$rand_suffix_arr = explode("\n",$rand_fields['rand_suffix']);
return stripslashes($rand_suffix_arr[array_rand($rand_suffix_arr,1)]);
}
add_shortcode( 'rand_suffix', 'rand_suffix_func' );
function rand_l_suffix_func( $atts ) {
$rand_fields = get_option("_rand_fields");
$rand_l_suffix_arr = explode("\n",$rand_fields['rand_l_suffix']);
return stripslashes($rand_l_suffix_arr[array_rand($rand_l_suffix_arr,1)]);
}
add_shortcode( 'rand_l_suffix', 'rand_l_suffix_func' );
function rand_keywords_func( $atts ) {
$rand_fields = get_option("_rand_fields");
$rand_keywords_arr = explode("\n",$rand_fields['rand_keywords']);
return stripslashes($rand_keywords_arr[array_rand($rand_keywords_arr,1)]);
}
add_shortcode( 'rand_keywords', 'rand_keywords_func' );
function rand_country_func( $atts ) {
$rand_fields = get_option("_rand_fields");
$rand_country_arr = explode("\n",$rand_fields['rand_country']);
return stripslashes($rand_country_arr[array_rand($rand_country_arr,1)]);
}
add_shortcode( 'rand_country', 'rand_country_func' );
function rand_feedback_func( $atts ) {
$rand_fields = get_option("_rand_fields");
$rand_feedback_arr = explode("\n",$rand_fields['rand_feedback']);
return stripslashes($rand_feedback_arr[array_rand($rand_feedback_arr,1)]);
}
add_shortcode( 'rand_feedback', 'rand_feedback_func' );
function rand_feedback_name_func( $atts ) {
$rand_fields = get_option("_rand_fields");
$rand_feedback_name_arr = explode("\n",$rand_fields['rand_feedback_name']);
return stripslashes($rand_feedback_name_arr[array_rand($rand_feedback_name_arr,1)]);
}
add_shortcode( 'rand_feedback_name', 'rand_feedback_name_func' );
function rand_feedback_time_func( $atts ) {
$rand_fields = get_option("_rand_fields");
$rand_feedback_time_arr = explode("\n",$rand_fields['rand_feedback_time']);
return stripslashes($rand_feedback_time_arr[array_rand($rand_feedback_time_arr,1)]);
}
add_shortcode( 'rand_feedback_time', 'rand_feedback_time_func' );
function easyiit_plugin_rand_fields_settings_link($links) {
$rand_fields_settings_link = '<a href="' . esc_url( admin_url( 'admin.php?page=easyiit_rand_fields' ) ) . '">' . __( 'Settings' ) . '</a>';
array_unshift($links, $rand_fields_settings_link);
return $links;
}
$plugin = plugin_basename(__FILE__);
add_filter("plugin_action_links_$plugin", 'easyiit_plugin_rand_fields_settings_link' );