public static function attributesBoxContentPost($post) { global $wpdb; global $mf_domain; $single_panel = FALSE; $panel_id = get_post_meta($post->ID, "_mf_write_panel_id", TRUE); if ($panel_id) { $panel = RCCWP_CustomWritePanel::Get($panel_id); } ?> <p><strong><?php _e('Write Panel'); ?> </strong></p> <label class="screen-reader-text" for="parent_id"><?php _e('Write Panel'); ?> </label> <?php // get a list of the write panels $customWritePanels = RCCWP_CustomWritePanel::GetCustomWritePanels(); ?> <select name="rc-cwp-change-custom-write-panel-id" id="rc-cwp-change-custom-write-panel-id"> <option value="-1"><?php _e('(None)', $mf_domain); ?> </option> <?php $items = array(); foreach ($customWritePanels as $panel) { $selected = $panel->id == $panel_id ? 'selected="selected"' : ''; $allow = $panel->type == "post"; if ($panel->single && $panel->id != $panel_id) { // check to see if there are any posts with this panel already. If so, we can't allow it to be used. $sql = $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->postmeta} WHERE {$wpdb->postmeta}.meta_value = %d AND {$wpdb->postmeta}.meta_key = %s", array($panel->id, "_mf_write_panel_id")); $count = $wpdb->get_var($sql); $allow = $count == 0; } if ($allow) { // cannot change to "single" panels ?> <option value="<?php echo $panel->id; ?> " <?php echo $selected; ?> ><?php echo $panel->name; ?> </option> <?php } } ?> </select> <?php }