PageRenderTime 77ms CodeModel.GetById 13ms RepoModel.GetById 5ms app.codeStats 0ms

/wp-admin/link.php

https://github.com/gplsek/competitor-mu
PHP | 116 lines | 74 code | 28 blank | 14 comment | 11 complexity | bfe9e765719cc2693ec86ddb15ce35ce MD5 | raw file
Possible License(s): LGPL-3.0
  1. <?php
  2. /**
  3. * Manage link administration actions.
  4. *
  5. * This page is accessed by the link management pages and handles the forms and
  6. * AJAX processes for link actions.
  7. *
  8. * @package WordPress
  9. * @subpackage Administration
  10. */
  11. /** Load WordPress Administration Bootstrap */
  12. require_once ('admin.php');
  13. wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'));
  14. if ( ! current_user_can('manage_links') )
  15. wp_die( __('You do not have sufficient permissions to edit the links for this blog.') );
  16. if ( !empty($_POST['deletebookmarks']) )
  17. $action = 'deletebookmarks';
  18. if ( !empty($_POST['move']) )
  19. $action = 'move';
  20. if ( !empty($_POST['linkcheck']) )
  21. $linkcheck = $_POST['linkcheck'];
  22. $this_file = 'link-manager.php';
  23. switch ($action) {
  24. case 'deletebookmarks' :
  25. check_admin_referer('bulk-bookmarks');
  26. //for each link id (in $linkcheck[]) change category to selected value
  27. if (count($linkcheck) == 0) {
  28. wp_redirect($this_file);
  29. exit;
  30. }
  31. $deleted = 0;
  32. foreach ($linkcheck as $link_id) {
  33. $link_id = (int) $link_id;
  34. if ( wp_delete_link($link_id) )
  35. $deleted++;
  36. }
  37. wp_redirect("$this_file?deleted=$deleted");
  38. exit;
  39. break;
  40. case 'move' :
  41. check_admin_referer('bulk-bookmarks');
  42. //for each link id (in $linkcheck[]) change category to selected value
  43. if (count($linkcheck) == 0) {
  44. wp_redirect($this_file);
  45. exit;
  46. }
  47. $all_links = join(',', $linkcheck);
  48. // should now have an array of links we can change
  49. //$q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)");
  50. wp_redirect($this_file);
  51. exit;
  52. break;
  53. case 'add' :
  54. check_admin_referer('add-bookmark');
  55. add_link();
  56. wp_redirect( wp_get_referer() . '?added=true' );
  57. exit;
  58. break;
  59. case 'save' :
  60. $link_id = (int) $_POST['link_id'];
  61. check_admin_referer('update-bookmark_' . $link_id);
  62. edit_link($link_id);
  63. wp_redirect($this_file);
  64. exit;
  65. break;
  66. case 'delete' :
  67. $link_id = (int) $_GET['link_id'];
  68. check_admin_referer('delete-bookmark_' . $link_id);
  69. wp_delete_link($link_id);
  70. wp_redirect($this_file);
  71. exit;
  72. break;
  73. case 'edit' :
  74. wp_enqueue_script('link');
  75. wp_enqueue_script('xfn');
  76. $parent_file = 'link-manager.php';
  77. $submenu_file = 'link-manager.php';
  78. $title = __('Edit Link');
  79. $link_id = (int) $_GET['link_id'];
  80. if (!$link = get_link_to_edit($link_id))
  81. wp_die(__('Link not found.'));
  82. include ('edit-link-form.php');
  83. include ('admin-footer.php');
  84. break;
  85. default :
  86. break;
  87. }
  88. ?>