Changeset 204702
- Timestamp:
- 02/12/2010 09:20:33 PM (16 years ago)
- File:
-
- 1 edited
-
magazine-edition-control/trunk/beheer.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
magazine-edition-control/trunk/beheer.php
r204597 r204702 30 30 31 31 add_action('admin_menu', 'magazinedition_admin_actions'); 32 33 add_action('admin_menu', 'magazinedition_custom'); 34 35 add_action('save_post', 'magazinedition_save_postdata'); 32 36 33 37 … … 52 56 } 53 57 58 function magazinedition_custom () { 59 if ( current_user_can('manage_options') ) { 60 add_meta_box("magazinedition_meta", __('Magazine Edtion Control', 'magazinedition'), "magazinedition_meta", "post", 'side', 'core'); 61 } 62 } 54 63 55 64 function magazinedition_menu() … … 157 166 return $return; 158 167 } 168 169 function magazinedition_meta ( ) { 170 global $wpdb; 171 global $post; 172 173 $structure = "SELECT * FROM " . $wpdb->prefix . "magazinedition_uitgaven ORDER BY cat_date"; 174 $results = $wpdb->get_results($structure); 175 176 $count = 0; 177 foreach ($results as $result) { 178 $count++; 179 } 180 if ($count == 0) { 181 182 echo "<a href=\"" . get_bloginfo('siteurl') . "/wp-admin/admin.php?page=magazinedition\">Please create and name an edition first.</a><br />"; 183 return 0; 184 } 185 186 $current_guid = get_post_meta( $_GET['post'], 'magazineditionuitgave', true); 187 188 echo "<label for=\"magazinedition_save_guid\">Select an edition:</label><br />"; 189 echo "<select name=\"magazinedition_save_guid\" style=\"width: 90%\">\n"; 190 echo "<option value=\"\">This post isn't part of an edition.</option><br />\n"; 191 192 foreach ($results as $result) { 193 $title = ""; 194 195 if ($result->cat_name == "") { 196 $title = "Edition of " . $result->cat_date; 197 } else { 198 $title = $result->cat_name; 199 } 200 201 if ($result->cat_guid == $current_guid) { 202 echo "<option value=\"" . $result->cat_guid . "\" selected=\"true\">" . $title . "</option><br />\n"; 203 } else { 204 echo "<option value=\"" . $result->cat_guid . "\">" . $title . "</option><br />\n"; 205 206 } 207 } 208 echo "</select><br /><br /><br />"; 209 echo "<a href=\"" . get_bloginfo('siteurl') . "/wp-admin/admin.php?page=magazinedition\">Edit editions.</a><br />"; 210 211 } 212 213 214 function magazinedition_save_postdata ( $post_id ) { 215 216 if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) 217 return $post_id; 218 219 if ( 'page' == $_POST['post_type'] ) { 220 if ( !current_user_can( 'edit_page', $post_id ) ) 221 return $post_id; 222 } else { 223 if ( !current_user_can( 'edit_post', $post_id ) ) 224 return $post_id; 225 } 226 227 add_post_meta($post_id, 'magazineditionuitgave', $_POST['magazinedition_save_guid'], true) or update_post_meta( $post_id, 'magazineditionuitgave', $_POST['magazinedition_save_guid'] ); 228 229 return $post_id; 230 231 }
Note: See TracChangeset
for help on using the changeset viewer.