diff --git a/includes/admin/class-admin.php b/includes/admin/class-admin.php
index ab49e5cb..b4a1a347 100644
--- a/includes/admin/class-admin.php
+++ b/includes/admin/class-admin.php
@@ -28,6 +28,222 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
add_action( 'admin_init', array( &$this, 'admin_init' ), 0 );
+ $prefix = is_network_admin() ? 'network_admin_' : '';
+ add_filter( "{$prefix}plugin_action_links_" . um_plugin, array( &$this, 'plugin_links' ) );
+
+ add_action( 'um_admin_do_action__user_cache', array( &$this, 'user_cache' ) );
+ add_action( 'um_admin_do_action__purge_temp', array( &$this, 'purge_temp' ) );
+ add_action( 'um_admin_do_action__duplicate_form', array( &$this, 'duplicate_form' ) );
+ add_action( 'um_admin_do_action__um_language_downloader', array( &$this, 'um_language_downloader' ) );
+ add_action( 'um_admin_do_action__um_hide_locale_notice', array( &$this, 'um_hide_notice' ) );
+ add_action( 'um_admin_do_action__um_can_register_notice', array( &$this, 'um_hide_notice' ) );
+ add_action( 'um_admin_do_action__um_hide_exif_notice', array( &$this, 'um_hide_notice' ) );
+ add_action( 'um_admin_do_action__user_action', array( &$this, 'user_action' ) );
+ }
+
+
+
+ /**
+ * Clear all users cache
+ *
+ * @param $action
+ */
+ function user_cache( $action ) {
+ global $wpdb;
+ if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
+ die();
+ }
+
+ $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" );
+
+ $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'cleared_cache' ), admin_url( 'admin.php' ) );
+ exit( wp_redirect( $url ) );
+ }
+
+
+ /**
+ * Purge temp uploads dir
+ * @param $action
+ */
+ function purge_temp( $action ) {
+ if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
+ die();
+ }
+
+ UM()->files()->remove_dir( UM()->files()->upload_temp );
+
+ $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'purged_temp' ), admin_url( 'admin.php' ) );
+ exit( wp_redirect( $url ) );
+ }
+
+
+ /**
+ * Duplicate form
+ *
+ * @param $action
+ */
+ function duplicate_form( $action ) {
+ if ( ! is_admin() || ! current_user_can('manage_options') ) die();
+ if ( ! isset( $_REQUEST['post_id'] ) || ! is_numeric( $_REQUEST['post_id'] ) ) die();
+
+ $post_id = $_REQUEST['post_id'];
+
+ $n = array(
+ 'post_type' => 'um_form',
+ 'post_title' => sprintf( __( 'Duplicate of %s', 'ultimate-member' ), get_the_title( $post_id ) ),
+ 'post_status' => 'publish',
+ 'post_author' => get_current_user_id(),
+ );
+
+ $n_id = wp_insert_post( $n );
+
+ $n_fields = get_post_custom( $post_id );
+ foreach ( $n_fields as $key => $value ) {
+
+ if ( $key == '_um_custom_fields' ) {
+ $the_value = unserialize( $value[0] );
+ } else {
+ $the_value = $value[0];
+ }
+
+ update_post_meta( $n_id, $key, $the_value );
+
+ }
+
+ delete_post_meta($n_id, '_um_core');
+
+ $url = admin_url('edit.php?post_type=um_form');
+ $url = add_query_arg('update','form_duplicated',$url);
+
+ exit( wp_redirect( $url ) );
+
+ }
+
+
+ /**
+ * Download a language remotely
+ *
+ * @param $action
+ */
+ function um_language_downloader( $action ) {
+ if ( !is_admin() || !current_user_can('manage_options') ) die();
+
+ $locale = get_option('WPLANG');
+ if ( !$locale ) return;
+ if ( !isset( UM()->available_languages[$locale] ) ) return;
+
+ $path = UM()->files()->upload_basedir;
+ $path = str_replace('/uploads/ultimatemember','',$path);
+ $path = $path . '/languages/plugins/';
+ $path = str_replace('//','/',$path);
+
+ $remote = 'https://ultimatemember.com/wp-content/languages/plugins/ultimatemember-' . $locale . '.po';
+ $remote2 = 'https://ultimatemember.com/wp-content/languages/plugins/ultimatemember-' . $locale . '.mo';
+
+ $remote_tmp = download_url( $remote, $timeout = 300 );
+ copy( $remote_tmp, $path . 'ultimatemember-' . $locale . '.po' );
+ unlink( $remote_tmp );
+
+ $remote2_tmp = download_url( $remote2, $timeout = 300 );
+ copy( $remote2_tmp, $path . 'ultimatemember-' . $locale . '.mo' );
+ unlink( $remote2_tmp );
+
+ $url = remove_query_arg('um_adm_action', UM()->permalinks()->get_current_url() );
+ $url = add_query_arg('update','language_updated',$url);
+ exit( wp_redirect($url) );
+
+ }
+
+
+ /**
+ * Action to hide notices in admin
+ *
+ * @param $action
+ */
+ function um_hide_notice( $action ) {
+ if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
+ die();
+ }
+
+ update_option( $action, 1 );
+ exit( wp_redirect( remove_query_arg( 'um_adm_action' ) ) );
+ }
+
+
+ /**
+ * Various user actions
+ *
+ * @param $action
+ */
+ function user_action( $action ) {
+ if ( !is_admin() || !current_user_can( 'edit_users' ) ) die();
+ if ( !isset( $_REQUEST['sub'] ) ) die();
+ if ( !isset($_REQUEST['user_id']) ) die();
+
+ um_fetch_user( $_REQUEST['user_id'] );
+
+ $subaction = $_REQUEST['sub'];
+
+ /**
+ * UM hook
+ *
+ * @type action
+ * @title um_admin_user_action_hook
+ * @description Action on bulk user subaction
+ * @input_vars
+ * [{"var":"$subaction","type":"string","desc":"Bulk Subaction"}]
+ * @change_log
+ * ["Since: 2.0"]
+ * @usage add_action( 'um_admin_user_action_hook', 'function_name', 10, 1 );
+ * @example
+ *
+ */
+ do_action( "um_admin_user_action_hook", $subaction );
+ /**
+ * UM hook
+ *
+ * @type action
+ * @title um_admin_user_action_{$subaction}_hook
+ * @description Action on bulk user subaction
+ * @change_log
+ * ["Since: 2.0"]
+ * @usage add_action( 'um_admin_user_action_{$subaction}_hook', 'function_name', 10 );
+ * @example
+ *
+ */
+ do_action( "um_admin_user_action_{$subaction}_hook" );
+
+ um_reset_user();
+
+ wp_redirect( add_query_arg( 'update', 'user_updated', admin_url('?page=ultimatemember') ) );
+ exit;
+
+ }
+
+
+ /**
+ * Add any custom links to plugin page
+ *
+ * @param array $links
+ *
+ * @return array
+ */
+ function plugin_links( $links ) {
+ $more_links[] = '' . __( 'Docs', 'ultimate-member' ) . '';
+ $more_links[] = '' . __( 'Settings', 'ultimate-member' ) . '';
+
+ $links = $more_links + $links;
+ return $links;
}
@@ -58,12 +274,6 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
* Init admin action/filters + request handlers
*/
function admin_init() {
- require_once 'core/um-admin-actions-user.php';
- require_once 'core/um-admin-actions-modal.php';
- require_once 'core/um-admin-actions.php';
-
- require_once 'core/um-admin-filters-fields.php';
-
if ( is_admin() && current_user_can( 'manage_options' ) && ! empty( $_REQUEST['um_adm_action'] ) ) {
/**
* UM hook
diff --git a/includes/admin/core/class-admin-builder.php b/includes/admin/core/class-admin-builder.php
index 4f1a971a..7efae58b 100644
--- a/includes/admin/core/class-admin-builder.php
+++ b/includes/admin/core/class-admin-builder.php
@@ -24,7 +24,262 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
* Admin_Builder constructor.
*/
function __construct() {
+ add_action( 'um_admin_field_modal_header', array( &$this, 'add_message_handlers' ) );
+ add_action( 'um_admin_field_modal_footer', array( &$this, 'add_conditional_support' ), 10, 4 );
+ add_filter( 'um_admin_pre_save_field_to_form', array( &$this, 'um_admin_pre_save_field_to_form' ), 1 );
+ add_filter( 'um_admin_pre_save_fields_hook', array( &$this, 'um_admin_pre_save_fields_hook' ), 1 );
+ add_filter( 'um_admin_field_update_error_handling', array( &$this, 'um_admin_field_update_error_handling' ), 1, 2 );
+ }
+
+ /**
+ * Apply a filter to handle errors for field updating in backend
+ *
+ * @param $errors
+ * @param $array
+ *
+ * @return mixed
+ */
+ function um_admin_field_update_error_handling( $errors, $array ) {
+ /**
+ * @var $field_type
+ */
+ extract( $array );
+
+ $field_attr = UM()->builtin()->get_core_field_attrs( $field_type );
+
+ if ( isset( $field_attr['validate'] ) ) {
+
+ $validate = $field_attr['validate'];
+ foreach ( $validate as $post_input => $arr ) {
+
+ $mode = $arr['mode'];
+
+ switch ( $mode ) {
+
+ case 'numeric':
+ if ( !empty( $array['post'][$post_input] ) && !is_numeric( $array['post'][$post_input] ) ){
+ $errors[$post_input] = $validate[$post_input]['error'];
+ }
+ break;
+
+ case 'unique':
+ if ( !isset( $array['post']['edit_mode'] ) ) {
+ if ( UM()->builtin()->unique_field_err( $array['post'][$post_input] ) ) {
+ $errors[$post_input] = UM()->builtin()->unique_field_err( $array['post'][$post_input] );
+ }
+ }
+ break;
+
+ case 'required':
+ if ( $array['post'][$post_input] == '' )
+ $errors[$post_input] = $validate[$post_input]['error'];
+ break;
+
+ case 'range-start':
+ if ( UM()->builtin()->date_range_start_err( $array['post'][$post_input] ) && $array['post']['_range'] == 'date_range' )
+ $errors[$post_input] = UM()->builtin()->date_range_start_err( $array['post'][$post_input] );
+ break;
+
+ case 'range-end':
+ if ( UM()->builtin()->date_range_end_err( $array['post'][$post_input], $array['post']['_range_start'] ) && $array['post']['_range'] == 'date_range' )
+ $errors[$post_input] = UM()->builtin()->date_range_end_err( $array['post'][$post_input], $array['post']['_range_start'] );
+ break;
+
+ }
+
+ }
+
+ }
+
+ return $errors;
+
+ }
+
+
+ /**
+ * Some fields may require extra fields before saving
+ *
+ * @param $array
+ *
+ * @return mixed
+ */
+ function um_admin_pre_save_fields_hook( $array ) {
+ /**
+ * @var $form_id
+ * @var $field_type
+ */
+ extract( $array );
+
+ /**
+ * UM hook
+ *
+ * @type filter
+ * @title um_fields_without_metakey
+ * @description Field Types without meta key
+ * @input_vars
+ * [{"var":"$types","type":"array","desc":"Field Types"}]
+ * @change_log
+ * ["Since: 2.0"]
+ * @usage add_filter( 'um_fields_without_metakey', 'function_name', 10, 1 );
+ * @example
+ *
+ */
+ $fields_without_metakey = apply_filters( 'um_fields_without_metakey', array(
+ 'block',
+ 'shortcode',
+ 'spacing',
+ 'divider',
+ 'group'
+ ) );
+
+ $fields = UM()->query()->get_attr('custom_fields', $form_id);
+ $count = 1;
+ if ( isset( $fields ) && !empty( $fields) ) $count = count($fields)+1;
+
+ // set unique meta key
+ if ( in_array( $field_type, $fields_without_metakey ) && !isset($array['post']['_metakey']) ) {
+ $array['post']['_metakey'] = "um_{$field_type}_{$form_id}_{$count}";
+ }
+
+ // set position
+ if ( !isset( $array['post']['_position'] ) ) {
+ $array['post']['_position'] = $count;
+ }
+
+ return $array;
+ }
+
+
+ /**
+ * Modify field args just before it is saved into form
+ *
+ * @param $array
+ *
+ * @return mixed
+ */
+ function um_admin_pre_save_field_to_form( $array ){
+ unset( $array['conditions'] );
+ if ( isset($array['conditional_field']) && !empty( $array['conditional_action'] ) && !empty( $array['conditional_operator'] ) ) {
+ $array['conditional_value'] = ! empty( $array['conditional_value'] ) ? $array['conditional_value'] : '';
+ $array['conditions'][] = array( $array['conditional_action'], $array['conditional_field'], $array['conditional_operator'], $array['conditional_value'] );
+ }
+
+ if ( isset($array['conditional_field1']) && !empty( $array['conditional_action1'] ) && !empty( $array['conditional_operator1'] ) ) {
+ $array['conditional_value1'] = ! empty( $array['conditional_value1'] ) ? $array['conditional_value1'] : '';
+ $array['conditions'][] = array( $array['conditional_action1'], $array['conditional_field1'], $array['conditional_operator1'], $array['conditional_value1'] );
+ }
+
+ if ( isset($array['conditional_field2']) && !empty( $array['conditional_action2'] ) && !empty( $array['conditional_operator2'] ) ) {
+ $array['conditional_value2'] = ! empty( $array['conditional_value2'] ) ? $array['conditional_value2'] : '';
+ $array['conditions'][] = array( $array['conditional_action2'], $array['conditional_field2'], $array['conditional_operator2'], $array['conditional_value2'] );
+ }
+
+ if ( isset($array['conditional_field3']) && !empty( $array['conditional_action3'] ) && !empty( $array['conditional_operator3'] ) ) {
+ $array['conditional_value3'] = ! empty( $array['conditional_value3'] ) ? $array['conditional_value3'] : '';
+ $array['conditions'][] = array( $array['conditional_action3'], $array['conditional_field3'], $array['conditional_operator3'], $array['conditional_value3'] );
+ }
+
+ if ( isset($array['conditional_field4']) && !empty( $array['conditional_action4'] ) && !empty( $array['conditional_operator4'] ) ) {
+ $array['conditional_value4'] = ! empty( $array['conditional_value4'] ) ? $array['conditional_value4'] : '';
+ $array['conditions'][] = array( $array['conditional_action4'], $array['conditional_field4'], $array['conditional_operator4'], $array['conditional_value4'] );
+ }
+
+ return $array;
+ }
+
+
+ /**
+ * Put status handler in modal
+ */
+ function add_message_handlers() {
+ ?>
+
+
+ metabox();
+
+ if ( isset( $field_args['conditional_support'] ) && $field_args['conditional_support'] == 0 ) {
+ return;
+ } ?>
+
+
+
+ in_edit = true; $metabox->edit_array = $edit_array; ?>
+
tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
+
+
tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
+
+
+
+
+
+
+
+ $arr ) {
+
+ if ( $k == 0 ) $k = ''; ?>
+
+
+
+ field_input( '_conditional_action' . $k, $form_id ); ?>
+ field_input( '_conditional_field' . $k , $form_id ); ?>
+ field_input( '_conditional_operator' . $k, $form_id ); ?>
+ field_input( '_conditional_value' . $k, $form_id ); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ field_input( '_conditional_action', $form_id ); ?>
+ field_input( '_conditional_field', $form_id ); ?>
+ field_input( '_conditional_operator', $form_id ); ?>
+ field_input( '_conditional_value', $form_id ); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+ admin()->is_plugin_post_type() ) {
+ unset( $actions['inline hide-if-no-js'] );
+ return $actions;
+ }
+ return $actions;
}
diff --git a/includes/admin/core/class-admin-metabox.php b/includes/admin/core/class-admin-metabox.php
index 39cd1535..4a76b930 100644
--- a/includes/admin/core/class-admin-metabox.php
+++ b/includes/admin/core/class-admin-metabox.php
@@ -40,6 +40,83 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
//roles metaboxes
add_action( 'um_roles_add_meta_boxes', array( &$this, 'add_metabox_role' ) );
+
+ add_filter( 'um_builtin_validation_types_continue_loop', array( &$this, 'validation_types_continue_loop' ), 1, 4 );
+ add_filter( 'um_restrict_content_hide_metabox', array( &$this, 'hide_metabox_restrict_content_shop' ), 10, 1 );
+ add_filter( 'um_admin_access_settings_fields', array( &$this, 'wpml_post_options' ), 10, 2 );
+ }
+
+
+ /**
+ * Add option for WPML
+ *
+ * @param array $fields
+ * @param array $data
+ *
+ * @return array
+ */
+ function wpml_post_options( $fields, $data ) {
+ global $post;
+
+ if ( ! function_exists( 'icl_get_current_language' ) ) {
+ return $fields;
+ }
+
+ if ( empty( $post->post_type ) || $post->post_type != 'page' ) {
+ return $fields;
+ }
+
+ $fields[] = array(
+ 'id' => '_um_wpml_user',
+ 'type' => 'checkbox',
+ 'label' => __( 'This is a translation of UM profile page?', 'ultimate-member' ),
+ 'value' => ! empty( $data['_um_wpml_user'] ) ? $data['_um_wpml_user'] : 0
+ );
+
+ $fields[] = array(
+ 'id' => '_um_wpml_account',
+ 'type' => 'checkbox',
+ 'label' => __( 'This is a translation of UM account page?', 'ultimate-member' ),
+ 'value' => ! empty( $data['_um_wpml_account'] ) ? $data['_um_wpml_account'] : 0
+ );
+
+ return $fields;
+ }
+
+
+ /**
+ * @param $hide
+ *
+ * @return bool
+ */
+ function hide_metabox_restrict_content_shop( $hide ) {
+ if ( function_exists( 'wc_get_page_id' ) && ! empty( $_GET['post'] ) &&
+ $_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;
}
diff --git a/includes/admin/core/class-admin-users.php b/includes/admin/core/class-admin-users.php
index 5353ea18..e7c2ff9e 100644
--- a/includes/admin/core/class-admin-users.php
+++ b/includes/admin/core/class-admin-users.php
@@ -31,7 +31,71 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
add_filter( 'views_users', array( &$this, 'add_status_links' ) );
- add_action( 'admin_init', array( &$this, 'um_bulk_users_edit' ), 9 );
+ add_action( 'admin_init', array( &$this, 'um_bulk_users_edit' ), 9 );
+
+ add_action( 'um_admin_user_action_hook', array( &$this, 'user_action_hook' ), 10, 1 );
+ }
+
+
+ /**
+ * Does an action to user asap
+ *
+ * @param string $action
+ */
+ function user_action_hook( $action ) {
+ switch ( $action ) {
+
+ default:
+ /**
+ * UM hook
+ *
+ * @type action
+ * @title um_admin_custom_hook_{$action}
+ * @description Integration hook on user action
+ * @input_vars
+ * [{"var":"$user_id","type":"int","desc":"User ID"}]
+ * @change_log
+ * ["Since: 2.0"]
+ * @usage add_action( 'um_admin_custom_hook_{$action}', 'function_name', 10, 1 );
+ * @example
+ *
+ */
+ do_action( "um_admin_custom_hook_{$action}", UM()->user()->id );
+ break;
+
+ case 'um_put_as_pending':
+ UM()->user()->pending();
+ break;
+
+ case 'um_approve_membership':
+ case 'um_reenable':
+ UM()->user()->approve();
+ break;
+
+ case 'um_reject_membership':
+ UM()->user()->reject();
+ break;
+
+ case 'um_resend_activation':
+ UM()->user()->email_pending();
+ break;
+
+ case 'um_deactivate':
+ UM()->user()->deactivate();
+ break;
+
+ case 'um_delete':
+ if ( is_admin() ) {
+ wp_die( 'This action is not allowed in backend.', 'ultimate-member' );
+ }
+ UM()->user()->delete();
+ break;
+ }
}
diff --git a/includes/admin/core/um-admin-actions-modal.php b/includes/admin/core/um-admin-actions-modal.php
deleted file mode 100644
index bdbe90d6..00000000
--- a/includes/admin/core/um-admin-actions-modal.php
+++ /dev/null
@@ -1,95 +0,0 @@
-
-
-
- metabox();
-
- if ( isset( $field_args['conditional_support'] ) && $field_args['conditional_support'] == 0 ) {
- return;
- } ?>
-
-
-
- in_edit = true; $metabox->edit_array = $edit_array; ?>
-
tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
-
-
tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
-
-
-
-
-
-
-
- $arr ) {
-
- if ( $k == 0 ) $k = '';
- ?>
-
-
-
- field_input( '_conditional_action' . $k, $form_id ); ?>
- field_input( '_conditional_field' . $k , $form_id ); ?>
- field_input( '_conditional_operator' . $k, $form_id ); ?>
- field_input( '_conditional_value' . $k, $form_id ); ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- field_input( '_conditional_action', $form_id ); ?>
- field_input( '_conditional_field', $form_id ); ?>
- field_input( '_conditional_operator', $form_id ); ?>
- field_input( '_conditional_value', $form_id ); ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
- */
- do_action( "um_admin_custom_hook_{$action}", UM()->user()->id );
- break;
-
- case 'um_put_as_pending':
- UM()->user()->pending();
- break;
-
- case 'um_approve_membership':
- case 'um_reenable':
- UM()->user()->approve();
- break;
-
- case 'um_reject_membership':
- UM()->user()->reject();
- break;
-
- case 'um_resend_activation':
- UM()->user()->email_pending();
- break;
-
- case 'um_deactivate':
- UM()->user()->deactivate();
- break;
-
- case 'um_delete':
- if ( is_admin() ) {
- wp_die( 'This action is not allowed in backend.', 'ultimate-member' );
- }
- UM()->user()->delete();
- break;
- }
-}
-add_action( 'um_admin_user_action_hook', 'um_admin_user_action_hook', 10, 1 );
\ No newline at end of file
diff --git a/includes/admin/core/um-admin-actions.php b/includes/admin/core/um-admin-actions.php
deleted file mode 100644
index 2b74a6a7..00000000
--- a/includes/admin/core/um-admin-actions.php
+++ /dev/null
@@ -1,270 +0,0 @@
-post_type ) || $post->post_type != 'page' )
- return $fields;
-
- $fields[] = array(
- 'id' => '_um_wpml_user',
- 'type' => 'checkbox',
- 'label' => __( 'This is a translation of UM profile page?', 'ultimate-member' ),
- 'value' => ! empty( $data['_um_wpml_user'] ) ? $data['_um_wpml_user'] : 0
- );
-
- $fields[] = array(
- 'id' => '_um_wpml_account',
- 'type' => 'checkbox',
- 'label' => __( 'This is a translation of UM account page?', 'ultimate-member' ),
- 'value' => ! empty( $data['_um_wpml_account'] ) ? $data['_um_wpml_account'] : 0
- );
-
- return $fields;
-}
-add_filter( 'um_admin_access_settings_fields', 'um_admin_wpml_post_options', 10, 2 );
-
-
-/**
- * Clear all users cache
- *
- * @param $action
- */
-function um_admin_do_action__user_cache( $action ) {
- global $wpdb;
- if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
- die();
- }
-
- $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" );
-
- $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'cleared_cache' ), admin_url( 'admin.php' ) );
- exit( wp_redirect( $url ) );
-}
-add_action( 'um_admin_do_action__user_cache', 'um_admin_do_action__user_cache' );
-
-
-/**
- * Purge temp uploads dir
- * @param $action
- */
-function um_admin_do_action__purge_temp( $action ){
- if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
- die();
- }
-
- UM()->files()->remove_dir( UM()->files()->upload_temp );
-
- $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'purged_temp' ), admin_url( 'admin.php' ) );
- exit( wp_redirect( $url ) );
-}
-add_action( 'um_admin_do_action__purge_temp', 'um_admin_do_action__purge_temp' );
-
-
-/**
- * Duplicate form
- *
- * @param $action
- */
-function um_admin_do_action__duplicate_form( $action ) {
- if ( ! is_admin() || ! current_user_can('manage_options') ) die();
- if ( ! isset( $_REQUEST['post_id'] ) || ! is_numeric( $_REQUEST['post_id'] ) ) die();
-
- $post_id = $_REQUEST['post_id'];
-
- $n = array(
- 'post_type' => 'um_form',
- 'post_title' => sprintf( __( 'Duplicate of %s', 'ultimate-member' ), get_the_title( $post_id ) ),
- 'post_status' => 'publish',
- 'post_author' => get_current_user_id(),
- );
-
- $n_id = wp_insert_post( $n );
-
- $n_fields = get_post_custom( $post_id );
- foreach ( $n_fields as $key => $value ) {
-
- if ( $key == '_um_custom_fields' ) {
- $the_value = unserialize( $value[0] );
- } else {
- $the_value = $value[0];
- }
-
- update_post_meta( $n_id, $key, $the_value );
-
- }
-
- delete_post_meta($n_id, '_um_core');
-
- $url = admin_url('edit.php?post_type=um_form');
- $url = add_query_arg('update','form_duplicated',$url);
-
- exit( wp_redirect( $url ) );
-
-}
-add_action( 'um_admin_do_action__duplicate_form', 'um_admin_do_action__duplicate_form' );
-
-
-/**
- * Download a language remotely
- *
- * @param $action
- */
-function um_admin_do_action__um_language_downloader( $action ) {
- if ( !is_admin() || !current_user_can('manage_options') ) die();
-
- $locale = get_option('WPLANG');
- if ( !$locale ) return;
- if ( !isset( UM()->available_languages[$locale] ) ) return;
-
- $path = UM()->files()->upload_basedir;
- $path = str_replace('/uploads/ultimatemember','',$path);
- $path = $path . '/languages/plugins/';
- $path = str_replace('//','/',$path);
-
- $remote = 'https://ultimatemember.com/wp-content/languages/plugins/ultimatemember-' . $locale . '.po';
- $remote2 = 'https://ultimatemember.com/wp-content/languages/plugins/ultimatemember-' . $locale . '.mo';
-
- $remote_tmp = download_url( $remote, $timeout = 300 );
- copy( $remote_tmp, $path . 'ultimatemember-' . $locale . '.po' );
- unlink( $remote_tmp );
-
- $remote2_tmp = download_url( $remote2, $timeout = 300 );
- copy( $remote2_tmp, $path . 'ultimatemember-' . $locale . '.mo' );
- unlink( $remote2_tmp );
-
- $url = remove_query_arg('um_adm_action', UM()->permalinks()->get_current_url() );
- $url = add_query_arg('update','language_updated',$url);
- exit( wp_redirect($url) );
-
-}
-add_action( 'um_admin_do_action__um_language_downloader', 'um_admin_do_action__um_language_downloader' );
-
-
-/**
- * Action to hide notices in admin
- *
- * @param $action
- */
-function um_admin_do_action__hide_notice( $action ) {
- if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
- die();
- }
-
- update_option( $action, 1 );
- exit( wp_redirect( remove_query_arg( 'um_adm_action' ) ) );
-}
-add_action( 'um_admin_do_action__um_hide_locale_notice', 'um_admin_do_action__hide_notice' );
-add_action( 'um_admin_do_action__um_can_register_notice', 'um_admin_do_action__hide_notice' );
-add_action( 'um_admin_do_action__um_hide_exif_notice', 'um_admin_do_action__hide_notice' );
-
-
-/**
- * Various user actions
- *
- * @param $action
- */
-function um_admin_do_action__user_action( $action ) {
- if ( !is_admin() || !current_user_can( 'edit_users' ) ) die();
- if ( !isset( $_REQUEST['sub'] ) ) die();
- if ( !isset($_REQUEST['user_id']) ) die();
-
- um_fetch_user( $_REQUEST['user_id'] );
-
- $subaction = $_REQUEST['sub'];
-
- /**
- * UM hook
- *
- * @type action
- * @title um_admin_user_action_hook
- * @description Action on bulk user subaction
- * @input_vars
- * [{"var":"$subaction","type":"string","desc":"Bulk Subaction"}]
- * @change_log
- * ["Since: 2.0"]
- * @usage add_action( 'um_admin_user_action_hook', 'function_name', 10, 1 );
- * @example
- *
- */
- do_action( "um_admin_user_action_hook", $subaction );
- /**
- * UM hook
- *
- * @type action
- * @title um_admin_user_action_{$subaction}_hook
- * @description Action on bulk user subaction
- * @change_log
- * ["Since: 2.0"]
- * @usage add_action( 'um_admin_user_action_{$subaction}_hook', 'function_name', 10 );
- * @example
- *
- */
- do_action( "um_admin_user_action_{$subaction}_hook" );
-
- um_reset_user();
-
- wp_redirect( add_query_arg( 'update', 'user_updated', admin_url('?page=ultimatemember') ) );
- exit;
-
-}
-add_action( 'um_admin_do_action__user_action', 'um_admin_do_action__user_action' );
-
-
-/**
- * Add any custom links to plugin page
- *
- * @param array $links
- *
- * @return array
- */
-function ultimatemember_plugin_links( $links ) {
- $more_links[] = '' . __( 'Docs', 'ultimate-member' ) . '';
- $more_links[] = '' . __( 'Settings', 'ultimate-member' ) . '';
-
- $links = $more_links + $links;
- return $links;
-}
-$prefix = is_network_admin() ? 'network_admin_' : '';
-add_filter( "{$prefix}plugin_action_links_" . um_plugin, 'ultimatemember_plugin_links' );
-
-
-/**
- * This will remove the "Edit" bulk action, which is actually quick edit.
- *
- * @param array $actions
- *
- * @return array;
- */
-function remove_bulk_actions_um_form_inline( $actions ){
- if ( UM()->admin()->is_plugin_post_type() ) {
- unset( $actions['inline hide-if-no-js'] );
- return $actions;
- }
- return $actions;
-}
-add_filter('post_row_actions', 'remove_bulk_actions_um_form_inline');
\ No newline at end of file
diff --git a/includes/admin/core/um-admin-filters-fields.php b/includes/admin/core/um-admin-filters-fields.php
deleted file mode 100644
index 5f933b33..00000000
--- a/includes/admin/core/um-admin-filters-fields.php
+++ /dev/null
@@ -1,200 +0,0 @@
-
- */
- $fields_without_metakey = apply_filters( 'um_fields_without_metakey', array(
- 'block',
- 'shortcode',
- 'spacing',
- 'divider',
- 'group'
- ) );
-
- $fields = UM()->query()->get_attr('custom_fields', $form_id);
- $count = 1;
- if ( isset( $fields ) && !empty( $fields) ) $count = count($fields)+1;
-
- // set unique meta key
- if ( in_array( $field_type, $fields_without_metakey ) && !isset($array['post']['_metakey']) ) {
- $array['post']['_metakey'] = "um_{$field_type}_{$form_id}_{$count}";
- }
-
- // set position
- if ( !isset( $array['post']['_position'] ) ) {
- $array['post']['_position'] = $count;
- }
-
- return $array;
-}
-add_filter('um_admin_pre_save_fields_hook', 'um_admin_pre_save_fields_hook', 1 );
-
-
-/**
- * Apply a filter to handle errors for field updating in backend
- *
- * @param $errors
- * @param $array
- *
- * @return mixed
- */
-function um_admin_field_update_error_handling( $errors, $array ){
- extract( $array );
-
- $field_attr = UM()->builtin()->get_core_field_attrs( $field_type );
-
- if ( isset( $field_attr['validate'] ) ) {
-
- $validate = $field_attr['validate'];
- foreach ( $validate as $post_input => $arr ) {
-
- $mode = $arr['mode'];
-
- switch ( $mode ) {
-
- case 'numeric':
- if ( !empty( $array['post'][$post_input] ) && !is_numeric( $array['post'][$post_input] ) ){
- $errors[$post_input] = $validate[$post_input]['error'];
- }
- break;
-
- case 'unique':
- if ( !isset( $array['post']['edit_mode'] ) ) {
- if ( UM()->builtin()->unique_field_err( $array['post'][$post_input] ) ) {
- $errors[$post_input] = UM()->builtin()->unique_field_err( $array['post'][$post_input] );
- }
- }
- break;
-
- case 'required':
- if ( $array['post'][$post_input] == '' )
- $errors[$post_input] = $validate[$post_input]['error'];
- break;
-
- case 'range-start':
- if ( UM()->builtin()->date_range_start_err( $array['post'][$post_input] ) && $array['post']['_range'] == 'date_range' )
- $errors[$post_input] = UM()->builtin()->date_range_start_err( $array['post'][$post_input] );
- break;
-
- case 'range-end':
- if ( UM()->builtin()->date_range_end_err( $array['post'][$post_input], $array['post']['_range_start'] ) && $array['post']['_range'] == 'date_range' )
- $errors[$post_input] = UM()->builtin()->date_range_end_err( $array['post'][$post_input], $array['post']['_range_start'] );
- break;
-
- }
-
- }
-
- }
-
- return $errors;
-
- }
-add_filter('um_admin_field_update_error_handling', 'um_admin_field_update_error_handling', 1, 2 );
-
-
-/**
- * Filter validation types on loop
- *
- * @param $break
- * @param $key
- * @param $form_id
- * @param $field_array
- *
- * @return bool
- */
-function um_builtin_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;
-}
-add_filter( 'um_builtin_validation_types_continue_loop', 'um_builtin_validation_types_continue_loop', 1, 4 );
-
-
-/**
- * @param $hide
- *
- * @return bool
- */
-function um_hide_metabox_restrict_content_shop( $hide ) {
- if ( function_exists( 'wc_get_page_id' ) && ! empty( $_GET['post'] ) &&
- $_GET['post'] == wc_get_page_id( 'shop' ) ) {
- return true;
- }
-
- return $hide;
-}
-add_filter( 'um_restrict_content_hide_metabox', 'um_hide_metabox_restrict_content_shop', 10, 1 );
\ No newline at end of file