diff --git a/assets/js/um-scripts.js b/assets/js/um-scripts.js index 21deca76..8935cffd 100644 --- a/assets/js/um-scripts.js +++ b/assets/js/um-scripts.js @@ -1,8 +1,3 @@ -/*jQuery('body').on('error', '.um-avatar', function() { - if( jQuery(this).data('load-error') != undefined ) return; - jQuery(this).data('load-error', '1').attr('src', jQuery(this).data('default')); -});*/ - function um_init_datetimepicker() { jQuery('.um-datepicker:not(.picker__input)').each(function(){ elem = jQuery(this); diff --git a/includes/admin/templates/access/restrict_content.php b/includes/admin/templates/access/restrict_content.php index 9f12d96b..ff0caf7d 100644 --- a/includes/admin/templates/access/restrict_content.php +++ b/includes/admin/templates/access/restrict_content.php @@ -19,6 +19,12 @@ if ( ! defined( 'ABSPATH' ) ) exit; } } + if ( ! empty( $object->post_type ) ) { + $post_type_object = get_post_type_object( $object->post_type ); + } else { + $post_type_object = array(); + } + /** * UM hook * @@ -131,7 +137,19 @@ if ( ! defined( 'ABSPATH' ) ) exit; 'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '', 'conditional' => array( '_um_accessible', '!=', '0' ) ) - ), $data ); + ), $data, $object, $post_type_object ); + + // Hierarchical + if ( $post_type_object->hierarchical ) { + $fields[] = array( + 'id' => '_um_access_hierarchical', + 'type' => 'checkbox', + 'label' => __( 'Hierarchical', 'ultimate-member' ), + 'tooltip' => __( 'Use parent page settings for the child pages that doesn\'t have own restriction settings.', 'ultimate-member' ), + 'value' => empty( $data['_um_access_hierarchical'] ) ? 0 : $data['_um_access_hierarchical'], + 'conditional' => array( '_um_custom_access_settings', '=', '1' ) + ); + } UM()->admin_forms( array( 'class' => 'um-restrict-content um-third-column', diff --git a/includes/admin/templates/role/role-edit.php b/includes/admin/templates/role/role-edit.php index 9cd4b9cf..47bd571b 100644 --- a/includes/admin/templates/role/role-edit.php +++ b/includes/admin/templates/role/role-edit.php @@ -59,64 +59,77 @@ if ( ! empty( $_GET['id'] ) ) { if ( ! empty( $_POST['role'] ) ) { - $data = $_POST['role']; - $id = ''; $redirect = ''; $error = ''; - if ( empty( $data['name'] ) ) { - - $error .= __( 'Title is empty!', 'ultimate-member' ) . '
'; - - } else { - - if ( 'add' == $_GET['tab'] ) { - - if ( preg_match( "/[a-z0-9]+$/i", $data['name'] ) ) { - $id = sanitize_title( $data['name'] ); - } else { - $auto_increment = UM()->options()->get( 'custom_roles_increment' ); - $auto_increment = ! empty( $auto_increment ) ? $auto_increment : 1; - $id = 'custom_role_' . $auto_increment; - } - - $redirect = add_query_arg( array( 'page'=>'um_roles', 'tab'=>'edit', 'id'=>$id, 'msg'=>'a' ), admin_url( 'admin.php' ) ); - } elseif ( 'edit' == $_GET['tab'] && ! empty( $_GET['id'] ) ) { - $id = $_GET['id']; - $redirect = add_query_arg( array( 'page' => 'um_roles', 'tab'=>'edit', 'id'=>$id, 'msg'=>'u' ), admin_url( 'admin.php' ) ); - } - - } - - $all_roles = array_keys( get_editable_roles() ); if ( 'add' == $_GET['tab'] ) { - if ( in_array( 'um_' . $id, $all_roles ) || in_array( $id, $all_roles ) ) - $error .= __( 'Role already exists!', 'ultimate-member' ) . '
'; + if ( ! wp_verify_nonce( $_POST['um_nonce'], 'um-add-role' ) ) { + $error = __( 'Security Issue', 'ultimate-member' ) . '
'; + } + } else { + if ( ! wp_verify_nonce( $_POST['um_nonce'], 'um-edit-role' ) ) { + $error = __( 'Security Issue', 'ultimate-member' ) . '
'; + } } - if ( '' == $error ) { + if ( empty( $error ) ) { - if ( 'add' == $_GET['tab'] ) { - $roles = get_option( 'um_roles' ); - $roles[] = $id; + $data = $_POST['role']; - update_option( 'um_roles', $roles ); + if ( empty( $data['name'] ) ) { - if ( isset( $auto_increment ) ) { - $auto_increment++; - UM()->options()->update( 'custom_roles_increment', $auto_increment ); + $error .= __( 'Title is empty!', 'ultimate-member' ) . '
'; + + } else { + + if ( 'add' == $_GET['tab'] ) { + + if ( preg_match( "/[a-z0-9]+$/i", $data['name'] ) ) { + $id = sanitize_title( $data['name'] ); + } else { + $auto_increment = UM()->options()->get( 'custom_roles_increment' ); + $auto_increment = ! empty( $auto_increment ) ? $auto_increment : 1; + $id = 'custom_role_' . $auto_increment; + } + + $redirect = add_query_arg( array( 'page'=>'um_roles', 'tab'=>'edit', 'id'=>$id, 'msg'=>'a' ), admin_url( 'admin.php' ) ); + } elseif ( 'edit' == $_GET['tab'] && ! empty( $_GET['id'] ) ) { + $id = $_GET['id']; + $redirect = add_query_arg( array( 'page' => 'um_roles', 'tab'=>'edit', 'id'=>$id, 'msg'=>'u' ), admin_url( 'admin.php' ) ); } + } - $role_meta = $data; - unset( $role_meta['id'] ); + $all_roles = array_keys( get_editable_roles() ); + if ( 'add' == $_GET['tab'] ) { + if ( in_array( 'um_' . $id, $all_roles ) || in_array( $id, $all_roles ) ) + $error .= __( 'Role already exists!', 'ultimate-member' ) . '
'; + } - update_option( "um_role_{$id}_meta", $role_meta ); + if ( '' == $error ) { - UM()->user()->remove_cache_all_users(); + if ( 'add' == $_GET['tab'] ) { + $roles = get_option( 'um_roles' ); + $roles[] = $id; - um_js_redirect( $redirect ); + update_option( 'um_roles', $roles ); + + if ( isset( $auto_increment ) ) { + $auto_increment++; + UM()->options()->update( 'custom_roles_increment', $auto_increment ); + } + } + + $role_meta = $data; + unset( $role_meta['id'] ); + + update_option( "um_role_{$id}_meta", $role_meta ); + + UM()->user()->remove_cache_all_users(); + + um_js_redirect( $redirect ); + } } } @@ -158,8 +171,10 @@ $screen_id = $current_screen->id; ?> + +
diff --git a/includes/core/class-access.php b/includes/core/class-access.php index b009a529..b4ebd455 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -1227,7 +1227,7 @@ if ( ! class_exists( 'um\core\Access' ) ) { } } - $has_thumbnail = apply_filters("um_restrict_post_thumbnail", $has_thumbnail, $post, $thumbnail_id ); + $has_thumbnail = apply_filters( 'um_restrict_post_thumbnail', $has_thumbnail, $post, $thumbnail_id ); return $has_thumbnail; } diff --git a/includes/core/class-enqueue.php b/includes/core/class-enqueue.php index 21639b51..2aa1e5f2 100644 --- a/includes/core/class-enqueue.php +++ b/includes/core/class-enqueue.php @@ -109,7 +109,7 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) { wp_register_script( 'um-gdpr', $this->js_baseurl . 'um-gdpr' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, false ); wp_register_script('um_conditional', $this->js_baseurl . 'um-conditional' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true ); - wp_register_script('um_scripts', $this->js_baseurl . 'um-scripts' . $this->suffix . '.js', array( 'jquery', 'wp-util', 'um_conditional', 'um_datetime', 'um_datetime_date', 'um_datetime_time', 'um_datetime_legacy' ), ultimatemember_version, true ); + wp_register_script('um_scripts', $this->js_baseurl . 'um-scripts' . $this->suffix . '.js', array( 'jquery', 'wp-util', 'um_conditional', 'um_datetime', 'um_datetime_date', 'um_datetime_time', 'um_datetime_legacy', 'select2' ), ultimatemember_version, true ); /** * UM hook * diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index 9cd78786..f107bddc 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -867,24 +867,6 @@ if ( ! class_exists( 'um\core\Fields' ) ) { if ( ! $field_value ) { $field_value = 0; } - - - // Support for the old user tags values - if( is_numeric( $value ) && is_array( $field_value ) ) { - $type = UM()->fields()->get_field_type( $key ); - if( $type === 'user_tags' ) { - foreach( $field_value as $k => $v ) { - if( is_numeric( $value ) && is_string( $v ) ) { - $term = get_term_by( 'slug', $v, 'um_user_tag' ); - if( $term ) { - $field_value[ $k ] = $term->term_id; - } - } - } - } - } - - if ( $key == 'role' ) { @@ -897,6 +879,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) { } } + /** * UM hook * @@ -905,7 +888,8 @@ if ( ! class_exists( 'um\core\Fields' ) ) { * @description Change is selected filter value * @input_vars * [{"var":"$value","type":"string","desc":"Selected filter value"}, - * {"var":"$key","type":"string","desc":"Selected filter key"}] + * {"var":"$key","type":"string","desc":"Selected filter key"}, + * {"var":"$value","type":"string","desc":"Selected filter value"}] * @change_log * ["Since: 2.0"] * @usage add_filter( 'um_is_selected_filter_value', 'function_name', 10, 2 ); @@ -918,7 +902,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) { * } * ?> */ - $field_value = apply_filters( 'um_is_selected_filter_value', $field_value, $key ); + $field_value = apply_filters( 'um_is_selected_filter_value', $field_value, $key, $value ); /** * UM hook diff --git a/includes/core/um-filters-fields.php b/includes/core/um-filters-fields.php index 66c87e88..c48f0eb0 100644 --- a/includes/core/um-filters-fields.php +++ b/includes/core/um-filters-fields.php @@ -521,15 +521,16 @@ add_filter('um_profile_field_filter_hook__','um_force_utf8_fields', 9, 3 ); * @uses hook filter: um_is_selected_filter_value */ function um_is_selected_filter_value( $value ) { - if ( ! UM()->options()->get('um_force_utf8_strings') ) + if ( ! UM()->options()->get( 'um_force_utf8_strings' ) ) { return $value; + } $value = um_force_utf8_string( $value ); return $value; } -add_filter( 'um_is_selected_filter_value','um_is_selected_filter_value', 1, 9 ); -add_filter( 'um_select_dropdown_dynamic_option_value','um_is_selected_filter_value', 1, 10 ); +add_filter( 'um_is_selected_filter_value','um_is_selected_filter_value', 9, 1 ); +add_filter( 'um_select_dropdown_dynamic_option_value','um_is_selected_filter_value', 10, 1 ); /** * Filter select dropdown to use UTF-8 encoding @@ -539,9 +540,10 @@ add_filter( 'um_select_dropdown_dynamic_option_value','um_is_selected_filter_val * @return array * @uses hook filter: um_select_dropdown_dynamic_options */ -function um_select_dropdown_dynamic_options_to_utf8( $options, $data ){ - if ( ! UM()->options()->get( 'um_force_utf8_strings' ) ) +function um_select_dropdown_dynamic_options_to_utf8( $options, $data ) { + if ( ! UM()->options()->get( 'um_force_utf8_strings' ) ) { return $options; + } foreach ( $options as $key => $value ) { $options[ $key ] = um_force_utf8_string( $value ); @@ -549,7 +551,7 @@ function um_select_dropdown_dynamic_options_to_utf8( $options, $data ){ return $options; } -add_filter( 'um_select_dropdown_dynamic_options','um_select_dropdown_dynamic_options_to_utf8', 2, 10 ); +add_filter( 'um_select_dropdown_dynamic_options','um_select_dropdown_dynamic_options_to_utf8', 10, 2 ); /** @@ -580,12 +582,8 @@ add_filter( 'um_field_non_utf8_value', 'um_field_non_utf8_value' ); * @uses hook filter: um_select_dropdown_dynamic_options, um_multiselect_options */ function um_select_dropdown_dynamic_callback_options( $options, $data ) { - - if( isset( $data['custom_dropdown_options_source'] ) && ! empty( $data['custom_dropdown_options_source'] ) ){ - - if( function_exists( $data['custom_dropdown_options_source'] ) ){ - $options = call_user_func( $data['custom_dropdown_options_source'] ); - } + if ( ! empty( $data['custom_dropdown_options_source'] ) && function_exists( $data['custom_dropdown_options_source'] ) ) { + $options = call_user_func( $data['custom_dropdown_options_source'] ); } return $options; @@ -604,7 +602,7 @@ add_filter( 'um_multiselect_options','um_select_dropdown_dynamic_callback_option */ function um_option_match_callback_view_field( $value, $data ) { - if( ! empty( $data['custom_dropdown_options_source'] ) ){ + if ( ! empty( $data['custom_dropdown_options_source'] ) ) { return UM()->fields()->get_option_value_from_callback( $value, $data, $data['type'] ); }