Plugin Directory

Changeset 204702


Ignore:
Timestamp:
02/12/2010 09:20:33 PM (16 years ago)
Author:
erwinwolff
Message:

sync

File:
1 edited

Legend:

Unmodified
Added
Removed
  • magazine-edition-control/trunk/beheer.php

    r204597 r204702  
    3030
    3131add_action('admin_menu', 'magazinedition_admin_actions');
     32
     33add_action('admin_menu', 'magazinedition_custom');
     34
     35add_action('save_post', 'magazinedition_save_postdata');
    3236
    3337
     
    5256}
    5357
     58function magazinedition_custom () {
     59if ( current_user_can('manage_options') ) {
     60add_meta_box("magazinedition_meta", __('Magazine Edtion Control', 'magazinedition'), "magazinedition_meta", "post", 'side', 'core');
     61}
     62}
    5463
    5564function magazinedition_menu()
     
    157166return $return;
    158167}
     168
     169function magazinedition_meta ( ) {
     170 global $wpdb;
     171global $post;
     172
     173$structure = "SELECT * FROM " . $wpdb->prefix . "magazinedition_uitgaven ORDER BY cat_date";
     174$results = $wpdb->get_results($structure);
     175
     176$count = 0;
     177foreach ($results as $result) {
     178$count++;
     179}
     180if ($count == 0) {
     181
     182echo "<a href=\"" . get_bloginfo('siteurl')  . "/wp-admin/admin.php?page=magazinedition\">Please create and name an edition first.</a><br />";
     183return 0;
     184}
     185
     186$current_guid = get_post_meta( $_GET['post'], 'magazineditionuitgave', true);
     187
     188echo "<label for=\"magazinedition_save_guid\">Select an edition:</label><br />";
     189echo "<select name=\"magazinedition_save_guid\" style=\"width: 90%\">\n";
     190echo "<option value=\"\">This post isn't part of an edition.</option><br />\n";
     191
     192foreach ($results as $result) {
     193$title = "";
     194
     195if ($result->cat_name == "") {
     196$title = "Edition of " . $result->cat_date;
     197} else {
     198$title = $result->cat_name;
     199}
     200
     201if ($result->cat_guid == $current_guid) {
     202echo "<option value=\"" . $result->cat_guid  . "\" selected=\"true\">" . $title . "</option><br />\n";
     203} else {
     204echo "<option value=\"" . $result->cat_guid  . "\">" . $title . "</option><br />\n";
     205
     206}
     207}
     208echo "</select><br /><br /><br />";
     209echo "<a href=\"" . get_bloginfo('siteurl')  . "/wp-admin/admin.php?page=magazinedition\">Edit editions.</a><br />";
     210
     211}
     212
     213
     214function magazinedition_save_postdata ( $post_id ) {
     215
     216if ( 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
     227add_post_meta($post_id, 'magazineditionuitgave', $_POST['magazinedition_save_guid'], true) or update_post_meta( $post_id, 'magazineditionuitgave', $_POST['magazinedition_save_guid'] );
     228
     229return $post_id;
     230
     231}
Note: See TracChangeset for help on using the changeset viewer.