From e6526654e9cda78de70d1797abdfc7064bc34ba0 Mon Sep 17 00:00:00 2001 From: nikitasinelnikov Date: Thu, 23 Mar 2017 17:55:43 +0200 Subject: [PATCH 01/10] Added H2 for UltimateMember section to Add/Edit User Form --- core/um-user.php | 1 + 1 file changed, 1 insertion(+) diff --git a/core/um-user.php b/core/um-user.php index e4cdef05..c8cc83a4 100644 --- a/core/um-user.php +++ b/core/um-user.php @@ -61,6 +61,7 @@ class UM_User { $um_user_role = get_user_meta($user->ID,'role',true); ?> +

From 6a07b50321f4742af2074fe62042cdd817ca347e Mon Sep 17 00:00:00 2001 From: nikitasinelnikov Date: Thu, 23 Mar 2017 20:25:41 +0200 Subject: [PATCH 02/10] Fix for Content Availability js added data and classes for conditional wrapper --- admin/core/um-admin-actions.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/admin/core/um-admin-actions.php b/admin/core/um-admin-actions.php index 6f5f44ce..b99f9a5e 100644 --- a/admin/core/um-admin-actions.php +++ b/admin/core/um-admin-actions.php @@ -71,10 +71,10 @@ } - function um_category_access_fields_create( $term ){ + function um_category_access_fields_create( $term ) { global $ultimatemember; - echo '
'; + echo '
'; echo ''; echo ' @@ -98,7 +98,8 @@ } - function um_category_access_fields_edit( $term ){ + + function um_category_access_fields_edit( $term ) { global $ultimatemember; $termID = $term->term_id; @@ -107,7 +108,7 @@ $_um_redirect= (isset( $termMeta['_um_redirect'] ) )? $termMeta['_um_redirect'] : ''; $_um_roles= (isset( $termMeta['_um_roles'] ) )? $termMeta['_um_roles'] : ''; - echo "
"; + echo ''; echo ""; echo '"; - } + function um_category_access_fields_save( $termID ){ if ( isset( $_POST['_um_accessible'] ) ) { From f378e81e5383732574a1d974bc3c49f20fa56635 Mon Sep 17 00:00:00 2001 From: nikitasinelnikov Date: Fri, 24 Mar 2017 16:46:49 +0200 Subject: [PATCH 03/10] Added user_profile section hook do_action( 'um_user_profile_section' ); --- core/um-user.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/um-user.php b/core/um-user.php index c8cc83a4..9ef6c651 100644 --- a/core/um-user.php +++ b/core/um-user.php @@ -80,6 +80,8 @@ class UM_User {


@@ -135,9 +136,9 @@ echo ''; echo '

' . __('Users who cannot see content will get redirected to that URL.','ultimatemember') . '

'; echo "
Date: Fri, 24 Mar 2017 16:50:49 +0200 Subject: [PATCH 04/10] changes for user profile section add action to our section hook --- core/um-api.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/um-api.php b/core/um-api.php index c2d2481a..b2bdd4ef 100644 --- a/core/um-api.php +++ b/core/um-api.php @@ -20,8 +20,9 @@ class UM_REST_API { add_action( 'init', array( $this, 'add_endpoint' ) ); add_action( 'template_redirect', array( $this, 'process_query' ), -1 ); add_filter( 'query_vars', array( $this, 'query_vars' ) ); - add_action( 'show_user_profile', array( $this, 'user_key_field' ) ); - add_action( 'edit_user_profile', array( $this, 'user_key_field' ) ); + + add_action( 'um_user_profile_section', array( $this, 'user_key_field' ), 2 ); + add_action( 'personal_options_update', array( $this, 'update_key' ) ); add_action( 'edit_user_profile_update', array( $this, 'update_key' ) ); @@ -863,4 +864,4 @@ class UM_REST_API { return hash( 'md5', $user->um_user_secret_key . $user->um_user_public_key ); } -} \ No newline at end of file +} From bfb6bc460a621f7fd6bdfcfc62948c0ef958ab4a Mon Sep 17 00:00:00 2001 From: nikitasinelnikov Date: Fri, 24 Mar 2017 18:06:45 +0200 Subject: [PATCH 05/10] Enqueue js at tax pages --- admin/core/um-admin-enqueue.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/admin/core/um-admin-enqueue.php b/admin/core/um-admin-enqueue.php index c71ecae1..dbac839b 100644 --- a/admin/core/um-admin-enqueue.php +++ b/admin/core/um-admin-enqueue.php @@ -226,10 +226,10 @@ class UM_Admin_Enqueue { ***/ function is_UM_admin(){ - global $current_screen, $post; - + global $current_screen, $post, $tax; + $screen_id = $current_screen->id; - + if ( !is_admin() ) return false; if ( strstr( $screen_id, 'ultimatemember') || strstr( $screen_id, 'um_') || strstr($screen_id, 'user') || strstr($screen_id, 'profile') )return true; @@ -238,6 +238,8 @@ class UM_Admin_Enqueue { if ( isset( $post->post_type ) ) return true; + if ( isset( $tax->name ) ) return true; + return false; } @@ -290,4 +292,4 @@ class UM_Admin_Enqueue { } -} \ No newline at end of file +} From 3fdd8430739f943edb9e85ab36e24508765fc47e Mon Sep 17 00:00:00 2001 From: nikitasinelnikov Date: Fri, 24 Mar 2017 18:26:05 +0200 Subject: [PATCH 06/10] fixed redirect field for 1 and 2 accessible option --- admin/core/um-admin-actions.php | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/admin/core/um-admin-actions.php b/admin/core/um-admin-actions.php index b99f9a5e..498aa8ec 100644 --- a/admin/core/um-admin-actions.php +++ b/admin/core/um-admin-actions.php @@ -70,10 +70,10 @@ } } - - function um_category_access_fields_create( $term ) { + + function um_category_access_fields_create( $term ){ global $ultimatemember; - + echo '
'; echo ''; echo ' @@ -88,20 +88,22 @@ echo ''; } echo '

' . __('This is applicable only if you restrict the content to logged-in users.','ultimatemember') . '

'; + echo ''; + echo ''; + echo '

' . __('Users who cannot see content will get redirected to that URL.','ultimatemember') . '

'; echo '
'; echo '
'; echo ''; - echo ''; + echo ''; echo '

' . __('Users who cannot see content will get redirected to that URL.','ultimatemember') . '

'; echo '
'; } - - function um_category_access_fields_edit( $term ) { + function um_category_access_fields_edit( $term ){ global $ultimatemember; - + $termID = $term->term_id; $termMeta = get_option( "category_$termID" ); $_um_accessible= (isset( $termMeta['_um_accessible'] ) )? $termMeta['_um_accessible'] : ''; @@ -127,18 +129,24 @@ } echo '  '; } + echo '

' . __('This is applicable only if you restrict the content to logged-in users.','ultimatemember') . '

'; + echo ""; + echo ""; + echo ""; + echo ''; + echo ''; echo '

' . __('Users who cannot see content will get redirected to that URL.','ultimatemember') . '

'; echo ""; echo ""; echo ""; echo ''; - echo ''; + echo ''; echo '

' . __('Users who cannot see content will get redirected to that URL.','ultimatemember') . '

'; echo ""; + } - function um_category_access_fields_save( $termID ){ if ( isset( $_POST['_um_accessible'] ) ) { @@ -151,6 +159,7 @@ // get value and save it into the database - maybe you have to sanitize your values (urls, etc...) $termMeta['_um_accessible'] = isset( $_POST['_um_accessible'] ) ? $_POST['_um_accessible'] : ''; $termMeta['_um_redirect'] = isset( $_POST['_um_redirect'] ) ? $_POST['_um_redirect'] : ''; + $termMeta['_um_redirect2'] = isset( $_POST['_um_redirect2'] ) ? $_POST['_um_redirect2'] : ''; $termMeta['_um_roles'] = isset( $_POST['_um_roles'] ) ? $_POST['_um_roles'] : ''; update_option( "category_$termID", $termMeta ); From 219daa6e5acc7a0118dd81e86df18fbcf07e465f Mon Sep 17 00:00:00 2001 From: nikitasinelnikov Date: Fri, 24 Mar 2017 18:28:26 +0200 Subject: [PATCH 07/10] fixed redirect field for 1 and 2 accessible option --- core/um-actions-access.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/um-actions-access.php b/core/um-actions-access.php index 25d805df..3b3fe3c7 100644 --- a/core/um-actions-access.php +++ b/core/um-actions-access.php @@ -389,8 +389,8 @@ if ( is_user_logged_in() ){ - if( isset( $opt['_um_redirect'] ) && ! empty( $opt['_um_redirect'] ) ) { - $redirect = $opt['_um_redirect']; + if( isset( $opt['_um_redirect2'] ) && ! empty( $opt['_um_redirect2'] ) ) { + $redirect = $opt['_um_redirect2']; }else{ $redirect = site_url(); } @@ -478,7 +478,7 @@ case 1: if ( is_user_logged_in() ) - $redirect = ( isset( $opt['_um_redirect'] ) && !empty( $opt['_um_redirect'] ) ) ? $opt['_um_redirect'] : site_url(); + $redirect = ( isset( $opt['_um_redirect2'] ) && !empty( $opt['_um_redirect2'] ) ) ? $opt['_um_redirect2'] : site_url(); $redirect = $ultimatemember->access->set_referer( $redirect, "categories_1" ); $ultimatemember->access->redirect_handler = $redirect; if ( !is_user_logged_in() ) @@ -566,8 +566,8 @@ if ( is_user_logged_in() ){ - if( isset( $opt['_um_redirect'] ) && ! empty( $opt['_um_redirect'] ) ) { - $redirect = $opt['_um_redirect']; + if( isset( $opt['_um_redirect2'] ) && ! empty( $opt['_um_redirect2'] ) ) { + $redirect = $opt['_um_redirect2']; }else{ $redirect = site_url(); } @@ -703,7 +703,7 @@ case 1: // Logged out users only if ( is_user_logged_in() ){ - $redirect = ( isset( $opt['_um_redirect'] ) && ! empty( $opt['_um_redirect'] ) ) ? $opt['_um_redirect'] : site_url(); + $redirect = ( isset( $opt['_um_redirect2'] ) && ! empty( $opt['_um_redirect2'] ) ) ? $opt['_um_redirect2'] : site_url(); $redirect = $ultimatemember->access->set_referer( $redirect, "page_cat_1a_t{$cat->term_id}_pt{$post_type}" ); $ultimatemember->access->redirect_handler = $redirect; $ultimatemember->access->allow_access = false; From be254c779a7f8cdb69749f951be00dc798c9e555 Mon Sep 17 00:00:00 2001 From: nikitasinelnikov Date: Fri, 24 Mar 2017 18:31:16 +0200 Subject: [PATCH 08/10] Update um-admin-actions.php --- admin/core/um-admin-actions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/admin/core/um-admin-actions.php b/admin/core/um-admin-actions.php index 498aa8ec..5ab15e7a 100644 --- a/admin/core/um-admin-actions.php +++ b/admin/core/um-admin-actions.php @@ -108,6 +108,7 @@ $termMeta = get_option( "category_$termID" ); $_um_accessible= (isset( $termMeta['_um_accessible'] ) )? $termMeta['_um_accessible'] : ''; $_um_redirect= (isset( $termMeta['_um_redirect'] ) )? $termMeta['_um_redirect'] : ''; + $_um_redirect2= (isset( $termMeta['_um_redirect2'] ) )? $termMeta['_um_redirect2'] : ''; $_um_roles= (isset( $termMeta['_um_roles'] ) )? $termMeta['_um_roles'] : ''; echo ''; @@ -141,7 +142,7 @@ echo ""; echo ""; echo ''; - echo ''; + echo ''; echo '

' . __('Users who cannot see content will get redirected to that URL.','ultimatemember') . '

'; echo ""; From 2d4b79ec0d9ba126e8b713f2f701e68b542a02df Mon Sep 17 00:00:00 2001 From: nikitasinelnikov Date: Mon, 27 Mar 2017 15:06:53 +0300 Subject: [PATCH 09/10] remove notices with PHP7.1 --- admin/core/um-admin-dragdrop.php | 141 ++++++++++++++++--------------- 1 file changed, 72 insertions(+), 69 deletions(-) diff --git a/admin/core/um-admin-dragdrop.php b/admin/core/um-admin-dragdrop.php index f38431ed..cb5f80d0 100644 --- a/admin/core/um-admin-dragdrop.php +++ b/admin/core/um-admin-dragdrop.php @@ -3,47 +3,50 @@ class UM_Admin_DragDrop { function __construct() { - + add_action('admin_footer', array(&$this, 'load_field_order'), 9); - + add_action('wp_ajax_nopriv_update_order', array(&$this, 'update_order') ); add_action('wp_ajax_update_order', array(&$this, 'update_order') ); - + } - + /*** *** @update order of fields ***/ function update_order(){ - + global $ultimatemember; - + if ( !is_user_logged_in() || !current_user_can('manage_options') ) die('Please login as administrator'); - + extract($_POST); - + $fields = $ultimatemember->query->get_attr('custom_fields', $form_id ); - - $this->row_data = get_option('um_form_rowdata_'. $form_id ); - - if( isset( $fields ) ){ - foreach( $fields as $key => $array ) { + + $this->row_data = get_option('um_form_rowdata_'. $form_id, array() ); + $this->exist_rows = array(); + + if ( ! empty( $fields ) ) { + foreach ( $fields as $key => $array ) { if ( $array['type'] == 'row' ) { $this->row_data[$key] = $array; unset( $fields[$key] ); } } - } - - foreach( $_POST as $key => $value ) { - + } else { + $fields = array(); + } + + foreach ( $_POST as $key => $value ) { + // adding rows - if (0 === strpos($key, '_um_row_')) { - + if ( 0 === strpos( $key, '_um_row_' ) ) { + $update_args = null; - + $row_id = str_replace( '_um_row_', '', $key ); - + $row_array = array( 'type' => 'row', 'id' => $value, @@ -51,9 +54,9 @@ class UM_Admin_DragDrop { 'cols' => $_POST[ '_um_rowcols_'.$row_id .'_cols' ], 'origin' => $_POST[ '_um_roworigin_'.$row_id . '_val' ], ); - + $row_args = $row_array; - + if ( isset( $this->row_data[ $row_array['origin'] ] ) ) { foreach( $this->row_data[ $row_array['origin'] ] as $k => $v ){ if ( $k != 'position' && $k != 'metakey' ) { @@ -67,91 +70,91 @@ class UM_Admin_DragDrop { } $fields[$key] = $row_args; - + } - + // change field position - if (0 === strpos($key, 'um_position_') ) { + if ( 0 === strpos( $key, 'um_position_' ) ) { $field_key = str_replace('um_position_','',$key); if ( isset( $fields[$field_key] ) ) { $fields[$field_key]['position'] = $value; } } - + // change field master row - if (0 === strpos($key, 'um_row_') ) { + if ( 0 === strpos( $key, 'um_row_' ) ) { $field_key = str_replace('um_row_','',$key); if ( isset( $fields[$field_key] ) ) { $fields[$field_key]['in_row'] = $value; } } - + // change field sub row - if (0 === strpos($key, 'um_subrow_') ) { + if ( 0 === strpos( $key, 'um_subrow_' ) ) { $field_key = str_replace('um_subrow_','',$key); if ( isset( $fields[$field_key] ) ) { $fields[$field_key]['in_sub_row'] = $value; } } - + // change field column - if (0 === strpos($key, 'um_col_') ) { + if ( 0 === strpos( $key, 'um_col_' ) ) { $field_key = str_replace('um_col_','',$key); if ( isset( $fields[$field_key] ) ) { $fields[$field_key]['in_column'] = $value; } } - + // add field to group - if (0 === strpos($key, 'um_group_') ) { + if ( 0 === strpos( $key, 'um_group_' ) ) { $field_key = str_replace('um_group_','',$key); if ( isset( $fields[$field_key] ) ) { $fields[$field_key]['in_group'] = $value; } } - + } - - foreach( $this->row_data as $k => $v ) { - if ( !in_array( $k, $this->exist_rows ) ) + + foreach ( $this->row_data as $k => $v ) { + if ( ! in_array( $k, $this->exist_rows ) ) unset( $this->row_data[$k] ); } - - update_option('um_existing_rows_' . $form_id, $this->exist_rows ); - - update_option('um_form_rowdata_' . $form_id , $this->row_data ); + + update_option( 'um_existing_rows_' . $form_id, $this->exist_rows ); + + update_option( 'um_form_rowdata_' . $form_id , $this->row_data ); $ultimatemember->query->update_attr( 'custom_fields', $form_id, $fields ); - + } - + /*** *** @load form to maintain form order ***/ function load_field_order(){ - + global $ultimatemember; - + $screen = get_current_screen(); - + if ( !isset( $screen->id ) || $screen->id != 'um_form' ) return; ?> - +
- +