| 1 |
<?php |
| 2 |
/** |
| 3 |
* 插件设置页面 |
| 4 |
*/ |
| 5 |
// require_once('WaterMarkFunctions.php'); |
| 6 |
|
| 7 |
function wpwatermark_setting_page() { |
| 8 |
// 如果当前用户权限不足 |
| 9 |
if (!current_user_can('manage_options')) { |
| 10 |
wp_die('Insufficient privileges!'); |
| 11 |
} |
| 12 |
|
| 13 |
$wpwatermark_options = get_option('wpwatermark_options'); |
| 14 |
if ($wpwatermark_options && !empty($_POST)) |
| 15 |
$wpwatermark_options['watermark_type'] = (isset($_POST['watermark_type'])) ? sanitize_text_field(trim(stripslashes($_POST['watermark_type']))) : $wpwatermark_options['watermark_type']; |
| 16 |
$wpwatermark_options['text_content'] = (isset($_POST['text_content'])) ? sanitize_text_field(trim(stripslashes($_POST['text_content']))) : $wpwatermark_options['text_content']; |
| 17 |
$wpwatermark_options['text_font'] = (isset($_POST['text_font'])) ? sanitize_text_field(trim(stripslashes($_POST['text_font']))) : $wpwatermark_options['text_font']; |
| 18 |
$wpwatermark_options['text_angle'] = (isset($_POST['text_angle'])) ? sanitize_text_field(trim(stripslashes($_POST['text_angle']))) : $wpwatermark_options['text_angle']; |
| 19 |
$wpwatermark_options['text_size'] = (isset($_POST['text_size'])) ? sanitize_text_field(trim(stripslashes($_POST['text_size']))) : $wpwatermark_options['text_size']; |
| 20 |
$wpwatermark_options['text_color'] = (isset($_POST['text_color'])) ? sanitize_text_field(trim(stripslashes($_POST['text_color']))) : $wpwatermark_options['text_color']; |
| 21 |
$wpwatermark_options['watermark_mark_image'] = (isset($_POST['watermark_mark_image'])) ? sanitize_text_field(trim(stripslashes($_POST['watermark_mark_image']))) : $wpwatermark_options['watermark_mark_image']; |
| 22 |
$wpwatermark_options['watermark_position'] = (isset($_POST['watermark_position'])) ? sanitize_text_field(trim(stripslashes($_POST['watermark_position']))) : $wpwatermark_options['watermark_position']; |
| 23 |
$wpwatermark_options['watermark_margin'] = (isset($_POST['watermark_margin'])) ? sanitize_text_field(trim(stripslashes($_POST['watermark_margin']))) : $wpwatermark_options['watermark_margin']; |
| 24 |
$wpwatermark_options['watermark_diaphaneity'] = (isset($_POST['watermark_diaphaneity'])) ? sanitize_text_field(trim(stripslashes($_POST['watermark_diaphaneity']))) : $wpwatermark_options['watermark_diaphaneity']; |
| 25 |
$wpwatermark_options['watermark_spacing'] = (isset($_POST['watermark_spacing'])) ? sanitize_text_field(trim(stripslashes($_POST['watermark_spacing']))) : $wpwatermark_options['watermark_spacing']; |
| 26 |
$wpwatermark_options['watermark_min_width'] = (isset($_POST['watermark_min_width'])) ? sanitize_text_field(trim(stripslashes($_POST['watermark_min_width']))) : $wpwatermark_options['watermark_min_width']; |
| 27 |
$wpwatermark_options['watermark_min_height'] = (isset($_POST['watermark_min_height'])) ? sanitize_text_field(trim(stripslashes($_POST['watermark_min_height']))) : $wpwatermark_options['watermark_min_height']; |
| 28 |
|
| 29 |
if ( isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce']) ) { |
| 30 |
// 不管结果变没变,有提交则直接以提交的数据 wpwatermark_options |
| 31 |
update_option('wpwatermark_options', $wpwatermark_options); |
| 32 |
?> |
| 33 |
<div class="notice notice-success settings-error is-dismissible"><p><strong>设置已保存。</strong></p></div> |
| 34 |
<?php } |
| 35 |
if ( isset($_POST['preview_wpnonce']) && wp_verify_nonce($_POST['preview_wpnonce']) ) { |
| 36 |
$demo_img_path = plugin_dir_path( __FILE__ ); |
| 37 |
$im_url = $demo_img_path . 'demo.jpg'; |
| 38 |
$new_im_url = $demo_img_path . 'preview.jpg'; |
| 39 |
if ( $wpwatermark_options['watermark_type'] === 'text_watermark' ) { |
| 40 |
wpWaterMarkCreateWordsWatermark( |
| 41 |
$im_url, |
| 42 |
$new_im_url, |
| 43 |
$wpwatermark_options['text_content'], |
| 44 |
$wpwatermark_options['watermark_spacing'], |
| 45 |
$wpwatermark_options['text_size'], |
| 46 |
$wpwatermark_options['text_color'], |
| 47 |
$wpwatermark_options['watermark_position'], |
| 48 |
$wpwatermark_options['text_font'], |
| 49 |
$wpwatermark_options['text_angle'], |
| 50 |
$wpwatermark_options['watermark_margin'] |
| 51 |
); |
| 52 |
} elseif ( $wpwatermark_options['watermark_type'] === 'image_watermark' ) { |
| 53 |
wpWaterMarkCreateImageWatermark( |
| 54 |
$im_url, |
| 55 |
$wpwatermark_options['watermark_mark_image'], |
| 56 |
$new_im_url, |
| 57 |
$wpwatermark_options['watermark_position'], |
| 58 |
$wpwatermark_options['watermark_diaphaneity'], |
| 59 |
$wpwatermark_options['watermark_spacing'], |
| 60 |
$wpwatermark_options['watermark_margin'] |
| 61 |
); |
| 62 |
} |
| 63 |
} |
| 64 |
?> |
| 65 |
<link rel='stylesheet' href='<?php echo plugin_dir_url(__FILE__); ?>layui/css/layui.css' /> |
| 66 |
<link rel='stylesheet' href='<?php echo plugin_dir_url(__FILE__); ?>layui/css/laobuluo.css'/> |
| 67 |
<script src='<?php echo plugin_dir_url(__FILE__); ?>layui/layui.js'></script> |
| 68 |
<style> |
| 69 |
.layui-table tbody tr:hover { |
| 70 |
background-color: white; |
| 71 |
} |
| 72 |
.preview-img{min-width:280px; width:60%;max-width:80%;} |
| 73 |
.preview-img img{max-width: 100%;height: auto;} |
| 74 |
</style> |
| 75 |
<div class="container-laobuluo-main"> |
| 76 |
<div class="laobuluo-wbs-header" style="margin-bottom: 15px;"> |
| 77 |
<div class="laobuluo-wbs-logo"> |
| 78 |
<a> |
| 79 |
<img src="<?php echo plugin_dir_url(__FILE__); ?>layui/images/logo.png"> |
| 80 |
</a><span class="wbs-span">WPWaterMark - WordPress轻水印插件</span><span class="wbs-free">Free V4.2</span> |
| 81 |
</div> |
| 82 |
<div class="laobuluo-wbs-btn"> |
| 83 |
<a class="layui-btn layui-btn-primary" href="https://www.laojiang.me/?utm_source=wpwatermark-setting&utm_media=link&utm_campaign=header" target="_blank"> |
| 84 |
<i class="layui-icon layui-icon-home"></i> 插件主页 |
| 85 |
</a> |
| 86 |
<a class="layui-btn layui-btn-primary" href="https://www.laojiang.me/5993.html?utm_source=wpwatermark-setting&utm_media=link&utm_campaign=header" target="_blank"> |
| 87 |
<i class="layui-icon layui-icon-release"></i> 插件教程 |
| 88 |
</a> |
| 89 |
</div> |
| 90 |
</div> |
| 91 |
</div> |
| 92 |
<!-- � |
| 93 |
容 --> |
| 94 |
<div class="container-laobuluo-main"> |
| 95 |
<div class="layui-container container-m"> |
| 96 |
<div class="layui-row layui-col-space15"> |
| 97 |
<!-- 左边 --> |
| 98 |
<div class="layui-col-md9"> |
| 99 |
<div class="laobuluo-panel"> |
| 100 |
<div class="laobuluo-controw"> |
| 101 |
<fieldset class="layui-elem-field layui-field-title site-title"> |
| 102 |
<legend> |
| 103 |
<a name="get"> |
| 104 |
设置选项 |
| 105 |
</a> |
| 106 |
</legend> |
| 107 |
</fieldset> |
| 108 |
<form class="layui-form wpcosform" action="<?php echo wp_nonce_url('./admin.php?page=' . WPWaterMark_INDEXFILE); ?>" name="wpwatermarkform" method="post"> |
| 109 |
<table class="layui-table" lay-even > |
| 110 |
<colgroup> |
| 111 |
<col width="120"> |
| 112 |
<col> |
| 113 |
</colgroup> |
| 114 |
<tbody> |
| 115 |
<tr> |
| 116 |
<td>水印类型:</td> |
| 117 |
<td> |
| 118 |
<div class="layui-form-item"> |
| 119 |
<div class="layui-input-inline"> |
| 120 |
<input class="layui-input" lay-filter="water-tab" type="radio" name="watermark_type" value="text_watermark" title="本文水印" |
| 121 |
<?php |
| 122 |
if ($wpwatermark_options['watermark_type'] == 'text_watermark') { echo 'checked="checked"'; |
| 123 |
} |
| 124 |
?> /> |
| 125 |
</div> |
| 126 |
<div class="layui-input-inline"> |
| 127 |
<input class="layui-input" lay-filter="water-tab" type="radio" name="watermark_type" value="image_watermark" title="图片水印" |
| 128 |
<?php |
| 129 |
if ($wpwatermark_options['watermark_type'] == 'image_watermark') { echo 'checked="checked"'; |
| 130 |
} |
| 131 |
?> /> |
| 132 |
</div> |
| 133 |
</div> |
| 134 |
<div class="water-tab text-watermark"style="display: |
| 135 |
<?php |
| 136 |
if ($wpwatermark_options['watermark_type'] == 'text_watermark') { |
| 137 |
echo 'block'; |
| 138 |
} else { |
| 139 |
echo 'none'; |
| 140 |
} |
| 141 |
?> |
| 142 |
;"> |
| 143 |
|
| 144 |
<div class="layui-form-item"> |
| 145 |
<label class="layui-form-label">文本� |
| 146 |
容:</label> |
| 147 |
<div class="layui-input-inline"> |
| 148 |
<input class="ipn-win layui-input" name="text_content" type="text" id="textfield" value="<?php echo esc_attr($wpwatermark_options['text_content']); ?>" size="30" /> |
| 149 |
</div> |
| 150 |
</div> |
| 151 |
<div class="layui-form-item"> |
| 152 |
<label class="layui-form-label">文本字体:</label> |
| 153 |
<div class="layui-input-inline"> |
| 154 |
<select class="ipn-win" id='text_font' name="text_font" required> |
| 155 |
<?php $dir = plugin_dir_path(__FILE__) . 'fonts/'; |
| 156 |
$files1 = scandir($dir); |
| 157 |
foreach ($files1 as $k => $v) { |
| 158 |
if ($v != "." && $v != "..") { |
| 159 |
$is_selected = $wpwatermark_options['text_font'] == $v ? "selected" : ""; |
| 160 |
echo "<option value='$v' $is_selected>$v</option>"; |
| 161 |
} |
| 162 |
} |
| 163 |
?> |
| 164 |
</select> |
| 165 |
</div> |
| 166 |
</div> |
| 167 |
<div class="layui-form-item"> |
| 168 |
<label class="layui-form-label">文本倾斜:</label> |
| 169 |
<div class="layui-input-inline"> |
| 170 |
<input class="ipn-win layui-input" name="text_angle" type="text" value="<?php echo esc_attr($wpwatermark_options['text_angle']); ?>" size="20" /> |
| 171 |
</div> |
| 172 |
</div> |
| 173 |
<div class="layui-form-item"> |
| 174 |
<label class="layui-form-label">文本大小:</label> |
| 175 |
<div class="layui-input-inline"> |
| 176 |
<input class="ipn-win layui-input" name="text_size" type="text" id="textfield2" value="<?php echo esc_attr($wpwatermark_options['text_size']); ?>" size="20" /> |
| 177 |
</div> |
| 178 |
</div> |
| 179 |
<div class="layui-form-item"> |
| 180 |
<label class="layui-form-label">文本颜色:</label> |
| 181 |
<div class="layui-input-inline"> |
| 182 |
<input class="ipn-win layui-input" name="text_color" type="text" value="<?php echo esc_attr($wpwatermark_options['text_color']); ?>" size="15"/> |
| 183 |
<span id="color_code"></span> |
| 184 |
</div> |
| 185 |
</div> |
| 186 |
</div> |
| 187 |
<div class="water-tab image-watermark"style="display: |
| 188 |
<?php |
| 189 |
if ($wpwatermark_options['watermark_type'] == 'image_watermark') { |
| 190 |
echo 'block'; |
| 191 |
} else { |
| 192 |
echo 'none'; |
| 193 |
} |
| 194 |
?> |
| 195 |
;"> |
| 196 |
<div class="layui-form-item mt5"> |
| 197 |
<div class="layui-input-block" style="margin-left: 0;width: 315px;"> |
| 198 |
<input class=" layui-input" type="text" name="watermark_mark_image" value="<?php echo esc_attr($wpwatermark_options['watermark_mark_image']) ?>" size="80"/> |
| 199 |
</div> |
| 200 |
<div class="layui-form-mid layui-word-aux"> |
| 201 |
说明:自己准备一个水印图片URL地址(比如:https://www.laobuluo.com/watermark.png),最好是透明 .png 图片,尺寸建议250*100px。 |
| 202 |
</div> |
| 203 |
</div> |
| 204 |
</div></td> |
| 205 |
</tr> |
| 206 |
<tr> |
| 207 |
<td>加水印条件:</td> |
| 208 |
<td> |
| 209 |
<div class="layui-form-item"> |
| 210 |
<label class="layui-form-label"> 宽度:</label> |
| 211 |
<div class="layui-input-inline"> |
| 212 |
<input class="layui-input" name="watermark_min_width" type="text" value="<?php echo esc_attr($wpwatermark_options['watermark_min_width']); ?>" size="10" /> |
| 213 |
</div> |
| 214 |
<div class="layui-form-mid layui-word-aux"> |
| 215 |
(单位为px) |
| 216 |
</div> |
| 217 |
</div> |
| 218 |
<div class="layui-form-item"> |
| 219 |
<label class="layui-form-label"> 高度:</label> |
| 220 |
<div class="layui-input-inline"> |
| 221 |
<input class="layui-input" name="watermark_min_height" type="text" value="<?php echo esc_attr($wpwatermark_options['watermark_min_height']); ?>" size="10" /> |
| 222 |
</div> |
| 223 |
<div class="layui-form-mid layui-word-aux"> |
| 224 |
(单位为px) |
| 225 |
</div> |
| 226 |
</div></td> |
| 227 |
</tr> |
| 228 |
<tr> |
| 229 |
<td>� |
| 230 |
�他设置:</td> |
| 231 |
<td> |
| 232 |
<div class="layui-form-item"> |
| 233 |
<label class="layui-form-label">水印间距:</label> |
| 234 |
<div class="layui-input-inline"> |
| 235 |
<input class="layui-input" name="watermark_margin" type="text" value="<?php echo esc_attr($wpwatermark_options['watermark_margin']); ?>" size="20" /> |
| 236 |
</div> |
| 237 |
<div class="layui-form-mid layui-word-aux"> |
| 238 |
(平铺时水印之间距离) |
| 239 |
</div> |
| 240 |
</div> |
| 241 |
<div class="layui-form-item"> |
| 242 |
<label class="layui-form-label">水印透明度:</label> |
| 243 |
<div class="layui-input-inline"> |
| 244 |
<input class="layui-input" name="watermark_diaphaneity" type="text" id="label4" value="<?php echo esc_attr($wpwatermark_options['watermark_diaphaneity']); ?>" size="20" /> |
| 245 |
</div> |
| 246 |
<div class="layui-form-mid layui-word-aux"> |
| 247 |
(0-100数值 数值越小越透明) |
| 248 |
</div> |
| 249 |
</div> |
| 250 |
<div class="layui-form-item"> |
| 251 |
<label class="layui-form-label">水印边距:</label> |
| 252 |
<div class="layui-input-inline"> |
| 253 |
<input class="layui-input" name="watermark_spacing" type="text" id="label3" value="<?php echo esc_attr($wpwatermark_options['watermark_spacing']); ?>" size="20" /> |
| 254 |
</div> |
| 255 |
<div class="layui-form-mid layui-word-aux"> |
| 256 |
(水印起始位置距离图片四周边距数值,单位为px 建议30px) |
| 257 |
</div> |
| 258 |
</div></td> |
| 259 |
</tr> |
| 260 |
|
| 261 |
<tr> |
| 262 |
<td>水印位置:</td> |
| 263 |
<td> |
| 264 |
<div class="layui-form-item"> |
| 265 |
<div class="layui-input-inline" style="width: 140px"> |
| 266 |
<input class=" layui-input" lay-filter="sudoku" type="radio" title="九宫格位置" name="watermarkPosition" value="jiugongge" <?php |
| 267 |
if ($wpwatermark_options['watermark_position'] > 0 and $wpwatermark_options['watermark_position'] < 10) { echo 'checked="checked"';}?> /> |
| 268 |
</div> |
| 269 |
<div class="layui-form-mid layui-word-aux"> |
| 270 |
(1-9 固定位置) |
| 271 |
</div> |
| 272 |
<div class="layui-input-block mt5 sudoku-box" style="margin-left: 0; width:315px;display: |
| 273 |
<?php |
| 274 |
if ($wpwatermark_options['watermark_position'] > 0 and $wpwatermark_options['watermark_position'] < 10) { |
| 275 |
echo 'block'; |
| 276 |
} else { |
| 277 |
echo 'none'; |
| 278 |
} |
| 279 |
?>"> |
| 280 |
<input class=" layui-input" name="jiugongge_value" type="text" id="label2" value=<?php |
| 281 |
if ($wpwatermark_options['watermark_position'] > 0 and $wpwatermark_options['watermark_position'] < 10) { echo '"' . esc_attr($wpwatermark_options['watermark_position']) . '"'; |
| 282 |
} else { echo '"" disabled'; |
| 283 |
}?> size="10" /> |
| 284 |
</div> |
| 285 |
|
| 286 |
</div> |
| 287 |
<div class="layui-form-item"> |
| 288 |
<div class="layui-input-inline" style="width: 140px"> |
| 289 |
<input type="radio" lay-filter="sudoku" title="随机九宫格" name="watermarkPosition" value="suiji" <?php if ($wpwatermark_options['watermark_position'] == 0) { echo 'checked="checked"';}?>/> |
| 290 |
</div> |
| 291 |
<div class="layui-form-mid layui-word-aux"> |
| 292 |
(每次水印位置随机) |
| 293 |
</div> |
| 294 |
</div> |
| 295 |
<div class="layui-form-item"> |
| 296 |
<div class="layui-input-inline" style="width: 140px"> |
| 297 |
<input type="radio" lay-filter="sudoku" title="满铺水印效果" name="watermarkPosition" value="manpu" <?php if ($wpwatermark_options['watermark_position'] == 10) { echo 'checked="checked"';}?>/> |
| 298 |
</div> |
| 299 |
<div class="layui-form-mid layui-word-aux"> |
| 300 |
(满铺水印效果,强力防御) |
| 301 |
</div> |
| 302 |
</div> |
| 303 |
<input type="hidden" name="watermark_position" value="<?php echo esc_attr($wpwatermark_options['watermark_position']); ?>" /> |
| 304 |
</td> |
| 305 |
</tr> |
| 306 |
<tr> |
| 307 |
<td></td> |
| 308 |
<td> |
| 309 |
<input type="submit" name="submit" value="保存轻水印插件设置" class="layui-btn" style="width: 176px;"/> |
| 310 |
</td> |
| 311 |
</tr> |
| 312 |
<tr> |
| 313 |
<td>演示效果:</td> |
| 314 |
<td> |
| 315 |
<input type="button" id="preview" value="点击刷新预览水印效果" class="layui-btn layui-btn-normal" /> |
| 316 |
<p class="mt10 preview-img" id="preview_block"></p></td> |
| 317 |
</tr> |
| 318 |
</tbody> |
| 319 |
</table> |
| 320 |
</form> |
| 321 |
</div> |
| 322 |
</div> |
| 323 |
</div> |
| 324 |
<!-- 左边 --> |
| 325 |
<!-- 右边 --> |
| 326 |
<div class="layui-col-md3"> |
| 327 |
<div id="nav"> |
| 328 |
<div class="laobuluo-panel"> |
| 329 |
<div class="laobuluo-panel-title">� |
| 330 |
�注� |
| 331 |
�众号</div> |
| 332 |
<div class="laobuluo-code"> |
| 333 |
<img src="<?php echo plugin_dir_url(__FILE__); ?>layui/images/qrcode.png"> |
| 334 |
<p>微信扫码� |
| 335 |
�注 <span class="layui-badge layui-bg-blue">老蒋朋友圈</span> � |
| 336 |
�众号</p> |
| 337 |
<p><span class="layui-badge">优� |
| 338 |
�</span> 获取插件更新 和 更多 <span class="layui-badge layui-bg-green">� |
| 339 |
�费插件</span> </p> |
| 340 |
</div> |
| 341 |
</div> |
| 342 |
|
| 343 |
|
| 344 |
</div> |
| 345 |
</div> |
| 346 |
<!-- 右边 --> |
| 347 |
</div> |
| 348 |
</div> |
| 349 |
</div> |
| 350 |
<!-- � |
| 351 |
容 --> |
| 352 |
<!-- footer --> |
| 353 |
<div class="container-laobuluo-main"> |
| 354 |
<div class="layui-container container-m"> |
| 355 |
<div class="layui-row layui-col-space15"> |
| 356 |
<div class="layui-col-md12"> |
| 357 |
<div class="laobuluo-footer-code"> |
| 358 |
<span class="codeshow"></span> |
| 359 |
</div> |
| 360 |
<div class="laobuluo-links"> |
| 361 |
<a href="https://www.laobuluo.com/?utm_source=lbs-setting&utm_media=link&utm_campaign=footer" target="_blank">老部落</a> |
| 362 |
<a href="https://www.lezaiyun.com/?utm_source=lbs-setting&utm_media=link&utm_campaign=footer" target="_blank">乐在云工作室</a> |
| 363 |
<a href="https://www.laojiang.me/5993.html?utm_source=lbs-setting&utm_media=link&utm_campaign=footer" target="_blank">使用说明</a> |
| 364 |
<a href="https://www.laojiang.me/aboutus/?utm_source=lbs-setting&utm_media=link&utm_campaign=footer" target="_blank">� |
| 365 |
�于我们</a> |
| 366 |
</div> |
| 367 |
</div> |
| 368 |
</div> |
| 369 |
</div> |
| 370 |
</div> |
| 371 |
<!-- footer --> |
| 372 |
<script> |
| 373 |
layui.use(['form', 'element','jquery'], function(){ |
| 374 |
var $ =layui.jquery; |
| 375 |
var form = layui.form; |
| 376 |
var element = layui.element |
| 377 |
|
| 378 |
function menuFixed(id) { |
| 379 |
var obj = document.getElementById(id); |
| 380 |
var _getHeight = obj.offsetTop; |
| 381 |
var _Width= obj.offsetWidth |
| 382 |
window.onscroll = function () { |
| 383 |
changePos(id, _getHeight,_Width); |
| 384 |
} |
| 385 |
} |
| 386 |
|
| 387 |
function changePos(id, height,width) { |
| 388 |
var obj = document.getElementById(id); |
| 389 |
obj.style.width = width+'px'; |
| 390 |
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; |
| 391 |
var _top = scrollTop-height; |
| 392 |
if (_top < 150) { |
| 393 |
var o = _top; |
| 394 |
obj.style.position = 'relative'; |
| 395 |
o = o > 0 ? o : 0; |
| 396 |
obj.style.top = o +'px'; |
| 397 |
|
| 398 |
} else { |
| 399 |
obj.style.position = 'fixed'; |
| 400 |
obj.style.top = 50+'px'; |
| 401 |
|
| 402 |
} |
| 403 |
} |
| 404 |
menuFixed('nav'); |
| 405 |
|
| 406 |
form.on('radio(water-tab)', function(data){ |
| 407 |
|
| 408 |
$(".water-tab").hide() |
| 409 |
if (this.value == 'text_watermark') { |
| 410 |
$('.text-watermark').show() |
| 411 |
} else if (this.value == 'image_watermark') { |
| 412 |
$('.image-watermark').show() |
| 413 |
} |
| 414 |
}) |
| 415 |
|
| 416 |
form.on('radio(sudoku)',function(){ |
| 417 |
|
| 418 |
$('input[name="jiugongge_value"]').attr('disabled', true); |
| 419 |
$('.sudoku-box').hide(); |
| 420 |
|
| 421 |
if (this.value=='jiugongge') { |
| 422 |
$('.sudoku-box').show() |
| 423 |
$('input[name="watermark_position"]').val($('input[name="jiugongge_value"]').val()); |
| 424 |
$('input[name="jiugongge_value"]').attr("disabled", false); |
| 425 |
|
| 426 |
} else if(this.value=='suiji'){ |
| 427 |
$('input[name="watermark_position"]').val('0'); |
| 428 |
} else if(this.value == 'manpu'){ |
| 429 |
$('input[name="watermark_position"]').val('10'); |
| 430 |
} |
| 431 |
}) |
| 432 |
|
| 433 |
$('input[name="jiugongge_value"]').change(function(){ |
| 434 |
$('input[name="watermark_position"]').val($('input[name="jiugongge_value"]').val()); |
| 435 |
}); |
| 436 |
|
| 437 |
function readyFn() { |
| 438 |
function randomNum(minNum,maxNum){ |
| 439 |
switch(arguments.length){ |
| 440 |
case 1: |
| 441 |
return parseInt(Math.random()*minNum+1,10); |
| 442 |
break; |
| 443 |
case 2: |
| 444 |
return parseInt(Math.random()*(maxNum-minNum+1)+minNum,10); |
| 445 |
break; |
| 446 |
default: |
| 447 |
return 0; |
| 448 |
break; |
| 449 |
} |
| 450 |
} |
| 451 |
|
| 452 |
$('input[type="color"]').colorpicker({hoverChange:true}); |
| 453 |
$('input[name="text_color"]').colorpicker({ |
| 454 |
'onSelect':function(color){ |
| 455 |
$('#color_code').text('(颜色修改为:'+color+')'); |
| 456 |
} |
| 457 |
}); |
| 458 |
$('#preview').click(function () { |
| 459 |
|
| 460 |
let watermark_type; |
| 461 |
if ( $('input[value="text_watermark"]').is(':checked') ) { |
| 462 |
watermark_type = "text_watermark"; |
| 463 |
} |
| 464 |
if ( $('input[value="image_watermark"]').is(':checked') ) { |
| 465 |
watermark_type = "image_watermark"; |
| 466 |
} |
| 467 |
let text_content = $('input[name="text_content"]').val(); |
| 468 |
let text_font = $('#text_font option:selected').val(); |
| 469 |
let text_angle = $('input[name="text_angle"]').val(); |
| 470 |
let text_size = $('input[name="text_size"]').val(); |
| 471 |
let text_color = $('input[name="text_color"]').val(); |
| 472 |
let watermark_mark_image = $('input[name="watermark_mark_image"]').val(); |
| 473 |
let watermark_position = $('input[name="watermark_position"]').val(); |
| 474 |
let watermark_margin = $('input[name="watermark_margin"]').val(); |
| 475 |
let watermark_diaphaneity = $('input[name="watermark_diaphaneity"]').val(); |
| 476 |
let watermark_spacing = $('input[name="watermark_spacing"]').val(); |
| 477 |
|
| 478 |
$.post( |
| 479 |
"<?php echo './admin.php?page=' . WPWaterMark_INDEXFILE; ?>", |
| 480 |
{ |
| 481 |
'preview_wpnonce': "<?php echo wp_create_nonce(); ?>", |
| 482 |
'watermark_type': watermark_type, |
| 483 |
'text_content': text_content, |
| 484 |
'text_font': text_font, |
| 485 |
'text_angle': text_angle, |
| 486 |
'text_size': text_size, |
| 487 |
'text_color': text_color, |
| 488 |
'watermark_mark_image': watermark_mark_image, |
| 489 |
'watermark_position': watermark_position, |
| 490 |
'watermark_margin': watermark_margin, |
| 491 |
'watermark_diaphaneity': watermark_diaphaneity, |
| 492 |
'watermark_spacing': watermark_spacing, |
| 493 |
}, |
| 494 |
function( res ) { |
| 495 |
// if ( res['status'] ==1 ) { |
| 496 |
let x = res; |
| 497 |
let img_src = "<?php echo plugins_url('preview.jpg', __FILE__) . '?' ?>" + randomNum(0, 99999); |
| 498 |
let img_code = "<img src='" + img_src + "' />"; |
| 499 |
$('#preview_block').html(img_code); |
| 500 |
}, |
| 501 |
); |
| 502 |
}); |
| 503 |
} |
| 504 |
$(document).ready(readyFn); |
| 505 |
|
| 506 |
}) |
| 507 |
</script> |
| 508 |
|
| 509 |
<?php |
| 510 |
} |
| 511 |
?> |