Hapimp

link-library WP plugin (v.5.6.9) non a-z0-9 search patch

Mar 25th, 2013
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 280.88 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Link Library
  4. Plugin URI: http://wordpress.org/extend/plugins/link-library/
  5. Description: Display links on pages with a variety of options
  6. Version: 5.6.9
  7. Author: Yannick Lefebvre
  8. Author URI: http://yannickcorner.nayanna.biz/
  9.  
  10. A plugin for the blogging MySQL/PHP-based WordPress.
  11. Copyright 2011 Yannick Lefebvre
  12.  
  13. Translations:
  14. Danish Translation Courtesy of GeorgWP (http://wordpress.blogos.dk)
  15. Italian Translation Courtesy of Gianni Diurno
  16.  
  17. This program is free software; you can redistribute it and/or
  18. modify it under the terms of the GNUs General Public License
  19. as published addlinkcatlistoverrideby the Free Software Foundation; either version 2
  20. of the License, or (at your option) any later version.
  21.  
  22. This program is distributed in the hope that it will be useful,
  23. but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. GNU General Public License for more details.
  26.  
  27. You should have received a copy of the GNU General Public License
  28. along with this program; if not, write to the Free Software
  29. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  30.  
  31. You can also view a copy of the HTML version of the GNU General Public
  32. License at http://www.gnu.org/copyleft/gpl.html
  33.  
  34. I, Yannick Lefebvre, can be contacted via e-mail at ylefebvre@gmail.com
  35. */
  36.  
  37. define('LINK_LIBRARY_ADMIN_PAGE_NAME', 'link-library');
  38.  
  39. if ( !get_option( 'link_manager_enabled' ) )
  40. add_filter( 'pre_option_link_manager_enabled', '__return_true' );
  41.  
  42. require_once(ABSPATH . '/wp-admin/includes/bookmark.php');
  43. require_once(ABSPATH . '/wp-admin/includes/taxonomy.php');
  44.  
  45. $rss_settings = "";
  46. $pagehooktop = "";
  47. $pagehookmoderate = "";
  48. $pagehooksettingssets = "";
  49. $pagehookstylesheet = "";
  50. $pagehookreciprocal = "";
  51.  
  52. /*********************************** Link Library Class *****************************************************************************/
  53. class link_library_plugin {
  54.  
  55. //constructor of class, PHP4 compatible construction for backward compatibility
  56. function link_library_plugin() {
  57.  
  58. $newoptions = get_option('LinkLibraryPP1', "");
  59.  
  60. if ($newoptions == "")
  61. {
  62. $this->ll_reset_options(1, 'list');
  63. $this->ll_reset_gen_settings();
  64. }
  65.  
  66. // Functions to be called when plugin is activated and deactivated
  67. register_activation_hook( __FILE__, array($this, 'll_install' ) );
  68. register_deactivation_hook( __FILE__, array($this, 'll_uninstall' ) );
  69.  
  70. add_action( 'wpmu_new_blog', array($this, 'new_network_site'), 10, 6);
  71.  
  72. add_action('admin_init', array($this, 'action_admin_init' ));
  73.  
  74. // wp_ajax_... is only run for logged usrs
  75. //add_action( 'wp_ajax_scn_check_url_action', array( &$this, 'ajax_action_check_url' ) );
  76.  
  77. // Add short codes
  78. add_shortcode('link-library-cats', array($this, 'link_library_cats_func'));
  79. add_shortcode('link-library-search', array($this, 'link_library_search_func'));
  80. add_shortcode('link-library-addlink', array($this, 'link_library_addlink_func'));
  81. add_shortcode('link-library-addlinkcustommsg', array($this, 'link_library_addlink_func'));
  82. add_shortcode('link-library', array($this, 'link_library_func'));
  83.  
  84. // Function to print information in page header when plugin present
  85. add_action('wp_head', array($this, 'll_rss_link'));
  86.  
  87. //add filter for WordPress 2.8 changed backend box system !
  88. add_filter('screen_layout_columns', array($this, 'on_screen_layout_columns'), 10, 2);
  89. //register callback for admin menu setup
  90. add_action('admin_menu', array($this, 'on_admin_menu'));
  91.  
  92. // Function to determine if Link Library is used on a page before printing headers
  93. add_filter('the_posts', array($this, 'conditionally_add_scripts_and_styles'));
  94. // the_posts gets triggered before wp_head
  95.  
  96. add_filter('wp_title', array($this, 'll_title_creator'));
  97.  
  98. // Capture and process user submissions for custom fields in Link Edition page
  99. add_action('add_link', array($this, 'add_link_field'));
  100. add_action('edit_link', array($this, 'add_link_field'));
  101. add_action('delete_link', array($this, 'delete_link_field'));
  102.  
  103. // Re-write rules filters to allow for custom permalinks
  104. add_filter('rewrite_rules_array', array($this, 'll_insertMyRewriteRules'));
  105. add_filter('query_vars', array($this, 'll_insertMyRewriteQueryVars'));
  106.  
  107. add_action( 'wp_dashboard_setup', array( $this, 'dashboard_widget') );
  108.  
  109. // Load text domain for translation of admin pages and text strings
  110. load_plugin_textdomain( 'link-library', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
  111. }
  112.  
  113. function db_prefix() {
  114. global $wpdb;
  115. if (method_exists($wpdb, "get_blog_prefix"))
  116. return $wpdb->get_blog_prefix();
  117. else
  118. return $wpdb->prefix;
  119. }
  120.  
  121. /************************** Link Library Installation Function **************************/
  122. function ll_install() {
  123. global $wpdb;
  124.  
  125. if (function_exists('is_multisite') && is_multisite()) {
  126. if (isset($_GET['networkwide']) && ($_GET['networkwide'] == 1))
  127. {
  128. $originalblog = $wpdb->blogid;
  129.  
  130. $bloglist = $wpdb->get_col($wpdb->prepare("SELECT blog_id FROM $wpdb->blogs"));
  131. foreach ($bloglist as $blog) {
  132. switch_to_blog($blog);
  133. $this->create_table_and_settings();
  134. }
  135. switch_to_blog($originalblog);
  136. return;
  137. }
  138. }
  139. $this->create_table_and_settings();
  140. }
  141.  
  142. function new_network_site($blog_id, $user_id, $domain, $path, $site_id, $meta )
  143. {
  144. global $wpdb;
  145.  
  146. if ( ! function_exists('is_plugin_active_for_network') )
  147. require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
  148.  
  149. if (is_plugin_active_for_network('link-library/link-library.php')) {
  150. $originalblog = $wpdb->blogid;
  151. switch_to_blog($blog_id);
  152. $this->create_table_and_settings();
  153. switch_to_blog($originalblog);
  154. }
  155. }
  156.  
  157. function create_table_and_settings()
  158. {
  159. global $wpdb;
  160.  
  161. $wpdb->links_extrainfo = $this->db_prefix().'links_extrainfo';
  162.  
  163. $creationquery = "CREATE TABLE " . $wpdb->links_extrainfo . " (
  164. link_id bigint(20) NOT NULL DEFAULT '0',
  165. link_second_url varchar(255) CHARACTER SET utf8 DEFAULT NULL,
  166. link_telephone varchar(128) CHARACTER SET utf8 DEFAULT NULL,
  167. link_email varchar(128) CHARACTER SET utf8 DEFAULT NULL,
  168. link_visits bigint(20) DEFAULT '0',
  169. link_reciprocal varchar(255) DEFAULT NULL,
  170. link_submitter varchar(255) DEFAULT NULL,
  171. link_submitter_name VARCHAR( 128 ) NULL,
  172. link_submitter_email VARCHAR( 128 ) NULL,
  173. link_textfield TEXT NULL,
  174. link_no_follow VARCHAR(1) NULL,
  175. link_featured VARCHAR(1) NULL,
  176. link_manual_updated VARCHAR(1) NULL,
  177. UNIQUE KEY link_id (link_id)
  178. );";
  179.  
  180. require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
  181. dbDelta($creationquery);
  182.  
  183. $genoptions = get_option('LinkLibraryGeneral');
  184.  
  185. if ($genoptions != '')
  186. {
  187. if ($genoptions['schemaversion'] == '' || floatval($genoptions['schemaversion']) < 3.5)
  188. {
  189. $genoptions['schemaversion'] = "3.5";
  190. update_option('LinkLibraryGeneral', $genoptions);
  191. }
  192. elseif (floatval($genoptions['schemaversion']) < "4.6")
  193. {
  194. $genoptions['schemaversion'] = "4.6";
  195. $wpdb->get_results("ALTER TABLE `" . $this->db_prefix() . "links_extrainfo` ADD `link_submitter_name` VARCHAR( 128 ) NULL, ADD `link_submitter_email` VARCHAR( 128 ) NULL , ADD `link_textfield` TEXT NULL ;");
  196.  
  197. update_option('LinkLibraryGeneral', $genoptions);
  198. }
  199. elseif (floatval($genoptions['schemaversion']) < "4.7")
  200. {
  201. $genoptions['schemaversion'] = "4.7";
  202. $wpdb->get_results("ALTER TABLE `" . $this->db_prefix() . "links_extrainfo` ADD `link_no_follow` VARCHAR( 1 ) NULL;");
  203.  
  204. update_option('LinkLibraryGeneral', $genoptions);
  205. }
  206. elseif (floatval($genoptions['schemaversion']) < "4.9")
  207. {
  208. $genoptions['schemaversion'] = "4.9";
  209. $wpdb->get_results("ALTER TABLE `" . $this->db_prefix() . "links_extrainfo` ADD `link_featured` VARCHAR( 1 ) NULL;");
  210.  
  211. update_option('LinkLibraryGeneral', $genoptions);
  212. }
  213.  
  214. for ($i = 1; $i <= $genoptions['numberstylesets']; $i++) {
  215. $settingsname = 'LinkLibraryPP' . $i;
  216. $options = get_option($settingsname);
  217.  
  218. if ($options != '')
  219. {
  220. if ($options['showname'] == '')
  221. $options['showname'] = true;
  222.  
  223. if ($options['show_image_and_name'] == true)
  224. {
  225. $options['showname'] = true;
  226. $options['show_images'] = true;
  227. }
  228.  
  229. if ($options['sourcename'] == '')
  230. $options['sourcename'] = 'primary';
  231.  
  232. if ($options['sourceimage'] == '')
  233. $options['sourceimage'] = 'primary';
  234.  
  235. if ($options['dragndroporder'] == '')
  236. {
  237. if ($options['imagepos'] == 'beforename')
  238. $options['dragndroporder'] = '1,2,3,4,5,6,7,8,9,10,11,12';
  239. elseif ($options['imagepos'] == 'aftername')
  240. $options['dragndroporder'] = '2,1,3,4,5,6,7,8,9,10,11,12';
  241. elseif ($options['imagepos'] == 'afterrssicons')
  242. $options['dragndroporder'] = '2,3,4,5,6,1,7,8,9,10,11,12';
  243. }
  244. else if ($options['dragndroporder'] != '')
  245. {
  246. $elementarray = explode(',', $options['dragndroporder']);
  247.  
  248. $allelements = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12');
  249. foreach ($allelements as $element)
  250. {
  251. if (!in_array($element, $elementarray))
  252. {
  253. $elementarray[] = $element;
  254. $options['dragndroporder'] = implode(",", $elementarray);
  255. }
  256. }
  257. }
  258.  
  259. if ($options['flatlist'] === true) $options['flatlist'] = 'unordered';
  260. elseif ($options['flatlist'] === false) $options['flatlist'] = 'table';
  261. }
  262.  
  263. update_option($settingsname, $options);
  264. }
  265. }
  266. }
  267.  
  268. /************************** Link Library Uninstall Function **************************/
  269. function ll_uninstall() {
  270. $genoptions = get_option('LinkLibraryGeneral');
  271.  
  272. if ($genoptions != '')
  273. {
  274. if ($genoptions['stylesheet'] != '' && $genoptions['fullstylesheet'] == '')
  275. {
  276. $stylesheetlocation = plugins_url( $genoptions['stylesheet'], __FILE__ );
  277. if ( file_exists( $stylesheetlocation ) )
  278. $genoptions['fullstylesheet'] = file_get_contents( $stylesheetlocation );
  279.  
  280. update_option('LinkLibraryGeneral', $genoptions);
  281. }
  282. }
  283. }
  284.  
  285. /************************** Function called to create default settings or to reset them on user request **************************/
  286. function ll_reset_options($settings = 1, $layout = 'list')
  287. {
  288. $uploads = wp_upload_dir();
  289.  
  290. if ($layout == "list")
  291. {
  292. $options['num_columns'] = 1;
  293. $options['showdescription'] = false;
  294. $options['shownotes'] = false;
  295. $options['beforenote'] = '<br />';
  296. $options['afternote'] = '';
  297. $options['beforeitem'] = '<li>';
  298. $options['afteritem'] = '</li>';
  299. $options['beforedesc'] = '';
  300. $options['afterdesc'] = '';
  301. $options['displayastable'] = false;
  302. $options['beforelink'] = '';
  303. $options['afterlink'] = '';
  304. $options['showcolumnheaders'] = false;
  305. $options['linkheader'] = '';
  306. $options['descheader'] = '';
  307. $options['notesheader'] = '';
  308. $options['beforerss'] = '';
  309. $options['afterrss'] = '';
  310. $options['beforedate'] = '';
  311. $options['afterdate'] = '';
  312. $options['beforeimage'] = '';
  313. $options['afterimage'] = '';
  314. $options['beforeweblink'] = '';
  315. $options['afterweblink'] = '';
  316. $options['beforetelephone'] = '';
  317. $options['aftertelephone'] = '';
  318. $options['beforeemail'] = '';
  319. $options['afteremail'] = '';
  320. $options['beforelinkhits'] = '';
  321. $options['afterlinkhits'] = '';
  322. }
  323. elseif ($layout == "table")
  324. {
  325. $options['num_columns'] = 3;
  326. $options['showdescription'] = true;
  327. $options['shownotes'] = true;
  328. $options['beforenote'] = '<td>';
  329. $options['afternote'] = '</td>';
  330. $options['beforeitem'] = '<tr>';
  331. $options['afteritem'] = '</tr>';
  332. $options['beforedesc'] = '<td>';
  333. $options['afterdesc'] = '</td>';
  334. $options['displayastable'] = true;
  335. $options['beforelink'] = '<td>';
  336. $options['afterlink'] = '</td>';
  337. $options['showcolumnheaders'] = true;
  338. $options['linkheader'] = 'Application';
  339. $options['descheader'] = 'Description';
  340. $options['notesheader'] = 'Similar to';
  341. $options['beforerss'] = '<td>';
  342. $options['afterrss'] = '</td>';
  343. $options['beforedate'] = '<td>';
  344. $options['afterdate'] = '</td>';
  345. $options['beforeimage'] = '<td>';
  346. $options['afterimage'] = '</td>';
  347. $options['beforeweblink'] = '<td>';
  348. $options['afterweblink'] = '</td>';
  349. $options['beforetelephone'] = '<td>';
  350. $options['aftertelephone'] = '</td>';
  351. $options['beforeemail'] = '<td>';
  352. $options['afteremail'] = '</td>';
  353. $options['beforelinkhits'] = '<td>';
  354. $options['afterlinkhits'] = '</td>';
  355. }
  356.  
  357. $options['order'] = 'name';
  358. $options['hide_if_empty'] = true;
  359. $options['table_width'] = 100;
  360. $options['catanchor'] = true;
  361. $options['flatlist'] = 'table';
  362. $options['categorylist'] = null;
  363. $options['excludecategorylist'] = null;
  364. $options['showrating'] = false;
  365. $options['showupdated'] = false;
  366. $options['show_images'] = false;
  367. $options['use_html_tags'] = false;
  368. $options['show_rss'] = false;
  369. $options['nofollow'] = false;
  370. $options['catlistwrappers'] = 1;
  371. $options['beforecatlist1'] = '';
  372. $options['beforecatlist2'] = '';
  373. $options['beforecatlist3'] = '';
  374. $options['divorheader'] = false;
  375. $options['catnameoutput'] = 'linklistcatname';
  376. $options['show_rss_icon'] = false;
  377. $options['linkaddfrequency'] = 0;
  378. $options['addbeforelink'] = '';
  379. $options['addafterlink'] = '';
  380. $options['linktarget'] = '';
  381. $options['showcategorydescheaders'] = false;
  382. $options['showcategorydesclinks'] = false;
  383. $options['settingssetname'] = 'Default';
  384. $options['showadmineditlinks'] = true;
  385. $options['showonecatonly'] = false;
  386. $options['loadingicon'] = '/icons/Ajax-loader.gif';
  387. $options['defaultsinglecat'] = '';
  388. $options['rsspreview'] = false;
  389. $options['rsspreviewcount'] = 3;
  390. $options['rssfeedinline'] = false;
  391. $options['rssfeedinlinecontent'] = false;
  392. $options['rssfeedinlinecount'] = 1;
  393. $options['direction'] = 'ASC';
  394. $options['linkdirection'] = 'ASC';
  395. $options['linkorder'] = 'name';
  396. $options['pagination'] = false;
  397. $options['linksperpage'] = 5;
  398. $options['hidecategorynames'] = false;
  399. $options['showinvisible'] = false;
  400. $options['showdate'] = false;
  401. $options['catdescpos'] = 'right';
  402. $options['catlistdescpos'] = 'right';
  403. $options['showuserlinks'] = false;
  404. $options['addnewlinkmsg'] = __('Add new link', 'link-library');
  405. $options['linknamelabel'] = __('Link name', 'link-library');
  406. $options['linkaddrlabel'] = __('Link address', 'link-library');
  407. $options['linkrsslabel'] = __('Link RSS', 'link-library');
  408. $options['linkcatlabel'] = __('Link Category', 'link-library');
  409. $options['linkdesclabel'] = __('Link Description', 'link-library');
  410. $options['linknoteslabel'] = __('Link Notes', 'link-library');
  411. $options['addlinkbtnlabel'] = __('Add Link', 'link-library');
  412. $options['newlinkmsg'] = __('New link submitted.', 'link-library');
  413. $options['moderatemsg'] = __('It will appear in the list once moderated. Thank you.', 'link-library');
  414. $options['rsspreviewwidth'] = 900;
  415. $options['rsspreviewheight'] = 700;
  416. $options['imagepos'] = 'beforename';
  417. $options['imageclass'] = '';
  418. $options['emailnewlink'] = false;
  419. $options['showaddlinkrss'] = false;
  420. $options['showaddlinkdesc'] = false;
  421. $options['showaddlinkcat'] = false;
  422. $options['showaddlinknotes'] = false;
  423. $options['usethumbshotsforimages'] = false;
  424. $options['addlinkreqlogin'] = false;
  425. $options['showcatlinkcount'] = false;
  426. $options['publishrssfeed'] = false;
  427. $options['numberofrssitems'] = 10;
  428. $options['rssfeedtitle'] = __('Link Library-Generated RSS Feed', 'link-library');
  429. $options['rssfeeddescription'] = __('Description of Link Library-Generated Feed', 'link-library');
  430. $options['showonecatmode'] = 'AJAX';
  431. $options['addlinkcustomcat'] = false;
  432. $options['linkcustomcatlabel'] = __('User-submitted category', 'link-library');
  433. $options['linkcustomcatlistentry'] = __('User-submitted category (define below)', 'link-library');
  434. $options['searchlabel'] = 'Search';
  435. $options['dragndroporder'] = '1,2,3,4,5,6,7,8,9,10,11,12';
  436. $options['showname'] = true;
  437. $options['cattargetaddress'] = '';
  438. $options['displayweblink'] = 'false';
  439. $options['sourceweblink'] = 'primary';
  440. $options['showtelephone'] = 'false';
  441. $options['sourcetelephone'] = 'primary';
  442. $options['showemail'] = 'false';
  443. $options['showlinkhits'] = false;
  444. $options['weblinklabel'] = '';
  445. $options['telephonelabel'] = '';
  446. $options['emaillabel'] = '';
  447. $options['showaddlinkreciprocal'] = false;
  448. $options['linkreciprocallabel'] = __('Reciprocal Link', 'link-library');
  449. $options['showaddlinksecondurl'] = false;
  450. $options['linksecondurllabel'] = __('Secondary Address', 'link-library');
  451. $options['showaddlinktelephone'] = false;
  452. $options['linktelephonelabel'] = __('Telephone', 'link-library');
  453. $options['showaddlinkemail'] = false;
  454. $options['linkemaillabel'] = __('E-mail', 'link-library');
  455. $options['emailcommand'] = '';
  456. $options['sourceimage'] = 'primary';
  457. $options['sourcename'] = 'primary';
  458. $options['enablerewrite'] = false;
  459. $options['rewritepage'] = '';
  460. $options['storelinksubmitter'] = false;
  461. $options['maxlinks'] = '';
  462. $options['showcaptcha'] = false;
  463. $options['beforelinkrating'] = '';
  464. $options['afterlinkrating'] = '';
  465. $options['linksubmitternamelabel'] = __('Submitter Name', 'link-library');
  466. $options['showlinksubmittername'] = false;
  467. $options['linksubmitteremaillabel'] = __('Submitter E-mail', 'link-library');
  468. $options['showaddlinksubmitteremail'] = false;
  469. $options['linksubmittercommentlabel'] = __('Submitter Comment', 'link-library');
  470. $options['showlinksubmittercomment'] = false;
  471. $options['addlinkcatlistoverride'] = '';
  472. $options['showlargedescription'] = false;
  473. $options['beforelargedescription'] = '';
  474. $options['afterlargedescription'] = '';
  475. $options['showcustomcaptcha'] = false;
  476. $options['customcaptchaquestion'] = __('Is boiling water hot or cold?', 'link-library');
  477. $options['customcaptchaanswer'] = __('hot','link-library');
  478. $options['rssfeedaddress'] = '';
  479. $options['addlinknoaddress'] = false;
  480. $options['featuredfirst'] = false;
  481. $options['linklargedesclabel'] = __('Large Description', 'link-library');
  482. $options['showuserlargedescription'] = false;
  483. $options['usetextareaforusersubmitnotes'] = false;
  484. $options['showcatonsearchresults'] = false;
  485. $options['shownameifnoimage'] = false;
  486. $options['searchresultsaddress'] = '';
  487. $options['enable_link_popup'] = false;
  488. $options['link_popup_text'] = __( '%link_image%<br />Click through to visit %link_name%.', 'link-library');
  489. $options['popup_width'] = 300;
  490. $options['popup_height'] = 400;
  491. $options['nocatonstartup'] = false;
  492.  
  493. $settingsname = 'LinkLibraryPP' . $settings;
  494. update_option($settingsname, $options);
  495. }
  496.  
  497. // Function used to set initial settings or reset them on user request
  498. function ll_reset_gen_settings()
  499. {
  500. $genoptions['numberstylesets'] = 1;
  501. $genoptions['includescriptcss'] = '';
  502. $genoptions['debugmode'] = false;
  503. $genoptions['schemaversion'] = "4.6";
  504. $genoptions['pagetitleprefix'] = '';
  505. $genoptions['pagetitlesuffix'] = '';
  506. $genoptions['thumbshotscid'] = '';
  507. $genoptions['emaillinksubmitter'] = false;
  508. $genoptions['moderatorname'] = '';
  509. $genoptions['moderatoremail'] = '';
  510. $genoptions['approvalemailtitle'] = '';
  511. $genoptions['approvalemailbody'] = '';
  512. $genoptions['rejectedemailtitle'] = '';
  513. $genoptions['rejectedemailbody'] = '';
  514. $genoptions['moderationnotificationtitle'] = '';
  515. $genoptions['linksubmissionthankyouurl'] = '';
  516. $genoptions['usefirstpartsubmittername'] = '';
  517. $genoptions['recipcheckaddress'] = get_bloginfo('wpurl');
  518. $genoptions['recipcheckdelete403'] = false;
  519.  
  520. $stylesheetlocation = get_bloginfo('wpurl') . '/wp-content/plugins/link-library/stylesheettemplate.css';
  521. $genoptions['fullstylesheet'] = file_get_contents($stylesheetlocation);
  522.  
  523. update_option('LinkLibraryGeneral', $genoptions);
  524. }
  525.  
  526. /* the function */
  527. function remove_querystring_var($url, $key) {
  528.  
  529. $keypos = strpos($url, $key);
  530. if ($keypos)
  531. {
  532. $ampersandpos = strpos($url, '&', $keypos);
  533. $newurl = substr($url, 0, $keypos - 1);
  534.  
  535. if ($ampersandpos)
  536. $newurl .= substr($url, $ampersandpos);
  537. }
  538. else
  539. $newurl = $url;
  540.  
  541. return $newurl;
  542. }
  543.  
  544. function ReciprocalLinkChecker($RecipCheckAddress = '', $recipcheckdelete403 = false) {
  545. global $wpdb;
  546.  
  547. if ($RecipCheckAddress != '')
  548. {
  549. $linkquery = "SELECT distinct *, l.link_id as proper_link_id, UNIX_TIMESTAMP(l.link_updated) as link_date, ";
  550. $linkquery .= "IF (DATE_ADD(l.link_updated, INTERVAL " . get_option('links_recently_updated_time') . " MINUTE) >= NOW(), 1,0) as recently_updated ";
  551. $linkquery .= "FROM " . $this->db_prefix() . "terms t ";
  552. $linkquery .= "LEFT JOIN " . $this->db_prefix() . "term_taxonomy tt ON (t.term_id = tt.term_id) ";
  553. $linkquery .= "LEFT JOIN " . $this->db_prefix() . "term_relationships tr ON (tt.term_taxonomy_id = tr.term_taxonomy_id) ";
  554. $linkquery .= "LEFT JOIN " . $this->db_prefix() . "links l ON (tr.object_id = l.link_id) ";
  555. $linkquery .= "LEFT JOIN " . $this->db_prefix() . "links_extrainfo le ON (l.link_id = le.link_id) ";
  556. $linkquery .= "WHERE tt.taxonomy = 'link_category' ";
  557. $linkquery .= "AND le.link_reciprocal <> '' ";
  558. $linkquery .= "order by l.link_name ASC";
  559.  
  560. $links = $wpdb->get_results($linkquery);
  561. $output = "<strong>Reciprocal Link Checker Report</strong><br /><br />";
  562.  
  563. if ($links)
  564. {
  565. foreach($links as $link)
  566. {
  567. $sitecontent = file_get_contents($link->link_reciprocal);
  568.  
  569. $output .= "<a href='" . $link->link_url . "'>" . $link->link_name . "</a>: ";
  570.  
  571. if (strpos($http_response_header[0], "200")) {
  572. if (strpos($sitecontent, $RecipCheckAddress) === false)
  573. {
  574. $output .= "<span style='color: #FF0000'>Not Found</span><br />";
  575. }
  576. elseif (strpos($sitecontent, $RecipCheckAddress) !== false)
  577. {
  578. $output .= "<span style='color: #00FF00'>OK</span><br />";
  579. }
  580. }
  581. elseif (strpos($http_response_header[0], "403") && $recipcheckdelete403 == true)
  582. {
  583. wp_delete_link($link->link_id);
  584. $output .= "Error 403: Link Deleted";
  585. }
  586. else
  587. $output .= "Website Unreachable";
  588. }
  589. }
  590. else
  591. {
  592. $output = "There are no links with reciprocal links associated with them.<br />";
  593. }
  594.  
  595. return $output;
  596. }
  597. }
  598.  
  599. function ll_get_link_image($url, $name, $mode, $linkid, $cid, $filepath)
  600. {
  601. if ($url != "" && $name != "")
  602. {
  603. if ($mode == 'thumb' || $mode == 'thumbonly')
  604. {
  605. if ($cid == '')
  606. $genthumburl = "http://open.thumbshots.org/image.aspx?url=" . esc_html($url);
  607. elseif ($cid != '')
  608. $genthumburl = "http://images.thumbshots.com/image.aspx?cid=" . $cid . "&v1=w=120&h=90&url=" . esc_html($url);
  609. }
  610. elseif ($mode == 'favicon' || $mode == 'favicononly')
  611. {
  612. $strippedurl = str_replace("http://", "", esc_html($url));
  613. $genthumburl = "http://www.getfavicon.org/?url=" . $strippedurl . "/favicon.png";
  614. }
  615.  
  616. $uploads = wp_upload_dir();
  617.  
  618. if (!file_exists($uploads['basedir']))
  619. {
  620. return __('Please create a folder called uploads under your Wordpress /wp-content/ directory with write permissions to use this functionality.', 'link-library');
  621. }
  622. elseif (!is_writable($uploads['basedir']))
  623. {
  624. return __('Please make sure that the /wp-content/uploads/ directory has write permissions to use this functionality.', 'link-library');
  625. }
  626. else
  627. {
  628. if (!file_exists($uploads['basedir'] . '/' . $filepath))
  629. mkdir($uploads['basedir'] . '/' . $filepath);
  630. }
  631.  
  632. $img = $uploads['basedir'] . "/" . $filepath. "/" . $linkid . ".jpg";
  633. $status = file_put_contents($img, file_get_contents($genthumburl));
  634.  
  635. if ($status !== false)
  636. {
  637. $newimagedata = array("link_id" => $linkid, "link_image" => $uploads['baseurl'] . "/" . $filepath . "/" . $linkid . ".jpg");
  638.  
  639. if ($mode == 'thumb' || $mode == 'favicon')
  640. wp_update_link($newimagedata);
  641.  
  642. return $newimagedata['link_image'];
  643. }
  644. else
  645. return "";
  646. }
  647. return "Parameters are missing";
  648. }
  649.  
  650. //for WordPress 2.8 we have to tell, that we support 2 columns !
  651. function on_screen_layout_columns($columns, $screen) {
  652. return $columns;
  653. }
  654.  
  655. /**
  656. * Returns the full URL of this plugin including trailing slash.
  657. */
  658. function plugin_url() {
  659.  
  660. return WP_PLUGIN_URL . '/' . str_replace( basename( __FILE__ ), "", plugin_basename( __FILE__ ) );
  661. }
  662.  
  663. function action_admin_init() {
  664. // Add addition section to Link Edition page
  665. add_meta_box ('linklibrary_meta_box', __('Link Library - Additional Link Parameters', 'link-library'), array($this, 'll_link_edit_extra'), 'link', 'normal', 'high');
  666.  
  667. //register the callback been used if options of page been submitted and needs to be processed
  668. add_action('admin_post_save_link_library_general', array($this, 'on_save_changes_general'));
  669. add_action('admin_post_save_link_library_settingssets', array($this, 'on_save_changes_settingssets'));
  670. add_action('admin_post_save_link_library_moderate', array($this, 'on_save_changes_moderate'));
  671. add_action('admin_post_save_link_library_stylesheet', array($this, 'on_save_changes_stylesheet'));
  672. add_action('admin_post_save_link_library_reciprocal', array($this, 'on_save_changes_reciprocal'));
  673.  
  674. // Under development, trying to display extra columns in link list page
  675. add_filter('manage_link-manager_columns', array($this, 'll_linkmanager_addcolumn'));
  676. add_action('manage_link_custom_column', array($this, 'll_linkmanager_populatecolumn'), 10, 2);
  677.  
  678. }
  679.  
  680. function filter_mce_buttons( $buttons ) {
  681.  
  682. array_push( $buttons, '|', 'scn_button');
  683. return $buttons;
  684. }
  685.  
  686. function filter_mce_external_plugins( $plugins ) {
  687.  
  688. $plugins['LinkLibraryPlugin'] = $this->plugin_url() . 'tinymce/editor_plugin.js';
  689. return $plugins;
  690. }
  691.  
  692. function ajax_action_check_url() {
  693.  
  694. $hadError = true;
  695.  
  696. $url = isset( $_REQUEST['url'] ) ? $_REQUEST['url'] : '';
  697.  
  698. if ( strlen( $url ) > 0 && function_exists( 'get_headers' ) ) {
  699.  
  700. $file_headers = @get_headers( $url );
  701. $exists = $file_headers && $file_headers[0] != 'HTTP/1.1 404 Not Found';
  702. $hadError = false;
  703. }
  704.  
  705. echo '{ "exists": '. ($exists ? '1' : '0') . ($hadError ? ', "error" : 1 ' : '') . ' }';
  706.  
  707. die();
  708. }
  709.  
  710. function dashboard_widget() {
  711. wp_add_dashboard_widget( 'link_library_dashboard_widget',
  712. 'Link Library',
  713. array( $this, 'render_dashboard_widget' ) );
  714. }
  715.  
  716. function render_dashboard_widget() {
  717. global $wpdb;
  718.  
  719. $linkmoderatecount = 0;
  720.  
  721. $linkmoderatequery = "SELECT count(*) ";
  722. $linkmoderatequery .= "FROM " . $this->db_prefix() . "links l ";
  723. $linkmoderatequery .= "WHERE l.link_description like '%LinkLibrary:AwaitingModeration:RemoveTextToApprove%' ";
  724. $linkmoderatequery .= " ORDER by link_name ASC";
  725.  
  726. $linkmoderatecount = $wpdb->get_var($linkmoderatequery);
  727.  
  728. echo '<strong>' . $linkmoderatecount . '</strong> ';
  729. _e('Links to moderate', 'link-library');
  730. }
  731.  
  732.  
  733. //extend the admin menu
  734. function on_admin_menu() {
  735. //add our own option page, you can also add it to different sections or use your own one
  736. global $wpdb, $pagehooktop, $pagehookmoderate, $pagehooksettingssets, $pagehookstylesheet, $pagehookreciprocal;
  737.  
  738. $linkmoderatecount = 0;
  739.  
  740. $linkmoderatequery = "SELECT count(*) ";
  741. $linkmoderatequery .= "FROM " . $this->db_prefix() . "links l ";
  742. $linkmoderatequery .= "WHERE l.link_description like '%LinkLibrary:AwaitingModeration:RemoveTextToApprove%' ";
  743. $linkmoderatequery .= " ORDER by link_name ASC";
  744.  
  745. $linkmoderatecount = $wpdb->get_var($linkmoderatequery);
  746.  
  747. if ($linkmoderatecount == 0) {
  748. $pagehooktop = add_menu_page('Link Library - ' . __('General Options', 'link-library'), 'Link Library', 'manage_options', LINK_LIBRARY_ADMIN_PAGE_NAME, array($this, 'on_show_page'), plugins_url('icons/folder-beige-internet-icon.png', __FILE__ ) );
  749. } else {
  750. $pagehooktop = add_menu_page('Link Library - ' . __('General Options', 'link-library'), 'Link Library ' . '<span class="update-plugins count-' . $linkmoderatecount . '"><span class="plugin-count">' . number_format_i18n($linkmoderatecount) . '</span></span>', 'manage_options', LINK_LIBRARY_ADMIN_PAGE_NAME, array($this, 'on_show_page'), plugins_url('icons/folder-beige-internet-icon.png', __FILE__ ) );
  751. }
  752.  
  753. $pagehookgeneraloptions = add_submenu_page( LINK_LIBRARY_ADMIN_PAGE_NAME, 'Link Library - ' . __('General Options', 'link-library'), __('General Options', 'link-library'), 'manage_options', LINK_LIBRARY_ADMIN_PAGE_NAME, array($this,'on_show_page') );
  754.  
  755. $pagehooksettingssets = add_submenu_page( LINK_LIBRARY_ADMIN_PAGE_NAME, 'Link Library - ' . __('Settings', 'link-library') , __('Library Settings', 'link-library'), 'manage_options', 'link-library-settingssets', array($this,'on_show_page'));
  756.  
  757. if ($linkmoderatecount == 0)
  758. $pagehookmoderate = add_submenu_page( LINK_LIBRARY_ADMIN_PAGE_NAME, 'Link Library - ' . __('Moderate', 'link-library') , __('Moderate', 'link-library'), 'manage_options', 'link-library-moderate', array($this,'on_show_page'));
  759. else
  760. $pagehookmoderate = add_submenu_page( LINK_LIBRARY_ADMIN_PAGE_NAME, 'Link Library - ' . __('Moderate', 'link-library') , sprintf( __('Moderate', 'link-library') . ' %s', "<span class='update-plugins count-" . $linkmoderatecount . "'><span class='plugin-count'>" . number_format_i18n($linkmoderatecount) . "</span></span>"), 'manage_options', 'link-library-moderate', array($this,'on_show_page'));
  761.  
  762. $pagehookstylesheet = add_submenu_page( LINK_LIBRARY_ADMIN_PAGE_NAME, 'Link Library - ' . __('Stylesheet', 'link-library') , __('Stylesheet', 'link-library'), 'manage_options', 'link-library-stylesheet', array($this,'on_show_page'));
  763.  
  764. $pagehookreciprocal = add_submenu_page( LINK_LIBRARY_ADMIN_PAGE_NAME, 'Link Library - ' . __('Reciprocal Checker', 'link-library') , __('Reciprocal Check', 'link-library'), 'manage_options', 'link-library-reciprocal', array($this,'on_show_page'));
  765.  
  766. //register callback gets call prior your own page gets rendered
  767. add_action('load-'.$pagehooktop, array($this, 'on_load_page'));
  768. add_action('load-'.$pagehooksettingssets, array($this, 'on_load_page'));
  769. add_action('load-'.$pagehookmoderate, array($this, 'on_load_page'));
  770. add_action('load-'.$pagehookstylesheet, array($this, 'on_load_page'));
  771. add_action('load-'.$pagehookreciprocal, array($this, 'on_load_page'));
  772. }
  773.  
  774. //will be executed if wordpress core detects this page has to be rendered
  775. function on_load_page() {
  776.  
  777. global $pagehooktop, $pagehookmoderate, $pagehooksettingssets, $pagehookstylesheet, $pagehookreciprocal;
  778.  
  779. //ensure, that the needed javascripts been loaded to allow drag/drop, expand/collapse and hide/show of boxes
  780. wp_enqueue_script('tiptip', get_bloginfo('wpurl').'/wp-content/plugins/link-library/tiptip/jquery.tipTip.minified.js', "jQuery", "1.0rc3");
  781. wp_enqueue_style('tiptipstyle', get_bloginfo('wpurl').'/wp-content/plugins/link-library/tiptip/tipTip.css');
  782. add_thickbox();
  783. wp_enqueue_script('jquery-ui-sortable');
  784. wp_enqueue_script('common');
  785. wp_enqueue_script('wp-lists');
  786. wp_enqueue_script('postbox');
  787.  
  788. //add several metaboxes now, all metaboxes registered during load page can be switched off/on at "Screen Options" automatically, nothing special to do therefore
  789. add_meta_box('linklibrary_general_meta_box', __('General Settings', 'link-library'), array($this, 'general_meta_box'), $pagehooktop, 'normal', 'high');
  790. add_meta_box('linklibrary_general_bookmarklet_meta_box', __('Bookmarklet', 'link-library'), array($this, 'general_meta_bookmarklet_box'), $pagehooktop, 'normal', 'high');
  791. add_meta_box('linklibrary_general_moderation_meta_box', __('General Moderation Options', 'link-library'), array($this, 'general_moderation_meta_box'), $pagehooktop, 'normal', 'high');
  792. add_meta_box('linklibrary_general_save_meta_box', __('Save', 'link-library'), array($this, 'general_save_meta_box'), $pagehooktop, 'normal', 'high');
  793. add_meta_box('linklibrary_moderation_meta_box', __('Links awaiting moderation', 'link-library'), array($this, 'moderate_meta_box'), $pagehookmoderate, 'normal', 'high');
  794. add_meta_box('linklibrary_stylesheet_meta_box', __('Editor', 'link-library'), array($this, 'stylesheet_meta_box'), $pagehookstylesheet, 'normal', 'high');
  795. add_meta_box('linklibrary_settingssets_usage_meta_box', __('Library Selection and Usage Instructions', 'link-library'), array($this, 'settingssets_usage_meta_box'), $pagehooksettingssets, 'normal', 'high');
  796. add_meta_box('linklibrary_settingssets_side_meta_box', __('Save', 'link-library'), array($this, 'settingssets_save_meta_box'), $pagehooksettingssets, 'normal', 'high');
  797. add_meta_box('linklibrary_settingssets_common_meta_box', __('Common Parameters', 'link-library'), array($this, 'settingssets_common_meta_box'), $pagehooksettingssets, 'normal', 'high');
  798. add_meta_box('linklibrary_settingssets_categories_meta_box', __('Link Categories Settings', 'link-library'), array($this, 'settingssets_categories_meta_box'), $pagehooksettingssets, 'normal', 'high');
  799. add_meta_box('linklibrary_settingssets_linkelement_meta_box', __('Link Element Settings', 'link-library'), array($this, 'settingssets_linkelement_meta_box'), $pagehooksettingssets, 'normal', 'high');
  800. add_meta_box('linklibrary_settingssets_subfieldtable_meta_box', __('Link Sub-Field Configuration Table', 'link-library'), array($this, 'settingssets_subfieldtable_meta_box'), $pagehooksettingssets, 'normal', 'high');
  801. add_meta_box('linklibrary_settingssets_linkpopup_meta_box', __('Link Pop-Up', 'link-library'), array($this, 'settingssets_linkpopup_meta_box'), $pagehooksettingssets, 'normal', 'high');
  802. add_meta_box('linklibrary_settingssets_rssconfig_meta_box', __('RSS Field Configuration', 'link-library'), array($this, 'settingssets_rssconfig_meta_box'), $pagehooksettingssets, 'normal', 'high');
  803. add_meta_box('linklibrary_settingssets_thumbnails_meta_box', __('Thumbnail Generation and Use', 'link-library'), array($this, 'settingssets_thumbnails_meta_box'), $pagehooksettingssets, 'normal', 'high');
  804. add_meta_box('linklibrary_settingssets_rssgen_meta_box', __('RSS Generation', 'link-library'), array($this, 'settingssets_rssgen_meta_box'), $pagehooksettingssets, 'normal', 'high');
  805. add_meta_box('linklibrary_settingssets_search_meta_box', __('Search Form Configuration', 'link-library'), array($this, 'settingssets_search_meta_box'), $pagehooksettingssets, 'normal', 'high');
  806. add_meta_box('linklibrary_settingssets_linksubmission_meta_box', __('Link User Submission', 'link-library'), array($this, 'settingssets_linksubmission_meta_box'), $pagehooksettingssets, 'normal', 'high');
  807. add_meta_box('linklibrary_settingssets_importexport_meta_box', __('Import / Export', 'link-library'), array($this, 'settingssets_importexport_meta_box'), $pagehooksettingssets, 'normal', 'high');
  808. add_meta_box('linklibrary_settingssets_side_meta_box_2', __('Save', 'link-library'), array($this, 'settingssets_save_meta_box'), $pagehooksettingssets, 'normal', 'high');
  809. add_meta_box('linklibrary_reciprocal_meta_box', __('Reciprocal Link Checker', 'link-library'), array($this, 'reciprocal_meta_box'), $pagehookreciprocal, 'normal', 'high');
  810. add_meta_box('linklibrary_reciprocal_save_meta_box', __('Save', 'link-library'), array($this, 'general_save_meta_box'), $pagehookreciprocal, 'normal', 'high');
  811. }
  812.  
  813. //executed to show the plugins complete admin page
  814. function on_show_page() {
  815. //we need the global screen column value to beable to have a sidebar in WordPress 2.8
  816. global $screen_layout_columns;
  817.  
  818. $settings = ( isset( $_GET['settings'] ) ? $_GET['settings'] : 1 );
  819.  
  820. // Retrieve general options
  821. $genoptions = get_option('LinkLibraryGeneral');
  822.  
  823. // If general options don't exist, create them
  824. if ($genoptions == FALSE)
  825. {
  826. $this->ll_reset_gen_settings();
  827. $genoptions = get_option('LinkLibraryGeneral');
  828. }
  829. elseif ($genoptions['schemaversion'] == '' || floatval($genoptions['schemaversion']) < "4.6") // If they exist, make sure they are up to date
  830. {
  831. $this->ll_install();
  832. $genoptions = get_option('LinkLibraryGeneral');
  833. }
  834.  
  835. $settingsname = 'LinkLibraryPP' . $settings;
  836. $options = get_option($settingsname);
  837.  
  838. if ( empty($options) )
  839. {
  840. $this->ll_reset_options($settings, 'list');
  841. $options = get_option($settingsname);
  842. }
  843.  
  844. if ( isset($_GET['genthumbs']) || isset($_GET['genfavicons']) || isset($_GET['genthumbsingle']) || isset($_GET['genfaviconsingle'])) {
  845. global $wpdb;
  846.  
  847. if (isset($_GET['genthumbs']) || isset($_GET['genthumbsingle']))
  848. $filepath = "link-library-images";
  849. elseif (isset($_GET['genfavicons']) || isset($_GET['genfaviconsingle']))
  850. $filepath = "link-library-favicons";
  851.  
  852. $uploads = wp_upload_dir();
  853.  
  854. if (!file_exists($uploads['basedir']))
  855. {
  856. echo "<div id='message' class='updated fade'><p><strong>" . __('Please create a folder called uploads under your Wordpress /wp-content/ directory with write permissions to use this functionality.', 'link-library') . "</strong></p></div>";
  857. }
  858. elseif (!is_writable($uploads['basedir']))
  859. {
  860. echo "<div id='message' class='updated fade'><p><strong>" . __('Please make sure that the /wp-content/uploads/ directory has write permissions to use this functionality.', 'link-library') . "</strong></p></div>";
  861. }
  862. else
  863. {
  864. if (!file_exists($uploads['basedir'] . '/' . $filepath))
  865. mkdir($uploads['basedir'] . '/' . $filepath);
  866.  
  867. if (isset($_GET['genthumbs']) || isset($_GET['genthumbsingle']))
  868. $genmode = 'thumb';
  869. elseif (isset($_GET['genfavicons']) || isset($_GET['genfaviconsingle']))
  870. $genmode = 'favicon';
  871.  
  872. $linkquery = "SELECT distinct * ";
  873. $linkquery .= "FROM " . $this->db_prefix() . "terms t ";
  874. $linkquery .= "LEFT JOIN " . $this->db_prefix() . "term_taxonomy tt ON (t.term_id = tt.term_id) ";
  875. $linkquery .= "LEFT JOIN " . $this->db_prefix() . "term_relationships tr ON (tt.term_taxonomy_id = tr.term_taxonomy_id) ";
  876. $linkquery .= "LEFT JOIN " . $this->db_prefix() . "links l ON (tr.object_id = l.link_id) ";
  877. $linkquery .= "WHERE tt.taxonomy = 'link_category' ";
  878.  
  879. if ($options['categorylist'] != "" && !isset($_GET['genthumbsingle']) && !isset($_GET['genfaviconsingle']))
  880. $linkquery .= " AND t.term_id in (" . $options['categorylist'] . ")";
  881.  
  882. if (isset($_GET['genthumbsingle']) || isset($_GET['genfaviconsingle']))
  883. $linkquery .= " AND l.link_id = " . $_GET['linkid'];
  884.  
  885. $linkitems = $wpdb->get_results($linkquery);
  886.  
  887. if ($linkitems)
  888. {
  889. $filescreated = 0;
  890. $totallinks = count($linkitems);
  891. foreach($linkitems as $linkitem)
  892. {
  893. $this->ll_get_link_image($linkitem->link_url, $linkitem->link_name, $genmode, $linkitem->link_id, $genoptions['thumbshotscid'], $filepath);
  894. $linkname = $linkitem->link_name;
  895. }
  896.  
  897. if (isset($_GET['genthumbs']))
  898. echo "<div id='message' class='updated fade'><p><strong>" . __('Thumbnails successfully generated!', 'link-library') . "</strong></p></div>";
  899. elseif (isset($_GET['genfavicons']))
  900. echo "<div id='message' class='updated fade'><p><strong>" . __('Favicons successfully generated!', 'link-library') . "</strong></p></div>";
  901. elseif (isset($_GET['genthumbsingle']))
  902. echo "<div id='message' class='updated fade'><p><strong>" . __('Thumbnail successfully generated for', 'link-library') . " " . $linkname . ".</strong></p></div>";
  903. elseif (isset($_GET['genfaviconsingle']))
  904. echo "<div id='message' class='updated fade'><p><strong>" . __('Favicon successfully generated for', 'link-library') . " " . $linkname . ".</strong></p></div>";
  905. }
  906. }
  907. }
  908.  
  909. // Check for current page to set some page=specific variables
  910. if ($_GET['page'] == 'link-library')
  911. {
  912. if (isset( $_GET['message'] ) && $_GET['message'] == '1')
  913. echo "<div id='message' class='updated fade'><p><strong>" . __('General Settings Saved', 'link-library') . ".</strong></p></div>";
  914. $formvalue = 'save_link_library_general';
  915. $pagetitle = 'Link Library ' . __('General Settings', 'link-library');
  916. }
  917. elseif ($_GET['page'] == 'link-library-settingssets')
  918. {
  919. $formvalue = 'save_link_library_settingssets';
  920.  
  921. if ( isset($_GET['reset']))
  922. $this->ll_reset_options($settings, 'list');
  923.  
  924. if ( isset($_GET['resettable']) )
  925. $this->ll_reset_options($settings, 'table');
  926.  
  927. if ( isset($_GET['copy']))
  928. {
  929. $destination = $_GET['copy'];
  930. $source = $_GET['source'];
  931.  
  932. $sourcesettingsname = 'LinkLibraryPP' . $source;
  933. $sourceoptions = get_option($sourcesettingsname);
  934.  
  935. $destinationsettingsname = 'LinkLibraryPP' . $destination;
  936. update_option($destinationsettingsname, $sourceoptions);
  937.  
  938. $settings = $destination;
  939. }
  940.  
  941. if ( isset($_GET['deletesettings']) ) {
  942. $settings = $_GET['deletesettings'];
  943. $deletesettingsname = 'LinkLibraryPP' . $settings;
  944. $options = delete_option($deletesettingsname);
  945. $settings = 1;
  946. }
  947.  
  948. $pagetitle = 'Link Library - ' . __('Library', 'link-library') . ' #' . $settings . " - " . $options['settingssetname'];
  949.  
  950. if (isset($_GET['messages']))
  951. {
  952. $messagelist = explode(",", $_GET['messages']);
  953.  
  954. foreach ($messagelist as $message)
  955. {
  956. switch($message) {
  957.  
  958. case '1':
  959. echo "<div id='message' class='updated fade'><p><strong>" . __('Library #', 'link-library') . $settings . " " . __('Updated', 'link-library') . "!</strong></p></div>";
  960. break;
  961.  
  962. case '2':
  963. echo '<br /><br />' . __('Included Category ID', 'link-library') . ' ' . $categoryid . ' ' . __('is invalid. Please check the ID in the Link Category editor.', 'link-library');
  964. break;
  965.  
  966. case '3':
  967. echo '<br /><br />' . __('Excluded Category ID', 'link-library') . ' ' . $categoryid . ' ' . __('is invalid. Please check the ID in the Link Category editor.', 'link-library');
  968. break;
  969.  
  970. case '4':
  971. echo "<div id='message' class='updated fade'><p><strong>" . __('Invalid column count for link on row', 'link-library') . "</strong></p></div>";
  972. break;
  973.  
  974. case '5':
  975. echo "<div id='message' class='updated fade'><p><strong>" . __('Library Settings Exported', 'link-library') . ". <a href='" . plugins_url( 'SettingSet' . $settings . 'Export.csv', __FILE__ ) . "'>" . __('Download here', 'link-library') . "</a>.</strong></p></div>";
  976. break;
  977.  
  978. case '6':
  979. echo "<div id='message' class='updated fade'><p><strong>" . __('Link Library plugin directory needs to be writable to perform this action', 'link-library') . ".</strong></p></div>";
  980. break;
  981.  
  982. case '7':
  983. echo "<div id='message' class='updated fade'><p><strong>" . __('Library Settings imported successfully', 'link-library') . ".</strong></p></div>";
  984. break;
  985.  
  986. case '8':
  987. echo "<div id='message' class='updated fade'><p><strong>" . __('Library Settings Upload Failed', 'link-library') . "</strong></p></div>";
  988. break;
  989.  
  990. case '9':
  991. echo "<div id='message' class='updated fade'><p><strong>" . $_GET['importrowscount'] . " " . __('row(s) found', 'link-library') . ". " . $_GET['successimportcount'] . " " . __('link(s) imported successfully', 'link-library') . ".</strong></p></div>";
  992.  
  993. }
  994.  
  995. }
  996.  
  997. }
  998. }
  999. elseif ($_GET['page'] == 'link-library-moderate')
  1000. {
  1001. $formvalue = 'save_link_library_moderate';
  1002. $pagetitle = 'Link Library - ' . __('Link Moderation', 'link-library');
  1003.  
  1004. if (isset( $_GET['message'] ) && $_GET['message'] == '1')
  1005. echo "<div id='message' class='updated fade'><p><strong>" . __('Link(s) Approved', 'link-library') . "</strong></p></div>";
  1006. elseif (isset( $_GET['message'] ) && $_GET['message'] == '2')
  1007. echo "<div id='message' class='updated fade'><p><strong>" . __('Link(s) Deleted', 'link-library') . "</strong></p></div>";
  1008.  
  1009. ?>
  1010.  
  1011. <?php
  1012. }
  1013. elseif ($_GET['page'] == 'link-library-stylesheet')
  1014. {
  1015. $formvalue = 'save_link_library_stylesheet';
  1016. $pagetitle = 'Link Library ' . __('Stylesheet Editor', 'link-library');
  1017.  
  1018. if (isset( $_GET['message'] ) && $_GET['message'] == '1')
  1019. echo "<div id='message' class='updated fade'><p><strong>" . __('Stylesheet updated', 'link-library') . ".</strong></p></div>";
  1020. elseif (isset( $_GET['message'] ) && $_GET['message'] == '2')
  1021. echo "<div id='message' class='updated fade'><p><strong>" . __('Stylesheet reset to original state', 'link-library') . ".</strong></p></div>";
  1022. }
  1023. elseif ($_GET['page'] == 'link-library-reciprocal')
  1024. {
  1025. $formvalue = 'save_link_library_reciprocal';
  1026. $pagetitle = 'Link Library ' . __('Reciprocal Link Checker', 'link-library');
  1027.  
  1028. if (isset( $_GET['message'] ) && $_GET['message'] == '1')
  1029. echo "<div id='message' class='updated fade'><p><strong>" . __('Settings updated', 'link-library') . ".</strong></p></div>";
  1030. elseif (isset( $_GET['message'] ) && $_GET['message'] == '2')
  1031. {
  1032. echo "<div id='message' class='updated fade'><p>";
  1033. echo $this->ReciprocalLinkChecker($genoptions['recipcheckaddress'], $genoptions['recipcheckdelete403']);
  1034. echo "</p></div>";
  1035. }
  1036. }
  1037.  
  1038. $data = array();
  1039. $data['settings'] = $settings;
  1040. $data['options'] = $options;
  1041. $data['genoptions'] = $genoptions;
  1042. global $pagehooktop, $pagehookmoderate, $pagehookstylesheet, $pagehooksettingssets, $pagehookreciprocal;
  1043. ?>
  1044. <div id="link-library-general" class="wrap">
  1045. <div class='icon32'><img src="<?php echo plugins_url( 'icons/folder-beige-internet-icon32.png', __FILE__ ); ?>" /></div>
  1046. <div ><h2><?php echo $pagetitle; ?><span style='padding-left: 50px'><a href="http://yannickcorner.nayanna.biz/wordpress-plugins/link-library/" target="linklibrary"><img src="<?php echo plugins_url( '/icons/btn_donate_LG.gif', __FILE__ ); ?>" /></a></span></h2></div>
  1047. <div><form name='linklibrary' enctype="multipart/form-data" action="admin-post.php" method="post">
  1048. <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
  1049.  
  1050. <?php wp_nonce_field('link-library'); ?>
  1051. <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false ); ?>
  1052. <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false ); ?>
  1053. <input type="hidden" name="action" value="<?php echo $formvalue; ?>" />
  1054.  
  1055. <style type="text/css">
  1056. #sortable { list-style-type: none; margin: 0; padding: 0; white-space:nowrap; list-style-type:none;}
  1057. #sortable li { list-style: none; margin: 0 6px 4px 6px; padding: 10px 15px 10px 15px; border: #CCCCCC solid 1px; color:#fff; display: inline; width:100px;height: 30px;cursor:move}
  1058. #sortable li span { position: absolute; margin-left: -1.3em; }
  1059. </style>
  1060.  
  1061. <div id="poststuff" class="metabox-holder">
  1062. <div id="post-body" class="has-sidebar">
  1063. <div id="post-body-content" class="has-sidebar-content">
  1064. <?php
  1065. if ($_GET['page'] == 'link-library')
  1066. do_meta_boxes($pagehooktop, 'normal', $data);
  1067. elseif ($_GET['page'] == 'link-library-settingssets')
  1068. do_meta_boxes($pagehooksettingssets, 'normal', $data);
  1069. elseif ($_GET['page'] == 'link-library-moderate')
  1070. do_meta_boxes($pagehookmoderate, 'normal', $data);
  1071. elseif ($_GET['page'] == 'link-library-stylesheet')
  1072. do_meta_boxes($pagehookstylesheet, 'normal', $data);
  1073. elseif ($_GET['page'] == 'link-library-reciprocal')
  1074. do_meta_boxes($pagehookreciprocal, 'normal', $data);
  1075. ?>
  1076. </div>
  1077. </div>
  1078. <br class="clear"/>
  1079. </div>
  1080. </form>
  1081. </div></div>
  1082. <script type="text/javascript">
  1083. //<![CDATA[
  1084. jQuery(document).ready( function($) {
  1085. // close postboxes that should be closed
  1086. $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
  1087. // postboxes setup
  1088. postboxes.add_postbox_toggles('<?php
  1089. if ($_GET['page'] == 'link-library')
  1090. echo $pagehooktop;
  1091. elseif ($_GET['page'] == 'link-library-settingssets')
  1092. echo $pagehooksettingssets;
  1093. elseif ($_GET['page'] == 'link-library-moderate')
  1094. echo $pagehookmoderate;
  1095. elseif ($_GET['page'] == 'link-library-stylesheet')
  1096. echo $pagehookstylesheet;
  1097. elseif ($_GET['page'] == 'link-library-reciprocal')
  1098. echo $pagehookreciprocal;
  1099. ?>');
  1100. });
  1101. //]]>
  1102.  
  1103. // Create the tooltips only on document load
  1104. jQuery(document).ready(function()
  1105. {
  1106. jQuery('.lltooltip').each(function()
  1107. {
  1108. jQuery(this).tipTip();
  1109. }
  1110. );
  1111.  
  1112. jQuery("#sortable").sortable({ opacity: 0.6, cursor: 'move', update: function() {
  1113. var order = jQuery("#sortable").sortable('toArray');
  1114. stringorder = order.join(',')
  1115. document.getElementById('dragndroporder').value = stringorder;
  1116. }
  1117. });
  1118.  
  1119. });
  1120. </script>
  1121.  
  1122. <?php
  1123. }
  1124.  
  1125. //executed if the post arrives initiated by pressing the submit button of form
  1126. function on_save_changes_general() {
  1127. //user permission check
  1128. if ( !current_user_can('manage_options') )
  1129. wp_die( __('Not allowed', 'link-library') );
  1130. //cross check the given referer
  1131. check_admin_referer('link-library');
  1132.  
  1133. $genoptions = get_option('LinkLibraryGeneral');
  1134.  
  1135. foreach (array('numberstylesets', 'includescriptcss', 'pagetitleprefix', 'pagetitlesuffix', 'schemaversion', 'thumbshotscid', 'approvalemailtitle',
  1136. 'moderatorname', 'moderatoremail', 'rejectedemailtitle', 'approvalemailbody', 'rejectedemailbody', 'moderationnotificationtitle',
  1137. 'linksubmissionthankyouurl', 'recipcheckaddress') as $option_name) {
  1138. if (isset($_POST[$option_name])) {
  1139. $genoptions[$option_name] = $_POST[$option_name];
  1140. }
  1141. }
  1142.  
  1143. foreach (array('debugmode', 'emaillinksubmitter', 'usefirstpartsubmittername') as $option_name) {
  1144. if (isset($_POST[$option_name])) {
  1145. $genoptions[$option_name] = true;
  1146. } else {
  1147. $genoptions[$option_name] = false;
  1148. }
  1149. }
  1150.  
  1151. update_option('LinkLibraryGeneral', $genoptions);
  1152.  
  1153. //lets redirect the post request into get request (you may add additional params at the url, if you need to show save results
  1154. wp_redirect($this->remove_querystring_var($_POST['_wp_http_referer'], 'message') . "&message=1");
  1155. }
  1156.  
  1157. //executed if the post arrives initiated by pressing the submit button of form
  1158. function on_save_changes_settingssets() {
  1159. //user permission check
  1160. if ( !current_user_can('manage_options') )
  1161. wp_die( __('Not allowed', 'link-library') );
  1162. //cross check the given referer
  1163. check_admin_referer('link-library');
  1164.  
  1165. $messages = array();
  1166. $row = 0;
  1167. $successfulimport = 0;
  1168.  
  1169. if (isset($_POST['importlinks']))
  1170. {
  1171. global $wpdb;
  1172.  
  1173. $handle = fopen($_FILES['linksfile']['tmp_name'], "r");
  1174.  
  1175. if ($handle)
  1176. {
  1177. $skiprow = 1;
  1178.  
  1179. while (($data = fgetcsv($handle, 5000, ",")) !== FALSE) {
  1180. $row += 1;
  1181. if ($skiprow == 1 && isset($_POST['firstrowheaders']) && $row >= 2)
  1182. $skiprow = 0;
  1183. elseif (!isset($_POST['firstrowheaders']))
  1184. $skiprow = 0;
  1185.  
  1186. if (!$skiprow)
  1187. {
  1188. if (count($data) == 14)
  1189. {
  1190. $existingcatquery = "SELECT t.term_id FROM " . $this->db_prefix() . "terms t, " . $this->db_prefix() . "term_taxonomy tt ";
  1191. $existingcatquery .= "WHERE t.name = '" . $data[5] . "' AND t.term_id = tt.term_id AND tt.taxonomy = 'link_category'";
  1192. $existingcat = $wpdb->get_var($existingcatquery);
  1193.  
  1194. if (!$existingcat)
  1195. {
  1196. $newlinkcatdata = array("cat_name" => $data[5], "category_description" => "", "category_nicename" => $wpdb->escape($data[5]));
  1197. $newlinkcat = wp_insert_category($newlinkcatdata);
  1198.  
  1199. $newcatarray = array("term_id" => $newlinkcat);
  1200.  
  1201. $newcattype = array("taxonomy" => 'link_category');
  1202.  
  1203. $wpdb->update( $this->db_prefix().'term_taxonomy', $newcattype, $newcatarray);
  1204.  
  1205. $newlinkcat = array($newlinkcat);
  1206. }
  1207. else
  1208. {
  1209. $newlinkcat = array($existingcat);
  1210. }
  1211.  
  1212. $newlink = array("link_name" => esc_html(stripslashes($data[0])),
  1213. "link_url" => esc_html(stripslashes($data[1])),
  1214. "link_rss" => esc_html(stripslashes($data[2])),
  1215. "link_description" => esc_html(stripslashes($data[3])),
  1216. "link_notes" => esc_html(stripslashes($data[4])),
  1217. "link_category" => $newlinkcat,
  1218. "link_visible" => $data[6],
  1219. "link_image" => $data[11]);
  1220.  
  1221. $newlinkid = wp_insert_link($newlink);
  1222.  
  1223. if ($newlinkid != 0)
  1224. {
  1225. $extradatatable = $this->db_prefix() . "links_extrainfo";
  1226. $nofollowvalue = ($data[13] == 'Y' ? true : false);
  1227. $wpdb->update( $extradatatable, array( 'link_second_url' => $data[7], 'link_telephone' => $data[8], 'link_email' => $data[9], 'link_reciprocal' => $data[10], 'link_textfield' => esc_html($data[12]), 'link_no_follow' => $nofollowvalue ), array( 'link_id' => $newlinkid ));
  1228.  
  1229. $successfulimport += 1;
  1230. }
  1231. }
  1232. else
  1233. {
  1234. $messages[] = '4';
  1235. }
  1236. }
  1237. }
  1238. }
  1239.  
  1240. if (isset($_POST['firstrowheaders']))
  1241. $row -= 1;
  1242.  
  1243. $messages[] = '9';
  1244. }
  1245. elseif (isset($_POST['exportsettings']))
  1246. {
  1247. if (is_writable(ABSPATH.PLUGINDIR . '/link-library'))
  1248. {
  1249. $myFile = ABSPATH.PLUGINDIR . "/link-library/SettingSet" . $_POST['settingsetid'] . "Export.csv";
  1250. $fh = fopen($myFile, 'w') or die("can't open file");
  1251.  
  1252. $sourcesettingsname = 'LinkLibraryPP' . $_POST['settingsetid'];
  1253. $sourceoptions = get_option($sourcesettingsname);
  1254.  
  1255. $headerrow = array();
  1256.  
  1257. foreach ($sourceoptions as $key => $option)
  1258. {
  1259. $headerrow[] = '"' . $key . '"';
  1260. }
  1261.  
  1262. $headerdata .= join(',', $headerrow)."\n";
  1263. fwrite($fh, $headerdata);
  1264.  
  1265. $datarow = array();
  1266.  
  1267. foreach ($sourceoptions as $key => $option)
  1268. {
  1269. $datarow[] = '"' . $option . '"';
  1270. }
  1271.  
  1272. $data .= join(',', $datarow)."\n";
  1273. fwrite($fh, $data);
  1274.  
  1275. fclose($fh);
  1276.  
  1277. $messages[] = '5';
  1278. }
  1279. else
  1280. $messages[] = '6';
  1281. }
  1282. elseif (isset($_POST['importsettings']))
  1283. {
  1284. global $wpdb;
  1285.  
  1286. if ($_FILES['settingsfile']['tmp_name'] != "")
  1287. {
  1288. $handle = fopen($_FILES['settingsfile']['tmp_name'], "r");
  1289.  
  1290. $row = 1;
  1291. $optionnames = "";
  1292. $options = "";
  1293.  
  1294. while (($data = fgetcsv($handle, 5000, ",")) !== FALSE) {
  1295. if ($row == 1)
  1296. {
  1297. $optionnames = $data;
  1298. $row++;
  1299. }
  1300. else if ($row == 2)
  1301. {
  1302. for ($counter = 0; $counter <= count($data) - 1; $counter++)
  1303. $options[$optionnames[$counter]] = $data[$counter];
  1304. $row++;
  1305. }
  1306. }
  1307.  
  1308. if ($options != "")
  1309. {
  1310. $settingsname = 'LinkLibraryPP' . $_POST['settingsetid'];
  1311.  
  1312. update_option($settingsname, $options);
  1313.  
  1314. $messages[] = '7';
  1315. }
  1316.  
  1317. fclose($handle);
  1318. }
  1319. else
  1320. {
  1321. $messages[] = '8';
  1322. }
  1323. }
  1324. else
  1325. {
  1326. $settingsetid = $_POST['settingsetid'];
  1327. $settings = $_POST['settingsetid'];
  1328.  
  1329. $settingsname = 'LinkLibraryPP' . $settingsetid;
  1330.  
  1331. $options = get_option($settingsname);
  1332.  
  1333. foreach (array('order', 'table_width', 'num_columns', 'categorylist', 'excludecategorylist', 'position',
  1334. 'beforecatlist1', 'beforecatlist2', 'beforecatlist3','catnameoutput', 'linkaddfrequency',
  1335. 'defaultsinglecat', 'rsspreviewcount', 'rssfeedinlinecount', 'linksperpage', 'catdescpos',
  1336. 'catlistdescpos', 'rsspreviewwidth', 'rsspreviewheight', 'numberofrssitems',
  1337. 'displayweblink', 'sourceweblink', 'showtelephone', 'sourcetelephone', 'showemail', 'sourceimage', 'sourcename', 'popup_width', 'popup_height' )
  1338. as $option_name) {
  1339. if (isset($_POST[$option_name])) {
  1340. $options[$option_name] = str_replace("\"", "'", strtolower( $_POST[$option_name] ) );
  1341. }
  1342. }
  1343.  
  1344. foreach (array('linkheader', 'descheader', 'notesheader','linktarget', 'settingssetname', 'loadingicon',
  1345. 'direction', 'linkdirection', 'linkorder', 'addnewlinkmsg', 'linknamelabel', 'linkaddrlabel', 'linkrsslabel',
  1346. 'linkcatlabel', 'linkdesclabel', 'linknoteslabel', 'addlinkbtnlabel', 'newlinkmsg', 'moderatemsg', 'imagepos',
  1347. 'imageclass', 'rssfeedtitle', 'rssfeeddescription', 'showonecatmode', 'linkcustomcatlabel', 'linkcustomcatlistentry',
  1348. 'searchlabel', 'dragndroporder', 'cattargetaddress', 'beforeweblink', 'afterweblink', 'weblinklabel', 'beforetelephone',
  1349. 'aftertelephone', 'telephonelabel', 'beforeemail', 'afteremail', 'emaillabel', 'beforelinkhits', 'afterlinkhits',
  1350. 'linkreciprocallabel', 'linksecondurllabel', 'linktelephonelabel', 'linkemaillabel', 'emailcommand', 'rewritepage',
  1351. 'maxlinks', 'beforedate', 'afterdate', 'beforeimage', 'afterimage', 'beforerss','afterrss', 'beforenote', 'afternote',
  1352. 'beforelink','afterlink', 'beforeitem', 'afteritem', 'beforedesc', 'afterdesc', 'addbeforelink', 'addafterlink',
  1353. 'beforelinkrating', 'afterlinkrating', 'linksubmitternamelabel', 'linksubmitteremaillabel', 'linksubmittercommentlabel',
  1354. 'addlinkcatlistoverride', 'beforelargedescription', 'afterlargedescription', 'customcaptchaquestion', 'customcaptchaanswer',
  1355. 'rssfeedaddress', 'linklargedesclabel', 'flatlist', 'searchresultsaddress', 'link_popup_text') as $option_name) {
  1356. if (isset($_POST[$option_name])) {
  1357. $options[$option_name] = str_replace("\"", "'", $_POST[$option_name]);
  1358. }
  1359. }
  1360.  
  1361. foreach (array('hide_if_empty', 'catanchor', 'showdescription', 'shownotes', 'showrating', 'showupdated', 'show_images',
  1362. 'use_html_tags', 'show_rss', 'nofollow','showcolumnheaders','show_rss_icon', 'showcategorydescheaders',
  1363. 'showcategorydesclinks', 'showadmineditlinks', 'showonecatonly', 'rsspreview', 'rssfeedinline', 'rssfeedinlinecontent',
  1364. 'pagination', 'hidecategorynames', 'showinvisible', 'showdate', 'showuserlinks', 'emailnewlink', 'usethumbshotsforimages',
  1365. 'addlinkreqlogin', 'showcatlinkcount', 'publishrssfeed', 'showname', 'enablerewrite', 'storelinksubmitter', 'showlinkhits', 'showcaptcha',
  1366. 'showlargedescription', 'addlinknoaddress', 'featuredfirst', 'usetextareaforusersubmitnotes', 'showcatonsearchresults', 'shownameifnoimage',
  1367. 'enable_link_popup', 'nocatonstartup')
  1368. as $option_name) {
  1369. if ( isset( $_POST[$option_name] ) ) {
  1370. $options[$option_name] = true;
  1371. } else {
  1372. $options[$option_name] = false;
  1373. }
  1374. }
  1375.  
  1376. foreach(array('displayastable', 'divorheader','showaddlinkrss', 'showaddlinkdesc', 'showaddlinkcat', 'showaddlinknotes','addlinkcustomcat',
  1377. 'showaddlinkreciprocal', 'showaddlinksecondurl', 'showaddlinktelephone', 'showaddlinkemail', 'showcustomcaptcha', 'showlinksubmittername',
  1378. 'showaddlinksubmitteremail', 'showlinksubmittercomment', 'showuserlargedescription') as $option_name) {
  1379. if ($_POST[$option_name] == 'true')
  1380. $options[$option_name] = true;
  1381. elseif ($_POST[$option_name] == 'false')
  1382. $options[$option_name] = false;
  1383. }
  1384.  
  1385. foreach (array('catlistwrappers') as $option_name)
  1386. {
  1387. if (isset($_POST[$option_name])) {
  1388. $options[$option_name] = (int)($_POST[$option_name]);
  1389. }
  1390. }
  1391.  
  1392. update_option($settingsname, $options);
  1393. $messages[] = "1";
  1394.  
  1395. global $wpdb;
  1396.  
  1397. if ($options['categorylist'] != '')
  1398. {
  1399. $categoryids = explode(',', $options['categorylist']);
  1400.  
  1401. foreach($categoryids as $categoryid)
  1402. {
  1403. $linkcatquery = "SELECT distinct t.name, t.term_id, t.slug as category_nicename, tt.description as category_description ";
  1404. $linkcatquery .= "FROM " . $this->db_prefix() . "terms t, " . $this->db_prefix(). "term_taxonomy tt ";
  1405.  
  1406. if (isset($_POST['hide_if_empty']))
  1407. $linkcatquery .= ", " . $this->db_prefix() . "term_relationships tr, " . $this->db_prefix() . "links l ";
  1408.  
  1409. $linkcatquery .= "WHERE t.term_id = tt.term_id AND tt.taxonomy = 'link_category'";
  1410.  
  1411. $linkcatquery .= " AND t.term_id = " . $categoryid;
  1412.  
  1413. $catnames = $wpdb->get_results($linkcatquery);
  1414.  
  1415. if (!$catnames)
  1416. {
  1417. $messages[] = '2';
  1418. }
  1419. }
  1420. }
  1421.  
  1422. if ($options['excludecategorylist'] != '')
  1423. {
  1424. $categoryids = explode(',', $options['excludecategorylist']);
  1425.  
  1426. foreach($categoryids as $categoryid)
  1427. {
  1428. $linkcatquery = "SELECT distinct t.name, t.term_id, t.slug as category_nicename, tt.description as category_description ";
  1429. $linkcatquery .= "FROM " . $this->db_prefix() . "terms t, " . $this->db_prefix(). "term_taxonomy tt ";
  1430.  
  1431. if (isset($_POST['hide_if_empty']))
  1432. $linkcatquery .= ", " . $this->db_prefix() . "term_relationships tr, " . $this->db_prefix() . "links l ";
  1433.  
  1434. $linkcatquery .= "WHERE t.term_id = tt.term_id AND tt.taxonomy = 'link_category'";
  1435.  
  1436. $linkcatquery .= " AND t.term_id = " . $categoryid;
  1437.  
  1438. $catnames = $wpdb->get_results($linkcatquery);
  1439.  
  1440. if (!$catnames)
  1441. {
  1442. $messages[] = '3';
  1443. }
  1444. }
  1445. }
  1446. global $wp_rewrite;
  1447. $wp_rewrite->flush_rules();
  1448. }
  1449.  
  1450. //lets redirect the post request into get request (you may add additional params at the url, if you need to show save results
  1451. $messagelist = implode(",", $messages);
  1452. $cleanredirecturl = $this->remove_querystring_var($_POST['_wp_http_referer'], 'messages');
  1453. $cleanredirecturl = $this->remove_querystring_var($cleanredirecturl, 'importrowscount');
  1454. $cleanredirecturl = $this->remove_querystring_var($cleanredirecturl, 'successimportcount');
  1455. $cleanredirecturl = $this->remove_querystring_var($cleanredirecturl, 'copy');
  1456. $cleanredirecturl = $this->remove_querystring_var($cleanredirecturl, 'reset');
  1457. $cleanredirecturl = $this->remove_querystring_var($cleanredirecturl, 'resettable');
  1458. $cleanredirecturl = $this->remove_querystring_var($cleanredirecturl, 'source');
  1459. $redirecturl = $cleanredirecturl;
  1460.  
  1461. if (!empty($messages))
  1462. $redirecturl = $cleanredirecturl . "&messages=" . $messagelist;
  1463.  
  1464. if ($row != 0)
  1465. $redirecturl .= "&importrowscount=" . $row;
  1466.  
  1467. if ($successfulimport != 0)
  1468. $redirecturl .= "&successimportcount=" . $successfulimport;
  1469.  
  1470. wp_redirect( $redirecturl );
  1471. }
  1472.  
  1473. //executed if the post arrives initiated by pressing the submit button of form
  1474. function on_save_changes_moderate() {
  1475. //user permission check
  1476. if ( !current_user_can('manage_options') )
  1477. wp_die( __('Not allowed', 'link-library') );
  1478. //cross check the given referer
  1479. check_admin_referer('link-library');
  1480.  
  1481. $message = '';
  1482.  
  1483. $genoptions = get_option('LinkLibraryGeneral');
  1484.  
  1485. if (isset($_POST['approvelinks']) && (isset($_POST['links']) && count($_POST['links']) > 0))
  1486. {
  1487. global $wpdb;
  1488.  
  1489. $section = 'moderate';
  1490.  
  1491. foreach ($_POST['links'] as $approved_link)
  1492. {
  1493. $linkdescquery = "SELECT link_description, link_name ";
  1494. $linkdescquery .= "FROM " . $this->db_prefix() . "links l ";
  1495. $linkdescquery .= "WHERE link_id = " . $approved_link;
  1496.  
  1497. $linkdata = $wpdb->get_row($linkdescquery, ARRAY_A);
  1498.  
  1499. $modpos = strpos($linkdata['link_description'], "LinkLibrary:AwaitingModeration:RemoveTextToApprove");
  1500.  
  1501. if ($modpos)
  1502. {
  1503. $startpos = $modpos + 51;
  1504. $newlinkdesc = substr($linkdata['link_description'], $startpos);
  1505.  
  1506. $id = array("id" => $linkdescquery);
  1507. $newdesc = array ("link_description", $newlinkdesc);
  1508.  
  1509. $tablename = $this->db_prefix() . "links";
  1510. $wpdb->update( $tablename, array( 'link_description' => $newlinkdesc, 'link_visible' => 'Y' ), array( 'link_id' => $approved_link ));
  1511. }
  1512.  
  1513. $linkextradata = $wpdb->get_row("select * from " . $this->db_prefix() . "links_extrainfo where link_id = " . $approved_link, ARRAY_A);
  1514.  
  1515. if ($genoptions['emaillinksubmitter'] == true && $linkextradata['link_submitter_email'] != '')
  1516. {
  1517. if ($genoptions['usefirstpartsubmittername'] == true)
  1518. {
  1519. $spacepos = strpos($linkextradata['link_submitter_name'], " ");
  1520. if ($spacepos !== false)
  1521. $linkextradata['link_submitter_name'] = substr($linkextradata['link_submitter_name'], 0, $spacepos);
  1522. }
  1523.  
  1524. $emailtitle = str_replace('%linkname%', $linkdata['link_name'], $genoptions['approvalemailtitle']);
  1525. $emailbody = nl2br($genoptions['approvalemailbody']);
  1526. $emailbody = str_replace('%submittername%', stripslashes($linkextradata['link_submitter_name']), stripslashes($emailbody));
  1527. $emailbody = str_replace('%linkname%', $linkdata['link_name'], $emailbody);
  1528.  
  1529. $headers = "MIME-Version: 1.0\r\n";
  1530. $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
  1531.  
  1532. if ($genoptions['moderatorname'] != '' && $genoptions['moderatoremail'] != '')
  1533. $headers .= "From: \"" . $genoptions['moderatorname'] . "\" <" . $genoptions['moderatoremail'] . ">\n";
  1534.  
  1535. $message = $emailbody;
  1536.  
  1537. $message .= "<br /><br />" . __('Message generated by', 'link-library') . " <a href='http://yannickcorner.nayanna.biz/wordpress-plugins/link-library/'>Link Library</a> for Wordpress";
  1538.  
  1539. wp_mail($linkextradata['link_submitter_email'], $emailtitle, $message, $headers);
  1540. }
  1541. }
  1542.  
  1543. $message = '1';
  1544. }
  1545. elseif (isset($_POST['deletelinks']) && (isset($_POST['links']) && count($_POST['links']) > 0))
  1546. {
  1547. global $wpdb;
  1548.  
  1549. $section = 'moderate';
  1550.  
  1551. foreach ($_POST['links'] as $approved_link)
  1552. {
  1553. $linkdescquery = "SELECT link_description, link_name ";
  1554. $linkdescquery .= "FROM " . $this->db_prefix() . "links l ";
  1555. $linkdescquery .= "WHERE link_id = " . $approved_link;
  1556.  
  1557. $linkdata = $wpdb->get_row($linkdescquery, ARRAY_A);
  1558.  
  1559. $linkextradata = $wpdb->get_row("select * from " . $this->db_prefix() . "links_extrainfo where link_id = " . $approved_link, ARRAY_A);
  1560.  
  1561. if ($genoptions['emaillinksubmitter'] == true && $linkextradata['link_submitter_email'] != '')
  1562. {
  1563. $emailtitle = str_replace('%linkname%', $linkdata['link_name'], $genoptions['rejectedemailtitle']);
  1564. $emailbody = nl2br($genoptions['rejectedemailbody']);
  1565. $emailbody = str_replace('%submittername%', stripslashes($linkextradata['link_submitter_name']), stripslashes($emailbody));
  1566. $emailbody = str_replace('%linkname%', $linkdata['link_name'], $emailbody);
  1567.  
  1568. $headers = "MIME-Version: 1.0\r\n";
  1569. $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
  1570.  
  1571. if ($genoptions['moderatorname'] != '' && $genoptions['moderatoremail'] != '')
  1572. $headers .= "From: \"" . $genoptions['moderatorname'] . "\" <" . $genoptions['moderatoremail'] . ">\n";
  1573.  
  1574. $message = $emailbody;
  1575.  
  1576. $message .= "<br /><br />" . __('Message generated by', 'link-library') . " <a href='http://yannickcorner.nayanna.biz/wordpress-plugins/link-library/'>Link Library</a> for Wordpress";
  1577.  
  1578. wp_mail($linkextradata['link_submitter_email'], $emailtitle, $message, $headers);
  1579. }
  1580.  
  1581. $wpdb->query("DELETE FROM " . $this->db_prefix() . "links WHERE link_id = " . $approved_link);
  1582. }
  1583.  
  1584. $message = '2';
  1585. }
  1586.  
  1587. $cleanredirecturl = $this->remove_querystring_var($_POST['_wp_http_referer'], 'message');
  1588.  
  1589. if ($message != '')
  1590. $redirecturl = $cleanredirecturl . "&message=" . $message;
  1591. else
  1592. $redirecturl = $cleanredirecturl;
  1593.  
  1594. //lets redirect the post request into get request (you may add additional params at the url, if you need to show save results
  1595. wp_redirect($redirecturl);
  1596. }
  1597.  
  1598. function on_save_changes_stylesheet() {
  1599. //user permission check
  1600. if ( !current_user_can('manage_options') )
  1601. wp_die( __('Not allowed', 'link-library') );
  1602. //cross check the given referer
  1603. check_admin_referer('link-library');
  1604.  
  1605. if (isset($_POST['submitstyle']))
  1606. {
  1607. $genoptions = get_option('LinkLibraryGeneral');
  1608.  
  1609. $genoptions['fullstylesheet'] = $_POST['fullstylesheet'];
  1610.  
  1611. update_option('LinkLibraryGeneral', $genoptions);
  1612. $message = 1;
  1613. }
  1614. elseif (isset($_POST['resetstyle']))
  1615. {
  1616. $genoptions = get_option('LinkLibraryGeneral');
  1617.  
  1618. $stylesheetlocation = plugins_url( 'stylesheettemplate.css', __FILE__ );
  1619. if (file_exists($stylesheetlocation))
  1620. $genoptions['fullstylesheet'] = file_get_contents($stylesheetlocation);
  1621.  
  1622. update_option('LinkLibraryGeneral', $genoptions);
  1623.  
  1624. $message = 2;
  1625. }
  1626.  
  1627. //lets redirect the post request into get request (you may add additional params at the url, if you need to show save results
  1628. wp_redirect($this->remove_querystring_var($_POST['_wp_http_referer'], 'message') . "&message=" . $message);
  1629. }
  1630.  
  1631. function on_save_changes_reciprocal() {
  1632. //user permission check
  1633. if ( !current_user_can('manage_options') )
  1634. wp_die( __('Not allowed', 'link-library') );
  1635. //cross check the given referer
  1636. check_admin_referer('link-library');
  1637.  
  1638. $message = -1;
  1639.  
  1640. $genoptions = get_option('LinkLibraryGeneral');
  1641.  
  1642. $genoptions['recipcheckaddress'] = ( ( isset( $_POST['recipcheckaddress'] ) && $_POST['recipcheckaddress'] !== '' ) ? $_POST['recipcheckaddress'] : "" );
  1643. $genoptions['recipcheckdelete403'] = ( ( isset( $_POST['recipcheckdelete403'] ) && $_POST['recipcheckdelete403'] !== '' ) ? $_POST['recipcheckdelete403'] : "" );
  1644.  
  1645. update_option('LinkLibraryGeneral', $genoptions);
  1646.  
  1647. if (!isset($_POST['recipcheck']))
  1648. {
  1649. $message = 1;
  1650. }
  1651. elseif (isset($_POST['recipcheck']))
  1652. {
  1653. $message = 2;
  1654. }
  1655.  
  1656. if ($message != -1)
  1657. $messageend = "&message=" . $message;
  1658. else
  1659. $messageend = '';
  1660.  
  1661. //lets redirect the post request into get request (you may add additional params at the url, if you need to show save results
  1662. wp_redirect($this->remove_querystring_var($_POST['_wp_http_referer'], 'message') . $messageend);
  1663. }
  1664.  
  1665. function general_meta_box($data) {
  1666. $genoptions = $data['genoptions'];
  1667. ?>
  1668. <table>
  1669. <tr>
  1670. <td>
  1671. <input type='hidden' value='<?php echo $genoptions['schemaversion']; ?>' name='schemaversion' id='schemaversion' />
  1672. <table>
  1673. <tr>
  1674. <td class='lltooltip' title='<?php _e('The stylesheet is now defined and stored using the Link Library admin interface. This avoids problems with updates from one version to the next.', 'link-library'); ?>' style='width:200px'><?php _e('Stylesheet','link-library'); ?></td>
  1675. <td class='lltooltip' title='<?php _e('The stylesheet is now defined and stored using the Link Library admin interface. This avoids problems with updates from one version to the next.', 'link-library'); ?>'><a href="<?php echo add_query_arg( array( 'page' => 'link-library-stylesheet', 'section' => 'stylesheet'), admin_url('admin.php') ); ?>"><?php _e('Editor', 'link-library'); ?></a></td>
  1676. </tr>
  1677. <tr>
  1678. <td><?php _e('Number of Libraries','link-library'); ?></td>
  1679. <td><input type="text" id="numberstylesets" name="numberstylesets" size="5" value="<?php if ($genoptions['numberstylesets'] == '') echo '1'; echo $genoptions['numberstylesets']; ?>"/></td>
  1680. </tr>
  1681. <tr>
  1682. <td class="lltooltip" title="<?php _e('Enter comma-separate list of pages on which the Link Library stylesheet and scripts should be loaded. Primarily used if you display Link Library using the API','link-library'); ?>"><?php _e('Additional pages to load styles and scripts','link-library'); ?></td>
  1683. <td class="lltooltip" title="<?php _e('Enter comma-separate list of pages on which the Link Library stylesheet and scripts should be loaded. Primarily used if you display Link Library using the API','link-library'); ?>"><input type="text" id="includescriptcss" name="includescriptcss" size="40" value="<?php echo $genoptions['includescriptcss']; ?>"/></td>
  1684. </tr>
  1685. <tr>
  1686. <td><?php _e('Debug Mode', 'link-library'); ?></td>
  1687. <td><input type="checkbox" id="debugmode" name="debugmode" <?php if ($genoptions['debugmode']) echo ' checked="checked" '; ?>/></td>
  1688. </tr>
  1689. <tr>
  1690. <td class="lltooltip" title="<?php _e('This function is only possible when showing one category at a time and while the default category is not shown.', 'link-library'); ?>"><?php _e('Page Title Prefix','link-library'); ?></td>
  1691. <td class="lltooltip" title="<?php _e('This function is only possible when showing one category at a time and while the default category is not shown.', 'link-library'); ?>"><input type="text" id="pagetitleprefix" name="pagetitleprefix" size="10" value="<?php echo $genoptions['pagetitleprefix']; ?>"/></td>
  1692. </tr>
  1693. <tr>
  1694. <td class="lltooltip" title="<?php _e('This function is only possible when showing one category at a time and while the default category is not shown.', 'link-library'); ?>"><?php _e('Page Title Suffix','link-library'); ?></td>
  1695. <td class="lltooltip" title="<?php _e('This function is only possible when showing one category at a time and while the default category is not shown.', 'link-library'); ?>"><input type="text" id="pagetitlesuffix" name="pagetitlesuffix" size="10" value="<?php echo $genoptions['pagetitlesuffix']; ?>"/></td>
  1696. </tr>
  1697. <tr>
  1698. <td class='lltooltip' title='<?php _e('CID provided with paid Thumbshots.org accounts', 'link-library'); ?>'><?php _e('Thumbshots CID', 'link-library'); ?></td>
  1699. <td colspan='4' class='lltooltip' title='<?php _e('CID provided with paid Thumbshots.org accounts', 'link-library'); ?>'><input type="text" id="thumbshotscid" name="thumbshotscid" size="20" value="<?php echo $genoptions['thumbshotscid']; ?>"/></td>
  1700. </tr>
  1701.  
  1702. </table>
  1703. </td>
  1704. <td style='padding: 8px; border: 1px solid #cccccc;'>
  1705. <div style="width: 400px"><h3>Support the author</h3><br /><table><tr><td><a href="http://www.packtpub.com/wordpress-plugin-development-cookbook/book"><img src='<?php echo plugins_url('icons/7683os_cover_small.jpg', __FILE__); ?>'></td><td></a>Learn how to create your own plugins with my upcoming book, coming out August 2012.<br /><br />Pre-order now!<br /><br /><a href="http://www.packtpub.com/wordpress-plugin-development-cookbook/book">Packt Publishing</a><br /><a href="http://www.amazon.com/dp/1849517681/?tag=packtpubli-20">Amazon.com</a><br /><a href="http://www.amazon.ca/WordPress-Development-Cookbook-Yannick-Lefebvre/dp/1849517681/ref=sr_1_1?ie=UTF8&qid=1336252569&sr=8-1">Amazon.ca</a></td></tr></table></div>
  1706. </td>
  1707. </table>
  1708. <?php }
  1709.  
  1710. function general_meta_bookmarklet_box($data) {
  1711. $bookmarkletcode = 'javascript:void(linkmanpopup=window.open(\''.get_bloginfo('wpurl').'/wp-admin/link-add.php?action=popup&linkurl=\'+escape(location.href)+\'&name=\'+(document.title),\'LinkManager\',\'scrollbars=yes,width=900px,height=600px,left=15,top=15,status=yes,resizable=yes\'));linkmanpopup.focus();window.focus();linkmanpopup.focus();';
  1712. ?>
  1713. <p><?php _e('Add new links to your site with this bookmarklet.', 'link-library'); ?></p>
  1714. <p><?php _e('To use this feature, drag-and-drop the button below to your favorite / bookmark toolbar.', 'link-library'); ?></p>
  1715. <a href="<?php echo $bookmarkletcode; ?>" class='button' title="Add to Links"><?php _e('Add to Links', 'link-library'); ?></a>
  1716.  
  1717. <?php }
  1718.  
  1719. function general_moderation_meta_box($data) {
  1720. $genoptions = $data['genoptions'];
  1721. ?>
  1722. <table>
  1723. <tr>
  1724. <td class='lltooltip' title='<?php _e('URL that user will be redirected to after submitting new link. When used, the short code [link-library-addlinkcustommsg] should be placed on the destination page.', 'link-library'); ?>.' style='width:250px'><?php _e('Link Acknowledgement URL', 'link-library'); ?></td>
  1725. <td class='lltooltip' style='width:75px;padding-right:20px' title='<?php _e('URL that user will be redirected to after submitting new link. When used, the short code [link-library-addlinkcustommsg] should be placed on the destination page.', 'link-library'); ?>.'><input type="text" id="linksubmissionthankyouurl" name="linksubmissionthankyouurl" size="60" value='<?php echo $genoptions['linksubmissionthankyouurl']; ?>' /></td>
  1726. </tr>
  1727. <tr>
  1728. <td class='lltooltip' title='<?php _e('Title of e-mail sent to site admin when new links are submitted. Use %linkname% as a variable to be replaced by the actual link name', 'link-library'); ?>.' style='width:250px'><?php _e('Moderation Notification Title', 'link-library'); ?></td>
  1729. <td style='width:75px;padding-right:20px'><input type="text" id="moderationnotificationtitle" name="moderationnotificationtitle" size="60" value='<?php echo $genoptions['moderationnotificationtitle']; ?>' /></td>
  1730. </tr>
  1731. <tr>
  1732. <td class='lltooltip' title='<?php _e('Will send a confirmation e-mail to link submitter if they provided their contact information', 'link-library'); ?>.' style='width:250px'><?php _e('E-mail submitter on link approval or rejection', 'link-library'); ?></td>
  1733. <td style='width:75px;padding-right:20px'><input type="checkbox" id="emaillinksubmitter" name="emaillinksubmitter" <?php if ($genoptions['emaillinksubmitter']) echo ' checked="checked" '; ?>/></td>
  1734. </tr>
  1735. <tr>
  1736. <td style='width:250px'><?php _e('Only use first part of submitter name', 'link-library'); ?></td>
  1737. <td style='width:75px;padding-right:20px'><input type="checkbox" id="usefirstpartsubmittername" name="usefirstpartsubmittername" <?php if ($genoptions['usefirstpartsubmittername']) echo ' checked="checked" '; ?>/></td>
  1738. </tr>
  1739. <tr>
  1740. <td class='lltooltip' title='<?php _e('The name of the e-mail account that the approval e-mail will be sent from', 'link-library'); ?>'><?php _e('Moderator Name', 'link-library'); ?></td>
  1741. <td><input type="text" id="moderatorname" name="moderatorname" size="60" value="<?php echo $genoptions['moderatorname']; ?>"/></td>
  1742. </tr>
  1743. <tr>
  1744. <td class='lltooltip' title='<?php _e('The e-mail address that the approval e-mail will be sent from', 'link-library'); ?>'><?php _e('Moderator E-mail', 'link-library'); ?></td>
  1745. <td><input type="text" id="moderatoremail" name="moderatoremail" size="60" value="<?php echo $genoptions['moderatoremail']; ?>"/></td>
  1746. </tr>
  1747. <tr>
  1748. <td class='lltooltip' title='<?php _e('Title of approval e-mail. Use %linkname% as a variable to be replaced by the actual link name', 'link-library'); ?>'><?php _e('Approval e-mail title', 'link-library'); ?></td>
  1749. <td><input type="text" id="approvalemailtitle" name="approvalemailtitle" size="60" value="<?php echo $genoptions['approvalemailtitle']; ?>"/></td>
  1750. </tr>
  1751. <tr>
  1752. <td class='lltooltip' title='<?php _e('Body of approval e-mail. Use %linkname% as a variable to be replaced by the actual link name and %submittername% for the submitter name', 'link-library'); ?>'><?php _e('Approval e-mail body', 'link-library'); ?></td>
  1753. <td><textarea id="approvalemailbody" name="approvalemailbody" cols="60"><?php echo stripslashes($genoptions['approvalemailbody']); ?></textarea></td>
  1754. </tr>
  1755. <tr>
  1756. <td class='lltooltip' title='<?php _e('Title of rejection e-mail. Use %linkname% as a variable to be replaced by the actual link name', 'link-library'); ?>'><?php _e('Rejection e-mail title', 'link-library'); ?></td>
  1757. <td><input type="text" id="rejectedemailtitle" name="rejectedemailtitle" size="60" value="<?php echo $genoptions['rejectedemailtitle']; ?>"/></td>
  1758. </tr>
  1759. <tr>
  1760. <td class='lltooltip' title='<?php _e('Body of rejection e-mail. Use %linkname% as a variable to be replaced by the actual link name and %submittername% for the submitter name', 'link-library'); ?>'><?php _e('Rejection e-mail body', 'link-library'); ?></td>
  1761. <td><textarea id="rejectedemailbody" name="rejectedemailbody" cols="60"><?php echo stripslashes($genoptions['rejectedemailbody']); ?></textarea></td>
  1762. </tr>
  1763. </table>
  1764. <?php }
  1765.  
  1766. function general_save_meta_box() {
  1767. ?>
  1768. <div class="submitbox">
  1769. <input type="submit" name="submit" class="button-primary" value="<?php _e('Save','link-library'); ?>" />
  1770. </div>
  1771. <?php
  1772. }
  1773.  
  1774. function settingssets_save_meta_box() {
  1775. ?>
  1776.  
  1777. <div class="submitbox">
  1778. <input type="submit" name="submit" class="button-primary" value="<?php _e('Update Settings','link-library'); ?>" />
  1779. </div>
  1780. <?php
  1781. }
  1782.  
  1783. function moderate_meta_box() {
  1784. ?>
  1785. <table class='widefat' style='clear:none;width:100%;background: #DFDFDF url(/wp-admin/images/gray-grad.png) repeat-x scroll left top;'>
  1786. <tr>
  1787. <th style='width: 30px'></th>
  1788. <th style='width: 200px'><?php _e('Link Name', 'link-library'); ?></th>
  1789. <th style='width: 200px'><?php _e('Link Category', 'link-library'); ?></th>
  1790. <th style='width: 300px'><?php _e('Link URL', 'link-library'); ?></th>
  1791. <th><?php _e('Link Description', 'link-library'); ?></th>
  1792. </tr>
  1793. <?php global $wpdb;
  1794.  
  1795. $linkquery = "SELECT distinct *, l.link_id as true_link_id ";
  1796. $linkquery .= "FROM " . $this->db_prefix() . "terms t ";
  1797. $linkquery .= "LEFT JOIN " . $this->db_prefix() . "term_taxonomy tt ON (t.term_id = tt.term_id) ";
  1798. $linkquery .= "LEFT JOIN " . $this->db_prefix() . "term_relationships tr ON (tt.term_taxonomy_id = tr.term_taxonomy_id) ";
  1799. $linkquery .= "LEFT JOIN " . $this->db_prefix() . "links l ON (tr.object_id = l.link_id) ";
  1800. $linkquery .= "LEFT JOIN " . $this->db_prefix() . "links_extrainfo le ON (l.link_id = le.link_id) ";
  1801. $linkquery .= "WHERE tt.taxonomy = 'link_category'";
  1802. $linkquery .= "AND l.link_description like '%LinkLibrary:AwaitingModeration:RemoveTextToApprove%' ";
  1803. $linkquery .= " ORDER by link_name ASC";
  1804.  
  1805. $linkitems = $wpdb->get_results($linkquery);
  1806.  
  1807. if ($linkitems) {
  1808. foreach($linkitems as $linkitem) {
  1809.  
  1810. $modpos = strpos($linkitem->link_description, "LinkLibrary:AwaitingModeration:RemoveTextToApprove");
  1811.  
  1812. if ($modpos)
  1813. {
  1814. $startpos = $modpos + 51;
  1815. $newlinkdesc = substr($linkitem->link_description, $startpos);
  1816. }
  1817. ?>
  1818. <tr style='background: #FFF'>
  1819. <td><input type="checkbox" name="links[]" value="<?php echo $linkitem->true_link_id; ?>" /></td>
  1820. <td><?php echo "<a title='Edit Link: " . $linkitem->link_name . "' href='" . add_query_arg( array( 'action' => 'edit', 'link_id' => $linkitem->true_link_id ), admin_url( 'link.php' ) ) . "'>" . $linkitem->link_name . "</a>"; ?></td>
  1821. <td><?php echo $linkitem->name; ?></td>
  1822. <td><?php echo "<a href='" . $linkitem->link_url . "'>" . $linkitem->link_url . "</a>"; ?></td>
  1823. <td><?php echo $newlinkdesc; ?></td>
  1824. </tr>
  1825. <?php }
  1826. }
  1827. else { ?>
  1828. <tr>
  1829. <td></td>
  1830. <td><?php _e('No Links Found to Moderate', 'link-library'); ?></td>
  1831. <td></td>
  1832. <td></td>
  1833. </tr>
  1834. <?php } ?>
  1835.  
  1836. </table><br />
  1837. <input type="button" id="CheckAll" value="<?php _e('Check All','link-library'); ?>">
  1838. <input type="button" id="UnCheckAll" value="<?php _e('Uncheck All', 'link-library'); ?>">
  1839.  
  1840. <input type="submit" name="approvelinks" value="<?php _e('Approve Selected Items','link-library'); ?>" />
  1841. <input type="submit" name="deletelinks" value="<?php _e('Delete Selected Items', 'link-library'); ?>" />
  1842.  
  1843. <script type="text/javascript">
  1844. jQuery(document).ready(function()
  1845. {
  1846. jQuery('#CheckAll').click(function() {
  1847. jQuery("INPUT[type='checkbox']").attr('checked', true);
  1848. });
  1849.  
  1850. jQuery('#UnCheckAll').click(function() {
  1851. jQuery("INPUT[type='checkbox']").attr('checked', false);
  1852. });
  1853. });
  1854. </script>
  1855.  
  1856. </div>
  1857.  
  1858. <?php
  1859. }
  1860.  
  1861. function stylesheet_meta_box($data) {
  1862. $genoptions = $data['genoptions'];
  1863. ?>
  1864.  
  1865. <?php _e('If the stylesheet editor is empty after upgrading, reset to the default stylesheet using the button below or copy/paste your backup stylesheet into the editor.', 'link-library'); ?><br /><br />
  1866.  
  1867. <textarea name='fullstylesheet' id='fullstylesheet' style='font-family:Courier' rows="30" cols="100">
  1868. <?php echo stripslashes($genoptions['fullstylesheet']);?>
  1869. </textarea>
  1870. <div><input type="submit" name="submitstyle" value="<?php _e('Submit','link-library'); ?>" /><span style='padding-left: 650px'><input type="submit" name="resetstyle" value="<?php _e('Reset to default','link-library'); ?>" /></span></div>
  1871. <?php
  1872. }
  1873.  
  1874. function settingssets_usage_meta_box($data) {
  1875. $options = $data['options'];
  1876. $settings = $data['settings'];
  1877. $genoptions = $data['genoptions'];
  1878. ?>
  1879. <div>
  1880. <?php _e('Select Current Library Settings', 'link-library'); ?> :
  1881. <SELECT id="settingsetlist" name="settingsetlist" style='width: 300px'>
  1882. <?php if ($genoptions['numberstylesets'] == '') $numberofsets = 1; else $numberofsets = $genoptions['numberstylesets'];
  1883. for ($counter = 1; $counter <= $numberofsets; $counter++): ?>
  1884. <?php $tempoptionname = "LinkLibraryPP" . $counter;
  1885. $tempoptions = get_option($tempoptionname); ?>
  1886. <option value="<?php echo $counter ?>" <?php if ($settings == $counter) echo 'SELECTED';?>><?php _e('Library', 'link-library'); ?> <?php echo $counter ?><?php if ($tempoptions != "") echo " (" . $tempoptions['settingssetname'] . ")"; ?></option>
  1887. <?php endfor; ?>
  1888. </SELECT>
  1889. <INPUT type="button" name="go" value="<?php _e('Go', 'link-library'); ?>!" onClick="window.location= 'admin.php?page=link-library-settingssets&amp;settings=' + jQuery('#settingsetlist').val()">
  1890. <?php if ($numberofsets > 1): ?>
  1891. <?php _e('Copy from:', 'link-library'); ?>
  1892. <SELECT id="copysource" name="copysource" style='width: 300px'>
  1893. <?php for ($counter = 1; $counter <= $numberofsets; $counter++): ?>
  1894. <?php $tempoptionname = "LinkLibraryPP" . $counter;
  1895. $tempoptions = get_option($tempoptionname);
  1896. if ($counter != $settings):?>
  1897. <option value="<?php echo $counter ?>" <?php if ($settings == $counter) echo 'SELECTED';?>><?php _e('Library', 'link-library'); ?> <?php echo $counter ?><?php if ($tempoptions != "") echo " (" . $tempoptions['settingssetname'] . ")"; ?></option>
  1898. <?php endif;
  1899. endfor;
  1900. ?>
  1901. </SELECT>
  1902. <INPUT type="button" name="copy" value="<?php _e('Copy', 'link-library'); ?>!" onClick="window.location= 'admin.php?page=link-library-settingssets&amp;settings=<?php echo $settings; ?>&amp;copy=<?php echo $settings; ?>&source=' + jQuery('#copysource').val()">
  1903. <?php endif; ?>
  1904. <br />
  1905. <br />
  1906. <table class='widefat' style='clear:none;width:100%;background: #DFDFDF url(/wp-admin/images/gray-grad.png) repeat-x scroll left top;'>
  1907. <thead>
  1908. <tr>
  1909. <th style='width:40px' class="lltooltip" title='<?php _e('Link Library Supports the Creation of an unlimited number of configurations to display link lists on your site', 'link-library'); ?>'>
  1910. <?php _e('Library #', 'link-library'); ?>
  1911. </th>
  1912. <th style='width:130px' class="lltooltip" title='<?php _e('Link Library Supports the Creation of an unlimited number of configurations to display link lists on your site', 'link-library'); ?>'>
  1913. <?php _e('Library Name', 'link-library'); ?>
  1914. </th>
  1915. <th style='width: 230px'><?php _e('Feature', 'link-library'); ?></th>
  1916. <th class="lltooltip" title='<?php _e('Link Library Supports the Creation of an unlimited number of configurations to display link lists on your site', 'link-library'); ?>'>
  1917. <?php _e('Code to insert on a Wordpress page', 'link-library'); ?>
  1918. </th>
  1919. </tr>
  1920. </thead>
  1921. <tr>
  1922. <td style='background: #FFF'><?php echo $settings; ?></td><td style='background: #FFF'><?php echo $options['settingssetname']; ?></a></td><td style='background: #FFF'><?php _e('Display basic link library', 'link-library'); ?></td><td style='background: #FFF'><?php echo "[link-library settings=" . $settings . "]"; ?></td>
  1923. </tr>
  1924. <tr>
  1925. <td style='background: #FFF'></td><td style='background: #FFF'></td><td style='background: #FFF'><?php _e('Display list of link categories', 'link-library'); ?></td><td style='background: #FFF'><?php echo "[link-library-cats settings=" . $settings . "]"; ?></td>
  1926. </tr>
  1927. <tr>
  1928. <td style='background: #FFF'></td><td style='background: #FFF'></td><td style='background: #FFF'><?php _e('Display search box', 'link-library'); ?></td><td style='background: #FFF'><?php echo "[link-library-search settings=" . $settings . "]"; ?></td>
  1929. </tr>
  1930. <tr>
  1931. <td style='background: #FFF'></td><td style='background: #FFF'></td><td style='background: #FFF'><?php _e('Display link submission form', 'link-library'); ?></td><td style='background: #FFF'><?php echo "[link-library-addlink settings=" . $settings . "]"; ?></td>
  1932. </tr>
  1933. </table>
  1934. <br />
  1935. </div>
  1936.  
  1937. <div>
  1938. <table>
  1939. <tr>
  1940. <td style='text-align:right'>
  1941. <span><a href='admin.php?page=link-library-settingssets&amp;deletesettings=<?php echo $settings ?>' <?php echo "onclick=\"if ( confirm('" . esc_js(sprintf( __("You are about to Delete Library #'%s'\n 'Cancel' to stop, 'OK' to delete.", "link-library"), $settings )) . "') ) { return true;}return false;\""; ?>><?php _e('Delete Library', 'link-library'); ?> <?php echo $settings ?></a></span>
  1942. <span><a href='admin.php?page=link-library-settingssets&amp;settings=<?php echo $settings ?>&reset=<?php echo $settings; ?>' <?php echo "onclick=\"if ( confirm('" . esc_js(sprintf( __("You are about to reset Library '%s'\n 'Cancel' to stop, 'OK' to reset.", "link-library"), $settings )) . "') ) { return true;}return false;\""; ?>><?php _e('Reset current Library', 'link-library'); ?></a></span>
  1943. <span><a href='admin.php?page=link-library-settingssets&amp;settings=<?php echo $settings ?>&resettable=<?php echo $settings; ?>' <?php echo "onclick=\"if ( confirm('" . esc_js(sprintf( __("You are about to reset Library '%s' for a table layout\n 'Cancel' to stop, 'OK' to reset.", "link-library"), $settings )) . "') ) { return true;}return false;\""; ?>><?php _e('Reset current Library for table layout', 'link-library'); ?></a></span>
  1944. </td>
  1945. </tr>
  1946. </table>
  1947. </div>
  1948. <?php }
  1949.  
  1950. function settingssets_common_meta_box($data) {
  1951. $options = $data['options'];
  1952. $settings = $data['settings'];
  1953. ?>
  1954.  
  1955. <div style='padding-top: 15px'>
  1956. <input type='hidden' value='<?php echo $settings; ?>' name='settingsetid' id='settingsetid' />
  1957. <table>
  1958.  
  1959. <tr>
  1960. <td style='width: 300px;padding-right: 50px'>
  1961. <?php _e('Current Library Name', 'link-library'); ?>
  1962. </td>
  1963. <td>
  1964. <input type="text" id="settingssetname" name="settingssetname" size="40" value="<?php echo $options['settingssetname']; ?>"/>
  1965. </td>
  1966. </tr>
  1967. <tr>
  1968. <td class="lltooltip" title="<?php _e('Leave Empty to see all categories', 'link-library'); ?><br /><br /><?php _e('Enter list of comma-separated', 'link-library'); ?><br /><?php _e('numeric category IDs', 'link-library'); ?><br /><br /><?php _e('To find the IDs, go to the Link Categories admin page, place the mouse above a category name and look for its ID in the address shown in your browsers status bar. For example', 'link-library'); ?>: 2,4,56">
  1969. <?php _e('Categories to be displayed (Empty=All)', 'link-library'); ?>
  1970. </td>
  1971. <td class="lltooltip" title="<?php _e('Leave Empty to see all categories', 'link-library'); ?><br /><br /><?php _e('Enter list of comma-separated', 'link-library'); ?><br /><?php _e('numeric category IDs', 'link-library'); ?><br /><br /><?php _e('For example', 'link-library'); ?>: 2,4,56">
  1972. <input type="text" id="categorylist" name="categorylist" size="40" value="<?php echo $options['categorylist']; ?>"/>
  1973. </td>
  1974. </tr>
  1975. <tr>
  1976. <td class="lltooltip" title="<?php _e('Enter list of comma-separated', 'link-library'); ?><br /><?php _e('numeric category IDs that should not be shown', 'link-library'); ?><br /><br /><?php _e('For example', 'link-library'); ?>: 5,34,43">
  1977. <?php _e('Categories to be excluded', 'link-library'); ?>
  1978. </td>
  1979. <td class="lltooltip" title="<?php _e('Enter list of comma-separated', 'link-library'); ?><br /><?php _e('numeric category IDs that should not be shown', 'link-library'); ?><br /><br /><?php _e('For example', 'link-library'); ?>: 5,34,43">
  1980. <input type="text" id="excludecategorylist" name="excludecategorylist" size="40" value="<?php echo $options['excludecategorylist']; ?>"/>
  1981. </td>
  1982. </tr>
  1983. <tr>
  1984. <td class="lltooltip" title="<?php _e('Only show one category of links at a time', 'link-library'); ?>">
  1985. <?php _e('Only show one category at a time', 'link-library'); ?>
  1986. </td>
  1987. <td class="lltooltip" title="<?php _e('Only show one category of links at a time', 'link-library'); ?>">
  1988. <input type="checkbox" id="showonecatonly" name="showonecatonly" <?php if ($options['showonecatonly']) echo ' checked="checked" '; ?>/>
  1989. </td>
  1990. <td class="lltooltip" title="<?php _e('Select if AJAX should be used to only reload the list of links without reloading the whole page or HTML GET to reload entire page with a new link. The Permalinks option must be enabled for HTML GET + Permalink to work correctly.', 'link-library'); ?>"><?php _e('Switching Method', 'link-library'); ?></td>
  1991. <td>
  1992. <select name="showonecatmode" id="showonecatmode" style="width:200px;">
  1993. <option value="AJAX"<?php if ($options['showonecatmode'] == 'AJAX' || $options['showonecatmode'] == '') { echo ' selected="selected"';} ?>>AJAX</option>
  1994. <option value="HTMLGET"<?php if ($options['showonecatmode'] == 'HTMLGET') { echo ' selected="selected"';} ?>>HTML GET</option>
  1995. <option value="HTMLGETPERM"<?php if ($options['showonecatmode'] == 'HTMLGETPERM') { echo ' selected="selected"';} ?>>HTML GET + Permalink</option>
  1996. </select>
  1997. </td>
  1998. </tr>
  1999. <tr>
  2000. <td>
  2001. <?php _e('Default category to be shown when only showing one at a time (numeric ID)', 'link-library'); ?>
  2002. </td>
  2003. <td>
  2004. <input type="text" id="defaultsinglecat" name="defaultsinglecat" size="4" value="<?php echo $options['defaultsinglecat']; ?>"/>
  2005. </td>
  2006. <td><?php _e('Hide category on start in single cat AJAX mode', 'link-library'); ?></td>
  2007. <td><input type="checkbox" id="nocatonstartup" name="nocatonstartup" <?php if ($options['nocatonstartup']) echo ' checked="checked" '; ?>/></td>
  2008. </tr>
  2009. <tr>
  2010. <td class="lltooltip" title="<?php _e('File path is relative to Link Library plugin directory', 'link-library'); ?>">
  2011. <?php _e('Icon to display when performing AJAX queries', 'link-library'); ?>
  2012. </td>
  2013. <td class="lltooltip" title="<?php _e('File path is relative to Link Library plugin directory', 'link-library'); ?>">
  2014. <input type="text" id="loadingicon" name="loadingicon" size="40" value="<?php if ($options['loadingicon'] == '') {echo '/icons/Ajax-loader.gif';} else {echo strval($options['loadingicon']);} ?>"/>
  2015. </td>
  2016. </tr>
  2017. <tr>
  2018. <td class="lltooltip" title='<?php _e('Only show a limited number of links and add page navigation links', 'link-library'); ?>'>
  2019. <?php _e('Paginate Results', 'link-library'); ?>
  2020. </td>
  2021. <td class="lltooltip" title='<?php _e('Only show a limited number of links and add page navigation links', 'link-library'); ?>'>
  2022. <input type="checkbox" id="pagination" name="pagination" <?php if ($options['pagination']) echo ' checked="checked" '; ?>/>
  2023. </td>
  2024. <td class="lltooltip" title="<?php _e('Number of Links to be Displayed per Page in Pagination Mode', 'link-library'); ?>">
  2025. <?php _e('Links per Page', 'link-library'); ?>
  2026. </td>
  2027. <td class="lltooltip" title="<?php _e('Number of Links to be Displayed per Page in Pagination Mode', 'link-library'); ?>">
  2028. <input type="text" id="linksperpage" name="linksperpage" size="3" value="<?php echo $options['linksperpage']; ?>"/>
  2029. </td>
  2030. </tr>
  2031. <tr>
  2032. <td>
  2033. <?php _e('Hide Results if Empty', 'link-library'); ?>
  2034. </td>
  2035. <td>
  2036. <input type="checkbox" id="hide_if_empty" name="hide_if_empty" <?php if ($options['hide_if_empty']) echo ' checked="checked" '; ?>/>
  2037. </td>
  2038. </tr>
  2039. <tr>
  2040. <td>
  2041. <?php _e('Enable Permalinks', 'link-library'); ?>
  2042. </td>
  2043. <td>
  2044. <input type="checkbox" id="enablerewrite" name="enablerewrite" <?php if ($options['enablerewrite']) echo ' checked="checked" '; ?>/>
  2045. </td>
  2046. <td>
  2047. <?php _e('Permalinks Page', 'link-library'); ?>
  2048. </td>
  2049. <td>
  2050. <input type="text" id="rewritepage" name="rewritepage" size="40" value="<?php echo $options['rewritepage']; ?>"/>
  2051. </td>
  2052. </tr>
  2053. </table>
  2054. </div>
  2055.  
  2056. <?php }
  2057.  
  2058. function settingssets_categories_meta_box($data)
  2059. {
  2060. $options = $data['options'];
  2061. $settings = $data['settings'];
  2062. ?>
  2063. <div style='padding-top:15px'>
  2064. <table>
  2065. <tr>
  2066. <td>
  2067. <?php _e('Results Order', 'link-library'); ?>
  2068. </td>
  2069. <td>
  2070. <select name="order" id="order" style="width:200px;">
  2071. <option value="name"<?php if ($options['order'] == 'name') { echo ' selected="selected"';} ?>><?php _e('Order by Name', 'link-library'); ?></option>
  2072. <option value="id"<?php if ($options['order'] == 'id') { echo ' selected="selected"';} ?>><?php _e('Order by ID', 'link-library'); ?></option>
  2073. <option value="catlist"<?php if ($options['order'] == 'catlist') { echo ' selected="selected"';} ?>><?php _e('Order of categories based on included category list', 'link-library'); ?></option>
  2074. <option value="order"<?php if ($options['order'] == 'order') { echo ' selected="selected"';} ?>><?php _e('Order by', 'link-library'); ?> 'My Link Order' <?php _e('Wordpress Plugin', 'link-library'); ?></option>
  2075. </select>
  2076. </td>
  2077. <td style='width:100px'></td>
  2078. <td style='width:200px'>
  2079. <?php _e('Link Categories Display Format', 'link-library'); ?>
  2080. </td>
  2081. <td>
  2082. <select name="flatlist" id="flatlist" style="width:200px;">
  2083. <option value="table"<?php if ($options['flatlist'] == 'table') { echo ' selected="selected"';} ?>><?php _e('Table', 'link-library'); ?></option>
  2084. <option value="unordered"<?php if ($options['flatlist'] == 'unordered') { echo ' selected="selected"';} ?>><?php _e('Unordered List', 'link-library'); ?></option>
  2085. <option value="dropdown"<?php if ($options['flatlist'] == 'dropdown') { echo ' selected="selected"';} ?>><?php _e('Drop-Down List', 'link-library'); ?></option>
  2086. </select>
  2087. </td>
  2088. </tr>
  2089. <tr>
  2090. <td>
  2091. <?php _e('Display link counts', 'link-library'); ?>
  2092. </td>
  2093. <td>
  2094. <input type="checkbox" id="showcatlinkcount" name="showcatlinkcount" <?php if ($options['showcatlinkcount']) echo ' checked="checked" '; ?>/>
  2095. </td>
  2096. <td style='width:100px'></td>
  2097. <td style='width:200px'><?php _e('Display categories with search results', 'link-library'); ?> </td>
  2098. <td><input type="checkbox" id="showcatonsearchresults" name="showcatonsearchresults" <?php if ($options['showcatonsearchresults']) echo ' checked="checked" '; ?>/></td>
  2099. </tr>
  2100. <tr>
  2101. <td class="lltooltip" title="<?php _e('This setting does not apply when selecting My Link Order for the order', 'link-library'); ?>">
  2102. <?php _e('Direction', 'link-library'); ?>
  2103. </td>
  2104. <td class="lltooltip" title="<?php _e('This setting does not apply when selecting My Link Order for the order', 'link-library'); ?>">
  2105. <select name="direction" id="direction" style="width:100px;">
  2106. <option value="ASC"<?php if ($options['direction'] == 'ASC') { echo ' selected="selected"';} ?>><?php _e('Ascending', 'link-library'); ?></option>
  2107. <option value="DESC"<?php if ($options['direction'] == 'DESC') { echo ' selected="selected"';} ?>><?php _e('Descending', 'link-library'); ?></option>
  2108. </select>
  2109. </td>
  2110. <td></td>
  2111. <td class="lltooltip" title="<?php _e('Use [ and ] in the description to perform special actions using HTML such as inserting images instead of < and >', 'link-library'); ?>">
  2112. <?php _e('Show Category Description', 'link-library'); ?>
  2113. </td>
  2114. <td class="lltooltip" title="<?php _e('Use [ and ] in the description to perform special actions using HTML such as inserting images instead of < and >', 'link-library'); ?>">
  2115. <input type="checkbox" id="showcategorydescheaders" name="showcategorydescheaders" <?php if ($options['showcategorydescheaders']) echo ' checked="checked" '; ?>/>
  2116. <span style='margin-left: 17px'><?php _e('Position', 'link-library'); ?>:</span>
  2117. <select name="catlistdescpos" id="catlistdescpos" style="width:100px;">
  2118. <option value="right"<?php if ($options['catlistdescpos'] == 'right') { echo ' selected="selected"';} ?>><?php _e('Right', 'link-library'); ?></option>
  2119. <option value="left"<?php if ($options['catlistdescpos'] == 'left') { echo ' selected="selected"';} ?>><?php _e('Left', 'link-library'); ?></option>
  2120. </select>
  2121. </td>
  2122. </tr>
  2123. <tr>
  2124. <td>
  2125. <?php _e('Width of Categories Table in Percents', 'link-library'); ?>
  2126. </td>
  2127. <td>
  2128. <input type="text" id="table_width" name="table_width" size="10" value="<?php echo strval($options['table_width']); ?>"/>
  2129. </td>
  2130. <td></td>
  2131. <td class="lltooltip" title='<?php _e('Determines the number of alternating div tags that will be placed before and after each link category', 'link-library'); ?>.<br /><br /><?php _e('These div tags can be used to style of position link categories on the link page', 'link-library'); ?>.'>
  2132. <?php _e('Number of alternating div classes', 'link-library'); ?>
  2133. </td>
  2134. <td class="lltooltip" title='<?php _e('Determines the number of alternating div tags that will be placed before and after each link category', 'link-library'); ?>.<br /><br /><?php _e('These div tags can be used to style of position link categories on the link page', 'link-library'); ?>.'>
  2135. <select name="catlistwrappers" id="catlistwrappers" style="width:200px;">
  2136. <option value="1"<?php if ($options['catlistwrappers'] == 1) { echo ' selected="selected"';} ?>>1</option>
  2137. <option value="2"<?php if ($options['catlistwrappers'] == 2) { echo ' selected="selected"';} ?>>2</option>
  2138. <option value="3"<?php if ($options['catlistwrappers'] == 3) { echo ' selected="selected"';} ?>>3</option>
  2139. </select>
  2140. </td>
  2141. </tr>
  2142. <tr>
  2143. <td>
  2144. <?php _e('Number of columns in Categories Table', 'link-library'); ?>
  2145. </td>
  2146. <td>
  2147. <input type="text" id="num_columns" name="num_columns" size="10" value="<?php echo strval($options['num_columns']); ?>">
  2148. </td>
  2149. <td></td>
  2150. <td>
  2151. <?php _e('First div class name', 'link-library'); ?>
  2152. </td>
  2153. <td>
  2154. <input type="text" id="beforecatlist1" name="beforecatlist1" size="40" value="<?php echo $options['beforecatlist1']; ?>" />
  2155. </td>
  2156. </tr>
  2157. <tr>
  2158. <td>
  2159. <?php _e('Use Div Class or Heading tag around Category Names', 'link-library'); ?>
  2160. </td>
  2161. <td>
  2162. <select name="divorheader" id="divorheader" style="width:200px;">
  2163. <option value="false"<?php if ($options['divorheader'] == false) { echo ' selected="selected"';} ?>><?php _e('Div Class', 'link-library'); ?></option>
  2164. <option value="true"<?php if ($options['divorheader'] == true) { echo ' selected="selected"';} ?>><?php _e('Heading Tag', 'link-library'); ?></option>
  2165. </select>
  2166. </td>
  2167. <td></td>
  2168. <td>
  2169. <?php _e('Second div class name', 'link-library'); ?>
  2170. </td>
  2171. <td>
  2172. <input type="text" id="beforecatlist2" name="beforecatlist2" size="40" value="<?php echo $options['beforecatlist2']; ?>" />
  2173. </td>
  2174. </tr>
  2175. <tr>
  2176. <td class="lltooltip" title="<?php _e('Example div class name: linklistcatname, Example Heading Label: h3', 'link-library'); ?>">
  2177. <?php _e('Div Class Name or Heading label', 'link-library'); ?>
  2178. </td>
  2179. <td class="lltooltip" title="<?php _e('Example div class name: linklistcatname, Example Heading Label: h3', 'link-library'); ?>">
  2180. <input type="text" id="catnameoutput" name="catnameoutput" size="30" value="<?php echo strval($options['catnameoutput']); ?>"/>
  2181. </td>
  2182. <td></td>
  2183. <td>
  2184. <?php _e('Third div class name', 'link-library'); ?>
  2185. </td>
  2186. <td>
  2187. <input type="text" id="beforecatlist3" name="beforecatlist3" size="40" value="<?php echo $options['beforecatlist3']; ?>" />
  2188. </td>
  2189. </tr>
  2190. <tr>
  2191. <td class="lltooltip" title="<?php _e('Set this address to a page running Link Library to place categories on a different page. Should always be used with the Show One Category at a Time and HTMLGET fetch method.', 'link-library'); ?>">
  2192. <?php _e('Category Target Address', 'link-library'); ?>
  2193. </td>
  2194. <td colspan="4" class="lltooltip" title="<?php _e('Set this address to a page running Link Library to place categories on a different page. Should always be used with the Show One Category at a Time and HTMLGET fetch method.', 'link-library'); ?>">
  2195. <input type="text" id="cattargetaddress" name="cattargetaddress" size="120" value="<?php echo $options['cattargetaddress']; ?>" /></td>
  2196. </tr>
  2197. </table>
  2198. </div>
  2199. <?php }
  2200.  
  2201. function settingssets_linkelement_meta_box($data) {
  2202. $options = $data['options'];
  2203. $settings = $data['settings'];
  2204. ?>
  2205.  
  2206. <table>
  2207. <tr>
  2208. <td>
  2209. <?php _e('Link Results Order', 'link-library'); ?>
  2210. </td>
  2211. <td>
  2212. <select name="linkorder" id="linkorder" style="width:250px;">
  2213. <option value="name"<?php if ($options['linkorder'] == 'name') { echo ' selected="selected"';} ?>><?php _e('Order by Name', 'link-library'); ?></option>
  2214. <option value="id"<?php if ($options['linkorder'] == 'id') { echo ' selected="selected"';} ?>><?php _e('Order by ID', 'link-library'); ?></option>
  2215. <option value="order"<?php if ($options['linkorder'] == 'order') { echo ' selected="selected"';} ?>><?php _e('Order set by ', 'link-library'); ?>'My Link Order' <?php _e('Wordpress Plugin', 'link-library'); ?></option>
  2216. <option value="random"<?php if ($options['linkorder'] == 'random') { echo ' selected="selected"';} ?>><?php _e('Order randomly', 'link-library'); ?></option>
  2217. <option value="date"<?php if ($options['linkorder'] == 'date') { echo ' selected="selected"';} ?>><?php _e('Order by updated date', 'link-library'); ?></option>
  2218. </select>
  2219. </td>
  2220. <td style='width:100px'></td>
  2221. <td class="lltooltip" title="<?php _e('Use [ and ] in the description to perform special actions using HTML such as inserting images instead of < and >', 'link-library'); ?>">
  2222. <?php _e('Show Category Description', 'link-library'); ?>
  2223. </td>
  2224. <td class="lltooltip" title="<?php _e('Use [ and ] in the description to perform special actions using HTML such as inserting images instead of < and >', 'link-library'); ?>">
  2225. <input type="checkbox" id="showcategorydesclinks" name="showcategorydesclinks" <?php if ($options['showcategorydesclinks']) echo ' checked="checked" '; ?>/>
  2226. <span style='margin-left: 17px'><?php _e('Position', 'link-library'); ?>:</span>
  2227. <select name="catdescpos" id="catdescpos" style="width:100px;">
  2228. <option value="right"<?php if ($options['catdescpos'] == 'right') { echo ' selected="selected"';} ?>><?php _e('Right', 'link-library'); ?></option>
  2229. <option value="left"<?php if ($options['catdescpos'] == 'left') { echo ' selected="selected"';} ?>><?php _e('Left', 'link-library'); ?></option>
  2230. </select>
  2231. </td>
  2232. </tr>
  2233. <tr>
  2234. <td><?php _e('List Featured Links ahead of Regular Links', 'link-library'); ?></td>
  2235. <td><input type="checkbox" id="featuredfirst" name="featuredfirst" <?php if ($options['featuredfirst']) echo ' checked="checked" '; ?>/></td>
  2236. </tr>
  2237. <tr>
  2238. <td class="lltooltip" title='<?php _e('Except for My Link Order mode', 'link-library'); ?>'>
  2239. <?php _e('Direction', 'link-library'); ?>
  2240. </td>
  2241. <td class="lltooltip" title='<?php _e('Except for My Link Order mode', 'link-library'); ?>'>
  2242. <select name="linkdirection" id="linkdirection" style="width:200px;">
  2243. <option value="ASC"<?php if ($options['linkdirection'] == 'ASC') { echo ' selected="selected"';} ?>><?php _e('Ascending', 'link-library'); ?></option>
  2244. <option value="DESC"<?php if ($options['linkdirection'] == 'DESC') { echo ' selected="selected"';} ?>><?php _e('Descending', 'link-library'); ?></option>
  2245. </select>
  2246. </td>
  2247. <td></td>
  2248. <td class="lltooltip" title="<?php _e('Leave empty to show all results', 'link-library'); ?>">
  2249. <?php _e('Max number of links to display', 'link-library'); ?>
  2250. </td>
  2251. <td class="lltooltip" title="<?php _e('Leave empty to show all results', 'link-library'); ?>">
  2252. <input type="text" id="maxlinks" name="maxlinks" size="4" value="<?php echo $options['maxlinks']; ?>"/>
  2253. </td>
  2254. </tr>
  2255. <tr>
  2256. <td class="lltooltip" title="<?php _e('Sets default link target window, does not override specific targets set in links', 'link-library'); ?>">
  2257. <?php _e('Link Target', 'link-library'); ?>
  2258. </td>
  2259. <td class="lltooltip" title="<?php _e('Sets default link target window, does not override specific targets set in links', 'link-library'); ?>">
  2260. <input type="text" id="linktarget" name="linktarget" size="40" value="<?php echo $options['linktarget']; ?>"/>
  2261. </td>
  2262. <td></td>
  2263. <td>
  2264. <?php _e('Link Display Format', 'link-library'); ?>
  2265. </td>
  2266. <td>
  2267. <select name="displayastable" id="displayastable" style="width:200px;">
  2268. <option value="true"<?php if ($options['displayastable'] == true) { echo ' selected="selected"';} ?>><?php _e('Table', 'link-library'); ?></option>
  2269. <option value="false"<?php if ($options['displayastable'] == false) { echo ' selected="selected"';} ?>><?php _e('Unordered List', 'link-library'); ?></option>
  2270. </select>
  2271. </td>
  2272. </tr>
  2273. <tr>
  2274. <td>
  2275. <?php _e('Show Column Headers', 'link-library'); ?>
  2276. </td>
  2277. <td>
  2278. <input type="checkbox" id="showcolumnheaders" name="showcolumnheaders" <?php if ($options['showcolumnheaders']) echo ' checked="checked" '; ?>/>
  2279. </td>
  2280. <td></td>
  2281. <td>
  2282. <?php _e('Link Column Header', 'link-library'); ?>
  2283. </td>
  2284. <td>
  2285. <input type="text" id="linkheader" name="linkheader" size="40" value="<?php echo $options['linkheader']; ?>"/>
  2286. </td>
  2287. </tr>
  2288. <tr>
  2289. <td>
  2290. <?php _e('Description Column Header', 'link-library'); ?>
  2291. </td>
  2292. <td>
  2293. <input type="text" id="descheader" name="descheader" size="40" value="<?php echo $options['descheader']; ?>"/>
  2294. </td>
  2295. <td></td>
  2296. <td>
  2297. <?php _e('Notes Column Header', 'link-library'); ?>
  2298. </td>
  2299. <td>
  2300. <input type="text" id="notesheader" name="notesheader" size="40" value="<?php echo $options['notesheader']; ?>"/>
  2301. </td>
  2302. </tr>
  2303. <tr>
  2304. <td>
  2305. <?php _e('Hide Category Names', 'link-library'); ?>
  2306. </td>
  2307. <td>
  2308. <input type="checkbox" id="hidecategorynames" name="hidecategorynames" <?php if ($options['hidecategorynames'] == true) echo ' checked="checked" '; ?>/>
  2309. </td>
  2310. <td></td>
  2311. <td>
  2312. <?php _e('Show Hidden Links', 'link-library'); ?>
  2313. </td>
  2314. <td>
  2315. <input type="checkbox" id="showinvisible" name="showinvisible" <?php if ($options['showinvisible'] == true) echo ' checked="checked" '; ?>/>
  2316. </td>
  2317. </tr>
  2318. <tr>
  2319. <td class="lltooltip" title='<?php _e('Need to be active for Link Categories to work', 'link-library'); ?>'>
  2320. <?php _e('Embed HTML anchors', 'link-library'); ?>
  2321. </td>
  2322. <td class="lltooltip" title='<?php _e('Need to be active for Link Categories to work', 'link-library'); ?>'>
  2323. <input type="checkbox" id="catanchor" name="catanchor" <?php if ($options['catanchor']) echo ' checked="checked" '; ?>/>
  2324. </td>
  2325. </tr>
  2326. </table>
  2327. <?php }
  2328.  
  2329. function settingssets_subfieldtable_meta_box($data) {
  2330. $options = $data['options'];
  2331. $settings = $data['settings'];
  2332. ?>
  2333.  
  2334. <?php _e('Arrange the items below via drag-and-drop to order the various Link Library elements.', 'link-library'); ?><br /><br />
  2335. <ul id="sortable">
  2336. <?php if ($options['dragndroporder'] == '') $dragndroporder = '1,2,3,4,5,6,7,8,9,10'; else $dragndroporder = $options['dragndroporder'];
  2337. $dragndroparray = explode(',', $dragndroporder);
  2338. if ($dragndroparray)
  2339. {
  2340. foreach ($dragndroparray as $arrayelements) {
  2341. switch ($arrayelements) {
  2342. case 1: ?>
  2343. <li id="1" style='background-color: #1240ab'><?php _e('Image', 'link-library'); ?></li>
  2344. <?php break;
  2345. case 2: ?>
  2346. <li id="2" style='background-color: #4671d5'><?php _e('Name', 'link-library'); ?></li>
  2347. <?php break;
  2348. case 3: ?>
  2349. <li id="3" style='background-color: #39e639'><?php _e('Date', 'link-library'); ?></li>
  2350. <?php break;
  2351. case 4: ?>
  2352. <li id="4" style='background-color: #009999'><?php _e('Desc', 'link-library'); ?></li>
  2353. <?php break;
  2354. case 5: ?>
  2355. <li id="5" style='background-color: #00cc00'><?php _e('Notes', 'link-library'); ?></li>
  2356. <?php break;
  2357. case 6: ?>
  2358. <li id="6" style='background-color: #008500'><?php _e('RSS', 'link-library'); ?></li>
  2359. <?php break;
  2360. case 7: ?>
  2361. <li id="7" style='background-color: #5ccccc'><?php _e('Web Link', 'link-library'); ?></li>
  2362. <?php break;
  2363. case 8: ?>
  2364. <li id="8" style='background-color: #6c8cd5'><?php _e('Phone', 'link-library'); ?></li>
  2365. <?php break;
  2366. case 9: ?>
  2367. <li id="9" style='background-color: #67e667'><?php _e('E-mail', 'link-library'); ?></li>
  2368. <?php break;
  2369. case 10: ?>
  2370. <li id="10" style='background-color: #33cccc'><?php _e('Hits', 'link-library'); ?></li>
  2371. <?php break;
  2372. case 11: ?>
  2373. <li id="11" style='background-color: #33cc00'><?php _e('Rating', 'link-library'); ?></li>
  2374. <?php break;
  2375. case 12: ?>
  2376. <li id="12" style='background-color: #33ccff'><?php _e('Large Desc', 'link-library'); ?></li>
  2377. <?php break;
  2378. }
  2379. }
  2380. }
  2381. ?>
  2382. </ul>
  2383. <input type="hidden" id="dragndroporder" name="dragndroporder" size="60" value="<?php echo $options['dragndroporder']; ?>"/>
  2384. <br />
  2385. <table class='widefat' style='width: 1000px;margin:15px 5px 10px 0px;clear:none;background: #DFDFDF url(/wp-admin/images/gray-grad.png) repeat-x scroll left top;'>
  2386. <thead>
  2387. <th style='width: 100px'></th>
  2388. <th style='width: 40px'><?php _e('Display', 'link-library'); ?></th>
  2389. <th style='width: 80px'><?php _e('Before', 'link-library'); ?></th>
  2390. <th style='width: 80px'><?php _e('After', 'link-library'); ?></th>
  2391. <th style='width: 80px'><?php _e('Additional Details', 'link-library'); ?></th>
  2392. <th style='width: 80px'><?php _e('Link Source', 'link-library'); ?></th>
  2393. </thead>
  2394. <tr>
  2395. <td class="lltooltip" title='<?php _e('This column allows for the output of text/code before a number of links determined by the Display field', 'link-library'); ?>'><?php _e('Intermittent Before Link', 'link-library'); ?></td>
  2396. <td style='background: #FFF' class="lltooltip" title='<?php _e('Frequency of additional output before and after complete link group', 'link-library'); ?>'>
  2397. <input type="text" id="linkaddfrequency" name="linkaddfrequency" size="10" value="<?php echo strval($options['linkaddfrequency']); ?>"/>
  2398. </td>
  2399. <td style='background: #FFF' class="lltooltip" title='<?php _e('Output before complete link group (link, notes, desc, etc...)', 'link-library'); ?>'>
  2400. <input type="text" id="addbeforelink" name="addbeforelink" size="22" value="<?php echo stripslashes($options['addbeforelink']); ?>"/>
  2401. </td>
  2402. <td style='background: #FFF'></td>
  2403. <td style='background: #FFF'></td>
  2404. <td style='background: #FFF'></td>
  2405. </tr>
  2406. <tr>
  2407. <td class="lltooltip" title='<?php _e('This column allows for the output of text/code before each link', 'link-library'); ?>'><?php _e('Before Link', 'link-library'); ?></td>
  2408. <td style='background: #FFF'></td>
  2409. <td style='background: #FFF' class="lltooltip" title='<?php _e('Output before complete link group (link, notes, desc, etc...)', 'link-library'); ?>'>
  2410. <input type="text" id="beforeitem" name="beforeitem" size="22" value="<?php echo stripslashes($options['beforeitem']); ?>"/>
  2411. </td>
  2412. <td style='background: #FFF'></td>
  2413. <td style='background: #FFF'></td>
  2414. <td style='background: #FFF'></td>
  2415. </tr>
  2416. <?php if ($options['dragndroporder'] == '') $dragndroporder = '1,2,3,4,5,6,7,8,9,10'; else $dragndroporder = $options['dragndroporder'];
  2417. $dragndroparray = explode(',', $dragndroporder);
  2418. if ($dragndroparray)
  2419. {
  2420. foreach ($dragndroparray as $arrayelements) {
  2421. switch ($arrayelements) {
  2422. case 1: /* -------------------------------- Link Image -------------------------------------------*/ ?>
  2423. <tr>
  2424. <td style='background-color: #1240ab; color: #fff' class="lltooltip" title='<?php _e('This column allows for the output of text/code before each link image', 'link-library'); ?>'><?php _e('Image', 'link-library'); ?></td>
  2425. <td style='text-align:center;background: #FFF'>
  2426. <input type="checkbox" id="show_images" name="show_images" <?php if ($options['show_images']) echo ' checked="checked" '; ?>/>
  2427. </td>
  2428. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed before each link image', 'link-library'); ?>'>
  2429. <input type="text" id="beforeimage" name="beforeimage" size="22" value="<?php echo stripslashes($options['beforeimage']); ?>"/>
  2430. </td>
  2431. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed after each link image', 'link-library'); ?>'>
  2432. <input type="text" id="afterimage" name="afterimage" size="22" value="<?php echo stripslashes($options['afterimage']); ?>"/>
  2433. </td>
  2434. <td style='background: #FFF' class="lltooltip" title='<?php _e('CSS Class to be assigned to link image', 'link-library'); ?>'>
  2435. <input type="text" id="imageclass" name="imageclass" size="22" value="<?php echo $options['imageclass']; ?>"/>
  2436. </td>
  2437. <td style='background: #FFF'>
  2438. <select name="sourceimage" id="sourceimage" style="width:200px;">
  2439. <option value="primary"<?php if ($options['sourceimage'] == "primary") { echo ' selected="selected"';} ?>><?php _e('Primary', 'link-library'); ?></option>
  2440. <option value="secondary"<?php if ($options['sourceimage'] == "secondary") { echo ' selected="selected"';} ?>><?php _e('Secondary', 'link-library'); ?></option>
  2441. </select>
  2442. </td>
  2443. </tr>
  2444. <?php break;
  2445. case 2: /* -------------------------------- Link Name -------------------------------------------*/ ?>
  2446. <tr>
  2447. <td style='background-color: #4671d5; color: #fff' class="lltooltip" title='<?php _e('This column allows for the output of text/code before and after each link name', 'link-library'); ?>'><?php _e('Link Name', 'link-library'); ?></td>
  2448. <td style='text-align:center;background: #FFF'>
  2449. <input type="checkbox" id="showname" name="showname" <?php if ($options['showname'] == true) echo ' checked="checked" '; ?>/>
  2450. </td>
  2451. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed before each link', 'link-library'); ?>'>
  2452. <input type="text" id="beforelink" name="beforelink" size="22" value="<?php echo stripslashes($options['beforelink']); ?>"/>
  2453. </td>
  2454. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed after each link', 'link-library'); ?>'>
  2455. <input type="text" id="afterlink" name="afterlink" size="22" value="<?php echo stripslashes($options['afterlink']); ?>"/>
  2456. </td>
  2457. <td style='background: #FFF'></td>
  2458. <td style='background: #FFF'>
  2459. <select name="sourcename" id="sourcename" style="width:200px;">
  2460. <option value="primary"<?php if ($options['sourcename'] == "primary") { echo ' selected="selected"';} ?>><?php _e('Primary', 'link-library'); ?></option>
  2461. <option value="secondary"<?php if ($options['sourcename'] == "secondary") { echo ' selected="selected"';} ?>><?php _e('Secondary', 'link-library'); ?></option>
  2462. </select>
  2463. </td>
  2464. </tr>
  2465. <?php break;
  2466. case 3: /* -------------------------------- Link Date -------------------------------------------*/ ?>
  2467. <tr>
  2468. <td style='background-color: #39e639; color:#fff' class="lltooltip" title='<?php _e('This column allows for the output of text/code before and after each link date stamp', 'link-library'); ?>'><?php _e('Link Date', 'link-library'); ?></td>
  2469. <td style='background: #FFF;text-align:center' class="lltooltip" title='<?php _e('Check to display link date', 'link-library'); ?>'>
  2470. <input type="checkbox" id="showdate" name="showdate" <?php if ($options['showdate']) echo ' checked="checked" '; ?>/>
  2471. </td>
  2472. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed before each date', 'link-library'); ?>'>
  2473. <input type="text" id="beforedate" name="beforedate" size="22" value="<?php echo stripslashes($options['beforedate']); ?>"/>
  2474. </td>
  2475. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed after each date', 'link-library'); ?>'>
  2476. <input type="text" id="afterdate" name="afterdate" size="22" value="<?php echo stripslashes($options['afterdate']); ?>"/>
  2477. </td>
  2478. <td style='background: #FFF'></td>
  2479. <td style='background: #FFF'></td>
  2480. </tr>
  2481. <?php break;
  2482. case 4: /* -------------------------------- Link Description -------------------------------------------*/ ?>
  2483. <tr>
  2484. <td style='background-color: #009999;color:#fff' class="lltooltip" title='<?php _e('This column allows for the output of text/code before and after each link description', 'link-library'); ?>'><?php _e('Link Description', 'link-library'); ?></td>
  2485. <td style='background: #FFF;text-align: center' class="lltooltip" title='<?php _e('Check to display link descriptions', 'link-library'); ?>'>
  2486. <input type="checkbox" id="showdescription" name="showdescription" <?php if ($options['showdescription']) echo ' checked="checked" '; ?>/>
  2487. </td>
  2488. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed before each description', 'link-library'); ?>'>
  2489. <input type="text" id="beforedesc" name="beforedesc" size="22" value="<?php echo stripslashes($options['beforedesc']); ?>"/>
  2490. </td>
  2491. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed after each description', 'link-library'); ?>'>
  2492. <input type="text" id="afterdesc" name="afterdesc" size="22" value="<?php echo stripslashes($options['afterdesc']); ?>"/>
  2493. </td>
  2494. <td style='background: #FFF'></td>
  2495. <td style='background: #FFF'></td>
  2496. </tr>
  2497. <?php break;
  2498. case 5: /* -------------------------------- Link Notes -------------------------------------------*/ ?>
  2499. <tr>
  2500. <td style='background-color: #00cc00;color:#fff' class="lltooltip" title='<?php _e('This column allows for the output of text/code before and after each link notes', 'link-library'); ?>'><?php _e('Link Notes', 'link-library'); ?></td>
  2501. <td style='background: #FFF;text-align: center' class="lltooltip" title='<?php _e('Check to display link notes', 'link-library'); ?>'>
  2502. <input type="checkbox" id="shownotes" name="shownotes" <?php if ($options['shownotes']) echo ' checked="checked" '; ?>/>
  2503. </td>
  2504. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed before each note', 'link-library'); ?>'>
  2505. <input type="text" id="beforenote" name="beforenote" size="22" value="<?php echo stripslashes($options['beforenote']); ?>"/>
  2506. </td>
  2507. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed after each note', 'link-library'); ?>'>
  2508. <input type="text" id="afternote" name="afternote" size="22" value="<?php echo stripslashes($options['afternote']); ?>"/>
  2509. </td>
  2510. <td style='background: #FFF'></td>
  2511. <td style='background: #FFF'></td>
  2512. </tr>
  2513. <?php break;
  2514. case 6: /* -------------------------------- Link RSS Icons -------------------------------------------*/ ?>
  2515. <tr>
  2516. <td style='background-color: #008500;color:#fff' class="lltooltip" title='<?php _e('This column allows for the output of text/code before and after the RSS icons', 'link-library'); ?>'><?php _e('RSS Icons', 'link-library'); ?></td>
  2517. <td style='text-align:center;background: #FFF'>
  2518. <?php _e('See below', 'link-library'); ?>
  2519. </td>
  2520. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed before RSS Icons', 'link-library'); ?>'>
  2521. <input type="text" id="beforerss" name="beforerss" size="22" value="<?php echo stripslashes($options['beforerss']); ?>"/>
  2522. </td>
  2523. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed after RSS Icons', 'link-library'); ?>'>
  2524. <input type="text" id="afterrss" name="afterrss" size="22" value="<?php echo stripslashes($options['afterrss']); ?>"/>
  2525. </td>
  2526. <td style='background: #FFF'></td>
  2527. <td style='background: #FFF'></td>
  2528. </tr>
  2529. <?php break;
  2530. case 7: /* -------------------------------- Web Link -------------------------------------------*/ ?>
  2531. <tr>
  2532. <td style='background-color: #5ccccc;color:#fff' class="lltooltip" title='<?php _e('This column allows for the output of text/code before and after the Web Link', 'link-library'); ?>'><?php _e('Web Link', 'link-library'); ?></td>
  2533. <td style='text-align:center;background: #FFF'>
  2534. <select name="displayweblink" id="displayweblink" style="width:80px;">
  2535. <option value="false"<?php if ($options['displayweblink'] == "false") { echo ' selected="selected"';} ?>><?php _e('False', 'link-library'); ?></option>
  2536. <option value="address"<?php if ($options['displayweblink'] == "address") { echo ' selected="selected"';} ?>><?php _e('Web Address', 'link-library'); ?></option>
  2537. <option value="label"<?php if ($options['displayweblink'] == "label") { echo ' selected="selected"';} ?>><?php _e('Label', 'link-library'); ?></option>
  2538. </select>
  2539. </td>
  2540. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed before Web Link', 'link-library'); ?>'>
  2541. <input type="text" id="beforeweblink" name="beforeweblink" size="22" value="<?php echo stripslashes($options['beforeweblink']); ?>"/>
  2542. </td>
  2543. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed after Web Link', 'link-library'); ?>'>
  2544. <input type="text" id="afterweblink" name="afterweblink" size="22" value="<?php echo stripslashes($options['afterweblink']); ?>"/>
  2545. </td>
  2546. <td style='background: #FFF' class="lltooltip" title='<?php _e('Text Label that the web link will be assigned to.', 'link-library'); ?>'>
  2547. <input type="text" id="weblinklabel" name="weblinklabel" size="22" value="<?php echo stripslashes($options['weblinklabel']); ?>"/>
  2548. </td>
  2549. <td style='background: #FFF' class="lltooltip" title='<?php _e('Select which link address will be displayed / used for link', 'link-library'); ?>'>
  2550. <select name="sourceweblink" id="sourceweblink" style="width:200px;">
  2551. <option value="primary"<?php if ($options['sourceweblink'] == "primary") { echo ' selected="selected"';} ?>><?php _e('Primary', 'link-library'); ?></option>
  2552. <option value="secondary"<?php if ($options['sourceweblink'] == "secondary") { echo ' selected="selected"';} ?>><?php _e('Secondary', 'link-library'); ?></option>
  2553. </select>
  2554. </td>
  2555. </tr>
  2556. <?php break;
  2557. case 8: /* -------------------------------- Telephone -------------------------------------------*/ ?>
  2558. <tr>
  2559. <td style='background-color: #6c8cd5;color:#fff' class="lltooltip" title='<?php _e('This column allows for the output of text/code before and after the Telephone Number', 'link-library'); ?>'><?php _e('Telephone', 'link-library'); ?></td>
  2560. <td style='text-align:center;background: #FFF'>
  2561. <select name="showtelephone" id="showtelephone" style="width:80px;">
  2562. <option value="false"<?php if ($options['showtelephone'] == "false") { echo ' selected="selected"';} ?>><?php _e('False', 'link-library'); ?></option>
  2563. <option value="plain"<?php if ($options['showtelephone'] == "plain") { echo ' selected="selected"';} ?>><?php _e('Plain Text', 'link-library'); ?></option>
  2564. <option value="link"<?php if ($options['showtelephone'] == "link") { echo ' selected="selected"';} ?>><?php _e('Link', 'link-library'); ?></option>
  2565. <option value="label"<?php if ($options['showtelephone'] == "label") { echo ' selected="selected"';} ?>><?php _e('Label', 'link-library'); ?></option>
  2566. </select>
  2567. </td>
  2568. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed before Telephone Number', 'link-library'); ?>'>
  2569. <input type="text" id="beforetelephone" name="beforetelephone" size="22" value="<?php echo stripslashes($options['beforetelephone']); ?>"/>
  2570. </td>
  2571. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed after Telephone Number', 'link-library'); ?>'>
  2572. <input type="text" id="aftertelephone" name="aftertelephone" size="22" value="<?php echo stripslashes($options['aftertelephone']); ?>"/>
  2573. </td>
  2574. <td style='background: #FFF' class="lltooltip" title='<?php _e('Text Label that the telephone will be assigned to.', 'link-library'); ?>'>
  2575. <input type="text" id="telephonelabel" name="telephonelabel" size="22" value="<?php echo stripslashes($options['telephonelabel']); ?>"/>
  2576. </td>
  2577. <td style='background: #FFF' class="lltooltip" title='<?php _e('Select which link address will be displayed / used for link', 'link-library'); ?>'>
  2578. <select name="sourcetelephone" id="sourcetelephone" style="width:200px;">
  2579. <option value="primary"<?php if ($options['sourcetelephone'] == "primary") { echo ' selected="selected"';} ?>><?php _e('Primary', 'link-library'); ?></option>
  2580. <option value="secondary"<?php if ($options['sourcetelephone'] == "secondary") { echo ' selected="selected"';} ?>><?php _e('Secondary', 'link-library'); ?></option>
  2581. </select>
  2582. </td>
  2583. </tr>
  2584. <?php break;
  2585. case 9: /* -------------------------------- E-mail -------------------------------------------*/ ?>
  2586. <tr>
  2587. <td style='background-color: #67e667;color:#fff' class="lltooltip" title='<?php _e('This column allows for the output of text/code before and after the E-mail', 'link-library'); ?>'><?php _e('E-mail', 'link-library'); ?></td>
  2588. <td style='text-align:center;background: #FFF'>
  2589. <select name="showemail" id="showemail" style="width:80px;">
  2590. <option value="false"<?php if ($options['showemail'] == "false") { echo ' selected="selected"';} ?>><?php _e('False', 'link-library'); ?></option>
  2591. <option value="plain"<?php if ($options['showemail'] == "plain") { echo ' selected="selected"';} ?>><?php _e('Plain Text', 'link-library'); ?></option>
  2592. <option value="mailto"<?php if ($options['showemail'] == "mailto") { echo ' selected="selected"';} ?>><?php _e('MailTo Link', 'link-library'); ?></option>
  2593. <option value="mailtolabel"<?php if ($options['showemail'] == "mailtolabel") { echo ' selected="selected"';} ?>><?php _e('MailTo Link with Label', 'link-library'); ?></option>
  2594. <option value="command"<?php if ($options['showemail'] == "command") { echo ' selected="selected"';} ?>><?php _e('Formatted Command', 'link-library'); ?></option>
  2595. <option value="commandlabel"<?php if ($options['showemail'] == "commandlabel") { echo ' selected="selected"';} ?>><?php _e('Formatted Command with Labels', 'link-library'); ?></option>
  2596. </select>
  2597. </td>
  2598. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed before E-mail', 'link-library'); ?>'>
  2599. <input type="text" id="beforeemail" name="beforeemail" size="22" value="<?php echo stripslashes($options['beforeemail']); ?>"/>
  2600. </td>
  2601. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed after E-mail', 'link-library'); ?>'>
  2602. <input type="text" id="afteremail" name="afteremail" size="22" value="<?php echo stripslashes($options['afteremail']); ?>"/>
  2603. </td>
  2604. <td style='background: #FFF' class="lltooltip" title='<?php _e('Text Label that the e-mail will be assigned to represent the e-mail link.', 'link-library'); ?>'>
  2605. <input type="text" id="emaillabel" name="emaillabel" size="22" value="<?php echo stripslashes($options['emaillabel']); ?>"/>
  2606. </td>
  2607. <td style='background: #FFF' class="lltooltip" title='<?php _e('Command that the e-mail will be embedded in. In the case of a command, use the symbols #email and #company to indicate the position where these elements should be inserted.', 'link-library'); ?>'>
  2608. <input type="text" id="emailcommand" name="emailcommand" size="22" value="<?php echo stripslashes($options['emailcommand']); ?>"/>
  2609. </td>
  2610. </tr>
  2611. <?php break;
  2612. case 10: /* -------------------------------- Link Hits -------------------------------------------*/ ?>
  2613. <tr>
  2614. <td style='background-color: #33cccc;color:#fff' class="lltooltip" title='<?php _e('This column allows for the output of text/code before and after Link Hits', 'link-library'); ?>'><?php _e('Link Hits', 'link-library'); ?></td>
  2615. <td style='text-align:center;background: #FFF'>
  2616. <input type="checkbox" id="showlinkhits" name="showlinkhits" <?php if ($options['showlinkhits']) echo ' checked="checked" '; ?>/>
  2617. </td>
  2618. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed before Link Hits', 'link-library'); ?>'>
  2619. <input type="text" id="beforelinkhits" name="beforelinkhits" size="22" value="<?php echo stripslashes($options['beforelinkhits']); ?>"/>
  2620. </td>
  2621. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed after Link Hits', 'link-library'); ?>'>
  2622. <input type="text" id="afterlinkhits" name="afterlinkhits" size="22" value="<?php echo stripslashes($options['afterlinkhits']); ?>"/>
  2623. </td>
  2624. <td style='background: #FFF'></td>
  2625. <td style='background: #FFF'></td>
  2626. </tr>
  2627. <?php break;
  2628. case 11: /* -------------------------------- Link Rating -------------------------------------------*/ ?>
  2629. <tr>
  2630. <td style='background-color: #33cc00;color:#fff' class="lltooltip" title='<?php _e('This column allows for the output of text/code before and after the Link Rating', 'link-library'); ?>'><?php _e('Link Rating', 'link-library'); ?></td>
  2631. <td style='text-align:center;background: #FFF'>
  2632. <input type="checkbox" id="showrating" name="showrating" <?php if ($options['showrating']) echo ' checked="checked" '; ?>/>
  2633. </td>
  2634. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed before Link Rating', 'link-library'); ?>'>
  2635. <input type="text" id="beforelinkrating" name="beforelinkrating" size="22" value="<?php echo stripslashes($options['beforelinkrating']); ?>"/>
  2636. </td>
  2637. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed after Link Rating', 'link-library'); ?>'>
  2638. <input type="text" id="afterlinkrating" name="afterlinkrating" size="22" value="<?php echo stripslashes($options['afterlinkrating']); ?>"/>
  2639. </td>
  2640. <td style='background: #FFF'></td>
  2641. <td style='background: #FFF'></td>
  2642. </tr>
  2643. <?php break;
  2644. case 12: /* -------------------------------- Large Description -------------------------------------------*/ ?>
  2645. <tr>
  2646. <td style='background-color: #33ccff;color:#fff' class="lltooltip" title='<?php _e('This column allows for the output of text/code before and after the Link Large Description', 'link-library'); ?>'><?php _e('Link Large Description', 'link-library'); ?></td>
  2647. <td style='text-align:center;background: #FFF'>
  2648. <input type="checkbox" id="showlargedescription" name="showlargedescription" <?php if ($options['showlargedescription']) echo ' checked="checked" '; ?>/>
  2649. </td>
  2650. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed before Link Large Description', 'link-library'); ?>'>
  2651. <input type="text" id="beforelargedescription" name="beforelargedescription" size="22" value="<?php echo stripslashes($options['beforelargedescription']); ?>"/>
  2652. </td>
  2653. <td style='background: #FFF' class="lltooltip" title='<?php _e('Code/Text to be displayed after Link Large Description', 'link-library'); ?>'>
  2654. <input type="text" id="afterlargedescription" name="afterlargedescription" size="22" value="<?php echo stripslashes($options['afterlargedescription']); ?>"/>
  2655. </td>
  2656. <td style='background: #FFF'></td>
  2657. <td style='background: #FFF'></td>
  2658. </tr>
  2659. <?php break;
  2660. }
  2661. }
  2662. }
  2663. ?>
  2664. <tr>
  2665. <td class="lltooltip" title='<?php _e('This column allows for the output of text/code after each link', 'link-library'); ?>'><?php _e('After Link Block', 'link-library'); ?></td>
  2666. <td style='background: #FFF'></td>
  2667. <td style='background: #FFF'></td>
  2668. <td style='background: #FFF' class="lltooltip" title='<?php _e('Output after complete link group (link, notes, desc, etc...)', 'link-library'); ?>'>
  2669. <input type="text" id="afteritem" name="afteritem" size="22" value="<?php echo stripslashes($options['afteritem']); ?>"/>
  2670. </td>
  2671. <td style='background: #FFF'></td>
  2672. <td style='background: #FFF'></td>
  2673. </tr>
  2674. <tr>
  2675. <td class="lltooltip" title='<?php _e('This column allows for the output of text/code after a number of links determined in the first column', 'link-library'); ?>'><?php _e('Intermittent After Link', 'link-library'); ?></td>
  2676. <td style='background: #FFF'></td>
  2677. <td style='background: #FFF'></td>
  2678. <td style='background: #FFF'>
  2679. <input type="text" id="addafterlink" name="addafterlink" size="22" value="<?php echo stripslashes($options['addafterlink']); ?>"/>
  2680. </td>
  2681. <td style='background: #FFF'></td>
  2682. <td style='background: #FFF'></td>
  2683. </tr>
  2684. </table>
  2685. </table>
  2686. <br />
  2687. <table>
  2688. <tr>
  2689. <td style='width:150px'>
  2690. <?php _e('Show Link Updated Flag', 'link-library'); ?>
  2691. </td>
  2692. <td style='width:75px;padding:0px 20px 0px 20px'>
  2693. <input type="checkbox" id="showupdated" name="showupdated" <?php if ($options['showupdated']) echo ' checked="checked" '; ?>/>
  2694. </td>
  2695. <td style='width:20px'>
  2696. </td>
  2697. <td>
  2698. <?php _e('Convert [] to &lt;&gt; in Link Description and Notes', 'link-library'); ?>
  2699. </td>
  2700. <td style='width:75px;padding:0px 20px 0px 20px'>
  2701. <input type="checkbox" id="use_html_tags" name="use_html_tags" <?php if ($options['use_html_tags']) echo ' checked="checked" '; ?>/>
  2702. </td>
  2703. </tr>
  2704. <tr>
  2705. <td>
  2706. <?php _e('Add nofollow tag to outgoing links', 'link-library'); ?>
  2707. </td>
  2708. <td style='width:75px;padding:0px 20px 0px 20px'>
  2709. <input type="checkbox" id="nofollow" name="nofollow" <?php checked( $options['nofollow'] ); ?>/>
  2710. </td>
  2711. <td></td>
  2712. <td>
  2713. <?php _e('Show edit links when logged in as editor or administrator', 'link-library'); ?>
  2714. </td>
  2715. <td style='width:75px;padding:0px 20px 0px 20px'>
  2716. <input type="checkbox" id="showadmineditlinks" name="showadmineditlinks" <?php if ($options['showadmineditlinks']) echo ' checked="checked" '; ?>/>
  2717. </td>
  2718. </tr>
  2719. <tr>
  2720. <td>
  2721. <?php _e('Show link name when no image is assigned', 'link-library'); ?>
  2722. </td>
  2723. <td style='width:75px;padding:0px 20px 0px 20px'>
  2724. <input type="checkbox" id="shownameifnoimage" name="shownameifnoimage" <?php if ($options['shownameifnoimage']) echo ' checked="checked" '; ?>/>
  2725. </td>
  2726. </tr>
  2727. </table>
  2728.  
  2729. <?php }
  2730.  
  2731. function settingssets_linkpopup_meta_box($data) {
  2732. $options = $data['options'];
  2733. $settings = $data['settings'];
  2734. ?>
  2735. <table>
  2736. <tr>
  2737. <td style='width:175px;'><?php _e( 'Enable link Pop-Ups', 'link-library' ); ?></td>
  2738. <td style='width:75px;padding-right:20px'>
  2739. <input type="checkbox" id="enable_link_popup" name="enable_link_popup" <?php checked( $options['enable_link_popup'] ); ?>/>
  2740. </td>
  2741. <td><?php _e('Pop-Up Width', 'link-library' ); ?></td>
  2742. <td><input type="text" id="popup_width" name="popup_width" size="4" value="<?php if ($options['popup_width'] == '') echo '300'; else echo strval($options['popup_width']); ?>"/></td>
  2743. <td><?php _e('Pop-Up Height', 'link-library' ); ?></td>
  2744. <td><input type="text" id="popup_height" name="popup_height" size="4" value="<?php if ($options['popup_height'] == '') echo '400'; else echo strval($options['popup_height']); ?>"/></td>
  2745. </tr>
  2746. <tr>
  2747. <td><?php _e( 'Dialog contents', 'link-library' ); ?></td>
  2748. <td colspan="5"><textarea id="link_popup_text" name="link_popup_text" cols="80" /><?php echo stripslashes($options['link_popup_text']); ?></textarea></td>
  2749. </tr>
  2750. </table>
  2751. <?php }
  2752.  
  2753. function settingssets_rssconfig_meta_box($data) {
  2754. $options = $data['options'];
  2755. $settings = $data['settings'];
  2756. ?>
  2757.  
  2758. <table>
  2759. <tr>
  2760. <td>
  2761. <?php _e('Show RSS Link using Text', 'link-library'); ?>
  2762. </td>
  2763. <td style='width:75px;padding-right:20px'>
  2764. <input type="checkbox" id="show_rss" name="show_rss" <?php if ($options['show_rss']) echo ' checked="checked" '; ?>/>
  2765. </td>
  2766. <td>
  2767. <?php _e('Show RSS Link using Standard Icon', 'link-library'); ?>
  2768. </td>
  2769. <td style='width:75px;padding-right:20px'>
  2770. <input type="checkbox" id="show_rss_icon" name="show_rss_icon" <?php if ($options['show_rss_icon']) echo ' checked="checked" '; ?>/>
  2771. </td>
  2772. <td></td><td style='width:75px;padding-right:20px'></td>
  2773. </tr>
  2774. <tr>
  2775. <td>
  2776. <?php _e('Show RSS Preview Link', 'link-library'); ?>
  2777. </td>
  2778. <td>
  2779. <input type="checkbox" id="rsspreview" name="rsspreview" <?php if ($options['rsspreview']) echo ' checked="checked" '; ?>/>
  2780. </td>
  2781. <td>
  2782. <?php _e('Number of articles shown in RSS Preview', 'link-library'); ?>
  2783. </td>
  2784. <td>
  2785. <input type="text" id="rsspreviewcount" name="rsspreviewcount" size="2" value="<?php if ($options['rsspreviewcount'] == '') echo '3'; else echo strval($options['rsspreviewcount']); ?>"/>
  2786. </td>
  2787. <td>
  2788. <?php _e('Show RSS Feed Headers in Link Library output', 'link-library'); ?>
  2789. </td>
  2790. <td>
  2791. <input type="checkbox" id="rssfeedinline" name="rssfeedinline" <?php if ($options['rssfeedinline']) echo ' checked="checked" '; ?>/>
  2792. </td>
  2793. </tr>
  2794. <tr>
  2795. <td>
  2796. <?php _e('Show RSS Feed Content in Link Library output', 'link-library'); ?>
  2797. </td>
  2798. <td>
  2799. <input type="checkbox" id="rssfeedinlinecontent" name="rssfeedinlinecontent" <?php if ($options['rssfeedinlinecontent']) echo ' checked="checked" '; ?>/>
  2800. </td>
  2801. <td>
  2802. <?php _e('Number of RSS articles shown in Link Library Output', 'link-library'); ?>
  2803. </td>
  2804. <td>
  2805. <input type="text" id="rssfeedinlinecount" name="rssfeedinlinecount" size="2" value="<?php if ($options['rssfeedinlinecount'] == '') echo '1'; else echo strval($options['rssfeedinlinecount']); ?>"/>
  2806. </td>
  2807. <td></td><td></td>
  2808. </tr>
  2809. <tr>
  2810. <td><?php _e('RSS Preview Width', 'link-library'); ?></td>
  2811. <td><input type="text" id="rsspreviewwidth" name="rsspreviewwidth" size="5" value="<?php if ($options['rsspreviewwidth'] == '') echo '900'; else echo strval($options['rsspreviewwidth']); ?>"/></td>
  2812. <td><?php _e('RSS Preview Height', 'link-library'); ?></td>
  2813. <td><input type="text" id="rsspreviewheight" name="rsspreviewheight" size="5" value="<?php if ($options['rsspreviewheight'] == '') echo '700'; else echo strval($options['rsspreviewheight']); ?>"/></td>
  2814. <td></td><td></td>
  2815. </tr>
  2816. </table>
  2817.  
  2818. <?php }
  2819.  
  2820. function settingssets_thumbnails_meta_box($data) {
  2821. $options = $data['options'];
  2822. $settings = $data['settings'];
  2823. ?>
  2824.  
  2825. <table>
  2826. <tr>
  2827. <td style='width: 400px' class='lltooltip' title='<?php _e('Checking this option will get images from the thumbshots web site every time', 'link-library'); ?>.'>
  2828. <?php _e('Use Thumbshots.org for dynamic link images', 'link-library'); ?>
  2829. </td>
  2830. <td colspan='2' class='lltooltip' title='<?php _e('Checking this option will get images from the thumbshots web site every time', 'link-library'); ?>.' style='width:75px;padding-right:20px'>
  2831. <input type="checkbox" id="usethumbshotsforimages" name="usethumbshotsforimages" <?php if ($options['usethumbshotsforimages']) echo ' checked="checked" '; ?>/>
  2832. </td>
  2833. </tr>
  2834. <tr>
  2835. <td><?php _e('Generate Images / Favorite Icons', 'link-library'); ?></td>
  2836. <td><INPUT type="button" name="genthumbs" value="<?php _e('Generate Thumbnails and Store locally', 'link-library'); ?>" onClick="window.location= 'admin.php?page=link-library-settingssets&amp;settings=<?php echo $settings; ?>&amp;genthumbs=<?php echo $settings; ?>'"></td>
  2837. <td><INPUT type="button" name="genfavicons" value="<?php _e('Generate Favorite Icons and Store locally', 'link-library'); ?>" onClick="window.location= 'admin.php?page=link-library-settingssets&amp;settings=<?php echo $settings; ?>&amp;genfavicons=<?php echo $settings; ?>'"></td><td style='width:75px;padding-right:20px'></td>
  2838. </tr>
  2839. </table>
  2840. <?php }
  2841.  
  2842. function settingssets_rssgen_meta_box($data) {
  2843. $options = $data['options'];
  2844. $settings = $data['settings'];
  2845. ?>
  2846.  
  2847. <table>
  2848. <tr>
  2849. <td>
  2850. <?php _e('Publish RSS Feed', 'link-library'); ?>
  2851. </td>
  2852. <td style='width:75px;padding-right:20px'>
  2853. <input type="checkbox" id="publishrssfeed" name="publishrssfeed" <?php if ($options['publishrssfeed']) echo ' checked="checked" '; ?>/>
  2854. </td>
  2855. <td><?php _e('Number of items in RSS feed', 'link-library'); ?></td><td style='width:75px;padding-right:20px'><input type="text" id="numberofrssitems" name="numberofrssitems" size="3" value="<?php if ($options['numberofrssitems'] == '') echo '10'; else echo strval($options['numberofrssitems']); ?>"/></td>
  2856. </tr>
  2857. <tr>
  2858. <td><?php _e('RSS Feed Title', 'link-library'); ?></td><td colspan=3><input type="text" id="rssfeedtitle" name="rssfeedtitle" size="80" value="<?php echo strval(esc_html(stripslashes($options['rssfeedtitle']))); ?>"/></td>
  2859. </tr>
  2860. <tr>
  2861. <td><?php _e('RSS Feed Description', 'link-library'); ?></td><td colspan=3><input type="text" id="rssfeeddescription" name="rssfeeddescription" size="80" value="<?php echo strval(esc_html(stripslashes($options['rssfeeddescription']))); ?>"/></td>
  2862. </tr>
  2863. <tr>
  2864. <td><?php _e('RSS Feed Web Address (default /linkrss/1)', 'link-library'); ?></td><td colspan=3><input type="text" id="rssfeedaddress" name="rssfeedaddress" size="80" value="<?php echo strval(esc_html(stripslashes($options['rssfeedaddress']))); ?>"/></td>
  2865. </tr>
  2866. </table>
  2867.  
  2868. <?php }
  2869.  
  2870. function settingssets_search_meta_box($data) {
  2871. $options = $data['options'];
  2872. $settings = $data['settings'];
  2873. ?>
  2874.  
  2875. <div>
  2876. <table>
  2877. <tr>
  2878. <td style='width:200px'><?php _e('Search Label', 'link-library'); ?></td>
  2879. <?php if ($options['searchlabel'] == "") $options['searchlabel'] = __('Search', 'link-library'); ?>
  2880. <td style='padding-right:20px'><input type="text" id="searchlabel" name="searchlabel" size="30" value="<?php echo $options['searchlabel']; ?>"/></td>
  2881. <td class="lltooltip" title='<?php _e('Leave empty when links are to be displayed on same page as search box', 'link-library'); ?>'>Results Page Address</td>
  2882. <td class="lltooltip" title='<?php _e('Leave empty when links are to be displayed on same page as search box', 'link-library'); ?>'>
  2883. <input type="text" id="searchresultsaddress" name="searchresultsaddress" size="80" value="<?php echo strval(esc_html(stripslashes($options['searchresultsaddress']))); ?>"/>
  2884. </td>
  2885. </tr>
  2886. </table>
  2887. </div>
  2888.  
  2889. <?php }
  2890.  
  2891. function settingssets_linksubmission_meta_box($data) {
  2892. $options = $data['options'];
  2893. $settings = $data['settings'];
  2894. ?>
  2895. <div>
  2896. <table>
  2897. <tr>
  2898. <td colspan=5 class="lltooltip" title='<?php _e('Following this link shows a list of all links awaiting moderation', 'link-library'); ?>.'><a href="<?php echo add_query_arg( 's', 'LinkLibrary%3AAwaitingModeration%3ARemoveTextToApprove' , admin_url( 'link-manager.php' ) ); ?>"><?php _e('View list of links awaiting moderation', 'link-library'); ?></a></td>
  2899. </tr>
  2900. <tr>
  2901. <td style='width:200px'><?php _e('Show user links immediately', 'link-library'); ?></td>
  2902. <td style='width:75px;padding-right:20px'><input type="checkbox" id="showuserlinks" name="showuserlinks" <?php if ($options['showuserlinks']) echo ' checked="checked" '; ?>/></td>
  2903. <td style='width: 20px'></td>
  2904. <td style='width: 20px'></td>
  2905. <td style='width:250px'><?php _e('E-mail admin on link submission', 'link-library'); ?></td>
  2906. <td style='width:75px;padding-right:20px'><input type="checkbox" id="emailnewlink" name="emailnewlink" <?php if ($options['emailnewlink']) echo ' checked="checked" '; ?>/></td>
  2907. <td style='width: 20px'></td>
  2908. </tr>
  2909. <tr>
  2910. <td style='width:200px'><?php _e('Require login to display form', 'link-library'); ?></td>
  2911. <td style='width:75px;padding-right:20px'><input type="checkbox" id="addlinkreqlogin" name="addlinkreqlogin" <?php if ($options['addlinkreqlogin']) echo ' checked="checked" '; ?>/></td>
  2912. <td style='width: 20px'></td>
  2913. <td style='width: 20px'></td>
  2914. <td style='width:250px'><?php _e('Allow link submission with empty link', 'link-library'); ?></td>
  2915. <td style='width:75px;padding-right:20px'><input type="checkbox" id="addlinknoaddress" name="addlinknoaddress" <?php if ($options['addlinknoaddress']) echo ' checked="checked" '; ?>/></td>
  2916. <td style='width: 20px'></td>
  2917. </tr>
  2918. <tr>
  2919. <td style='width:200px'><?php _e('Display captcha', 'link-library'); ?></td>
  2920. <td style='width:75px;padding-right:20px'><input type="checkbox" id="showcaptcha" name="showcaptcha" <?php if ($options['showcaptcha']) echo ' checked="checked" '; ?>/></td>
  2921. <td style='width: 20px'></td>
  2922. <td style='width: 20px'></td>
  2923. <td class='lltooltip' title='<?php _e('This function will only store data when users are logged in to Wordpress', 'link-library'); ?>.' style='width:250px'><?php _e('Store login name on link submission', 'link-library'); ?></td>
  2924. <td style='width:75px;padding-right:20px'><input type="checkbox" id="storelinksubmitter" name="storelinksubmitter" <?php if ($options['storelinksubmitter']) echo ' checked="checked" '; ?>/></td>
  2925. <td style='width: 20px'></td>
  2926. </tr>
  2927. <tr>
  2928. <td style='width:200px'><?php _e('Add new link label', 'link-library'); ?></td>
  2929. <?php if ($options['addnewlinkmsg'] == "") $options['addnewlinkmsg'] = __('Add new link', 'link-library'); ?>
  2930. <td><input type="text" id="addnewlinkmsg" name="addnewlinkmsg" size="30" value="<?php echo $options['addnewlinkmsg']; ?>"/></td>
  2931. <td style='width: 20px'></td>
  2932. <td style='width: 20px'></td>
  2933. <td style='width:200px'><?php _e('Link name label', 'link-library'); ?></td>
  2934. <?php if ($options['linknamelabel'] == "") $options['linknamelabel'] = __('Link Name', 'link-library'); ?>
  2935. <td><input type="text" id="linknamelabel" name="linknamelabel" size="30" value="<?php echo $options['linknamelabel']; ?>"/></td>
  2936. <td style='width: 20px'></td>
  2937. </tr>
  2938. <tr>
  2939. <td style='width:200px'><?php _e('Link address label', 'link-library'); ?></td>
  2940. <?php if ($options['linkaddrlabel'] == "") $options['linkaddrlabel'] = __('Link Address', 'link-library'); ?>
  2941. <td><input type="text" id="linkaddrlabel" name="linkaddrlabel" size="30" value="<?php echo $options['linkaddrlabel']; ?>"/></td>
  2942. <td style='width: 20px'></td>
  2943. <td style='width: 20px'></td>
  2944. <td style='width:200px'><?php _e('Link RSS label', 'link-library'); ?></td>
  2945. <?php if ($options['linkrsslabel'] == "") $options['linkrsslabel'] = __('Link RSS', 'link-library'); ?>
  2946. <td><input type="text" id="linkrsslabel" name="linkrsslabel" size="30" value="<?php echo $options['linkrsslabel']; ?>"/></td>
  2947. <td>
  2948. <select name="showaddlinkrss" id="showaddlinkrss" style="width:60px;">
  2949. <option value="false"<?php if ($options['showaddlinkrss'] == false) { echo ' selected="selected"';} ?>><?php _e('Hide', 'link-library'); ?></option>
  2950. <option value="true"<?php if ($options['showaddlinkrss'] == true) { echo ' selected="selected"';} ?>><?php _e('Show', 'link-library'); ?></option>
  2951. </select>
  2952. </td>
  2953. </tr>
  2954. <tr>
  2955. <td style='width:200px'><?php _e('Link category label', 'link-library'); ?></td>
  2956. <?php if ($options['linkcatlabel'] == "") $options['linkcatlabel'] = __('Link Category', 'link-library'); ?>
  2957. <td><input type="text" id="linkcatlabel" name="linkcatlabel" size="30" value="<?php echo $options['linkcatlabel']; ?>"/></td>
  2958. <td>
  2959. <select name="showaddlinkcat" id="showaddlinkcat" style="width:60px;">
  2960. <option value="false"<?php if ($options['showaddlinkcat'] == false) { echo ' selected="selected"';} ?>><?php _e('Hide', 'link-library'); ?></option>
  2961. <option value="true"<?php if ($options['showaddlinkcat'] == true) { echo ' selected="selected"';} ?>><?php _e('Show', 'link-library'); ?></option>
  2962. </select>
  2963. </td>
  2964. <td style='width: 20px'></td>
  2965. <td style='width:200px' class='lltooltip' title='<?php _e('Comma-seperated list of categories to be displayed in category selection box (e.g. 1,5,4) instead of displaying the set of categories specified by the library.', 'link-library'); ?>'><?php _e('Link category override selection list', 'link-library'); ?></td>
  2966. <td colspan=3 class='lltooltip' title='<?php _e('Comma-seperated list of categories to be displayed in category selection box (e.g. 1,5,4)', 'link-library'); ?>'><input type="text" id="addlinkcatlistoverride" name="addlinkcatlistoverride" size="50" value="<?php echo $options['addlinkcatlistoverride']; ?>" />
  2967. <td style='width:200px'></td>
  2968. </tr>
  2969. <tr>
  2970. <td style='width:200px'><?php _e('User-submitted category', 'link-library'); ?></td>
  2971. <?php if ($options['linkcustomcatlabel'] == "") $options['linkcustomcatlabel'] = __('User-submitted category', 'link-library'); ?>
  2972. <td><input type="text" id="linkcustomcatlabel" name="linkcustomcatlabel" size="30" value="<?php echo $options['linkcustomcatlabel']; ?>"/></td>
  2973. <td>
  2974. <select name="addlinkcustomcat" id="addlinkcustomcat" style="width:60px;">
  2975. <option value="false"<?php if ($options['addlinkcustomcat'] == false) { echo ' selected="selected"';} ?>><?php _e('No', 'link-library'); ?></option>
  2976. <option value="true"<?php if ($options['addlinkcustomcat'] == true) { echo ' selected="selected"';} ?>><?php _e('Allow', 'link-library'); ?></option>
  2977. </select>
  2978. </td>
  2979. <td></td>
  2980. <td style='width:200px'><?php _e('User-submitted category prompt', 'link-library'); ?></td>
  2981. <?php if ($options['linkcustomcatlistentry'] == "") $options['linkcustomcatlistentry'] = __('User-submitted category (define below)', 'link-library'); ?>
  2982. <td colspan=3><input type="text" id="linkcustomcatlistentry" name="linkcustomcatlistentry" size="50" value="<?php echo $options['linkcustomcatlistentry']; ?>"/></td>
  2983. <td style='width:200px'></td>
  2984. </tr>
  2985. <tr>
  2986. <td style='width:200px'><?php _e('Link description label', 'link-library'); ?></td>
  2987. <?php if ($options['linkdesclabel'] == "") $options['linkdesclabel'] = __('Link Description', 'link-library'); ?>
  2988. <td><input type="text" id="linkdesclabel" name="linkdesclabel" size="30" value="<?php echo $options['linkdesclabel']; ?>"/></td>
  2989. <td>
  2990. <select name="showaddlinkdesc" id="showaddlinkdesc" style="width:60px;">
  2991. <option value="false"<?php if ($options['showaddlinkdesc'] == false) { echo ' selected="selected"';} ?>><?php _e('Hide', 'link-library'); ?></option>
  2992. <option value="true"<?php if ($options['showaddlinkdesc'] == true) { echo ' selected="selected"';} ?>><?php _e('Show', 'link-library'); ?></option>
  2993. </select>
  2994. </td>
  2995. <td style='width: 20px'></td>
  2996. <td style='width:200px'><?php _e('Link notes label', 'link-library'); ?></td>
  2997. <?php if ($options['linknoteslabel'] == "") $options['linknoteslabel'] = __('Link Notes', 'link-library'); ?>
  2998. <td><input type="text" id="linknoteslabel" name="linknoteslabel" size="30" value="<?php echo $options['linknoteslabel']; ?>"/></td>
  2999. <td>
  3000. <select name="showaddlinknotes" id="showaddlinknotes" style="width:60px;">
  3001. <option value="false"<?php if ($options['showaddlinknotes'] == false) { echo ' selected="selected"';} ?>><?php _e('Hide', 'link-library'); ?></option>
  3002. <option value="true"<?php if ($options['showaddlinknotes'] == true) { echo ' selected="selected"';} ?>><?php _e('Show', 'link-library'); ?></option>
  3003. </select>
  3004. </td>
  3005. </tr>
  3006. <tr>
  3007. <td></td>
  3008. <td></td>
  3009. <td></td>
  3010. <td></td>
  3011. <td>Use Text Area for Notes</td>
  3012. <td><input type="checkbox" id="usetextareaforusersubmitnotes" name="usetextareaforusersubmitnotes" <?php if ($options['usetextareaforusersubmitnotes']) echo ' checked="checked" '; ?>/></td>
  3013. </tr>
  3014. <tr>
  3015. <td style='width:200px'><?php _e('Reciprocal Link label', 'link-library'); ?></td>
  3016. <?php if ($options['linkreciprocallabel'] == "") $options['linkreciprocallabel'] = __('Reciprocal Link', 'link-library'); ?>
  3017. <td><input type="text" id="linkreciprocallabel" name="linkreciprocallabel" size="30" value="<?php echo $options['linkreciprocallabel']; ?>"/></td>
  3018. <td>
  3019. <select name="showaddlinkreciprocal" id="showaddlinkreciprocal" style="width:60px;">
  3020. <option value="false"<?php if ($options['showaddlinkreciprocal'] == false) { echo ' selected="selected"';} ?>><?php _e('Hide', 'link-library'); ?></option>
  3021. <option value="true"<?php if ($options['showaddlinkreciprocal'] == true) { echo ' selected="selected"';} ?>><?php _e('Show', 'link-library'); ?></option>
  3022. </select>
  3023. </td>
  3024. <td style='width: 20px'></td>
  3025. <td style='width:200px'><?php _e('Secondary Address label', 'link-library'); ?></td>
  3026. <?php if ($options['linksecondurllabel'] == "") $options['linksecondurllabel'] = __('Secondary Address', 'link-library'); ?>
  3027. <td><input type="text" id="linksecondurllabel" name="linksecondurllabel" size="30" value="<?php echo $options['linksecondurllabel']; ?>"/></td>
  3028. <td>
  3029. <select name="showaddlinksecondurl" id="showaddlinksecondurl" style="width:60px;">
  3030. <option value="false"<?php if ($options['showaddlinksecondurl'] == false) { echo ' selected="selected"';} ?>><?php _e('Hide', 'link-library'); ?></option>
  3031. <option value="true"<?php if ($options['showaddlinksecondurl'] == true) { echo ' selected="selected"';} ?>><?php _e('Show', 'link-library'); ?></option>
  3032. </select>
  3033. </td>
  3034. </tr>
  3035. <tr>
  3036. <td style='width:200px'><?php _e('Link Telephone label', 'link-library'); ?></td>
  3037. <?php if ($options['linktelephonelabel'] == "") $options['linktelephonelabel'] = __('Telephone', 'link-library'); ?>
  3038. <td><input type="text" id="linktelephonelabel" name="linktelephonelabel" size="30" value="<?php echo $options['linktelephonelabel']; ?>"/></td>
  3039. <td>
  3040. <select name="showaddlinktelephone" id="showaddlinktelephone" style="width:60px;">
  3041. <option value="false"<?php if ($options['showaddlinktelephone'] == false) { echo ' selected="selected"';} ?>><?php _e('Hide', 'link-library'); ?></option>
  3042. <option value="true"<?php if ($options['showaddlinktelephone'] == true) { echo ' selected="selected"';} ?>><?php _e('Show', 'link-library'); ?></option>
  3043. </select>
  3044. </td>
  3045. <td style='width: 20px'></td>
  3046. <td style='width:200px'><?php _e('Link E-mail label', 'link-library'); ?></td>
  3047. <?php if ($options['linkemaillabel'] == "") $options['linkemaillabel'] = __('E-mail', 'link-library'); ?>
  3048. <td><input type="text" id="linkemaillabel" name="linkemaillabel" size="30" value="<?php echo $options['linkemaillabel']; ?>"/></td>
  3049. <td>
  3050. <select name="showaddlinkemail" id="showaddlinkemail" style="width:60px;">
  3051. <option value="false"<?php if ($options['showaddlinkemail'] == false) { echo ' selected="selected"';} ?>><?php _e('Hide', 'link-library'); ?></option>
  3052. <option value="true"<?php if ($options['showaddlinkemail'] == true) { echo ' selected="selected"';} ?>><?php _e('Show', 'link-library'); ?></option>
  3053. </select>
  3054. </td>
  3055. </tr>
  3056. <tr>
  3057. <td style='width:200px'><?php _e('Link Submitter Name label', 'link-library'); ?></td>
  3058. <?php if ($options['linksubmitternamelabel'] == "") $options['linksubmitternamelabel'] = __('Submitter Name', 'link-library'); ?>
  3059. <td><input type="text" id="linksubmitternamelabel" name="linksubmitternamelabel" size="30" value="<?php echo $options['linksubmitternamelabel']; ?>"/></td>
  3060. <td>
  3061. <select name="showlinksubmittername" id="showlinksubmittername" style="width:60px;">
  3062. <option value="false"<?php if ($options['showlinksubmittername'] == false) { echo ' selected="selected"';} ?>><?php _e('Hide', 'link-library'); ?></option>
  3063. <option value="true"<?php if ($options['showlinksubmittername'] == true) { echo ' selected="selected"';} ?>><?php _e('Show', 'link-library'); ?></option>
  3064. </select>
  3065. </td>
  3066. <td style='width: 20px'></td>
  3067. <td style='width:200px'><?php _e('Link Submitter E-mail label', 'link-library'); ?></td>
  3068. <?php if ($options['linksubmitteremaillabel'] == "") $options['linksubmitteremaillabel'] = __('Submitter E-mail', 'link-library'); ?>
  3069. <td><input type="text" id="linksubmitteremaillabel" name="linksubmitteremaillabel" size="30" value="<?php echo $options['linksubmitteremaillabel']; ?>"/></td>
  3070. <td>
  3071. <select name="showaddlinksubmitteremail" id="showaddlinksubmitteremail" style="width:60px;">
  3072. <option value="false"<?php if ($options['showaddlinksubmitteremail'] == false) { echo ' selected="selected"';} ?>><?php _e('Hide', 'link-library'); ?></option>
  3073. <option value="true"<?php if ($options['showaddlinksubmitteremail'] == true) { echo ' selected="selected"';} ?>><?php _e('Show', 'link-library'); ?></option>
  3074. </select>
  3075. </td>
  3076. </tr>
  3077. <tr>
  3078. <td style='width:200px'><?php _e('Link Submitter Comment Label', 'link-library'); ?></td>
  3079. <?php if ($options['linksubmittercommentlabel'] == "") $options['linksubmittercommentlabel'] = __('Submitter Comment', 'link-library'); ?>
  3080. <td><input type="text" id="linksubmittercommentlabel" name="linksubmittercommentlabel" size="30" value="<?php echo $options['linksubmittercommentlabel']; ?>"/></td>
  3081. <td>
  3082. <select name="showlinksubmittercomment" id="showlinksubmittercomment" style="width:60px;">
  3083. <option value="false"<?php if ($options['showlinksubmittercomment'] == false) { echo ' selected="selected"';} ?>><?php _e('Hide', 'link-library'); ?></option>
  3084. <option value="true"<?php if ($options['showlinksubmittercomment'] == true) { echo ' selected="selected"';} ?>><?php _e('Show', 'link-library'); ?></option>
  3085. </select>
  3086. </td>
  3087. <td style='width: 20px'></td>
  3088. <td style='width:200px'><?php _e('Large Description Label', 'link-library'); ?></td>
  3089. <?php if ($options['linklargedesclabel'] == "") $options['linklargedesclabel'] = __('Large Description', 'link-library'); ?>
  3090. <td><input type="text" id="linklargedesclabel" name="linklargedesclabel" size="30" value="<?php echo $options['linklargedesclabel']; ?>"/></td>
  3091. <td>
  3092. <select name="showuserlargedescription" id="showuserlargedescription" style="width:60px;">
  3093. <option value="false"<?php if ($options['showuserlargedescription'] == false) { echo ' selected="selected"';} ?>><?php _e('Hide', 'link-library'); ?></option>
  3094. <option value="true"<?php if ($options['showuserlargedescription'] == true) { echo ' selected="selected"';} ?>><?php _e('Show', 'link-library'); ?></option>
  3095. </select>
  3096. </td>
  3097. </tr>
  3098. <tr>
  3099. <td style='width:200px'><?php _e('Custom Captcha Question', 'link-library'); ?></td>
  3100. <?php if ($options['customcaptchaquestion'] == "") $options['customcaptchaquestion'] = __('Is boiling water hot or cold?', 'link-library'); ?>
  3101. <td><input type="text" id="customcaptchaquestion" name="customcaptchaquestion" size="30" value="<?php echo $options['customcaptchaquestion']; ?>"/></td>
  3102. <td>
  3103. <select name="showcustomcaptcha" id="showcustomcaptcha" style="width:60px;">
  3104. <option value="false"<?php if ($options['showcustomcaptcha'] == false) { echo ' selected="selected"';} ?>><?php _e('Hide', 'link-library'); ?></option>
  3105. <option value="true"<?php if ($options['showcustomcaptcha'] == true) { echo ' selected="selected"';} ?>><?php _e('Show', 'link-library'); ?></option>
  3106. </select>
  3107. </td>
  3108. <td style='width: 20px'></td>
  3109. <td style='width:200px'><?php _e('Custom Captcha Answer', 'link-library'); ?></td>
  3110. <?php if ($options['customcaptchaanswer'] == "") $options['customcaptchaanswer'] = __('hot', 'link-library'); ?>
  3111. <td><input type="text" id="customcaptchaanswer" name="customcaptchaanswer" size="30" value="<?php echo $options['customcaptchaanswer']; ?>"/></td>
  3112. </tr>
  3113. <tr>
  3114. <td style='width:200px'><?php _e('Add Link button label', 'link-library'); ?></td>
  3115. <?php if ($options['addlinkbtnlabel'] == "") $options['addlinkbtnlabel'] = __('Add Link', 'link-library'); ?>
  3116. <td><input type="text" id="addlinkbtnlabel" name="addlinkbtnlabel" size="30" value="<?php echo $options['addlinkbtnlabel']; ?>"/></td>
  3117. <td style='width: 20px'></td>
  3118. <td style='width: 20px'></td>
  3119. <td style='width:200px'><?php _e('New Link Message', 'link-library'); ?></td>
  3120. <?php if ($options['newlinkmsg'] == "") $options['newlinkmsg'] = __('New link submitted', 'link-library'); ?>
  3121. <td><input type="text" id="newlinkmsg" name="newlinkmsg" size="30" value="<?php echo $options['newlinkmsg']; ?>"/></td>
  3122. </tr>
  3123. <tr>
  3124. <td style='width:200px'><?php _e('New Link Moderation Label', 'link-library'); ?></td>
  3125. <?php if ($options['moderatemsg'] == "") $options['moderatemsg'] = __('it will appear in the list once moderated. Thank you.', 'link-library'); ?>
  3126. <td colspan=6><input type="text" id="moderatemsg" name="moderatemsg" size="90" value="<?php echo $options['moderatemsg']; ?>"/></td>
  3127. </tr>
  3128. </table>
  3129. </div>
  3130.  
  3131. <?php }
  3132.  
  3133. function settingssets_importexport_meta_box($data) {
  3134. $options = $data['options'];
  3135. $settings = $data['settings'];
  3136. ?>
  3137.  
  3138. <table>
  3139. <tr>
  3140. <td class='lltooltip' title='<?php _e('Allows for links to be added in batch to the Wordpress links database. CSV file needs to follow template for column layout.', 'link-library'); ?>' style='width: 330px'><?php _e('CSV file to upload to import links', 'link-library'); ?> (<a href="<?php echo plugins_url( 'importtemplate.csv', __FILE__ ); ?>"><?php _e('file template', 'link-library'); ?></a>)</td>
  3141. <td><input size="80" name="linksfile" type="file" /></td>
  3142. <td><input type="submit" name="importlinks" value="<?php _e('Import Links', 'link-library'); ?>" /></td>
  3143. </tr>
  3144. <tr>
  3145. <td><?php _e('First row contains column headers', 'link-library'); ?></td>
  3146. <td><input type="checkbox" id="firstrowheaders" name="firstrowheaders" checked="checked" /></td>
  3147. </tr>
  3148. </table>
  3149.  
  3150. <hr style='color: #CCC; ' />
  3151. <input type='hidden' value='<?php echo $settings; ?>' name='settingsetid' id='settingsetid' />
  3152. <table>
  3153. <tr>
  3154. <td class='lltooltip' title='<?php _e('Overwrites current library settings with contents of CSV file', 'link-library'); ?>' style='width: 330px'><?php _e('Library Settings CSV file to import', 'link-library'); ?></td>
  3155. <td><input size="80" name="settingsfile" type="file" /></td>
  3156. <td><input type="submit" name="importsettings" value="<?php _e('Import Library Settings', 'link-library'); ?>" /></td>
  3157. </tr>
  3158. <tr>
  3159. <td class='lltooltip' style='width: 330px' title='<?php _e('Generates CSV file with current library configuration for download', 'link-library'); ?>'><?php _e('Export current library settings', 'link-library'); ?></td>
  3160. <td><input type="submit" name="exportsettings" value="<?php _e('Export Library Settings', 'link-library'); ?>" /></td>
  3161. </tr>
  3162. </table>
  3163.  
  3164. <?php }
  3165.  
  3166. function reciprocal_meta_box($data) {
  3167. $genoptions = $data['genoptions'];
  3168. ?>
  3169. <table>
  3170. <tr>
  3171. <td style='width: 250px'><?php _e('Search string', 'link-library'); ?></td>
  3172. <td><input type="text" id="recipcheckaddress" name="recipcheckaddress" size="60" value="<?php echo $genoptions['recipcheckaddress']; ?>"/></td>
  3173. <td><input type='submit' id="recipcheck" name="recipcheck" value="<?php _e('Check Reciprocal Links', 'link-library'); ?>" /></td>
  3174. </tr>
  3175. <tr>
  3176. <td><?php _e('Delete links that return a 403 error', 'link-library'); ?></td>
  3177. <td><input type="checkbox" id="recipcheckdelete403" name="recipcheckdelete403" <?php if ($genoptions['recipcheckdelete403']) echo ' checked="checked" '; ?>/></td>
  3178. </tr>
  3179. </table>
  3180.  
  3181. <?php
  3182. }
  3183.  
  3184.  
  3185. /************************************************ Render Custom Meta Box in Link Editor *******************************************/
  3186. function ll_link_edit_extra($link) {
  3187. global $wpdb;
  3188.  
  3189. $genoptions = get_option('LinkLibraryGeneral');
  3190.  
  3191. if (floatval($genoptions['schemaversion']) < "4.6")
  3192. {
  3193. $this->ll_install();
  3194. }
  3195.  
  3196. if ($link->link_id != '')
  3197. {
  3198. $link_updated_query = "select link_updated from " . $this->db_prefix() . "links where link_id = " . $link->link_id;
  3199. $link_updated = $wpdb->get_var($link_updated_query);
  3200.  
  3201. $linkextradataquery = "select * from " . $this->db_prefix() . "links_extrainfo where link_id = " . $link->link_id;
  3202. $extradata = $wpdb->get_row($linkextradataquery, ARRAY_A);
  3203.  
  3204. if ($extradata['link_visits'] == '') $extradata['link_visits'] = 0;
  3205.  
  3206. $originallinkdata = "select * from " . $this->db_prefix() . "links where link_id = " . $link->link_id;
  3207. $originaldata = $wpdb->get_row($originallinkdata, ARRAY_A);
  3208. }
  3209. else
  3210. {
  3211. $link_updated = date("Y-m-d H:i");
  3212. $extradata = array();
  3213. $originaldata = array();
  3214. }
  3215. ?>
  3216. <table>
  3217. <tr>
  3218. <td style='width: 200px'><?php _e('Featured Link', 'link-library'); ?></td>
  3219. <td><input type="checkbox" id="link_featured" name="link_featured" <?php checked( $extradata['link_featured'] ); ?>/></td>
  3220. </tr>
  3221. <tr>
  3222. <td style='width: 200px'><?php _e('No Follow', 'link-library'); ?></td>
  3223. <td><input type="checkbox" id="link_no_follow" name="link_no_follow" <?php checked ( $extradata['link_no_follow'] ); ?>/></td>
  3224. </tr>
  3225. <tr>
  3226. <td style='width: 200px'><?php _e('Updated Date', 'link-library'); ?></td>
  3227. <td>Set Manually <input type="checkbox" id="ll_updated_manual" name="ll_updated_manual" <?php if ($extradata['link_manual_updated'] == 'Y') echo ' checked="checked" '; ?>/> <input type="text" <?php if ($extradata['link_manual_updated'] == 'N' || $extradata['link_manual_updated'] == '') echo 'disabled="disabled"'; ?> id="ll_link_updated" name="ll_link_updated" size="80" value="<?php echo $link_updated; ?>"/></td>
  3228. </tr>
  3229. <tr>
  3230. <td style='width: 200px'><?php _e('Secondary Web Address', 'link-library'); ?></td>
  3231. <td><input type="text" id="ll_secondwebaddr" name="ll_secondwebaddr" size="80" value="<?php echo $extradata['link_second_url']; ?>"/> <?php if ($extradata['link_second_url'] != "") echo " <a href=" . stripslashes($extradata['link_second_url']) . ">" . __('Visit', 'link-library') . "</a>"; ?></td>
  3232. </tr>
  3233. <tr>
  3234. <td><?php _e('Telephone', 'link-library'); ?></td>
  3235. <td><input type="text" id="ll_telephone" name="ll_telephone" size="80" value="<?php echo stripslashes($extradata['link_telephone']); ?>"/></td>
  3236. </tr>
  3237. <tr>
  3238. <td><?php _e('E-mail', 'link-library'); ?></td>
  3239. <td><input type="text" id="ll_email" name="ll_email" size="80" value="<?php echo stripslashes($extradata['link_email']); ?>"/></td>
  3240. </tr>
  3241. <tr>
  3242. <td><?php _e('Reciprocal Link', 'link-library'); ?></td>
  3243. <td><input type="text" id="ll_reciprocal" name="ll_reciprocal" size="80" value="<?php echo $extradata['link_reciprocal']; ?>"/> <?php if ($extradata['link_reciprocal'] != "") echo " <a href=" . stripslashes($extradata['link_reciprocal']) . ">" . __('Visit', 'link-library') . "</a>"; ?></td>
  3244. </tr>
  3245. <tr>
  3246. <td><?php _e('Number of link views', 'link-library'); ?></td>
  3247. <td><input disabled type="text" id="ll_hits" name="ll_hits" size="80" value="<?php echo $extradata['link_visits']; ?>"/></td>
  3248. </tr>
  3249. <tr>
  3250. <td><?php _e('Link Submitter', 'link-library'); ?></td>
  3251. <td><input disabled type="text" id="ll_submitter" name="ll_submitter" size="80" value="<?php echo stripslashes($extradata['link_submitter']); ?>"/></td>
  3252. </tr>
  3253. <tr>
  3254. <td><?php _e('Link Submitter Name', 'link-library'); ?></td>
  3255. <td><input disabled type="text" id="link_submitter_name" name="link_submitter_name" size="80" value="<?php echo stripslashes($extradata['link_submitter_name']); ?>"/></td>
  3256. </tr>
  3257. <tr>
  3258. <td><?php _e('Link Submitter E-mail', 'link-library'); ?></td>
  3259. <td><input disabled type="text" id="link_submitter_email" name="link_submitter_email" size="80" value="<?php echo stripslashes($extradata['link_submitter_email']); ?>"/></td>
  3260. </tr>
  3261. <tr>
  3262. <td><?php _e('Link Large Description', 'link-library'); ?></td>
  3263. <td><textarea id="link_textfield" name="link_textfield" cols='66'><?php echo stripslashes($extradata['link_textfield']); ?></textarea></td>
  3264. </tr>
  3265. <tr>
  3266. <td><?php _e('Current Link Image', 'link-library'); ?></td>
  3267. <td>
  3268. <div id='current_link_image'>
  3269. <?php if ($originaldata['link_image'] != ''): ?>
  3270. <img src="<?php echo $originaldata['link_image'] ?>" />
  3271. <?php else: ?>
  3272. <?php _e('None Assigned', 'link-library'); ?>
  3273. <?php endif; ?>
  3274. </div>
  3275. </td>
  3276. </tr>
  3277. <?php if ($link->link_id != ''): ?>
  3278. <tr>
  3279. <td><?php _e('Automatic Image Generation', 'link-library'); ?></td>
  3280. <td><INPUT type="button" id="genthumbs" name="genthumbs" value="<?php _e('Generate Thumbnail and Store locally', 'link-library'); ?>">
  3281. <INPUT type="button" id="genfavicons" name="genfavicons" value="<?php _e('Generate Favorite Icon and Store locally', 'link-library'); ?>"></td>
  3282. </tr>
  3283. <?php else: ?>
  3284. <tr>
  3285. <td><?php _e('Automatic Image Generation', 'link-library'); ?></td>
  3286. <td><?php _e('Only available once link is saved', 'link-library'); ?></td>
  3287. </tr>
  3288. <?php endif; ?>
  3289. <tr>
  3290. <td><?php _e('Manual Image Upload', 'link-library'); ?></td>
  3291. <td><input size="80" name="linkimageupload" type="file" /></td>
  3292. </tr>
  3293. <tr>
  3294. <td colspan='2'><p><?php _e('Manual upload requires a wp-content\uploads directory to be present with write permissions', 'link-library'); ?>.</p></td>
  3295. </tr>
  3296. </table>
  3297.  
  3298. <?php $genoptions = get_option('LinkLibraryGeneral'); ?>
  3299.  
  3300. <script type="text/javascript">
  3301. jQuery(document).ready(function()
  3302. {
  3303. jQuery("#ll_updated_manual").click(function() {
  3304. if (jQuery('#ll_updated_manual').is(':checked')) {
  3305. jQuery('#ll_link_updated').attr('disabled', false);
  3306. } else {
  3307. jQuery('#ll_link_updated').attr('disabled', true);
  3308. }
  3309. });
  3310. // Using jQuery, set both the enctype and the encoding
  3311. // attributes to be multipart/form-data.
  3312. jQuery( "form#editlink" )
  3313. .attr( "enctype", "multipart/form-data" )
  3314. .attr( "encoding", "multipart/form-data" )
  3315. ;
  3316. jQuery('#genthumbs').click(function()
  3317. {
  3318. var linkname = jQuery('#link_name').val();
  3319. var linkurl = jQuery('#link_url').val();
  3320.  
  3321. if (linkname != '' && linkurl != '')
  3322. {
  3323. jQuery('#current_link_image').fadeOut('fast');
  3324. var map = { name: linkname, url: linkurl, mode: 'thumbonly', cid: '<?php echo $genoptions['thumbshotscid']; ?>', filepath: 'link-library-images', linkid: <?php echo $link->link_id; ?> };
  3325. jQuery.get('<?php echo WP_PLUGIN_URL; ?>/link-library/link-library-image-generator.php', map,
  3326. function(data){
  3327. if (data != '')
  3328. {
  3329. jQuery('#current_link_image').replaceWith("<div id='current_link_image'><img src='" + data + "' /></div>");
  3330. jQuery('#current_link_image').fadeIn('fast');
  3331. jQuery('#link_image').val(data);
  3332. alert('<?php _e('Thumbnail successfully generated for', 'link-library'); ?> ' + linkname);
  3333. }
  3334. });
  3335. }
  3336. else
  3337. {
  3338. alert("<?php _e('Cannot generate thumbnail when no name and no web address are specified.', 'link-library'); ?>");
  3339. }
  3340. } );
  3341.  
  3342. jQuery('#genfavicons').click(function()
  3343. {
  3344. var linkname = jQuery('#link_name').val();
  3345. var linkurl = jQuery('#link_url').val();
  3346.  
  3347. if (linkname != '' && linkurl != '')
  3348. {
  3349. jQuery('#current_link_image').fadeOut('fast');
  3350. var map = { name: linkname, url: linkurl, mode: 'favicononly', cid: '<?php echo $genoptions['thumbshotscid']; ?>', filepath: 'link-library-favicons', linkid: <?php echo $link->link_id; ?> };
  3351. jQuery.get('<?php echo WP_PLUGIN_URL; ?>/link-library/link-library-image-generator.php', map,
  3352. function(data){
  3353. if (data != '')
  3354. {
  3355. jQuery('#current_link_image').replaceWith("<div id='current_link_image'><img src='" + data + "' /></div>");
  3356. jQuery('#current_link_image').fadeIn('fast');
  3357. jQuery('#link_image').val(data);
  3358. alert('<?php _e('Favicon successfully generated for', 'link-library') ?> ' + linkname);
  3359. }
  3360. });
  3361. }
  3362. else
  3363. {
  3364. alert("<?php _e('Cannot generate favorite icon when no name and no web address are specified.', 'link-library'); ?>");
  3365. }
  3366. } );
  3367.  
  3368. });
  3369. </script>
  3370.  
  3371. <?php
  3372. }
  3373.  
  3374. /******************************* Store extra field data when link is saved *******************************************/
  3375. function add_link_field($link_id) {
  3376. global $wpdb;
  3377.  
  3378. $uploads = wp_upload_dir();
  3379.  
  3380. if(array_key_exists('linkimageupload', $_FILES))
  3381. {
  3382. if (!file_exists($uploads['basedir'] . '/link-library-images'))
  3383. mkdir($uploads['basedir'] . '/link-library-images');
  3384. $target_path = $uploads['basedir'] . "/link-library-images/" . $link_id . ".jpg";
  3385. $file_path = $uploads['baseurl'] . "/link-library-images/" . $link_id . ".jpg";
  3386. if (move_uploaded_file($_FILES['linkimageupload']['tmp_name'], $target_path))
  3387. $withimage = true;
  3388. else
  3389. $withimage = false;
  3390. }
  3391. else
  3392. $withimage = false;
  3393.  
  3394. $tablename = $this->db_prefix() . "links";
  3395.  
  3396. if (isset($_POST['ll_link_updated']))
  3397. $link_updated = $_POST['ll_link_updated'];
  3398. elseif (!isset($_POST['ll_link_updated']))
  3399. $link_updated = date("Y-m-d H:i");
  3400.  
  3401. if ($withimage == true)
  3402. $wpdb->update( $tablename, array( 'link_updated' => $link_updated, 'link_image' => $file_path ), array( 'link_id' => $link_id ));
  3403. else
  3404. $wpdb->update( $tablename, array( 'link_updated' => $link_updated ), array( 'link_id' => $link_id ));
  3405.  
  3406. $extradatatable = $this->db_prefix() . "links_extrainfo";
  3407.  
  3408. $linkextradataquery = "select * from " . $this->db_prefix() . "links_extrainfo where link_id = " . $link_id;
  3409. $extradata = $wpdb->get_row($linkextradataquery, ARRAY_A);
  3410.  
  3411. global $current_user;
  3412.  
  3413. get_currentuserinfo();
  3414.  
  3415. $username = $current_user->user_login;
  3416.  
  3417. $updatearray = array();
  3418.  
  3419. if (isset($_POST['ll_updated_manual']))
  3420. $updatearray['link_manual_updated'] = 'Y';
  3421. else
  3422. $updatearray['link_manual_updated'] = 'N';
  3423.  
  3424. if (isset($_POST['ll_secondwebaddr']))
  3425. $updatearray['link_second_url'] = $_POST['ll_secondwebaddr'];
  3426.  
  3427. if (isset($_POST['ll_telephone']))
  3428. $updatearray['link_telephone'] = $_POST['ll_telephone'];
  3429.  
  3430. if (isset($_POST['ll_email']))
  3431. $updatearray['link_email'] = $_POST['ll_email'];
  3432.  
  3433. if (isset($_POST['ll_reciprocal']))
  3434. $updatearray['link_reciprocal'] = $_POST['ll_reciprocal'];
  3435.  
  3436. if (isset($_POST['link_textfield']))
  3437. $updatearray['link_textfield'] = esc_html($_POST['link_textfield']);
  3438.  
  3439. if ( isset($_POST['link_no_follow']) && $_POST['link_no_follow'] == 'on' )
  3440. $updatearray['link_no_follow'] = true;
  3441. else
  3442. $updatearray['link_no_follow'] = false;
  3443.  
  3444. if ( isset($_POST['link_featured']) && $_POST['link_featured'] == 'on' )
  3445. $updatearray['link_featured'] = true;
  3446. else
  3447. $updatearray['link_featured'] = false;
  3448.  
  3449. if ($extradata)
  3450. $wpdb->update( $extradatatable, $updatearray, array( 'link_id' => $link_id ));
  3451. else
  3452. {
  3453. $updatearray['link_id'] = $link_id;
  3454. $updatearray['link_submitter'] = $username;
  3455. $wpdb->insert( $extradatatable, $updatearray );
  3456. }
  3457. }
  3458.  
  3459. /************************************************ Delete extra field data when link is deleted ***********************************/
  3460. function delete_link_field($link_id) {
  3461. global $wpdb;
  3462.  
  3463. $deletequery = "delete from " . $this->db_prefix() . "links_extrainfo where link_id = " . $link_id;
  3464. $wpdb->get_results($deletequery);
  3465. }
  3466.  
  3467. /******************************************** Print style data to header *********************************************/
  3468.  
  3469. function ll_rss_link() {
  3470. global $llstylesheet, $rss_settings;
  3471.  
  3472. if ($rss_settings != "")
  3473. {
  3474. $settingsname = 'LinkLibraryPP' . $rss_settings;
  3475. $options = get_option($settingsname);
  3476.  
  3477. $feedtitle = ($options['rssfeedtitle'] == "" ? __('Link Library Generated Feed', 'link-library') : $options['rssfeedtitle']);
  3478.  
  3479. echo '<link rel="alternate" type="application/rss+xml" title="' . esc_html(stripslashes($feedtitle)) . '" href="' . plugins_url('rssfeed.php?settingset=' . $rss_settings, __FILE__) . '" />';
  3480. }
  3481.  
  3482. if ($llstylesheet == true)
  3483. {
  3484. $genoptions = get_option('LinkLibraryGeneral');
  3485.  
  3486. echo "<style id='LinkLibraryStyle' type='text/css'>\n";
  3487. echo stripslashes($genoptions['fullstylesheet']);
  3488. echo "</style>\n";
  3489. }
  3490. }
  3491.  
  3492. /****************************************** Add Link Category name to page title when option is present ********************************/
  3493. function ll_title_creator($title) {
  3494. global $wp_query;
  3495. global $wpdb;
  3496. global $llstylesheet;
  3497.  
  3498. if ($llstylesheet)
  3499. {
  3500. $genoptions = get_option('LinkLibraryGeneral');
  3501.  
  3502. $categoryname = ( isset( $wp_query->query_vars['cat_name'] ) ? $wp_query->query_vars['cat_name'] : '' );
  3503. $catid = ( isset( $_GET['cat_id'] ) ? intval($_GET['cat_id']) : '' );
  3504.  
  3505. $linkcatquery = "SELECT t.name ";
  3506. $linkcatquery .= "FROM " . $this->db_prefix() . "terms t LEFT JOIN " . $this->db_prefix(). "term_taxonomy tt ON (t.term_id = tt.term_id) ";
  3507. $linkcatquery .= "LEFT JOIN " . $this->db_prefix() . "term_relationships tr ON (tt.term_taxonomy_id = tr.term_taxonomy_id) ";
  3508. $linkcatquery .= "WHERE tt.taxonomy = 'link_category' AND ";
  3509.  
  3510. if ($categoryname != '')
  3511. {
  3512. $linkcatquery .= "t.slug = '" . $categoryname . "'";
  3513. $nicecatname = $wpdb->get_var($linkcatquery);
  3514. return $title . $genoptions['pagetitleprefix'] . $nicecatname . $genoptions['pagetitlesuffix'];
  3515. }
  3516. elseif ($catid != '')
  3517. {
  3518. $linkcatquery .= "t.term_id = '" . $catid . "'";
  3519. //echo $linkcatquery;
  3520. $nicecatname = $wpdb->get_var($linkcatquery);
  3521. return $title . $genoptions['pagetitleprefix'] . $nicecatname . $genoptions['pagetitlesuffix'];
  3522. }
  3523. }
  3524.  
  3525. return $title;
  3526. }
  3527.  
  3528. /***************************************** Add column to link list view ****************************************/
  3529. function ll_linkmanager_addcolumn($columns) {
  3530. $columns['hits'] = 'Hits';
  3531. return $columns;
  3532. }
  3533.  
  3534. function ll_linkmanager_populatecolumn($arg1, $arg2) {
  3535. global $wpdb;
  3536.  
  3537. switch ($arg1) {
  3538. case 'hits':
  3539. $linkextradataquery = "select * from " . $this->db_prefix() . "links_extrainfo where link_id = " . $arg2;
  3540. $extradata = $wpdb->get_row($linkextradataquery, ARRAY_A);
  3541. $hits = $extradata['link_visits'];
  3542. if ($hits == '') $hits = 0;
  3543. echo $hits;
  3544. }
  3545. }
  3546.  
  3547. /************************************* Function to add to rewrite rules for permalink support **********************************/
  3548. function ll_insertMyRewriteRules($rules)
  3549. {
  3550. $newrules = array();
  3551.  
  3552. $genoptions = get_option('LinkLibraryGeneral');
  3553.  
  3554. if ($genoptions != '')
  3555. {
  3556. for ($i = 1; $i <= $genoptions['numberstylesets']; $i++) {
  3557. $settingsname = 'LinkLibraryPP' . $i;
  3558. $options = get_option($settingsname);
  3559.  
  3560. if ($options['enablerewrite'] == true && $options['rewritepage'] != '')
  3561. $newrules['(' . $options['rewritepage'] . ')/(.+?)$'] = 'index.php?pagename=$matches[1]&cat_name=$matches[2]';
  3562.  
  3563. if ($options['publishrssfeed'] == true)
  3564. {
  3565. if ($options['rssfeedaddress'] != '')
  3566. $newrules['(' . $options['rssfeedaddress'] . ')/(.+?)$'] = '/wp-content/plugins/link-library/rssfeed.php?settingset=$matches[1]';
  3567. elseif ($options['rssfeedaddress'] == '')
  3568. $newrules['(linkrss)/(.+?)$'] = '/wp-content/plugins/link-library/rssfeed.php?settingset=$matches[1]';
  3569. }
  3570. }
  3571. }
  3572.  
  3573. return $newrules + $rules;
  3574. }
  3575.  
  3576. // Adding the id var so that WP recognizes it
  3577. function ll_insertMyRewriteQueryVars($vars)
  3578. {
  3579. array_push($vars, 'cat_name');
  3580. return $vars;
  3581. }
  3582.  
  3583. /*********************************************** Private Link Library Categories Function *************************************/
  3584.  
  3585. function PrivateLinkLibraryCategories($order = 'name', $hide_if_empty = true, $table_width = 100, $num_columns = 1, $catanchor = true,
  3586. $flatlist = 'table', $categorylist = '', $excludecategorylist = '', $showcategorydescheaders = false,
  3587. $showonecatonly = false, $settings = '', $loadingicon = '/icons/Ajax-loader.gif', $catlistdescpos = 'right',
  3588. $debugmode = false, $pagination = false, $linksperpage = 5, $showcatlinkcount = false, $showonecatmode = 'AJAX',
  3589. $cattargetaddress = '', $rewritepage = '', $showinvisible = false, $showuserlinks = false, $showcatonsearchresults = false) {
  3590.  
  3591. global $wpdb;
  3592.  
  3593. $output = '';
  3594.  
  3595. $categoryid = '';
  3596.  
  3597. if (isset($_GET['cat_id']))
  3598. $categoryid = intval($_GET['cat_id']);
  3599.  
  3600. if (!isset($_GET['searchll']) || $showcatonsearchresults == true)
  3601. {
  3602. $countcat = 0;
  3603.  
  3604. $order = strtolower($order);
  3605.  
  3606. $output .= "<!-- Link Library Categories Output -->\n\n";
  3607.  
  3608. if ($showonecatonly == true && ($showonecatmode == 'AJAX' || $showonecatmode == ''))
  3609. {
  3610. $output .= "<SCRIPT LANGUAGE=\"JavaScript\">\n";
  3611. $output .= "var ajaxobject;\n";
  3612. $output .= "function showLinkCat ( _incomingID, _settingsID, _pagenumber) {\n";
  3613. $output .= "if (typeof(ajaxobject) != \"undefined\") { ajaxobject.abort(); }\n";
  3614. $output .= "var map = {id : _incomingID, settings : _settingsID, linkresultpage: _pagenumber}\n";
  3615. $output .= "\tjQuery('#contentLoading').toggle();jQuery.get('" . WP_PLUGIN_URL . "/link-library/link-library-ajax.php', map, function(data){jQuery('#linklist" . $settings. "').replaceWith(data);jQuery('#contentLoading').toggle();});\n";
  3616. $output .= "}\n";
  3617.  
  3618. $output .= "</SCRIPT>\n\n";
  3619. }
  3620.  
  3621. // Handle link category sorting
  3622. $direction = 'ASC';
  3623. if (substr($order,0,1) == '_') {
  3624. $direction = 'DESC';
  3625. $order = substr($order,1);
  3626. }
  3627.  
  3628. if (!isset($direction)) $direction = '';
  3629. // Fetch the link category data as an array of hashesa
  3630.  
  3631. $linkcatquery = "SELECT count(l.link_name) as linkcount, t.name, t.term_id, t.slug as category_nicename, tt.description as category_description ";
  3632. $linkcatquery .= "FROM " . $this->db_prefix() . "terms t LEFT JOIN " . $this->db_prefix(). "term_taxonomy tt ON (t.term_id = tt.term_id)";
  3633. $linkcatquery .= " LEFT JOIN " . $this->db_prefix() . "term_relationships tr ON (tt.term_taxonomy_id = tr.term_taxonomy_id) ";
  3634.  
  3635. $linkcatquery .= " LEFT OUTER JOIN " . $this->db_prefix() . "links l on (tr.object_id = l.link_id";
  3636.  
  3637. if ($showinvisible == false)
  3638. $linkcatquery .= " AND l.link_visible != 'N'";
  3639.  
  3640. if (!$showuserlinks)
  3641. $linkcatquery .= " AND l.link_description not like '%LinkLibrary:AwaitingModeration:RemoveTextToApprove%' ";
  3642.  
  3643. $linkcatquery .= " ) ";
  3644.  
  3645. $linkcatquery .= "WHERE tt.taxonomy = 'link_category'";
  3646.  
  3647. if ($categorylist != "")
  3648. $linkcatquery .= " AND t.term_id in (" . $categorylist. ")";
  3649.  
  3650. if ($excludecategorylist != "")
  3651. $linkcatquery .= " AND t.term_id not in (" . $excludecategorylist . ")";
  3652.  
  3653. if ($hide_if_empty == true)
  3654. $linkcatquery .= " AND l.link_name != '' ";
  3655.  
  3656. $linkcatquery .= " GROUP BY t.name ";
  3657.  
  3658. if ($order == "name")
  3659. $linkcatquery .= " ORDER by t.name " . $direction;
  3660. elseif ($order == "id")
  3661. $linkcatquery .= " ORDER by t.term_id " . $direction;
  3662. elseif ($order == "order")
  3663. $linkcatquery .= " ORDER by t.term_order " . $direction;
  3664. elseif ($order == "catlist")
  3665. $linkcatquery .= " ORDER by FIELD(t.term_id," . $categorylist . ") ";
  3666.  
  3667. $catnames = $wpdb->get_results($linkcatquery);
  3668.  
  3669. if ($debugmode)
  3670. {
  3671. $output .= "\n<!-- Category Query: " . print_r($linkcatquery, TRUE) . "-->\n\n";
  3672. $output .= "\n<!-- Category Results: " . print_r($catnames, TRUE) . "-->\n\n";
  3673. }
  3674.  
  3675. // Display each category
  3676.  
  3677. if ($catnames) {
  3678.  
  3679. $output .= "<div id=\"linktable\" class=\"linktable\">";
  3680.  
  3681. if ($flatlist == 'table')
  3682. $output .= "<table width=\"" . $table_width . "%\">\n";
  3683. elseif ($flatlist == 'unordered')
  3684. $output .= "<ul class='menu'>\n";
  3685. elseif ($flatlist == 'dropdown')
  3686. $output .= "<form name='catselect'><select name='catdropdown' class='catdropdown'>";
  3687.  
  3688. $linkcount = 0;
  3689.  
  3690. foreach ( (array) $catnames as $catname) {
  3691. // Handle each category.
  3692. // First, fix the sort_order info
  3693. //$orderby = $cat['sort_order'];
  3694. //$orderby = (bool_from_yn($cat['sort_desc'])?'_':'') . $orderby;
  3695.  
  3696. $catfront = '';
  3697. $cattext = '';
  3698. $catitem = '';
  3699.  
  3700. // Display the category name
  3701. $countcat += 1;
  3702. if ($flatlist == 'table' and (($countcat % $num_columns == 1) or ($num_columns == 1) )) $output .= "<tr>\n";
  3703.  
  3704. if ($flatlist == 'table')
  3705. $catfront = ' <td>';
  3706. elseif ($flatlist == 'unordered')
  3707. $catfront = ' <li>';
  3708. elseif ($flatlist == 'dropdown')
  3709. {
  3710. $catfront = ' <option ';
  3711. if ($categoryid != '' && $categoryid == $catname->term_id)
  3712. $catfront .= 'selected="selected" ';
  3713. $catfront .= 'value="';
  3714. }
  3715.  
  3716. if ($showonecatonly)
  3717. {
  3718. if ($showonecatmode == 'AJAX' || $showonecatmode == '')
  3719. {
  3720. if ($flatlist != 'dropdown')
  3721. $cattext = "<a href='#' onClick=\"showLinkCat('" . $catname->term_id. "', '" . $settings . "', 1);return false;\" >";
  3722. elseif ($flatlist == 'dropdown')
  3723. $cattext = $catname->term_id;
  3724. }
  3725. elseif ($showonecatmode == 'HTMLGET')
  3726. {
  3727. if ($flatlist != 'dropdown')
  3728. $cattext = "<a href='";
  3729.  
  3730. if ($cattargetaddress != '' && strpos($cattargetaddress, "?") != false)
  3731. {
  3732. $cattext .= $cattargetaddress;
  3733. $cattext .= "&cat_id=";
  3734. }
  3735. elseif ($cattargetaddress != '' && strpos($cattargetaddress, "?") == false)
  3736. {
  3737. $cattext .= $cattargetaddress;
  3738. $cattext .= "?cat_id=";
  3739. }
  3740. elseif ($cattargetaddress == '')
  3741. $cattext .= "?cat_id=";
  3742.  
  3743. $cattext .= $catname->term_id;
  3744.  
  3745. if ($flatlist != 'dropdown')
  3746. $cattext .= "'>";
  3747. }
  3748. elseif ($showonecatmode == 'HTMLGETPERM')
  3749. {
  3750. if ($flatlist != 'dropdown')
  3751. $cattext = "<a href='";
  3752.  
  3753. $cattext .= "/" . $rewritepage . "/" . $catname->category_nicename;
  3754.  
  3755. if ($flatlist != 'dropdown')
  3756. $cattext .= "'>";
  3757. }
  3758. }
  3759. else if ($catanchor)
  3760. {
  3761. if (!$pagination)
  3762. {
  3763. if ($flatlist != 'dropdown')
  3764. $cattext = '<a href="';
  3765.  
  3766. $cattext .= '#' . $catname->category_nicename;
  3767.  
  3768. if ($flatlist != 'dropdown')
  3769. $cattext .= '">';
  3770. }
  3771. elseif ($pagination)
  3772. {
  3773. if ($linksperpage == 0 && $linksperpage == '')
  3774. $linksperpage = 5;
  3775.  
  3776. $pageposition = ( $linkcount + 1 ) / $linksperpage;
  3777. $ceilpageposition = ceil($pageposition);
  3778. if ( $ceilpageposition == 0 && !isset( $_GET['linkresultpage'] ) ) {
  3779. if ($flatlist != 'dropdown')
  3780. $cattext = '<a href="';
  3781.  
  3782. $cattext .= get_permalink() . '#' . $catname->category_nicename;
  3783.  
  3784. if ( $flatlist != 'dropdown' )
  3785. $cattext .= '">';
  3786. } else {
  3787. if ( $flatlist != 'dropdown' )
  3788. $cattext = '<a href="';
  3789.  
  3790. $cattext .= '?linkresultpage=' . ($ceilpageposition == 0 ? 1 : $ceilpageposition) . '#' . $catname->category_nicename;
  3791.  
  3792. if ( $flatlist != 'dropdown' )
  3793. $cattext .= '">';
  3794. }
  3795.  
  3796. $linkcount = $linkcount + $catname->linkcount;
  3797. }
  3798. }
  3799. else
  3800. $cattext = '';
  3801.  
  3802. if ( $flatlist == 'dropdown' )
  3803. $cattext .= '">';
  3804.  
  3805. if ( $catlistdescpos == 'right' || $catlistdescpos == '' ) {
  3806. $catitem .= '<div class="linkcatname">' . $catname->name . '</div>';
  3807. if ($showcatlinkcount)
  3808. $catitem .= " (" . $catname->linkcount . ")";
  3809. }
  3810.  
  3811. if ( $showcategorydescheaders ) {
  3812. $catname->category_description = esc_html($catname->category_description);
  3813. $catname->category_description = str_replace("[", "<", $catname->category_description);
  3814. $catname->category_description = str_replace("]", ">", $catname->category_description);
  3815. $catname->category_description = str_replace("&quot;", "\"", $catname->category_description);
  3816. $catitem .= "<span class='linkcatdesc'>" . $catname->category_description . "</span>";
  3817. }
  3818.  
  3819. if ($catlistdescpos == 'left')
  3820. {
  3821. $catitem .= '<div class="linkcatname">' . $catname->name . '</div>';
  3822. if ($showcatlinkcount)
  3823. $catitem .= " (" . $catname->linkcount . ")";
  3824. }
  3825.  
  3826. if (($catanchor || $showonecatonly) && $flatlist != 'dropdown')
  3827. $catitem .= "</a>";
  3828.  
  3829. $output .= ($catfront . $cattext . $catitem );
  3830.  
  3831. if ($flatlist == 'table')
  3832. $catterminator = " </td>\n";
  3833. elseif ($flatlist == 'unordered')
  3834. $catterminator = " </li>\n";
  3835. elseif ($flatlist == 'dropdown')
  3836. $catterminator = " </option>\n";
  3837.  
  3838. $output .= ($catterminator);
  3839.  
  3840. if ($flatlist == "table" and ($countcat % $num_columns == 0)) $output .= "</tr>\n";
  3841. }
  3842.  
  3843. if ($flatlist == "table" and ($countcat % $num_columns == 3)) $output .= "</tr>\n";
  3844. if ($flatlist == "table" && $catnames)
  3845. $output .= "</table>\n";
  3846. elseif ($flatlist == 'unordered' && $catnames)
  3847. $output .= "</ul>\n";
  3848. elseif ($flatlist == 'dropdown' && $catnames)
  3849. {
  3850. $output .= "</select>\n";
  3851. $output .= "<button type='button' onclick='showcategory()'>" . __('Go!', 'link-library') . "</button>";
  3852. $output .= "</form>";
  3853. }
  3854.  
  3855. $output .= "</div>\n";
  3856.  
  3857. if ($showonecatonly && ($showonecatmode == 'AJAX' || $showonecatmode == ''))
  3858. {
  3859. if ($loadingicon == '') $loadingicon = '/icons/Ajax-loader.gif';
  3860. $output .= "<div class='contentLoading' id='contentLoading' style='display: none;'><img src='" . WP_PLUGIN_URL . "/link-library" . $loadingicon . "' alt='Loading data, please wait...'></div>\n";
  3861. }
  3862.  
  3863. if ($flatlist == 'dropdown')
  3864. {
  3865. $output .= "<SCRIPT TYPE='text/javascript'>\n";
  3866. $output .= "\tfunction showcategory(){\n";
  3867.  
  3868. if ($showonecatonly && ($showonecatmode == 'AJAX' || $showonecatmode == '') )
  3869. {
  3870. $output .= "catidvar = document.catselect.catdropdown.options[document.catselect.catdropdown.selectedIndex].value;";
  3871. $output .= "showLinkCat(catidvar, '" . $settings . "', 1);return false; }";
  3872. }
  3873. else
  3874. {
  3875. $output .= "\t\tlocation=\n";
  3876. $output .= "document.catselect.catdropdown.options[document.catselect.catdropdown.selectedIndex].value }\n";
  3877.  
  3878. }
  3879. $output .= "</SCRIPT>\n";
  3880. }
  3881. }
  3882. else
  3883. {
  3884. $output .= "<div>" . __('No categories found', 'link-library') . ".</div>";
  3885. }
  3886.  
  3887. $output .= "\n<!-- End of Link Library Categories Output -->\n\n";
  3888. }
  3889. return $output;
  3890. }
  3891.  
  3892. function ll_highlight_phrase($str, $phrase, $tag_open = '<strong>', $tag_close = '</strong>')
  3893. {
  3894. if ($str == '')
  3895. {
  3896. return '';
  3897. }
  3898.  
  3899. if ($phrase != '')
  3900. {
  3901. return preg_replace('/('.preg_quote($phrase, '/').'(?![^<]*>))/i', $tag_open."\\1".$tag_close, $str);
  3902. }
  3903.  
  3904. return $str;
  3905. }
  3906.  
  3907. function PrivateLinkLibrary($order = 'name', $hide_if_empty = true, $catanchor = true,
  3908. $showdescription = false, $shownotes = false, $showrating = false,
  3909. $showupdated = false, $categorylist = '', $show_images = false,
  3910. $show_image_and_name = false, $use_html_tags = false,
  3911. $show_rss = false, $beforenote = '<br />', $nofollow = false, $excludecategorylist = '',
  3912. $afternote = '', $beforeitem = '<li>', $afteritem = '</li>', $beforedesc = '', $afterdesc = '',
  3913. $displayastable = false, $beforelink = '', $afterlink = '', $showcolumnheaders = false,
  3914. $linkheader = '', $descheader = '', $notesheader = '', $catlistwrappers = 1, $beforecatlist1 = '',
  3915. $beforecatlist2 = '', $beforecatlist3 = '', $divorheader = false, $catnameoutput = 'linklistcatname',
  3916. $show_rss_icon = false, $linkaddfrequency = 0, $addbeforelink = '', $addafterlink = '', $linktarget = '',
  3917. $showcategorydesclinks = false, $showadmineditlinks = true, $showonecatonly = false, $AJAXcatid = '',
  3918. $defaultsinglecat = '', $rsspreview = false, $rsspreviewcount = 3, $rssfeedinline = false,
  3919. $rssfeedinlinecontent = false, $rssfeedinlinecount = 1, $beforerss = '', $afterrss = '',
  3920. $rsscachedir = '', $direction = 'ASC', $linkdirection = 'ASC', $linkorder = 'name',
  3921. $pagination = false, $linksperpage = 5, $hidecategorynames = false, $settings = '',
  3922. $showinvisible = false, $showdate = false, $beforedate = '', $afterdate = '', $catdescpos = 'right',
  3923. $showuserlinks = false, $rsspreviewwidth = 900, $rsspreviewheight = 700, $beforeimage = '', $afterimage = '',
  3924. $imagepos = 'beforename', $imageclass = '', $AJAXpageid = 1, $debugmode = false, $usethumbshotsforimages = false,
  3925. $showonecatmode = 'AJAX', $dragndroporder = '1,2,3,4,5,6,7,8,9,10', $showname = true, $displayweblink = 'false',
  3926. $sourceweblink = 'primary', $showtelephone = 'false', $sourcetelephone = 'primary', $showemail = 'false', $showlinkhits = false,
  3927. $beforeweblink = '', $afterweblink = '', $weblinklabel = '', $beforetelephone = '', $aftertelephone = '', $telephonelabel = '',
  3928. $beforeemail = '', $afteremail = '', $emaillabel = '', $beforelinkhits = '', $afterlinkhits = '', $emailcommand = '',
  3929. $sourceimage = '', $sourcename = '', $thumbshotscid = '', $maxlinks = '', $beforelinkrating = '', $afterlinkrating = '',
  3930. $showlargedescription = false, $beforelargedescription = '', $afterlargedescription = '', $featuredfirst = false, $shownameifnoimage = false,
  3931. $enablelinkpopup = false, $popupwidth = 300, $popupheight = 400, $nocatonstartup = false ) {
  3932.  
  3933. global $wpdb;
  3934.  
  3935. $output = "\n<!-- Beginning of Link Library Output -->\n\n";
  3936.  
  3937. $currentcategory = 1;
  3938. $categoryname = "";
  3939.  
  3940. if ( $showonecatonly && $showonecatmode == 'AJAX' && $AJAXcatid == '' ) {
  3941. $AJAXnocatset = true;
  3942. } else {
  3943. $AJAXnocatset = false;
  3944. }
  3945.  
  3946. if ($showonecatonly && $showonecatmode == 'AJAX' && $AJAXcatid != '' && $_GET['searchll'] == "")
  3947. {
  3948. $categorylist = $AJAXcatid;
  3949. }
  3950. elseif ($showonecatonly && $showonecatmode == 'HTMLGET' && isset($_GET['cat_id']) && $_GET['searchll'] == "")
  3951. {
  3952. $categorylist = intval($_GET['cat_id']);
  3953. $AJAXcatid = $categorylist;
  3954. }
  3955. elseif ($showonecatonly && $showonecatmode == 'HTMLGETPERM' && $_GET['searchll'] == "")
  3956. {
  3957. global $wp_query;
  3958.  
  3959. $categoryname = $wp_query->query_vars['cat_name'];
  3960. $AJAXcatid = $categoryname;
  3961. }
  3962. elseif ($showonecatonly && $AJAXcatid == '' && $defaultsinglecat != '' && $_GET['searchll'] == "")
  3963. {
  3964. $categorylist = $defaultsinglecat;
  3965. $AJAXcatid = $categorylist;
  3966. }
  3967. elseif ($showonecatonly && $AJAXcatid == '' && $defaultsinglecat == '' && $_GET['searchll'] == "")
  3968. {
  3969. $catquery = "SELECT distinct t.name, t.term_id ";
  3970. $catquery .= "FROM " . $this->db_prefix() . "terms t ";
  3971. $catquery .= "LEFT JOIN " . $this->db_prefix() . "term_taxonomy tt ON (t.term_id = tt.term_id) ";
  3972. $catquery .= "LEFT JOIN " . $this->db_prefix() . "term_relationships tr ON (tt.term_taxonomy_id = tr.term_taxonomy_id) ";
  3973. $catquery .= "LEFT JOIN " . $this->db_prefix() . "links l ON (tr.object_id = l.link_id) ";
  3974. $catquery .= "WHERE tt.taxonomy = 'link_category' ";
  3975.  
  3976. if ($hide_if_empty)
  3977. $catquery .= "AND l.link_id is not NULL AND l.link_description not like '%LinkLibrary:AwaitingModeration:RemoveTextToApprove%' ";
  3978.  
  3979. if ($categorylist != "")
  3980. $catquery .= " AND t.term_id in (" . $categorylist. ")";
  3981.  
  3982. if ($excludecategorylist != "")
  3983. $catquery .= " AND t.term_id not in (" . $excludecategorylist . ")";
  3984.  
  3985. if ($showinvisible == false)
  3986. $catquery .= " AND l.link_visible != 'N'";
  3987.  
  3988. $mode = "normal";
  3989.  
  3990. $catquery .= " ORDER by ";
  3991.  
  3992. if ($featuredfirst == true)
  3993. $catquery .= "link_featured DESC, ";
  3994.  
  3995. if ($order == "name")
  3996. $catquery .= " name " . $direction;
  3997. elseif ($order == "id")
  3998. $catquery .= " t.term_id " . $direction;
  3999. elseif ($order == "order")
  4000. $catquery .= " t.term_order " . $direction;
  4001. elseif ($order == "catlist")
  4002. $catquery .= " FIELD(t.term_id," . $categorylist . ") ";
  4003.  
  4004. if ($linkorder == "name")
  4005. $catquery .= ", link_name " . $linkdirection;
  4006. elseif ($linkorder == "id")
  4007. $catquery .= ", link_id " . $linkdirection;
  4008. elseif ($linkorder == "order")
  4009. $catquery .= ", link_order ". $linkdirection;
  4010. elseif ($linkorder == "date")
  4011. $catquery .= ", link_updated ". $linkdirection;
  4012.  
  4013. $catitems = $wpdb->get_results($catquery);
  4014.  
  4015. if ($debugmode)
  4016. {
  4017. $output .= "\n<!-- AJAX Default Category Query: " . print_r($catquery, TRUE) . "-->\n\n";
  4018. $output .= "\n<!-- AJAX Default Category Results: " . print_r($catitems, TRUE) . "-->\n\n";
  4019. }
  4020.  
  4021. if ($catitems)
  4022. {
  4023. $categorylist = $catitems[0]->term_id;
  4024. $AJAXcatid = $categorylist;
  4025. }
  4026. }
  4027.  
  4028. $linkquery = "SELECT distinct *, l.link_id as proper_link_id, UNIX_TIMESTAMP(l.link_updated) as link_date, ";
  4029. $linkquery .= "IF (DATE_ADD(l.link_updated, INTERVAL " . get_option('links_recently_updated_time') . " MINUTE) >= NOW(), 1,0) as recently_updated ";
  4030. $linkquery .= "FROM " . $this->db_prefix() . "terms t ";
  4031. $linkquery .= "LEFT JOIN " . $this->db_prefix() . "term_taxonomy tt ON (t.term_id = tt.term_id) ";
  4032. $linkquery .= "LEFT JOIN " . $this->db_prefix() . "term_relationships tr ON (tt.term_taxonomy_id = tr.term_taxonomy_id) ";
  4033. $linkquery .= "LEFT JOIN " . $this->db_prefix() . "links l ON (tr.object_id = l.link_id) ";
  4034. $linkquery .= "LEFT JOIN " . $this->db_prefix() . "links_extrainfo le ON (l.link_id = le.link_id) ";
  4035. $linkquery .= "WHERE tt.taxonomy = 'link_category' ";
  4036.  
  4037. if ($hide_if_empty)
  4038. $linkquery .= "AND l.link_id is not NULL AND l.link_description not like '%LinkLibrary:AwaitingModeration:RemoveTextToApprove%' ";
  4039.  
  4040. if ($categorylist != "" || isset($_GET['cat_id']))
  4041. $linkquery .= " AND t.term_id in (" . $categorylist. ")";
  4042.  
  4043. if ($categoryname != "" && $showonecatmode == 'HTMLGETPERM')
  4044. $linkquery .= " AND t.slug = '" . $categoryname. "'";
  4045.  
  4046. if ($excludecategorylist != "")
  4047. $linkquery .= " AND t.term_id not in (" . $excludecategorylist . ")";
  4048.  
  4049. if ($showinvisible == false)
  4050. $linkquery .= " AND l.link_visible != 'N'";
  4051.  
  4052. if (isset($_GET['searchll']) && $_GET['searchll'] != "")
  4053. {
  4054. $searchterms = explode(" ", mysql_escape_string($_GET['searchll']));
  4055.  
  4056. if ($searchterms)
  4057. {
  4058. $mode = "search";
  4059. $termnb = 1;
  4060.  
  4061.  
  4062. foreach($searchterms as $searchterm)
  4063. {
  4064. if (true || ctype_alpha($searchterm) == true)
  4065. {
  4066. if ($termnb == 1)
  4067. {
  4068. $linkquery .= " AND (link_name like '%" . $searchterm . "%' ";
  4069. $termnb++;
  4070. }
  4071. else
  4072. {
  4073. $linkquery .= " OR link_name like '%" . $searchterm . "%' ";
  4074. }
  4075.  
  4076. if ($hidecategorynames == false)
  4077. $linkquery .= " OR name like '%" . $searchterm . "%' ";
  4078. if ($shownotes)
  4079. $linkquery .= " OR link_notes like '%" . $searchterm . "%' ";
  4080. if ($showdescription)
  4081. $linkquery .= " OR link_description like '%" . $searchterm . "%' ";
  4082. if ($showlargedescription)
  4083. $linkquery .= " OR link_textfield like '%" . $searchterm . "%' ";
  4084. }
  4085. }
  4086.  
  4087. $linkquery .= ")";
  4088. }
  4089. }
  4090. else
  4091. $mode = "normal";
  4092.  
  4093. $linkquery .= " ORDER by ";
  4094.  
  4095. if ($featuredfirst == true)
  4096. $linkquery .= "link_featured DESC, ";
  4097.  
  4098. if ($order == "name")
  4099. $linkquery .= " name " . $direction;
  4100. elseif ($order == "id")
  4101. $linkquery .= " t.term_id " . $direction;
  4102. elseif ($order == "order")
  4103. $linkquery .= " t.term_order " . $direction;
  4104. elseif ($order == "catlist")
  4105. $linkquery .= " FIELD(t.term_id," . $categorylist . ") ";
  4106.  
  4107. if ($linkorder == "name" || $linkorder == 'random')
  4108. $linkquery .= ", l.link_name " . $linkdirection;
  4109. elseif ($linkorder == "id")
  4110. $linkquery .= ", l.link_id " . $linkdirection;
  4111. elseif ($linkorder == "order")
  4112. $linkquery .= ", l.link_order ". $linkdirection;
  4113. elseif ($linkorder == "date")
  4114. $linkquery .= ", l.link_updated ". $linkdirection;
  4115.  
  4116. if ($pagination && $mode != 'search')
  4117. {
  4118. $linkitemsforcount = $wpdb->get_results($linkquery);
  4119.  
  4120. $numberoflinks = count($linkitemsforcount);
  4121.  
  4122. $quantity = $linksperpage + 1;
  4123.  
  4124. if (isset($_GET['linkresultpage']))
  4125. {
  4126. $pagenumber = $_GET['linkresultpage'];
  4127. $startingitem = ($pagenumber - 1) * $linksperpage;
  4128. $linkquery .= " LIMIT " . $startingitem . ", " . $quantity;
  4129. }
  4130. else
  4131. {
  4132. $pagenumber = 1;
  4133. $linkquery .= " LIMIT 0, " . $quantity;
  4134. }
  4135. }
  4136.  
  4137. $linkitems = $wpdb->get_results($linkquery, ARRAY_A);
  4138.  
  4139. if ($debugmode)
  4140. {
  4141. $output .= "\n<!-- Link Query: " . print_r($linkquery, TRUE) . "-->\n\n";
  4142. $output .= "\n<!-- Link Results: " . print_r($linkitems, TRUE) . "-->\n\n";
  4143. }
  4144.  
  4145. if ($pagination)
  4146. {
  4147. if ($linksperpage == 0 && $linksperpage == '')
  4148. $linksperpage = 5;
  4149.  
  4150. if (count($linkitems) > $linksperpage)
  4151. {
  4152. array_pop($linkitems);
  4153. $nextpage = true;
  4154. }
  4155. else
  4156. $nextpage = false;
  4157. $preroundpages = $numberoflinks / $linksperpage;
  4158. $numberofpages = ceil( $preroundpages * 1 ) / 1;
  4159. }
  4160.  
  4161. if ($linkorder == 'random')
  4162. {
  4163. shuffle($linkitems);
  4164. }
  4165.  
  4166. if ( $maxlinks != '' ) {
  4167. if ( is_numeric( $maxlinks ) ) {
  4168. array_splice( $linkitems, $maxlinks );
  4169. }
  4170. }
  4171.  
  4172. echo "<!-- showonecatmode: " . $showonecatonly . ", AJAXnocatset: " . $AJAXnocatset . ", nocatonstartup: " . $nocatonstartup . "-->";
  4173.  
  4174. // Display links
  4175. if ( $linkitems && $showonecatonly && $AJAXnocatset && $nocatonstartup ) {
  4176. $output .= "<div id='linklist" . $settings . "' class='linklist'>\n";
  4177. $output .= '</div>';
  4178. } elseif ( $linkitems ) {
  4179. $output .= "<div id='linklist" . $settings . "' class='linklist'>\n";
  4180.  
  4181. if ( $mode == 'search' ) {
  4182. $output .= "<div class='resulttitle'>" . __('Search Results for', 'link-library') . " '" . $_GET['searchll'] . "'</div>";
  4183. }
  4184.  
  4185. $currentcategoryid = -1;
  4186.  
  4187. foreach ( $linkitems as $linkitem ) {
  4188.  
  4189. if ($currentcategoryid != $linkitem['term_id'])
  4190. {
  4191. if ($currentcategoryid != -1 && $showonecatonly && $_GET['searchll'] == "")
  4192. {
  4193. break;
  4194. }
  4195. if ($currentcategoryid != -1)
  4196. {
  4197. // Close the last category
  4198. if ($displayastable)
  4199. $output .= "\t</table>\n";
  4200. else
  4201. $output .= "\t</ul>\n";
  4202.  
  4203. if ($catlistwrappers != '')
  4204. $output .= "</div>";
  4205.  
  4206. $output .= "</div>";
  4207.  
  4208. $currentcategory = $currentcategory + 1;
  4209. }
  4210.  
  4211. $currentcategoryid = $linkitem['term_id'];
  4212. $output .= "<div class='LinkLibraryCat" . $currentcategoryid . "'>";
  4213. $linkcount = 0;
  4214.  
  4215. if ($catlistwrappers == 1)
  4216. $output .= "<div class=\"" . $beforecatlist1 . "\">";
  4217. else if ($catlistwrappers == 2)
  4218. {
  4219. $remainder = $currentcategory % $catlistwrappers;
  4220. switch ($remainder) {
  4221.  
  4222. case 0:
  4223. $output .= "<div class=\"" . $beforecatlist2 . "\">";
  4224. break;
  4225.  
  4226. case 1:
  4227. $output .= "<div class=\"" . $beforecatlist1 . "\">";
  4228. break;
  4229. }
  4230. }
  4231. else if ($catlistwrappers == 3)
  4232. {
  4233. $remainder = $currentcategory % $catlistwrappers;
  4234. switch ($remainder) {
  4235.  
  4236. case 0:
  4237. $output .= "<div class=\"" . $beforecatlist3 . "\">";
  4238. break;
  4239.  
  4240. case 2:
  4241. $output .= "<div class=\"" . $beforecatlist2 . "\">";
  4242. break;
  4243.  
  4244. case 1:
  4245. $output .= "<div class=\"" . $beforecatlist1 . "\">";
  4246. break;
  4247. }
  4248. }
  4249.  
  4250. // Display the category name
  4251. if ($hidecategorynames == false || $hidecategorynames == "")
  4252. {
  4253. if ($catanchor)
  4254. $cattext = '<div id="' . $linkitem['slug'] . '">';
  4255. else
  4256. $cattext = '';
  4257.  
  4258. if ($divorheader == false)
  4259. {
  4260. if ($mode == "search")
  4261. foreach ($searchterms as $searchterm)
  4262. {
  4263. $linkitem['name'] = $this->ll_highlight_phrase($linkitem['name'], $searchterm, '<span class="highlight_word">', '</span>');
  4264. }
  4265.  
  4266. $catlink = '<div class="' . $catnameoutput . '">';
  4267.  
  4268. if ($catdescpos == "right" || $catdescpos == '')
  4269. $catlink .= $linkitem['name'];
  4270.  
  4271. if ($showcategorydesclinks)
  4272. {
  4273. $catlink .= "<span class='linklistcatnamedesc'>";
  4274. $linkitem['description'] = str_replace("[", "<", $linkitem['description']);
  4275. $linkitem['description'] = str_replace("]", ">", $linkitem['description']);
  4276. $catlink .= $linkitem['description'];
  4277. $catlink .= '</span>';
  4278. }
  4279.  
  4280. if ($catdescpos == "left")
  4281. $catlink .= $linkitem['name'];
  4282.  
  4283. $catlink .= "</div>";
  4284. }
  4285. else if ($divorheader == true)
  4286. {
  4287. if ($mode == "search")
  4288. foreach ($searchterms as $searchterm)
  4289. {
  4290. $linkitem['name'] = $this->ll_highlight_phrase($linkitem['name'], $searchterm, '<span class="highlight_word">', '</span>');
  4291. }
  4292.  
  4293. $catlink = '<'. $catnameoutput . '>';
  4294.  
  4295. if ($catdescpos == "right" || $catdescpos == '')
  4296. $catlink .= $linkitem['name'];
  4297.  
  4298. if ($showcategorydesclinks)
  4299. {
  4300. $catlink .= "<span class='linklistcatnamedesc'>";
  4301. $linkitem['description'] = str_replace("[", "<", $linkitem['description']);
  4302. $linkitem['description'] = str_replace("]", ">", $linkitem['description']);
  4303. $catlink .= $linkitem['description'];
  4304. $catlink .= '</span>';
  4305. }
  4306.  
  4307. if ($catdescpos == "left")
  4308. $catlink .= $linkitem['name'];
  4309.  
  4310. $catlink .= '</' . $catnameoutput . '>';
  4311. }
  4312.  
  4313. if ($catanchor)
  4314. $catenddiv = '</div>';
  4315. else
  4316. $catenddiv = '';
  4317. }
  4318.  
  4319. if ($displayastable == true)
  4320. {
  4321. $catstartlist = "\n\t<table class='linklisttable'>\n";
  4322. if ($showcolumnheaders == true)
  4323. {
  4324. $catstartlist .= "<div class='linklisttableheaders'><tr>";
  4325.  
  4326. if ($linkheader != "")
  4327. $catstartlist .= "<th><div class='linklistcolumnheader'>".$linkheader."</div></th>";
  4328.  
  4329. if ($descheader != "")
  4330. $catstartlist .= "<th><div class='linklistcolumnheader'>".$descheader."</div></th>";
  4331.  
  4332. if ($notesheader != "")
  4333. $catstartlist .= "<th><div class='linklistcolumnheader'>".$notesheader."</div></th>";
  4334.  
  4335. $catstartlist .= "</tr></div>\n";
  4336. }
  4337. else
  4338. $catstartlist .= '';
  4339. }
  4340. else
  4341. $catstartlist = "\n\t<ul>\n";
  4342.  
  4343. $output .= $cattext . $catlink . $catenddiv . $catstartlist;
  4344. }
  4345.  
  4346. $between = "\n";
  4347.  
  4348. if ($rssfeedinline == true)
  4349. include_once(ABSPATH . WPINC . '/feed.php');
  4350.  
  4351. if ($showuserlinks == true || strpos($linkitem['link_description'], "LinkLibrary:AwaitingModeration:RemoveTextToApprove") == false)
  4352. {
  4353. $linkcount = $linkcount + 1;
  4354.  
  4355. if ($linkaddfrequency > 0)
  4356. if (($linkcount - 1) % $linkaddfrequency == 0)
  4357. $output .= stripslashes($addbeforelink);
  4358.  
  4359. if (!isset($linkitem['recently_updated'])) $linkitem['recently_updated'] = false;
  4360. $output .= stripslashes($beforeitem);
  4361. if ($showupdated && $linkitem['recently_updated'])
  4362. $output .= get_option('links_recently_updated_prepend');
  4363.  
  4364. $the_link = '#';
  4365. if (!empty($linkitem['link_url']) )
  4366. $the_link = esc_html($linkitem['link_url']);
  4367.  
  4368. $the_second_link = '#';
  4369. if (!empty($linkitem['link_second_url']) )
  4370. $the_second_link = esc_html($linkitem['link_second_url']);
  4371.  
  4372. $rel = $linkitem['link_rel'];
  4373. if ('' != $rel and !$nofollow and !$linkitem['link_no_follow'])
  4374. $rel = ' rel="' . $rel . '"';
  4375. else if ('' != $rel and ($nofollow or $linkitem['link_no_follow']))
  4376. $rel = ' rel="' . $rel . ' nofollow"';
  4377. else if ('' == $rel and ($nofollow or $linkitem['link_no_follow']))
  4378. $rel = ' rel="nofollow"';
  4379.  
  4380. if ($use_html_tags) {
  4381. $descnotes = $linkitem['link_notes'];
  4382. $descnotes = str_replace("[", "<", $descnotes);
  4383. $descnotes = str_replace("]", ">", $descnotes);
  4384. }
  4385. else
  4386. $descnotes = esc_html($linkitem['link_notes'], ENT_QUOTES);
  4387.  
  4388. if ($use_html_tags) {
  4389. $desc = $linkitem['link_description'];
  4390. $desc = str_replace("[", "<", $desc);
  4391. $desc = str_replace("]", ">", $desc);
  4392. } else {
  4393. $desc = esc_html($linkitem['link_description'], ENT_QUOTES);
  4394. }
  4395.  
  4396. $cleanname = esc_html($linkitem['link_name'], ENT_QUOTES);
  4397.  
  4398. if ( $use_html_tags ) {
  4399. $textfield = stripslashes( $linkitem['link_textfield'] );
  4400. $textfield = str_replace( '[', '<', $textfield );
  4401. $textfield = str_replace( ']', '>', $textfield );
  4402. } else {
  4403. $textfield = stripslashes( $linkitem['link_textfield'] );
  4404. }
  4405.  
  4406.  
  4407. if ($mode == "search")
  4408. {
  4409. foreach ($searchterms as $searchterm)
  4410. {
  4411. $descnotes = $this->ll_highlight_phrase($descnotes, $searchterm, '<span class="highlight_word">', '</span>');
  4412. $desc = $this->ll_highlight_phrase($desc, $searchterm, '<span class="highlight_word">', '</span>');
  4413. $name = $this->ll_highlight_phrase($linkitem['link_name'], $searchterm, '<span class="highlight_word">', '</span>');
  4414. $textfield = $this->ll_highlight_phrase($textfield, $searchterm, '<span class="highlight_word">', '</span>');
  4415. }
  4416. }
  4417. else
  4418. $name = $cleanname;
  4419.  
  4420. $title = $cleanname;
  4421.  
  4422. if ($showupdated) {
  4423. if (substr($linkitem['link_updated'],0,2) != '00') {
  4424. $title .= ' ('.__('Last updated', 'link-library') . ' ' . date(get_option('links_updated_date_format'), $linkitem['link_updated'] + (get_option('gmt_offset') * 3600)) .')';
  4425. }
  4426. }
  4427.  
  4428. if (!empty( $title ) )
  4429. $title = ' title="' . $cleanname . '"';
  4430.  
  4431. $alt = ' alt="' . $cleanname . '"';
  4432.  
  4433. $target = $linkitem['link_target'];
  4434. if ('' != $target)
  4435. $target = ' target="' . $target . '"';
  4436. else
  4437. {
  4438. $target = $linktarget;
  4439. if ('' != $target)
  4440. $target = ' target="' . $target . '"';
  4441. }
  4442.  
  4443. if ($dragndroporder == '') $dragndroporder = '1,2,3,4,5,6,7,8,9,10';
  4444. $dragndroparray = explode(',', $dragndroporder);
  4445. if ($dragndroparray)
  4446. {
  4447. foreach ($dragndroparray as $arrayelements) {
  4448. switch ($arrayelements) {
  4449. case 1: //------------------ Image Output --------------------
  4450.  
  4451. if ( (($linkitem['link_image'] != '' || $usethumbshotsforimages)) && ($show_images)) {
  4452. $imageoutput = stripslashes($beforeimage) . '<a href="';
  4453.  
  4454. if ( !$enablelinkpopup ) {
  4455. if ($sourceimage == 'primary' || $sourceimage == '')
  4456. $imageoutput .= $the_link;
  4457. elseif ($sourceimage == 'secondary')
  4458. $imageoutput .= $the_second_link;
  4459. } else {
  4460. $imageoutput .= plugins_url( 'linkpopup.php?linkid=' . $linkitem['proper_link_id'] . '&settings=' . $settings . '&height=' . ( empty( $popupheight ) ? 300 : $popupheight ) . '&width=' . ( empty( $popupwidth ) ? 400 : $popupwidth ), __FILE__ );
  4461. }
  4462.  
  4463. $imageoutput .= '" id="link-' . $linkitem['proper_link_id'] . '" class="' . ( $enablelinkpopup ? 'thickbox' : 'track_this_link' ) . '' . ( $linkitem['link_featured'] ? 'featured' : '' ). '" ' . $rel . $title . $target. '>';
  4464.  
  4465. if ($usethumbshotsforimages)
  4466. {
  4467. if ($thumbshotscid == '')
  4468. $imageoutput .= '<img src="http://open.thumbshots.org/image.aspx?url=' . $the_link . '"';
  4469. elseif ($thumbshotscid != '')
  4470. $imageoutput .= '<img src="http://images.thumbshots.com/image.aspx?cid=' . $thumbshotscid .
  4471. '&v=1&w=120&h=90&url=' . $the_link . '"';
  4472. }
  4473. elseif ( strpos($linkitem['link_image'], 'http') !== false )
  4474. $imageoutput .= '<img src="' . $linkitem['link_image'] . '"';
  4475. else // If it's a relative path
  4476. $imageoutput .= '<img src="' . get_option('siteurl') . $linkitem['link_image'] . '"';
  4477.  
  4478. $imageoutput .= $alt . $title;
  4479.  
  4480. if ($imageclass != '')
  4481. $imageoutput .= ' class="' . $imageclass . '" ';
  4482.  
  4483. $imageoutput .= "/>";
  4484.  
  4485. $imageoutput .= '</a>' . stripslashes($afterimage);
  4486. }
  4487.  
  4488. if ( ($linkitem['link_image'] != '' || $usethumbshotsforimages) && ($show_images) ) {
  4489. $output .= $imageoutput;
  4490. break;
  4491. }
  4492. elseif ($show_images == false || $shownameifnoimage == false)
  4493. break;
  4494.  
  4495. case 2: //------------------ Name Output --------------------
  4496. if (($showname == true) || ($show_images == true && $linkitem['link_image'] == '' && $arrayelements == 1))
  4497. {
  4498. $output .= stripslashes($beforelink);
  4499.  
  4500. if (($sourcename == 'primary' && $the_link != '#') || ($sourcename == 'secondary' && $the_second_link != '#'))
  4501. {
  4502. $output .= '<a href="';
  4503.  
  4504. if ( !$enablelinkpopup ) {
  4505. if ( $sourcename == 'primary' || $sourcename == '' )
  4506. $output .= $the_link;
  4507. elseif ( $sourcename == 'secondary' )
  4508. $output .= $the_second_link;
  4509. } else {
  4510. $output .= plugins_url( 'linkpopup.php?linkid=' . $linkitem['proper_link_id'] . '&settings=' . $settings . '&height=' . ( empty( $popupheight ) ? 300 : $popupheight ) . '&width=' . ( empty( $popupwidth ) ? 400 : $popupwidth ), __FILE__ );
  4511. }
  4512.  
  4513. $output .= '" id="link-' . $linkitem['proper_link_id'] . '" class="' . ( $enablelinkpopup ? 'thickbox' : 'track_this_link' ) . ( $linkitem['link_featured'] ? ' featured' : '' ). '" ' . $rel . $title . $target. '>';
  4514. }
  4515.  
  4516. $output .= $name;
  4517.  
  4518. if (($sourcename == 'primary' && $the_link != '#') || ($sourcename == 'secondary' && $the_second_link != '#'))
  4519. $output .= '</a>';
  4520.  
  4521. if (($showadmineditlinks) && current_user_can("manage_links")) {
  4522. $output .= $between . '<a href="' . add_query_arg( array( 'action' => 'edit', 'link_id' => $linkitem['proper_link_id'] ), admin_url( 'link.php' ) ) . '">(' . __('Edit', 'link-library') . ')</a>';
  4523. }
  4524.  
  4525. if ($showupdated && $linkitem['recently_updated']) {
  4526. $output .= get_option('links_recently_updated_append');
  4527. }
  4528.  
  4529. $output .= stripslashes($afterlink);
  4530. }
  4531.  
  4532. break;
  4533.  
  4534. case 3: //------------------ Date Output --------------------
  4535.  
  4536. $formatteddate = date("F d Y", $linkitem['link_date']);
  4537.  
  4538. if ($showdate)
  4539. $output .= $between . stripslashes($beforedate) . $formatteddate . stripslashes($afterdate);
  4540.  
  4541. break;
  4542.  
  4543. case 4: //------------------ Description Output --------------------
  4544.  
  4545. if ($showdescription)
  4546. $output .= $between . stripslashes($beforedesc) . $desc . stripslashes($afterdesc);
  4547.  
  4548. break;
  4549.  
  4550. case 5: //------------------ Notes Output --------------------
  4551.  
  4552. if ($shownotes) {
  4553. $output .= $between . stripslashes($beforenote) . $descnotes . stripslashes($afternote);
  4554. }
  4555.  
  4556. break;
  4557.  
  4558. case 6: //------------------ RSS Icons Output --------------------
  4559.  
  4560. if ($show_rss || $show_rss_icon || $rsspreview)
  4561. $output .= stripslashes($beforerss) . '<div class="rsselements">';
  4562.  
  4563. if ($show_rss && ($linkitem['link_rss'] != '')) {
  4564. $output .= $between . '<a class="rss" href="' . $linkitem['link_rss'] . '">RSS</a>';
  4565. }
  4566. if ($show_rss_icon && ($linkitem['link_rss'] != '')) {
  4567. $output .= $between . '<a class="rssicon" href="' . $linkitem['link_rss'] . '"><img src="' . plugins_url( 'icons/feed-icon-14x14.png', __FILE__ ) . '" /></a>';
  4568. }
  4569. if ($rsspreview && $linkitem['link_rss'] != '')
  4570. {
  4571. $output .= $between . '<a href="' . WP_PLUGIN_URL . '/link-library/rsspreview.php?keepThis=true&linkid=' . $linkitem['proper_link_id'] . '&previewcount=' . $rsspreviewcount . 'height=' . (($rsspreviewwidth == "") ? 900 : $rsspreviewwidth) . '&width=' . (($rsspreviewheight == "") ? 700 : $rsspreviewheight) . '" title="' . __('Preview of RSS feed for', 'link-library') . ' ' . $cleanname . '" class="thickbox"><img src="' . plugins_url( 'icons/preview-16x16.png', __FILE__ ) . '" /></a>';
  4572. }
  4573.  
  4574. if ($show_rss || $show_rss_icon || $rsspreview)
  4575. $output .= '</div>' . stripslashes($afterrss);
  4576.  
  4577. if ($rssfeedinline && $linkitem['link_rss'])
  4578. {
  4579. $rss = fetch_feed($linkitem['link_rss']);
  4580. if (!is_wp_error( $rss ) ) :
  4581. $maxitems = $rss->get_item_quantity($rssfeedinlinecount);
  4582.  
  4583. $rss_items = $rss->get_items(0, $maxitems);
  4584.  
  4585. if ($rss_items)
  4586. {
  4587. $output .= '<div id="ll_rss_results">';
  4588.  
  4589. foreach($rss_items as $item)
  4590. {
  4591. $output .= '<div class="chunk" style="padding:0 5px 5px;">';
  4592. $output .= '<div class="rsstitle"><a target="feedwindow" href="' . $item->get_permalink() . '">' . $item->get_title() . '</a> - ' . $item->get_date('j F Y | g:i a') . '</div>';
  4593. if ($rssfeedinlinecontent) $output .= '<div class="rsscontent">' . $item->get_description() . '</div>';
  4594. $output .= '</div>';
  4595. $output .= '<br />'; }
  4596.  
  4597. $output .= '</div>';
  4598. }
  4599.  
  4600. endif;
  4601. }
  4602. break;
  4603. case 7: //------------------ Web Link Output --------------------
  4604.  
  4605. if ($displayweblink != 'false') {
  4606. $output .= $between . stripslashes($beforeweblink) . "<a href='";
  4607.  
  4608. if ($sourceweblink == "primary" || $sourceweblink == "")
  4609. $output .= $the_link;
  4610. elseif ($sourceweblink == "secondary")
  4611. $output .= $the_second_link;
  4612.  
  4613. $output .= "' id='link-" . $linkitem['proper_link_id'] . "' class='track_this_link' " . $target . ">";
  4614.  
  4615. if ($displayweblink == 'address')
  4616. {
  4617. if (($sourceweblink == "primary" || $sourceweblink == '') && $the_link != '')
  4618. $output .= $the_link;
  4619. elseif ($sourceweblink == "secondary" && $the_second_link != '')
  4620. $output .= $the_second_link;
  4621. }
  4622. elseif ($displayweblink == 'label' && $weblinklabel != '')
  4623. $output .= $weblinklabel;
  4624.  
  4625. $output .= "</a>" . stripslashes($afterweblink);
  4626. }
  4627.  
  4628. break;
  4629. case 8: //------------------ Telephone Output --------------------
  4630.  
  4631. if ($showtelephone != 'false')
  4632. {
  4633. $output .= $between . stripslashes($beforetelephone);
  4634.  
  4635. if ($showtelephone != 'plain')
  4636. {
  4637. $output .= "<a href='";
  4638.  
  4639. if (($sourcetelephone == "primary" || $sourcetelephone == '') && $the_link != '')
  4640. $output .= $the_link;
  4641. elseif ($sourcetelephone == "secondary" && $the_second_link != '')
  4642. $output .= $the_second_link;
  4643.  
  4644. $output .= "' id='link-" . $linkitem['proper_link_id'] . "' class='track_this_link' >";
  4645. }
  4646.  
  4647. if ($showtelephone == 'link' || $showtelephone == "plain")
  4648. $output .= $linkitem['link_telephone'];
  4649. elseif ($showtelephone == 'label')
  4650. $output .= $telephonelabel;
  4651.  
  4652. if ($showtelephone != 'plain')
  4653. $output .= "</a>";
  4654.  
  4655. $output .= stripslashes($aftertelephone);
  4656. }
  4657. break;
  4658. case 9: //------------------ E-mail Output --------------------
  4659.  
  4660. if ($showemail != 'false')
  4661. {
  4662. $output .= $between . stripslashes($beforeemail);
  4663.  
  4664. if ($showemail != 'plain')
  4665. {
  4666. $output .= "<a href='";
  4667.  
  4668. if ($showemail == 'mailto' || $showemail == 'mailtolabel')
  4669. $output .= "mailto:" . $linkitem['link_email'];
  4670. elseif ($showemail == 'command' || $showemail == 'commandlabel')
  4671. {
  4672. $newcommand = str_replace("#email", $linkitem['link_email'], $emailcommand);
  4673. $cleanlinkname = str_replace(" ", "%20", $linkitem['link_name']);
  4674. $newcommand = str_replace("#company", $cleanlinkname, $newcommand);
  4675. $output .= $newcommand;
  4676. }
  4677.  
  4678. $output .= "'>";
  4679. }
  4680.  
  4681. if ($showemail == 'plain' || $showemail == 'mailto' || $showemail == 'command')
  4682. $output .= $linkitem['link_email'];
  4683. elseif ($showemail == 'mailtolabel' || $showemail == 'commandlabel')
  4684. $output .= $emaillabel;
  4685.  
  4686. if ($showemail != 'plain')
  4687. $output .= "</a>";
  4688.  
  4689. $output .= stripslashes($afteremail);
  4690. }
  4691.  
  4692. break;
  4693. case 10: //------------------ Link Hits Output --------------------
  4694.  
  4695. if ($showlinkhits)
  4696. {
  4697. $output .= $between . stripslashes($beforelinkhits);
  4698.  
  4699. $output .= $linkitem['link_visits'];
  4700.  
  4701. $output .= stripslashes($afterlinkhits);
  4702. }
  4703.  
  4704. break;
  4705.  
  4706. case 11: //------------------ Link Rating Output --------------------
  4707.  
  4708. if ($showrating)
  4709. {
  4710. $output .= $between . stripslashes($beforelinkrating);
  4711.  
  4712. $output .= $linkitem['link_rating'];
  4713.  
  4714. $output .= stripslashes($afterlinkrating);
  4715. }
  4716.  
  4717. break;
  4718.  
  4719. case 12: //------------------ Link Large Description Output --------------------
  4720.  
  4721. if ($showlargedescription)
  4722. {
  4723. $output .= $between . stripslashes($beforelargedescription);
  4724.  
  4725. $output .= $textfield;
  4726.  
  4727. $output .= stripslashes($afterlargedescription);
  4728. }
  4729.  
  4730. break;
  4731. }
  4732. }
  4733. }
  4734.  
  4735. $output .= stripslashes($afteritem) . "\n";
  4736.  
  4737. if ($linkaddfrequency > 0)
  4738. if ($linkcount % $linkaddfrequency == 0)
  4739. $output .= stripslashes($addafterlink);
  4740.  
  4741. }
  4742.  
  4743. } // end while
  4744.  
  4745. // Close the last category
  4746. if ($displayastable)
  4747. $output .= "\t</table>\n";
  4748. else
  4749. $output .= "\t</ul>\n";
  4750.  
  4751. if ($catlistwrappers != '')
  4752. $output .= "</div>";
  4753.  
  4754. $output .= "</div>";
  4755.  
  4756. if ($pagination && $mode != "search")
  4757. {
  4758. $previouspagenumber = $pagenumber - 1;
  4759. $nextpagenumber = $pagenumber + 1;
  4760. $dotbelow = false;
  4761. $dotabove = false;
  4762.  
  4763. if ($numberofpages > 1)
  4764. {
  4765. $output .= "<div class='pageselector'>";
  4766.  
  4767. if ($pagenumber != 1)
  4768. {
  4769. $output .= "<span class='previousnextactive'>";
  4770.  
  4771. if (!$showonecatonly)
  4772. $output .= "<a href='?page_id=" . get_the_ID() . "&linkresultpage=" . $previouspagenumber . "'>" . __('Previous', 'link-library') . "</a>";
  4773. elseif ($showonecatonly)
  4774. {
  4775. if ($showonecatmode == 'AJAX' || $showonecatmode == '')
  4776. $output .= "<a href='#' onClick=\"showLinkCat('" . $AJAXcatid . "', '" . $settings . "', " . $previouspagenumber . ");return false;\" >" . __('Previous', 'link-library') . "</a>";
  4777. elseif ($showonecatmode == 'HTMLGET')
  4778. $output .= "<a href='?page_id=" . get_the_ID() . "&linkresultpage=" . $previouspagenumber . "&cat_id=" . $AJAXcatid . "' >" . __('Previous', 'link-library') . "</a>";
  4779. }
  4780.  
  4781. $output .= "</span>";
  4782. }
  4783. else
  4784. $output .= "<span class='previousnextinactive'>" . __('Previous', 'link-library') . "</span>";
  4785.  
  4786. for ($counter = 1; $counter <= $numberofpages; $counter++)
  4787. {
  4788. if ($counter <= 2 || $counter >= $numberofpages - 1 || ($counter <= $pagenumber + 2 && $counter >= $pagenumber - 2))
  4789. {
  4790. if ($counter != $pagenumber)
  4791. $output .= "<span class='unselectedpage'>";
  4792. else
  4793. $output .= "<span class='selectedpage'>";
  4794.  
  4795. if (!$showonecatonly)
  4796. $output .= "<a href='?page_id=" . get_the_ID() . "&linkresultpage=" . $counter . "'>" . $counter . "</a>";
  4797. elseif ($showonecatonly)
  4798. {
  4799. if ($showonecatmode == 'AJAX' || $showonecatmode == '')
  4800. $output .= "<a href='#' onClick=\"showLinkCat('" . $AJAXcatid . "', '" . $settings . "', " . $counter . ");return false;\" >" . $counter . "</a>";
  4801. elseif ($showonecatmode == 'HTMLGET')
  4802. $output .= "<a href='?page_id=" . get_the_ID() . "&linkresultpage=" . $counter . "&cat_id=" . $AJAXcatid . "' >" . $counter . "</a>";
  4803. }
  4804.  
  4805. $output .= "</a></span>";
  4806. }
  4807.  
  4808. if ($counter >= 2 && $counter < $pagenumber - 2 && $dotbelow == false)
  4809. {
  4810. $output .= "...";
  4811. $dotbelow = true;
  4812. }
  4813.  
  4814. if ($counter > $pagenumber + 2 && $counter < $numberofpages - 1 && $dotabove == false)
  4815. {
  4816. $output .= "...";
  4817. $dotabove = true;
  4818. }
  4819. }
  4820.  
  4821. if ($pagenumber != $numberofpages)
  4822. {
  4823. $output .= "<span class='previousnextactive'>";
  4824.  
  4825. if (!$showonecatonly)
  4826. $output .= "<a href='?page_id=" . get_the_ID() . "&linkresultpage=" . $nextpagenumber . "'>" . __('Next', 'link-library') . "</a>";
  4827. elseif ($showonecatonly)
  4828. {
  4829. if ($showonecatmode == 'AJAX' || $showonecatmode == '')
  4830. $output .= "<a href='#' onClick=\"showLinkCat('" . $AJAXcatid . "', '" . $settings . "', " . $nextpagenumber . ");return false;\" >" . __('Next', 'link-library') . "</a>";
  4831. elseif ($showonecatmode == 'HTMLGET')
  4832. $output .= "<a href='?page_id=" . get_the_ID() . "&linkresultpage=" . $nextpagenumber . "&cat_id=" . $AJAXcatid . "' >" . __('Next', 'link-library') . "</a>";
  4833. }
  4834.  
  4835. $output .= "</span>";
  4836. }
  4837. else
  4838. $output .= "<span class='previousnextinactive'>" . __('Next', 'link-library') . "</span>";
  4839.  
  4840. $output .= "</div>";
  4841. }
  4842. }
  4843.  
  4844. $output .= "<script type='text/javascript'>\n";
  4845. $output .= "jQuery(document).ready(function()\n";
  4846. $output .= "{\n";
  4847. $output .= "jQuery('a.track_this_link').click(function() {\n";
  4848. $output .= "linkid = this.id;\n";
  4849. $output .= "linkid = linkid.substring(5);";
  4850. $output .= "jQuery.post('" . WP_PLUGIN_URL . "/link-library/tracker.php', {id:linkid});\n";
  4851. $output .= "return true;\n";
  4852. $output .= "});\n";
  4853. $output .= "});\n";
  4854. $output .= "</script>";
  4855.  
  4856. $currentcategory = $currentcategory + 1;
  4857.  
  4858. $output .= "</div>\n";
  4859.  
  4860. }
  4861. else
  4862. {
  4863. $output .= "<div id='linklist" . $settings . "' class='linklist'>\n";
  4864. $output .= __('No links found', 'link-library') . ".\n";
  4865. $output .= "</div>";
  4866. }
  4867.  
  4868. $output .= "\n<!-- End of Link Library Output -->\n\n";
  4869.  
  4870. return $output;
  4871. }
  4872.  
  4873. function PrivateLinkLibrarySearchForm($searchlabel = 'Search', $searchresultsaddress = '') {
  4874.  
  4875. if ($searchlabel == "") $searchlabel = __('Search', 'link-library');
  4876. $output = "<form method='get' id='llsearch'";
  4877. if ($searchresultsaddress != '')
  4878. $output .= " action='" . $searchresultsaddress . "'";
  4879. $output .= ">\n";
  4880. $output .= "<div>\n";
  4881. $output .= "<input type='text' onfocus=\"this.value=''\" value='" . $searchlabel . "...' name='searchll' id='searchll' />\n";
  4882. $output .= "<input type='hidden' value='" . get_the_ID() . "' name='page_id' id='page_id' />\n";
  4883. $output .= "<input type='submit' value='" . $searchlabel . "' />\n";
  4884. $output .= "</div>\n";
  4885. $output .= "</form>\n\n";
  4886.  
  4887. return $output;
  4888. }
  4889.  
  4890. function PrivateLinkLibraryAddLinkForm($selectedcategorylist = '', $excludedcategorylist = '', $addnewlinkmsg = '', $linknamelabel = '', $linkaddrlabel = '',
  4891. $linkrsslabel = '', $linkcatlabel = '', $linkdesclabel = '', $linknoteslabel = '', $addlinkbtnlabel = '', $hide_if_empty = true,
  4892. $showaddlinkrss = false, $showaddlinkdesc = false, $showaddlinkcat = false, $showaddlinknotes = false,
  4893. $addlinkreqlogin = false, $debugmode = false, $addlinkcustomcat = false, $linkcustomcatlabel = '',
  4894. $linkcustomcatlistentry = 'User-submitted category (define below)', $showaddlinkreciprocal = false,
  4895. $linkreciprocallabel = '', $showaddlinksecondurl = false, $linksecondurllabel = '',
  4896. $showaddlinktelephone = false, $linktelephonelabel = '', $showaddlinkemail = false, $linkemaillabel = '',
  4897. $showcaptcha = false, $captureddata = '', $linksubmitternamelabel = '', $showlinksubmittername = false,
  4898. $linksubmitteremaillabel = '', $showaddlinksubmitteremail = false, $linksubmittercommentlabel = '',
  4899. $showlinksubmittercomment = false, $linksubmissionthankyouurl = '', $addlinkcatlistoverride = '',
  4900. $showcustomcaptcha = false, $customcaptchaquestion = '', $linklargedesclabel = 'Large Description', $showuserlargedescription = false, $usetextareaforusersubmitnotes = false, $settings = 1, $code = 'link-library-addlink') {
  4901.  
  4902. global $wpdb;
  4903. $output = "";
  4904.  
  4905. $settingsname = 'LinkLibraryPP' . $settings;
  4906. $options = get_option($settingsname);
  4907.  
  4908. if ($code == 'link-library-addlink' || $code == 'link-library-addlinkcustommsg')
  4909. {
  4910. if (isset($_GET['addlinkmessage']))
  4911. {
  4912. if ($_GET['addlinkmessage'] == 1)
  4913. $output = "<div class='llmessage'>" . __('Confirm code not given', 'link-library') . ".</div>";
  4914. elseif ($_GET['addlinkmessage'] == 2)
  4915. $output = "<div class='llmessage'>" . __('Captcha code is wrong', 'link-library') . ".</div>";
  4916. elseif ($_GET['addlinkmessage'] == 3)
  4917. $output = "<div class='llmessage'>" . __('Captcha code is only valid for 5 minutes', 'link-library') . ".</div>";
  4918. elseif ($_GET['addlinkmessage'] == 4)
  4919. $output = "<div class='llmessage'>" . __('No captcha cookie given. Make sure cookies are enabled', 'link-library') . ".</div>";
  4920. elseif ($_GET['addlinkmessage'] == 5)
  4921. $output = "<div class='llmessage'>" . __('Captcha answer was not provided.', 'link-library') . "</div>";
  4922. elseif ($_GET['addlinkmessage'] == 6)
  4923. $output = "<div class='llmessage'>" . __('Captcha answer is incorrect', 'link-library') . ".</div>";
  4924. elseif ($_GET['addlinkmessage'] == 7)
  4925. $output = "<div class='llmessage'>" . __('User Category was not provided correctly. Link insertion failed.', 'link-library') . "</div>";
  4926. elseif ($_GET['addlinkmessage'] == 8)
  4927. {
  4928. $output .= "<div class='llmessage'>" . $options['newlinkmsg'];
  4929. if ($options['showuserlinks'] == false)
  4930. $output .= " " . $options['moderatemsg'];
  4931. $output .= "</div>";
  4932. }
  4933. elseif ($_GET['addlinkmessage'] == 9)
  4934. $output = "<div class='llmessage'>" . __('Error: Link does not have an address.', 'link-library') . "</div>";
  4935. elseif ($_GET['addlinkmessage'] == 10)
  4936. $output = "<div class='llmessage'>" . __('Error: Link already exists.', 'link-library') . "</div>";
  4937. }
  4938. }
  4939.  
  4940. if ($code == 'link-library-addlink' && (($addlinkreqlogin && current_user_can("read")) || !$addlinkreqlogin))
  4941. {
  4942. $output .= "<form method='post' id='lladdlink' action='" . plugins_url('usersubmission.php', __FILE__). "'>\n";
  4943.  
  4944. $output .= wp_nonce_field('LL_ADDLINK_FORM', '_wpnonce', true, false);
  4945. $output .= "<input type='hidden' name='thankyouurl' value='" . $linksubmissionthankyouurl . "' />";
  4946. $output .= "<input type='hidden' name='settingsid' value='" . $settings . "' />";
  4947.  
  4948. $output .= "<div class='lladdlink'>\n";
  4949.  
  4950. if ($addnewlinkmsg == "") $addnewlinkmsg = __('Add new link', 'link-library');
  4951. $output .= "<div id='lladdlinktitle'>" . $addnewlinkmsg . "</div>\n";
  4952.  
  4953. $output .= "<table>\n";
  4954.  
  4955. if ($linknamelabel == "") $linknamelabel = __('Link name', 'link-library');
  4956. $output .= "<tr><th>" . $linknamelabel . "</th><td><input type='text' name='link_name' id='link_name' value='" . esc_html(stripslashes($_GET['addlinkname']), '1') . "' /></td></tr>\n";
  4957.  
  4958. if ($linkaddrlabel == "") $linkaddrlabel = __('Link address', 'link-library');
  4959. $output .= "<tr><th>" . $linkaddrlabel . "</th><td><input type='text' name='link_url' id='link_url' value='" . esc_html(stripslashes($_GET['addlinkurl']), '1') . "' /></td></tr>\n";
  4960.  
  4961. if ($showaddlinkrss)
  4962. {
  4963. if ($linkrsslabel == "") $linkrsslabel = __('Link RSS', 'link-library');
  4964. $output .= "<tr><th>" . $linkrsslabel . "</th><td><input type='text' name='link_rss' id='link_rss' value='" . esc_html(stripslashes($_GET['addlinkrss']), '1') . "' /></td></tr>\n";
  4965. }
  4966.  
  4967. $linkcatquery = "SELECT distinct t.name, t.term_id, t.slug as category_nicename, tt.description as category_description ";
  4968. $linkcatquery .= "FROM " . $this->db_prefix() . "terms t ";
  4969. $linkcatquery .= "LEFT JOIN " . $this->db_prefix() . "term_taxonomy tt ON (t.term_id = tt.term_id) ";
  4970. $linkcatquery .= "LEFT JOIN " . $this->db_prefix() . "term_relationships tr ON (tt.term_taxonomy_id = tr.term_taxonomy_id) ";
  4971.  
  4972. $linkcatquery .= "WHERE tt.taxonomy = 'link_category' ";
  4973.  
  4974. if ($selectedcategorylist != "")
  4975. {
  4976. $linkcatquery .= " AND t.term_id in (" . $selectedcategorylist. ")";
  4977. }
  4978.  
  4979. if ($excludedcategorylist != "")
  4980. {
  4981. $linkcatquery .= " AND t.term_id not in (" . $excludedcategorylist . ")";
  4982. }
  4983.  
  4984. $linkcatquery .= " ORDER by t.name ASC";
  4985.  
  4986. $linkcats = $wpdb->get_results($linkcatquery);
  4987.  
  4988. if ($debugmode)
  4989. {
  4990. $output .= "\n<!-- Category query for add link form:" . print_r($linkcatquery, TRUE) . "-->\n\n";
  4991. $output .= "\n<!-- Results of Category query for add link form:" . print_r($linkcats, TRUE) . "-->\n";
  4992. }
  4993.  
  4994. if ($linkcats)
  4995. {
  4996. if ($showaddlinkcat)
  4997. {
  4998. if ($linkcatlabel == "") $linkcatlabel = __('Link category', 'link-library');
  4999.  
  5000. $output .= "<tr><th>" . $linkcatlabel . "</th><td><SELECT name='link_category' id='link_category'>";
  5001.  
  5002. if ($linkcustomcatlistentry == "") $linkcustomcatlistentry = __('User-submitted category (define below)', 'link-library');
  5003.  
  5004. foreach ($linkcats as $linkcat)
  5005. {
  5006. $output .= "<OPTION VALUE='" . $linkcat->term_id . "' ";
  5007. if ($_GET['addlinkcat'] == $linkcat->term_id)
  5008. $output .= "selected";
  5009. $output .= ">" . $linkcat->name;
  5010. }
  5011.  
  5012. if ($addlinkcustomcat)
  5013. $output .= "<OPTION VALUE='new'>" . stripslashes($linkcustomcatlistentry) . "\n";
  5014.  
  5015. $output .= "</SELECT></td></tr>\n";
  5016. }
  5017. else
  5018. {
  5019. $output .= "<input type='hidden' name='link_category' id='link_category' value='" . $linkcats[0]->term_id . "'>";
  5020. }
  5021.  
  5022. if ($addlinkcustomcat)
  5023. $output .= "<tr><th>" . $linkcustomcatlabel . "</th><td><input type='text' name='link_user_category' id='link_user_category' value='" . esc_html(stripslashes($_GET['addlinkusercat']), '1') . "' /></td></tr>\n";
  5024. }
  5025.  
  5026. if ($showaddlinkdesc)
  5027. {
  5028. if ($linkdesclabel == "") $linkdesclabel = __('Link description', 'link-library');
  5029. $output .= "<tr><th>" . $linkdesclabel . "</th><td><input type='text' name='link_description' id='link_description' value='" . esc_html(stripslashes($_GET['addlinkdesc']), '1') . "' /></td></tr>\n";
  5030. }
  5031.  
  5032. if ($showuserlargedescription)
  5033. {
  5034. if ($linklargedesclabel == "") $linklargedesclabel = __('Large description', 'link-library');
  5035. $output .= "<tr><th style='vertical-align: top'>" . $linklargedesclabel . "</th><td><textarea name='link_textfield' id='link_textfield' cols='66'>" . esc_html(stripslashes($_GET['addlinktextfield']), '1') . "</textarea></td></tr>\n";
  5036. }
  5037.  
  5038. if ($showaddlinknotes)
  5039. {
  5040. if ($linknoteslabel == "") $linknoteslabel = __('Link notes', 'link-library');
  5041. $output .= "<tr><th>" . $linknoteslabel . "</th><td>";
  5042.  
  5043. if ($usetextareaforusersubmitnotes == false || $usetextareaforusersubmitnotes == '')
  5044. $output .= "<input type='text' name='link_notes' id='link_notes' value='";
  5045. elseif ($usetextareaforusersubmitnotes == true)
  5046. $output .= "<textarea name='link_notes' id='link_notes'>";
  5047.  
  5048. $output .= esc_html(stripslashes($_GET['addlinknotes']), '1');
  5049.  
  5050. if ($usetextareaforusersubmitnotes == false || $usetextareaforusersubmitnotes == '')
  5051. $output .= "' />";
  5052. elseif ($usetextareaforusersubmitnotes == true)
  5053. $output .= "</textarea>";
  5054.  
  5055. $output .= "</td></tr>\n";
  5056. }
  5057.  
  5058. if ($showaddlinkreciprocal)
  5059. {
  5060. if ($linkreciprocallabel == "") $linkreciprocallabel = __('Reciprocal Link', 'link-library');
  5061. $output .= "<tr><th>" . $linkreciprocallabel . "</th><td><input type='text' name='ll_reciprocal' id='ll_reciprocal' value='" . esc_html(stripslashes($_GET['addlinkreciprocal']), '1') . "' /></td></tr>\n";
  5062. }
  5063.  
  5064. if ($showaddlinksecondurl)
  5065. {
  5066. if ($linksecondurllabel == "") $linksecondurllabel = __('Secondary Address', 'link-library');
  5067. $output .= "<tr><th>" . $linksecondurllabel . "</th><td><input type='text' name='ll_secondwebaddr' id='ll_secondwebaddr' value='" . esc_html(stripslashes($_GET['addlinksecondurl']), '1') . "' /></td></tr>\n";
  5068. }
  5069.  
  5070. if ($showaddlinktelephone)
  5071. {
  5072. if ($linktelephonelabel == "") $linktelephonelabel = __('Telephone', 'link-library');
  5073. $output .= "<tr><th>" . $linktelephonelabel . "</th><td><input type='text' name='ll_telephone' id='ll_telephone' value='" . esc_html(stripslashes($_GET['addlinktelephone']), '1') . "' /></td></tr>\n";
  5074. }
  5075.  
  5076. if ($showaddlinkemail)
  5077. {
  5078. if ($linkemaillabel == "") $linkemaillabel = __('E-mail', 'link-library');
  5079. $output .= "<tr><th>" . $linkemaillabel . "</th><td><input type='text' name='ll_email' id='ll_email' value='" . esc_html(stripslashes($_GET['addlinkemail']), '1') . "' /></td></tr>\n";
  5080. }
  5081.  
  5082. if ($showlinksubmittername)
  5083. {
  5084. if ($linksubmitternamelabel == "") $linksubmitternamelabel = __('Submitter Name', 'link-library');
  5085. $output .= "<tr><th>" . $linksubmitternamelabel . "</th><td><input type='text' name='ll_submittername' id='ll_submittername' value='" . esc_html(stripslashes($_GET['addlinksubmitname']), '1') . "' /></td></tr>\n";
  5086. }
  5087.  
  5088. if ($showaddlinksubmitteremail)
  5089. {
  5090. if ($linksubmitteremaillabel == "") $linksubmitteremaillabel = __('Submitter E-mail', 'link-library');
  5091. $output .= "<tr><th>" . $linksubmitteremaillabel . "</th><td><input type='text' name='ll_submitteremail' id='ll_submitteremail' value='" . esc_html(stripslashes($_GET['addlinksubmitemail']), '1') . "' /></td></tr>\n";
  5092. }
  5093.  
  5094. if ($showlinksubmittercomment)
  5095. {
  5096. if ($linksubmittercommentlabel == "") $linksubmittercommentlabel = __('Submitter Comment', 'link-library');
  5097. $output .= "<tr><th style='vertical-align: top;'>" . $linksubmittercommentlabel . "</th><td><textarea name='ll_submittercomment' id='ll_submittercomment' cols='38''>" . esc_html(stripslashes($_GET['addlinksubmitcomment']), '1') . "</textarea></td></tr>\n";
  5098. }
  5099.  
  5100. if ($showcaptcha)
  5101. {
  5102. $output .= "<tr><td></td><td><span id='captchaimage'><img src='" . plugins_url( 'captcha/easycaptcha.php', __FILE__ ) . "' /></span></td></tr>\n";
  5103. $output .= "<tr><th>" . __('Enter code from above image', 'link-library') . "</th><td><input type='text' name='confirm_code' /></td></tr>\n";
  5104. }
  5105.  
  5106. if ($showcustomcaptcha)
  5107. {
  5108. if ($customcaptchaquestion == "") $customcaptchaquestion = __('Is boiling water hot or cold?', 'link-library');
  5109. $output .= "<tr><th style='vertical-align: top;'>" . $customcaptchaquestion . "</th><td><input type='text' name='ll_customcaptchaanswer' id='ll_customcaptchaanswer' value='" . $_GET['ll_customcaptchaanswer'] . "' /></td></tr>\n";
  5110. }
  5111.  
  5112. $output .= "</table>\n";
  5113.  
  5114. if ($addlinkbtnlabel == "") $addlinkbtnlabel = __('Add link', 'link-library');
  5115. $output .= '<span style="border:0;" class="LLUserLinkSubmit"><input type="submit" name="submit" value="' . $addlinkbtnlabel . '" /></span>';
  5116.  
  5117. $output .= "</div>\n";
  5118. $output .= "</form>\n\n";
  5119. }
  5120.  
  5121. return $output;
  5122. }
  5123.  
  5124. /*
  5125. * function LinkLibraryCategories()
  5126. *
  5127. * added by Yannick Lefebvre
  5128. *
  5129. * Output a list of all links categories, listed by category, using the
  5130. * settings in $wpdb->linkcategories and output it as table
  5131. *
  5132. * Parameters:
  5133. * order (default 'name') - Sort link categories by 'name' or 'id' or 'category-list'. When set to 'AdminSettings', will use parameters set in Admin Settings Panel.
  5134. * hide_if_empty (default true) - Supress listing empty link categories
  5135. * table_witdh (default 100) - Width of table, percentage
  5136. * num_columns (default 1) - Number of columns in table
  5137. * catanchor (default true) - Determines if links to generated anchors should be created
  5138. * flatlist (default 'table') - When set to true, displays an unordered list instead of a table
  5139. * categorylist (default null) - Specifies a comma-separate list of the only categories that should be displayed
  5140. * excludecategorylist (default null) - Specifies a comma-separate list of the categories that should not be displayed
  5141. * showcategorydescheaders (default null) - Show category descriptions in category list
  5142. * showonecatonly (default false) - Enable AJAX mode showing only one category at a time
  5143. * settings (default NULL) - Settings Set ID, only used when showonecatonly is true
  5144. * loadingicon (default NULL) - Path to icon to display when only show one category at a time
  5145. * catlistdescpos (default 'right') - Position of category description relative to name
  5146. * debugmode (default false)
  5147. * pagination (default false)
  5148. * linksperpage (default 5)
  5149. * showcatlinkcount (default false)
  5150. * showonecatmode (default 'AJAX')
  5151. * cattargetaddress
  5152. * rewritepage
  5153. * showinvisible
  5154. */
  5155.  
  5156. function LinkLibraryCategories($order = 'name', $hide_if_empty = true, $table_width = 100, $num_columns = 1, $catanchor = true,
  5157. $flatlist = 'table', $categorylist = '', $excludecategorylist = '', $showcategorydescheaders = false,
  5158. $showonecatonly = false, $settings = '', $loadingicon = '/icons/Ajax-loader.gif', $catlistdescpos = 'right', $debugmode = false,
  5159. $pagination = false, $linksperpage = 5, $showcatlinkcount = false, $showonecatmode = 'AJAX', $cattargetaddress = '',
  5160. $rewritepage = '', $showinvisible = false, $showuserlinks = true, $showcatonsearchresults = false) {
  5161.  
  5162. if (strpos($order, 'AdminSettings') != false)
  5163. {
  5164. $settingsetid = substr($order, 13);
  5165. $settingsetname = "LinkLibraryPP" . $settingsetid;
  5166. $options = get_option($settingsetname);
  5167.  
  5168. $genoptions = get_option('LinkLibraryGeneral');
  5169.  
  5170. return $this->PrivateLinkLibraryCategories($options['order'], $options['hide_if_empty'], $options['table_width'], $options['num_columns'], $options['catanchor'], $options['flatlist'],
  5171. $options['categorylist'], $options['excludecategorylist'], $options['showcategorydescheaders'], $options['showonecatonly'], '',
  5172. $options['loadingicon'], $options['catlistdescpos'], $genoptions['debugmode'], $options['pagination'], $options['linksperpage'],
  5173. $options['showcatlinkcount'], $options['showonecatmode'], $options['cattargetaddress'], $options['rewritepage'], $options['showinvisible'], $options['showuserlinks'], $options['showcatonsearchresults']);
  5174. }
  5175. else
  5176. return $this->PrivateLinkLibraryCategories($order, $hide_if_empty, $table_width, $num_columns, $catanchor, $flatlist, $categorylist, $excludecategorylist, $showcategorydescheaders,
  5177. $showonecatonly, $settings, $loadingicon, $catlistdescpos, $debugmode, $pagination, $linksperpage, $showcatlinkcount, $showonecatmode, $cattargetaddress,
  5178. $rewritepage, $showinvisible, $showuserlinks, $showcatonsearchresults);
  5179.  
  5180. }
  5181.  
  5182. /*
  5183. * function LinkLibrary()
  5184. *
  5185. * added by Yannick Lefebvre
  5186. *
  5187. * Output a list of all links, listed by category, using the
  5188. * settings in $wpdb->linkcategories and output it as a nested
  5189. * HTML unordered list. Can also insert anchors for categories
  5190. *
  5191. * Parameters:
  5192. * order (default 'name') - Sort link categories by 'name' or 'id'. When set to 'AdminSettings', will use parameters set in Admin Settings Panel.
  5193. * hide_if_empty (default true) - Supress listing empty link categories
  5194. * catanchor (default true) - Adds name anchors to categorie links to be able to link directly to categories\
  5195. * showdescription (default false) - Displays link descriptions. Added for 2.1 since link categories no longer have this setting
  5196. * shownotes (default false) - Shows notes in addition to description for links (useful since notes field is larger than description)
  5197. * showrating (default false) - Displays link ratings. Added for 2.1 since link categories no longer have this setting
  5198. * showupdated (default false) - Displays link updated date. Added for 2.1 since link categories no longer have this setting
  5199. * categorylist (default null) - Only show links inside of selected categories. Enter category numbers in a string separated by commas
  5200. * showimages (default false) - Displays link images. Added for 2.1 since link categories no longer have this setting
  5201. * show_image_and_name (default false) - Show both image and name instead of only one or the other
  5202. * use_html_tags (default false) - Use HTML tags for formatting instead of just displaying them
  5203. * show_rss (default false) - Display RSS URI if available in link description
  5204. * beforenote (default <br />) - Code to print out between the description and notes
  5205. * nofollow (default false) - Adds nofollow tag to outgoing links
  5206. * excludecategorylist (default null) - Specifies a comma-separate list of the categories that should not be displayed
  5207. * afternote (default null) - Code / Text to be displayed after note
  5208. * beforeitem (default null) - Code / Text to be displayed before item
  5209. * afteritem (default null) - Code / Text to be displayed after item
  5210. * beforedesc (default null) - Code / Text to be displayed before description
  5211. * afterdesc (default null) - Code / Text to be displayed after description
  5212. * displayastable (default false) - Display lists of links as a table (when true) or as an unordered list (when false)
  5213. * beforelink (default null) - Code / Text to be displayed before link
  5214. * afterlink (default null) - Code / Text to be displayed after link
  5215. * showcolumnheaders (default false) - Show column headers if rendering in table mode
  5216. * linkheader (default null) - Text to be shown in link column when displaying as table
  5217. * descheader (default null) - Text to be shown in desc column when displaying as table
  5218. * notesheader (default null) - Text to be shown in notes column when displaying as table
  5219. * catlistwrappers (default 1) - Number of different sets of alternating elements to be placed before and after each link category section
  5220. * beforecatlist1 (default null) - First element to be placed before a link category section
  5221. * beforecatlist2 (default null) - Second element to be placed before a link category section
  5222. * beforecatlist3 (default null) - Third element to be placed before a link category section
  5223. * divorheader (default false) - Output div before and after cat name if false, output heading tag if true
  5224. * catnameoutput (default linklistcatname) - Name of div class or heading to output
  5225. * showrssicon (default false) - Output RSS URI if available and assign to standard RSS icon
  5226. * linkaddfrequency (default 0) - Frequency at which extra before and after output should be placed around links
  5227. * addbeforelink (default null) - Addition output to be placed before link
  5228. * addafterlink (default null) - Addition output to be placed after link
  5229. * linktarget (default null) - Specifies the link target window
  5230. * showcategorydescheaders (default false) - Display link category description when printing category list
  5231. * showcategorydesclinks (default false) - Display link category description when printing links
  5232. * showadmineditlinks (default false) - Display edit links in output if logged in as administrator
  5233. * showonecatonly (default false) - Only show one category at a time
  5234. * AJAXcatid (default null) - Category ID for AJAX sub-queries
  5235. * defaultsinglecat (default null) - ID of first category to be shown in single category mode
  5236. * rsspreview (default false) - Add preview links after RSS feed addresses
  5237. * rssfeedpreviewcount(default 3) - Number of RSS feed items to show in preview
  5238. * rssfeedinline (default false) - Shows latest feed items inline with link list
  5239. * rssfeedinlinecontent (default false) - Shows latest feed items contents inline with link list
  5240. * rssfeedinlinecount (default 1) - Number of RSS feed items to show inline
  5241. * beforerss (default null) - String to output before RSS block
  5242. * afterrss (default null) - String to output after RSS block
  5243. * rsscachedir (default null) - Path for SimplePie library to store RSS cache information - Obsolete
  5244. * direction (default ASC) - Sort direction for Link Categories
  5245. * linkdirection (default ASC) - Sort direction for Links within each category
  5246. * linkorder (default 'name') - Sort order for Links within each category
  5247. * pagination (default false) - Limit number of links displayed per page
  5248. * linksperpage (default 5) - Number of links to be shown per page in Pagination Mode
  5249. * hidecategorynames (default false) - Show category names in Link Library list
  5250. * settings (default NULL) - Setting Set ID
  5251. * showinvisible (default false) - Shows links that are set to be invisible
  5252. * showdate (default false) - Determines is link update date should be displayed
  5253. * beforedate (default null) - Code/Text to be displayed before link date
  5254. * afterdate (default null) - Code/Text to be displated after link date
  5255. * catdescpos (default 'right') - Position of link category description output
  5256. * showuserlinks (default false) - Specifies if user submitted links should be shown immediately after submission
  5257. * rsspreviewwidth (default 900) - Specifies the width of the box in which RSS previews are displayed
  5258. * rsspreviewheight (default 700) - Specifies the height of the box in which RSS previews are displayed
  5259. * beforeimage (default null) - Code/Text to be displayed before link image
  5260. * afterimage (default null) - Code/Text to be displayed after link image
  5261. * imagepos (default beforename) - Position of image relative to link name
  5262. * imageclass (default null) - Class that will be assigned to link images
  5263. * debugmode (default false) - Adds debug information as comments in the Wordpress output to facilitate remote debugging
  5264. * usethumbshotsforimages (default false) - Uses thumbshots.org to generate images for links
  5265. * showonecatmode (default AJAX) - Method used to load different categories when only showing one at a time
  5266. * dragndroporder (default 1,2,3,4,5,6,7,8,9,10) - Order to display link sub-sections
  5267. * displayweblink (default 'false')
  5268. * sourceweblink (default 'primary')
  5269. * showtelephone (default 'false')
  5270. * sourcetelephone (default 'primary')
  5271. * showemail (default 'false')
  5272. * showlinkhits (default false)
  5273. * beforeweblink (default null)
  5274. * afterweblink (default null)
  5275. * weblinklabel (default null)
  5276. * beforetelephone (default null)
  5277. * aftertelephone (default null)
  5278. * telephonelabel (default null)
  5279. * beforeemail (default null)
  5280. * afteremail (default null)
  5281. * emaillabel (default null)
  5282. * beforelinkhits (default null)
  5283. * afterlinkhits (default null)
  5284. * emailcommand (default null)
  5285. */
  5286.  
  5287. function LinkLibrary($order = 'name', $hide_if_empty = true, $catanchor = true,
  5288. $showdescription = false, $shownotes = false, $showrating = false,
  5289. $showupdated = false, $categorylist = '', $show_images = false,
  5290. $show_image_and_name = false, $use_html_tags = false,
  5291. $show_rss = false, $beforenote = '<br />', $nofollow = false, $excludecategorylist = '',
  5292. $afternote = '', $beforeitem = '<li>', $afteritem = '</li>', $beforedesc = '', $afterdesc = '',
  5293. $displayastable = false, $beforelink = '', $afterlink = '', $showcolumnheaders = false,
  5294. $linkheader = '', $descheader = '', $notesheader = '', $catlistwrappers = 1, $beforecatlist1 = '',
  5295. $beforecatlist2 = '', $beforecatlist3 = '', $divorheader = false, $catnameoutput = 'linklistcatname',
  5296. $show_rss_icon = false, $linkaddfrequency = 0, $addbeforelink = '', $addafterlink = '', $linktarget = '',
  5297. $showcategorydesclinks = false, $showadmineditlinks = true, $showonecatonly = false, $AJAXcatid = '',
  5298. $defaultsinglecat = '', $rsspreview = false, $rsspreviewcount = 3, $rssfeedinline = false, $rssfeedinlinecontent = false,
  5299. $rssfeedinlinecount = 1, $beforerss = '', $afterrss = '', $rsscachedir = NULL, $direction = 'ASC',
  5300. $linkdirection = 'ASC', $linkorder = 'name', $pagination = false, $linksperpage = 5, $hidecategorynames = false,
  5301. $settings = '', $showinvisible = false, $showdate = false, $beforedate = '', $afterdate = '', $catdescpos = 'right',
  5302. $showuserlinks = false, $rsspreviewwidth = 900, $rsspreviewheight = 700, $beforeimage = '', $afterimage = '', $imagepos = 'beforename',
  5303. $imageclass = '', $AJAXpageid = 1, $debugmode = false, $usethumbshotsforimages = false, $showonecatmode = 'AJAX',
  5304. $dragndroporder = '1,2,3,4,5,6,7,8,9,10', $showname = true, $displayweblink = 'false', $sourceweblink = 'primary', $showtelephone = 'false',
  5305. $sourcetelephone = 'primary', $showemail = 'false', $showlinkhits = false, $beforeweblink = '', $afterweblink = '', $weblinklabel = '',
  5306. $beforetelephone = '', $aftertelephone = '', $telephonelabel = '', $beforeemail = '', $afteremail = '', $emaillabel = '', $beforelinkhits = '',
  5307. $afterlinkhits = '', $emailcommand = '', $sourceimage = 'primary', $sourcename = 'primary', $thumbshotscid = '',
  5308. $maxlinks = '', $beforelinkrating = '', $afterlinkrating = '', $showlargedescription = false, $beforelargedescription = '',
  5309. $afterlargedescription = '', $featuredfirst = false, $shownameifnoimage = false, $enablelinkpopup = false, $popupwidth = 300, $popupheight = 400, $nocatonstartup = false ) {
  5310.  
  5311. if (strpos($order, 'AdminSettings') !== false)
  5312. {
  5313. $settingsetid = substr($order, 13);
  5314. $settingsetname = "LinkLibraryPP" . $settingsetid;
  5315. $options = get_option($settingsetname);
  5316.  
  5317. $genoptions = get_option('LinkLibraryGeneral');
  5318.  
  5319. return $this->PrivateLinkLibrary($options['order'], $options['hide_if_empty'], $options['catanchor'], $options['showdescription'], $options['shownotes'],
  5320. $options['showrating'], $options['showupdated'], $options['categorylist'], $options['show_images'],
  5321. false, $options['use_html_tags'], $options['show_rss'], $options['beforenote'],
  5322. $options['nofollow'], $options['excludecategorylist'], $options['afternote'], $options['beforeitem'],
  5323. $options['afteritem'], $options['beforedesc'], $options['afterdesc'], $options['displayastable'],
  5324. $options['beforelink'], $options['afterlink'], $options['showcolumnheaders'], $options['linkheader'],
  5325. $options['descheader'], $options['notesheader'], $options['catlistwrappers'], $options['beforecatlist1'],
  5326. $options['beforecatlist2'], $options['beforecatlist3'], $options['divorheader'], $options['catnameoutput'],
  5327. $options['show_rss_icon'], $options['linkaddfrequency'], $options['addbeforelink'], $options['addafterlink'],
  5328. $options['linktarget'], $options['showcategorydesclinks'], $options['showadmineditlinks'], $options['showonecatonly'],
  5329. $AJAXcatid, $options['defaultsinglecat'], $options['rsspreview'], $options['rsspreviewcount'], $options['rssfeedinline'],
  5330. $options['rssfeedinlinecontent'], $options['rssfeedinlinecount'], $options['beforerss'], $options['afterrss'],
  5331. NULL, $options['direction'], $options['linkdirection'], $options['linkorder'],
  5332. $options['pagination'], $options['linksperpage'], $options['hidecategorynames'], $settingsetid, $options['showinvisible'],
  5333. $options['showdate'], $options['beforedate'], $options['afterdate'], $options['catdescpos'], $options['showuserlinks'],
  5334. $options['rsspreviewwidth'], $options['rsspreviewheight'], $options['beforeimage'], $options['afterimage'], $options['imagepos'],
  5335. $options['imageclass'], $AJAXpageid, $genoptions['debugmode'], $options['usethumbshotsforimages'], 'AJAX', $options['dragndroporder'],
  5336. $options['showname'], $options['displayweblink'], $options['sourceweblink'], $options['showtelephone'], $options['sourcetelephone'],
  5337. $options['showemail'], $options['showlinkhits'], $options['beforeweblink'], $options['afterweblink'], $options['weblinklabel'],
  5338. $options['beforetelephone'], $options['aftertelephone'], $options['telephonelabel'], $options['beforeemail'], $options['afteremail'],
  5339. $options['emaillabel'], $options['beforelinkhits'], $options['afterlinkhits'], $options['emailcommand'], $options['sourceimage'],
  5340. $options['sourcename'], $genoptions['thumbshotscid'], $options['maxlinks'], $options['beforelinkrating'],
  5341. $options['afterlinkrating'], $options['showlargedescription'], $options['beforelargedescription'],
  5342. $options['afterlargedescription'], $options['featuredfirst'], $options['shownameifnoimage'], $options['enable_link_popup'],
  5343. $options['popup_width'], $options['popup_height'], $options['nocatonstartup'] );
  5344. }
  5345. else
  5346. return $this->PrivateLinkLibrary($order, $hide_if_empty, $catanchor, $showdescription, $shownotes, $showrating,
  5347. $showupdated, $categorylist, $show_images, false, $use_html_tags,
  5348. $show_rss, $beforenote, $nofollow, $excludecategorylist, $afternote, $beforeitem, $afteritem,
  5349. $beforedesc, $afterdesc, $displayastable, $beforelink, $afterlink, $showcolumnheaders,
  5350. $linkheader, $descheader, $notesheader, $catlistwrappers, $beforecatlist1,
  5351. $beforecatlist2, $beforecatlist3, $divorheader, $catnameoutput, $show_rss_icon,
  5352. $linkaddfrequency, $addbeforelink, $addafterlink, $linktarget, $showcategorydesclinks, $showadmineditlinks,
  5353. $showonecatonly, '', $defaultsinglecat, $rsspreview, $rsspreviewcount, $rssfeedinline, $rssfeedinlinecontent, $rssfeedinlinecount,
  5354. $beforerss, $afterrss, NULL, $direction, $linkdirection, $linkorder,
  5355. $pagination, $linksperpage, $hidecategorynames, $settings, $showinvisible, $showdate, $beforedate, $afterdate, $catdescpos,
  5356. $showuserlinks, $rsspreviewwidth, $rsspreviewheight, $beforeimage, $afterimage, $imagepos, $imageclass, '', $debugmode,
  5357. $usethumbshotsforimages, $showonecatmode, $dragndroporder, $showname, $displayweblink, $sourceweblink, $showtelephone,
  5358. $sourcetelephone, $showemail, $showlinkhits, $beforeweblink, $afterweblink, $weblinklabel, $beforetelephone, $aftertelephone,
  5359. $telephonelabel, $beforeemail, $afteremail, $emaillabel, $beforelinkhits, $afterlinkhits, $emailcommand, $sourceimage, $sourcename,
  5360. $thumbshotscid, $maxlinks, $beforelinkrating, $afterlinkrating, $showlargedescription, $beforelargedescription,
  5361. $afterlargedescription, $featuredfirst, $shownameifnoimage, $enablelinkpopup, $popupwidth, $popupheight, $nocatonstartup );
  5362. }
  5363.  
  5364. /********************************************** Function to Process [link-library-cats] shortcode *********************************************/
  5365.  
  5366. function link_library_cats_func($atts) {
  5367. extract(shortcode_atts(array(
  5368. 'categorylistoverride' => '',
  5369. 'excludecategoryoverride' => '',
  5370. 'settings' => ''
  5371. ), $atts));
  5372.  
  5373. if ($settings == '')
  5374. {
  5375. $settings = 1;
  5376. $options = get_option('LinkLibraryPP1');
  5377. }
  5378. else
  5379. {
  5380. $settingsname = 'LinkLibraryPP' . $settings;
  5381. $options = get_option($settingsname);
  5382. }
  5383.  
  5384. if ($categorylistoverride != '')
  5385. $selectedcategorylist = $categorylistoverride;
  5386. else
  5387. $selectedcategorylist = $options['categorylist'];
  5388.  
  5389. if ($excludecategoryoverride != '')
  5390. $excludedcategorylist = $excludecategoryoverride;
  5391. else
  5392. $excludedcategorylist = $options['excludecategorylist'];
  5393.  
  5394. $genoptions = get_option('LinkLibraryGeneral');
  5395.  
  5396. return $this->PrivateLinkLibraryCategories($options['order'], $options['hide_if_empty'], $options['table_width'], $options['num_columns'], $options['catanchor'], $options['flatlist'],
  5397. $selectedcategorylist, $excludedcategorylist, $options['showcategorydescheaders'], $options['showonecatonly'], $settings,
  5398. $options['loadingicon'], $options['catlistdescpos'], $genoptions['debugmode'], $options['pagination'], $options['linksperpage'],
  5399. $options['showcatlinkcount'], $options['showonecatmode'], $options['cattargetaddress'], $options['rewritepage'],
  5400. $options['showinvisible'], $options['showuserlinks'], $options['showcatonsearchresults']);
  5401. }
  5402.  
  5403. /********************************************** Function to Process [link-library-search] shortcode *********************************************/
  5404.  
  5405. function link_library_search_func($atts) {
  5406. extract(shortcode_atts(array(
  5407. 'settings' => ''
  5408. ), $atts));
  5409.  
  5410. if ($settings == '')
  5411. $options = get_option('LinkLibraryPP1');
  5412. else
  5413. {
  5414. $settingsname = 'LinkLibraryPP' . $settings;
  5415. $options = get_option($settingsname);
  5416. }
  5417.  
  5418. return $this->PrivateLinkLibrarySearchForm($options['searchlabel'], $options['searchresultsaddress']);
  5419. }
  5420.  
  5421. /********************************************** Function to Process [link-library-add-link] shortcode *********************************************/
  5422.  
  5423. function link_library_insert_link( $linkdata, $wp_error = false, $addlinknoaddress = false) {
  5424. global $wpdb;
  5425.  
  5426. $defaults = array( 'link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0 );
  5427.  
  5428. $linkdata = wp_parse_args( $linkdata, $defaults );
  5429. $linkdata = sanitize_bookmark( $linkdata, 'db' );
  5430.  
  5431. extract( stripslashes_deep( $linkdata ), EXTR_SKIP );
  5432.  
  5433. $update = false;
  5434.  
  5435. if ( !empty( $link_id ) )
  5436. $update = true;
  5437.  
  5438. if ( trim( $link_name ) == '' ) {
  5439. if ( trim( $link_url ) != '' ) {
  5440. $link_name = $link_url;
  5441. } else {
  5442. return 0;
  5443. }
  5444. }
  5445.  
  5446. if ($addlinknoaddress == false)
  5447. {
  5448. if ( trim( $link_url ) == '' )
  5449. return 0;
  5450. }
  5451.  
  5452. if ( empty( $link_rating ) )
  5453. $link_rating = 0;
  5454.  
  5455. if ( empty( $link_image ) )
  5456. $link_image = '';
  5457.  
  5458. if ( empty( $link_target ) )
  5459. $link_target = '';
  5460.  
  5461. if ( empty( $link_visible ) )
  5462. $link_visible = 'Y';
  5463.  
  5464. if ( empty( $link_owner ) )
  5465. $link_owner = get_current_user_id();
  5466.  
  5467. if ( empty( $link_notes ) )
  5468. $link_notes = '';
  5469.  
  5470. if ( empty( $link_description ) )
  5471. $link_description = '';
  5472.  
  5473. if ( empty( $link_rss ) )
  5474. $link_rss = '';
  5475.  
  5476. if ( empty( $link_rel ) )
  5477. $link_rel = '';
  5478.  
  5479. // Make sure we set a valid category
  5480. if ( ! isset( $link_category ) || 0 == count( $link_category ) || !is_array( $link_category ) ) {
  5481. $link_category = array( get_option( 'default_link_category' ) );
  5482. }
  5483.  
  5484. if ( $update ) {
  5485. if ( false === $wpdb->update( $wpdb->links, compact('link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_rating', 'link_rel', 'link_notes', 'link_rss'), compact('link_id') ) ) {
  5486. if ( $wp_error )
  5487. return new WP_Error( 'db_update_error', __( 'Could not update link in the database', 'link-library' ), $wpdb->last_error );
  5488. else
  5489. return 0;
  5490. }
  5491. } else {
  5492. if ( false === $wpdb->insert( $wpdb->links, compact('link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss') ) ) {
  5493. if ( $wp_error )
  5494. return new WP_Error( 'db_insert_error', __( 'Could not insert link into the database', 'link-library' ), $wpdb->last_error );
  5495. else
  5496. return 0;
  5497. }
  5498. $link_id = (int) $wpdb->insert_id;
  5499. }
  5500.  
  5501. wp_set_link_cats( $link_id, $link_category );
  5502.  
  5503. if ( $update )
  5504. do_action( 'edit_link', $link_id );
  5505. else
  5506. do_action( 'add_link', $link_id );
  5507.  
  5508. clean_bookmark_cache( $link_id );
  5509.  
  5510. return $link_id;
  5511. }
  5512.  
  5513. function link_library_addlink_func($atts, $content, $code) {
  5514. extract(shortcode_atts(array(
  5515. 'settings' => '',
  5516. 'categorylistoverride' => '',
  5517. 'excludecategoryoverride' => ''
  5518. ), $atts));
  5519.  
  5520. if ($settings == '')
  5521. $settings = 1;
  5522.  
  5523. $settingsname = 'LinkLibraryPP' . $settings;
  5524. $options = get_option($settingsname);
  5525.  
  5526. $genoptions = get_option('LinkLibraryGeneral');
  5527.  
  5528. if ($categorylistoverride != '')
  5529. $selectedcategorylist = $categorylistoverride;
  5530. elseif ($options['addlinkcatlistoverride'] != '')
  5531. $selectedcategorylist = $options['addlinkcatlistoverride'];
  5532. else
  5533. $selectedcategorylist = $options['categorylist'];
  5534.  
  5535. if ($excludecategoryoverride != '')
  5536. $excludedcategorylist = $excludecategoryoverride;
  5537. else
  5538. $excludedcategorylist = $options['excludecategorylist'];
  5539.  
  5540. return $outputmessage . $this->PrivateLinkLibraryAddLinkForm($selectedcategorylist, $excludedcategorylist, $options['addnewlinkmsg'], $options['linknamelabel'], $options['linkaddrlabel'],
  5541. $options['linkrsslabel'], $options['linkcatlabel'], $options['linkdesclabel'], $options['linknoteslabel'],
  5542. $options['addlinkbtnlabel'], $options['hide_if_empty'], $options['showaddlinkrss'], $options['showaddlinkdesc'],
  5543. $options['showaddlinkcat'], $options['showaddlinknotes'], $options['addlinkreqlogin'], $genoptions['debugmode'],
  5544. $options['addlinkcustomcat'], $options['linkcustomcatlabel'], $options['linkcustomcatlistentry'],
  5545. $options['showaddlinkreciprocal'], $options['linkreciprocallabel'], $options['showaddlinksecondurl'], $options['linksecondurllabel'],
  5546. $options['showaddlinktelephone'], $options['linktelephonelabel'], $options['showaddlinkemail'], $options['linkemaillabel'],
  5547. $options['showcaptcha'], $captureddata, $options['linksubmitternamelabel'], $options['showlinksubmittername'],
  5548. $options['linksubmitteremaillabel'], $options['showaddlinksubmitteremail'], $options['linksubmittercommentlabel'],
  5549. $options['showlinksubmittercomment'], $genoptions['linksubmissionthankyouurl'], $options['addlinkcatlistoverride'],
  5550. $options['showcustomcaptcha'], $options['customcaptchaquestion'], $options['linklargedesclabel'], $options['showuserlargedescription'], $options['usetextareaforusersubmitnotes'], $settings, $code);
  5551.  
  5552.  
  5553. }
  5554.  
  5555. /********************************************** Function to Process [link-library] shortcode *********************************************/
  5556.  
  5557. function link_library_func($atts) {
  5558. extract(shortcode_atts(array(
  5559. 'categorylistoverride' => '',
  5560. 'excludecategoryoverride' => '',
  5561. 'notesoverride' => '',
  5562. 'descoverride' => '',
  5563. 'rssoverride' => '',
  5564. 'tableoverride' => '',
  5565. 'settings' => ''
  5566. ), $atts));
  5567.  
  5568. if ($settings == '')
  5569. {
  5570. $settings = 1;
  5571. $options = get_option('LinkLibraryPP1');
  5572. }
  5573. else
  5574. {
  5575. $settingsname = 'LinkLibraryPP' . $settings;
  5576. $options = get_option($settingsname);
  5577. }
  5578.  
  5579. if ($notesoverride != '')
  5580. $selectedshownotes = $notesoverride;
  5581. else
  5582. $selectedshownotes = $options['shownotes'];
  5583.  
  5584. if ($descoverride != '')
  5585. $selectedshowdescription = $descoverride;
  5586. else
  5587. $selectedshowdescription = $options['showdescription'];
  5588.  
  5589. if ($rssoverride != '')
  5590. $selectedshowrss = $rssoverride;
  5591. else
  5592. $selectedshowrss = $options['show_rss'];
  5593.  
  5594. if ($categorylistoverride != '')
  5595. $selectedcategorylist = $categorylistoverride;
  5596. else
  5597. $selectedcategorylist = $options['categorylist'];
  5598.  
  5599. if ($excludecategoryoverride != '')
  5600. $excludedcategorylist = $excludecategoryoverride;
  5601. else
  5602. $excludedcategorylist = $options['excludecategorylist'];
  5603.  
  5604. if ($tableoverride != '')
  5605. $overridedisplayastable = $tableoverride;
  5606. else
  5607. $overridedisplayastable = $options['displayastable'];
  5608.  
  5609. $genoptions = get_option('LinkLibraryGeneral');
  5610.  
  5611. $linklibraryoutput = "";
  5612.  
  5613. if (floatval($genoptions['schemaversion']) < "4.6")
  5614. {
  5615. $this->ll_install();
  5616. $genoptions = get_option('LinkLibraryGeneral');
  5617.  
  5618. if ($settings == '')
  5619. $options = get_option('LinkLibraryPP1');
  5620. else
  5621. {
  5622. $settingsname = 'LinkLibraryPP' . $settings;
  5623. $options = get_option($settingsname);
  5624. }
  5625. }
  5626.  
  5627. if ($genoptions['debugmode'] == true)
  5628. $linklibraryoutput .= "\n<!-- Library Settings Info:" . print_r($options, TRUE) . "-->\n";
  5629.  
  5630. $linklibraryoutput .= $this->PrivateLinkLibrary( $options['order'], $options['hide_if_empty'], $options['catanchor'], $selectedshowdescription, $selectedshownotes,
  5631. $options['showrating'], $options['showupdated'], $selectedcategorylist, $options['show_images'],
  5632. false, $options['use_html_tags'], $options['show_rss'], $options['beforenote'],
  5633. $options['nofollow'], $excludedcategorylist, $options['afternote'], $options['beforeitem'],
  5634. $options['afteritem'], $options['beforedesc'], $options['afterdesc'], $overridedisplayastable,
  5635. $options['beforelink'], $options['afterlink'], $options['showcolumnheaders'], $options['linkheader'],
  5636. $options['descheader'], $options['notesheader'], $options['catlistwrappers'], $options['beforecatlist1'],
  5637. $options['beforecatlist2'], $options['beforecatlist3'], $options['divorheader'], $options['catnameoutput'],
  5638. $options['show_rss_icon'], $options['linkaddfrequency'], $options['addbeforelink'], $options['addafterlink'],
  5639. $options['linktarget'], $options['showcategorydesclinks'], $options['showadmineditlinks'],
  5640. $options['showonecatonly'], '', $options['defaultsinglecat'], $options['rsspreview'], $options['rsspreviewcount'],
  5641. $options['rssfeedinline'], $options['rssfeedinlinecontent'], $options['rssfeedinlinecount'],
  5642. $options['beforerss'], $options['afterrss'], NULL, $options['direction'],
  5643. $options['linkdirection'], $options['linkorder'], $options['pagination'], $options['linksperpage'],
  5644. $options['hidecategorynames'], $settings, $options['showinvisible'], $options['showdate'], $options['beforedate'],
  5645. $options['afterdate'], $options['catdescpos'], $options['showuserlinks'], $options['rsspreviewwidth'], $options['rsspreviewheight'],
  5646. $options['beforeimage'], $options['afterimage'], $options['imagepos'], $options['imageclass'], '', $genoptions['debugmode'],
  5647. $options['usethumbshotsforimages'], $options['showonecatmode'], $options['dragndroporder'], $options['showname'], $options['displayweblink'],
  5648. $options['sourceweblink'], $options['showtelephone'], $options['sourcetelephone'], $options['showemail'], $options['showlinkhits'],
  5649. $options['beforeweblink'], $options['afterweblink'], $options['weblinklabel'], $options['beforetelephone'], $options['aftertelephone'],
  5650. $options['telephonelabel'], $options['beforeemail'], $options['afteremail'], $options['emaillabel'], $options['beforelinkhits'],
  5651. $options['afterlinkhits'], $options['emailcommand'], $options['sourceimage'], $options['sourcename'], $genoptions['thumbshotscid'],
  5652. $options['maxlinks'], $options['beforelinkrating'], $options['afterlinkrating'], $options['showlargedescription'],
  5653. $options['beforelargedescription'], $options['afterlargedescription'], $options['featuredfirst'], $options['shownameifnoimage'],
  5654. $options['enable_link_popup'], $options['popup_width'], $options['popup_height'], $options['nocatonstartup'] );
  5655.  
  5656. return $linklibraryoutput;
  5657. }
  5658.  
  5659.  
  5660. function conditionally_add_scripts_and_styles($posts){
  5661. if (empty($posts)) return $posts;
  5662.  
  5663. $load_jquery = false;
  5664. $load_thickbox = false;
  5665. $load_style = false;
  5666. global $testvar;
  5667.  
  5668. $genoptions = get_option('LinkLibraryGeneral');
  5669.  
  5670. if (is_admin())
  5671. {
  5672. $load_jquery = false;
  5673. $load_thickbox = false;
  5674. $load_style = false;
  5675. }
  5676. else
  5677. {
  5678. foreach ($posts as $post) {
  5679. $continuesearch = true;
  5680. $searchpos = 0;
  5681. $settingsetids = array();
  5682.  
  5683. while ($continuesearch)
  5684. {
  5685. $linklibrarypos = stripos($post->post_content, 'link-library ', $searchpos);
  5686. if ($linklibrarypos == false)
  5687. {
  5688. $linklibrarypos = stripos($post->post_content, 'link-library]', $searchpos);
  5689. if ($linklibrarypos == false)
  5690. if (stripos($post->post_content, 'link-library-cats') || stripos($post->post_content, 'link-library-addlink'))
  5691. $load_style = true;
  5692. }
  5693. $continuesearch = $linklibrarypos;
  5694. if ($continuesearch)
  5695. {
  5696. $load_style = true;
  5697. $load_jquery = true;
  5698. $shortcodeend = stripos($post->post_content, ']', $linklibrarypos);
  5699. if ($shortcodeend)
  5700. $searchpos = $shortcodeend;
  5701. else
  5702. $searchpos = $linklibrarypos + 1;
  5703.  
  5704. if ($shortcodeend)
  5705. {
  5706. $settingconfigpos = stripos($post->post_content, 'settings=', $linklibrarypos);
  5707. if ($settingconfigpos && $settingconfigpos < $shortcodeend)
  5708. {
  5709. $settingset = substr($post->post_content, $settingconfigpos + 9, $shortcodeend - $settingconfigpos - 9);
  5710.  
  5711. $settingsetids[] = $settingset;
  5712. }
  5713. else if (count($settingsetids) == 0)
  5714. {
  5715. $settingsetids[] = 1;
  5716. }
  5717. }
  5718. }
  5719. }
  5720. }
  5721.  
  5722. if ($settingsetids)
  5723. {
  5724. foreach ($settingsetids as $settingsetid)
  5725. {
  5726. $settingsname = 'LinkLibraryPP' . $settingsetid;
  5727. $options = get_option($settingsname);
  5728.  
  5729. if ( $options['showonecatonly'] ) {
  5730. $load_jquery = true;
  5731. }
  5732.  
  5733. if ( $options['rsspreview'] || $options['enable_link_popup'] ) {
  5734. $load_thickbox = true;
  5735. }
  5736.  
  5737. if ($options['publishrssfeed'] == true) {
  5738. global $rss_settings;
  5739. $rss_settings = $settingsetid;
  5740. }
  5741. }
  5742. }
  5743.  
  5744. if ($genoptions['includescriptcss'] != '')
  5745. {
  5746. $pagelist = explode (',', $genoptions['includescriptcss']);
  5747. $loadscripts = false;
  5748. foreach($pagelist as $pageid) {
  5749. if ( ( $pageid == 'front' && is_front_page() ) ||
  5750. ( $pageid == 'category' && is_category() ) ||
  5751. ( $pageid == 'all') ||
  5752. ( is_page( $pageid ) ) ) {
  5753. $load_jquery = true;
  5754. $load_thickbox = true;
  5755. $load_style = true;
  5756. }
  5757. }
  5758. }
  5759. }
  5760.  
  5761. global $llstylesheet;
  5762. if ( $load_style ) {
  5763. $llstylesheet = true;
  5764. } else {
  5765. $llstylesheet = false;
  5766. }
  5767.  
  5768. if ( $load_jquery ) {
  5769. wp_enqueue_script( 'jquery' );
  5770. }
  5771.  
  5772. if ( $load_thickbox ) {
  5773. wp_enqueue_script( 'thickbox' );
  5774. wp_enqueue_style ( 'thickbox' );
  5775. }
  5776.  
  5777. return $posts;
  5778. }
  5779. }
  5780.  
  5781. $my_link_library_plugin = new link_library_plugin();
  5782.  
  5783. ?>
Add Comment
Please, Sign In to add comment