From 36268e85babfdcfd424bb4ad549eca35baf105f0 Mon Sep 17 00:00:00 2001 From: ashubawork Date: Tue, 23 May 2023 18:25:53 +0300 Subject: [PATCH 01/39] - add default sorting --- includes/admin/class-admin.php | 6 ++++ .../admin/templates/directory/sorting.php | 33 +++++++++++++++++++ includes/core/class-fields.php | 2 ++ includes/core/class-member-directory.php | 7 ++-- 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/includes/admin/class-admin.php b/includes/admin/class-admin.php index b6c7bbaf..742e2015 100644 --- a/includes/admin/class-admin.php +++ b/includes/admin/class-admin.php @@ -389,6 +389,12 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { '_um_sortby_custom_label' => array( 'sanitize' => 'text', ), + '_um_sortby_custom_type' => array( + 'sanitize' => 'text', + ), + '_um_sortby_custom_order' => array( + 'sanitize' => 'text', + ), '_um_enable_sorting' => array( 'sanitize' => 'bool', ), diff --git a/includes/admin/templates/directory/sorting.php b/includes/admin/templates/directory/sorting.php index b7f7832a..6a33522b 100644 --- a/includes/admin/templates/directory/sorting.php +++ b/includes/admin/templates/directory/sorting.php @@ -7,6 +7,18 @@ global $post_id; $_um_sorting_fields = get_post_meta( $post_id, '_um_sorting_fields', true ); $_um_sorting_fields = empty( $_um_sorting_fields ) ? array() : $_um_sorting_fields; +$custom_type_options = array( + 'CHAR' => 'CHAR', + 'NUMERIC' => 'NUMERIC', + 'BINARY' => 'BINARY', + 'DATE' => 'DATE', + 'DATETIME' => 'DATETIME', + 'DECIMAL' => 'DECIMAL', + 'SIGNED' => 'SIGNED', + 'TIME' => 'TIME', + 'UNSIGNED' => 'UNSIGNED', +); + $fields = array( array( 'id' => '_um_sortby', @@ -24,6 +36,27 @@ $fields = array( 'value' => UM()->query()->get_meta_value( '_um_sortby_custom', null, 'na' ), 'conditional' => array( '_um_sortby', '=', 'other' ), ), + array( + 'id' => '_um_sortby_custom_type', + 'type' => 'select', + 'label' => __( 'Data type', 'ultimate-member' ), + 'tooltip' => __( 'To correct sort by a custom field, choose a data type', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_sortby_custom_type', null, 'CHAR' ), + 'options' => $custom_type_options, + 'conditional' => array( '_um_sortby', '=', 'other' ), + ), + array( + 'id' => '_um_sortby_custom_order', + 'type' => 'select', + 'label' => __( 'Order', 'ultimate-member' ), + 'tooltip' => __( 'To correct sort by a custom field, choose an order', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_sortby_custom_order', null, 'ASC' ), + 'options' => array( + 'ASC' => 'ASC', + 'DESC' => 'DESC', + ), + 'conditional' => array( '_um_sortby', '=', 'other' ), + ), array( 'id' => '_um_sortby_custom_label', 'type' => 'text', diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index 596b9052..34930ce5 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -388,6 +388,8 @@ if ( ! class_exists( 'um\core\Fields' ) ) { } update_post_meta( $directory_id, '_um_sortby_custom', '' ); update_post_meta( $directory_id, '_um_sortby_custom_label', '' ); + update_post_meta( $directory_id, '_um_sortby_custom_type', '' ); + update_post_meta( $directory_id, '_um_sortby_custom_order', '' ); } } diff --git a/includes/core/class-member-directory.php b/includes/core/class-member-directory.php index b04cbca9..090a5bdf 100644 --- a/includes/core/class-member-directory.php +++ b/includes/core/class-member-directory.php @@ -1423,7 +1423,8 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) { } elseif ( ( ! empty( $directory_data['sortby_custom'] ) && $sortby == $directory_data['sortby_custom'] ) || in_array( $sortby, $custom_sort ) ) { - $custom_sort_type = apply_filters( 'um_member_directory_custom_sorting_type', 'CHAR', $sortby, $directory_data ); + $custom_sort_type = ! empty( $directory_data['sortby_custom_type'] ) ? $directory_data['sortby_custom_type'] : 'CHAR'; + $custom_sort_type = apply_filters( 'um_member_directory_custom_sorting_type', $custom_sort_type, $sortby, $directory_data ); $this->query_args['meta_query'][] = array( 'relation' => 'OR', @@ -1438,7 +1439,9 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) { ) ); - $this->query_args['orderby'] = array( $sortby . '_cs' => 'ASC', 'user_login' => 'ASC' ); + $custom_sort_order = ! empty( $directory_data['sortby_custom_order'] ) ? $directory_data['sortby_custom_order'] : 'CHAR'; + + $this->query_args['orderby'] = array( $sortby . '_cs' => $custom_sort_order, 'user_login' => 'ASC' ); } else { From 781d21d32957ae0a6cd86f6c98e4a2ebf182c317 Mon Sep 17 00:00:00 2001 From: ashubawork Date: Wed, 24 May 2023 11:04:50 +0300 Subject: [PATCH 02/39] - for meta table --- includes/core/class-member-directory-meta.php | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/includes/core/class-member-directory-meta.php b/includes/core/class-member-directory-meta.php index 268934ed..0b3809fb 100644 --- a/includes/core/class-member-directory-meta.php +++ b/includes/core/class-member-directory-meta.php @@ -144,10 +144,10 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) { global $wpdb; $result = $wpdb->get_var( $wpdb->prepare( - "SELECT umeta_id - FROM {$wpdb->prefix}um_metadata - WHERE user_id = %d AND - um_key = %s + "SELECT umeta_id + FROM {$wpdb->prefix}um_metadata + WHERE user_id = %d AND + um_key = %s LIMIT 1", $object_id, $meta_key @@ -517,7 +517,7 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) { $this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_general ON umm_general.user_id = u.ID"; $this->general_meta_joined = true; } - $this->where_clauses[] = "( umm_general.um_key = 'um_member_directory_data' AND + $this->where_clauses[] = "( umm_general.um_key = 'um_member_directory_data' AND umm_general.um_value LIKE '%s:14:\"account_status\";s:8:\"approved\";%' AND umm_general.um_value LIKE '%s:15:\"hide_in_members\";b:0;%'{$profile_photo_where}{$cover_photo_where} )"; } else { if ( ! empty( $cover_photo_where ) || ! empty( $profile_photo_where ) ) { @@ -697,9 +697,15 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) { $this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = '{$sortby}' )"; - $custom_sort_type = apply_filters( 'um_member_directory_custom_sorting_type', 'CHAR', $sortby, $directory_data ); + $custom_sort_type = ! empty( $directory_data['sortby_custom_type'] ) ? $directory_data['sortby_custom_type'] : 'CHAR'; + if ( 'NUMERIC' === $custom_sort_type ) { + $custom_sort_type = 'DECIMAL'; + } + $custom_sort_type = apply_filters( 'um_member_directory_custom_sorting_type', $custom_sort_type, $sortby, $directory_data ); - $this->sql_order = " ORDER BY CAST( umm_sort.um_value AS {$custom_sort_type} ) {$order} "; + $custom_sort_order = ! empty( $directory_data['sortby_custom_order'] ) ? $directory_data['sortby_custom_order'] : 'CHAR'; + + $this->sql_order = " ORDER BY CAST( umm_sort.um_value AS {$custom_sort_type} ) {$custom_sort_order} "; } elseif ( count( $numeric_sorting_keys ) && in_array( $sortby, $numeric_sorting_keys ) ) { From 65a25da89cf3243ffb3c142b419c1b7732f44e78 Mon Sep 17 00:00:00 2001 From: ashubawork Date: Wed, 24 May 2023 13:31:57 +0300 Subject: [PATCH 03/39] - add sorting options in admin area --- includes/admin/assets/js/um-admin-forms.js | 15 +++++++++ includes/admin/class-admin.php | 6 ++++ includes/admin/core/class-admin-forms.php | 37 ++++++++++++++++------ includes/core/class-member-directory.php | 16 ++++++++-- 4 files changed, 63 insertions(+), 11 deletions(-) diff --git a/includes/admin/assets/js/um-admin-forms.js b/includes/admin/assets/js/um-admin-forms.js index 314d6d24..f47f8017 100644 --- a/includes/admin/assets/js/um-admin-forms.js +++ b/includes/admin/assets/js/um-admin-forms.js @@ -250,6 +250,21 @@ jQuery(document).ready( function() { '' + wp.i18n.__( 'Remove', 'ultimate-member' ) + '' + '' + '' + + '' + + '' + '' + ''; list.append( html ); diff --git a/includes/admin/class-admin.php b/includes/admin/class-admin.php index 742e2015..2e8b66ef 100644 --- a/includes/admin/class-admin.php +++ b/includes/admin/class-admin.php @@ -873,6 +873,12 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { if ( isset( $item['label'] ) ) { $item['label'] = sanitize_text_field( $item['label'] ); } + if ( isset( $item['order'] ) ) { + $item['order'] = sanitize_text_field( $item['order'] ); + } + if ( isset( $item['data_type'] ) ) { + $item['data_type'] = sanitize_text_field( $item['data_type'] ); + } return $item; } else { diff --git a/includes/admin/core/class-admin-forms.php b/includes/admin/core/class-admin-forms.php index 260d29a9..c5e30524 100644 --- a/includes/admin/core/class-admin-forms.php +++ b/includes/admin/core/class-admin-forms.php @@ -1590,14 +1590,18 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { if ( ! empty( $values ) && is_array( $values ) ) { foreach ( $values as $k => $value ) { - $other_key = ''; + $other_key = ''; $other_label = ''; + $other_type = ''; + $other_order = ''; if ( is_array( $value ) ) { - $keys = array_keys( $value ); + $keys = array_keys( $value ); $other_key = $keys[0]; - $labels = array_values( $value ); + $labels = array_values( $value ); $other_label = $labels[0]; + $other_type = $value['type']; + $other_order = $value['order']; } else { if ( ! in_array( $value, array_keys( $field_data['options'] ) ) ) { continue; @@ -1621,12 +1625,27 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { if ( $sorting ) { $html .= ''; } - $html .= " - - " . __( 'Remove', 'ultimate-member' ) . " - - - "; + $html .= ' + + ' . __( 'Remove', 'ultimate-member' ) . ' + + + + + '; } } elseif ( ! empty( $field_data['show_default_number'] ) && is_numeric( $field_data['show_default_number'] ) && $field_data['show_default_number'] > 0 ) { $i = 0; diff --git a/includes/core/class-member-directory.php b/includes/core/class-member-directory.php index 090a5bdf..448a1f75 100644 --- a/includes/core/class-member-directory.php +++ b/includes/core/class-member-directory.php @@ -210,7 +210,6 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) { if ( ! empty( $value ) && in_array( $key, array( '_um_view_types', '_um_roles', '_um_roles_can_search', '_um_roles_can_filter' ), true ) ) { $value = array_keys( $value ); } elseif ( '_um_search_filters' === $key ) { - $temp_value = array(); if ( ! empty( $value ) ) { @@ -264,8 +263,17 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) { if ( ! empty( $other_data[ $k ]['label'] ) ) { $metalabel = wp_strip_all_tags( $other_data[ $k ]['label'] ); } + if ( ! empty( $other_data[ $k ]['data_type'] ) ) { + $data_type = sanitize_text_field( $other_data[ $k ]['data_type'] ); + } + if ( ! empty( $other_data[ $k ]['order'] ) ) { + $order = sanitize_text_field( $other_data[ $k ]['order'] ); + } $row = array( - $metakey => ! empty( $metalabel ) ? $metalabel : $metakey, + $metakey => $metakey, + 'label' => ! empty( $metalabel ) ? $metalabel : $metakey, + 'type' => ! empty( $data_type ) ? $data_type : '', + 'order' => ! empty( $order ) ? $order : '', ); } } @@ -275,6 +283,10 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) { $value = sanitize_text_field( $value ); } elseif ( '_um_sortby_custom_label' === $key ) { $value = wp_strip_all_tags( $value ); + } elseif ( '_um_sortby_custom_type' === $key ) { + $value = sanitize_text_field( $value ); + } elseif ( '_um_sortby_custom_order' === $key ) { + $value = sanitize_text_field( $value ); } } From 995c07d76a8478f57c3dab7052c138d307f45e24 Mon Sep 17 00:00:00 2001 From: ashubawork Date: Wed, 24 May 2023 15:24:29 +0300 Subject: [PATCH 04/39] - sorting in member directory --- includes/core/class-member-directory.php | 39 +++++++++++++++++------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/includes/core/class-member-directory.php b/includes/core/class-member-directory.php index 448a1f75..231f44dd 100644 --- a/includes/core/class-member-directory.php +++ b/includes/core/class-member-directory.php @@ -1434,26 +1434,40 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) { unset( $this->query_args['order'] ); } elseif ( ( ! empty( $directory_data['sortby_custom'] ) && $sortby == $directory_data['sortby_custom'] ) || in_array( $sortby, $custom_sort ) ) { + $custom_sort_order = ! empty( $directory_data['sortby_custom_order'] ) ? $directory_data['sortby_custom_order'] : 'CHAR'; $custom_sort_type = ! empty( $directory_data['sortby_custom_type'] ) ? $directory_data['sortby_custom_type'] : 'CHAR'; + if ( ! empty( $directory_data['sorting_fields'] ) ) { + // phpcs:disable WordPress.Security.NonceVerification -- already verified here + $sorting = sanitize_text_field( $_POST['sorting'] ); + $sorting_fields = unserialize( $directory_data['sorting_fields'] ); + // phpcs:enable WordPress.Security.NonceVerification + foreach ( $sorting_fields as $field ) { + if ( isset( $field[ $sorting ] ) ) { + $custom_sort_type = $field['type']; + $custom_sort_order = $field['order']; + } + } + } $custom_sort_type = apply_filters( 'um_member_directory_custom_sorting_type', $custom_sort_type, $sortby, $directory_data ); $this->query_args['meta_query'][] = array( - 'relation' => 'OR', + 'relation' => 'OR', $sortby . '_cs' => array( - 'key' => $sortby, - 'compare' => 'EXISTS', - 'type' => $custom_sort_type, + 'key' => $sortby, + 'compare' => 'EXISTS', + 'type' => $custom_sort_type, ), array( - 'key' => $sortby, - 'compare' => 'NOT EXISTS', - ) + 'key' => $sortby, + 'compare' => 'NOT EXISTS', + ), ); - $custom_sort_order = ! empty( $directory_data['sortby_custom_order'] ) ? $directory_data['sortby_custom_order'] : 'CHAR'; - - $this->query_args['orderby'] = array( $sortby . '_cs' => $custom_sort_order, 'user_login' => 'ASC' ); + $this->query_args['orderby'] = array( + $sortby . '_cs' => $custom_sort_order, + 'user_login' => 'ASC', + ); } else { @@ -2629,7 +2643,10 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) { add_filter( 'get_meta_sql', array( &$this, 'change_meta_sql' ), 10, 6 ); add_filter( 'pre_user_query', array( &$this, 'pagination_changes' ), 10, 1 ); - +//echo '
';
+//print_r($this->query_args);
+//echo '
'; +//exit(); $user_query = new \WP_User_Query( $this->query_args ); remove_filter( 'pre_user_query', array( &$this, 'pagination_changes' ), 10 ); From e4c30a472ef2178d0a3ec3e85e41c1410963fccb Mon Sep 17 00:00:00 2001 From: ashubawork Date: Wed, 24 May 2023 15:45:27 +0300 Subject: [PATCH 05/39] - sorting for meta table --- includes/core/class-member-directory-meta.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/includes/core/class-member-directory-meta.php b/includes/core/class-member-directory-meta.php index 0b3809fb..4b616a69 100644 --- a/includes/core/class-member-directory-meta.php +++ b/includes/core/class-member-directory-meta.php @@ -694,17 +694,28 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) { // handle sorting options // sort members by if ( $sortby == $directory_data['sortby_custom'] || in_array( $sortby, $custom_sort ) ) { + $custom_sort_order = ! empty( $directory_data['sortby_custom_order'] ) ? $directory_data['sortby_custom_order'] : 'CHAR'; $this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = '{$sortby}' )"; $custom_sort_type = ! empty( $directory_data['sortby_custom_type'] ) ? $directory_data['sortby_custom_type'] : 'CHAR'; + if ( ! empty( $directory_data['sorting_fields'] ) ) { + // phpcs:disable WordPress.Security.NonceVerification -- already verified here + $sorting = sanitize_text_field( $_POST['sorting'] ); + $sorting_fields = unserialize( $directory_data['sorting_fields'] ); + // phpcs:enable WordPress.Security.NonceVerification + foreach ( $sorting_fields as $field ) { + if ( isset( $field[ $sorting ] ) ) { + $custom_sort_type = $field['type']; + $custom_sort_order = $field['order']; + } + } + } if ( 'NUMERIC' === $custom_sort_type ) { $custom_sort_type = 'DECIMAL'; } $custom_sort_type = apply_filters( 'um_member_directory_custom_sorting_type', $custom_sort_type, $sortby, $directory_data ); - $custom_sort_order = ! empty( $directory_data['sortby_custom_order'] ) ? $directory_data['sortby_custom_order'] : 'CHAR'; - $this->sql_order = " ORDER BY CAST( umm_sort.um_value AS {$custom_sort_type} ) {$custom_sort_order} "; } elseif ( count( $numeric_sorting_keys ) && in_array( $sortby, $numeric_sorting_keys ) ) { From 568b56d267841e39927ba2b01d3398fefd83c92a Mon Sep 17 00:00:00 2001 From: ashubawork Date: Wed, 24 May 2023 16:18:08 +0300 Subject: [PATCH 06/39] - fix small errors --- includes/admin/assets/css/um-admin-forms.css | 8 ++++ includes/admin/assets/js/um-admin-forms.js | 10 ++-- includes/admin/core/class-admin-forms.php | 48 ++++++++++++-------- 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/includes/admin/assets/css/um-admin-forms.css b/includes/admin/assets/css/um-admin-forms.css index 36692707..6beb8ecf 100644 --- a/includes/admin/assets/css/um-admin-forms.css +++ b/includes/admin/assets/css/um-admin-forms.css @@ -146,6 +146,14 @@ textarea.um-forms-field.um-small-field { flex: 0.9; } +.um-multi-selects-option-line .um-field-wrapper.um-custom-order-fields label select{ + width: auto; + display: inline; + font-weight: normal; + max-width: 70%; + flex: 0.9; +} + .um-multi-selects-option-line.um-admin-drag-fld .um-field-wrapper { width: calc( 100% - 90px ); } diff --git a/includes/admin/assets/js/um-admin-forms.js b/includes/admin/assets/js/um-admin-forms.js index f47f8017..74d47bcc 100644 --- a/includes/admin/assets/js/um-admin-forms.js +++ b/includes/admin/assets/js/um-admin-forms.js @@ -250,7 +250,7 @@ jQuery(document).ready( function() { '' + wp.i18n.__( 'Remove', 'ultimate-member' ) + '' + '' + '' + - '' + '' + '' + '' + @@ -260,11 +260,11 @@ jQuery(document).ready( function() { '' + '' + '' + - '' + - '' + + '' + + '' + '' + ''; list.append( html ); @@ -274,6 +274,8 @@ jQuery(document).ready( function() { jQuery( '#' + list.data('id_attr') + '-' + k ).parents('li').find('.um-field-wrapper.um-custom-order-fields input[name="meta_key"]').attr('name', 'um_metadata[_um_sorting_fields][other_data][' + k + '][meta_key]'); jQuery( '#' + list.data('id_attr') + '-' + k ).parents('li').find('.um-field-wrapper.um-custom-order-fields input[name="label"]').attr('name', 'um_metadata[_um_sorting_fields][other_data][' + k + '][label]'); + jQuery( '#' + list.data('id_attr') + '-' + k ).parents('li').find('.um-field-wrapper.um-custom-order-fields select[name="data_type"]').attr('name', 'um_metadata[_um_sorting_fields][other_data][' + k + '][data_type]'); + jQuery( '#' + list.data('id_attr') + '-' + k ).parents('li').find('.um-field-wrapper.um-custom-order-fields select[name="order"]').attr('name', 'um_metadata[_um_sorting_fields][other_data][' + k + '][order]'); }); diff --git a/includes/admin/core/class-admin-forms.php b/includes/admin/core/class-admin-forms.php index c5e30524..68995432 100644 --- a/includes/admin/core/class-admin-forms.php +++ b/includes/admin/core/class-admin-forms.php @@ -1594,14 +1594,24 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { $other_label = ''; $other_type = ''; $other_order = ''; + if ( is_array( $value ) ) { $keys = array_keys( $value ); $other_key = $keys[0]; - $labels = array_values( $value ); - $other_label = $labels[0]; - $other_type = $value['type']; - $other_order = $value['order']; + if ( ! empty( $value['label'] ) ) { + $other_label = $value['label']; + } else { + $labels = array_values( $value ); + $other_label = $labels[0]; + } + + if ( ! empty( $value['type'] ) ) { + $other_type = $value['type']; + } + if ( ! empty( $value['order'] ) ) { + $other_order = $value['order']; + } } else { if ( ! in_array( $value, array_keys( $field_data['options'] ) ) ) { continue; @@ -1629,21 +1639,21 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { ' . __( 'Remove', 'ultimate-member' ) . ' - - + + '; } From 3ab36c082dbd3416c34293ea145e64ab5a620563 Mon Sep 17 00:00:00 2001 From: Mykyta Synelnikov Date: Thu, 1 Jun 2023 11:30:00 +0300 Subject: [PATCH 07/39] - fixed PHP notice; --- includes/core/class-fields.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index 3b197db9..acbaa197 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -2814,7 +2814,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) { $output .= '
'; - if ( isset( $data['html'] ) && $data['html'] != 0 && $key != "description" ) { + if ( isset( $data['html'] ) && $data['html'] != 0 && 'description' !== $key ) { $textarea_settings = array( 'media_buttons' => false, @@ -2863,7 +2863,10 @@ if ( ! class_exists( 'um\core\Fields' ) ) { $output .= ob_get_clean(); $output .= '
' . $placeholder . ''; } else { - $textarea_field_value = ! empty( $data['html'] ) ? $field_value : strip_tags( $field_value ); + $textarea_field_value = ''; + if ( ! empty( $field_value ) ) { + $textarea_field_value = ! empty( $data['html'] ) ? $field_value : wp_strip_all_tags( $field_value ); + } $output .= ''; } From d09d2091fe05d366465ef2dd2cfc3683de3e1a84 Mon Sep 17 00:00:00 2001 From: Mykyta Synelnikov Date: Mon, 5 Jun 2023 13:10:15 +0300 Subject: [PATCH 08/39] - added docs generator; --- .github/workflows/build-docs.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/build-docs.yml diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml new file mode 100644 index 00000000..4168dda6 --- /dev/null +++ b/.github/workflows/build-docs.yml @@ -0,0 +1,32 @@ +name: Build Hook Docs + +on: + push: + branches: + - master + - development/2.6.3 + +jobs: + hookdocs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - name: npm install, and build docs + run: | + npm install + npm run build:docs + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-suggest + - name: PhpDocumentor + uses: gpupo/actions-phpDocumentor@1.0 + with: + dir: './' + - name: Deploy to GH Pages + uses: JamesIves/github-pages-deploy-action@v4.3.3 + with: + branch: gh-pages # The branch the action should deploy to. + folder: 'docs/' # The folder the action should deploy. + token: ${{ secrets.GH_PAT }} From f8c0bbe28e24f31fa628906ff603ac70d123a6f6 Mon Sep 17 00:00:00 2001 From: ashubawork Date: Mon, 5 Jun 2023 13:20:53 +0300 Subject: [PATCH 09/39] - add a hook for private content --- includes/admin/core/list-tables/roles-list-table.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/admin/core/list-tables/roles-list-table.php b/includes/admin/core/list-tables/roles-list-table.php index 1ac73f4d..cd3a7edb 100644 --- a/includes/admin/core/list-tables/roles-list-table.php +++ b/includes/admin/core/list-tables/roles-list-table.php @@ -362,6 +362,8 @@ class UM_Roles_List_Table extends WP_List_Table { } } + $actions = apply_filters( 'um_role_row_actions', $actions, $id ); + return sprintf('%1$s %2$s', '' . stripslashes( $item['name'] ) . '', $this->row_actions( $actions ) ); } From 4e47afce99eae75e0df7cc84484e790f37eef7b2 Mon Sep 17 00:00:00 2001 From: Mykyta Synelnikov Date: Mon, 5 Jun 2023 13:22:44 +0300 Subject: [PATCH 10/39] - added docs generator; --- .github/hookdoc-tmpl/README.md | 7 ++ .github/hookdoc-tmpl/layout.tmpl | 46 +++++++++++ .github/hookdoc-tmpl/static/styles-um.css | 98 +++++++++++++++++++++++ composer.json | 8 +- hookdoc-conf.json | 31 +++++++ package.json | 17 ++-- phpdoc.dist.xml | 25 ++++++ 7 files changed, 226 insertions(+), 6 deletions(-) create mode 100644 .github/hookdoc-tmpl/README.md create mode 100644 .github/hookdoc-tmpl/layout.tmpl create mode 100644 .github/hookdoc-tmpl/static/styles-um.css create mode 100644 hookdoc-conf.json create mode 100644 phpdoc.dist.xml diff --git a/.github/hookdoc-tmpl/README.md b/.github/hookdoc-tmpl/README.md new file mode 100644 index 00000000..4481cbad --- /dev/null +++ b/.github/hookdoc-tmpl/README.md @@ -0,0 +1,7 @@ +# Welcome to the Ultimate Member Plugin Hook Documentation + +This resource is generated documentation on actions and filters found in the [Ultimate Member](https://wordpress.org/plugins/ultimate-member/) plugin. Use the sidebar to browse and navigate. + +For more information about using Ultimate Member with WordPress, please see the [Ultimate Member Docs](https://docs.ultimatemember.com/). + +To report an issue with Ultimate Member, please visit the [Support forum](https://wordpress.org/support/plugin/ultimate-member/). diff --git a/.github/hookdoc-tmpl/layout.tmpl b/.github/hookdoc-tmpl/layout.tmpl new file mode 100644 index 00000000..411c75fa --- /dev/null +++ b/.github/hookdoc-tmpl/layout.tmpl @@ -0,0 +1,46 @@ + + + + + <?js= title ?> - Ultimate Member Hook Docs + + + + + + + + + + + + class="home"> + +
+ + +

+ + + + + + + +
+ + + +
+ + + + + diff --git a/.github/hookdoc-tmpl/static/styles-um.css b/.github/hookdoc-tmpl/static/styles-um.css new file mode 100644 index 00000000..ed86c3c8 --- /dev/null +++ b/.github/hookdoc-tmpl/static/styles-um.css @@ -0,0 +1,98 @@ +body { + background: #fefefe; + color: #232323; + font-family: 'IBM Plex Sans', sans-serif; + font-size: 1.3rem; + font-weight: 300; +} + +h1, h2, h3 { + line-height: 1.2; + font-family: 'Playfair Display', sans-serif; + font-weight: 900; + letter-spacing: -.01em; +} + +h1.page-title { + font-size: 42px; + margin-top: .5em; +} + +nav ul { + font-size: 1.2rem; +} + +nav li a { + background-image: none; +} + +nav li a:hover { + text-decoration: underline; +} + +code, pre, +nav ul a, nav ul a:visited, nav ul a:active, +.name, .signature, +.params .name, .props .name, +.name code { + font-family: 'IBM Plex Mono', monospace; +} + +article h1 { + margin: 12px 0 32px; +} + +a { + background-image: linear-gradient(transparent calc(100% - 7px), #f2dede 0), + linear-gradient(transparent calc(100% - 7px), #cef8f7 0); + background-position: 0 0; + background-repeat: no-repeat; + background-size: 0 100%, 100% 100%; + color: #232323; + text-decoration: none; + transition: all .1s; +} + +a:visited, +a:active { + color: #232323; +} + +a:focus, +a:hover { + background-size: 100% 100%, 100% 100%; + color: #232323; + text-decoration: none; +} + +a.banner { + background-image: none; + margin-left: -10px; +} + +a.banner img { + width: 100%; + max-width: 888px; +} + +footer { + text-align: center; + font-size: .8em; + font-style: normal; + font-weight: 300; +} + +.home #main > section:first-of-type, +.home nav > h2 { + display: none; +} + +.prettyprint.source { + font-size: 14px; +} + +.prettyprint code { + padding: 2px 10px; + line-height: 16px; + height: 16px; +} diff --git a/composer.json b/composer.json index e309c5c1..9b5aae8f 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,12 @@ "license": "GPL-3.0-or-later", "minimum-stability": "stable", "prefer-stable": true, + "config": { + "allow-plugins": { + "symfony/flex": true, + "dealerdirect/phpcodesniffer-composer-installer": true + } + }, "require": { "ext-mbstring": "*", "ext-json": "*", @@ -18,7 +24,7 @@ "woocommerce/action-scheduler": "3.2.1" }, "require-dev": { - "roave/security-advisories": "dev-master", + "roave/security-advisories": "dev-latest", "wp-cli/wp-cli": "*", "dealerdirect/phpcodesniffer-composer-installer": "^0.7.1", "object-calisthenics/phpcs-calisthenics-rules": "*", diff --git a/hookdoc-conf.json b/hookdoc-conf.json new file mode 100644 index 00000000..5e3a6944 --- /dev/null +++ b/hookdoc-conf.json @@ -0,0 +1,31 @@ +{ + "opts": { + "destination": "docs/hooks", + "template": "node_modules/wp-hookdoc/template", + "recurse": true, + "readme": "./.github/hookdoc-tmpl/README.md" + }, + "source": { + "include": [ + "./" + ], + "exclude": [ + "node_modules" + ], + "includePattern": ".+\\.(php)?$" + }, + "plugins": [ + "node_modules/wp-hookdoc/plugin", + "plugins/markdown" + ], + "templates": { + "default": { + "layoutFile": "./.github/hookdoc-tmpl/layout.tmpl", + "staticFiles": { + "include": [ + "./.github/hookdoc-tmpl/static" + ] + } + } + } +} diff --git a/package.json b/package.json index ce1525b8..d08fe57d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,11 @@ { - "name": "roots", - "version": "7.0.3", - "author": "Ben Word ", + "name": "ultimate-member", + "version": "2.6.3", + "author": { + "name": "Ultimate Member", + "email": "team@ultimatemember.com", + "url": "https://ultimatemember.com" + }, "homepage": "http://roots.io", "repository": { "type": "git", @@ -17,7 +21,7 @@ } ], "scripts": { - "postinstall": "node node_modules/bower/bin/bower install && grunt dev", + "build:docs": "rm -rf docs/hooks/ && jsdoc -c hookdoc-conf.json", "build": "npm-run-all build:*", "build:all-blocks": "npm-run-all --parallel build-block-*", "build-block-um-member-directories": "cd includes/blocks/um-member-directories && wp-scripts build src/index.js", @@ -36,6 +40,8 @@ "gulp-sass": "^5.1.0", "gulp-uglify": "^3.0.2", "gulp-clean-css": "^4.3.0", + "jsdoc": "~4.0.2", + "wp-hookdoc": "^0.2.0", "npm-run-all": "^4.1.5", "@wordpress/block-editor": "^11.5.0", "@wordpress/blocks": "^12.5.0", @@ -45,6 +51,7 @@ "@wordpress/server-side-render": "^4.5.0" }, "dependencies": { - "react": "^18.2.0" + "react": "^18.2.0", + "taffydb": "^2.7.3" } } diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml new file mode 100644 index 00000000..2fb02cab --- /dev/null +++ b/phpdoc.dist.xml @@ -0,0 +1,25 @@ + + + Ultimate Member - PHPDoc + + docs/phpdoc + docs/phpdoc/cache + + + latest + + + includes + templates + + + php + + + +