"; }
exit;
}// function cpr_cats
function cpr_save() {
global $post_ID;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id;
if (!wp_verify_nonce( $_POST['myplugin_noncename'], plugin_basename(__FILE__))) return $post_id;
if (!current_user_can( 'edit_post', $post_id ) ) return $post_id;
$id = $_POST['post_ID'];
$related = $_POST['reladded'];
update_post_meta($id, 'cpr_related', $related);
}
function cpr_populate($id) {
global $wpdb;
$related_meta = get_post_meta($id, 'cpr_related', true);
$related_posts = array();
if (!empty($related_meta)) {
foreach ($related_meta as $related) {
$post = get_post($related);
$related_posts[] = $post;
}
return $related_posts;
}
}
// oi! wait! where are you going? are you sure? 100%? a second thought? come on let's talk about it. oh well.
function cpr_uninstall() {
global $wpdb;
$wpdb->query($wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_key = 'cpr_related'"));
}
add_action('admin_menu', 'cpr_box');
add_action('wp_ajax_cpr-cats', 'cpr_cats');
add_action('admin_menu', 'cpr_scripts_styles');
add_action('save_post', 'cpr_save');
add_action('wt4_show','cpr_populate');
register_uninstall_hook(__FILE__, 'cpr_uninstall');
?>