X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/ff81ee6e8304a1982a3ec4f5b134764a29d502cf..542cf06a610bc430421351ace7a2cc45f393b990:/wp-admin/link-manager.php
diff --git a/wp-admin/link-manager.php b/wp-admin/link-manager.php
index 5626570f..2243d6b0 100644
--- a/wp-admin/link-manager.php
+++ b/wp-admin/link-manager.php
@@ -1,445 +1,292 @@
' . sprintf(__('You can add links here to be displayed on your site, usually using Widgets . By default, links to several sites in the WordPress community are included as examples.'), 'widgets.php') . '
' .
+ '' . __('Links may be separated into categories; these are different than the categories used on your posts.') . '
' .
+ '' . __('You can customize the display of this screen using the Screen Options tab and/or the dropdown filters above the links table.') . '
' .
+ '' . __('If you delete a link, it will be removed permanently, as Links do not have a Trash function yet.') . '
' .
+ '' . __('For more information:') . '
' .
+ '' . __('Link Management Documentation ') . '
' .
+ '' . __('Support Forums ') . '
'
+);
+
+include_once ('./admin-header.php');
+
+if ( ! current_user_can('manage_links') )
+ wp_die(__("You do not have sufficient permissions to edit the links for this site."));
+
+switch ($order_by) {
+ case 'order_id' :
+ $sqlorderby = 'id';
+ break;
+ case 'order_url' :
+ $sqlorderby = 'url';
+ break;
+ case 'order_desc' :
+ $sqlorderby = 'description';
+ break;
+ case 'order_owner' :
+ $sqlorderby = 'owner';
+ break;
+ case 'order_rating' :
+ $sqlorderby = 'rating';
+ break;
+ case 'order_name' :
+ default :
+ $sqlorderby = 'name';
+ break;
+} ?>
+
+
+
+
' . __('Search results for “%s”') . '', esc_html( stripslashes($_GET['s']) ) ); ?>
+
+
+
';
+ $deleted = (int) $_GET['deleted'];
+ printf(_n('%s link deleted.', '%s links deleted', $deleted), $deleted);
+ echo '
';
+ $_SERVER['REQUEST_URI'] = remove_query_arg(array('deleted'), $_SERVER['REQUEST_URI']);
}
+?>
-$links_show_cat_id = $_COOKIE['links_show_cat_id_' . COOKIEHASH];
-$links_show_order = $_COOKIE['links_show_order_' . COOKIEHASH];
-
-if ('' != $_POST['assign']) $action = 'assign';
-if ('' != $_POST['visibility']) $action = 'visibility';
-if ('' != $_POST['move']) $action = 'move';
-if ('' != $_POST['linkcheck']) $linkcheck = $_POST[linkcheck];
-
-switch ($action) {
- case 'assign':
- {
- check_admin_referer();
-
- // check the current user's level first.
- if ( !current_user_can('manage_links') )
- die (__("Cheatin' uh ?"));
-
- //for each link id (in $linkcheck[]): if the current user level >= the
- //userlevel of the owner of the link then we can proceed.
-
- if (count($linkcheck) == 0) {
- header('Location: ' . $this_file);
- exit;
- }
- $all_links = join(',', $linkcheck);
- $results = $wpdb->get_results("SELECT link_id, link_owner FROM $wpdb->links LEFT JOIN $wpdb->users ON link_owner = ID WHERE link_id in ($all_links)");
- foreach ($results as $row) {
- $ids_to_change[] = $row->link_id;
- }
-
- // should now have an array of links we can change
- $all_links = join(',', $ids_to_change);
- $q = $wpdb->query("update $wpdb->links SET link_owner='$newowner' WHERE link_id IN ($all_links)");
-
- header('Location: ' . $this_file);
- break;
- }
- case 'visibility':
- {
- check_admin_referer();
-
- // check the current user's level first.
- if ( !current_user_can('manage_links') )
- die (__("Cheatin' uh ?"));
-
- //for each link id (in $linkcheck[]): toggle the visibility
- if (count($linkcheck) == 0) {
- header('Location: ' . $this_file);
- exit;
- }
- $all_links = join(',', $linkcheck);
- $results = $wpdb->get_results("SELECT link_id, link_visible FROM $wpdb->links WHERE link_id in ($all_links)");
- foreach ($results as $row) {
- if ($row->link_visible == 'Y') { // ok to proceed
- $ids_to_turnoff[] = $row->link_id;
- } else {
- $ids_to_turnon[] = $row->link_id;
- }
- }
-
- // should now have two arrays of links to change
- if (count($ids_to_turnoff)) {
- $all_linksoff = join(',', $ids_to_turnoff);
- $q = $wpdb->query("update $wpdb->links SET link_visible='N' WHERE link_id IN ($all_linksoff)");
- }
-
- if (count($ids_to_turnon)) {
- $all_linkson = join(',', $ids_to_turnon);
- $q = $wpdb->query("update $wpdb->links SET link_visible='Y' WHERE link_id IN ($all_linkson)");
- }
-
- header('Location: ' . $this_file);
- break;
- }
- case 'move':
- {
- check_admin_referer();
-
- // check the current user's level first.
- if ( !current_user_can('manage_links') )
- die (__("Cheatin' uh ?"));
-
- //for each link id (in $linkcheck[]) change category to selected value
- if (count($linkcheck) == 0) {
- header('Location: ' . $this_file);
- exit;
- }
- $all_links = join(',', $linkcheck);
- // should now have an array of links we can change
- $q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)");
-
- header('Location: ' . $this_file);
- break;
- }
-
- case 'Add':
- {
- check_admin_referer();
-
- add_link();
-
- header('Location: ' . $_SERVER['HTTP_REFERER'] . '?added=true');
- break;
- } // end Add
-
- case 'editlink':
- {
-
- check_admin_referer();
-
- if (isset($links_show_cat_id) && ($links_show_cat_id != ''))
- $cat_id = $links_show_cat_id;
-
- if (!isset($cat_id) || ($cat_id == '')) {
- if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))
- $cat_id = 'All';
- }
- $links_show_cat_id = $cat_id;
-
- $link_id = (int) $_POST['link_id'];
- edit_link($link_id);
-
- setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600);
- wp_redirect($this_file);
- break;
- } // end Save
-
- case 'Delete':
- {
- check_admin_referer();
-
- if ( !current_user_can('manage_links') )
- die (__("Cheatin' uh ?"));
-
- $link_id = (int) $_GET['link_id'];
-
- wp_delete_link($link_id);
-
- if (isset($links_show_cat_id) && ($links_show_cat_id != ''))
- $cat_id = $links_show_cat_id;
-
- if (!isset($cat_id) || ($cat_id == '')) {
- if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))
- $cat_id = 'All';
- }
- $links_show_cat_id = $cat_id;
- setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600);
- wp_redirect($this_file);
- break;
- } // end Delete
-
- case 'linkedit': {
- $xfn_js = true;
- include_once ('admin-header.php');
- if ( !current_user_can('manage_links') )
- die(__('You do not have sufficient permissions to edit the links for this blog.'));
-
- $link_id = (int) $_GET['link_id'];
-
- if ( !$link = get_link_to_edit($link_id) )
- die( __('Link not found.') );
-
- include('edit-link-form.php');
- break;
- } // end linkedit
- case __("Show"):
- {
- if (!isset($cat_id) || ($cat_id == '')) {
- if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))
- $cat_id = 'All';
- }
- $links_show_cat_id = $cat_id;
- if (!isset($order_by) || ($order_by == '')) {
- if (!isset($links_show_order) || ($links_show_order == ''))
- $order_by = 'order_name';
- }
- $links_show_order = $order_by;
- //break; fall through
- } // end Show
- case "popup":
- {
- $link_url = stripslashes($_GET["linkurl"]);
- $link_name = stripslashes($_GET["name"]);
- //break; fall through
- }
- default:
- {
- if (isset($links_show_cat_id) && ($links_show_cat_id != ''))
- $cat_id = $links_show_cat_id;
-
- if (!isset($cat_id) || ($cat_id == '')) {
- if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))
- $cat_id = 'All';
- }
- $links_show_cat_id = $cat_id;
- if (isset($links_show_order) && ($links_show_order != ''))
- $order_by = $links_show_order;
-
- if (!isset($order_by) || ($order_by == ''))
- $order_by = 'order_name';
- $links_show_order = $order_by;
-
- setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600);
- setcookie('links_show_order_' . COOKIEHASH, $links_show_order, time()+600);
- include_once ("./admin-header.php");
- if ( !current_user_can('manage_links') )
- die(__("You do not have sufficient permissions to edit the links for this blog."));
-
- switch ($order_by)
- {
- case 'order_id': $sqlorderby = 'id'; break;
- case 'order_url': $sqlorderby = 'url'; break;
- case 'order_desc': $sqlorderby = 'description'; break;
- case 'order_owner': $sqlorderby = 'owner'; break;
- case 'order_rating': $sqlorderby = 'rating'; break;
- case 'order_name':
- default: $sqlorderby = 'name'; break;
- }
-
- if ($action != "popup") {
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
users.user_login, link_id,
- link_rating, link_rel
- FROM $wpdb->links
- LEFT JOIN $wpdb->linkcategories ON $wpdb->links.link_category = $wpdb->linkcategories.cat_id
- LEFT JOIN $wpdb->users ON $wpdb->users.ID = $wpdb->links.link_owner ";
-
- if (isset($cat_id) && ($cat_id != 'All')) {
- $sql .= " WHERE link_category = $cat_id ";
- }
- $sql .= ' ORDER BY link_' . $sqlorderby;
-
- // echo "$sql";
- $links = $wpdb->get_results($sql);
- if ($links) {
- foreach ($links as $link) {
- $link->link_name = wp_specialchars($link->link_name);
- $link->link_category = wp_specialchars($link->link_category);
- $link->link_description = wp_specialchars($link->link_description);
- $link->link_url = wp_specialchars($link->link_url);
- $short_url = str_replace('http://', '', $link->link_url);
- $short_url = str_replace('www.', '', $short_url);
- if ('/' == substr($short_url, -1))
- $short_url = substr($short_url, 0, -1);
- if (strlen($short_url) > 35)
- $short_url = substr($short_url, 0, 32).'...';
-
- $image = ($link->link_image != null) ? __('Yes') : __('No');
- $visible = ($link->link_visible == 'Y') ? __('Yes') : __('No');
- ++$i;
- $style = ($i % 2) ? '' : ' class="alternate"';
+ $link_columns = get_column_headers('link-manager');
+ $hidden = get_hidden_columns('link-manager');
?>
- >
- link_name; ?>
-link_description) . " ";
- echo "link_url\" title=\"" . sprintf(__('Visit %s'), $link->link_name) . "\">$short_url ";
- echo <<$link->category
- $link->link_rel
- $image
- $visible
-LINKS;
- $show_buttons = 1; // default
-
- if ($show_buttons) {
- echo '' . __('Edit') . ' ';
- echo 'link_id , '" . sprintf(__("You are about to delete the "%s" link to %s.\\n"Cancel" to stop, "OK" to delete."), wp_specialchars($link->link_name,1), wp_specialchars($link->link_url)) . '\' );" class="delete">' . __('Delete') . ' ';
- echo ' ';
- } else {
- echo " \n";
- }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+link_name = esc_attr($link->link_name);
+ $link->link_category = wp_get_link_cats($link->link_id);
+ $short_url = str_replace('http://', '', $link->link_url);
+ $short_url = preg_replace('/^www\./i', '', $short_url);
+ if ('/' == substr($short_url, -1))
+ $short_url = substr($short_url, 0, -1);
+ if (strlen($short_url) > 35)
+ $short_url = substr($short_url, 0, 32).'...';
+ $visible = ($link->link_visible == 'Y') ? __('Yes') : __('No');
+ $rating = $link->link_rating;
+ $style = ($alt % 2) ? '' : ' class="alternate"';
+ ++ $alt;
+ $edit_link = get_edit_bookmark_link();
+ ?>>$column_display_name) {
+ $class = "class=\"column-$column_name\"";
+
+ $style = '';
+ if ( in_array($column_name, $hidden) )
+ $style = ' style="display:none;"';
+
+ $attributes = "$class$style";
+
+ switch($column_name) {
+ case 'cb':
+ echo ' ';
+ break;
+ case 'name':
+
+ echo "link_name)) . "'>$link->link_name ";
+ $actions = array();
+ $actions['edit'] = '' . __('Edit') . ' ';
+ $actions['delete'] = "link_id) . "' onclick=\"if ( confirm('" . esc_js(sprintf( __("You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete."), $link->link_name )) . "') ) { return true;}return false;\">" . __('Delete') . " ";
+ $action_count = count($actions);
+ $i = 0;
+ echo '';
+ foreach ( $actions as $action => $linkaction ) {
+ ++$i;
+ ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
+ echo "$linkaction$sep ";
+ }
+ echo '
';
+ echo ' ';
+ break;
+ case 'url':
+ echo "link_name)."'>$short_url ";
+ break;
+ case 'categories':
+ ?>>link_category as $category) {
+ $cat = get_term($category, 'link_category', OBJECT, 'display');
+ if ( is_wp_error( $cat ) )
+ echo $cat->get_error_message();
+ $cat_name = $cat->name;
+ if ( $cat_id != $category )
+ $cat_name = "$cat_name ";
+ $cat_names[] = $cat_name;
+ }
+ echo implode(', ', $cat_names);
+ ?> >link_rel) ? ' ' : $link->link_rel; ?> > >
+ >link_id); ?>
+ \n";
- }
- }
+ }
?>
+
-
+
-
+