| [ Index ] |
PHP Cross Reference of zeList |
[Summary view] [Print] [Text view]
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 12 /** Load WordPress Administration Bootstrap */ 13 require_once ('admin.php'); 14 15 ///if($_POST) { echo '<pre>'.print_r($_POST,1).'</pre>'; die();} 16 17 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[]')); 18 19 if ( ! current_user_can('manage_links') ) 20 wp_die( __('You do not have sufficient permissions to edit the links for this blog.') ); 21 22 if ( !empty($_POST['deletebookmarks']) ) $action = 'deletebookmarks'; 23 if ( !empty($_POST['move']) )$action = 'move'; 24 if ( !empty($_POST['linkcheck']) ) $linkcheck = $_POST['linkcheck']; 25 26 // zelist : change #content to #link_description 27 if(!empty($_POST['content'])) { 28 $_POST['link_description'] = $_POST['content']; 29 unset($_POST['content']); 30 } 31 32 if($action == 'edit') { 33 do_action('do_meta_boxes', 'link', 'normal', $link); 34 do_action('do_meta_boxes', 'link', 'advanced', $link); 35 do_action('do_meta_boxes', 'link', 'side', $link); 36 do_action('zelist_link_meta_boxes'); 37 } 38 39 $this_file = ZELIST_ADMIN_URL_MANAGER; 40 41 switch ($action) { 42 43 case 'create_link' : 44 check_admin_referer('create_link'); 45 46 if(!$_POST['link_url'] || !$_POST['link_name'] || !$_POST['link_category']) { 47 $error_id = 3; 48 } 49 else { 50 51 $_POST['link_url'] = clean_url(wp_specialchars( $_POST['link_url'])); 52 $_POST['link_name'] = wp_specialchars( $_POST['link_name'] ); 53 $_POST['link_category'] = array($_POST['link_category']); 54 55 $error_id = $link_id = false; 56 $error_message = ''; 57 58 global $wpdb; 59 $link_id = $wpdb->get_var($wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_url LIKE %s",$_POST['link_url'])); 60 if($link_id) { 61 $error_id = 1; 62 } 63 else { 64 $error = add_link(); 65 if ( is_wp_error($error) ) { 66 $error_id = 2; 67 $error_message = $error->get_error_message(); 68 } 69 70 if(!$error_id) { 71 $link_id = $error; 72 // set pending as a default status 73 link_status($link_id,'pending'); 74 $location = get_edit_bookmark_link($link_id); 75 wp_redirect($location); 76 exit; 77 } 78 } 79 } 80 $args = array('error_id' => $error_id); 81 if($error_message) $args['error_message'] = urlencode($error_message); 82 if($link_id) $args['link_id'] = $link_id; 83 if($_POST['link_url']) $args['link_url'] = $_POST['link_url']; 84 if($_POST['link_name']) $args['link_name'] = $_POST['link_name']; 85 if($_POST['link_category'][0]) $args['link_category'] = $_POST['link_category'][0]; 86 $location = add_query_arg($args,get_submit_link()); 87 wp_redirect($location); 88 exit; 89 90 break; 91 case 'deletebookmarks' : 92 check_admin_referer('bulk-bookmarks'); 93 94 //for each link id (in $linkcheck[]) change category to selected value 95 if (count($linkcheck) == 0) { 96 wp_redirect($this_file); 97 exit; 98 } 99 100 $deleted = 0; 101 foreach ($linkcheck as $link_id) { 102 $link_id = (int) $link_id; 103 104 if ( wp_delete_link($link_id) ) 105 $deleted++; 106 } 107 108 wp_redirect("$this_file&deleted=$deleted"); 109 exit; 110 break; 111 112 case 'move' : 113 check_admin_referer('bulk-bookmarks'); 114 115 //for each link id (in $linkcheck[]) change category to selected value 116 if (count($linkcheck) == 0) { 117 wp_redirect($this_file); 118 exit; 119 } 120 $all_links = join(',', $linkcheck); 121 // should now have an array of links we can change 122 //$q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)"); 123 124 wp_redirect(wp_get_referer()); 125 exit; 126 break; 127 128 case 'add' : 129 check_admin_referer('add-bookmark'); 130 $link_id = add_link(); 131 if($link_id) $location = ZELIST_ADMIN_URL_LINK."&action=edit&link_id=$link_id&added=1"; 132 else $location = wp_get_referer(); 133 wp_redirect($location); 134 exit; 135 break; 136 137 case 'deny' : 138 check_admin_referer('deny-bookmark_' . $link_id); 139 link_status($link_id,'deny'); 140 wp_redirect( add_query_arg('denied',$link_id,wp_get_referer())); 141 exit; 142 break; 143 144 case 'publish' : 145 check_admin_referer('publish-bookmark_' . $link_id); 146 link_status($link_id,'publish'); 147 $location = ZELIST_ADMIN_URL_MANAGER."&published=$link_id"; 148 wp_redirect( $location ) ; 149 exit; 150 break; 151 152 case 'save' : 153 $link_id = (int) $_POST['link_id']; 154 check_admin_referer('update-bookmark_' . $link_id); 155 edit_link($link_id); 156 wp_redirect(ZELIST_ADMIN_URL_LINK."&action=edit&link_id=$link_id&saved=$link_id"); 157 exit; 158 break; 159 160 case 'delete' : 161 $link_id = (int) $_GET['link_id']; 162 check_admin_referer('delete-bookmark_' . $link_id); 163 164 wp_delete_link($link_id); 165 166 wp_redirect(add_query_arg('deleted','1',ZELIST_ADMIN_URL_MANAGER)); 167 exit; 168 break; 169 170 case 'edit' : 171 wp_enqueue_script('link'); 172 wp_enqueue_script('xfn'); 173 174 $parent_file = ZELIST_ADMIN_URL_MANAGER; 175 $submenu_file = ZELIST_ADMIN_URL_MANAGER; 176 $title = __('Edit Link'); 177 178 $link_id = (int) $_GET['link_id']; 179 180 if (!$link = get_link_to_edit($link_id)) 181 wp_die(__('Link not found.')); 182 $link->link_category = array_unique( wp_get_object_terms($link->link_id, 'link_category', 'fields=ids') ); 183 184 include (ZELIST_ADMIN_PATH_EDIT_LINK_FORM); 185 break; 186 187 default : 188 break; 189 } 190 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat May 30 23:51:06 2009 | Cross-referenced by PHPXref 0.7 |