member_directory(), 'before_save_data' ), 10, 3 ); } public function remove_meta_box() { remove_meta_box( 'submitdiv', 'um_form', 'core' ); remove_meta_box( 'slugdiv', 'um_form', 'core' ); remove_meta_box( 'submitdiv', 'um_directory', 'core' ); remove_meta_box( 'slugdiv', 'um_directory', 'core' ); } /** * Enter title placeholder * * @param string $title * @param WP_Post $post * * @return string */ public function enter_title_here( $title, $post ) { if ( ! isset( $post->post_type ) ) { return $title; } if ( 'um_directory' === $post->post_type ) { $title = __( 'e.g. Member Directory', 'ultimate-member' ); } elseif ( 'um_form' === $post->post_type ) { $title = __( 'e.g. New Registration Form', 'ultimate-member' ); } return $title; } /** * Hide Woocommerce Shop page restrict content metabox * @param $hide * * @return bool */ function hide_metabox_restrict_content_shop( $hide ) { if ( function_exists( 'wc_get_page_id' ) && ! empty( $_GET['post'] ) && absint( $_GET['post'] ) == wc_get_page_id( 'shop' ) ) { return true; } return $hide; } /** * Filter validation types on loop * * @param $break * @param $key * @param $form_id * @param $field_array * * @return bool */ function validation_types_continue_loop( $break, $key, $form_id, $field_array ) { // show unique username validation only for user_login field if ( isset( $field_array['metakey'] ) && $field_array['metakey'] == 'user_login' && $key !== 'unique_username' ) { return false; } return $break; } /** * Gets the role meta * * @param $id * * @return mixed */ 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; } return false; } /** * Runs on admin head */ public function admin_head() { global $post; if ( isset( $post->ID ) && UM()->admin()->screen()->is_own_post_type() ) { $this->postmeta = $this->get_custom_post_meta( $post->ID ); } } /** * Init the metaboxes */ public function add_metabox() { global $current_screen; if ( 'um_form' === $current_screen->id ) { add_action( 'add_meta_boxes', array( &$this, 'add_metabox_form' ), 1 ); add_action( 'save_post', array( &$this, 'save_metabox_form' ), 10, 2 ); } elseif ( 'um_directory' === $current_screen->id ) { 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()->options()->get( 'restricted_access_post_metabox' ); if ( ! empty( $post_types[ $current_screen->id ] ) ) { /** * UM hook * * @type filter * @title um_restrict_content_hide_metabox * @description Show/Hide Restrict content metabox * @input_vars * [{"var":"$show","type":"bool","desc":"Show Metabox"}] * @change_log * ["Since: 2.0"] * @usage add_filter( 'um_restrict_content_hide_metabox', 'function_name', 10, 1 ); * @example * */ $hide_metabox = apply_filters( 'um_restrict_content_hide_metabox', false ); if ( ! $hide_metabox ) { add_action( 'add_meta_boxes', array(&$this, 'add_metabox_restrict_content'), 1 ); add_action( 'save_post', array( &$this, 'save_metabox_restrict_content' ), 10, 2 ); } if ( $current_screen->id == 'attachment' ) { add_action( 'add_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 ); add_action( 'edit_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 ); } } add_action( 'save_post', array( &$this, 'save_metabox_custom' ), 10, 2 ); } /** * @param $post_id * @param $post */ public 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; } /** * UM hook * * @type action * @title um_admin_custom_restrict_content_metaboxes * @description Save metabox custom with restrict content * @input_vars * [{"var":"$post_id","type":"int","desc":"Post ID"}, * {"var":"$post","type":"array","desc":"Post data"}] * @change_log * ["Since: 2.0"] * @usage add_action( 'um_admin_custom_restrict_content_metaboxes', 'function_name', 10, 2 ); * @example * */ 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', __( 'Ultimate Member: Content Restriction', 'ultimate-member' ), array( &$this, 'restrict_content_cb' ), $current_screen->id, 'normal', 'default' ); /** * UM hook * * @type action * @title um_admin_custom_restrict_content_metaboxes * @description Add restrict content custom metabox * @change_log * ["Since: 2.0"] * @usage add_action( 'um_admin_custom_restrict_content_metaboxes', 'function_name', 10 ); * @example * */ 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()->options()->get( 'restricted_access_taxonomy_metabox' ); $exclude_taxonomies = UM()->excluded_taxonomies(); 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' ) ); } } /** * @param $post_id * @param $post */ 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; } // validate user $post_type = get_post_type_object( $post->post_type ); if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) { return; } if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) { $restriction_meta = UM()->admin()->sanitize_post_restriction_meta( $_POST['um_content_restriction'] ); update_post_meta( $post_id, 'um_content_restriction', $restriction_meta ); } else { delete_post_meta( $post_id, 'um_content_restriction' ); } } /** * @param $post_id * */ function save_attachment_metabox_restrict_content( $post_id ) { // 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 = get_post( $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; } if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) { $restriction_meta = UM()->admin()->sanitize_post_restriction_meta( $_POST['um_content_restriction'] ); update_post_meta( $post_id, 'um_content_restriction', $restriction_meta ); } else { delete_post_meta( $post_id, 'um_content_restriction' ); } } /** * */ function um_category_access_fields_create() { /** * UM hook * * @type filter * @title um_admin_category_access_settings_fields * @description Settings fields for terms * @input_vars * [{"var":"$access_settings_fields","type":"array","desc":"Settings Fields"}, * {"var":"$data","type":"array","desc":"Settings Data"}, * {"var":"$screen","type":"string","desc":"Category Screen"}] * @change_log * ["Since: 2.0"] * @usage add_filter( 'um_admin_category_access_settings_fields', 'function_name', 10, 3 ); * @example * 'my-field-key', * 'type' => 'my-field-type', * 'label' => __( 'My field Label', 'ultimate-member' ), * 'description' => __( 'My Field Description', 'ultimate-member' ), * 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0, * ); * return $access_settings_fields; * } * ?> */ $fields = apply_filters( 'um_admin_category_access_settings_fields', array( array( 'id' => '_um_custom_access_settings', 'type' => 'checkbox', 'label' => __( 'Restrict access to this term and its posts?', 'ultimate-member' ), 'description' => __( 'Activate content restriction for this term and its posts. Affects only posts that do not have individual Restriction Content settings', 'ultimate-member' ), 'value' => 0, ), array( 'id' => '_um_accessible', 'type' => 'select', 'label' => __( 'Who can access this term and its posts?', 'ultimate-member' ), 'value' => '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', 'label' => __( 'Select which roles can access this term and its posts', 'ultimate-member' ), 'description' => __( 'Leave empty if you want to display a term for all logged in users', 'ultimate-member' ), 'options' => UM()->roles()->get_roles( false ), 'columns' => 3, 'conditional' => array( '_um_accessible', '=', '2' ), ), array( 'id' => '_um_access_hide_from_queries', 'type' => 'checkbox', 'label' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? __( 'Hide from queries', 'ultimate-member' ) : __( 'Would you like to display a 404 page for users who do not have access to this term on the term\'s archive page and terms\' posts single pages?', 'ultimate-member' ), 'description' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? __( 'Exclude only from WP queries results', 'ultimate-member' ) : __( 'Recommended to be enabled. Restricted term\'s archive page and all terms\' posts will be hidden by exclusion from WP Query. The safest and most effective method that hides post and its comments from all requests, RSS feeds, etc. on your site', 'ultimate-member' ), 'value' => 1, 'conditional' => array( '_um_accessible', '!=', '0' ), ), array( 'id' => '_um_noaccess_action', 'type' => 'select', 'label' => __( 'What happens when users without access try to view the term\'s post?', 'ultimate-member' ), 'description' => __( 'Action when users without access tries to view the term\'s post', 'ultimate-member' ), 'value' => '0', 'options' => array( '0' => __( 'Show access restricted message', 'ultimate-member' ), '1' => __( 'Redirect user', 'ultimate-member' ), ), 'conditional' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? array( '_um_accessible', '!=', '0' ) : array( '_um_access_hide_from_queries', '=', '0' ), ), array( 'id' => '_um_restrict_by_custom_message', 'type' => 'select', 'label' => __( 'Restricted access message type', 'ultimate-member' ), 'description' => __( 'Would you like to use the global default message or apply a custom message to this term\'s post?', 'ultimate-member' ), 'value' => '0', 'options' => array( '0' => __( 'Global default message', 'ultimate-member' ), '1' => __( 'Custom message', 'ultimate-member' ), ), 'conditional' => array( '_um_noaccess_action', '=', '0' ), ), array( 'id' => '_um_restrict_custom_message', 'type' => 'wp_editor', 'label' => __( 'Custom restricted access message', 'ultimate-member' ), 'description' => __( 'You may replace global restricted access message here', 'ultimate-member' ), 'value' => '', 'conditional' => array( '_um_restrict_by_custom_message', '=', '1' ), ), array( 'id' => '_um_access_redirect', 'type' => 'select', 'label' => __( 'Where should users be redirected to?', 'ultimate-member' ), 'description' => __( 'Select redirect to page when user hasn\'t access to the term\'s post', 'ultimate-member' ), 'value' => '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', 'label' => __( 'Redirect URL', 'ultimate-member' ), 'description' => __( 'Set full URL where do you want to redirect the user', 'ultimate-member' ), 'value' => '', 'conditional' => array( '_um_access_redirect', '=', '1' ), ), ), array(), 'create' ); UM()->admin_forms( array( 'class' => 'um-restrict-content um-third-column', 'prefix_id' => 'um_content_restriction', 'without_wrapper' => true, 'div_line' => true, 'fields' => $fields, ) )->render_form(); wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' ); } /** * @param $term */ 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 hook * * @type filter * @title um_admin_category_access_settings_fields * @description Settings fields for terms * @input_vars * [{"var":"$access_settings_fields","type":"array","desc":"Settings Fields"}, * {"var":"$data","type":"array","desc":"Settings Data"}, * {"var":"$screen","type":"string","desc":"Category Screen"}] * @change_log * ["Since: 2.0"] * @usage add_filter( 'um_admin_category_access_settings_fields', 'function_name', 10, 3 ); * @example * 'my-field-key', * 'type' => 'my-field-type', * 'label' => __( 'My field Label', 'ultimate-member' ), * 'description' => __( 'My Field Description', 'ultimate-member' ), * 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0, * ); * return $access_settings_fields; * } * ?> */ $fields = apply_filters( 'um_admin_category_access_settings_fields', array( array( 'id' => '_um_custom_access_settings', 'type' => 'checkbox', 'label' => __( 'Restrict access to this term and its posts?', 'ultimate-member' ), 'description' => __( 'Activate content restriction for this term and its posts. Affects only posts that do not have individual Restriction Content settings', 'ultimate-member' ), 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0, ), array( 'id' => '_um_accessible', 'type' => 'select', 'label' => __( 'Who can access this term and its posts?', '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', 'label' => __( 'Select which roles can access this term and its posts', 'ultimate-member' ), 'description' => __( 'Leave empty if you want to display a term for all logged in users', 'ultimate-member' ), 'value' => $_um_access_roles_value, 'options' => UM()->roles()->get_roles( false ), 'columns' => 3, 'conditional' => array( '_um_accessible', '=', '2' ), ), array( 'id' => '_um_access_hide_from_queries', 'type' => 'checkbox', 'label' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? __( 'Hide from queries', 'ultimate-member' ) : __( 'Would you like to display a 404 page for users who do not have access to this term on the term\'s archive page and terms\' posts single pages?', 'ultimate-member' ), 'description' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? __( 'Exclude only from WP queries results', 'ultimate-member' ) : __( 'Recommended to be enabled. Restricted term\'s archive page and all terms\' posts will be hidden by exclusion from WP Query. The safest and most effective method that hides post and its comments from all requests, RSS feeds, etc. on your site', 'ultimate-member' ), 'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '', 'conditional' => array( '_um_accessible', '!=', '0' ), ), array( 'id' => '_um_noaccess_action', 'type' => 'select', 'label' => __( 'What happens when users without access try to view the term\'s post?', 'ultimate-member' ), 'description' => __( 'Action when users without access tries to view the term\'s post', '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' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? array( '_um_accessible', '!=', '0' ) : array( '_um_access_hide_from_queries', '=', '0' ), ), array( 'id' => '_um_restrict_by_custom_message', 'type' => 'select', 'label' => __( 'Restricted access message type', 'ultimate-member' ), 'description' => __( 'Would you like to use the global default message or apply a custom message to this term\'s post?', 'ultimate-member' ), 'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0', 'options' => array( '0' => __( 'Global default message', 'ultimate-member' ), '1' => __( 'Custom message', 'ultimate-member' ), ), 'conditional' => array( '_um_noaccess_action', '=', '0' ), ), array( 'id' => '_um_restrict_custom_message', 'type' => 'wp_editor', 'label' => __( 'Custom restricted access message', 'ultimate-member' ), 'description' => __( 'You may replace global restricted access message here', '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', 'label' => __( 'Where should users be redirected to?', 'ultimate-member' ), 'description' => __( 'Select redirect to page when user hasn\'t access to the term\'s post', 'ultimate-member' ), 'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0', 'options' => array( '0' => __( 'Login page', 'ultimate-member' ), '1' => __( 'Custom URL', 'ultimate-member' ), ), 'conditional' => array( '_um_noaccess_action', '=', '1' ), ), array( 'id' => '_um_access_redirect_url', 'type' => 'text', 'label' => __( 'Redirect URL', 'ultimate-member' ), 'description' => __( 'Set full URL where do you want to redirect the user', 'ultimate-member' ), 'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '', 'conditional' => array( '_um_access_redirect', '=', '1' ), ), ), $data, 'edit' ); UM()->admin_forms( array( 'class' => 'um-restrict-content um-third-column', 'prefix_id' => 'um_content_restriction', 'without_wrapper' => true, 'fields' => $fields, ) )->render_form(); wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' ); } /** * @param $termID * * @return mixed */ 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'] ) && is_array( $_REQUEST['um_content_restriction'] ) ) { $restriction_meta = UM()->admin()->sanitize_term_restriction_meta( $_REQUEST['um_content_restriction'] ); update_term_meta( $termID, 'um_content_restriction', $restriction_meta ); } else { delete_term_meta( $termID, 'um_content_restriction' ); } return $termID; } /** * Load a directory metabox * * @param $object * @param $box */ function load_metabox_directory( $object, $box ) { $box['id'] = str_replace( 'um-admin-form-', '', $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/directory/'. $box['id'] . '.php'; if ( ! $this->directory_nonce_added ) { $this->directory_nonce_added = true; wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_directory_nonce' ); } } /** * Load a role metabox * * @param $object * @param $box */ 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 * * @param $object * @param $box */ 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 admin custom metabox * * @param $object * @param $box */ 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'; if ( ! $this->custom_nonce_added ) { $this->custom_nonce_added = true; wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_custom_nonce' ); } } /** * Add directory metabox */ public function add_metabox_directory() { add_meta_box( 'submitdiv', __( 'Publish', 'ultimate-member' ), array( &$this, 'custom_submitdiv' ), 'um_directory', 'side', 'high' ); add_meta_box( 'um-admin-form-general', __( 'General Options', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' ); add_meta_box( 'um-admin-form-sorting', __( 'Sorting', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' ); add_meta_box( 'um-admin-form-profile', __( 'Profile Card', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' ); add_meta_box( 'um-admin-form-search', __( 'Search Options', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' ); add_meta_box( 'um-admin-form-pagination', __( 'Results & Pagination', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' ); add_meta_box( 'um-admin-form-shortcode', __( 'Shortcode', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'side', 'default' ); add_meta_box( 'um-admin-form-appearance', __( 'Styling: General', 'ultimate-member' ), 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-permissions', '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' ) ); if ( ! isset( $_GET['id'] ) || 'administrator' !== sanitize_key( $_GET['id'] ) ) { $roles_metaboxes[] = array( 'id' => 'um-admin-form-home', 'title' => __( 'Homepage Options', 'ultimate-member' ), 'callback' => $callback, 'screen' => 'um_role_meta', 'context' => 'normal', 'priority' => 'default' ); } $roles_metaboxes = array_merge( $roles_metaboxes, array( 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' ) ) ); /** * UM hook * * @type filter * @title um_admin_role_metaboxes * @description Extend metaboxes at Add/Edit User Role * @input_vars * [{"var":"$roles_metaboxes","type":"array","desc":"Metaboxes at Add/Edit UM Role"}] * @change_log * ["Since: 2.0"] * @usage add_filter( 'um_admin_role_metaboxes', 'function_name', 10, 1 ); * @example * 'um-admin-form-your-custom', * 'title' => __( 'My Roles Metabox', 'ultimate-member' ), * 'callback' => 'my-metabox-callback', * 'screen' => 'um_role_meta', * 'context' => 'side', * 'priority' => 'default' * ); * * return $roles_metaboxes; * } * ?> */ $roles_metaboxes = apply_filters( 'um_admin_role_metaboxes', $roles_metaboxes ); $wp_caps_metabox = false; if ( ! empty( $_GET['id'] ) ) { $data = get_option( 'um_role_' . sanitize_key( $_GET['id'] ) . '_meta' ); if ( ! empty( $data['_um_is_custom'] ) ) { $wp_caps_metabox = true; } } if ( 'add' == sanitize_key( $_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 */ public function add_metabox_form() { add_meta_box( 'submitdiv', __( 'Publish', 'ultimate-member' ), array( $this, 'custom_submitdiv' ), 'um_form', 'side', 'high' ); if ( defined( 'UM_DEV_MODE' ) && UM_DEV_MODE && UM()->options()->get( 'enable_new_form_builder' ) ) { // Do new metabox. } else { add_meta_box( 'um-admin-form-mode', __( 'Select Form Type', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' ); add_meta_box( 'um-admin-form-builder', __( 'Form Builder', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' ); } add_meta_box( 'um-admin-form-shortcode', __( 'Shortcode', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' ); add_meta_box( 'um-admin-form-register_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' ); /** * UM hook * * @type action * @title um_admin_custom_register_metaboxes * @description Add custom metaboxes for register form * @change_log * ["Since: 2.0"] * @usage add_action( 'um_admin_custom_register_metaboxes', 'function_name', 10 ); * @example * */ do_action( 'um_admin_custom_register_metaboxes' ); add_meta_box( 'um-admin-form-profile_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' ); add_meta_box( 'um-admin-form-profile_settings', __( 'User Meta', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' ); /** * UM hook * * @type action * @title um_admin_custom_profile_metaboxes * @description Add custom metaboxes for profile form * @change_log * ["Since: 2.0"] * @usage add_action( 'um_admin_custom_profile_metaboxes', 'function_name', 10 ); * @example * */ do_action( 'um_admin_custom_profile_metaboxes' ); add_meta_box( 'um-admin-form-login_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' ); add_meta_box( 'um-admin-form-login_settings', __( 'Options', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' ); /** * UM hook * * @type action * @title um_admin_custom_login_metaboxes * @description Add custom metaboxes for login form * @change_log * ["Since: 2.0"] * @usage add_action( 'um_admin_custom_login_metaboxes', 'function_name', 10 ); * @example * */ do_action( 'um_admin_custom_login_metaboxes' ); } /** * */ public function custom_submitdiv() { global $post, $current_screen; ?>
setup()->set_icons_options(); $um_icons_list = get_option( 'um_icons_list' ); $first_activation_date = get_option( 'um_first_activation_date', false ); $wrapper_classes = array( 'um-icon-select-field-wrapper', ); if ( 'row' === $this->set_field_type ) { $wrapper_classes[] = '_heading_text'; } $wrapper_classes = implode( ' ', $wrapper_classes ); // @todo new version if ( empty( $first_activation_date ) || $first_activation_date >= 1716336000 || empty( $this->edit_mode_value ) || array_key_exists( $this->edit_mode_value, $um_icons_list ) ) { ?>
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 : UM()->options()->get( 'require_strongpass' ) ) ?> />
edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_label_confirm_pass" data-cond1-hide="xxx" />
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', 'ultimate-member' ); } if ( $this->set_field_type == 'file' ) { $value = __( 'Drag & Drop File', 'ultimate-member' ); } ?>
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 == 'date' ) { ?>
set_field_type == 'time' ) { ?>
set_field_type == 'rating' ) { ?>
__( 'Everyone', 'ultimate-member' ), '2' => __( 'Members', 'ultimate-member' ), '-1' => __( 'Only visible to profile owner and users who can edit other member accounts', 'ultimate-member' ), '-3' => __( 'Only visible to profile owner and specific roles', 'ultimate-member' ), '-2' => __( 'Only specific member roles', 'ultimate-member' ), ); $privacy_options = apply_filters( 'um_field_privacy_options', $privacy_options ); ?>
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 ); ?> />
edit_mode_value = null; } } }