slug = 'ultimatemember'; add_action( 'load-post.php', array(&$this, 'add_metabox'), 9 ); add_action( 'load-post-new.php', array(&$this, 'add_metabox'), 9 ); } /*** *** @add a helper tooltip ***/ function tooltip( $text, $e = false ){ ?> form_id = get_the_ID(); } preg_match('#\{.*?\}#s', $box['id'], $matches); if ( isset($matches[0]) ){ $path = $matches[0]; $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] ); } else { $path = um_path; } $path = str_replace('{','', $path ); $path = str_replace('}','', $path ); include_once $path . 'admin/templates/access/'. $box['id'] . '.php'; wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_access_nonce' ); } /*** *** @add form metabox ***/ function add_metabox_form() { global $ultimatemember; if ( um_get_option('access_widget_admin_only') && !current_user_can( 'edit_users' ) ) return; $types = $ultimatemember->query->get_post_types; foreach($types as $post_type) { if ( !$this->core_post_type( $post_type ) ) { add_meta_box('um-admin-access-settings', __('Ultimate Member'), array(&$this, 'load_metabox_form'), $post_type, 'side', 'default'); } do_action('um_admin_custom_access_metaboxes'); } } /*** *** @save form metabox ***/ function save_metabox_form( $post_id, $post ) { global $wpdb; // validate nonce if ( !isset( $_POST['um_admin_save_metabox_access_nonce'] ) || !wp_verify_nonce( $_POST['um_admin_save_metabox_access_nonce'], basename( __FILE__ ) ) ) return $post_id; // validate user $post_type = get_post_type_object( $post->post_type ); if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) return $post_id; // save $multi_choice_keys = apply_filters('um_admin_multi_choice_keys', array() ); if ( $multi_choice_keys ) { foreach( $multi_choice_keys as $k ) { delete_post_meta( $post_id, $k ); } } foreach( $_POST as $k => $v ) { if (strstr($k, '_um_')){ update_post_meta( $post_id, $k, $v); } } } }