slug = 'ultimatemember'; $this->in_edit = false; $this->edit_mode_value = null; add_action('admin_head', array(&$this, 'admin_head'), 9); add_action('admin_footer', array(&$this, 'load_modal_content'), 9); add_action( 'load-post.php', array(&$this, 'add_metabox'), 9 ); add_action( 'load-post-new.php', array(&$this, 'add_metabox'), 9 ); add_action( 'plugins_loaded', array(&$this, 'add_taxonomy_metabox'), 9 ); //roles metaboxes add_action( 'um_roles_add_meta_boxes', array( &$this, 'add_metabox_role' ) ); } /*** *** @Boolean check if we're viewing UM backend ***/ function is_UM_admin() { global $current_screen; $screen_id = $current_screen->id; if ( is_admin() && ( strstr( $screen_id, 'ultimatemember') || strstr( $screen_id, 'um_') || strstr($screen_id, 'user') || strstr($screen_id, 'profile') ) ) return true; return false; } /*** *** @check that we're on a custom post type supported by UM ***/ function is_plugin_post_type() { if (isset($_REQUEST['post_type'])){ $post_type = $_REQUEST['post_type']; if ( in_array($post_type, array('um_form','um_role','um_directory'))){ return true; } } else if ( isset($_REQUEST['action'] ) && $_REQUEST['action'] == 'edit') { $post_type = get_post_type(); if ( in_array($post_type, array('um_form','um_role','um_directory'))){ return true; } } return false; } /*** *** @Gets the role meta ***/ function get_custom_post_meta($id){ $all_meta = get_post_custom($id); foreach($all_meta as $k=>$v){ if (strstr($k, '_um_')){ $um_meta[$k] = $v; } } if (isset($um_meta)) return $um_meta; } /*** *** @Runs on admin head ***/ function admin_head(){ global $post; if ( $this->is_plugin_post_type() && isset($post->ID) ){ $this->postmeta = $this->get_custom_post_meta($post->ID); } } /*** *** @Init the metaboxes ***/ function add_metabox() { global $current_screen; if ( $current_screen->id == 'um_form' ) { add_action( 'add_meta_boxes', array(&$this, 'add_metabox_form'), 1 ); add_action( 'save_post', array(&$this, 'save_metabox_form'), 10, 2 ); } if ( $current_screen->id == 'um_directory' ) { add_action( 'add_meta_boxes', array(&$this, 'add_metabox_directory'), 1 ); add_action( 'save_post', array(&$this, 'save_metabox_directory'), 10, 2 ); } //restrict content metabox $post_types = um_get_option( 'restricted_access_post_metabox' ); if ( ! empty( $post_types[ $current_screen->id ] ) ) { add_action( 'add_meta_boxes', array(&$this, 'add_metabox_restrict_content'), 1 ); add_action( 'save_post', array( &$this, 'save_metabox_restrict_content' ), 10, 2 ); } add_action( 'save_post', array( &$this, 'save_metabox_custom' ), 10, 2 ); } function save_metabox_custom( $post_id, $post ) { // validate nonce if ( ! isset( $_POST['um_admin_save_metabox_custom_nonce'] ) || ! wp_verify_nonce( $_POST['um_admin_save_metabox_custom_nonce'], basename( __FILE__ ) ) ) return $post_id; do_action( 'um_admin_custom_restrict_content_metaboxes', $post_id, $post ); } function add_metabox_restrict_content() { global $current_screen; add_meta_box( 'um-admin-restrict-content', __( 'UM Content Restriction', 'ultimate-member' ), array( &$this, 'restrict_content_cb' ), $current_screen->id, 'normal', 'default' ); do_action( 'um_admin_custom_restrict_content_metaboxes' ); } /** * Content restriction metabox * * @param $object * @param $box */ function restrict_content_cb( $object, $box ) { include_once UM()->admin()->templates_path . 'access/restrict_content.php'; wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_restrict_content_nonce' ); } /*** *** @Init the metaboxes ***/ function add_taxonomy_metabox() { //restrict content metabox $all_taxonomies = get_taxonomies( array( 'public' => true ) ); $tax_types = um_get_option( 'restricted_access_taxonomy_metabox' ); $exclude_taxonomies = array( 'nav_menu', 'link_category', 'post_format', 'um_user_tag', 'um_hashtag', ); foreach ( $all_taxonomies as $key => $taxonomy ) { if ( in_array( $key, $exclude_taxonomies ) || empty( $tax_types[$key] ) ) continue; add_action( $taxonomy . '_add_form_fields', array( &$this, 'um_category_access_fields_create' ) ); add_action( $taxonomy . '_edit_form_fields', array( &$this, 'um_category_access_fields_edit' ) ); add_action( 'create_' . $taxonomy, array( &$this, 'um_category_access_fields_save' ) ); add_action( 'edited_' . $taxonomy, array( &$this, 'um_category_access_fields_save' ) ); } } function save_metabox_restrict_content( $post_id, $post ) { // validate nonce if ( ! isset( $_POST['um_admin_save_metabox_restrict_content_nonce'] ) || !wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_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; if ( ! empty( $_POST['um_content_restriction'] ) ) update_post_meta( $post_id, 'um_content_restriction', $_POST['um_content_restriction'] ); else delete_post_meta( $post_id, 'um_content_restriction' ); return $post_id; } function um_category_access_fields_create() { $data = array(); UM()->admin_forms( array( 'class' => 'um-restrict-content um-third-column', 'prefix_id' => 'um_content_restriction', 'without_wrapper' => true, 'div_line' => true, 'fields' => array( array( 'id' => '_um_custom_access_settings', 'type' => 'checkbox', 'name' => '_um_custom_access_settings', 'label' => __( 'Restrict access to this content?', 'ultimate-member' ), 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ), 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0, ), array( 'id' => '_um_accessible', 'type' => 'select', 'name' => '_um_accessible', 'label' => __( 'Who can access this content?', 'ultimate-member' ), 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ), 'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : 0, 'options' => array( '0' => __( 'Everyone', 'ultimate-member' ), '1' => __( 'Logged out users', 'ultimate-member' ), '2' => __( 'Logged in users', 'ultimate-member' ), ), 'conditional' => array( '_um_custom_access_settings', '=', '1' ) ), array( 'id' => '_um_access_roles', 'type' => 'multi_checkbox', 'name' => '_um_access_roles', 'label' => __( 'Select which roles can access this content', 'ultimate-member' ), 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ), 'options' => UM()->roles()->get_roles( false, array( 'administrator' ) ), 'columns' => 3, 'conditional' => array( '_um_accessible', '=', '2' ) ), array( 'id' => '_um_noaccess_action', 'type' => 'select', 'name' => '_um_noaccess_action', 'label' => __( 'What happens when users without access tries to view the content?', 'ultimate-member' ), 'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ), 'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : 0, 'options' => array( '0' => __( 'Show access restricted message', 'ultimate-member' ), '1' => __( 'Redirect user', 'ultimate-member' ), ), 'conditional' => array( '_um_accessible', '!=', '0' ) ), array( 'id' => '_um_restrict_by_custom_message', 'type' => 'select', 'name' => '_um_restrict_by_custom_message', 'label' => __( 'Would you like to use the global default message or apply a custom message to this content?', 'ultimate-member' ), 'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ), 'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0', 'options' => array( '0' => __( 'Global default message (default)', 'ultimate-member' ), '1' => __( 'Custom message', 'ultimate-member' ), ), 'conditional' => array( '_um_noaccess_action', '=', '0' ) ), array( 'id' => '_um_restrict_custom_message', 'type' => 'wp_editor', 'name' => '_um_restrict_custom_message', 'label' => __( 'Custom Restrict Content message', 'ultimate-member' ), 'description' => __( 'Changed global restrict message', 'ultimate-member' ), 'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '', 'conditional' => array( '_um_restrict_by_custom_message', '=', '1' ) ), array( 'id' => '_um_access_redirect', 'type' => 'select', 'name' => '_um_access_redirect', 'label' => __( 'Where should users be redirected to?', 'ultimate-member' ), 'description' => __( 'Select redirect to page when user hasn\'t access to content', 'ultimate-member' ), 'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0', 'conditional' => array( '_um_noaccess_action', '=', '1' ), 'options' => array( '0' => __( 'Login page', 'ultimate-member' ), '1' => __( 'Custom URL', 'ultimate-member' ), ), ), array( 'id' => '_um_access_redirect_url', 'type' => 'text', 'name' => '_um_access_redirect_url', 'label' => __( 'Redirect URL', 'ultimate-member' ), 'description' => __( 'Changed global restrict message', 'ultimate-member' ), 'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '', 'conditional' => array( '_um_access_redirect', '=', '1' ) ), array( 'id' => '_um_access_hide_from_queries', 'type' => 'checkbox', 'name' => '_um_access_hide_from_queries', 'label' => __( 'Hide from queries', 'ultimate-member' ), 'description' => __( 'Hide this content from archives, RSS feeds etc for users who do not have permission to view this content', 'ultimate-member' ), 'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '', 'conditional' => array( '_um_accessible', '!=', '0' ) ) ) ) )->render_form(); wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' ); } function um_category_access_fields_edit( $term ) { $termID = $term->term_id; $data = get_term_meta( $termID, 'um_content_restriction', true ); $_um_access_roles_value = array(); if ( ! empty( $data['_um_access_roles'] ) ) { foreach ( $data['_um_access_roles'] as $key => $value ) { if ( $value ) $_um_access_roles_value[] = $key; } } UM()->admin_forms( array( 'class' => 'um-restrict-content um-third-column', 'prefix_id' => 'um_content_restriction', 'without_wrapper' => true, 'fields' => array( array( 'id' => '_um_custom_access_settings', 'type' => 'checkbox', 'class' => 'form-field', 'name' => '_um_custom_access_settings', 'label' => __( 'Restrict access to this content?', 'ultimate-member' ), 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ), 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0, ), array( 'id' => '_um_accessible', 'type' => 'select', 'class' => 'form-field', 'name' => '_um_accessible', 'label' => __( 'Who can access this content?', 'ultimate-member' ), 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ), 'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : 0, 'options' => array( '0' => __( 'Everyone', 'ultimate-member' ), '1' => __( 'Logged out users', 'ultimate-member' ), '2' => __( 'Logged in users', 'ultimate-member' ), ), 'conditional' => array( '_um_custom_access_settings', '=', '1' ) ), array( 'id' => '_um_access_roles', 'type' => 'multi_checkbox', 'class' => 'form-field', 'name' => '_um_access_roles', 'label' => __( 'Select which roles can access this content', 'ultimate-member' ), 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ), 'value' => $_um_access_roles_value, 'options' => UM()->roles()->get_roles( false, array( 'administrator' ) ), 'columns' => 3, 'conditional' => array( '_um_accessible', '=', '2' ) ), array( 'id' => '_um_noaccess_action', 'type' => 'select', 'class' => 'form-field', 'name' => '_um_noaccess_action', 'label' => __( 'What happens when users without access tries to view the content?', 'ultimate-member' ), 'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ), 'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : 0, 'options' => array( '0' => __( 'Show access restricted message', 'ultimate-member' ), '1' => __( 'Redirect user', 'ultimate-member' ), ), 'conditional' => array( '_um_accessible', '!=', '0' ) ), array( 'id' => '_um_restrict_by_custom_message', 'type' => 'select', 'class' => 'form-field', 'name' => '_um_restrict_by_custom_message', 'label' => __( 'Would you like to use the global default message or apply a custom message to this content?', 'ultimate-member' ), 'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ), 'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0', 'options' => array( '0' => __( 'Global default message (default)', 'ultimate-member' ), '1' => __( 'Custom message', 'ultimate-member' ), ), 'conditional' => array( '_um_noaccess_action', '=', '0' ) ), array( 'id' => '_um_restrict_custom_message', 'type' => 'wp_editor', 'class' => 'form-field', 'name' => '_um_restrict_custom_message', 'label' => __( 'Custom Restrict Content message', 'ultimate-member' ), 'description' => __( 'Changed global restrict message', 'ultimate-member' ), 'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '', 'conditional' => array( '_um_restrict_by_custom_message', '=', '1' ) ), array( 'id' => '_um_access_redirect', 'type' => 'select', 'class' => 'form-field', 'name' => '_um_access_redirect', 'label' => __( 'Where should users be redirected to?', 'ultimate-member' ), 'description' => __( 'Select redirect to page when user hasn\'t access to content', 'ultimate-member' ), 'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0', 'conditional' => array( '_um_noaccess_action', '=', '1' ), 'options' => array( '0' => __( 'Login page', 'ultimate-member' ), '1' => __( 'Custom URL', 'ultimate-member' ), ), ), array( 'id' => '_um_access_redirect_url', 'type' => 'text', 'class' => 'form-field', 'name' => '_um_access_redirect_url', 'label' => __( 'Redirect URL', 'ultimate-member' ), 'description' => __( 'Changed global restrict message', 'ultimate-member' ), 'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '', 'conditional' => array( '_um_access_redirect', '=', '1' ) ), array( 'id' => '_um_access_hide_from_queries', 'type' => 'checkbox', 'class' => 'form-field', 'name' => '_um_access_hide_from_queries', 'label' => __( 'Hide from queries', 'ultimate-member' ), 'description' => __( 'Hide this content from archives, RSS feeds etc for users who do not have permission to view this content', 'ultimate-member' ), 'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '', 'conditional' => array( '_um_accessible', '!=', '0' ) ) ) ) )->render_form(); wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' ); } function um_category_access_fields_save( $termID ) { // validate nonce if ( ! isset( $_REQUEST['um_admin_save_taxonomy_restrict_content_nonce'] ) || ! wp_verify_nonce( $_REQUEST['um_admin_save_taxonomy_restrict_content_nonce'], basename( __FILE__ ) ) ) return $termID; // validate user $term = get_term( $termID ); $taxonomy = get_taxonomy( $term->taxonomy ); if ( ! current_user_can( $taxonomy->cap->edit_terms, $termID ) ) return $termID; if ( ! empty( $_REQUEST['um_content_restriction'] ) ) update_term_meta( $termID, 'um_content_restriction', $_REQUEST['um_content_restriction'] ); else delete_term_meta( $termID, 'um_content_restriction' ); return $termID; } /*** *** @load a directory metabox ***/ function load_metabox_directory( $object, $box ) { $box['id'] = str_replace( 'um-admin-form-', '', $box['id'] ); include_once UM()->admin()->templates_path . 'directory/'. $box['id'] . '.php'; wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_directory_nonce' ); } /*** *** @load a role metabox ***/ function load_metabox_role( $object, $box ) { global $post; $box['id'] = str_replace( 'um-admin-form-', '', $box['id'] ); if ( $box['id'] == 'builder' ) { UM()->builder()->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 . 'includes/admin/templates/role/'. $box['id'] . '.php'; //wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_role_nonce' ); } /*** *** @load a form metabox ***/ function load_metabox_form( $object, $box ) { global $post; $box['id'] = str_replace( 'um-admin-form-','', $box['id'] ); if ( $box['id'] == 'builder' ) { UM()->builder()->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 . 'includes/admin/templates/form/'. $box['id'] . '.php'; if ( ! $this->form_nonce_added ) { $this->form_nonce_added = true; wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_form_nonce' ); } } /*** *** @load a form metabox ***/ function load_metabox_custom( $object, $box ) { global $post; $box['id'] = str_replace('um-admin-custom-','', $box['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 . 'includes/admin/templates/'. $box['id'] . '.php'; wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_custom_nonce' ); } /*** *** @add directory metabox ***/ function add_metabox_directory() { add_meta_box('um-admin-form-general', __('General Options'), array(&$this, 'load_metabox_directory'), 'um_directory', 'normal', 'default'); add_meta_box('um-admin-form-profile', __('Profile Card'), array(&$this, 'load_metabox_directory'), 'um_directory', 'normal', 'default'); add_meta_box('um-admin-form-search', __('Search Options'), array(&$this, 'load_metabox_directory'), 'um_directory', 'normal', 'default'); add_meta_box('um-admin-form-pagination', __('Results & Pagination'), array(&$this, 'load_metabox_directory'), 'um_directory', 'normal', 'default'); add_meta_box('um-admin-form-shortcode', __('Shortcode'), array(&$this, 'load_metabox_directory'), 'um_directory', 'side', 'default'); add_meta_box('um-admin-form-appearance', __('Styling: General'), array(&$this, 'load_metabox_directory'), 'um_directory', 'side', 'default'); //add_meta_box('um-admin-form-profile_card', __('Styling: Profile Card'), array(&$this, 'load_metabox_directory'), 'um_directory', 'side', 'default'); } /*** *** @add role metabox ***/ function add_metabox_role() { $callback = array( &$this, 'load_metabox_role' ); $roles_metaboxes = array( array( 'id' => 'um-admin-form-admin', 'title' => __( 'Administrative Permissions', 'ultimate-member' ), 'callback' => $callback, 'screen' => 'um_role_meta', 'context' => 'normal', 'priority' => 'default' ), array( 'id' => 'um-admin-form-general', 'title' => __( 'General Permissions', 'ultimate-member' ), 'callback' => $callback, 'screen' => 'um_role_meta', 'context' => 'normal', 'priority' => 'default' ), array( 'id' => 'um-admin-form-profile', 'title' => __( 'Profile Access', 'ultimate-member' ), 'callback' => $callback, 'screen' => 'um_role_meta', 'context' => 'normal', 'priority' => 'default' ), array( 'id' => 'um-admin-form-home', 'title' => __( 'Homepage Options', 'ultimate-member' ), 'callback' => $callback, 'screen' => 'um_role_meta', 'context' => 'normal', 'priority' => 'default' ), array( 'id' => 'um-admin-form-register', 'title' => __( 'Registration Options', 'ultimate-member' ), 'callback' => $callback, 'screen' => 'um_role_meta', 'context' => 'normal', 'priority' => 'default' ), array( 'id' => 'um-admin-form-login', 'title' => __( 'Login Options', 'ultimate-member' ), 'callback' => $callback, 'screen' => 'um_role_meta', 'context' => 'normal', 'priority' => 'default' ), array( 'id' => 'um-admin-form-logout', 'title' => __( 'Logout Options', 'ultimate-member' ), 'callback' => $callback, 'screen' => 'um_role_meta', 'context' => 'normal', 'priority' => 'default' ), array( 'id' => 'um-admin-form-delete', 'title' => __( 'Delete Options', 'ultimate-member' ), 'callback' => $callback, 'screen' => 'um_role_meta', 'context' => 'normal', 'priority' => 'default' ), array( 'id' => 'um-admin-form-publish', 'title' => __( 'Publish', 'ultimate-member' ), 'callback' => $callback, 'screen' => 'um_role_meta', 'context' => 'side', 'priority' => 'default' ) ); $roles_metaboxes = apply_filters( 'um_admin_role_metaboxes', $roles_metaboxes ); $wp_caps_metabox = false; if ( ! empty( $_GET['id'] ) ) { $data = get_option( "um_role_{$_GET['id']}_meta" ); if ( ! empty( $data['_um_is_custom'] ) ) $wp_caps_metabox = true; } if ( 'add' == $_GET['tab'] || $wp_caps_metabox ) { $roles_metaboxes[] = array( 'id' => 'um-admin-form-wp-capabilities', 'title' => __( 'WP Capabilities', 'ultimate-member' ), 'callback' => $callback, 'screen' => 'um_role_meta', 'context' => 'normal', 'priority' => 'default' ); } foreach ( $roles_metaboxes as $metabox ) { add_meta_box( $metabox['id'], $metabox['title'], $metabox['callback'], $metabox['screen'], $metabox['context'], $metabox['priority'] ); } } /*** *** @add form metabox ***/ function add_metabox_form() { add_meta_box( 'um-admin-form-mode', __( 'Select Form Type' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' ); add_meta_box( 'um-admin-form-builder', __( 'Form Builder' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' ); add_meta_box( 'um-admin-form-shortcode', __( 'Shortcode' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' ); add_meta_box('um-admin-form-register_customize', __( 'Customize this form' ), array(&$this, 'load_metabox_form'), 'um_form', 'side', 'default'); do_action( 'um_admin_custom_register_metaboxes' ); add_meta_box('um-admin-form-profile_customize', __('Customize this form'), array(&$this, 'load_metabox_form'), 'um_form', 'side', 'default'); add_meta_box('um-admin-form-profile_settings', __('User Meta'), array(&$this, 'load_metabox_form'), 'um_form', 'side', 'default'); do_action( 'um_admin_custom_profile_metaboxes' ); add_meta_box('um-admin-form-login_customize', __('Customize this form'), array(&$this, 'load_metabox_form'), 'um_form', 'side', 'default'); add_meta_box('um-admin-form-login_settings', __('Options'), array(&$this, 'load_metabox_form'), 'um_form', 'side', 'default'); do_action( 'um_admin_custom_login_metaboxes' ); } /*** *** @save directory metabox ***/ function save_metabox_directory( $post_id, $post ) { global $wpdb; // validate nonce if ( !isset( $_POST['um_admin_save_metabox_directory_nonce'] ) || !wp_verify_nonce( $_POST['um_admin_save_metabox_directory_nonce'], basename( __FILE__ ) ) ) return $post_id; // validate post type if ( $post->post_type != 'um_directory' ) 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; $where = array( 'ID' => $post_id ); if ( empty( $_POST['post_title'] ) ) $_POST['post_title'] = 'Directory #'.$post_id; $wpdb->update( $wpdb->posts, array( 'post_title' => $_POST['post_title'] ), $where ); // save delete_post_meta( $post_id, '_um_roles' ); delete_post_meta( $post_id, '_um_tagline_fields' ); delete_post_meta( $post_id, '_um_reveal_fields' ); delete_post_meta( $post_id, '_um_search_fields' ); delete_post_meta( $post_id, '_um_roles_can_search' ); delete_post_meta( $post_id, '_um_show_these_users' ); //save metadata foreach ( $_POST['um_metadata'] as $k => $v ) { if ( $k == '_um_show_these_users' && trim( $_POST['um_metadata'][ $k ] ) ) { $v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY ); } if ( strstr( $k, '_um_' ) ) { update_post_meta( $post_id, $k, $v ); } } } /*** *** @save role metabox ***/ /* function save_metabox_role( $post_id, $post ) { global $wpdb; // validate nonce if ( !isset( $_POST['um_admin_save_metabox_role_nonce'] ) || !wp_verify_nonce( $_POST['um_admin_save_metabox_role_nonce'], basename( __FILE__ ) ) ) return $post_id; // validate post type if ( $post->post_type != 'um_role' ) 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; $where = array( 'ID' => $post_id ); if (empty($_POST['post_title'])) $_POST['post_title'] = 'Role #'.$post_id; $wpdb->update( $wpdb->posts, array( 'post_title' => $_POST['post_title'], 'post_name' => sanitize_title( $_POST['post_title'] ) ), $where ); // save delete_post_meta( $post_id, '_um_can_view_roles' ); delete_post_meta( $post_id, '_um_can_edit_roles' ); delete_post_meta( $post_id, '_um_can_delete_roles' ); do_action('um_admin_before_saving_role_meta', $post_id ); do_action('um_admin_before_save_role', $post_id, $post ); foreach( $_POST as $k => $v ) { if (strstr($k, '_um_')){ update_post_meta( $post_id, $k, $v); } } do_action('um_admin_after_editing_role', $post_id, $post); do_action('um_admin_after_save_role', $post_id, $post ); }*/ /*** *** @save form metabox ***/ function save_metabox_form( $post_id, $post ) { global $wpdb; // validate nonce if ( !isset( $_POST['um_admin_save_metabox_form_nonce'] ) || !wp_verify_nonce( $_POST['um_admin_save_metabox_form_nonce'], basename( __FILE__ ) ) ) return $post_id; // validate post type if ( $post->post_type != 'um_form' ) 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; $where = array( 'ID' => $post_id ); if ( empty( $_POST['post_title'] ) ) $_POST['post_title'] = 'Form #' . $post_id; $wpdb->update( $wpdb->posts, array( 'post_title' => $_POST['post_title'] ), $where ); // save delete_post_meta( $post_id, '_um_profile_metafields' ); foreach ( $_POST['form'] as $k => $v ) { if ( strstr( $k, '_um_' ) ){ update_post_meta( $post_id, $k, $v); } } } /*** *** @Load modal content ***/ function load_modal_content() { $screen = get_current_screen(); if ( $this->is_UM_admin() ) { foreach ( glob( um_path . 'includes/admin/templates/modal/*.php' ) as $modal_content ) { include_once $modal_content; } } // needed on forms only if ( !isset( $this->is_loaded ) && isset( $screen->id ) && strstr( $screen->id, 'um_form' ) ) { $settings['textarea_rows'] = 8; echo ''; echo ''; } } /*** *** @Show field input for edit ***/ function field_input( $attribute, $form_id = null, $field_args = array() ) { if ( $this->in_edit == true ) { // we're editing a field $real_attr = substr( $attribute, 1 ); $this->edit_mode_value = (isset( $this->edit_array[ $real_attr ] ) ) ? $this->edit_array[ $real_attr ] : null; } switch ( $attribute ) { default: do_action( "um_admin_field_edit_hook{$attribute}", $this->edit_mode_value ); break; case '_visibility': ?>

  

set_field_type == 'row' ) { $back = 'UM_edit_row'; ?>

Choose Icon edit_mode_value ) { ?>No Icon edit_mode_value ) { ?>

in_edit ) { $back = 'UM_edit_field'; } else { $back = 'UM_add_field'; } ?>

Choose Icon edit_mode_value ) { ?>No Icon edit_mode_value ) { ?>

edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_heading_text" data-cond1-hide="xxx" />

edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> />

edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> />

set_field_type == 'date' ) { ?>

edit_mode_value ) && is_array( $this->edit_mode_value ) ) { $values = $this->edit_mode_value; } else { $values = array(''); } ?>

set_field_type == 'shortcode' ) { ?>

set_field_type == 'image' ) { if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) { $values = $this->edit_mode_value; } else { $values = array('png','jpeg','jpg','gif'); } ?>

edit_mode_value ) && is_array( $this->edit_mode_value ) ) { $values = $this->edit_mode_value; } else { $values = array('pdf','txt'); } ?>

set_field_type == 'image' ) $value = 'Drag & Drop Photo'; if ( $this->set_field_type == 'file' ) $value = 'Drag & Drop File'; ?>

edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_max_selections" data-cond1-hide="xxx" />

edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> />

edit_mode_value ) && is_array( $this->edit_mode_value ) ) { $values = implode("\n", $this->edit_mode_value); } else if ( $this->edit_mode_value ) { $values = $this->edit_mode_value; } else { $values = ''; } ?>

in_edit ) { ?>

set_field_type == 'textarea' ) { ?>

set_field_type == 'rating' ) { ?>

edit_mode_value ) && is_array( $this->edit_mode_value ) ) { $values = $this->edit_mode_value; } else { $values = array(''); } ?>

set_field_type == 'password' ) $def_required = 1; else $def_required = 0; ?>

edit_mode_value ) ? $this->edit_mode_value : $def_required ) ?> />

edit_mode_value || $this->edit_mode_value ) ?> />