raw
mp-wp_genesis           1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Link Management Administration Panel.
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package WordPress
mp-wp_genesis 6 * @subpackage Administration
mp-wp_genesis 7 */
mp-wp_genesis 8
mp-wp_genesis 9 /** Load WordPress Administration Bootstrap */
mp-wp_genesis 10 require_once ('admin.php');
mp-wp_genesis 11
mp-wp_genesis 12 // Handle bulk deletes
mp-wp_genesis 13 if ( isset($_GET['action']) && isset($_GET['linkcheck']) ) {
mp-wp_genesis 14 check_admin_referer('bulk-bookmarks');
mp-wp_genesis 15 $doaction = $_GET['action'] ? $_GET['action'] : $_GET['action2'];
mp-wp_genesis 16
mp-wp_genesis 17 if ( ! current_user_can('manage_links') )
mp-wp_genesis 18 wp_die( __('You do not have sufficient permissions to edit the links for this blog.') );
mp-wp_genesis 19
mp-wp_genesis 20 if ( 'delete' == $doaction ) {
mp-wp_genesis 21 foreach ( (array) $_GET['linkcheck'] as $link_id ) {
mp-wp_genesis 22 $link_id = (int) $link_id;
mp-wp_genesis 23
mp-wp_genesis 24 wp_delete_link($link_id);
mp-wp_genesis 25 }
mp-wp_genesis 26
mp-wp_genesis 27 wp_redirect( wp_get_referer() );
mp-wp_genesis 28 exit;
mp-wp_genesis 29 }
mp-wp_genesis 30 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
mp-wp_genesis 31 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
mp-wp_genesis 32 exit;
mp-wp_genesis 33 }
mp-wp_genesis 34
mp-wp_genesis 35 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[]'));
mp-wp_genesis 36
mp-wp_genesis 37 if ( empty($cat_id) )
mp-wp_genesis 38 $cat_id = 'all';
mp-wp_genesis 39
mp-wp_genesis 40 if ( empty($order_by) )
mp-wp_genesis 41 $order_by = 'order_name';
mp-wp_genesis 42
mp-wp_genesis 43 $title = __('Edit Links');
mp-wp_genesis 44 $this_file = $parent_file = 'link-manager.php';
mp-wp_genesis 45 include_once ("./admin-header.php");
mp-wp_genesis 46
mp-wp_genesis 47 if (!current_user_can('manage_links'))
mp-wp_genesis 48 wp_die(__("You do not have sufficient permissions to edit the links for this blog."));
mp-wp_genesis 49
mp-wp_genesis 50 switch ($order_by) {
mp-wp_genesis 51 case 'order_id' :
mp-wp_genesis 52 $sqlorderby = 'id';
mp-wp_genesis 53 break;
mp-wp_genesis 54 case 'order_url' :
mp-wp_genesis 55 $sqlorderby = 'url';
mp-wp_genesis 56 break;
mp-wp_genesis 57 case 'order_desc' :
mp-wp_genesis 58 $sqlorderby = 'description';
mp-wp_genesis 59 break;
mp-wp_genesis 60 case 'order_owner' :
mp-wp_genesis 61 $sqlorderby = 'owner';
mp-wp_genesis 62 break;
mp-wp_genesis 63 case 'order_rating' :
mp-wp_genesis 64 $sqlorderby = 'rating';
mp-wp_genesis 65 break;
mp-wp_genesis 66 case 'order_name' :
mp-wp_genesis 67 default :
mp-wp_genesis 68 $sqlorderby = 'name';
mp-wp_genesis 69 break;
mp-wp_genesis 70 } ?>
mp-wp_genesis 71
mp-wp_genesis 72 <div class="wrap nosubsub">
mp-wp_genesis 73 <?php screen_icon(); ?>
mp-wp_genesis 74 <h2><?php echo wp_specialchars( $title );
mp-wp_genesis 75 if ( isset($_GET['s']) && $_GET['s'] )
mp-wp_genesis 76 printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', wp_specialchars( stripslashes($_GET['s']) ) ); ?>
mp-wp_genesis 77 </h2>
mp-wp_genesis 78
mp-wp_genesis 79 <?php
mp-wp_genesis 80 if ( isset($_GET['deleted']) ) {
mp-wp_genesis 81 echo '<div id="message" class="updated fade"><p>';
mp-wp_genesis 82 $deleted = (int) $_GET['deleted'];
mp-wp_genesis 83 printf(__ngettext('%s link deleted.', '%s links deleted', $deleted), $deleted);
mp-wp_genesis 84 echo '</p></div>';
mp-wp_genesis 85 $_SERVER['REQUEST_URI'] = remove_query_arg(array('deleted'), $_SERVER['REQUEST_URI']);
mp-wp_genesis 86 }
mp-wp_genesis 87 ?>
mp-wp_genesis 88
mp-wp_genesis 89 <form class="search-form" action="" method="get">
mp-wp_genesis 90 <p class="search-box">
mp-wp_genesis 91 <label class="hidden" for="link-search-input"><?php _e( 'Search Links' ); ?>:</label>
mp-wp_genesis 92 <input type="text" class="search-input" id="link-search-input" name="s" value="<?php _admin_search_query(); ?>" />
mp-wp_genesis 93 <input type="submit" value="<?php _e( 'Search Links' ); ?>" class="button" />
mp-wp_genesis 94 </p>
mp-wp_genesis 95 </form>
mp-wp_genesis 96 <br class="clear" />
mp-wp_genesis 97
mp-wp_genesis 98 <form id="posts-filter" action="" method="get">
mp-wp_genesis 99 <div class="tablenav">
mp-wp_genesis 100
mp-wp_genesis 101 <div class="alignleft actions">
mp-wp_genesis 102 <select name="action">
mp-wp_genesis 103 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
mp-wp_genesis 104 <option value="delete"><?php _e('Delete'); ?></option>
mp-wp_genesis 105 </select>
mp-wp_genesis 106 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
mp-wp_genesis 107
mp-wp_genesis 108 <?php
mp-wp_genesis 109 $categories = get_terms('link_category', "hide_empty=1");
mp-wp_genesis 110 $select_cat = "<select name=\"cat_id\">\n";
mp-wp_genesis 111 $select_cat .= '<option value="all"' . (($cat_id == 'all') ? " selected='selected'" : '') . '>' . __('View all Categories') . "</option>\n";
mp-wp_genesis 112 foreach ((array) $categories as $cat)
mp-wp_genesis 113 $select_cat .= '<option value="' . $cat->term_id . '"' . (($cat->term_id == $cat_id) ? " selected='selected'" : '') . '>' . sanitize_term_field('name', $cat->name, $cat->term_id, 'link_category', 'display') . "</option>\n";
mp-wp_genesis 114 $select_cat .= "</select>\n";
mp-wp_genesis 115
mp-wp_genesis 116 $select_order = "<select name=\"order_by\">\n";
mp-wp_genesis 117 $select_order .= '<option value="order_id"' . (($order_by == 'order_id') ? " selected='selected'" : '') . '>' . __('Order by Link ID') . "</option>\n";
mp-wp_genesis 118 $select_order .= '<option value="order_name"' . (($order_by == 'order_name') ? " selected='selected'" : '') . '>' . __('Order by Name') . "</option>\n";
mp-wp_genesis 119 $select_order .= '<option value="order_url"' . (($order_by == 'order_url') ? " selected='selected'" : '') . '>' . __('Order by Address') . "</option>\n";
mp-wp_genesis 120 $select_order .= '<option value="order_rating"' . (($order_by == 'order_rating') ? " selected='selected'" : '') . '>' . __('Order by Rating') . "</option>\n";
mp-wp_genesis 121 $select_order .= "</select>\n";
mp-wp_genesis 122
mp-wp_genesis 123 echo $select_cat;
mp-wp_genesis 124 echo $select_order;
mp-wp_genesis 125
mp-wp_genesis 126 ?>
mp-wp_genesis 127 <input type="submit" id="post-query-submit" value="<?php _e('Filter'); ?>" class="button-secondary" />
mp-wp_genesis 128
mp-wp_genesis 129 </div>
mp-wp_genesis 130
mp-wp_genesis 131 <br class="clear" />
mp-wp_genesis 132 </div>
mp-wp_genesis 133
mp-wp_genesis 134 <div class="clear"></div>
mp-wp_genesis 135
mp-wp_genesis 136 <?php
mp-wp_genesis 137 if ( 'all' == $cat_id )
mp-wp_genesis 138 $cat_id = '';
mp-wp_genesis 139 $args = array('category' => $cat_id, 'hide_invisible' => 0, 'orderby' => $sqlorderby, 'hide_empty' => 0);
mp-wp_genesis 140 if ( !empty($_GET['s']) )
mp-wp_genesis 141 $args['search'] = $_GET['s'];
mp-wp_genesis 142 $links = get_bookmarks( $args );
mp-wp_genesis 143 if ( $links ) {
mp-wp_genesis 144 $link_columns = get_column_headers('link-manager');
mp-wp_genesis 145 $hidden = get_hidden_columns('link-manager');
mp-wp_genesis 146 ?>
mp-wp_genesis 147
mp-wp_genesis 148 <?php wp_nonce_field('bulk-bookmarks') ?>
mp-wp_genesis 149 <table class="widefat fixed" cellspacing="0">
mp-wp_genesis 150 <thead>
mp-wp_genesis 151 <tr>
mp-wp_genesis 152 <?php print_column_headers('link-manager'); ?>
mp-wp_genesis 153 </tr>
mp-wp_genesis 154 </thead>
mp-wp_genesis 155
mp-wp_genesis 156 <tfoot>
mp-wp_genesis 157 <tr>
mp-wp_genesis 158 <?php print_column_headers('link-manager', false); ?>
mp-wp_genesis 159 </tr>
mp-wp_genesis 160 </tfoot>
mp-wp_genesis 161
mp-wp_genesis 162 <tbody>
mp-wp_genesis 163 <?php
mp-wp_genesis 164 $alt = 0;
mp-wp_genesis 165
mp-wp_genesis 166 foreach ($links as $link) {
mp-wp_genesis 167 $link = sanitize_bookmark($link);
mp-wp_genesis 168 $link->link_name = attribute_escape($link->link_name);
mp-wp_genesis 169 $link->link_category = wp_get_link_cats($link->link_id);
mp-wp_genesis 170 $short_url = str_replace('http://', '', $link->link_url);
mp-wp_genesis 171 $short_url = str_replace('www.', '', $short_url);
mp-wp_genesis 172 if ('/' == substr($short_url, -1))
mp-wp_genesis 173 $short_url = substr($short_url, 0, -1);
mp-wp_genesis 174 if (strlen($short_url) > 35)
mp-wp_genesis 175 $short_url = substr($short_url, 0, 32).'...';
mp-wp_genesis 176 $visible = ($link->link_visible == 'Y') ? __('Yes') : __('No');
mp-wp_genesis 177 $style = ($alt % 2) ? '' : ' class="alternate"';
mp-wp_genesis 178 ++ $alt;
mp-wp_genesis 179 $edit_link = get_edit_bookmark_link();
mp-wp_genesis 180 ?><tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>><?php
mp-wp_genesis 181 foreach($link_columns as $column_name=>$column_display_name) {
mp-wp_genesis 182 $class = "class=\"column-$column_name\"";
mp-wp_genesis 183
mp-wp_genesis 184 $style = '';
mp-wp_genesis 185 if ( in_array($column_name, $hidden) )
mp-wp_genesis 186 $style = ' style="display:none;"';
mp-wp_genesis 187 if ( 'visible' == $column_name )
mp-wp_genesis 188 $style = empty($style) ? ' style="text-align: center;"' : ' style="text-align: center; display: none;"';
mp-wp_genesis 189 $attributes = "$class$style";
mp-wp_genesis 190
mp-wp_genesis 191 switch($column_name) {
mp-wp_genesis 192 case 'cb':
mp-wp_genesis 193 echo '<th scope="row" class="check-column"><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></th>';
mp-wp_genesis 194 break;
mp-wp_genesis 195 case 'name':
mp-wp_genesis 196
mp-wp_genesis 197 echo "<td $attributes><strong><a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $link->link_name)) . "'>$link->link_name</a></strong><br />";
mp-wp_genesis 198 $actions = array();
mp-wp_genesis 199 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
mp-wp_genesis 200 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf( __("You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete."), $link->link_name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
mp-wp_genesis 201 $action_count = count($actions);
mp-wp_genesis 202 $i = 0;
mp-wp_genesis 203 echo '<div class="row-actions">';
mp-wp_genesis 204 foreach ( $actions as $action => $linkaction ) {
mp-wp_genesis 205 ++$i;
mp-wp_genesis 206 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
mp-wp_genesis 207 echo "<span class='$action'>$linkaction$sep</span>";
mp-wp_genesis 208 }
mp-wp_genesis 209 echo '</div>';
mp-wp_genesis 210 echo '</td>';
mp-wp_genesis 211 break;
mp-wp_genesis 212 case 'url':
mp-wp_genesis 213 echo "<td $attributes><a href='$link->link_url' title='".sprintf(__('Visit %s'), $link->link_name)."'>$short_url</a></td>";
mp-wp_genesis 214 break;
mp-wp_genesis 215 case 'categories':
mp-wp_genesis 216 ?><td <?php echo $attributes ?>><?php
mp-wp_genesis 217 $cat_names = array();
mp-wp_genesis 218 foreach ($link->link_category as $category) {
mp-wp_genesis 219 $cat = get_term($category, 'link_category', OBJECT, 'display');
mp-wp_genesis 220 if ( is_wp_error( $cat ) )
mp-wp_genesis 221 echo $cat->get_error_message();
mp-wp_genesis 222 $cat_name = $cat->name;
mp-wp_genesis 223 if ( $cat_id != $category )
mp-wp_genesis 224 $cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>";
mp-wp_genesis 225 $cat_names[] = $cat_name;
mp-wp_genesis 226 }
mp-wp_genesis 227 echo implode(', ', $cat_names);
mp-wp_genesis 228 ?></td><?php
mp-wp_genesis 229 break;
mp-wp_genesis 230 case 'rel':
mp-wp_genesis 231 ?><td <?php echo $attributes ?>><?php echo $link->link_rel; ?></td><?php
mp-wp_genesis 232 break;
mp-wp_genesis 233 case 'visible':
mp-wp_genesis 234 ?><td <?php echo $attributes ?>><?php echo $visible; ?></td><?php
mp-wp_genesis 235 break;
mp-wp_genesis 236 default:
mp-wp_genesis 237 ?>
mp-wp_genesis 238 <td><?php do_action('manage_link_custom_column', $column_name, $link->link_id); ?></td>
mp-wp_genesis 239 <?php
mp-wp_genesis 240 break;
mp-wp_genesis 241
mp-wp_genesis 242 }
mp-wp_genesis 243 }
mp-wp_genesis 244 echo "\n </tr>\n";
mp-wp_genesis 245 }
mp-wp_genesis 246 ?>
mp-wp_genesis 247 </tbody>
mp-wp_genesis 248 </table>
mp-wp_genesis 249
mp-wp_genesis 250 <?php } else { ?>
mp-wp_genesis 251 <p><?php _e('No links found.') ?></p>
mp-wp_genesis 252 <?php } ?>
mp-wp_genesis 253
mp-wp_genesis 254 <div class="tablenav">
mp-wp_genesis 255
mp-wp_genesis 256 <div class="alignleft actions">
mp-wp_genesis 257 <select name="action2">
mp-wp_genesis 258 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
mp-wp_genesis 259 <option value="delete"><?php _e('Delete'); ?></option>
mp-wp_genesis 260 </select>
mp-wp_genesis 261 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
mp-wp_genesis 262 </div>
mp-wp_genesis 263
mp-wp_genesis 264 <br class="clear" />
mp-wp_genesis 265 </div>
mp-wp_genesis 266
mp-wp_genesis 267 </form>
mp-wp_genesis 268
mp-wp_genesis 269 <div id="ajax-response"></div>
mp-wp_genesis 270
mp-wp_genesis 271 </div>
mp-wp_genesis 272
mp-wp_genesis 273 <script type="text/javascript">
mp-wp_genesis 274 /* <![CDATA[ */
mp-wp_genesis 275 (function($){
mp-wp_genesis 276 $(document).ready(function(){
mp-wp_genesis 277 $('#doaction, #doaction2').click(function(){
mp-wp_genesis 278 if ( $('select[name^="action"]').val() == 'delete' ) {
mp-wp_genesis 279 var m = '<?php echo js_escape(__("You are about to delete the selected links.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
mp-wp_genesis 280 return showNotice.warn(m);
mp-wp_genesis 281 }
mp-wp_genesis 282 });
mp-wp_genesis 283 });
mp-wp_genesis 284 })(jQuery);
mp-wp_genesis 285 columns.init('link-manager');
mp-wp_genesis 286 /* ]]> */
mp-wp_genesis 287 </script>
mp-wp_genesis 288
mp-wp_genesis 289 <?php include('admin-footer.php'); ?>