options_page.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  3. $options = $this->plugin_option;
  4. $options->refresh();
  5. /*
  6. *****************************************
  7. *
  8. * Option page saving
  9. *
  10. *****************************************
  11. */
  12. if (isset($_POST['submitted'])) {
  13. check_admin_referer('urlyar-urlshortener');
  14. //Shortener
  15. $options->set('urlserviceenable',sanitize_text_field( $_POST['urlserviceenable']));
  16. $options->set('useslug', sanitize_text_field($_POST['useslug']));
  17. $options->set('appendurl', array('home' =>sanitize_text_field( $_POST['appendurl_home']),
  18. 'single' => sanitize_text_field($_POST['appendurl_single']),
  19. 'page' => sanitize_text_field($_POST['appendurl_page']),
  20. 'product' => sanitize_text_field($_POST['appendurl_product']),
  21. 'text' => strip_tags(sanitize_text_field($_POST['appendurl_text'])),
  22. )
  23. );
  24. $options->set('appendqr', array('home' => sanitize_text_field($_POST['appendqr_home']),
  25. 'single' => sanitize_text_field($_POST['appendqr_single']),
  26. 'page' => sanitize_text_field($_POST['appendqr_page']),
  27. 'product' => sanitize_text_field($_POST['appendqr_product']),
  28. 'text' => strip_tags(sanitize_text_field($_POST['appendqr_text'])),
  29. 'provider' => sanitize_text_field($_POST['appendqr_provider']),
  30. )
  31. );
  32. //Nice ID
  33. $options->set('niceid', sanitize_text_field($_POST['niceid']));
  34. $options->set('niceid_prefix', esc_url_raw($_POST['niceid_prefix']));
  35. //Shortcode
  36. $options->set('url_shortcode', sanitize_text_field($_POST['url_shortcode']));
  37. //Services
  38. $service_list = $this->shortener->service_list('detailed');
  39. foreach ($service_list as $keys => $values) {
  40. switch ($values[2]) {
  41. case 1:
  42. case 4:
  43. $options->set('apiuser_' . $keys, sanitize_text_field($_POST['apiuser_' . $keys]));
  44. break;
  45. case 2:
  46. case 5:
  47. $options->set('apikey_' . $keys, sanitize_text_field($_POST['apikey_' . $keys]));
  48. break;
  49. case 3:
  50. case 6:
  51. case 101:
  52. $options->set('apiuser_' . $keys, sanitize_text_field($_POST['apiuser_' . $keys]));
  53. $options->set('apikey_' . $keys, sanitize_text_field($_POST['apikey_' . $keys]));
  54. break;
  55. default:
  56. break;
  57. }
  58. }
  59. $options->set('generic_yourls', array('endpoint' => sanitize_text_field($_POST['generic_yourls_endpoint'])
  60. )
  61. );
  62. $options->set('generic_interdose', array('service' => sanitize_text_field($_POST['generic_interdose_service'])
  63. )
  64. );
  65. //last command includes save.
  66. $options->set('urlservice', sanitize_text_field($_POST['urlservice']));
  67. $options->save();
  68. echo '<div class="updated fade"><p>Plugin settings saved.</p></div>';
  69. }
  70. /*
  71. *****************************************
  72. *
  73. * Setup option page display
  74. *
  75. *****************************************
  76. */
  77. $options->refresh();
  78. $urlserviceenable = $options->get('urlserviceenable');
  79. $urlservice = $options->get('urlservice');
  80. $useslug = $options->get('useslug');
  81. $appendurl = $options->get('appendurl');
  82. $appendqr = $options->get('appendqr');
  83. $niceid = $options->get('niceid');
  84. $niceid_prefix = $options->get('niceid_prefix');
  85. $url_shortcode = $options->get('url_shortcode');
  86. //$sfx = new FTShared();
  87. $supported = $this->shortener->service_list('detailed');
  88. $authkey = $this->shortener->service_list('authkey');
  89. $authuser = $this->shortener->service_list('authuser');
  90. $reqkey = $this->shortener->service_list('reqkey');
  91. $requser = $this->shortener->service_list('requser');
  92. /*
  93. *****************************************
  94. *
  95. * Start of the form
  96. *
  97. *****************************************
  98. */
  99. ?>
  100. <div class="wrap">
  101. <h2><?php _e('URLYar URL Shortener', 'url-shortener');
  102. echo ' ' . $this->plugin_version ?></h2>
  103. <div class="j-show" id="tab-select">
  104. <?php _e('Options', 'url-shortener')?>:
  105. <ul>
  106. <li><a rel="opt-gen" href="#opt-general"><?php _e('General', 'url-shortener')?></a></li>
  107. <li><a rel="opt-add" href="#opt-additional"><?php _e('Additional Features', 'url-shortener')?></a></li>
  108. <!--<li><a rel="opt-mod" href="#opt-modules">Modules</a></li>-->
  109. </ul>
  110. </div>
  111. <form method="post" action="<?php echo $action_url ?>" id="shorturl_options">
  112. <?php wp_nonce_field('urlyar-urlshortener'); ?>
  113. <input type="hidden" name="submitted" value="1"/>
  114. <?php /*
  115. *****************************************
  116. *
  117. * General Options
  118. *
  119. *****************************************
  120. */ ?>
  121. <fieldset id="opt-general" title="General Options for Plugin" class="fs-opt opt-gen j-hide">
  122. <h3 class="divider"><?php _e('Main Settings', 'url-shortener'); ?></h3>
  123. <table class="form-table">
  124. <tr>
  125. <th scope="row"><label
  126. for="urlserviceenable"><?php _e('URL Shortener Integration', 'url-shortener'); ?></label>
  127. </th>
  128. <td>
  129. <input name="urlserviceenable" id="urlserviceenable" type="checkbox"
  130. value="yes" <?php checked('yes', $urlserviceenable) ?> />
  131. <span class="description"><?php _e('Enable Short URL generation using your <a href="#shorturl_selector">configured service<a/>.', 'url-shortener'); ?></span>
  132. </td>
  133. </tr>
  134. <tr>
  135. <th scope="row"><label
  136. for="useslug"><?php _e('Use Permalinks for Short URLs', 'url-shortener'); ?></label>
  137. </th>
  138. <td>
  139. <input name="useslug" id="useslug" type="checkbox"
  140. value="yes" <?php checked('yes', $useslug) ?> />
  141. <span class="description"><?php sprintf(_e('Use your <a href="%s/wp-admin/options-permalink.php">permalinks</a> to generate the Short URL.'), get_option('siteurl')); ?>
  142. <br/><?php _e('(Default: "http://yoursite/?p=123" or "http://yoursite/?page_id=123")', 'url-shortener'); ?></span>
  143. </td>
  144. </tr>
  145. <tr>
  146. <th scope="row"><label><?php _e('Append Short URL to: ', 'url-shortener'); ?></label></th>
  147. <td>
  148. <input name="appendurl_home" id="appendurl_home" type="checkbox"
  149. value="yes" <?php checked('yes', $appendurl['home']) ?> />
  150. <label for="appendurl_home"><?php _e('Posts (Homepage)', 'url-shortener'); ?></label>
  151. <br/>
  152. <input name="appendurl_single" id="appendurl_single" type="checkbox"
  153. value="yes" <?php checked('yes', $appendurl['single']) ?> />
  154. <label for="appendurl_single"><?php _e('Posts (Individual)', 'url-shortener'); ?></label>
  155. <br/>
  156. <input name="appendurl_page" id="appendurl_page" type="checkbox"
  157. value="yes" <?php checked('yes', $appendurl['page']) ?> />
  158. <label for="appendurl_page"><?php _e('Pages', 'url-shortener'); ?></label>
  159. <br/>
  160. <input name="appendurl_product" id="appendurl_product" type="checkbox"
  161. value="yes" <?php checked('yes', $appendurl['product']) ?> />
  162. <label for="appendurl_product"><?php _e('Products', 'url-shortener'); ?></label>
  163. </td>
  164. </tr>
  165. <tr>
  166. <th><label for="appendurl_text"><?php _e('Text before Short URL link ', 'url-shortener'); ?></label>
  167. </th>
  168. <td>
  169. <input name="appendurl_text" type="text" id="appendurl_text"
  170. value="<?php echo $appendurl['text']; ?>" class="regular-text code"/>
  171. </td>
  172. </tr>
  173. </table>
  174. </fieldset>
  175. <?php /*
  176. *****************************************
  177. *
  178. * Additional options
  179. *
  180. *****************************************
  181. */ ?>
  182. <fieldset id="opt-additional" title="Additional Features" class="fs-opt opt-add j-hide">
  183. <h3 class="divider"><?php _e('Nice ID', 'url-shortener'); ?></h3>
  184. <table class="form-table">
  185. <tr>
  186. <th scope="row">
  187. <label for="niceid"><?php _e('Nice ID URLs', 'url-shortener'); ?></label><br/>
  188. <span class="description"><?php _e('(Formally named template_redirection)', 'url-shortener'); ?></span>
  189. </th>
  190. <td>
  191. <input name="niceid" id="niceid" type="checkbox" value="yes" <?php checked('yes', $niceid) ?> />
  192. <span class="description"><?php _e('Allows usage of "http://yoursite/123" instead of "http://yoursite/?p=123"', 'url-shortener'); ?></span>
  193. </td>
  194. </td>
  195. </tr>
  196. <tr>
  197. <th scope="row"><label for="niceid"><?php _e('Nice ID URL Prefix', 'url-shortener'); ?></label></th>
  198. <td>
  199. <input name="niceid_prefix" type="text" id="niceidprefix" value="<?php echo $niceid_prefix; ?>"
  200. class="regular-text code"/>
  201. <span class="description"><?php _e('default: "/" (http://yoursite/123)</span>
  202. <p>Examples:
  203. <br />"<span class="red">prefix/</span>" = http://yoursite/<span class="red">prefix/</span>123
  204. <br />"<span class="red">prefix-</span>" = http://yoursite/<span class="red">prefix-</span>123
  205. </p>', 'url-shortener'); ?>
  206. </td>
  207. </td>
  208. </tr>
  209. </table>
  210. <h3 class="divider"><?php _e('Shortcode', 'url-shortener'); ?></h3>
  211. <table class="form-table">
  212. <tr>
  213. <th scope="row"><label
  214. for="url_shortcode"><?php _e('Disable Shortcode [urlyar_shortlink]', 'url-shortener'); ?></label>
  215. </th>
  216. <td>
  217. <input name="url_shortcode" id="url_shortcode" type="checkbox"
  218. value="disable" <?php checked('disable', $url_shortcode) ?> />
  219. <span class="description"><?php _e('Disables the usage of URL Shortener shortcode [urlyar_shortlink]', 'url-shortener'); ?></span>
  220. </td>
  221. </td>
  222. </tr>
  223. </table>
  224. <h3 class="divider"><?php _e('QR Code', 'url-shortener'); ?></h3>
  225. <table class="form-table">
  226. <tr>
  227. <th scope="row"><label><?php _e('Append QR Code to: ', 'url-shortener'); ?></label></th>
  228. <td>
  229. <input name="appendqr_home" id="appendqr_home" type="checkbox"
  230. value="yes" <?php checked('yes', $appendqr['home']) ?> />
  231. <label for="appendqr_home"><?php _e('Posts (Homepage)', 'url-shortener'); ?></label>
  232. <br/>
  233. <input name="appendqr_single" id="appendqr_single" type="checkbox"
  234. value="yes" <?php checked('yes', $appendqr['single']) ?> />
  235. <label for="appendqr_single"><?php _e('Posts (Individual)', 'url-shortener'); ?></label>
  236. <br/>
  237. <input name="appendqr_page" id="appendqr_page" type="checkbox"
  238. value="yes" <?php checked('yes', $appendqr['page']) ?> />
  239. <label for="appendqr_page"><?php _e('Pages', 'url-shortener'); ?></label>
  240. <br/>
  241. <input name="appendqr_product" id="appendqr_product" type="checkbox"
  242. value="yes" <?php checked('yes', $appendqr['page']) ?> />
  243. <label for="appendqr_product"><?php _e('Products', 'url-shortener'); ?></label>
  244. </td>
  245. </tr>
  246. <tr>
  247. <th><label for="appendqr_provider"><?php _e('QR Code Provider ', 'url-shortener'); ?></label></th>
  248. <td>
  249. <div><input name="appendqr_provider" type="radio" id="appendqr_provider"
  250. value="urlyar" <?php echo ($appendqr['provider'] == "urlyar") ? "checked" : ""; ?>
  251. class="regular-radio code"/>
  252. <label for="appendqr_urlyar"><?php _e('URLYar', 'url-shortener'); ?></label>
  253. </div>
  254. <div><input name="appendqr_provider" type="radio" id="appendqr_provider"
  255. value="google" <?php echo ($appendqr['provider'] == "google") ? "checked" : ""; ?>
  256. class="regular-radio code"/>
  257. <label for="appendqr_google"><?php _e('Google', 'url-shortener'); ?></label>
  258. </div>
  259. </td>
  260. </tr>
  261. <tr>
  262. <th><label for="appendqr_text"><?php _e('Text before QR Code ', 'url-shortener'); ?></label></th>
  263. <td>
  264. <input name="appendqr_text" type="text" id="appendqr_text"
  265. value="<?php echo $appendqr['text']; ?>" class="regular-text code"/>
  266. </td>
  267. </tr>
  268. </table>
  269. </fieldset>
  270. <?php /*
  271. *****************************************
  272. *
  273. * Modules
  274. *
  275. *****************************************
  276. <fieldset id="opt-modules" title="List of Modules" class="fs-opt opt-mod j-hide">
  277. <h3 class="divider"><?php _e('Shortener Modules', 'url-shortener'); ?></h3>
  278. <table id="component_list" class="widefat post fixed" cellspacing="0">
  279. <thead>
  280. <tr>
  281. <th scope="col" class="manage-column"><?php _e('Name', 'url-shortener'); ?></th>
  282. <th scope="col" class="manage-column"><?php _e('Description', 'url-shortener'); ?></th>
  283. <th scope="col" class="manage-column colsmall"><?php _e('ID', 'url-shortener'); ?></th>
  284. </tr>
  285. </thead>
  286. <tfoot>
  287. <tr>
  288. <th scope="col" class="manage-column"><?php _e('Name', 'url-shortener'); ?></th>
  289. <th scope="col" class="manage-column"><?php _e('Description', 'url-shortener'); ?></th>
  290. <th scope="col" class="manage-column colsmall"><?php _e('ID', 'url-shortener'); ?></th>
  291. </tr>
  292. </tfoot>
  293. <tbody>
  294. <?php foreach ($this->shortener_modules as $modules){ ?>
  295. <tr>
  296. <td class="name">
  297. <strong class="checkit"><?php echo $modules['name']; ?></strong>
  298. <span>Version: <?php echo $modules['version']; ?></span>
  299. </td>
  300. <td>
  301. <?php echo $modules['description']; ?>
  302. </td>
  303. <td><?php echo $modules['classname']; ?></td>
  304. </tr>
  305. <?php } ?>
  306. </tbody>
  307. </table>
  308. </fieldset>
  309. */ ?>
  310. <?php /*
  311. *****************************************
  312. *
  313. * Shortlink Service Table
  314. *
  315. *****************************************
  316. */ ?>
  317. <fieldset title="URL Shortening Services" id="shorturl_selector" class="opt-gen j-hide">
  318. <h3 class="divider"><?php _e('URL Service Configuration', 'url-shortener'); ?></h3>
  319. <p><?php _e('Select and configure your desired Short URL service.', 'url-shortener'); ?></p>
  320. <p><?php _e('<span class="red">*</span> are required configurations for that service.', 'url-shortener'); ?></p>
  321. <div class="reqfielderror"></div>
  322. <table id="shorturl_table" class="widefat post fixed" cellspacing="0">
  323. <thead>
  324. <tr>
  325. <th scope="col" id="col1" class="manage-column"><?php _e('Select', 'url-shortener'); ?></th>
  326. <th scope="col" id="col2" class="manage-column"><?php _e('Services', 'url-shortener'); ?></th>
  327. <th scope="col" class="manage-column"><span
  328. class="col3c"><?php _e('Configuration', 'url-shortener'); ?></span></th>
  329. </tr>
  330. </thead>
  331. <tfoot>
  332. <tr>
  333. <th scope="col" class="manage-column"><?php _e('Select', 'url-shortener'); ?></th>
  334. <th scope="col" class="manage-column"><?php _e('Services', 'url-shortener'); ?></th>
  335. <th scope="col" class="manage-column"><span
  336. class="col3c"><?php _e('Configuration', 'url-shortener'); ?></span></th>
  337. </tr>
  338. </tfoot>
  339. <tbody>
  340. <?php
  341. /*
  342. *****************************************
  343. *
  344. * Individual configuration fields
  345. *
  346. *****************************************
  347. */
  348. foreach ($supported as $key => $value) {
  349. if ($urlservice == $key) {
  350. $sh = 'show';
  351. $rh = 'class="detail"';
  352. } else {
  353. $sh = 'hide';
  354. $rh='';
  355. }
  356. $apirow = '<tr id="row_' . $key . '"' . $rh . '>';
  357. $apirow .= '<th class="ssr" scope="row"><input name="urlservice" id="' . $key . '" type="radio" value="' . $key . '"' . checked($key, $urlservice, false) . '/></th>';
  358. $apirow .= '<td class="ssl"><label for="' . $key . '">' . $value[0] . '</label></td><td>';
  359. $apirow .= '<div id="userkey_' . $key . '" class="APIConfig ' . $sh . '">';
  360. $apireq = '';
  361. /*
  362. *****************************************
  363. * User Authentication
  364. *****************************************
  365. */
  366. if (in_array($key, $authuser)) {
  367. $apireq .= '<label for="apiuser_' . $key . '">';
  368. in_array($key, $requser) ? $apireq .= '<span>*</span>' : $apireq .= '';
  369. $apireq .= __('User/ID', 'url-shortener') . ': </label><input type="text" name="apiuser_' . $key . '" id="apiuser_' . $key . '" value="' . $options->get('apiuser_' . $key) . '" />';
  370. }
  371. /*
  372. *****************************************
  373. * Key Authentication
  374. *****************************************
  375. */
  376. if (in_array($key, $authkey)) {
  377. $apireq .= '<label for="apikey_' . $key . '">';
  378. in_array($key, $reqkey) ? $apireq .= ' <span>*</span>' : $apireq .= '';
  379. $apireq .= __('Key/API', 'url-shortener') . ': </label><input type="text" name="apikey_' . $key . '" id="apikey_' . $key . '" value="' . $options->get('apikey_' . $key) . '" />';
  380. }
  381. /*
  382. *****************************************
  383. * Misc Authentication Fields..
  384. * Case by Case Basis
  385. *****************************************
  386. */
  387. switch ($key) {
  388. case 'yourls':
  389. $apireq .= '<label for="apiuser_' . $key . '">';
  390. $apireq .= __('User/ID', 'url-shortener') . ': </label><input type="text" name="apiuser_' . $key . '" id="apiuser_' . $key . '" value="' . $options->get('apiuser_' . $key) . '" />';
  391. $apireq .= '<label for="apikey_' . $key . '">';
  392. $apireq .= __('Password', 'url-shortener') . ': </label><input type="password" name="apikey_' . $key . '" id="apikey_' . $key . '" value="' . $options->get('apikey_' . $key) . '" />';
  393. $apireq .= '<div class="contentblock"><label for="generic_' . $key . '_endpoint">';
  394. $generic = $options->get('generic_' . $key);
  395. $apireq .= __('URL to the YOURLS API', 'url-shortener') . ': </label><input style="display: block; width: 80%;" type="text" name="generic_' . $key . '_endpoint" id="generic_' . $key . '_endpoint" value="' . $generic['endpoint'] . '" />';
  396. $apireq .= 'Example: http://site.com/yourls-api.php';
  397. $apireq .= '<br /><strong>Note:</strong> Please check out <a href="http://salamzadeh.net/plugins/urlyar/docs/url-shortener-wordpress-plugin/known-issues">Known issues</a> before activiting yourls support</strong>';
  398. $apireq .= '</div>';
  399. break;
  400. case 'interdose':
  401. $apireq .= '<div class="contentblock"><label for="generic_' . $key . '_service">';
  402. $generic = $options->get('generic_' . $key);
  403. $apireq .= '<span>*</span>' . __('Service/Domain', 'url-shortener') . ': </label><input style="display: block; width: 80%;" type="text" name="generic_' . $key . '_service" id="generic_' . $key . '_service" value="' . $generic['service'] . '" />';
  404. $apireq .= 'Example: piep.net, xlnk.cc';
  405. $apireq .= '</div>';
  406. break;
  407. default:
  408. break;
  409. }
  410. /*if (in_array($key, $this->generic)){
  411. $apireq .= '<br /><label for="generic_'.$key.'">';
  412. //Cases
  413. switch ($key){
  414. case 'interdose':
  415. $apireq .= __('Service', 'url-shortener') . ': </label><input type="text" name="generic_'.$key.'" id="generic_'.$key.'" value="'.$options->get('generic_'.$key].'" />';
  416. $data = $sfx->openurl('http://api.interdose.com/api/shorturl/v1/services.json');
  417. $data = $sfx->processjson($data);
  418. $count = count($data);
  419. if ($count){
  420. $apireq .= '<br /><span class="slabel">Public Services: </span>';
  421. for ($i = 0; $i < $count; $i++){
  422. $apireq .= '<a class="val_'.$key.'" href="#generic_'.$key.'">'.$data[$i]->service.'</a>';
  423. }
  424. }
  425. break;
  426. default:
  427. break;
  428. }
  429. } */
  430. if ($apireq == '') {
  431. $apireq = '<span class="nc">' . __('No Configuration Needed', 'url-shortener') . '</span>';
  432. }
  433. $apirow .= $apireq;
  434. $apirow .= '</div></td></tr>';
  435. $rh = '';
  436. echo $apirow;
  437. }
  438. ?>
  439. </tbody>
  440. </table>
  441. <div class="clear"></div>
  442. </fieldset>
  443. <div class="reqfielderror"></div>
  444. <script type="text/javascript">
  445. jQuery(document).ready(function ($) {
  446. //display modification
  447. $('.hide, .col3c, .reqfielderror, .j-hide').hide();
  448. $('#tab-select li:first a').addClass('tab-now');
  449. $('.j-show').show();
  450. var tabnow = '.' + $('.tab-now').attr('rel');
  451. $(tabnow).show();
  452. $('#tab-select a').click(function () {
  453. $('.j-hide').hide();
  454. $('.tab-now').removeClass('tab-now');
  455. $(this).addClass('tab-now');
  456. var tabnow = '.' + $('.tab-now').attr('rel');
  457. $(tabnow).fadeIn();
  458. return false;
  459. })
  460. //Service Selection Table
  461. $('.ssr input[type="radio"]').change(function () {
  462. $('.showdetail .APIConfig, .detail .APIConfig').hide();
  463. $('.showdetail').removeClass('showdetail');
  464. var pc = '';
  465. pc = $(this).parent().parent();
  466. if (($(this).is(':checked'))) {// && !(pc.hasClass('rh'))){
  467. pc.addClass('showdetail');
  468. $('.showdetail .APIConfig').show();
  469. }
  470. });
  471. $('.val_interdose').click(function () {
  472. linkval = $(this).html()
  473. $('#generic_interdose').val(linkval);
  474. })
  475. //Submission Functions
  476. var requser = ['snipurl', 'snurl', 'snipr', 'snim', 'cllk'];
  477. var reqkey = ['snipurl', 'snurl', 'snipr', 'snim', 'cllk', 'awesm', 'pingfm'];
  478. $('#shorturl_options').submit(function () {
  479. $('.reqfielderror').html('');
  480. var errorcount = false;
  481. var checkopt = $('input:radio[name=urlservice]:checked').val();
  482. if ($.inArray(checkopt, requser) == -1) {
  483. } else {
  484. var suser = jQuery.trim($('#apiuser_' + checkopt).val());
  485. if (suser == '') {
  486. $('.reqfielderror').append('<?php _e('<strong>Service Configuration: </strong>Please fill the required User/ID', 'url-shortener'); ?><br />');
  487. errorcount = true;
  488. }
  489. }
  490. if ($.inArray(checkopt, reqkey) == -1) {
  491. } else {
  492. var spass = jQuery.trim($('#apikey_' + checkopt).val());
  493. if (spass == '') {
  494. $('.reqfielderror').append('<?php _e('<strong>Service Configuration: </strong>Please fill in the required API/Key', 'url-shortener'); ?><br />');
  495. errorcount = true;
  496. }
  497. }
  498. if (errorcount) {
  499. $('.reqfielderror').fadeIn(400);
  500. return false;
  501. } else {
  502. $('.reqfielderror').hide();
  503. //return false;
  504. }
  505. });//end submission
  506. });//end js
  507. </script>
  508. <p class="submit"><input type="submit" id="submit-button" class="button-primary"
  509. value="<?php _e('Save Changes') ?>"/></p>
  510. </form>
  511. </div>