This commit is contained in:
Yurii Nalivaiko
2018-11-01 12:16:35 +02:00
34 changed files with 913 additions and 690 deletions
@@ -5,6 +5,7 @@
.um-admin.post-type-um_form .manage-column.column-id {width: 60px}
.um-admin.post-type-um_form .manage-column.column-mode {width: 100px}
.um-admin.post-type-um_form .manage-column.column-is_default {width: 60px}
.um-admin.post-type-um_form .manage-column.column-title {width: 200px}
.um-admin.post-type-um_form .manage-column.column-shortcode {width: 200px}
.um-admin.post-type-um_form .manage-column.column-impressions {width: 100px}
@@ -12,6 +13,7 @@
.um-admin.post-type-um_directory .manage-column.column-id {width: 60px}
.um-admin.post-type-um_directory .manage-column.column-title {width: 250px}
.um-admin.post-type-um_directory .manage-column.column-is_default {width: 60px}
.um-admin.post-type-um_role .manage-column.column-title {width: 200px}
.um-admin.post-type-um_role .manage-column.column-count {width: 150px}
+20 -10
View File
@@ -45,22 +45,32 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
add_action( 'um_admin_do_action__install_core_pages', array( &$this, 'install_core_pages' ) );
add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ), 999 );
add_action( 'parent_file', array( &$this, 'parent_file' ), 9 );
add_filter( 'gettext', array( &$this, 'gettext' ), 10, 4 );
add_filter( 'post_updated_messages', array( &$this, 'post_updated_messages' ) );
add_action( 'wp_ajax_um_dynamic_modal_content', array( UM()->builder(), 'dynamic_modal_content' ) );
add_action( 'wp_ajax_um_populate_dropdown_options', array( UM()->builder(), 'populate_dropdown_options' ) );
add_action( 'wp_ajax_um_update_field', array( UM()->builder(), 'update_field' ) );
add_action( 'wp_ajax_um_do_ajax_action', array( UM()->fields(), 'do_ajax_action' ) );
add_action( 'wp_ajax_um_update_builder', array( UM()->builder(), 'update_builder' ) );
add_action( 'wp_ajax_um_update_order', array( UM()->dragdrop(), 'update_order' ) );
add_action( 'wp_ajax_um_rated', array( UM()->admin_menu(), 'ultimatemember_rated' ) );
}
/**
* Adds class to our admin pages
*
* @param $classes
*
* @return string
*/
function admin_body_class( $classes ) {
if ( $this->is_um_screen() ) {
return "$classes um-admin";
}
return $classes;
}
/**
*
*/
function manual_upgrades_request() {
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
die();
@@ -0,0 +1,33 @@
<?php
namespace um\admin\core;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'um\admin\core\Admin_Ajax_Hooks' ) ) {
/**
* Class Admin_Ajax_Hooks
* @package um\admin\core
*/
class Admin_Ajax_Hooks {
/**
* Admin_Columns constructor.
*/
function __construct() {
add_action( 'wp_ajax_um_do_ajax_action', array( UM()->fields(), 'do_ajax_action' ) );
add_action( 'wp_ajax_um_update_builder', array( UM()->builder(), 'update_builder' ) );
add_action( 'wp_ajax_um_update_order', array( UM()->dragdrop(), 'update_order' ) );
add_action( 'wp_ajax_um_update_field', array( UM()->builder(), 'update_field' ) );
add_action( 'wp_ajax_um_dynamic_modal_content', array( UM()->builder(), 'dynamic_modal_content' ) );
add_action( 'wp_ajax_um_populate_dropdown_options', array( UM()->builder(), 'populate_dropdown_options' ) );
add_action( 'wp_ajax_um_rated', array( UM()->admin_menu(), 'ultimatemember_rated' ) );
}
}
}
+32 -8
View File
@@ -90,11 +90,12 @@ if ( ! class_exists( 'um\admin\core\Admin_Columns' ) ) {
*/
function manage_edit_um_form_columns( $columns ) {
$new_columns['cb'] = '<input type="checkbox" />';
$new_columns['title'] = __( 'Title', 'ulitmatemember' );
$new_columns['id'] = __('ID', 'ulitmatemember' );
$new_columns['mode'] = __( 'Type', 'ulitmatemember' );
$new_columns['shortcode'] = __( 'Shortcode', 'ulitmatemember' );
$new_columns['date'] = __( 'Date', 'ulitmatemember' );
$new_columns['title'] = __( 'Title', 'ulitmate-member' );
$new_columns['id'] = __('ID', 'ulitmate-member' );
$new_columns['mode'] = __( 'Type', 'ulitmate-member' );
$new_columns['is_default'] = __( 'Default', 'ulitmate-member' );
$new_columns['shortcode'] = __( 'Shortcode', 'ulitmate-member' );
$new_columns['date'] = __( 'Date', 'ulitmate-member' );
return $new_columns;
}
@@ -111,6 +112,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Columns' ) ) {
$new_columns['cb'] = '<input type="checkbox" />';
$new_columns['title'] = __( 'Title', 'ultimate-member' );
$new_columns['id'] = __( 'ID', 'ultimate-member' );
$new_columns['is_default'] = __( 'Default', 'ulitmate-member' );
$new_columns['shortcode'] = __( 'Shortcode', 'ultimate-member' );
$new_columns['date'] = __( 'Date', 'ultimate-member' );
@@ -131,7 +133,19 @@ if ( ! class_exists( 'um\admin\core\Admin_Columns' ) ) {
break;
case 'shortcode':
echo UM()->shortcodes()->get_shortcode( $id );
$is_default = UM()->query()->get_attr( 'is_default', $id );
if ( $is_default ) {
echo UM()->shortcodes()->get_default_shortcode( $id );
} else {
echo UM()->shortcodes()->get_shortcode( $id );
}
break;
case 'is_default':
$is_default = UM()->query()->get_attr( 'is_default', $id );
echo empty( $is_default ) ? __( 'No', 'ultimate-member' ) : __( 'Yes', 'ultimate-member' );
break;
case 'mode':
@@ -143,7 +157,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Columns' ) ) {
/**
* Display cusom columns for Directory
* Display custom columns for Directory
*
* @param string $column_name
* @param int $id
@@ -154,7 +168,17 @@ if ( ! class_exists( 'um\admin\core\Admin_Columns' ) ) {
echo '<span class="um-admin-number">'.$id.'</span>';
break;
case 'shortcode':
echo UM()->shortcodes()->get_shortcode( $id );
$is_default = UM()->query()->get_attr( 'is_default', $id );
if ( $is_default ) {
echo UM()->shortcodes()->get_default_shortcode( $id );
} else {
echo UM()->shortcodes()->get_shortcode( $id );
}
break;
case 'is_default':
$is_default = UM()->query()->get_attr( 'is_default', $id );
echo empty( $is_default ) ? __( 'No', 'ultimate-member' ) : __( 'Yes', 'ultimate-member' );
break;
}
}
@@ -39,8 +39,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ), 999 );
add_filter( 'enter_title_here', array( &$this, 'enter_title_here' ) );
add_action( 'load-user-new.php', array( &$this, 'enqueue_role_wrapper' ) );
@@ -344,21 +342,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
}
/**
* Adds class to our admin pages
*
* @param $classes
*
* @return string
*/
function admin_body_class( $classes ) {
if ( UM()->admin()->is_um_screen() ) {
return "$classes um-admin";
}
return $classes;
}
/**
* Enqueue scripts and styles
*/
+33 -2
View File
@@ -1087,6 +1087,21 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
$v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
}
if ( strstr( $k, '_um_' ) ) {
if ( $k === '_um_is_default' ) {
$mode = UM()->query()->get_attr( 'mode', $post_id );
if ( ! empty( $mode ) ) {
$posts = $wpdb->get_col(
"SELECT post_id
FROM {$wpdb->postmeta}
WHERE meta_key = '_um_mode' AND
meta_value = 'directory'"
);
foreach ( $posts as $p_id ) {
delete_post_meta( $p_id, '_um_is_default' );
}
}
}
update_post_meta( $post_id, $k, $v );
}
}
@@ -1121,8 +1136,24 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
// save
delete_post_meta( $post_id, '_um_profile_metafields' );
foreach ( $_POST['form'] as $k => $v ) {
if ( strstr( $k, '_um_' ) ){
update_post_meta( $post_id, $k, $v);
if ( strstr( $k, '_um_' ) ) {
if ( $k === '_um_is_default' ) {
$mode = UM()->query()->get_attr( 'mode', $post_id );
if ( ! empty( $mode ) ) {
$posts = $wpdb->get_col( $wpdb->prepare(
"SELECT post_id
FROM {$wpdb->postmeta}
WHERE meta_key = '_um_mode' AND
meta_value = %s",
$mode
) );
foreach ( $posts as $p_id ) {
delete_post_meta( $p_id, '_um_is_default' );
}
}
}
update_post_meta( $post_id, $k, $v );
}
}
+3 -3
View File
@@ -298,11 +298,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
ob_start(); ?>
<p>
<?php printf( __( 'One or more of your %s pages are not correctly setup. Please visit <strong>%s > Settings</strong> to re-assign your missing pages.', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_plugin_name ); ?>
<?php printf( __( '%s needs to create several pages (User Profiles, Account, Registration, Login, Password Reset, Logout, Member Directory) to function correctly.', 'ultimate-member' ), ultimatemember_plugin_name ); ?>
</p>
<p>
<a href="<?php echo esc_attr( add_query_arg( 'um_adm_action', 'install_core_pages' ) ); ?>" class="button button-primary"><?php _e( 'Setup Pages', 'ultimate-member' ) ?></a>
<a href="<?php echo esc_attr( add_query_arg( 'um_adm_action', 'install_core_pages' ) ); ?>" class="button button-primary"><?php _e( 'Create Pages', 'ultimate-member' ) ?></a>
&nbsp;
<a href="javascript:void(0);" class="button-secondary um_secondary_dimiss"><?php _e( 'No thanks', 'ultimate-member' ) ?></a>
</p>
@@ -531,7 +531,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
ob_start(); ?>
<p>
<?php printf( __( 'Thanks for installing <strong>%s</strong>! We hope you like the plugin. To fund full-time development and support of the plugin we also sell extensions. If you subscribe to our mailing list we will send you a 20%% discount code for our <a href="%s" target="_blank">extensions bundle</a>.', 'ultimate-member' ), ultimatemember_plugin_name, 'https://ultimatemember.com/core-extensions-bundle/' ); ?>
<?php printf( __( 'Thanks for installing <strong>%s</strong>! We hope you like the plugin. To fund full-time development and support of the plugin we also sell extensions. If you subscribe to our mailing list we will send you a 20%% discount code for our <a href="%s" target="_blank">extensions bundle</a>.', 'ultimate-member' ), ultimatemember_plugin_name, 'https://ultimatemember.com/core-extensions-bundle/' ); ?>
</p>
<p>
@@ -1,3 +1,24 @@
<div class="um-admin-metabox">
<?php /*UM()->admin_forms( array(
'class' => 'um-member-directory-shortcode um-top-label',
'prefix_id' => 'um_metadata',
'fields' => array(
array(
'id' => '_um_is_default',
'type' => 'select',
'label' => __( 'Default Member Directory', 'ultimate-member' ),
'tooltip' => sprintf( __( 'If you set this member directory as default you will have an ability to use %s shortcode for the displaying directory at the page. Otherwise you will have to use %s', 'ultimate-member' ), UM()->shortcodes()->get_default_shortcode( get_the_ID() ), UM()->shortcodes()->get_shortcode( get_the_ID() ) ),
'value' => UM()->query()->get_meta_value( '_um_is_default' ),
'options' => array(
0 => __( 'No', 'ultimate-member' ),
1 => __( 'Yes', 'ultimate-member' ),
),
),
)
) )->render_form();*/ ?>
<!-- <div class="um-admin-clear"></div>-->
<p><?php echo UM()->shortcodes()->get_shortcode( get_the_ID() ); ?></p>
<!-- <p>--><?php //echo UM()->shortcodes()->get_default_shortcode( get_the_ID() ); ?><!--</p>-->
</div>
@@ -1,3 +1,24 @@
<div class="um-admin-metabox">
<?php /*UM()->admin_forms( array(
'class' => 'um-form-shortcode um-top-label',
'prefix_id' => 'form',
'fields' => array(
array(
'id' => '_um_is_default',
'type' => 'select',
'label' => __( 'Default Form', 'ultimate-member' ),
'tooltip' => sprintf( __( 'If you set this form as default you will have an ability to use %s shortcode for the displaying form at the page. Otherwise you will have to use %s', 'ultimate-member' ), UM()->shortcodes()->get_default_shortcode( get_the_ID() ), UM()->shortcodes()->get_shortcode( get_the_ID() ) ),
'value' => UM()->query()->get_meta_value( '_um_is_default' ),
'options' => array(
0 => __( 'No', 'ultimate-member' ),
1 => __( 'Yes', 'ultimate-member' ),
),
),
)
) )->render_form();*/ ?>
<!-- <div class="um-admin-clear"></div>-->
<p><?php echo UM()->shortcodes()->get_shortcode( get_the_ID() ); ?></p>
<!-- <p>--><?php //echo UM()->shortcodes()->get_default_shortcode( get_the_ID() ); ?><!--</p>-->
</div>
+1
View File
@@ -60,6 +60,7 @@ if ( ! class_exists( 'um\Dependencies' ) ) {
'beaver-builder' => '2.0',
'user-photos' => '2.0.1',
'user-exporter' => '1.0.0',
'bookmark' => '2.0',
);
+26
View File
@@ -525,6 +525,7 @@ if ( ! class_exists( 'UM' ) ) {
if ( $this->is_request( 'ajax' ) ) {
$this->admin();
$this->ajax_init();
$this->admin_ajax_hooks();
$this->metabox();
$this->admin_upgrade()->init_packages_ajax_handlers();
$this->admin_gdpr();
@@ -638,6 +639,17 @@ if ( ! class_exists( 'UM' ) ) {
}
/**
* @since 2.0.30
*/
function admin_ajax_hooks() {
if ( empty( $this->classes['admin_ajax_hooks'] ) ) {
$this->classes['admin_ajax_hooks'] = new um\admin\core\Admin_Ajax_Hooks();
}
return $this->classes['admin_ajax_hooks'];
}
/**
* @since 2.0
*
@@ -1313,6 +1325,20 @@ if ( ! class_exists( 'UM' ) ) {
}
/**
* @since 2.0
*
* @return um\core\Templates
*/
function templates() {
if ( empty( $this->classes['templates'] ) ) {
$this->classes['templates'] = new um\core\Templates();
}
return $this->classes['templates'];
}
/**
* @since 2.0
*
+82 -104
View File
@@ -13,16 +13,33 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
*/
class Enqueue {
/**
* @var string
*/
var $suffix = '';
/**
* @var string
*/
var $js_baseurl = '';
/**
* @var string
*/
var $css_baseurl = '';
/**
* Enqueue constructor.
*/
function __construct() {
$this->suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || defined( 'UM_SCRIPT_DEBUG' ) ) ? '' : '.min';
$this->js_baseurl = um_url . 'assets/js/';
$this->css_baseurl = um_url . 'assets/css/';
/**
* UM hook
@@ -49,31 +66,63 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
}
/**
* Minify css string
*
* @param $css
*
* @return mixed
*/
function minify( $css ) {
$css = str_replace(array("\r", "\n"), '', $css);
$css = str_replace(' {','{', $css );
$css = str_replace('{ ','{', $css );
$css = str_replace('; ',';', $css );
$css = str_replace(';}','}', $css );
$css = str_replace(': ',':', $css );
return $css;
}
/**
* Enqueue scripts and styles
*/
function wp_enqueue_scripts() {
global $post;
$this->suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || defined( 'UM_SCRIPT_DEBUG' ) ) ? '' : '.min';
$dequeue_select2 = apply_filters( 'um_dequeue_select2_scripts', false );
if ( class_exists( 'WooCommerce' ) || $dequeue_select2 ) {
wp_dequeue_style( 'select2' );
wp_deregister_style( 'select2' );
wp_dequeue_script( 'select2');
wp_deregister_script('select2');
}
wp_register_script( 'select2', $this->js_baseurl . 'select2/select2.full.min.js', array( 'jquery', 'jquery-masonry' ), ultimatemember_version, true );
wp_register_script( 'um_scrollbar', $this->js_baseurl . 'um-scrollbar' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
wp_register_script( 'um_jquery_form', $this->js_baseurl . 'um-jquery-form' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
wp_register_script( 'um_fileupload', $this->js_baseurl . 'um-fileupload' . $this->suffix . '.js', array( 'jquery', 'um_jquery_form' ), ultimatemember_version, true );
$datetime_deps = array( 'jquery' );
// load a localized version for date/time
$locale = get_locale();
if ( $locale && file_exists( um_path . 'assets/js/pickadate/translations/' . $locale . '.js' ) ) {
wp_register_script('um_datetime_locale', um_url . 'assets/js/pickadate/translations/' . $locale . '.js', array( 'jquery' ), ultimatemember_version, true );
$datetime_deps[] = 'um_datetime_locale';
}
wp_register_script( 'um_datetime', $this->js_baseurl . 'pickadate/picker.js', $datetime_deps, ultimatemember_version, true );
wp_register_script( 'um_datetime_date', $this->js_baseurl . 'pickadate/picker.date.js', array( 'jquery' ), ultimatemember_version, true );
wp_register_script( 'um_datetime_time', $this->js_baseurl . 'pickadate/picker.time.js', array( 'jquery' ), ultimatemember_version, true );
wp_register_script( 'um_datetime_legacy', $this->js_baseurl . 'pickadate/legacy.js', array( 'jquery' ), ultimatemember_version, true );
wp_register_script( 'um_tipsy', $this->js_baseurl . 'um-tipsy' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
wp_register_script( 'um_raty', $this->js_baseurl . 'um-raty' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
wp_register_script( 'um_crop', $this->js_baseurl . 'um-crop' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
//FontAwesome and FontIcons styles
wp_register_style( 'um_fonticons_ii', $this->css_baseurl . 'um-fonticons-ii.css', array(), ultimatemember_version );
wp_register_style( 'um_fonticons_fa', $this->css_baseurl . 'um-fonticons-fa.css', array(), ultimatemember_version );
wp_register_style( 'um_crop', $this->css_baseurl . 'um-crop.css', array(), ultimatemember_version );
wp_register_style( 'um_tipsy', $this->css_baseurl . 'um-tipsy.css', array(), ultimatemember_version );
wp_register_style( 'um_raty', $this->css_baseurl . 'um-raty.css', array(), ultimatemember_version );
wp_register_style( 'select2', $this->css_baseurl . 'select2/select2.min.css', array(), ultimatemember_version );
wp_register_style( 'um_fileupload', $this->css_baseurl . 'um-fileupload.css', array(), ultimatemember_version );
wp_register_style( 'um_datetime', $this->css_baseurl . 'pickadate/default.css', array(), ultimatemember_version );
wp_register_style( 'um_datetime_date', $this->css_baseurl . 'pickadate/default.date.css', array( 'um-datetime' ), ultimatemember_version );
wp_register_style( 'um_datetime_time', $this->css_baseurl . 'pickadate/default.time.css', array( 'um-datetime' ), ultimatemember_version );
wp_register_style( 'um_scrollbar', $this->css_baseurl . 'um-scrollbar.css', array(), ultimatemember_version );
//ui slider for filters
//wp_enqueue_script( 'jquery-ui-slider' );
global $post;
if ( ! is_admin() ) {
$c_url = UM()->permalinks()->get_current_url( get_option( 'permalink_structure' ) );
@@ -119,25 +168,26 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
// rtl style
if ( is_rtl() ) {
wp_register_style('um_rtl', um_url . 'assets/css/um.rtl.css', '', ultimatemember_version, 'all' );
wp_register_style('um_rtl', um_url . 'assets/css/um.rtl.css', array(), ultimatemember_version );
wp_enqueue_style('um_rtl');
}
// load a localized version for date/time
$locale = get_locale();
if ( $locale && file_exists( um_path . 'assets/js/pickadate/translations/' . $locale . '.js' ) ) {
wp_register_script('um_datetime_locale', um_url . 'assets/js/pickadate/translations/' . $locale . '.js', '', ultimatemember_version, true );
wp_enqueue_script('um_datetime_locale');
}
if(is_object($post) && has_shortcode($post->post_content,'ultimate-member')) {
wp_dequeue_script('jquery-form');
}
//old settings before UM 2.0 CSS
wp_register_style('um_default_css', um_url . 'assets/css/um-old-default.css', '', ultimatemember_version, 'all' );
wp_register_style('um_default_css', um_url . 'assets/css/um-old-default.css', array(), ultimatemember_version );
wp_enqueue_style('um_default_css');
$this->old_css_settings();
}
/**
*
*/
function old_css_settings() {
$uploads = wp_upload_dir();
$upload_dir = $uploads['basedir'] . DIRECTORY_SEPARATOR . 'ultimatemember' . DIRECTORY_SEPARATOR;
if ( file_exists( $upload_dir . 'um_old_settings.css' ) ) {
@@ -172,7 +222,7 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
$this->load_raty();
$this->load_scrollto();
//$this->load_scrollto();
$this->load_scrollbar();
@@ -228,20 +278,7 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
*/
function load_selectjs() {
$dequeue_select2 = apply_filters( 'um_dequeue_select2_scripts', false );
if ( class_exists( 'WooCommerce' ) || $dequeue_select2 ) {
wp_dequeue_style( 'select2' );
wp_deregister_style( 'select2' );
wp_dequeue_script( 'select2');
wp_deregister_script('select2');
}
wp_register_script('select2', um_url . 'assets/js/select2/select2.full.min.js', array('jquery', 'jquery-masonry') );
wp_enqueue_script('select2');
wp_register_style('select2', um_url . 'assets/css/select2/select2.min.css' );
wp_enqueue_style('select2');
}
@@ -251,13 +288,8 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
* Load Fonticons
*/
function load_fonticons(){
wp_register_style('um_fonticons_ii', um_url . 'assets/css/um-fonticons-ii.css' );
wp_enqueue_style('um_fonticons_ii');
wp_register_style('um_fonticons_fa', um_url . 'assets/css/um-fonticons-fa.css' );
wp_enqueue_style('um_fonticons_fa');
}
@@ -265,16 +297,9 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
* Load fileupload JS
*/
function load_fileupload() {
wp_register_script('um_jquery_form', um_url . 'assets/js/um-jquery-form' . $this->suffix . '.js' );
wp_enqueue_script('um_jquery_form');
wp_register_script('um_fileupload', um_url . 'assets/js/um-fileupload' . $this->suffix . '.js' );
wp_enqueue_script('um_fileupload');
wp_register_style('um_fileupload', um_url . 'assets/css/um-fileupload.css' );
wp_enqueue_style('um_fileupload');
}
@@ -283,7 +308,7 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
*/
function load_functions() {
wp_register_script('um_functions', um_url . 'assets/js/um-functions' . $this->suffix . '.js', array('jquery', 'jquery-masonry', 'wp-util') );
wp_register_script('um_functions', um_url . 'assets/js/um-functions' . $this->suffix . '.js', array('jquery', 'jquery-masonry', 'wp-util', 'um_scrollbar') );
wp_enqueue_script('um_functions');
wp_enqueue_script( 'um-gdpr', um_url . 'assets/js/um-gdpr' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, false );
@@ -343,39 +368,13 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
* Load date & time picker
*/
function load_datetimepicker() {
wp_register_script('um_datetime', um_url . 'assets/js/pickadate/picker.js' );
wp_enqueue_script('um_datetime');
wp_register_script('um_datetime_date', um_url . 'assets/js/pickadate/picker.date.js' );
wp_enqueue_script('um_datetime_date');
wp_register_script('um_datetime_time', um_url . 'assets/js/pickadate/picker.time.js' );
wp_enqueue_script('um_datetime_time');
wp_register_script('um_datetime_legacy', um_url . 'assets/js/pickadate/legacy.js' );
wp_enqueue_script('um_datetime_legacy');
wp_register_style('um_datetime', um_url . 'assets/css/pickadate/default.css' );
wp_enqueue_style('um_datetime');
wp_register_style('um_datetime_date', um_url . 'assets/css/pickadate/default.date.css' );
wp_enqueue_style('um_datetime_date');
wp_register_style('um_datetime_time', um_url . 'assets/css/pickadate/default.time.css' );
wp_enqueue_style('um_datetime_time');
}
/**
* Load scrollto
*/
function load_scrollto(){
wp_register_script('um_scrollto', um_url . 'assets/js/um-scrollto' . $this->suffix . '.js' );
wp_enqueue_script('um_scrollto');
}
@@ -383,27 +382,16 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
* Load scrollbar
*/
function load_scrollbar(){
wp_register_script('um_scrollbar', um_url . 'assets/js/um-scrollbar' . $this->suffix . '.js' );
wp_enqueue_script('um_scrollbar');
wp_register_style('um_scrollbar', um_url . 'assets/css/um-scrollbar.css' );
wp_enqueue_style('um_scrollbar');
}
/**
* Load rating
*/
function load_raty(){
wp_register_script('um_raty', um_url . 'assets/js/um-raty' . $this->suffix . '.js' );
function load_raty() {
wp_enqueue_script('um_raty');
wp_register_style('um_raty', um_url . 'assets/css/um-raty.css' );
wp_enqueue_style('um_raty');
}
@@ -411,13 +399,8 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
* Load crop script
*/
function load_imagecrop(){
wp_register_script('um_crop', um_url . 'assets/js/um-crop' . $this->suffix . '.js' );
wp_enqueue_script('um_crop');
wp_register_style('um_crop', um_url . 'assets/css/um-crop.css' );
wp_enqueue_style('um_crop');
}
@@ -425,13 +408,8 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
* Load tipsy
*/
function load_tipsy(){
wp_register_script('um_tipsy', um_url . 'assets/js/um-tipsy' . $this->suffix . '.js' );
wp_enqueue_script('um_tipsy');
wp_register_style('um_tipsy', um_url . 'assets/css/um-tipsy.css' );
wp_enqueue_style('um_tipsy');
}
@@ -286,8 +286,8 @@ if ( ! class_exists( 'um\core\External_Integrations' ) ) {
$language_codes = $this->get_languages_codes();
$lang = '';
if ( $language_codes['default'] != $language_codes['current'] &&
UM()->config()->email_notifications[ $template_name ]['recipient'] != 'admin' ) {
if ( $language_codes['default'] != $language_codes['current'] /*&&
UM()->config()->email_notifications[ $template_name ]['recipient'] != 'admin'*/ ) {
$lang = $language_codes['current'] . '/';
}
+39 -10
View File
@@ -1128,13 +1128,42 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
* @return string
*/
function get_label( $key ) {
$fields = UM()->builtin()->all_user_fields;
if ( isset( $fields[$key]['label'] ) )
return stripslashes( $fields[$key]['label'] );
if ( isset( $fields[$key]['title'] ) )
return stripslashes( $fields[$key]['title'] );
$label = '';
return '';
$fields = UM()->builtin()->all_user_fields;
if ( isset( $fields[ $key ]['label'] ) ) {
$label = stripslashes( $fields[ $key ]['label'] );
}
if ( isset( $fields[ $key ]['title'] ) ) {
$label = stripslashes( $fields[ $key ]['title'] );
}
/**
* UM hook
*
* @type filter
* @title um_change_field_label
* @description Change Field Label
* @input_vars
* [{"var":"$label","type":"string","desc":"Field Label"},
* {"var":"$key","type":"string","desc":"Field Key"}]
* @change_log
* ["Since: 2.0.30"]
* @usage add_filter( 'um_change_field_label', 'function_name', 10, 2 );
* @example
* <?php
* add_filter( 'um_change_field_label', 'my_change_field_label', 10, 2 );
* function my_form_fields( $label, $key ) {
* // your code here
* return $label;
* }
* ?>
*/
$label = apply_filters( 'um_change_field_label', $label, $key );
$label = sprintf( __( '%s', 'ultimate-member' ), $label );
return $label;
}
@@ -2268,8 +2297,8 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$output .= '<div class="um-single-image-upload" data-user_id="' . esc_attr( $_um_profile_id ) . '" data-nonce="' . $nonce . '" data-timestamp="' . esc_attr( $this->timestamp ) . '" data-icon="' . esc_attr( $icon ) . '" data-set_id="' . esc_attr( $set_id ) . '" data-set_mode="' . esc_attr( $set_mode ) . '" data-type="' . esc_attr( $type ) . '" data-key="' . esc_attr( $key ) . '" data-max_size="' . esc_attr( $max_size ) . '" data-max_size_error="' . esc_attr( $max_size_error ) . '" data-min_size_error="' . esc_attr( $min_size_error ) . '" data-extension_error="' . esc_attr( $extension_error ) . '" data-allowed_types="' . esc_attr( $allowed_types ) . '" data-upload_text="' . esc_attr( $upload_text ) . '" data-max_files_error="' . esc_attr( $max_files_error ) . '" data-upload_help_text="' . esc_attr( $upload_help_text ) . '">' . $button_text . '</div>';
$output .= '<div class="um-modal-footer">
<div class="um-modal-right">
<a href="#" class="um-modal-btn um-finish-upload image disabled" data-key="' . $key . '" data-change="' . __( 'Change photo', 'ultimate-member' ) . '" data-processing="' . __( 'Processing...', 'ultimate-member' ) . '"> ' . __( 'Apply', 'ultimate-member' ) . '</a>
<a href="#" class="um-modal-btn alt" data-action="um_remove_modal"> ' . __( 'Cancel', 'ultimate-member' ) . '</a>
<a href="javascript:void(0);" class="um-modal-btn um-finish-upload image disabled" data-key="' . $key . '" data-change="' . __( 'Change photo', 'ultimate-member' ) . '" data-processing="' . __( 'Processing...', 'ultimate-member' ) . '"> ' . __( 'Apply', 'ultimate-member' ) . '</a>
<a href="javascript:void(0);" class="um-modal-btn alt" data-action="um_remove_modal"> ' . __( 'Cancel', 'ultimate-member' ) . '</a>
</div>
<div class="um-clear"></div>
</div>';
@@ -2365,8 +2394,8 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$output .= '<div class="um-single-file-upload" data-user_id="' . esc_attr( $_um_profile_id ) . '" data-timestamp="' . esc_attr( $this->timestamp ) . '" data-nonce="' . $nonce . '" data-icon="' . esc_attr( $icon ) . '" data-set_id="' . esc_attr( $set_id ) . '" data-set_mode="' . esc_attr( $set_mode ) . '" data-type="' . esc_attr( $type ) . '" data-key="' . esc_attr( $key ) . '" data-max_size="' . esc_attr( $max_size ) . '" data-max_size_error="' . esc_attr( $max_size_error ) . '" data-min_size_error="' . esc_attr( $min_size_error ) . '" data-extension_error="' . esc_attr( $extension_error ) . '" data-allowed_types="' . esc_attr( $allowed_types ) . '" data-upload_text="' . esc_attr( $upload_text ) . '" data-max_files_error="' . esc_attr( $max_files_error ) . '" data-upload_help_text="' . esc_attr( $upload_help_text ) . '">' . $button_text . '</div>';
$output .= '<div class="um-modal-footer">
<div class="um-modal-right">
<a href="#" class="um-modal-btn um-finish-upload file disabled" data-key="' . $key . '" data-change="' . __( 'Change file' ) . '" data-processing="' . __( 'Processing...', 'ultimate-member' ) . '"> ' . __( 'Save', 'ultimate-member' ) . '</a>
<a href="#" class="um-modal-btn alt" data-action="um_remove_modal"> ' . __( 'Cancel', 'ultimate-member' ) . '</a>
<a href="javascript:void(0);" class="um-modal-btn um-finish-upload file disabled" data-key="' . $key . '" data-change="' . __( 'Change file' ) . '" data-processing="' . __( 'Processing...', 'ultimate-member' ) . '"> ' . __( 'Save', 'ultimate-member' ) . '</a>
<a href="javascript:void(0);" class="um-modal-btn alt" data-action="um_remove_modal"> ' . __( 'Cancel', 'ultimate-member' ) . '</a>
</div>
<div class="um-clear"></div>
</div>';
+17 -2
View File
@@ -83,12 +83,15 @@ if ( ! class_exists( 'um\core\Files' ) ) {
if ( UM()->is_permalinks ) {
$url = get_site_url( get_current_blog_id() );
$nonce = wp_create_nonce( $user_id . $form_id . 'um-download-nonce' );
return $url . "/um-download/{$form_id}/{$field_key}/{$user_id}/{$nonce}";
$url = $url . "/um-download/{$form_id}/{$field_key}/{$user_id}/{$nonce}";
} else {
$url = get_site_url( get_current_blog_id() );
$nonce = wp_create_nonce( $user_id . $form_id . 'um-download-nonce' );
return add_query_arg( array( 'um_action' => 'download', 'um_form' => $form_id, 'um_field' => $field_key, 'um_user' => $user_id, 'um_verify' => $nonce ), $url );
$url = add_query_arg( array( 'um_action' => 'download', 'um_form' => $form_id, 'um_field' => $field_key, 'um_user' => $user_id, 'um_verify' => $nonce ), $url );
}
//add time to query args for sites with the cache
return add_query_arg( array( 't' => time() ), $url );
}
@@ -183,6 +186,12 @@ if ( ! class_exists( 'um\core\Files' ) ) {
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . $size);
$levels = ob_get_level();
for ( $i = 0; $i < $levels; $i++ ) {
@ob_end_clean();
}
readfile( $file_path );
exit;
}
@@ -217,6 +226,12 @@ if ( ! class_exists( 'um\core\Files' ) ) {
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . $size);
$levels = ob_get_level();
for ( $i = 0; $i < $levels; $i++ ) {
@ob_end_clean();
}
readfile( $file_path );
exit;
}
+2 -3
View File
@@ -70,10 +70,9 @@ if ( ! class_exists( 'um\core\GDPR' ) ) {
* @return mixed
*/
function email_registration_data( $submitted ) {
$timestamp = ! empty( $submitted['timestamp'] ) ? $submitted['timestamp'] : $submitted['use_gdpr_agreement'];
if ( ! empty( $submitted['use_gdpr_agreement'] ) ) {
$timestamp = ! empty( $submitted['timestamp'] ) ? $submitted['timestamp'] : $submitted['use_gdpr_agreement'];
$submitted['GDPR Applied'] = date( "d M Y H:i", $timestamp );
unset( $submitted['use_gdpr_agreement'] );
}
+2 -2
View File
@@ -373,11 +373,11 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) {
} else {
$profile_url = add_query_arg( 'um_user', $slug, $profile_url );
$profile_url = add_query_arg( 'um_user', strtolower( $slug ), $profile_url );
}
return ! empty( $profile_url ) ? strtolower( $profile_url ) : '';
return ! empty( $profile_url ) ? $profile_url : '';
}
+164 -5
View File
@@ -26,6 +26,11 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
add_shortcode( 'ultimatemember', array( &$this, 'ultimatemember' ) );
add_shortcode( 'ultimatemember_login', array( &$this, 'ultimatemember_login' ) );
add_shortcode( 'ultimatemember_register', array( &$this, 'ultimatemember_register' ) );
add_shortcode( 'ultimatemember_profile', array( &$this, 'ultimatemember_profile' ) );
add_shortcode( 'ultimatemember_directory', array( &$this, 'ultimatemember_directory' ) );
add_shortcode( 'um_loggedin', array( &$this, 'um_loggedin' ) );
add_shortcode( 'um_loggedout', array( &$this, 'um_loggedout' ) );
add_shortcode( 'um_show_content', array( &$this, 'um_shortcode_show_content_for_role' ) );
@@ -260,7 +265,7 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
if ( isset( $this->set_args ) && is_array( $this->set_args ) ) {
$args = $this->set_args;
unset( $args['file'] );
unset( $args['theme_file'] );
unset( $args['tpl'] );
@@ -358,12 +363,13 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
$args = wp_parse_args( $args, $defaults );
$args['lock_text'] = $this->convert_locker_tags( $args['lock_text'] );
if ( ! is_user_logged_in() ) {
if ( $args['show_lock'] == 'no' ) {
echo '';
} else {
$args['lock_text'] = $this->convert_locker_tags( $args['lock_text'] );
$this->set_args = $args;
$this->load_template( 'login-to-view' );
}
@@ -375,8 +381,14 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
return $output;
}
/***
*** @Logged-out only content
/**
* Logged-out only content
*
* @param array $args
* @param string $content
*
* @return string
*/
function um_loggedout($args = array(), $content = "") {
ob_start();
@@ -393,6 +405,124 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
}
/**
* @param array $args
*
* @return string
*/
function ultimatemember_login( $args = array() ) {
global $wpdb;
$args = ! empty( $args ) ? $args : array();
$default_login = $wpdb->get_var(
"SELECT pm.post_id
FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->postmeta} pm2 ON( pm.post_id = pm2.post_id AND pm2.meta_key = '_um_is_default' )
WHERE pm.meta_key = '_um_mode' AND
pm.meta_value = 'login' AND
pm2.meta_value = '1'"
);
$args['form_id'] = $default_login;
$shortcode_attrs = '';
foreach ( $args as $key => $value ) {
$shortcode_attrs .= " {$key}=\"{$value}\"";
}
return do_shortcode( "[ultimatemember {$shortcode_attrs} /]" );
}
/**
* @param array $args
*
* @return string
*/
function ultimatemember_register( $args = array() ) {
global $wpdb;
$args = ! empty( $args ) ? $args : array();
$default_register = $wpdb->get_var(
"SELECT pm.post_id
FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->postmeta} pm2 ON( pm.post_id = pm2.post_id AND pm2.meta_key = '_um_is_default' )
WHERE pm.meta_key = '_um_mode' AND
pm.meta_value = 'register' AND
pm2.meta_value = '1'"
);
$args['form_id'] = $default_register;
$shortcode_attrs = '';
foreach ( $args as $key => $value ) {
$shortcode_attrs .= " {$key}=\"{$value}\"";
}
return do_shortcode( "[ultimatemember {$shortcode_attrs} /]" );
}
/**
* @param array $args
*
* @return string
*/
function ultimatemember_profile( $args = array() ) {
global $wpdb;
$args = ! empty( $args ) ? $args : array();
$default_profile = $wpdb->get_var(
"SELECT pm.post_id
FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->postmeta} pm2 ON( pm.post_id = pm2.post_id AND pm2.meta_key = '_um_is_default' )
WHERE pm.meta_key = '_um_mode' AND
pm.meta_value = 'profile' AND
pm2.meta_value = '1'"
);
$args['form_id'] = $default_profile;
$shortcode_attrs = '';
foreach ( $args as $key => $value ) {
$shortcode_attrs .= " {$key}=\"{$value}\"";
}
return do_shortcode( "[ultimatemember {$shortcode_attrs} /]" );
}
/**
* @param array $args
*
* @return string
*/
function ultimatemember_directory( $args = array() ) {
global $wpdb;
$args = ! empty( $args ) ? $args : array();
$default_directory = $wpdb->get_var(
"SELECT pm.post_id
FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->postmeta} pm2 ON( pm.post_id = pm2.post_id AND pm2.meta_key = '_um_is_default' )
WHERE pm.meta_key = '_um_mode' AND
pm.meta_value = 'directory' AND
pm2.meta_value = '1'"
);
$args['form_id'] = $default_directory;
$shortcode_attrs = '';
foreach ( $args as $key => $value ) {
$shortcode_attrs .= " {$key}=\"{$value}\"";
}
return do_shortcode( "[ultimatemember {$shortcode_attrs} /]" );
}
/**
* Shortcode
*
@@ -813,7 +943,36 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
* @return string
*/
function get_shortcode( $post_id ) {
$shortcode = '[ultimatemember form_id=' . $post_id . ']';
$shortcode = '[ultimatemember form_id="' . $post_id . '"]';
return $shortcode;
}
/**
* Get Shortcode for given form ID
*
* @param $post_id
*
* @return string
*/
function get_default_shortcode( $post_id ) {
$mode = UM()->query()->get_attr( 'mode', $post_id );
switch ( $mode ) {
case 'login':
$shortcode = '[ultimatemember_login]';
break;
case 'profile':
$shortcode = '[ultimatemember_profile]';
break;
case 'register':
$shortcode = '[ultimatemember_register]';
break;
case 'directory':
$shortcode = '[ultimatemember_directory]';
break;
}
return $shortcode;
}
+41
View File
@@ -0,0 +1,41 @@
<?php
namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Templates' ) ) {
/**
* Class Templates
* @package um\core
*/
class Templates {
function __construct() {
}
/**
* Get template path
*
*
* @param $slug
* @return string
*/
function get_template( $slug ) {
$file_list = um_path . "templates/{$slug}.php";
$theme_file = get_stylesheet_directory() . "/ultimate-member/templates/{$slug}.php";
if ( file_exists( $theme_file ) ) {
$file_list = $theme_file;
}
return $file_list;
}
}
}
+85 -54
View File
@@ -95,7 +95,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
$this->core_upload_dir = DIRECTORY_SEPARATOR . "ultimatemember" . DIRECTORY_SEPARATOR;
$this->core_upload_url = "/ultimatemember/";
$this->upload_image_type = 'stream_photo';
$this->wp_upload_dir = wp_upload_dir();
$this->wp_upload_dir = wp_upload_dir();
$this->temp_upload_dir = "temp";
add_filter( "upload_dir", array( $this, "set_upload_directory" ), 10, 1 );
@@ -120,7 +120,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
/**
* Get core temporary directory path
*
* @since 2.0.22
* @since 2.0.22
* @return string
*/
public function get_core_temp_dir() {
@@ -131,7 +131,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
/**
* Get core temporary directory URL
*
* @since 2.0.22
* @since 2.0.22
* @return string
*/
public function get_core_temp_url() {
@@ -142,7 +142,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
/**
* Get core upload directory
*
* @since 2.0.22
* @since 2.0.22
* @return string
*/
public function get_core_upload_dir() {
@@ -153,7 +153,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
/**
* Get core upload base url
*
* @since 2.0.22
* @since 2.0.22
* @return string
*/
public function get_upload_base_url() {
@@ -168,7 +168,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
/**
* Get core upload base directory
*
* @since 2.0.22
* @since 2.0.22
* @return string
*/
public function get_upload_base_dir() {
@@ -198,7 +198,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
$this->upload_user_basedir = $this->get_upload_base_dir() . $this->user_id;
if ( $create_dir ) {
wp_mkdir_p( $this->upload_user_basedir );
wp_mkdir_p( $this->upload_user_basedir );
}
return $this->upload_user_basedir;
@@ -207,9 +207,9 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
/**
* Get user upload base url
*
*
* @param integer $user_id
* @since 2.0.22
* @since 2.0.22
* @return string
*/
public function get_upload_user_base_url( $user_id = null ) {
@@ -222,10 +222,10 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
return $this->upload_user_baseurl;
}
/**
* Validate file size
* @param array $file
* @param array $file
* @return array
*/
public function validate_upload( $file ) {
@@ -312,7 +312,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
if ( in_array( $field_key, array( 'profile_photo','cover_photo' ) ) ) {
$this->upload_image_type = $field_key;
}
}
$field_data = UM()->fields()->get_field( $field_key );
@@ -326,7 +326,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
foreach ( $field_allowed_file_types as $a ) {
$atype = wp_check_filetype( "test.{$a}" );
$allowed_image_mimes[ $atype['ext'] ] = $atype['type'];
$allowed_image_mimes[ $atype['ext'] ] = $atype['type'];
}
$image_compression = UM()->options()->get('image_compression');
@@ -352,9 +352,9 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
$movefile['url'] = set_url_scheme( $movefile['url'] );
$movefile['file_info']['basename'] = wp_basename( $movefile['file'] );
$file_type = wp_check_filetype( $movefile['file_info']['basename'] );
$movefile['file_info']['name'] = $movefile['url'];
$movefile['file_info']['original_name'] = $uploadedfile['name'];
$movefile['file_info']['ext'] = $file_type['ext'];
@@ -454,7 +454,10 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
$filename = wp_basename( $movefile['url'] );
set_transient( "um_{$filename}", $movefile['file_info'], 2 * HOUR_IN_SECONDS );
$transient = set_transient( "um_{$filename}", $movefile['file_info'], 2 * HOUR_IN_SECONDS );
if ( empty( $transient ) ) {
update_user_meta( $this->user_id, "{$field_key}_metadata_temp", $movefile['file_info'] );
}
}
$response['handle_upload'] = $movefile;
@@ -497,7 +500,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
foreach ( $field_allowed_file_types as $a ) {
$atype = wp_check_filetype( "test.{$a}" );
$allowed_file_mimes[ $atype['ext'] ] = $atype['type'];
$allowed_file_mimes[ $atype['ext'] ] = $atype['type'];
}
$upload_overrides = array(
@@ -529,7 +532,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
$movefile['file_info']['type'] = $file_type['type'];
$movefile['file_info']['size'] = filesize( $movefile['file'] );
$movefile['file_info']['size_format'] = size_format( $movefile['file_info']['size'] );
/**
* UM hook
@@ -619,7 +622,10 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
$filename = wp_basename( $movefile['url'] );
set_transient( "um_{$filename}", $movefile['file_info'], 2 * HOUR_IN_SECONDS );
$transient = set_transient( "um_{$filename}", $movefile['file_info'], 2 * HOUR_IN_SECONDS );
if ( empty( $transient ) ) {
update_user_meta( $this->user_id, "{$field_key}_metadata_temp", $movefile['file_info'] );
}
}
$response['handle_upload'] = $movefile;
@@ -854,12 +860,12 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
/**
* Make unique filename
* @param string $filename
* @param string $ext
* @param string $dir
* @param string $filename
* @param string $ext
* @param string $dir
* @return string $filename
*
* @since 2.0.22
* @since 2.0.22
*/
public function unique_filename( $filename, $ext, $dir ) {
$image_type = wp_check_filetype( $ext );
@@ -897,10 +903,10 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
/**
* Delete file
* @param string $filename
* @param string $ext
* @param string $dir
*
* @param string $filename
* @param string $ext
* @param string $dir
*
* @since 2.0.22
*/
public function delete_existing_file( $filename, $ext = '', $dir = '' ) {
@@ -912,11 +918,11 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
/**
* Profile photo image process
* @param string $src
* @param integer $user_id
* @param string $coord
* @param array $crop
*
* @param string $src
* @param integer $user_id
* @param string $coord
* @param array $crop
*
* @since 2.0.22
*/
public function profile_photo( $image_path, $src, $key, $user_id, $coord, $crop ) {
@@ -934,6 +940,11 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
$image->crop( $src_x, $src_y, $src_w, $src_h );
$max_w = UM()->options()->get('image_max_width');
if ( $src_w > $max_w ) {
$image->resize( $max_w, $src_h );
}
$image->save( $image_path );
$image->set_quality( $quality );
@@ -956,11 +967,11 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
/**
* Cover photo image process
* @param string $src
* @param integer $user_id
* @param string $coord
* @param array $crop
*
* @param string $src
* @param integer $user_id
* @param string $coord
* @param array $crop
*
* @since 2.0.22
*/
public function cover_photo( $image_path, $src, $key, $user_id, $coord, $crop ){
@@ -980,8 +991,13 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
$image->crop( $src_x, $src_y, $src_w, $src_h );
$max_w = UM()->options()->get('image_max_width');
if ( $src_w > $max_w ) {
$image->resize( $max_w, $src_h );
}
$image->save( $image_path );
$image->set_quality( $quality );
$sizes_array = array();
@@ -1000,15 +1016,15 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
/**
* Stream photo image process
* @param string $src
* @param integer $user_id
* @param string $coord
* @param array $crop
*
* @param string $src
* @param integer $user_id
* @param string $coord
* @param array $crop
*
* @since 2.0.22
*/
public function stream_photo( $image_path, $src, $key, $user_id, $coord, $crop ){
$image = wp_get_image_editor( $image_path ); // Return an implementation that extends WP_Image_Editor
$quality = UM()->options()->get( 'image_compression' );
@@ -1026,10 +1042,15 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
$src_h = $crop[3];
$image->crop( $src_x, $src_y, $src_w, $src_h );
$max_w = UM()->options()->get('image_max_width');
if ( $src_w > $max_w ) {
$image->resize( $max_w, $src_h );
}
}
$image->save( $image_path );
$image->set_quality( $quality );
} else {
@@ -1040,9 +1061,9 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
/**
* Set stream photo default settings
* @param array $args
* @return array
*
* @param array $args
* @return array
*
* @since 2.0.22
*/
public function stream_photo_data( $args ) {
@@ -1145,10 +1166,18 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
$new_files[ $key ] = $new_filename;
if ( rename( $temp_file_path, $file ) ) {
$file_info = get_transient("um_{$filename}");
update_user_meta( $user_id, $key, $new_filename );
update_user_meta( $user_id, "{$key}_metadata", $file_info );
delete_transient("um_{$filename}");
$file_info = get_transient( "um_{$filename}" );
if ( ! $file_info ) {
$file_info = get_user_meta( $user_id, "{$key}_metadata_temp", true );
delete_user_meta( $user_id, "{$key}_metadata_temp" );
}
if ( $file_info ) {
update_user_meta( $user_id, "{$key}_metadata", $file_info );
delete_transient( "um_{$filename}" );
}
}
}
}
@@ -1171,9 +1200,11 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
$user_meta_keys = UM()->user()->profile;
$_array = array();
foreach ( UM()->builtin()->custom_fields as $_field ) {
if ( $_field['type'] == 'file' && ! empty( $user_meta_keys[ $_field['metakey'] ] ) ) {
$_array[ $_field['metakey'] ] = $user_meta_keys[ $_field['metakey'] ];
if ( ! empty( UM()->builtin()->custom_fields ) ) {
foreach ( UM()->builtin()->custom_fields as $_field ) {
if ( $_field['type'] == 'file' && ! empty( $user_meta_keys[ $_field['metakey'] ] ) ) {
$_array[ $_field['metakey'] ] = $user_meta_keys[ $_field['metakey'] ];
}
}
}
$_array = array_merge( $_array, $new_files );
+6 -6
View File
@@ -177,7 +177,7 @@ add_action( 'um_profile_content_main', 'um_profile_content_main' );
*/
function um_user_edit_profile( $args ) {
$to_update = null;
$files = null;
$files = array();
if ( isset( $args['user_id'] ) ) {
if ( UM()->roles()->um_current_user_can( 'edit', $args['user_id'] ) ) {
@@ -218,18 +218,18 @@ function um_user_edit_profile( $args ) {
// loop through fields
if ( ! empty( $fields ) ) {
foreach ( $fields as $key => $array ) {
if ( ! um_can_edit_field( $fields[ $key ] ) && isset( $fields[ $key ]['editable'] ) && ! $fields[ $key ]['editable'] )
if ( ! um_can_edit_field( $array ) && isset( $array['editable'] ) && ! $array['editable'] ) {
continue;
}
if ( $fields[$key]['type'] == 'multiselect' || $fields[$key]['type'] == 'checkbox' && ! isset( $args['submitted'][ $key ] ) ) {
if ( $array['type'] == 'multiselect' || $array['type'] == 'checkbox' && ! isset( $args['submitted'][ $key ] ) ) {
delete_user_meta( um_user( 'ID' ), $key );
}
if ( isset( $args['submitted'][ $key ] ) ) {
if ( isset( $fields[ $key ]['type'] ) && in_array( $fields[ $key ]['type'], array( 'image', 'file' ) ) &&
if ( isset( $array['type'] ) && in_array( $array['type'], array( 'image', 'file' ) ) &&
( /*um_is_file_owner( UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . '/' . $args['submitted'][ $key ], um_user( 'ID' ) ) ||*/
um_is_temp_file( $args['submitted'][ $key ] ) || $args['submitted'][ $key ] == 'empty_file' ) ) {
@@ -366,7 +366,7 @@ function um_user_edit_profile( $args ) {
*/
$files = apply_filters( 'um_user_pre_updating_files_array', $files );
if ( is_array( $files ) ) {
if ( ! empty( $files ) && is_array( $files ) ) {
UM()->uploader()->move_temporary_files( um_user( 'ID' ), $files );
}
+29 -2
View File
@@ -38,8 +38,35 @@ function um_get_avatar( $avatar = '', $id_or_email='', $size = '96', $avatar_cla
um_fetch_user( $user_id );
$avatar = um_user('profile_photo', $size);
$avatar = um_user( 'profile_photo', $size );
return $avatar;
}
add_filter( 'get_avatar', 'um_get_avatar', 99999, 5 );
add_filter( 'get_avatar', 'um_get_avatar', 99999, 5 );
if ( ! function_exists( 'um_filter_get_avatar_url' ) ) {
/**
* Replace Gravatar image URL to Ultimate member profile image URL if setting "Use Gravatars?" disabled
*
* @param string $url
* @param int $id_or_email
* @param array $args
* @return string
*/
function um_filter_get_avatar_url( $url, $id_or_email, $args ) {
if ( is_numeric( $id_or_email ) && ! UM()->options()->get( 'use_gravatars' ) && preg_match( '/gravatar/i', $url ) ) {
$data = um_get_user_avatar_data( $id_or_email, $args['size'] );
if ( ! empty( $data['url'] ) ) {
$url = $data['url'];
}
}
return $url;
}
// hooked in the get_avatar_data function
add_filter( 'get_avatar_url', 'um_filter_get_avatar_url', 20, 3 );
}
+11 -9
View File
@@ -1671,6 +1671,9 @@ function um_get_cover_uri( $image, $attrs ) {
$uri_common = false;
$ext = '.' . pathinfo( $image, PATHINFO_EXTENSION );
$ratio = str_replace(':1','',UM()->options()->get( 'profile_cover_ratio' ) );
$height = round( $attrs / $ratio );
if ( is_multisite() ) {
//multisite fix for old customers
$multisite_fix_dir = UM()->uploader()->get_upload_base_dir();
@@ -1682,8 +1685,8 @@ function um_get_cover_uri( $image, $attrs ) {
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/cover_photo{$ext}?" . current_time( 'timestamp' );
}
if ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}x{$attrs}{$ext}" ) ) {
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/cover_photo-{$attrs}x{$attrs}{$ext}?". current_time( 'timestamp' );
if ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}x{$height}{$ext}" ) ) {
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/cover_photo-{$attrs}x{$height}{$ext}?". current_time( 'timestamp' );
} elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}{$ext}" ) ) {
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/cover_photo-{$attrs}{$ext}?" . current_time( 'timestamp' );
}
@@ -1693,8 +1696,8 @@ function um_get_cover_uri( $image, $attrs ) {
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/cover_photo{$ext}?" . current_time( 'timestamp' );
}
if ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}x{$attrs}{$ext}" ) ) {
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/cover_photo-{$attrs}x{$attrs}{$ext}?". current_time( 'timestamp' );
if ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}x{$height}{$ext}" ) ) {
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/cover_photo-{$attrs}x{$height}{$ext}?". current_time( 'timestamp' );
} elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}{$ext}" ) ) {
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/cover_photo-{$attrs}{$ext}?" . current_time( 'timestamp' );
}
@@ -2179,17 +2182,16 @@ function um_user( $data, $attrs = null ) {
}
if ($op == 'field' && UM()->options()->get( 'display_name_field' ) != '') {
if ( $op == 'field' && UM()->options()->get( 'display_name_field' ) != '' ) {
$fields = array_filter( preg_split( '/[,\s]+/', UM()->options()->get( 'display_name_field' ) ) );
$name = '';
foreach ($fields as $field) {
if (um_profile( $field )) {
foreach ( $fields as $field ) {
if ( um_profile( $field ) ) {
$name .= um_profile( $field ) . ' ';
} else if (um_user( $field )) {
} elseif ( um_user( $field ) && $field != 'display_name' ) {
$name .= um_user( $field ) . ' ';
}
}
}