mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-18 22:23:37 +09:00
- made hooks documentation;
- some optimizations and make single functions for some hooks;
This commit is contained in:
@@ -64,6 +64,37 @@ if ( ! class_exists( 'Access' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $restriction
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function um_custom_restriction( $restriction ) {
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_custom_restriction
|
||||
* @description Extend Sort Types for Member Directory
|
||||
* @input_vars
|
||||
* [{"var":"$custom_restriction","type":"bool","desc":"Custom Restriction"},
|
||||
* {"var":"$restriction","type":"array","desc":"Restriction settings"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_custom_restriction', 'function_name', 10, 2 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_custom_restriction', 'my_custom_restriction', 10, 2 );
|
||||
* function my_directory_sort_users_select( $custom_restriction, $restriction ) {
|
||||
* // your code here
|
||||
* return $custom_restriction;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
return apply_filters( 'um_custom_restriction', true, $restriction );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check individual term Content Restriction settings
|
||||
*/
|
||||
@@ -126,7 +157,7 @@ if ( ! class_exists( 'Access' ) ) {
|
||||
//if post for logged in users and user is not logged in
|
||||
if ( is_user_logged_in() ) {
|
||||
|
||||
$custom_restrict = apply_filters( 'um_custom_restriction', true, $restriction );
|
||||
$custom_restrict = $this->um_custom_restriction( $restriction );
|
||||
|
||||
if ( empty( $restriction['_um_access_roles'] ) || false === array_search( '1', $restriction['_um_access_roles'] ) ) {
|
||||
if ( $custom_restrict ) {
|
||||
@@ -351,8 +382,29 @@ if ( ! class_exists( 'Access' ) ) {
|
||||
*/
|
||||
function set_referer( $url, $referer ) {
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_access_enable_referer
|
||||
* @description Access Referrer Enable/Disable
|
||||
* @input_vars
|
||||
* [{"var":"$referrer","type":"bool","desc":"Access referrer"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_access_enable_referer', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_access_enable_referer', 'my_access_enable_referer', 10, 1 );
|
||||
* function my_access_enable_referer( $referrer ) {
|
||||
* // your code here
|
||||
* return $referrer;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$enable_referer = apply_filters( "um_access_enable_referer", false );
|
||||
if( ! $enable_referer ) return $url;
|
||||
if ( ! $enable_referer )
|
||||
return $url;
|
||||
|
||||
$url = add_query_arg( 'um_ref', $referer, $url );
|
||||
return $url;
|
||||
@@ -560,7 +612,7 @@ if ( ! class_exists( 'Access' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$custom_restrict = apply_filters( 'um_custom_restriction', true, $restriction );
|
||||
$custom_restrict = $this->um_custom_restriction( $restriction );
|
||||
|
||||
if ( empty( $restriction['_um_access_roles'] ) || false === array_search( '1', $restriction['_um_access_roles'] ) ) {
|
||||
if ( $custom_restrict ) {
|
||||
@@ -774,7 +826,7 @@ if ( ! class_exists( 'Access' ) ) {
|
||||
//if post for logged in users and user is not logged in
|
||||
if ( is_user_logged_in() ) {
|
||||
|
||||
$custom_restrict = apply_filters( 'um_custom_restriction', true, $restriction );
|
||||
$custom_restrict = $this->um_custom_restriction( $restriction );
|
||||
|
||||
if ( empty( $restriction['_um_access_roles'] ) || false === array_search( '1', $restriction['_um_access_roles'] ) ) {
|
||||
if ( $custom_restrict ) {
|
||||
|
||||
+199
-15
@@ -94,6 +94,26 @@ if ( ! class_exists( 'Account' ) ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_account_page_default_tabs_hook
|
||||
* @description Account Page Tabs
|
||||
* @input_vars
|
||||
* [{"var":"$tabs","type":"array","desc":"Account Page Tabs"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_account_page_default_tabs_hook', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_account_page_default_tabs_hook', 'my_account_page_default_tabs', 10, 1 );
|
||||
* function my_account_page_default_tabs( $tabs ) {
|
||||
* // your code here
|
||||
* return $tabs;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
return apply_filters( 'um_account_page_default_tabs_hook', $tabs );
|
||||
}
|
||||
|
||||
@@ -116,6 +136,26 @@ if ( ! class_exists( 'Account' ) ) {
|
||||
);
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_account_shortcode_args_filter
|
||||
* @description Account Shortcode Arguments
|
||||
* @input_vars
|
||||
* [{"var":"$args","type":"array","desc":"Shortcode Arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_account_shortcode_args_filter', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_account_shortcode_args_filter', 'my_account_shortcode_args', 10, 1 );
|
||||
* function my_account_shortcode_args( $args ) {
|
||||
* // your code here
|
||||
* return $args;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$args = apply_filters( 'um_account_shortcode_args_filter', $args );
|
||||
|
||||
if ( ! empty( $args['tab'] ) ) {
|
||||
@@ -265,8 +305,8 @@ if ( ! class_exists( 'Account' ) ) {
|
||||
function filter_fields_by_attrs( $fields, $shortcode_args ) {
|
||||
|
||||
foreach ( $fields as $k => $field ) {
|
||||
if ( isset( $shortcode_args[$field['metakey']] ) && 0 == $shortcode_args[$field['metakey']] )
|
||||
unset( $fields[$k] );
|
||||
if ( isset( $shortcode_args[ $field['metakey'] ] ) && 0 == $shortcode_args[ $field['metakey'] ] )
|
||||
unset( $fields[ $k ] );
|
||||
}
|
||||
|
||||
return $fields;
|
||||
@@ -274,6 +314,33 @@ if ( ! class_exists( 'Account' ) ) {
|
||||
}
|
||||
|
||||
|
||||
function account_secure_fields( $fields, $id ) {
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_account_secure_fields
|
||||
* @description Change Account secure fields
|
||||
* @input_vars
|
||||
* [{"var":"$fields","type":"array","desc":"Account Fields"},
|
||||
* {"var":"$id","type":"int","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_account_secure_fields', 'function_name', 10, 2 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_account_secure_fields', 'my_account_secure_fields', 10, 2 );
|
||||
* function my_account_secure_fields( $fields, $id ) {
|
||||
* // your code here
|
||||
* return $fields;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$fields = apply_filters( 'um_account_secure_fields', $fields, $id );
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* * Get Tab Output
|
||||
*
|
||||
@@ -296,12 +363,31 @@ if ( ! class_exists( 'Account' ) ) {
|
||||
case 'privacy':
|
||||
|
||||
$args = 'profile_privacy,hide_in_members';
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_account_tab_privacy_fields
|
||||
* @description Extend Account Tab Privacy
|
||||
* @input_vars
|
||||
* [{"var":"$args","type":"array","desc":"Account Arguments"},
|
||||
* {"var":"$shortcode_args","type":"array","desc":"Account Shortcode Arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_account_tab_privacy_fields', 'function_name', 10, 2 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_account_tab_privacy_fields', 'my_account_tab_privacy_fields', 10, 2 );
|
||||
* function my_account_tab_privacy_fields( $args, $shortcode_args ) {
|
||||
* // your code here
|
||||
* return $args;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$args = apply_filters( 'um_account_tab_privacy_fields', $args, $shortcode_args );
|
||||
|
||||
$fields = UM()->builtin()->get_specific_fields( $args );
|
||||
|
||||
$fields = apply_filters( 'um_account_secure_fields', $fields, $id );
|
||||
|
||||
$fields = $this->account_secure_fields( $fields, $id );
|
||||
$fields = $this->filter_fields_by_attrs( $fields, $shortcode_args );
|
||||
|
||||
foreach ( $fields as $key => $data ){
|
||||
@@ -314,12 +400,31 @@ if ( ! class_exists( 'Account' ) ) {
|
||||
|
||||
$args = 'single_user_password';
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_account_tab_delete_fields
|
||||
* @description Extend Account Tab Delete
|
||||
* @input_vars
|
||||
* [{"var":"$args","type":"array","desc":"Account Arguments"},
|
||||
* {"var":"$shortcode_args","type":"array","desc":"Account Shortcode Arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_account_tab_delete_fields', 'function_name', 10, 2 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_account_tab_delete_fields', 'my_account_tab_delete_fields', 10, 2 );
|
||||
* function my_account_tab_delete_fields( $args, $shortcode_args ) {
|
||||
* // your code here
|
||||
* return $args;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$args = apply_filters( 'um_account_tab_delete_fields', $args, $shortcode_args );
|
||||
|
||||
$fields = UM()->builtin()->get_specific_fields( $args );
|
||||
|
||||
$fields = apply_filters( 'um_account_secure_fields', $fields, $id );
|
||||
|
||||
$fields = $this->account_secure_fields( $fields, $id );
|
||||
$fields = $this->filter_fields_by_attrs( $fields, $shortcode_args );
|
||||
|
||||
foreach ( $fields as $key => $data ) {
|
||||
@@ -340,12 +445,31 @@ if ( ! class_exists( 'Account' ) ) {
|
||||
$args = str_replace(',user_email','', $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_account_tab_general_fields
|
||||
* @description Extend Account Tab General
|
||||
* @input_vars
|
||||
* [{"var":"$args","type":"array","desc":"Account Arguments"},
|
||||
* {"var":"$shortcode_args","type":"array","desc":"Account Shortcode Arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_account_tab_general_fields', 'function_name', 10, 2 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_account_tab_general_fields', 'my_account_tab_general_fields', 10, 2 );
|
||||
* function my_account_tab_general_fields( $args, $shortcode_args ) {
|
||||
* // your code here
|
||||
* return $args;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$args = apply_filters( 'um_account_tab_general_fields', $args, $shortcode_args );
|
||||
|
||||
$fields = UM()->builtin()->get_specific_fields( $args );
|
||||
|
||||
$fields = apply_filters( 'um_account_secure_fields', $fields, $id );
|
||||
|
||||
$fields = $this->account_secure_fields( $fields, $id );
|
||||
$fields = $this->filter_fields_by_attrs( $fields, $shortcode_args );
|
||||
|
||||
foreach ( $fields as $key => $data ) {
|
||||
@@ -358,12 +482,31 @@ if ( ! class_exists( 'Account' ) ) {
|
||||
|
||||
$args = 'user_password';
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_account_tab_password_fields
|
||||
* @description Extend Account Tab Password
|
||||
* @input_vars
|
||||
* [{"var":"$args","type":"array","desc":"Account Arguments"},
|
||||
* {"var":"$shortcode_args","type":"array","desc":"Account Shortcode Arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_account_tab_password_fields', 'function_name', 10, 2 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_account_tab_password_fields', 'my_account_tab_password_fields', 10, 2 );
|
||||
* function my_account_tab_password_fields( $args, $shortcode_args ) {
|
||||
* // your code here
|
||||
* return $args;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$args = apply_filters( 'um_account_tab_password_fields', $args, $shortcode_args );
|
||||
|
||||
$fields = UM()->builtin()->get_specific_fields( $args );
|
||||
|
||||
$fields = apply_filters( 'um_account_secure_fields', $fields, $id );
|
||||
|
||||
$fields = $this->account_secure_fields( $fields, $id );
|
||||
$fields = $this->filter_fields_by_attrs( $fields, $shortcode_args );
|
||||
|
||||
foreach ( $fields as $key => $data ) {
|
||||
@@ -374,6 +517,27 @@ if ( ! class_exists( 'Account' ) ) {
|
||||
|
||||
default :
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_account_content_hook_{$id}
|
||||
* @description Change not default Account tabs content
|
||||
* @input_vars
|
||||
* [{"var":"$output","type":"string","desc":"Account Tab Output"},
|
||||
* {"var":"$shortcode_args","type":"array","desc":"Account Shortcode Arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_account_content_hook_{$id}', 'function_name', 10, 2 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_account_content_hook_{$id}', 'my_account_content', 10, 2 );
|
||||
* function my_account_tab_password_fields( $args, $shortcode_args ) {
|
||||
* // your code here
|
||||
* return $args;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$output = apply_filters( "um_account_content_hook_{$id}", $output, $shortcode_args );
|
||||
break;
|
||||
|
||||
@@ -448,7 +612,27 @@ if ( ! class_exists( 'Account' ) ) {
|
||||
$classes .= ' um-viewing';
|
||||
}
|
||||
|
||||
$classes = apply_filters('um_form_official_classes__hook', $classes);
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_form_official_classes__hook
|
||||
* @description Change not default Account tabs content
|
||||
* @input_vars
|
||||
* [{"var":"$classes","type":"string","desc":"Form Classes"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_form_official_classes__hook', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_form_official_classes__hook', 'my_form_official_classes', 10, 1 );
|
||||
* function my_form_official_classes( $classes ) {
|
||||
* // your code here
|
||||
* return $classes;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$classes = apply_filters( 'um_form_official_classes__hook', $classes );
|
||||
return $classes;
|
||||
}
|
||||
}
|
||||
|
||||
+130
-10
@@ -533,8 +533,27 @@ if ( ! class_exists( 'Builtin' ) ) {
|
||||
|
||||
);
|
||||
|
||||
$this->core_fields = apply_filters('um_core_fields_hook', $this->core_fields );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_core_fields_hook
|
||||
* @description UM Core Fields
|
||||
* @input_vars
|
||||
* [{"var":"$core_fields","type":"array","desc":"Core Fields"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_core_fields_hook', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_core_fields_hook', 'my_core_fields', 10, 1 );
|
||||
* function my_core_fields( $core_fields ) {
|
||||
* // your code here
|
||||
* return $core_fields;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$this->core_fields = apply_filters( 'um_core_fields_hook', $this->core_fields );
|
||||
}
|
||||
|
||||
/***
|
||||
@@ -556,7 +575,30 @@ if ( ! class_exists( 'Builtin' ) ) {
|
||||
|
||||
$um_roles = UM()->roles()->get_roles( false, $exclude_roles );
|
||||
|
||||
$profile_privacy = apply_filters('um_profile_privacy_options', array( __('Everyone','ultimate-member'), __('Only me','ultimate-member') ) );
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_profile_privacy_options
|
||||
* @description Profile Privacy Options
|
||||
* @input_vars
|
||||
* [{"var":"$privacy_options","type":"array","desc":"Privacy Options"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_profile_privacy_options', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_profile_privacy_options', 'my_profile_privacy_options', 10, 1 );
|
||||
* function my_profile_privacy_options( $privacy_options ) {
|
||||
* // your code here
|
||||
* return $privacy_options;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$profile_privacy = apply_filters( 'um_profile_privacy_options', array(
|
||||
__( 'Everyone', 'ultimate-member' ),
|
||||
__( 'Only me', 'ultimate-member' )
|
||||
) );
|
||||
|
||||
$this->predefined_fields = array(
|
||||
|
||||
@@ -1050,8 +1092,27 @@ if ( ! class_exists( 'Builtin' ) ) {
|
||||
|
||||
);
|
||||
|
||||
$this->predefined_fields = apply_filters('um_predefined_fields_hook', $this->predefined_fields );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_predefined_fields_hook
|
||||
* @description Extend Predefined Fields
|
||||
* @input_vars
|
||||
* [{"var":"$predefined_fields","type":"array","desc":"Predefined Fields"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_predefined_fields_hook', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_predefined_fields_hook', 'my_predefined_fields', 10, 1 );
|
||||
* function my_predefined_fields( $predefined_fields ) {
|
||||
* // your code here
|
||||
* return $predefined_fields;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$this->predefined_fields = apply_filters( 'um_predefined_fields_hook', $this->predefined_fields );
|
||||
}
|
||||
|
||||
/***
|
||||
@@ -1087,7 +1148,28 @@ if ( ! class_exists( 'Builtin' ) ) {
|
||||
|
||||
$fields_without_metakey = array('block','shortcode','spacing','divider','group');
|
||||
remove_filter('um_fields_without_metakey', 'um_user_tags_requires_no_metakey');
|
||||
$fields_without_metakey = apply_filters('um_fields_without_metakey', $fields_without_metakey );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_fields_without_metakey
|
||||
* @description Extend Fields without metakey
|
||||
* @input_vars
|
||||
* [{"var":"$fields","type":"array","desc":"Fields without metakey"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_fields_without_metakey', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_fields_without_metakey', 'my_fields_without_metakey', 10, 1 );
|
||||
* function my_fields_without_metakey( $fields ) {
|
||||
* // your code here
|
||||
* return $fields;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$fields_without_metakey = apply_filters( 'um_fields_without_metakey', $fields_without_metakey );
|
||||
|
||||
if ( !$show_all ) {
|
||||
$this->fields_dropdown = array('image','file','password','rating');
|
||||
@@ -1169,7 +1251,27 @@ if ( ! class_exists( 'Builtin' ) ) {
|
||||
$array['youtube_url'] = __('YouTube Profile','ultimate-member');
|
||||
$array['custom'] = __('Custom Validation','ultimate-member');
|
||||
|
||||
$array = apply_filters('um_admin_field_validation_hook', $array );
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_admin_field_validation_hook
|
||||
* @description Extend validation types
|
||||
* @input_vars
|
||||
* [{"var":"$types","type":"array","desc":"Validation Types"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_admin_field_validation_hook', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_admin_field_validation_hook', 'my_admin_field_validation', 10, 1 );
|
||||
* function my_admin_field_validation( $types ) {
|
||||
* // your code here
|
||||
* return $types;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$array = apply_filters( 'um_admin_field_validation_hook', $array );
|
||||
return $array;
|
||||
}
|
||||
|
||||
@@ -1622,10 +1724,28 @@ if ( ! class_exists( 'Builtin' ) ) {
|
||||
|
||||
}
|
||||
|
||||
$array = apply_filters("um_{$data}_predefined_field_options", $array);
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_{$data}_predefined_field_options
|
||||
* @description Extend Predefined Fields options. Where $data - field key.
|
||||
* @input_vars
|
||||
* [{"var":"$options","type":"array","desc":"Field's Options"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_{$data}_predefined_field_options', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_{$data}_predefined_field_options', 'my_predefined_field', 10, 1 );
|
||||
* function my_predefined_field( $options ) {
|
||||
* // your code here
|
||||
* return $options;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$array = apply_filters( "um_{$data}_predefined_field_options", $array );
|
||||
return $array;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,58 +5,113 @@ namespace um\core;
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if ( ! class_exists( 'Cron' ) ) {
|
||||
class Cron {
|
||||
/**
|
||||
* Class Cron
|
||||
* @package um\core
|
||||
*/
|
||||
class Cron {
|
||||
|
||||
public function __construct() {
|
||||
/**
|
||||
* Cron constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$um_cron = apply_filters('um_cron_disable', false );
|
||||
if( $um_cron ) return;
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_cron_disable
|
||||
* @description Make UM Cron Actions Enabled or Disabled
|
||||
* @input_vars
|
||||
* [{"var":"$cron_disable","type":"bool","desc":"Disable UM Cron?"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_cron_disable', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_cron_disable', 'my_cron_disable', 10, 1 );
|
||||
* function my_predefined_field( $cron_disable ) {
|
||||
* // your code here
|
||||
* return $cron_disable;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$um_cron = apply_filters( 'um_cron_disable', false );
|
||||
if ( $um_cron ) {
|
||||
return;
|
||||
}
|
||||
|
||||
add_filter( 'cron_schedules', array( $this, 'add_schedules' ) );
|
||||
add_action( 'wp', array( $this, 'schedule_Events' ) );
|
||||
}
|
||||
add_filter( 'cron_schedules', array( $this, 'add_schedules' ) );
|
||||
add_action( 'wp', array( $this, 'schedule_Events' ) );
|
||||
}
|
||||
|
||||
public function add_schedules( $schedules = array() ) {
|
||||
|
||||
// Adds once weekly to the existing schedules.
|
||||
$schedules['weekly'] = array(
|
||||
'interval' => 604800,
|
||||
'display' => __( 'Once Weekly', 'ultimate-member' )
|
||||
);
|
||||
/**
|
||||
* @param array $schedules
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_schedules( $schedules = array() ) {
|
||||
|
||||
return $schedules;
|
||||
}
|
||||
// Adds once weekly to the existing schedules.
|
||||
$schedules['weekly'] = array(
|
||||
'interval' => 604800,
|
||||
'display' => __( 'Once Weekly', 'ultimate-member' )
|
||||
);
|
||||
|
||||
public function schedule_Events() {
|
||||
$this->weekly_events();
|
||||
$this->daily_events();
|
||||
$this->twicedaily_events();
|
||||
$this->hourly_events();
|
||||
}
|
||||
return $schedules;
|
||||
}
|
||||
|
||||
private function weekly_events() {
|
||||
if ( ! wp_next_scheduled( 'um_weekly_scheduled_events' ) ) {
|
||||
wp_schedule_event( current_time( 'timestamp' ), 'weekly', 'um_weekly_scheduled_events' );
|
||||
}
|
||||
}
|
||||
|
||||
private function daily_events() {
|
||||
if ( ! wp_next_scheduled( 'um_daily_scheduled_events' ) ) {
|
||||
wp_schedule_event( current_time( 'timestamp' ), 'daily', 'um_daily_scheduled_events' );
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function schedule_Events() {
|
||||
$this->weekly_events();
|
||||
$this->daily_events();
|
||||
$this->twicedaily_events();
|
||||
$this->hourly_events();
|
||||
}
|
||||
|
||||
private function twicedaily_events() {
|
||||
if ( ! wp_next_scheduled( 'um_twicedaily_scheduled_events' ) ) {
|
||||
wp_schedule_event( current_time( 'timestamp' ), 'twicedaily', 'um_twicedaily_scheduled_events' );
|
||||
}
|
||||
}
|
||||
|
||||
private function hourly_events() {
|
||||
if ( ! wp_next_scheduled( 'um_hourly_scheduled_events' ) ) {
|
||||
wp_schedule_event( current_time( 'timestamp' ), 'hourly', 'um_hourly_scheduled_events' );
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function weekly_events() {
|
||||
if ( ! wp_next_scheduled( 'um_weekly_scheduled_events' ) ) {
|
||||
wp_schedule_event( current_time( 'timestamp' ), 'weekly', 'um_weekly_scheduled_events' );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function daily_events() {
|
||||
if ( ! wp_next_scheduled( 'um_daily_scheduled_events' ) ) {
|
||||
wp_schedule_event( current_time( 'timestamp' ), 'daily', 'um_daily_scheduled_events' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function twicedaily_events() {
|
||||
if ( ! wp_next_scheduled( 'um_twicedaily_scheduled_events' ) ) {
|
||||
wp_schedule_event( current_time( 'timestamp' ), 'twicedaily', 'um_twicedaily_scheduled_events' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function hourly_events() {
|
||||
if ( ! wp_next_scheduled( 'um_hourly_scheduled_events' ) ) {
|
||||
wp_schedule_event( current_time( 'timestamp' ), 'hourly', 'um_hourly_scheduled_events' );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,121 +5,190 @@ namespace um\core;
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if ( ! class_exists( 'Date_Time' ) ) {
|
||||
class Date_Time {
|
||||
|
||||
function __construct() {
|
||||
|
||||
}
|
||||
/**
|
||||
* Class Date_Time
|
||||
* @package um\core
|
||||
*/
|
||||
class Date_Time {
|
||||
|
||||
/***
|
||||
*** @Display time in specific format
|
||||
***/
|
||||
function get_time( $format ) {
|
||||
return current_time( $format );
|
||||
}
|
||||
/**
|
||||
* Date_Time constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
|
||||
/***
|
||||
*** @Show a cool time difference between 2 timestamps
|
||||
***/
|
||||
function time_diff( $from, $to = '' ) {
|
||||
if ( empty( $to ) ) {
|
||||
$to = time();
|
||||
}
|
||||
$diff = (int) abs( $to - $from );
|
||||
if ( $diff < 60 ) {
|
||||
}
|
||||
|
||||
$since = __('just now','ultimate-member');
|
||||
|
||||
} elseif ( $diff < HOUR_IN_SECONDS ) {
|
||||
/**
|
||||
* Display time in specific format
|
||||
*
|
||||
* @param $format
|
||||
*
|
||||
* @return int|string
|
||||
*/
|
||||
function get_time( $format ) {
|
||||
return current_time( $format );
|
||||
}
|
||||
|
||||
$mins = round( $diff / MINUTE_IN_SECONDS );
|
||||
if ( $mins <= 1 )
|
||||
$mins = 1;
|
||||
if ( $mins == 1 ) {
|
||||
$since = sprintf( __('%s min','ultimate-member'), $mins );
|
||||
} else {
|
||||
$since = sprintf( __('%s mins','ultimate-member'), $mins );
|
||||
}
|
||||
|
||||
} elseif ( $diff < DAY_IN_SECONDS && $diff >= HOUR_IN_SECONDS ) {
|
||||
/**
|
||||
* Show a cool time difference between 2 timestamps
|
||||
*
|
||||
* @param $from
|
||||
* @param string $to
|
||||
*
|
||||
* @return mixed|void
|
||||
*/
|
||||
function time_diff( $from, $to = '' ) {
|
||||
$since = '';
|
||||
|
||||
$hours = round( $diff / HOUR_IN_SECONDS );
|
||||
if ( $hours <= 1 )
|
||||
$hours = 1;
|
||||
if ( $hours == 1 ) {
|
||||
$since = sprintf( __('%s hr','ultimate-member'), $hours );
|
||||
} else {
|
||||
$since = sprintf( __('%s hrs','ultimate-member'), $hours );
|
||||
}
|
||||
if ( empty( $to ) ) {
|
||||
$to = time();
|
||||
}
|
||||
|
||||
} elseif ( $diff < WEEK_IN_SECONDS && $diff >= DAY_IN_SECONDS ) {
|
||||
$diff = (int) abs( $to - $from );
|
||||
if ( $diff < 60 ) {
|
||||
|
||||
$days = round( $diff / DAY_IN_SECONDS );
|
||||
if ( $days <= 1 )
|
||||
$days = 1;
|
||||
if ( $days == 1 ) {
|
||||
$since = sprintf( __('Yesterday at %s','ultimate-member'), date('g:ia', $from ) );
|
||||
} else {
|
||||
$since = sprintf(__('%s at %s','ultimate-member'), date('F d', $from ), date('g:ia', $from ) );
|
||||
}
|
||||
$since = __('just now','ultimate-member');
|
||||
|
||||
} elseif ( $diff < 30 * DAY_IN_SECONDS && $diff >= WEEK_IN_SECONDS ) {
|
||||
} elseif ( $diff < HOUR_IN_SECONDS ) {
|
||||
|
||||
$since = sprintf(__('%s at %s','ultimate-member'), date('F d', $from ), date('g:ia', $from ) );
|
||||
$mins = round( $diff / MINUTE_IN_SECONDS );
|
||||
if ( $mins <= 1 )
|
||||
$mins = 1;
|
||||
if ( $mins == 1 ) {
|
||||
$since = sprintf( __('%s min','ultimate-member'), $mins );
|
||||
} else {
|
||||
$since = sprintf( __('%s mins','ultimate-member'), $mins );
|
||||
}
|
||||
|
||||
} elseif ( $diff < YEAR_IN_SECONDS && $diff >= 30 * DAY_IN_SECONDS ) {
|
||||
} elseif ( $diff < DAY_IN_SECONDS && $diff >= HOUR_IN_SECONDS ) {
|
||||
|
||||
$since = sprintf(__('%s at %s','ultimate-member'), date('F d', $from ), date('g:ia', $from ) );
|
||||
$hours = round( $diff / HOUR_IN_SECONDS );
|
||||
if ( $hours <= 1 )
|
||||
$hours = 1;
|
||||
if ( $hours == 1 ) {
|
||||
$since = sprintf( __('%s hr','ultimate-member'), $hours );
|
||||
} else {
|
||||
$since = sprintf( __('%s hrs','ultimate-member'), $hours );
|
||||
}
|
||||
|
||||
} elseif ( $diff >= YEAR_IN_SECONDS ) {
|
||||
} elseif ( $diff < WEEK_IN_SECONDS && $diff >= DAY_IN_SECONDS ) {
|
||||
|
||||
$since = sprintf(__('%s at %s','ultimate-member'), date( 'F d, Y', $from ), date('g:ia', $from ) );
|
||||
$days = round( $diff / DAY_IN_SECONDS );
|
||||
if ( $days <= 1 )
|
||||
$days = 1;
|
||||
if ( $days == 1 ) {
|
||||
$since = sprintf( __('Yesterday at %s','ultimate-member'), date('g:ia', $from ) );
|
||||
} else {
|
||||
$since = sprintf(__('%s at %s','ultimate-member'), date('F d', $from ), date('g:ia', $from ) );
|
||||
}
|
||||
|
||||
}
|
||||
} elseif ( $diff < 30 * DAY_IN_SECONDS && $diff >= WEEK_IN_SECONDS ) {
|
||||
|
||||
return apply_filters( 'um_human_time_diff', $since, $diff, $from, $to );
|
||||
}
|
||||
$since = sprintf(__('%s at %s','ultimate-member'), date('F d', $from ), date('g:ia', $from ) );
|
||||
|
||||
/***
|
||||
*** @Get age
|
||||
***/
|
||||
function get_age($then) {
|
||||
if ( !$then ) return '';
|
||||
$then_ts = strtotime($then);
|
||||
$then_year = date('Y', $then_ts);
|
||||
$age = date('Y') - $then_year;
|
||||
if( strtotime('+' . $age . ' years', $then_ts) > current_time( 'timestamp' ) ) $age--;
|
||||
if ( $age == 1 )
|
||||
return sprintf(__('%s year old','ultimate-member'), $age );
|
||||
if ( $age > 1 )
|
||||
return sprintf(__('%s years old','ultimate-member'), $age );
|
||||
if ( $age == 0 )
|
||||
return __('Less than 1 year old','ultimate-member');
|
||||
}
|
||||
} elseif ( $diff < YEAR_IN_SECONDS && $diff >= 30 * DAY_IN_SECONDS ) {
|
||||
|
||||
/***
|
||||
*** @Reformat dates
|
||||
***/
|
||||
function format($old, $new){
|
||||
$datetime = new \DateTime($old);
|
||||
$output = $datetime->format( $new );
|
||||
return $output;
|
||||
}
|
||||
$since = sprintf(__('%s at %s','ultimate-member'), date('F d', $from ), date('g:ia', $from ) );
|
||||
|
||||
/***
|
||||
*** @Get last 30 days as array
|
||||
***/
|
||||
function get_last_days($num = 30, $reverse = true) {
|
||||
$d = array();
|
||||
for($i = 0; $i < $num; $i++) {
|
||||
$d[ date('Y-m-d', strtotime('-'. $i .' days')) ] = date('m/d', strtotime('-'. $i .' days'));
|
||||
}
|
||||
if ($reverse == true){
|
||||
return array_reverse($d);
|
||||
} else {
|
||||
return $d;
|
||||
}
|
||||
}
|
||||
} elseif ( $diff >= YEAR_IN_SECONDS ) {
|
||||
|
||||
}
|
||||
$since = sprintf(__('%s at %s','ultimate-member'), date( 'F d, Y', $from ), date('g:ia', $from ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_human_time_diff
|
||||
* @description Change human time string
|
||||
* @input_vars
|
||||
* [{"var":"$since","type":"string","desc":"Disable UM Cron?"},
|
||||
* {"var":"$diff","type":"int","desc":"Difference in seconds"},
|
||||
* {"var":"$from","type":"int","desc":"From Timestamp"},
|
||||
* {"var":"$to","type":"int","desc":"To Timestamp"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_human_time_diff', 'function_name', 10, 4 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_human_time_diff', 'my_human_time_diff', 10, 4 );
|
||||
* function my_human_time_diff( $since, $diff, $from, $to ) {
|
||||
* // your code here
|
||||
* return $since;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
return apply_filters( 'um_human_time_diff', $since, $diff, $from, $to );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get age
|
||||
*
|
||||
* @param $then
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_age( $then ) {
|
||||
if ( ! $then ) {
|
||||
return '';
|
||||
}
|
||||
$then_ts = strtotime( $then );
|
||||
$then_year = date( 'Y', $then_ts );
|
||||
$age = date( 'Y' ) - $then_year;
|
||||
if ( strtotime( '+' . $age . ' years', $then_ts ) > current_time( 'timestamp' ) ) {
|
||||
$age--;
|
||||
}
|
||||
if ( $age == 1 ) {
|
||||
return sprintf( __( '%s year old', 'ultimate-member' ), $age );
|
||||
}
|
||||
if ( $age > 1 ) {
|
||||
return sprintf( __( '%s years old', 'ultimate-member' ), $age );
|
||||
}
|
||||
if ( $age == 0 ) {
|
||||
return __( 'Less than 1 year old', 'ultimate-member' );
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reformat dates
|
||||
*
|
||||
* @param $old
|
||||
* @param $new
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function format( $old, $new ) {
|
||||
$datetime = new \DateTime( $old );
|
||||
$output = $datetime->format( $new );
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get last 30 days as array
|
||||
*
|
||||
* @param int $num
|
||||
* @param bool $reverse
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_last_days( $num = 30, $reverse = true ) {
|
||||
$d = array();
|
||||
for ( $i = 0; $i < $num; $i++ ) {
|
||||
$d[ date('Y-m-d', strtotime( '-' . $i . ' days' ) ) ] = date( 'm/d', strtotime( '-' . $i . ' days' ) );
|
||||
}
|
||||
|
||||
return ( $reverse ) ? array_reverse( $d ) : $d;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+349
-277
@@ -5,394 +5,466 @@ namespace um\core;
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if ( ! class_exists( 'Enqueue' ) ) {
|
||||
class Enqueue {
|
||||
|
||||
var $suffix = '';
|
||||
|
||||
function __construct() {
|
||||
/**
|
||||
* Class Enqueue
|
||||
* @package um\core
|
||||
*/
|
||||
class Enqueue {
|
||||
|
||||
$priority = apply_filters( 'um_core_enqueue_priority', 100 );
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
var $suffix = '';
|
||||
|
||||
/**
|
||||
* Enqueue constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_core_enqueue_priority
|
||||
* @description Change Enqueue scripts priority
|
||||
* @input_vars
|
||||
* [{"var":"$priority","type":"int","desc":"Priority"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_core_enqueue_priority', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_core_enqueue_priority', 'my_core_enqueue_priority', 10, 1 );
|
||||
* function my_core_enqueue_priority( $priority ) {
|
||||
* // your code here
|
||||
* return $priority;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$priority = apply_filters( 'um_core_enqueue_priority', 100 );
|
||||
add_action( 'wp_enqueue_scripts', array( &$this, 'wp_enqueue_scripts' ), $priority );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Minify css string
|
||||
***/
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* 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';
|
||||
/**
|
||||
* Enqueue scripts and styles
|
||||
*/
|
||||
function wp_enqueue_scripts() {
|
||||
global $post;
|
||||
|
||||
$this->suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || defined('UM_SCRIPT_DEBUG') ) ? '' : '.min';
|
||||
|
||||
$exclude = UM()->options()->get('js_css_exclude');
|
||||
if ( is_array( $exclude ) ) {
|
||||
array_filter( $exclude );
|
||||
}
|
||||
if ( $exclude && !is_admin() && is_array( $exclude ) ) {
|
||||
|
||||
$c_url = UM()->permalinks()->get_current_url( get_option('permalink_structure') );
|
||||
|
||||
foreach( $exclude as $match ) {
|
||||
if ( ! empty( $c_url ) && strstr( $c_url, untrailingslashit( $match ) ) ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
$exclude = UM()->options()->get('js_css_exclude');
|
||||
if ( is_array( $exclude ) ) {
|
||||
array_filter( $exclude );
|
||||
}
|
||||
if ( $exclude && !is_admin() && is_array( $exclude ) ) {
|
||||
|
||||
$c_url = UM()->permalinks()->get_current_url( get_option('permalink_structure') );
|
||||
|
||||
foreach( $exclude as $match ) {
|
||||
if ( ! empty( $c_url ) && strstr( $c_url, untrailingslashit( $match ) ) ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$include = UM()->options()->get('js_css_include');
|
||||
if ( is_array( $include ) ) {
|
||||
array_filter( $include );
|
||||
}
|
||||
if ( $include && !is_admin() && is_array( $include ) ) {
|
||||
|
||||
$c_url = UM()->permalinks()->get_current_url( get_option('permalink_structure') );
|
||||
|
||||
foreach( $include as $match ) {
|
||||
if ( strstr( $c_url, untrailingslashit( $match ) ) ) {
|
||||
$force_load = true;
|
||||
} else {
|
||||
if ( !isset( $force_load ) ) {
|
||||
$force_load = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( isset($force_load) && $force_load == false ) return;
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_enqueue_localize_data
|
||||
* @description Extend UM localized data
|
||||
* @input_vars
|
||||
* [{"var":"$data","type":"array","desc":"Localize Array"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_enqueue_localize_data', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_enqueue_localize_data', 'my_enqueue_localize_data', 10, 1 );
|
||||
* function my_enqueue_localize_data( $data ) {
|
||||
* // your code here
|
||||
* return $data;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$localize_data = apply_filters( 'um_enqueue_localize_data', array(
|
||||
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
||||
'fileupload' => UM()->get_ajax_route( 'um\core\Files', 'ajax_file_upload' ),
|
||||
'imageupload' => UM()->get_ajax_route( 'um\core\Files', 'ajax_image_upload' ),
|
||||
'remove_file' => UM()->get_ajax_route( 'um\core\Files', 'ajax_remove_file' ),
|
||||
'delete_profile_photo' => UM()->get_ajax_route( 'um\core\Profile', 'ajax_delete_profile_photo' ),
|
||||
'delete_cover_photo' => UM()->get_ajax_route( 'um\core\Profile', 'ajax_delete_cover_photo' ),
|
||||
'resize_image' => UM()->get_ajax_route( 'um\core\Files', 'ajax_resize_image' ),
|
||||
'muted_action' => UM()->get_ajax_route( 'um\core\Form', 'ajax_muted_action' ),
|
||||
'ajax_paginate' => UM()->get_ajax_route( 'um\core\Query', 'ajax_paginate' ),
|
||||
'ajax_select_options' => UM()->get_ajax_route( 'um\core\Form', 'ajax_select_options' ),
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
$include = UM()->options()->get('js_css_include');
|
||||
if ( is_array( $include ) ) {
|
||||
array_filter( $include );
|
||||
}
|
||||
if ( $include && !is_admin() && is_array( $include ) ) {
|
||||
$this->load_original();
|
||||
wp_localize_script( 'um_scripts', 'um_scripts', $localize_data );
|
||||
|
||||
$c_url = UM()->permalinks()->get_current_url( get_option('permalink_structure') );
|
||||
// rtl style
|
||||
if ( is_rtl() ) {
|
||||
wp_register_style('um_rtl', um_url . 'assets/css/um.rtl.css', '', ultimatemember_version, 'all' );
|
||||
wp_enqueue_style('um_rtl');
|
||||
}
|
||||
|
||||
foreach( $include as $match ) {
|
||||
if ( strstr( $c_url, untrailingslashit( $match ) ) ) {
|
||||
$force_load = true;
|
||||
} else {
|
||||
if ( !isset( $force_load ) ) {
|
||||
$force_load = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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');
|
||||
}
|
||||
|
||||
if ( isset($force_load) && $force_load == false ) return;
|
||||
//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_enqueue_style('um_default_css');
|
||||
|
||||
// enqueue styles
|
||||
$localize_data = apply_filters( 'um_enqueue_localize_data', array(
|
||||
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
||||
'fileupload' => UM()->get_ajax_route( 'um\core\Files', 'ajax_file_upload' ),
|
||||
'imageupload' => UM()->get_ajax_route( 'um\core\Files', 'ajax_image_upload' ),
|
||||
'remove_file' => UM()->get_ajax_route( 'um\core\Files', 'ajax_remove_file' ),
|
||||
'delete_profile_photo' => UM()->get_ajax_route( 'um\core\Profile', 'ajax_delete_profile_photo' ),
|
||||
'delete_cover_photo' => UM()->get_ajax_route( 'um\core\Profile', 'ajax_delete_cover_photo' ),
|
||||
'resize_image' => UM()->get_ajax_route( 'um\core\Files', 'ajax_resize_image' ),
|
||||
'muted_action' => UM()->get_ajax_route( 'um\core\Form', 'ajax_muted_action' ),
|
||||
'ajax_paginate' => UM()->get_ajax_route( 'um\core\Query', 'ajax_paginate' ),
|
||||
'ajax_select_options' => UM()->get_ajax_route( 'um\core\Form', 'ajax_select_options' ),
|
||||
) );
|
||||
$uploads = wp_upload_dir();
|
||||
$upload_dir = $uploads['basedir'] . DIRECTORY_SEPARATOR . 'ultimatemember' . DIRECTORY_SEPARATOR;
|
||||
if ( file_exists( $upload_dir . 'um_old_settings.css' ) ) {
|
||||
//was the issues with HTTPS
|
||||
//wp_register_style('um_old_css', $uploads['baseurl'] . '/ultimatemember/um_old_settings.css' );
|
||||
//fixed using "../../"
|
||||
wp_register_style('um_old_css', um_url . '../../uploads/ultimatemember/um_old_settings.css' );
|
||||
wp_enqueue_style('um_old_css');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->load_original();
|
||||
wp_localize_script( 'um_scripts', 'um_scripts', $localize_data );
|
||||
/**
|
||||
* This will load original files (not minified)
|
||||
*/
|
||||
function load_original() {
|
||||
|
||||
// rtl style
|
||||
if ( is_rtl() ) {
|
||||
wp_register_style('um_rtl', um_url . 'assets/css/um.rtl.css', '', ultimatemember_version, 'all' );
|
||||
wp_enqueue_style('um_rtl');
|
||||
}
|
||||
//maybe deprecated
|
||||
//$this->load_google_charts();
|
||||
|
||||
// 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');
|
||||
}
|
||||
$this->load_fonticons();
|
||||
|
||||
if(is_object($post) && has_shortcode($post->post_content,'ultimate-member')) {
|
||||
wp_dequeue_script('jquery-form');
|
||||
}
|
||||
$this->load_selectjs();
|
||||
|
||||
//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_enqueue_style('um_default_css');
|
||||
$this->load_modal();
|
||||
|
||||
$uploads = wp_upload_dir();
|
||||
$upload_dir = $uploads['basedir'] . DIRECTORY_SEPARATOR . 'ultimatemember' . DIRECTORY_SEPARATOR;
|
||||
if ( file_exists( $upload_dir . 'um_old_settings.css' ) ) {
|
||||
//was the issues with HTTPS
|
||||
//wp_register_style('um_old_css', $uploads['baseurl'] . '/ultimatemember/um_old_settings.css' );
|
||||
//fixed using "../../"
|
||||
wp_register_style('um_old_css', um_url . '../../uploads/ultimatemember/um_old_settings.css' );
|
||||
wp_enqueue_style('um_old_css');
|
||||
}
|
||||
}
|
||||
$this->load_css();
|
||||
|
||||
/***
|
||||
*** @This will load original files (not minified)
|
||||
***/
|
||||
function load_original() {
|
||||
$this->load_fileupload();
|
||||
|
||||
//maybe deprecated
|
||||
//$this->load_google_charts();
|
||||
$this->load_datetimepicker();
|
||||
|
||||
$this->load_fonticons();
|
||||
$this->load_raty();
|
||||
|
||||
$this->load_selectjs();
|
||||
$this->load_scrollto();
|
||||
|
||||
$this->load_modal();
|
||||
$this->load_scrollbar();
|
||||
|
||||
$this->load_css();
|
||||
$this->load_imagecrop();
|
||||
|
||||
$this->load_fileupload();
|
||||
$this->load_tipsy();
|
||||
|
||||
$this->load_datetimepicker();
|
||||
$this->load_functions();
|
||||
|
||||
$this->load_raty();
|
||||
$this->load_responsive();
|
||||
|
||||
$this->load_scrollto();
|
||||
$this->load_customjs();
|
||||
|
||||
$this->load_scrollbar();
|
||||
}
|
||||
|
||||
$this->load_imagecrop();
|
||||
|
||||
$this->load_tipsy();
|
||||
/**
|
||||
* Include Google charts
|
||||
*/
|
||||
function load_google_charts() {
|
||||
|
||||
$this->load_functions();
|
||||
wp_register_script('um_gchart', 'https://www.google.com/jsapi' );
|
||||
wp_enqueue_script('um_gchart');
|
||||
|
||||
$this->load_responsive();
|
||||
}
|
||||
|
||||
$this->load_customjs();
|
||||
|
||||
}
|
||||
/**
|
||||
* Load plugin css
|
||||
*/
|
||||
function load_css() {
|
||||
|
||||
/***
|
||||
*** @Include Google charts
|
||||
***/
|
||||
function load_google_charts() {
|
||||
wp_register_style('um_styles', um_url . 'assets/css/um-styles.css' );
|
||||
wp_enqueue_style('um_styles');
|
||||
|
||||
wp_register_script('um_gchart', 'https://www.google.com/jsapi' );
|
||||
wp_enqueue_script('um_gchart');
|
||||
wp_register_style('um_members', um_url . 'assets/css/um-members.css' );
|
||||
wp_enqueue_style('um_members');
|
||||
|
||||
}
|
||||
wp_register_style('um_profile', um_url . 'assets/css/um-profile.css' );
|
||||
wp_enqueue_style('um_profile');
|
||||
|
||||
/***
|
||||
*** @Load plugin css
|
||||
***/
|
||||
function load_css() {
|
||||
wp_register_style('um_account', um_url . 'assets/css/um-account.css' );
|
||||
wp_enqueue_style('um_account');
|
||||
|
||||
wp_register_style('um_styles', um_url . 'assets/css/um-styles.css' );
|
||||
wp_enqueue_style('um_styles');
|
||||
wp_register_style('um_misc', um_url . 'assets/css/um-misc.css' );
|
||||
wp_enqueue_style('um_misc');
|
||||
|
||||
wp_register_style('um_members', um_url . 'assets/css/um-members.css' );
|
||||
wp_enqueue_style('um_members');
|
||||
}
|
||||
|
||||
wp_register_style('um_profile', um_url . 'assets/css/um-profile.css' );
|
||||
wp_enqueue_style('um_profile');
|
||||
|
||||
wp_register_style('um_account', um_url . 'assets/css/um-account.css' );
|
||||
wp_enqueue_style('um_account');
|
||||
/**
|
||||
* Load select-dropdowns JS
|
||||
*/
|
||||
function load_selectjs() {
|
||||
|
||||
wp_register_style('um_misc', um_url . 'assets/css/um-misc.css' );
|
||||
wp_enqueue_style('um_misc');
|
||||
if ( class_exists( 'WooCommerce' ) ) {
|
||||
wp_dequeue_style( 'select2' );
|
||||
wp_deregister_style( 'select2' );
|
||||
|
||||
}
|
||||
wp_dequeue_script( 'select2');
|
||||
wp_deregister_script('select2');
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Load select-dropdowns JS
|
||||
***/
|
||||
function load_selectjs() {
|
||||
wp_register_script('select2', um_url . 'assets/js/select2/select2.full.min.js', array('jquery', 'jquery-masonry') );
|
||||
wp_enqueue_script('select2');
|
||||
|
||||
if ( class_exists( 'WooCommerce' ) ) {
|
||||
wp_dequeue_style( 'select2' );
|
||||
wp_deregister_style( 'select2' );
|
||||
wp_register_style('select2', um_url . 'assets/css/select2/select2.min.css' );
|
||||
wp_enqueue_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');
|
||||
/**
|
||||
* 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');
|
||||
|
||||
/***
|
||||
*** @Load Fonticons
|
||||
***/
|
||||
function load_fonticons(){
|
||||
wp_register_style('um_fonticons_fa', um_url . 'assets/css/um-fonticons-fa.css' );
|
||||
wp_enqueue_style('um_fonticons_fa');
|
||||
|
||||
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');
|
||||
|
||||
}
|
||||
/**
|
||||
* Load fileupload JS
|
||||
*/
|
||||
function load_fileupload() {
|
||||
|
||||
/***
|
||||
*** @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_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_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');
|
||||
|
||||
wp_register_style('um_fileupload', um_url . 'assets/css/um-fileupload.css' );
|
||||
wp_enqueue_style('um_fileupload');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Load JS functions
|
||||
***/
|
||||
function load_functions() {
|
||||
/**
|
||||
* Load JS functions
|
||||
*/
|
||||
function load_functions() {
|
||||
|
||||
wp_register_script('um_functions', um_url . 'assets/js/um-functions' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_functions');
|
||||
wp_register_script('um_functions', um_url . 'assets/js/um-functions' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_functions');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Load custom JS
|
||||
***/
|
||||
function load_customjs() {
|
||||
|
||||
wp_register_script('um_conditional', um_url . 'assets/js/um-conditional' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_conditional');
|
||||
/**
|
||||
* Load custom JS
|
||||
*/
|
||||
function load_customjs() {
|
||||
|
||||
wp_register_script('um_scripts', um_url . 'assets/js/um-scripts' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_scripts');
|
||||
wp_register_script('um_conditional', um_url . 'assets/js/um-conditional' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_conditional');
|
||||
|
||||
wp_register_script('um_members', um_url . 'assets/js/um-members' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_members');
|
||||
wp_register_script('um_scripts', um_url . 'assets/js/um-scripts' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_scripts');
|
||||
|
||||
wp_register_script('um_profile', um_url . 'assets/js/um-profile' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_profile');
|
||||
wp_register_script('um_members', um_url . 'assets/js/um-members' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_members');
|
||||
|
||||
wp_register_script('um_account', um_url . 'assets/js/um-account' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_account');
|
||||
wp_register_script('um_profile', um_url . 'assets/js/um-profile' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_profile');
|
||||
|
||||
}
|
||||
wp_register_script('um_account', um_url . 'assets/js/um-account' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_account');
|
||||
|
||||
/***
|
||||
*** @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');
|
||||
/**
|
||||
* Load date & time picker
|
||||
*/
|
||||
function load_datetimepicker() {
|
||||
|
||||
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', um_url . 'assets/js/pickadate/picker.js' );
|
||||
wp_enqueue_script('um_datetime');
|
||||
|
||||
wp_register_script('um_datetime_legacy', um_url . 'assets/js/pickadate/legacy.js' );
|
||||
wp_enqueue_script('um_datetime_legacy');
|
||||
wp_register_script('um_datetime_date', um_url . 'assets/js/pickadate/picker.date.js' );
|
||||
wp_enqueue_script('um_datetime_date');
|
||||
|
||||
wp_register_style('um_datetime', um_url . 'assets/css/pickadate/default.css' );
|
||||
wp_enqueue_style('um_datetime');
|
||||
wp_register_script('um_datetime_time', um_url . 'assets/js/pickadate/picker.time.js' );
|
||||
wp_enqueue_script('um_datetime_time');
|
||||
|
||||
wp_register_style('um_datetime_date', um_url . 'assets/css/pickadate/default.date.css' );
|
||||
wp_enqueue_style('um_datetime_date');
|
||||
wp_register_script('um_datetime_legacy', um_url . 'assets/js/pickadate/legacy.js' );
|
||||
wp_enqueue_script('um_datetime_legacy');
|
||||
|
||||
wp_register_style('um_datetime_time', um_url . 'assets/css/pickadate/default.time.css' );
|
||||
wp_enqueue_style('um_datetime_time');
|
||||
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');
|
||||
|
||||
/***
|
||||
*** @Load scrollto
|
||||
***/
|
||||
function load_scrollto(){
|
||||
wp_register_style('um_datetime_time', um_url . 'assets/css/pickadate/default.time.css' );
|
||||
wp_enqueue_style('um_datetime_time');
|
||||
|
||||
wp_register_script('um_scrollto', um_url . 'assets/js/um-scrollto' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_scrollto');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Load scrollbar
|
||||
***/
|
||||
function load_scrollbar(){
|
||||
/**
|
||||
* Load scrollto
|
||||
*/
|
||||
function load_scrollto(){
|
||||
|
||||
wp_register_script('um_scrollbar', um_url . 'assets/js/um-scrollbar' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_scrollbar');
|
||||
wp_register_script('um_scrollto', um_url . 'assets/js/um-scrollto' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_scrollto');
|
||||
|
||||
wp_register_style('um_scrollbar', um_url . 'assets/css/um-scrollbar.css' );
|
||||
wp_enqueue_style('um_scrollbar');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Load rating
|
||||
***/
|
||||
function load_raty(){
|
||||
/**
|
||||
* Load scrollbar
|
||||
*/
|
||||
function load_scrollbar(){
|
||||
|
||||
wp_register_script('um_raty', um_url . 'assets/js/um-raty' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_raty');
|
||||
wp_register_script('um_scrollbar', um_url . 'assets/js/um-scrollbar' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_scrollbar');
|
||||
|
||||
wp_register_style('um_raty', um_url . 'assets/css/um-raty.css' );
|
||||
wp_enqueue_style('um_raty');
|
||||
wp_register_style('um_scrollbar', um_url . 'assets/css/um-scrollbar.css' );
|
||||
wp_enqueue_style('um_scrollbar');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
*** @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');
|
||||
/**
|
||||
* Load rating
|
||||
*/
|
||||
function load_raty(){
|
||||
|
||||
wp_register_style('um_crop', um_url . 'assets/css/um-crop.css' );
|
||||
wp_enqueue_style('um_crop');
|
||||
wp_register_script('um_raty', um_url . 'assets/js/um-raty' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_raty');
|
||||
|
||||
}
|
||||
wp_register_style('um_raty', um_url . 'assets/css/um-raty.css' );
|
||||
wp_enqueue_style('um_raty');
|
||||
|
||||
/***
|
||||
*** @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');
|
||||
/**
|
||||
* 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');
|
||||
|
||||
/***
|
||||
*** @Load modal
|
||||
***/
|
||||
function load_modal(){
|
||||
wp_register_style('um_crop', um_url . 'assets/css/um-crop.css' );
|
||||
wp_enqueue_style('um_crop');
|
||||
|
||||
wp_register_style('um_modal', um_url . 'assets/css/um-modal.css' );
|
||||
wp_enqueue_style('um_modal');
|
||||
}
|
||||
|
||||
wp_register_script('um_modal', um_url . 'assets/js/um-modal' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_modal');
|
||||
|
||||
}
|
||||
/**
|
||||
* Load tipsy
|
||||
*/
|
||||
function load_tipsy(){
|
||||
|
||||
/***
|
||||
*** @Load responsive styles
|
||||
***/
|
||||
function load_responsive(){
|
||||
wp_register_script('um_tipsy', um_url . 'assets/js/um-tipsy' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_tipsy');
|
||||
|
||||
wp_register_script('um_responsive', um_url . 'assets/js/um-responsive' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_responsive');
|
||||
wp_register_style('um_tipsy', um_url . 'assets/css/um-tipsy.css' );
|
||||
wp_enqueue_style('um_tipsy');
|
||||
|
||||
wp_register_style('um_responsive', um_url . 'assets/css/um-responsive.css' );
|
||||
wp_enqueue_style('um_responsive');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Load modal
|
||||
*/
|
||||
function load_modal(){
|
||||
|
||||
wp_register_style('um_modal', um_url . 'assets/css/um-modal.css' );
|
||||
wp_enqueue_style('um_modal');
|
||||
|
||||
wp_register_script('um_modal', um_url . 'assets/js/um-modal' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_modal');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load responsive styles
|
||||
*/
|
||||
function load_responsive(){
|
||||
|
||||
wp_register_script('um_responsive', um_url . 'assets/js/um-responsive' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_responsive');
|
||||
|
||||
wp_register_style('um_responsive', um_url . 'assets/css/um-responsive.css' );
|
||||
wp_enqueue_style('um_responsive');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+904
-62
File diff suppressed because it is too large
Load Diff
+1155
-785
File diff suppressed because it is too large
Load Diff
@@ -52,6 +52,27 @@ if ( ! class_exists( 'Form' ) ) {
|
||||
$form_fields = UM()->fields()->get_fields();
|
||||
$arr_options['fields'] = $form_fields;
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_ajax_select_options__debug_mode
|
||||
* @description Activate debug mode for AJAX select options
|
||||
* @input_vars
|
||||
* [{"var":"$debug_mode","type":"bool","desc":"Enable Debug mode"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_ajax_select_options__debug_mode', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_ajax_select_options__debug_mode', 'my_ajax_select_options__debug_mode', 10, 1 );
|
||||
* function my_ajax_select_options__debug_mode( $debug_mode ) {
|
||||
* // your code here
|
||||
* return $debug_mode;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$debug = apply_filters('um_ajax_select_options__debug_mode', false );
|
||||
if( $debug ){
|
||||
$arr_options['debug'] = array(
|
||||
@@ -100,16 +121,36 @@ if ( ! class_exists( 'Form' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Appends field errors
|
||||
* @param string $key
|
||||
* @param string $error
|
||||
*/
|
||||
function add_error( $key, $error ) {
|
||||
if ( ! isset( $this->errors[ $key ] ) ){
|
||||
|
||||
$error = apply_filters('um_submit_form_error', $error , $key );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_submit_form_error
|
||||
* @description Change error text on submit form
|
||||
* @input_vars
|
||||
* [{"var":"$error","type":"string","desc":"Error String"},
|
||||
* {"var":"$key","type":"string","desc":"Error Key"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_submit_form_error', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_submit_form_error', 'my_submit_form_error', 10, 2 );
|
||||
* function my_submit_form_error( $error, $key ) {
|
||||
* // your code here
|
||||
* return $error;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$error = apply_filters( 'um_submit_form_error', $error, $key );
|
||||
$this->errors[ $key ] = $error;
|
||||
}
|
||||
}
|
||||
@@ -158,9 +199,29 @@ if ( ! class_exists( 'Form' ) ) {
|
||||
|
||||
|
||||
if ( $this->form_status == 'publish' ) {
|
||||
|
||||
/* save entire form as global */
|
||||
$this->post_form = apply_filters('um_submit_post_form' ,$_POST );
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_submit_post_form
|
||||
* @description Change submitted data on form submit
|
||||
* @input_vars
|
||||
* [{"var":"$data","type":"array","desc":"Submitted data"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_submit_post_form', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_submit_post_form', 'my_submit_post_form', 10, 1 );
|
||||
* function my_submit_post_form( $data ) {
|
||||
* // your code here
|
||||
* return $data;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$this->post_form = apply_filters( 'um_submit_post_form', $_POST );
|
||||
|
||||
$this->post_form = $this->beautify( $this->post_form );
|
||||
|
||||
@@ -220,6 +281,28 @@ if ( ! class_exists( 'Form' ) ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_submit_form_data
|
||||
* @description Change submitted data on form submit
|
||||
* @input_vars
|
||||
* [{"var":"$data","type":"array","desc":"Submitted data"},
|
||||
* {"var":"$mode","type":"string","desc":"Form mode"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_submit_form_data', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_submit_form_data', 'my_submit_form_data', 10, 2 );
|
||||
* function my_submit_form_data( $data ) {
|
||||
* // your code here
|
||||
* return $data;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$this->post_form = apply_filters( 'um_submit_form_data', $this->post_form, $this->post_form['mode'] );
|
||||
|
||||
/* Continue based on form mode - pre-validation */
|
||||
|
||||
@@ -20,6 +20,27 @@ if ( ! class_exists( 'Mail' ) ) {
|
||||
|
||||
|
||||
function init_paths() {
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_email_templates_path_by_slug
|
||||
* @description Extend email templates path
|
||||
* @input_vars
|
||||
* [{"var":"$paths","type":"array","desc":"Email slug -> Template Path"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_email_templates_path_by_slug', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_email_templates_path_by_slug', 'my_email_templates_path_by_slug', 10, 1 );
|
||||
* function my_email_templates_path_by_slug( $paths ) {
|
||||
* // your code here
|
||||
* return $paths;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$this->path_by_slug = apply_filters( 'um_email_templates_path_by_slug', $this->path_by_slug );
|
||||
}
|
||||
|
||||
@@ -58,6 +79,28 @@ if ( ! class_exists( 'Mail' ) ) {
|
||||
$this->attachments = null;
|
||||
$this->headers = 'From: '. UM()->options()->get('mail_from') .' <'. UM()->options()->get('mail_from_addr') .'>' . "\r\n";
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_email_send_subject
|
||||
* @description Change email notification subject
|
||||
* @input_vars
|
||||
* [{"var":"$subject","type":"string","desc":"Subject"},
|
||||
* {"var":"$key","type":"string","desc":"Template Key"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_email_send_subject', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_email_send_subject', 'my_email_send_subject', 10, 2 );
|
||||
* function my_email_send_subject( $subject, $key ) {
|
||||
* // your code here
|
||||
* return $paths;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$subject = apply_filters( 'um_email_send_subject', UM()->options()->get( $template . '_sub' ), $template );
|
||||
$this->subject = um_convert_tags( $subject , $args );
|
||||
|
||||
@@ -78,6 +121,29 @@ if ( ! class_exists( 'Mail' ) ) {
|
||||
function get_email_template( $slug, $args = array() ) {
|
||||
$located = $this->locate_template( $slug );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_email_template_path
|
||||
* @description Change email template location
|
||||
* @input_vars
|
||||
* [{"var":"$located","type":"string","desc":"Template Location"},
|
||||
* {"var":"$slug","type":"string","desc":"Template Key"},
|
||||
* {"var":"$args","type":"array","desc":"Template settings"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_email_template_path', 'function_name', 10, 3 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_email_template_path', 'my_email_send_subject', 10, 3 );
|
||||
* function my_email_send_subject( $located, $slug, $args ) {
|
||||
* // your code here
|
||||
* return $located;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$located = apply_filters( 'um_email_template_path', $located, $slug, $args );
|
||||
|
||||
if ( ! file_exists( $located ) ) {
|
||||
@@ -109,13 +175,63 @@ if ( ! class_exists( 'Mail' ) ) {
|
||||
|
||||
if ( UM()->options()->get( 'email_html' ) ) {
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_email_template_html_formatting
|
||||
* @description Change email notification template header
|
||||
* @input_vars
|
||||
* [{"var":"$header","type":"string","desc":"Email notification header. '<html>' by default"},
|
||||
* {"var":"$slug","type":"string","desc":"Template Key"},
|
||||
* {"var":"$args","type":"array","desc":"Template settings"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_email_template_html_formatting', 'function_name', 10, 3 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_email_template_html_formatting', 'my_email_template_html_formatting', 10, 3 );
|
||||
* function my_email_template_html_formatting( $header, $slug, $args ) {
|
||||
* // your code here
|
||||
* return $header;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
echo apply_filters( 'um_email_template_html_formatting', '<html>', $slug, $args );
|
||||
|
||||
do_action( 'um_before_email_template_body', $slug, $args ); ?>
|
||||
do_action( 'um_before_email_template_body', $slug, $args );
|
||||
|
||||
<body <?php echo apply_filters( 'um_email_template_body_attrs', 'style="background: #f2f2f2;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;"', $slug ) ?>>
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_email_template_body_attrs
|
||||
* @description Change email notification template body additional attributes
|
||||
* @input_vars
|
||||
* [{"var":"$body_atts","type":"string","desc":"Email notification body attributes"},
|
||||
* {"var":"$slug","type":"string","desc":"Template Key"},
|
||||
* {"var":"$args","type":"array","desc":"Template settings"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_email_template_body_attrs', 'function_name', 10, 3 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_email_template_body_attrs', 'my_email_template_body_attrs', 10, 3 );
|
||||
* function my_email_template_body_attrs( $body_atts, $slug, $args ) {
|
||||
* // your code here
|
||||
* return $body_atts;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$body_attrs = apply_filters( 'um_email_template_body_attrs', 'style="background: #f2f2f2;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;"', $slug, $args );
|
||||
?>
|
||||
|
||||
<?php echo $this->get_email_template( $slug, $args ); ?>
|
||||
|
||||
<body <?php echo $body_attrs ?>>
|
||||
|
||||
<?php echo $this->get_email_template( $slug, $args ); ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -153,10 +269,57 @@ if ( ! class_exists( 'Mail' ) ) {
|
||||
}
|
||||
|
||||
// Return what we found.
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_locate_email_template
|
||||
* @description Change email notification template path
|
||||
* @input_vars
|
||||
* [{"var":"$template","type":"string","desc":"Template Path"},
|
||||
* {"var":"$template_name","type":"string","desc":"Template Name"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_locate_email_template', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_locate_email_template', 'my_locate_email_template', 10, 2 );
|
||||
* function my_email_template_body_attrs( $template, $template_name ) {
|
||||
* // your code here
|
||||
* return $template;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
return apply_filters( 'um_locate_email_template', $template, $template_name );
|
||||
}
|
||||
|
||||
|
||||
function get_template_filename( $template_name ) {
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_change_email_template_file
|
||||
* @description Change email notification template path
|
||||
* @input_vars
|
||||
* [{"var":"$template_name","type":"string","desc":"Template Name"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_change_email_template_file', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_change_email_template_file', 'my_change_email_template_file', 10, 1 );
|
||||
* function my_change_email_template_file( $template, $template_name ) {
|
||||
* // your code here
|
||||
* return $template;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
return apply_filters( 'um_change_email_template_file', $template_name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate a template and return the path for inclusion.
|
||||
*
|
||||
@@ -166,7 +329,7 @@ if ( ! class_exists( 'Mail' ) ) {
|
||||
* @return string
|
||||
*/
|
||||
function template_in_theme( $template_name, $html = false ) {
|
||||
$template_name_file = apply_filters( 'um_change_email_template_file', $template_name );
|
||||
$template_name_file = $this->get_template_filename( $template_name );
|
||||
$ext = ! $html ? '.php' : '.html';
|
||||
|
||||
// check if there is template at theme folder
|
||||
@@ -190,7 +353,7 @@ if ( ! class_exists( 'Mail' ) ) {
|
||||
*/
|
||||
function get_template_file( $location, $template_name, $html = false ) {
|
||||
$template_path = '';
|
||||
$template_name_file = apply_filters( 'um_change_email_template_file', $template_name );
|
||||
$template_name_file = $this->get_template_filename( $template_name );
|
||||
|
||||
$ext = ! $html ? '.php' : '.html';
|
||||
|
||||
|
||||
@@ -73,20 +73,127 @@ if ( ! class_exists( 'Members' ) ) {
|
||||
if ( isset( $fields[ $filter ] ) ) {
|
||||
$attrs = $fields[ $filter ];
|
||||
} else {
|
||||
$attrs = apply_filters("um_custom_search_field_{$filter}", array() );
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_custom_search_field_{$filter}
|
||||
* @description Custom search settings by $filter
|
||||
* @input_vars
|
||||
* [{"var":"$settings","type":"array","desc":"Search Settings"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_custom_search_field_{$filter}', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_custom_search_field_{$filter}', 'my_custom_search_field', 10, 1 );
|
||||
* function my_change_email_template_file( $settings ) {
|
||||
* // your code here
|
||||
* return $settings;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$attrs = apply_filters( "um_custom_search_field_{$filter}", array() );
|
||||
}
|
||||
|
||||
// additional filter for search field attributes
|
||||
$attrs = apply_filters("um_search_field_{$filter}", $attrs);
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_search_field_{$filter}
|
||||
* @description Extend search settings by $filter
|
||||
* @input_vars
|
||||
* [{"var":"$settings","type":"array","desc":"Search Settings"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_search_field_{$filter}', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_search_field_{$filter}', 'my_search_field', 10, 1 );
|
||||
* function my_change_email_template_file( $settings ) {
|
||||
* // your code here
|
||||
* return $settings;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$attrs = apply_filters( "um_search_field_{$filter}", $attrs );
|
||||
|
||||
$type = UM()->builtin()->is_dropdown_field( $filter, $attrs ) ? 'select' : 'text';
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_search_field_type
|
||||
* @description Change search field type
|
||||
* @input_vars
|
||||
* [{"var":"$type","type":"string","desc":"Search field type"},
|
||||
* {"var":"$settings","type":"array","desc":"Search Settings"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_search_field_type', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_search_field_type', 'my_search_field_type', 10, 2 );
|
||||
* function my_search_field_type( $type, $settings ) {
|
||||
* // your code here
|
||||
* return $type;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$type = apply_filters( 'um_search_field_type', $type, $attrs );
|
||||
|
||||
// filter all search fields
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_search_fields
|
||||
* @description Filter all search fields
|
||||
* @input_vars
|
||||
* [{"var":"$settings","type":"array","desc":"Search Fields"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_search_fields', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_search_fields', 'my_search_fields', 10, 1 );
|
||||
* function my_search_fields( $settings ) {
|
||||
* // your code here
|
||||
* return $settings;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$attrs = apply_filters( 'um_search_fields', $attrs );
|
||||
|
||||
if ( $type == 'select' )
|
||||
if ( $type == 'select' ) {
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_search_select_fields
|
||||
* @description Filter all search fields for select field type
|
||||
* @input_vars
|
||||
* [{"var":"$settings","type":"array","desc":"Search Fields"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_search_select_fields', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_search_select_fields', 'my_search_select_fields', 10, 1 );
|
||||
* function my_search_select_fields( $settings ) {
|
||||
* // your code here
|
||||
* return $settings;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$attrs = apply_filters( 'um_search_select_fields', $attrs );
|
||||
}
|
||||
|
||||
switch ( $type ) {
|
||||
|
||||
@@ -181,10 +288,31 @@ if ( ! class_exists( 'Members' ) ) {
|
||||
* @var $profiles_per_page
|
||||
* @var $profiles_per_page_mobile
|
||||
*/
|
||||
extract($args);
|
||||
extract( $args );
|
||||
|
||||
$query_args = array();
|
||||
$query_args = apply_filters( 'um_prepare_user_query_args', $query_args, $args );
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_prepare_user_query_args
|
||||
* @description Extend member directory query arguments
|
||||
* @input_vars
|
||||
* [{"var":"$query_args","type":"array","desc":"Members Query Arguments"},
|
||||
* {"var":"$directory_settings","type":"array","desc":"Member Directory Settings"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_prepare_user_query_args', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_prepare_user_query_args', 'my_prepare_user_query_args', 10, 2 );
|
||||
* function my_prepare_user_query_args( $query_args, $directory_settings ) {
|
||||
* // your code here
|
||||
* return $query_args;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$query_args = apply_filters( 'um_prepare_user_query_args', array(), $args );
|
||||
|
||||
// Prepare for BIG SELECT query
|
||||
$wpdb->query('SET SQL_BIG_SELECTS=1');
|
||||
@@ -318,8 +446,28 @@ if ( ! class_exists( 'Members' ) ) {
|
||||
|
||||
}
|
||||
|
||||
return apply_filters('um_prepare_user_results_array', $array );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_prepare_user_results_array
|
||||
* @description Extend member directory query result
|
||||
* @input_vars
|
||||
* [{"var":"$result","type":"array","desc":"Members Query Result"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_prepare_user_results_array', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_prepare_user_results_array', 'my_prepare_user_results', 10, 1 );
|
||||
* function my_prepare_user_results( $result ) {
|
||||
* // your code here
|
||||
* return $result;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
return apply_filters( 'um_prepare_user_results_array', $array );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -32,8 +32,30 @@ if ( ! class_exists( 'Options' ) ) {
|
||||
* @return mixed|string|void
|
||||
*/
|
||||
function get( $option_id ) {
|
||||
if ( isset( $this->options[ $option_id ] ) )
|
||||
if ( isset( $this->options[ $option_id ] ) ) {
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_get_option_filter__{$option_id}
|
||||
* @description Change UM option on get by $option_id
|
||||
* @input_vars
|
||||
* [{"var":"$option","type":"array","desc":"Option Value"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_get_option_filter__{$option_id}', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_get_option_filter__{$option_id}', 'my_get_option_filter', 10, 1 );
|
||||
* function my_get_option_filter( $option ) {
|
||||
* // your code here
|
||||
* return $option;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
return apply_filters( "um_get_option_filter__{$option_id}", $this->options[ $option_id ] );
|
||||
}
|
||||
|
||||
switch ( $option_id ) {
|
||||
case 'site_name':
|
||||
@@ -90,5 +112,38 @@ if ( ! class_exists( 'Options' ) ) {
|
||||
return $settings_defaults[ $option_id ];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get core page ID
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return mixed|void
|
||||
*/
|
||||
function get_core_page_id( $key ) {
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_core_page_id_filter
|
||||
* @description Change UM page slug
|
||||
* @input_vars
|
||||
* [{"var":"$slug","type":"array","desc":"UM page slug"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_core_page_id_filter', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_core_page_id_filter', 'my_core_page_id', 10, 1 );
|
||||
* function my_core_page_id( $slug ) {
|
||||
* // your code here
|
||||
* return $slug;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
return apply_filters( 'um_core_page_id_filter', 'core_' . $key );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,28 @@ if ( ! class_exists( 'Password' ) ) {
|
||||
$classes .= ' um-viewing';
|
||||
}
|
||||
|
||||
$classes = apply_filters('um_form_official_classes__hook', $classes);
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_form_official_classes__hook
|
||||
* @description Change form additional classes
|
||||
* @input_vars
|
||||
* [{"var":"$classes","type":"string","desc":"Form additional classes"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_form_official_classes__hook', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_form_official_classes__hook', 'my_form_official_classes', 10, 1 );
|
||||
* function my_form_official_classes( $classes ) {
|
||||
* // your code here
|
||||
* return $classes;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$classes = apply_filters( 'um_form_official_classes__hook', $classes );
|
||||
return $classes;
|
||||
}
|
||||
|
||||
@@ -165,7 +186,28 @@ if ( ! class_exists( 'Password' ) ) {
|
||||
$args = array_merge( UM()->shortcodes()->get_css_args( $args ), $args );
|
||||
}
|
||||
|
||||
$args = apply_filters('um_reset_password_shortcode_args_filter', $args);
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_reset_password_shortcode_args_filter
|
||||
* @description Extend Reset Password Arguments
|
||||
* @input_vars
|
||||
* [{"var":"$args","type":"array","desc":"Shortcode arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_reset_password_shortcode_args_filter', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_reset_password_shortcode_args_filter', 'my_reset_password_shortcode_args', 10, 1 );
|
||||
* function my_reset_password_shortcode_args( $args ) {
|
||||
* // your code here
|
||||
* return $args;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$args = apply_filters( 'um_reset_password_shortcode_args_filter', $args );
|
||||
|
||||
if ( isset( $this->change_password ) ) {
|
||||
|
||||
|
||||
@@ -42,7 +42,28 @@ if ( ! class_exists( 'Permalinks' ) ) {
|
||||
if ( !is_singular() )
|
||||
return;
|
||||
|
||||
$enable_canonical = apply_filters("um_allow_canonical__filter", true );
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_allow_canonical__filter
|
||||
* @description Allow canonical
|
||||
* @input_vars
|
||||
* [{"var":"$allow_canonical","type":"bool","desc":"Allow?"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_allow_canonical__filter', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_allow_canonical__filter', 'my_allow_canonical', 10, 1 );
|
||||
* function my_allow_canonical( $allow_canonical ) {
|
||||
* // your code here
|
||||
* return $allow_canonical;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$enable_canonical = apply_filters( "um_allow_canonical__filter", true );
|
||||
|
||||
if( ! $enable_canonical )
|
||||
return;
|
||||
@@ -160,6 +181,27 @@ if ( ! class_exists( 'Permalinks' ) ) {
|
||||
$page_url = strtok( $page_url, '?' );
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_get_current_page_url
|
||||
* @description Change current page URL
|
||||
* @input_vars
|
||||
* [{"var":"$page_url","type":"string","desc":"Page URL"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_get_current_page_url', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_get_current_page_url', 'my_get_current_page_url', 10, 1 );
|
||||
* function my_get_current_page_url( $page_url ) {
|
||||
* // your code here
|
||||
* return $page_url;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
return apply_filters( 'um_get_current_page_url', $page_url );
|
||||
}
|
||||
|
||||
@@ -209,9 +251,33 @@ if ( ! class_exists( 'Permalinks' ) ) {
|
||||
/***
|
||||
*** @makes an activate link for any user
|
||||
***/
|
||||
function activate_url(){
|
||||
if ( !um_user('account_secret_hash') ) return false;
|
||||
$url = apply_filters( 'um_activate_url', home_url() );
|
||||
function activate_url() {
|
||||
if ( !um_user('account_secret_hash') ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_activate_url
|
||||
* @description Change activate user URL
|
||||
* @input_vars
|
||||
* [{"var":"$url","type":"string","desc":"Activate URL"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_activate_url', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_activate_url', 'my_activate_url', 10, 1 );
|
||||
* function my_activate_url( $url ) {
|
||||
* // your code here
|
||||
* return $url;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$url = apply_filters( 'um_activate_url', home_url() );
|
||||
$url = add_query_arg( 'act', 'activate_via_email', $url );
|
||||
$url = add_query_arg( 'hash', um_user('account_secret_hash'), $url );
|
||||
$url = add_query_arg( 'user_id', um_user('ID'), $url );
|
||||
@@ -282,6 +348,28 @@ if ( ! class_exists( 'Permalinks' ) ) {
|
||||
$page_id = UM()->config()->permalinks['user'];
|
||||
$profile_url = get_permalink( $page_id );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_localize_permalink_filter
|
||||
* @description Change user profile URL
|
||||
* @input_vars
|
||||
* [{"var":"$profile_url","type":"string","desc":"Profile URL"},
|
||||
* {"var":"$page_id","type":"int","desc":"Profile Page ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_localize_permalink_filter', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_localize_permalink_filter', 'my_localize_permalink', 10, 2 );
|
||||
* function my_localize_permalink( $profile_url, $page_id ) {
|
||||
* // your code here
|
||||
* return $profile_url;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$profile_url = apply_filters( 'um_localize_permalink_filter', $profile_url, $page_id );
|
||||
|
||||
if ( get_option('permalink_structure') ) {
|
||||
|
||||
@@ -45,6 +45,27 @@ if ( ! class_exists( 'Profile' ) ) {
|
||||
***/
|
||||
function tabs() {
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_profile_tabs
|
||||
* @description Extend user profile tabs
|
||||
* @input_vars
|
||||
* [{"var":"$tabs","type":"array","desc":"Profile tabs"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_profile_tabs', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_profile_tabs', 'my_profile_tabs', 10, 1 );
|
||||
* function my_profile_tabs( $tabs ) {
|
||||
* // your code here
|
||||
* return $tabs;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$tabs = apply_filters( 'um_profile_tabs', array(
|
||||
'main' => array(
|
||||
'name' => __( 'About', 'ultimate-member' ),
|
||||
@@ -178,6 +199,27 @@ if ( ! class_exists( 'Profile' ) ) {
|
||||
$this->active_tab = get_query_var('profiletab');
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_profile_active_tab
|
||||
* @description Change active profile tab
|
||||
* @input_vars
|
||||
* [{"var":"$tab","type":"string","desc":"Active Profile tab"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_profile_active_tab', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_profile_active_tab', 'my_profile_active_tab', 10, 1 );
|
||||
* function my_profile_active_tab( $tab ) {
|
||||
* // your code here
|
||||
* return $tab;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$this->active_tab = apply_filters( 'um_profile_active_tab', $this->active_tab );
|
||||
|
||||
return $this->active_tab;
|
||||
|
||||
@@ -102,6 +102,27 @@ if ( ! class_exists( 'Query' ) ) {
|
||||
|
||||
unset( $args['post_type'] );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_excluded_comment_types
|
||||
* @description Extend excluded comment types
|
||||
* @input_vars
|
||||
* [{"var":"$types","type":"array","desc":"Comment Types"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_excluded_comment_types', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_excluded_comment_types', 'my_excluded_comment_types', 10, 1 );
|
||||
* function my_profile_active_tab( $types ) {
|
||||
* // your code here
|
||||
* return $types;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$args['type__not_in'] = apply_filters( 'um_excluded_comment_types', array('') );
|
||||
|
||||
$comments = get_comments($args);
|
||||
|
||||
@@ -18,7 +18,28 @@ if ( ! class_exists( 'Register' ) ) {
|
||||
}
|
||||
|
||||
public function verify_nonce( $args ){
|
||||
$allow_nonce_verification = apply_filters("um_register_allow_nonce_verification", true );
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_register_allow_nonce_verification
|
||||
* @description Enable/DIsable nonce verification of registration
|
||||
* @input_vars
|
||||
* [{"var":"$allow_nonce","type":"bool","desc":"Enable nonce"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_register_allow_nonce_verification', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_register_allow_nonce_verification', 'my_register_allow_nonce_verification', 10, 1 );
|
||||
* function my_register_allow_nonce_verification( $allow_nonce ) {
|
||||
* // your code here
|
||||
* return $allow_nonce;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$allow_nonce_verification = apply_filters( "um_register_allow_nonce_verification", true );
|
||||
|
||||
if( ! $allow_nonce_verification ){
|
||||
return $args;
|
||||
|
||||
@@ -31,9 +31,28 @@ if ( ! class_exists( 'REST_API' ) ) {
|
||||
// Determine if JSON_PRETTY_PRINT is available
|
||||
$this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null;
|
||||
|
||||
// Allow API request logging to be turned off
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_api_log_requests
|
||||
* @description Allow API request logging to be turned off
|
||||
* @input_vars
|
||||
* [{"var":"$allow_log","type":"bool","desc":"Enable api logs"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_api_log_requests', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_api_log_requests', 'my_api_log_requests', 10, 1 );
|
||||
* function my_api_log_requests( $allow_log ) {
|
||||
* // your code here
|
||||
* return $allow_log;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$this->log_requests = apply_filters( 'um_api_log_requests', $this->log_requests );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,6 +203,7 @@ if ( ! class_exists( 'REST_API' ) ) {
|
||||
}
|
||||
|
||||
// Determine the kind of query
|
||||
$args = array();
|
||||
$query_mode = $this->get_query_mode();
|
||||
foreach( $this->vars as $k ) {
|
||||
$args[ $k ] = isset( $wp_query->query_vars[ $k ] ) ? $wp_query->query_vars[ $k ] : null;
|
||||
@@ -214,12 +234,55 @@ if ( ! class_exists( 'REST_API' ) ) {
|
||||
break;
|
||||
|
||||
default:
|
||||
$data = apply_filters( 'um_rest_query_mode', $data , $query_mode, $args );
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_rest_query_mode
|
||||
* @description Change query attributes
|
||||
* @input_vars
|
||||
* [{"var":"$data","type":"array","desc":"Query Data"},
|
||||
* {"var":"$query_mode","type":"string","desc":"Query Mode"},
|
||||
* {"var":"$args","type":"array","desc":"Query Arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_rest_query_mode', 'function_name', 10, 3 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_rest_query_mode', 'my_rest_query_mode', 10, 3 );
|
||||
* function um_rest_query_mode( $data, $query_mode, $args ) {
|
||||
* // your code here
|
||||
* return $data;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$data = apply_filters( 'um_rest_query_mode', $data, $query_mode, $args );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Allow extensions to setup their own return data
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_api_output_data
|
||||
* @description Change output data for Rest API call
|
||||
* @input_vars
|
||||
* [{"var":"$data","type":"array","desc":"Output Data"},
|
||||
* {"var":"$query_mode","type":"string","desc":"Query Mode"},
|
||||
* {"var":"$api_class","type":"REST_API","desc":"REST_API instance"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_api_output_data', 'function_name', 10, 3 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_api_output_data', 'my_api_output_data', 10, 3 );
|
||||
* function my_api_output_data( $data, $query_mode, $api_class ) {
|
||||
* // your code here
|
||||
* return $data;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$this->data = apply_filters( 'um_api_output_data', $data, $query_mode, $this );
|
||||
|
||||
// Log this API request, if enabled. We log it here because we have access to errors.
|
||||
@@ -245,8 +308,28 @@ if ( ! class_exists( 'REST_API' ) ) {
|
||||
$pending = UM()->user()->get_pending_users_count();
|
||||
$response['stats']['pending_users'] = absint( $pending );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_rest_api_get_stats
|
||||
* @description Change output data for Rest API get stats call
|
||||
* @input_vars
|
||||
* [{"var":"$response","type":"array","desc":"Output Data"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_rest_api_get_stats', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_rest_api_get_stats', 'my_rest_api_get_stats', 10, 1 );
|
||||
* function my_rest_api_get_stats( $response ) {
|
||||
* // your code here
|
||||
* return $response;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$response = apply_filters( 'um_rest_api_get_stats', $response );
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
@@ -347,6 +430,29 @@ if ( ! class_exists( 'REST_API' ) ) {
|
||||
$val->profile_pic_normal = $this->getsrc( um_user('profile_photo', 200) );
|
||||
$val->profile_pic_small = $this->getsrc( um_user('profile_photo', 40) );
|
||||
$val->cover_photo = $this->getsrc( um_user('cover_photo', 1000) );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_rest_userdata
|
||||
* @description Change output data for Rest API userdata call
|
||||
* @input_vars
|
||||
* [{"var":"$value","type":"array","desc":"Output Data"},
|
||||
* {"var":"$user_id","type":"string","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_rest_userdata', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_rest_userdata', 'my_rest_userdata', 10, 2 );
|
||||
* function my_rest_userdata( $value, $user_id ) {
|
||||
* // your code here
|
||||
* return $value;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$val = apply_filters( 'um_rest_userdata', $val, $user->ID );
|
||||
}
|
||||
$response[ $user->ID ] = $val;
|
||||
@@ -420,10 +526,32 @@ if ( ! class_exists( 'REST_API' ) ) {
|
||||
switch( $field ) {
|
||||
|
||||
default:
|
||||
$response[$field] = ( um_profile( $field ) ) ? um_profile( $field ) : '';
|
||||
$response[ $field ] = ( um_profile( $field ) ) ? um_profile( $field ) : '';
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_rest_get_auser
|
||||
* @description Change output data for Rest API user authentification call
|
||||
* @input_vars
|
||||
* [{"var":"$response","type":"array","desc":"Output Data"},
|
||||
* {"var":"$field","type":"string","desc":"Field Key"},
|
||||
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_rest_get_auser', 'function_name', 10, 3 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_rest_get_auser', 'my_rest_get_auser', 10, 3 );
|
||||
* function my_rest_get_auser( $response, $field, $user_id ) {
|
||||
* // your code here
|
||||
* return $response;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$response = apply_filters( 'um_rest_get_auser', $response, $field, $user->ID );
|
||||
|
||||
break;
|
||||
|
||||
case 'cover_photo':
|
||||
@@ -467,6 +595,29 @@ if ( ! class_exists( 'REST_API' ) ) {
|
||||
$val->profile_pic_normal = $this->getsrc( um_user('profile_photo', 200) );
|
||||
$val->profile_pic_small = $this->getsrc( um_user('profile_photo', 40) );
|
||||
$val->cover_photo = $this->getsrc( um_user('cover_photo', 1000) );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_rest_userdata
|
||||
* @description Change output data for Rest API userdata call
|
||||
* @input_vars
|
||||
* [{"var":"$value","type":"array","desc":"Output Data"},
|
||||
* {"var":"$user_id","type":"string","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_rest_userdata', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_rest_userdata', 'my_rest_userdata', 10, 2 );
|
||||
* function my_rest_userdata( $value, $user_id ) {
|
||||
* // your code here
|
||||
* return $value;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$val = apply_filters( 'um_rest_userdata', $val, $user->ID );
|
||||
}
|
||||
$response = $val;
|
||||
@@ -493,7 +644,27 @@ if ( ! class_exists( 'REST_API' ) ) {
|
||||
public function get_query_mode() {
|
||||
global $wp_query;
|
||||
|
||||
// Whitelist our query options
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_api_valid_query_modes
|
||||
* @description Whitelist UM query options
|
||||
* @input_vars
|
||||
* [{"var":"$list","type":"array","desc":"Whitelist"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_api_valid_query_modes', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_api_valid_query_modes', 'my_api_valid_query_modes', 10, 1 );
|
||||
* function my_api_valid_query_modes( $list ) {
|
||||
* // your code here
|
||||
* return $list;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$accepted = apply_filters( 'um_api_valid_query_modes', array(
|
||||
'get.users',
|
||||
'get.user',
|
||||
@@ -534,6 +705,27 @@ if ( ! class_exists( 'REST_API' ) ) {
|
||||
|
||||
$format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json';
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_api_output_format
|
||||
* @description UM Rest API output format
|
||||
* @input_vars
|
||||
* [{"var":"$format","type":"string","desc":"Format"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_api_output_format', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_api_output_format', 'my_api_output_format', 10, 1 );
|
||||
* function my_api_output_format( $format ) {
|
||||
* // your code here
|
||||
* return $format;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
return apply_filters( 'um_api_output_format', $format );
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,28 @@ if ( ! class_exists( 'Rewrite' ) ) {
|
||||
'top'
|
||||
);
|
||||
|
||||
if( ! apply_filters( 'um_rewrite_flush_rewrite_rules', UM()->options()->get( 'um_flush_stop' ) ) )
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_rewrite_flush_rewrite_rules
|
||||
* @description Enable flushing rewrite rules
|
||||
* @input_vars
|
||||
* [{"var":"$stop_flush","type":"bool","desc":"Stop flushing rewrite rules"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_rewrite_flush_rewrite_rules', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_rewrite_flush_rewrite_rules', 'my_rewrite_flush_rewrite_rules', 10, 1 );
|
||||
* function my_rewrite_flush_rewrite_rules( $stop_flush ) {
|
||||
* // your code here
|
||||
* return $stop_flush;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
if ( ! apply_filters( 'um_rewrite_flush_rewrite_rules', UM()->options()->get( 'um_flush_stop' ) ) )
|
||||
flush_rewrite_rules( true );
|
||||
|
||||
}
|
||||
@@ -200,6 +221,27 @@ if ( ! class_exists( 'Rewrite' ) ) {
|
||||
exit( wp_redirect( $url ) );
|
||||
} else {
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_locate_user_profile_not_loggedin__redirect
|
||||
* @description Change redirect URL from user profile for not logged in user
|
||||
* @input_vars
|
||||
* [{"var":"$url","type":"string","desc":"Redirect URL"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_locate_user_profile_not_loggedin__redirect', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_locate_user_profile_not_loggedin__redirect', 'my_user_profile_not_loggedin__redirect', 10, 1 );
|
||||
* function my_user_profile_not_loggedin__redirect( $url ) {
|
||||
* // your code here
|
||||
* return $url;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$redirect_to = apply_filters( 'um_locate_user_profile_not_loggedin__redirect', home_url() );
|
||||
if ( ! empty( $redirect_to ) ){
|
||||
exit( wp_redirect( $redirect_to ) );
|
||||
|
||||
@@ -137,6 +137,29 @@ if ( ! class_exists( 'Roles_Capabilities' ) ) {
|
||||
$new_role = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_set_user_role
|
||||
* @description User role was changed
|
||||
* @input_vars
|
||||
* [{"var":"$new_role","type":"string","desc":"New role"},
|
||||
* {"var":"$user_id","type":"int","desc":"User ID"},
|
||||
* {"var":"$user","type":"array","desc":"Userdata"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_set_user_role', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_set_user_role', 'my_set_user_role', 10, 1 );
|
||||
* function my_set_user_role( $new_role ) {
|
||||
* // your code here
|
||||
* return $new_role;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
return apply_filters( 'um_set_user_role', $new_role, $user_id, $user );
|
||||
}
|
||||
|
||||
@@ -472,6 +495,29 @@ if ( ! class_exists( 'Roles_Capabilities' ) ) {
|
||||
$user_id = get_current_user_id();
|
||||
$role = UM()->roles()->get_priority_user_role( $user_id );
|
||||
$permissions = $this->role_data( $role );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_user_permissions_filter
|
||||
* @description Change User Permissions
|
||||
* @input_vars
|
||||
* [{"var":"$permissions","type":"array","desc":"User Permissions"},
|
||||
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_user_permissions_filter', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_user_permissions_filter', 'my_user_permissions', 10, 2 );
|
||||
* function my_user_permissions( $permissions, $user_id ) {
|
||||
* // your code here
|
||||
* return $permissions;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$permissions = apply_filters( 'um_user_permissions_filter', $permissions, $user_id );
|
||||
|
||||
if ( isset( $permissions[ $permission ] ) && is_serialized( $permissions[ $permission ] ) )
|
||||
|
||||
@@ -188,8 +188,8 @@ if ( ! class_exists( 'Setup' ) ) {
|
||||
}
|
||||
|
||||
foreach ( $core_pages as $slug => $page_id ) {
|
||||
$key = apply_filters( 'um_core_page_id_filter', 'core_' . $slug );
|
||||
$options[$key] = $page_id;
|
||||
$key = UM()->options()->get_core_page_id( $slug );
|
||||
$options[ $key ] = $page_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,27 @@ if ( ! class_exists( 'Shortcodes' ) ) {
|
||||
add_filter( 'um_shortcode_args_filter', array( &$this, 'display_logout_form' ), 99 );
|
||||
add_filter( 'um_shortcode_args_filter', array( &$this, 'parse_shortcode_args' ), 99 );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_emoji_base_uri
|
||||
* @description Change Emoji base URL
|
||||
* @input_vars
|
||||
* [{"var":"$url","type":"string","desc":"Base URL"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_emoji_base_uri', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_emoji_base_uri', 'my_emoji_base_uri', 10, 1 );
|
||||
* function my_emoji_base_uri( $url ) {
|
||||
* // your code here
|
||||
* return $url;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$base_uri = apply_filters( 'um_emoji_base_uri', 'https://s.w.org/images/core/emoji/' );
|
||||
|
||||
$this->emoji[':)'] = $base_uri . '72x72/1f604.png';
|
||||
@@ -256,7 +277,28 @@ if ( ! class_exists( 'Shortcodes' ) ) {
|
||||
$classes .= ' um-' . $args['template'];
|
||||
}
|
||||
|
||||
$classes = apply_filters('um_form_official_classes__hook', $classes);
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_form_official_classes__hook
|
||||
* @description Change official form classes
|
||||
* @input_vars
|
||||
* [{"var":"$classes","type":"string","desc":"Classes string"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_form_official_classes__hook', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_form_official_classes__hook', 'my_form_official_classes', 10, 1 );
|
||||
* function my_form_official_classes( $classes ) {
|
||||
* // your code here
|
||||
* return $classes;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$classes = apply_filters( 'um_form_official_classes__hook', $classes );
|
||||
return $classes;
|
||||
}
|
||||
|
||||
@@ -343,7 +385,28 @@ if ( ! class_exists( 'Shortcodes' ) ) {
|
||||
// get data into one global array
|
||||
$post_data = UM()->query()->post_data($this->form_id);
|
||||
|
||||
$args = apply_filters('um_pre_args_setup', $post_data);
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_pre_args_setup
|
||||
* @description Change arguments on load shortcode
|
||||
* @input_vars
|
||||
* [{"var":"$post_data","type":"string","desc":"$_POST data"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_pre_args_setup', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_pre_args_setup', 'my_pre_args_setup', 10, 1 );
|
||||
* function my_pre_args_setup( $post_data ) {
|
||||
* // your code here
|
||||
* return $post_data;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$args = apply_filters( 'um_pre_args_setup', $post_data );
|
||||
|
||||
if (!isset($args['template'])) {
|
||||
$args['template'] = '';
|
||||
@@ -372,7 +435,29 @@ if ( ! class_exists( 'Shortcodes' ) ) {
|
||||
}
|
||||
}
|
||||
// filter for arguments
|
||||
$args = apply_filters('um_shortcode_args_filter', $args);
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_shortcode_args_filter
|
||||
* @description Change arguments on load shortcode
|
||||
* @input_vars
|
||||
* [{"var":"$args","type":"string","desc":"Shortcode arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_shortcode_args_filter', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_shortcode_args_filter', 'my_shortcode_args', 10, 1 );
|
||||
* function my_shortcode_args( $args ) {
|
||||
* // your code here
|
||||
* return $args;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$args = apply_filters( 'um_shortcode_args_filter', $args );
|
||||
|
||||
extract($args, EXTR_SKIP);
|
||||
|
||||
@@ -432,8 +517,26 @@ if ( ! class_exists( 'Shortcodes' ) ) {
|
||||
* @return string
|
||||
*/
|
||||
function dynamic_css( $args = array() ) {
|
||||
/*
|
||||
* for fix the issue #306
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_disable_dynamic_global_css
|
||||
* @description Turn on for disable global dynamic CSS for fix the issue #306
|
||||
* @input_vars
|
||||
* [{"var":"$disable","type":"bool","desc":"Disable global CSS"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_disable_dynamic_global_css', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_disable_dynamic_global_css', 'my_disable_dynamic_global_css', 10, 1 );
|
||||
* function my_disable_dynamic_global_css( $disable ) {
|
||||
* // your code here
|
||||
* return $disable;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$disable_css = apply_filters( 'um_disable_dynamic_global_css', false );
|
||||
if ( $disable_css )
|
||||
@@ -594,6 +697,27 @@ if ( ! class_exists( 'Shortcodes' ) ) {
|
||||
'{username}',
|
||||
);
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_allowed_user_tags_patterns
|
||||
* @description Extend user placeholders patterns
|
||||
* @input_vars
|
||||
* [{"var":"$patterns","type":"array","desc":"Placeholders"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_allowed_user_tags_patterns', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_allowed_user_tags_patterns', 'my_allowed_user_tags', 10, 1 );
|
||||
* function my_allowed_user_tags( $patterns ) {
|
||||
* // your code here
|
||||
* return $patterns;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$pattern_array = apply_filters( 'um_allowed_user_tags_patterns', $pattern_array );
|
||||
|
||||
//$matches = false;
|
||||
@@ -616,6 +740,28 @@ if ( ! class_exists( 'Shortcodes' ) ) {
|
||||
$value = um_user( 'user_login' );
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_profile_tag_hook__{$usermeta}
|
||||
* @description Change usermeta field value
|
||||
* @input_vars
|
||||
* [{"var":"$value","type":"array","desc":"Meta field value"},
|
||||
* {"var":"$user_id","type":"array","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_profile_tag_hook__{$usermeta}', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_profile_tag_hook__{$usermeta}', 'my_profile_tag', 10, 2 );
|
||||
* function my_profile_tag( $value, $user_id ) {
|
||||
* // your code here
|
||||
* return $value;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$value = apply_filters( "um_profile_tag_hook__{$usermeta}", $value, um_user( 'ID' ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -4,105 +4,157 @@ namespace um\core;
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
|
||||
if ( ! class_exists( 'User_posts' ) ) {
|
||||
class User_posts {
|
||||
|
||||
function __construct() {
|
||||
|
||||
add_action('um_profile_content_posts', array(&$this, 'add_posts') );
|
||||
add_action('um_profile_content_comments', array(&$this, 'add_comments') );
|
||||
|
||||
add_action('um_ajax_load_posts__um_load_posts', array(&$this, 'load_posts') );
|
||||
add_action('um_ajax_load_posts__um_load_comments', array(&$this, 'load_comments') );
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @dynamic load of posts
|
||||
***/
|
||||
function load_posts( $args ) {
|
||||
$array = explode(',', $args );
|
||||
$post_type = $array[0];
|
||||
$posts_per_page = $array[1];
|
||||
$offset = $array[2];
|
||||
$author = $array[3];
|
||||
|
||||
$offset_n = $posts_per_page + $offset;
|
||||
|
||||
UM()->shortcodes()->modified_args = "$post_type,$posts_per_page,$offset_n,$author";
|
||||
|
||||
UM()->shortcodes()->loop = UM()->query()->make("post_type=$post_type&posts_per_page=$posts_per_page&offset=$offset&author=$author");
|
||||
|
||||
UM()->shortcodes()->load_template('profile/posts-single');
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @dynamic load of comments
|
||||
***/
|
||||
function load_comments( $args ) {
|
||||
$array = explode(',', $args );
|
||||
$post_type = $array[0];
|
||||
$posts_per_page = $array[1];
|
||||
$offset = $array[2];
|
||||
$author = $array[3];
|
||||
|
||||
$offset_n = $posts_per_page + $offset;
|
||||
|
||||
UM()->shortcodes()->modified_args = "$post_type,$posts_per_page,$offset_n,$author";
|
||||
|
||||
UM()->shortcodes()->loop = UM()->query()->make("post_type=$post_type&number=$posts_per_page&offset=$offset&user_id=$author");
|
||||
|
||||
UM()->shortcodes()->load_template('profile/comments-single');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @add posts
|
||||
***/
|
||||
function add_posts() {
|
||||
UM()->shortcodes()->load_template('profile/posts');
|
||||
}
|
||||
/**
|
||||
* Class User_posts
|
||||
* @package um\core
|
||||
*/
|
||||
class User_posts {
|
||||
|
||||
/***
|
||||
*** @add comments
|
||||
***/
|
||||
function add_comments() {
|
||||
UM()->shortcodes()->load_template('profile/comments');
|
||||
}
|
||||
/**
|
||||
* User_posts constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
add_action( 'um_profile_content_posts', array( &$this, 'add_posts' ) );
|
||||
add_action( 'um_profile_content_comments', array( &$this, 'add_comments' ) );
|
||||
|
||||
/***
|
||||
*** @count posts
|
||||
***/
|
||||
function count_user_posts_by_type( $user_id= '', $post_type = 'post' ) {
|
||||
global $wpdb;
|
||||
if ( !$user_id )
|
||||
$user_id = um_user('ID');
|
||||
add_action( 'um_ajax_load_posts__um_load_posts', array( &$this, 'load_posts' ) );
|
||||
add_action( 'um_ajax_load_posts__um_load_comments', array( &$this, 'load_comments' ) );
|
||||
}
|
||||
|
||||
if ( !$user_id ) return 0;
|
||||
|
||||
$where = get_posts_by_author_sql( $post_type, true, $user_id );
|
||||
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" );
|
||||
/**
|
||||
* Dynamic load of posts
|
||||
*
|
||||
* @param array $args
|
||||
*/
|
||||
function load_posts( $args ) {
|
||||
$array = explode(',', $args );
|
||||
$post_type = $array[0];
|
||||
$posts_per_page = $array[1];
|
||||
$offset = $array[2];
|
||||
$author = $array[3];
|
||||
|
||||
return apply_filters('um_pretty_number_formatting', $count);
|
||||
}
|
||||
$offset_n = $posts_per_page + $offset;
|
||||
|
||||
/***
|
||||
*** @count comments
|
||||
***/
|
||||
function count_user_comments( $user_id = null ) {
|
||||
global $wpdb;
|
||||
if ( !$user_id )
|
||||
$user_id = um_user('ID');
|
||||
UM()->shortcodes()->modified_args = "$post_type,$posts_per_page,$offset_n,$author";
|
||||
|
||||
if ( !$user_id ) return 0;
|
||||
UM()->shortcodes()->loop = UM()->query()->make("post_type=$post_type&posts_per_page=$posts_per_page&offset=$offset&author=$author");
|
||||
|
||||
$count = $wpdb->get_var("SELECT COUNT(comment_ID) FROM " . $wpdb->comments. " WHERE user_id = " . $user_id . " AND comment_approved = '1'");
|
||||
UM()->shortcodes()->load_template('profile/posts-single');
|
||||
}
|
||||
|
||||
return apply_filters('um_pretty_number_formatting', $count);
|
||||
}
|
||||
/**
|
||||
* Dynamic load of comments
|
||||
*
|
||||
* @param $args
|
||||
*/
|
||||
function load_comments( $args ) {
|
||||
$array = explode(',', $args );
|
||||
$post_type = $array[0];
|
||||
$posts_per_page = $array[1];
|
||||
$offset = $array[2];
|
||||
$author = $array[3];
|
||||
|
||||
}
|
||||
$offset_n = $posts_per_page + $offset;
|
||||
|
||||
UM()->shortcodes()->modified_args = "$post_type,$posts_per_page,$offset_n,$author";
|
||||
|
||||
UM()->shortcodes()->loop = UM()->query()->make("post_type=$post_type&number=$posts_per_page&offset=$offset&user_id=$author");
|
||||
|
||||
UM()->shortcodes()->load_template('profile/comments-single');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add posts
|
||||
*/
|
||||
function add_posts() {
|
||||
UM()->shortcodes()->load_template( 'profile/posts' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add comments
|
||||
*/
|
||||
function add_comments() {
|
||||
UM()->shortcodes()->load_template( 'profile/comments' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Count posts by type
|
||||
*
|
||||
* @param string $user_id
|
||||
* @param string $post_type
|
||||
*
|
||||
* @return int|string
|
||||
*/
|
||||
function count_user_posts_by_type( $user_id= '', $post_type = 'post' ) {
|
||||
global $wpdb;
|
||||
if ( !$user_id )
|
||||
$user_id = um_user( 'ID' );
|
||||
|
||||
if ( !$user_id ) return 0;
|
||||
|
||||
$where = get_posts_by_author_sql( $post_type, true, $user_id );
|
||||
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" );
|
||||
|
||||
return $this->pretty_number_formatting( $count );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Count comments
|
||||
*
|
||||
* @param int|null $user_id
|
||||
*
|
||||
* @return int|string
|
||||
*/
|
||||
function count_user_comments( $user_id = null ) {
|
||||
global $wpdb;
|
||||
if ( !$user_id )
|
||||
$user_id = um_user('ID');
|
||||
|
||||
if ( !$user_id ) return 0;
|
||||
|
||||
$count = $wpdb->get_var("SELECT COUNT(comment_ID) FROM " . $wpdb->comments. " WHERE user_id = " . $user_id . " AND comment_approved = '1'");
|
||||
|
||||
return $this->pretty_number_formatting( $count );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $count
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function pretty_number_formatting( $count ) {
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_pretty_number_formatting
|
||||
* @description Change User Posts count value
|
||||
* @input_vars
|
||||
* [{"var":"$count","type":"int","desc":"Posts Count"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_pretty_number_formatting', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_pretty_number_formatting', 'my_pretty_number_formatting', 10, 1 );
|
||||
* function my_pretty_number_formatting( $count ) {
|
||||
* // your code here
|
||||
* return $count;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
return apply_filters( 'um_pretty_number_formatting', $count );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -155,6 +155,28 @@ if ( ! class_exists( 'User' ) ) {
|
||||
'value' => 'awaiting_admin_review',
|
||||
'compare' => '='
|
||||
);
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_admin_pending_queue_filter
|
||||
* @description Change user query arguments when get pending users
|
||||
* @input_vars
|
||||
* [{"var":"$args","type":"array","desc":"WP_Users query arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_admin_pending_queue_filter', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_admin_pending_queue_filter', 'my_admin_pending_queue', 10, 1 );
|
||||
* function my_admin_pending_queue( $args ) {
|
||||
* // your code here
|
||||
* return $args;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$args = apply_filters( 'um_admin_pending_queue_filter', $args );
|
||||
$users = new \WP_User_Query( $args );
|
||||
|
||||
@@ -371,6 +393,28 @@ if ( ! class_exists( 'User' ) ) {
|
||||
*/
|
||||
function profile_form_additional_section( $userdata ) {
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_user_profile_additional_fields
|
||||
* @description Make additional content section
|
||||
* @input_vars
|
||||
* [{"var":"$content","type":"array","desc":"Additional section content"},
|
||||
* {"var":"$userdata","type":"array","desc":"Userdata"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_user_profile_additional_fields', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_user_profile_additional_fields', 'my_admin_pending_queue', 10, 2 );
|
||||
* function my_admin_pending_queue( $content, $userdata ) {
|
||||
* // your code here
|
||||
* return $content;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$section_content = apply_filters( 'um_user_profile_additional_fields', '', $userdata );
|
||||
|
||||
if ( ! empty( $section_content ) && ! ( is_multisite() && is_network_admin() ) ) {
|
||||
@@ -489,7 +533,29 @@ if ( ! class_exists( 'User' ) ) {
|
||||
if ( is_numeric( $user_id ) && $user_id > 0 ) {
|
||||
$find_user = get_option("um_cache_userdata_{$user_id}");
|
||||
if ( $find_user ) {
|
||||
$find_user = apply_filters('um_user_permissions_filter', $find_user, $user_id);
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_user_permissions_filter
|
||||
* @description Change User Permissions
|
||||
* @input_vars
|
||||
* [{"var":"$permissions","type":"array","desc":"User Permissions"},
|
||||
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_user_permissions_filter', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_user_permissions_filter', 'my_user_permissions', 10, 2 );
|
||||
* function my_user_permissions( $permissions, $user_id ) {
|
||||
* // your code here
|
||||
* return $permissions;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$find_user = apply_filters( 'um_user_permissions_filter', $find_user, $user_id );
|
||||
return $find_user;
|
||||
}
|
||||
}
|
||||
@@ -627,6 +693,28 @@ if ( ! class_exists( 'User' ) ) {
|
||||
$this->profile['roles'] = UM()->roles()->get_all_user_roles( $this->id );
|
||||
|
||||
$role_meta = UM()->roles()->role_data( $user_role );
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_user_permissions_filter
|
||||
* @description Change User Permissions
|
||||
* @input_vars
|
||||
* [{"var":"$permissions","type":"array","desc":"User Permissions"},
|
||||
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_user_permissions_filter', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_user_permissions_filter', 'my_user_permissions', 10, 2 );
|
||||
* function my_user_permissions( $permissions, $user_id ) {
|
||||
* // your code here
|
||||
* return $permissions;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$role_meta = apply_filters( 'um_user_permissions_filter', $role_meta, $this->id );
|
||||
|
||||
/*$role_meta = array_map( function( $key, $item ) {
|
||||
@@ -725,7 +813,28 @@ if ( ! class_exists( 'User' ) ) {
|
||||
unset( $submitted['confirm_user_password'] );
|
||||
}
|
||||
|
||||
$submitted = apply_filters('um_before_save_filter_submitted', $submitted );
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_before_save_filter_submitted
|
||||
* @description Change submitted data before save usermeta "submitted" on registration process
|
||||
* @input_vars
|
||||
* [{"var":"$submitted","type":"array","desc":"Submitted data"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_before_save_filter_submitted', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_before_save_filter_submitted', 'my_before_save_filter_submitted', 10, 1 );
|
||||
* function my_before_save_filter_submitted( $submitted ) {
|
||||
* // your code here
|
||||
* return $submitted;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$submitted = apply_filters( 'um_before_save_filter_submitted', $submitted );
|
||||
|
||||
do_action('um_before_save_registration_details', $this->id, $submitted );
|
||||
|
||||
@@ -1059,6 +1168,27 @@ if ( ! class_exists( 'User' ) ) {
|
||||
function get_admin_actions() {
|
||||
$items = array();
|
||||
$actions = array();
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_admin_user_actions_hook
|
||||
* @description Extend admin actions for each user
|
||||
* @input_vars
|
||||
* [{"var":"$actions","type":"array","desc":"Actions for user"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_admin_user_actions_hook', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_admin_user_actions_hook', 'my_admin_user_actions', 10, 1 );
|
||||
* function my_admin_user_actions( $actions ) {
|
||||
* // your code here
|
||||
* return $actions;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$actions = apply_filters('um_admin_user_actions_hook', $actions );
|
||||
if ( !isset( $actions ) || empty( $actions ) ) return false;
|
||||
foreach($actions as $id => $arr ) {
|
||||
@@ -1144,7 +1274,30 @@ if ( ! class_exists( 'User' ) ) {
|
||||
$privacy = get_user_meta( $user_id, 'profile_privacy', true );
|
||||
|
||||
if ( $privacy == $case ) {
|
||||
$bool = apply_filters('um_is_private_filter_hook', false, $privacy, $user_id );
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_is_private_filter_hook
|
||||
* @description Change user privacy
|
||||
* @input_vars
|
||||
* [{"var":"$is_private","type":"bool","desc":"Is user private"},
|
||||
* {"var":"$privacy","type":"bool","desc":"Profile Privacy"},
|
||||
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_is_private_filter_hook', 'function_name', 10, 3 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_is_private_filter_hook', 'my_is_private_filter', 10, 3 );
|
||||
* function my_is_private_filter( $is_private ) {
|
||||
* // your code here
|
||||
* return $is_private;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$bool = apply_filters( 'um_is_private_filter_hook', false, $privacy, $user_id );
|
||||
return $bool;
|
||||
}
|
||||
|
||||
@@ -1170,7 +1323,30 @@ if ( ! class_exists( 'User' ) ) {
|
||||
function update_profile( $changes ) {
|
||||
|
||||
$args['ID'] = $this->id;
|
||||
$changes = apply_filters('um_before_update_profile', $changes, $this->id);
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_before_update_profile
|
||||
* @description Change update profile changes data
|
||||
* @input_vars
|
||||
* [{"var":"$changes","type":"array","desc":"User Profile Changes"},
|
||||
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_before_update_profile', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_before_update_profile', 'my_before_update_profile', 10, 2 );
|
||||
* function my_before_update_profile( $changes, $user_id ) {
|
||||
* // your code here
|
||||
* return $changes;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$changes = apply_filters('um_before_update_profile', $changes, $this->id );
|
||||
|
||||
// save or update profile meta
|
||||
foreach ( $changes as $key => $value ) {
|
||||
|
||||
+261
-149
@@ -5,183 +5,295 @@ namespace um\core;
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if ( ! class_exists( 'Validation' ) ) {
|
||||
class Validation {
|
||||
|
||||
function __construct() {
|
||||
|
||||
$this->regex_safe = '/\A[\w\-\.]+\z/';
|
||||
$this->regex_phone_number = '/\A[\d\-\.\+\(\)\ ]+\z/';
|
||||
/**
|
||||
* Class Validation
|
||||
* @package um\core
|
||||
*/
|
||||
class Validation {
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @removes html from any string
|
||||
***/
|
||||
function remove_html($string) {
|
||||
return wp_strip_all_tags( $string );
|
||||
}
|
||||
/**
|
||||
* Validation constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->regex_safe = '/\A[\w\-\.]+\z/';
|
||||
$this->regex_phone_number = '/\A[\d\-\.\+\(\)\ ]+\z/';
|
||||
}
|
||||
|
||||
/***
|
||||
*** @normalize a string
|
||||
***/
|
||||
function normalize($string) {
|
||||
$string = preg_replace('~&([a-z]{1,2})(acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities($string, ENT_QUOTES, 'UTF-8'));
|
||||
return $string;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @safe name usage ( for url purposes )
|
||||
***/
|
||||
function safe_name_in_url( $name ) {
|
||||
$name = strtolower( $name );
|
||||
$name = preg_replace("/'/","", $name );
|
||||
$name = stripslashes( $name );
|
||||
$name = $this->normalize($name);
|
||||
$name = rawurldecode( $name );
|
||||
return $name;
|
||||
}
|
||||
/**
|
||||
* Removes html from any string
|
||||
*
|
||||
* @param $string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function remove_html( $string ) {
|
||||
return wp_strip_all_tags( $string );
|
||||
}
|
||||
|
||||
/***
|
||||
*** @password test
|
||||
***/
|
||||
function strong_pass($candidate) {
|
||||
$r1='/[A-Z]/';
|
||||
$r2='/[a-z]/';
|
||||
$r3='/[0-9]/';
|
||||
if(preg_match_all($r1,$candidate, $o)<1) return false;
|
||||
if(preg_match_all($r2,$candidate, $o)<1) return false;
|
||||
if(preg_match_all($r3,$candidate, $o)<1) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @space, dash, underscore
|
||||
***/
|
||||
function safe_username( $string ) {
|
||||
/**
|
||||
* Normalize a string
|
||||
*
|
||||
* @param $string
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function normalize( $string ) {
|
||||
$string = preg_replace('~&([a-z]{1,2})(acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities($string, ENT_QUOTES, 'UTF-8'));
|
||||
return $string;
|
||||
}
|
||||
|
||||
$regex_safe_username = apply_filters('um_validation_safe_username_regex',$this->regex_safe );
|
||||
|
||||
if ( is_email( $string ) )
|
||||
return true;
|
||||
if ( !is_email( $string) && !preg_match( $regex_safe_username, $string ) )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Safe name usage ( for url purposes )
|
||||
*
|
||||
* @param $name
|
||||
*
|
||||
* @return mixed|string
|
||||
*/
|
||||
function safe_name_in_url( $name ) {
|
||||
$name = strtolower( $name );
|
||||
$name = preg_replace("/'/","", $name );
|
||||
$name = stripslashes( $name );
|
||||
$name = $this->normalize($name);
|
||||
$name = rawurldecode( $name );
|
||||
return $name;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @dash and underscore (metakey)
|
||||
***/
|
||||
function safe_string($string){
|
||||
|
||||
$regex_safe_string = apply_filters('um_validation_safe_string_regex',$this->regex_safe );
|
||||
/**
|
||||
* Password test
|
||||
*
|
||||
* @param $candidate
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function strong_pass( $candidate ) {
|
||||
$r1='/[A-Z]/';
|
||||
$r2='/[a-z]/';
|
||||
$r3='/[0-9]/';
|
||||
if(preg_match_all($r1,$candidate, $o)<1) return false;
|
||||
if(preg_match_all($r2,$candidate, $o)<1) return false;
|
||||
if(preg_match_all($r3,$candidate, $o)<1) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( !preg_match( $regex_safe_string, $string) ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @is phone number
|
||||
***/
|
||||
function is_phone_number( $string ){
|
||||
if ( !$string )
|
||||
return true;
|
||||
if ( !preg_match( $this->regex_phone_number, $string) )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Space, dash, underscore
|
||||
*
|
||||
* @param $string
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function safe_username( $string ) {
|
||||
|
||||
/***
|
||||
*** @is url
|
||||
***/
|
||||
function is_url( $url, $social = false ){
|
||||
if ( !$url ) return true;
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_validation_safe_username_regex
|
||||
* @description Change validation regex for username
|
||||
* @input_vars
|
||||
* [{"var":"$regex_safe","type":"string","desc":"Regex"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_validation_safe_username_regex', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_validation_safe_username_regex', 'my_validation_safe_username', 10, 1 );
|
||||
* function my_validation_safe_username( $regex_safe ) {
|
||||
* // your code here
|
||||
* return $regex_safe;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$regex_safe_username = apply_filters('um_validation_safe_username_regex',$this->regex_safe );
|
||||
|
||||
if ( $social ) {
|
||||
if ( is_email( $string ) )
|
||||
return true;
|
||||
if ( !is_email( $string) && !preg_match( $regex_safe_username, $string ) )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( !filter_var($url, FILTER_VALIDATE_URL) && strstr( $url, $social ) ) { // starts with social requested
|
||||
return true;
|
||||
} else {
|
||||
|
||||
if ( filter_var($url, FILTER_VALIDATE_URL) && strstr( $url, $social ) ) {
|
||||
return true;
|
||||
} elseif ( preg_match( $this->regex_safe, $url) ) {
|
||||
/**
|
||||
* Dash and underscore (metakey)
|
||||
*
|
||||
* @param $string
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function safe_string( $string ) {
|
||||
|
||||
if ( strstr( $url, '.com' ) ){
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_validation_safe_string_regex
|
||||
* @description Change validation regex for each string
|
||||
* @input_vars
|
||||
* [{"var":"$regex_safe","type":"string","desc":"Regex"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_validation_safe_string_regex', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_validation_safe_string_regex', 'my_validation_safe_string', 10, 1 );
|
||||
* function my_validation_safe_string( $regex_safe ) {
|
||||
* // your code here
|
||||
* return $regex_safe;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$regex_safe_string = apply_filters('um_validation_safe_string_regex',$this->regex_safe );
|
||||
|
||||
}
|
||||
if ( !preg_match( $regex_safe_string, $string) ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
/**
|
||||
* Ss phone number
|
||||
*
|
||||
* @param $string
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function is_phone_number( $string ) {
|
||||
if ( !$string )
|
||||
return true;
|
||||
if ( !preg_match( $this->regex_phone_number, $string) )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( strstr( $url, 'http://') || strstr( $url, 'https://') )
|
||||
return true;
|
||||
|
||||
}
|
||||
/**
|
||||
* Is url
|
||||
*
|
||||
* @param $url
|
||||
* @param bool $social
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function is_url( $url, $social = false ){
|
||||
if ( !$url ) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
if ( $social ) {
|
||||
|
||||
/***
|
||||
*** @get a random string
|
||||
***/
|
||||
function randomize( $length = 10 ) {
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$result = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$result .= $characters[rand(0, strlen($characters) - 1)];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
if ( !filter_var($url, FILTER_VALIDATE_URL) && strstr( $url, $social ) ) { // starts with social requested
|
||||
return true;
|
||||
} else {
|
||||
|
||||
/***
|
||||
*** @generate a password, hash, or similar
|
||||
***/
|
||||
function generate( $length = 40 ) {
|
||||
return wp_generate_password( $length, false );
|
||||
}
|
||||
if ( filter_var($url, FILTER_VALIDATE_URL) && strstr( $url, $social ) ) {
|
||||
return true;
|
||||
} elseif ( preg_match( $this->regex_safe, $url) ) {
|
||||
|
||||
/***
|
||||
*** @random numbers only
|
||||
***/
|
||||
function random_number($len = false) {
|
||||
$ints = array();
|
||||
$len = $len ? $len : rand(2,9);
|
||||
if($len > 9)
|
||||
{
|
||||
trigger_error('Maximum length should not exceed 9');
|
||||
return 0;
|
||||
}
|
||||
while(true)
|
||||
{
|
||||
$current = rand(0,9);
|
||||
if(!in_array($current,$ints))
|
||||
{
|
||||
$ints[] = $current;
|
||||
}
|
||||
if(count($ints) == $len)
|
||||
{
|
||||
return implode($ints);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( strstr( $url, '.com' ) ){
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @To validate given date input
|
||||
***/
|
||||
function validate_date( $date, $format='YYYY/MM/D' ) {
|
||||
if ( strlen( $date ) < strlen($format) ) return false;
|
||||
if ( $date[4] != '/' ) return false;
|
||||
if ( $date[7] != '/' ) return false;
|
||||
if ( false === strtotime($date) ) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if ( strstr( $url, 'http://') || strstr( $url, 'https://') )
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a random string
|
||||
*
|
||||
* @param int $length
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function randomize( $length = 10 ) {
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$result = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$result .= $characters[rand(0, strlen($characters) - 1)];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate a password, hash, or similar
|
||||
*
|
||||
* @param int $length
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function generate( $length = 40 ) {
|
||||
return wp_generate_password( $length, false );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Random numbers only
|
||||
*
|
||||
* @param bool $len
|
||||
*
|
||||
* @return int|string
|
||||
*/
|
||||
function random_number( $len = false ) {
|
||||
$ints = array();
|
||||
$len = $len ? $len : rand(2,9);
|
||||
if($len > 9)
|
||||
{
|
||||
trigger_error('Maximum length should not exceed 9');
|
||||
return 0;
|
||||
}
|
||||
while(true)
|
||||
{
|
||||
$current = rand(0,9);
|
||||
if(!in_array($current,$ints))
|
||||
{
|
||||
$ints[] = $current;
|
||||
}
|
||||
if(count($ints) == $len)
|
||||
{
|
||||
return implode($ints);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To validate given date input
|
||||
*
|
||||
* @param $date
|
||||
* @param string $format
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function validate_date( $date, $format='YYYY/MM/D' ) {
|
||||
if ( strlen( $date ) < strlen($format) ) return false;
|
||||
if ( $date[4] != '/' ) return false;
|
||||
if ( $date[7] != '/' ) return false;
|
||||
if ( false === strtotime($date) ) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,30 @@ function um_submit_account_errors_hook( $args ) {
|
||||
|
||||
$arr_fields = array();
|
||||
$account_fields = get_user_meta( um_user('ID'), 'um_account_secure_fields', true );
|
||||
$secure_fields = apply_filters( 'um_secure_account_fields', $account_fields , um_user( 'ID' ) );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_secure_account_fields
|
||||
* @description Change secure account fields
|
||||
* @input_vars
|
||||
* [{"var":"$fields","type":"array","desc":"Secure account fields"},
|
||||
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_secure_account_fields', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_secure_account_fields', 'my_secure_account_fields', 10, 2 );
|
||||
* function my_secure_account_fields( $fields, $user_id ) {
|
||||
* // your code here
|
||||
* return $fields;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$secure_fields = apply_filters( 'um_secure_account_fields', $account_fields, um_user( 'ID' ) );
|
||||
|
||||
if ( is_array( $secure_fields ) ) {
|
||||
foreach ( $secure_fields as $tab_key => $fields ) {
|
||||
@@ -184,6 +207,27 @@ function um_submit_account_errors_hook( $args ) {
|
||||
unset( $changes['hide_in_members'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_account_pre_updating_profile_array
|
||||
* @description Change update profile data before saving
|
||||
* @input_vars
|
||||
* [{"var":"$changes","type":"array","desc":"Profile changes array"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_account_pre_updating_profile_array', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_account_pre_updating_profile_array', 'my_account_pre_updating_profile', 10, 1 );
|
||||
* function my_account_pre_updating_profile( $changes ) {
|
||||
* // your code here
|
||||
* return $changes;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$changes = apply_filters( 'um_account_pre_updating_profile_array', $changes );
|
||||
|
||||
// fired on account page, just before updating profile
|
||||
|
||||
@@ -2,23 +2,46 @@
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
/**
|
||||
* Run check if username exists
|
||||
* @uses action hooks: wp_ajax_nopriv_ultimatemember_check_username_exists, wp_ajax_ultimatemember_check_username_exists
|
||||
* @return boolean
|
||||
*/
|
||||
add_action('wp_ajax_nopriv_ultimatemember_check_username_exists', 'ultimatemember_check_username_exists');
|
||||
add_action('wp_ajax_ultimatemember_check_username_exists', 'ultimatemember_check_username_exists');
|
||||
function ultimatemember_check_username_exists() {
|
||||
$username = isset($_REQUEST['username']) ? $_REQUEST['username'] : '';
|
||||
$exists = username_exists( $username );
|
||||
|
||||
/**
|
||||
* Run check if username exists
|
||||
* @uses action hooks: wp_ajax_nopriv_ultimatemember_check_username_exists, wp_ajax_ultimatemember_check_username_exists
|
||||
* @return boolean
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_validate_username_exists
|
||||
* @description Change username exists validation
|
||||
* @input_vars
|
||||
* [{"var":"$exists","type":"bool","desc":"Exists?"},
|
||||
* {"var":"$username","type":"string","desc":"Username"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_validate_username_exists', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_validate_username_exists', 'my_validate_username_exists', 10, 2 );
|
||||
* function my_account_pre_updating_profile( $exists, $username ) {
|
||||
* // your code here
|
||||
* return $exists;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
add_action('wp_ajax_nopriv_ultimatemember_check_username_exists', 'ultimatemember_check_username_exists');
|
||||
add_action('wp_ajax_ultimatemember_check_username_exists', 'ultimatemember_check_username_exists');
|
||||
function ultimatemember_check_username_exists() {
|
||||
$username = isset($_REQUEST['username']) ? $_REQUEST['username'] : '';
|
||||
$exists = username_exists( $username );
|
||||
$exists = apply_filters( 'um_validate_username_exists', $exists, $username );
|
||||
$exists = apply_filters( 'um_validate_username_exists', $exists, $username );
|
||||
|
||||
if( $exists ) {
|
||||
echo 1;
|
||||
} else {
|
||||
echo 0;
|
||||
}
|
||||
if ( $exists ) {
|
||||
echo 1;
|
||||
} else {
|
||||
echo 0;
|
||||
}
|
||||
|
||||
die();
|
||||
}
|
||||
die();
|
||||
}
|
||||
@@ -148,6 +148,28 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_get_custom_field_array
|
||||
* @description Extend custom field data on submit form error
|
||||
* @input_vars
|
||||
* [{"var":"$array","type":"array","desc":"Field data"},
|
||||
* {"var":"$fields","type":"array","desc":"All fields"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_get_custom_field_array', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_get_custom_field_array', 'my_get_custom_field_array', 10, 2 );
|
||||
* function my_get_custom_field_array( $array, $fields ) {
|
||||
* // your code here
|
||||
* return $array;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$array = apply_filters( 'um_get_custom_field_array', $array, $fields );
|
||||
|
||||
if ( ! empty( $array['conditions'] ) ) {
|
||||
|
||||
@@ -65,8 +65,6 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
UM()->form()->add_error( 'user_password', __('Password is incorrect. Please try again.','ultimate-member') );
|
||||
}
|
||||
|
||||
// add a way for other plugins like wp limit login
|
||||
// to limit the login attempts
|
||||
$user = apply_filters( 'authenticate', null, $user_name, $args['user_password'] );
|
||||
|
||||
$authenticate_user = apply_filters( 'wp_authenticate_user', $user_name, $args['user_password'] );
|
||||
@@ -240,12 +238,78 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( UM()->user()->preview == true && is_admin() ) return;
|
||||
|
||||
$primary_btn_word = $args['primary_btn_word'];
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_login_form_button_one
|
||||
* @description Change Login Form Primary button
|
||||
* @input_vars
|
||||
* [{"var":"$primary_btn_word","type":"string","desc":"Button text"},
|
||||
* {"var":"$args","type":"array","desc":"Login Form arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_login_form_button_one', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_login_form_button_one', 'my_login_form_button_one', 10, 2 );
|
||||
* function my_login_form_button_one( $primary_btn_word, $args ) {
|
||||
* // your code here
|
||||
* return $primary_btn_word;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$primary_btn_word = apply_filters('um_login_form_button_one', $primary_btn_word, $args );
|
||||
|
||||
$secondary_btn_word = $args['secondary_btn_word'];
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_login_form_button_two
|
||||
* @description Change Login Form Secondary button
|
||||
* @input_vars
|
||||
* [{"var":"$secondary_btn_word","type":"string","desc":"Button text"},
|
||||
* {"var":"$args","type":"array","desc":"Login Form arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_login_form_button_two', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_login_form_button_two', 'my_login_form_button_two', 10, 2 );
|
||||
* function my_login_form_button_two( $secondary_btn_word, $args ) {
|
||||
* // your code here
|
||||
* return $secondary_btn_word;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$secondary_btn_word = apply_filters('um_login_form_button_two', $secondary_btn_word, $args );
|
||||
|
||||
$secondary_btn_url = ( isset( $args['secondary_btn_url'] ) && $args['secondary_btn_url'] ) ? $args['secondary_btn_url'] : um_get_core_page('register');
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_login_form_button_two_url
|
||||
* @description Change Login Form Secondary button URL
|
||||
* @input_vars
|
||||
* [{"var":"$secondary_btn_url","type":"string","desc":"Button URL"},
|
||||
* {"var":"$args","type":"array","desc":"Login Form arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_login_form_button_two_url', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_login_form_button_two_url', 'my_login_form_button_two_url', 10, 2 );
|
||||
* function my_login_form_button_two_url( $secondary_btn_url, $args ) {
|
||||
* // your code here
|
||||
* return $secondary_btn_url;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$secondary_btn_url = apply_filters('um_login_form_button_two_url', $secondary_btn_url, $args );
|
||||
|
||||
?>
|
||||
|
||||
@@ -17,8 +17,29 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$search_filters = apply_filters('um_frontend_member_search_filters',$search_filters);
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_frontend_member_search_filters
|
||||
* @description Extend Member Directory Search filter
|
||||
* @input_vars
|
||||
* [{"var":"$search_filters","type":"array","desc":"Search Filters"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_frontend_member_search_filters', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_frontend_member_search_filters', 'my_frontend_member_search_filters', 10, 1 );
|
||||
* function my_frontend_member_search_filters( $search_filters ) {
|
||||
* // your code here
|
||||
* return $search_filters;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$search_filters = apply_filters( 'um_frontend_member_search_filters', $search_filters );
|
||||
|
||||
if ( $args['search'] == 1 && is_array( $search_filters ) ) { // search on
|
||||
|
||||
|
||||
@@ -41,9 +41,29 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
$url = apply_filters('um_browser_url_redirect_to__filter', $url );
|
||||
if( ! empty( $url ) ){
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_browser_url_redirect_to__filter
|
||||
* @description Add redirect to field to form and change URL for it
|
||||
* @input_vars
|
||||
* [{"var":"$url","type":"string","desc":"Redirect to URL"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_browser_url_redirect_to__filter', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_browser_url_redirect_to__filter', 'my_browser_url_redirect_to', 10, 1 );
|
||||
* function my_browser_url_redirect_to( $url ) {
|
||||
* // your code here
|
||||
* return $url;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$url = apply_filters( 'um_browser_url_redirect_to__filter', $url );
|
||||
if ( ! empty( $url ) ) {
|
||||
echo '<input type="hidden" name="redirect_to" id="redirect_to" value="' . esc_url( $url ) . '" />';
|
||||
}
|
||||
|
||||
@@ -64,7 +84,29 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
switch( $_REQUEST['updated'] ) {
|
||||
|
||||
default:
|
||||
$success = apply_filters("um_custom_success_message_handler", $success, $_REQUEST['updated']);
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_custom_success_message_handler
|
||||
* @description Add custom success message
|
||||
* @input_vars
|
||||
* [{"var":"$success","type":"string","desc":"Message"},
|
||||
* {"var":"$updated","type":"array","desc":"Updated data"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_custom_success_message_handler', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_custom_success_message_handler', 'my_custom_success_message', 10, 2 );
|
||||
* function my_custom_success_message( $success, $updated ) {
|
||||
* // your code here
|
||||
* return $success;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$success = apply_filters( "um_custom_success_message_handler", $success, $_REQUEST['updated'] );
|
||||
break;
|
||||
|
||||
case 'account':
|
||||
@@ -86,9 +128,31 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
switch( $_REQUEST['err'] ) {
|
||||
|
||||
default:
|
||||
$err = apply_filters("um_custom_error_message_handler", $err, $_REQUEST['err']);
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_custom_error_message_handler
|
||||
* @description Add custom error message
|
||||
* @input_vars
|
||||
* [{"var":"$error","type":"string","desc":"Error message"},
|
||||
* {"var":"$request_error","type":"array","desc":"Error data"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_custom_error_message_handler', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_custom_error_message_handler', 'my_custom_error_message', 10, 2 );
|
||||
* function my_custom_error_message( $error, $request_error ) {
|
||||
* // your code here
|
||||
* return $error;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$err = apply_filters( "um_custom_error_message_handler", $err, $_REQUEST['err'] );
|
||||
if ( !$err )
|
||||
$err = __('An error has been encountered','ultimate-member');
|
||||
$err = __( 'An error has been encountered', 'ultimate-member' );
|
||||
break;
|
||||
|
||||
case 'registration_disabled':
|
||||
|
||||
@@ -13,9 +13,31 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! UM()->options()->get( 'profile_tab_main' ) && ! isset( $_REQUEST['um_action'] ) )
|
||||
return;
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_profile_can_view_main
|
||||
* @description Check user can view profile
|
||||
* @input_vars
|
||||
* [{"var":"$view","type":"bool","desc":"Can view?"},
|
||||
* {"var":"$user_id","type":"int","desc":"User profile ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_profile_can_view_main', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_profile_can_view_main', 'my_profile_can_view_main', 10, 2 );
|
||||
* function my_profile_can_view_main( $view, $user_id ) {
|
||||
* // your code here
|
||||
* return $view;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$can_view = apply_filters( 'um_profile_can_view_main', -1, um_profile_id() );
|
||||
|
||||
if ($can_view == -1) {
|
||||
if ( $can_view == -1 ) {
|
||||
|
||||
do_action( "um_before_form", $args );
|
||||
|
||||
@@ -120,6 +142,27 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
do_action( 'um_user_pre_updating_profile', $to_update );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_user_pre_updating_profile_array
|
||||
* @description Change submitted data before update profile
|
||||
* @input_vars
|
||||
* [{"var":"$to_update","type":"array","desc":"Profile data upgrade"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_user_pre_updating_profile_array', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_user_pre_updating_profile_array', 'my_user_pre_updating_profile', 10, 1 );
|
||||
* function my_user_pre_updating_profile( $to_update ) {
|
||||
* // your code here
|
||||
* return $to_update;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$to_update = apply_filters( 'um_user_pre_updating_profile_array', $to_update );
|
||||
|
||||
|
||||
@@ -128,6 +171,27 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
do_action( 'um_after_user_updated', um_user( 'ID' ), $args, $to_update );
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_user_pre_updating_files_array
|
||||
* @description Change submitted files before update profile
|
||||
* @input_vars
|
||||
* [{"var":"$files","type":"array","desc":"Profile data files"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_user_pre_updating_files_array', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_user_pre_updating_files_array', 'my_user_pre_updating_files', 10, 1 );
|
||||
* function my_user_pre_updating_files( $files ) {
|
||||
* // your code here
|
||||
* return $files;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$files = apply_filters( 'um_user_pre_updating_files_array', $files );
|
||||
|
||||
if (is_array( $files )) {
|
||||
@@ -377,6 +441,27 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
'<a href="#" class="um-dropdown-hide">' . __( 'Cancel', 'ultimate-member' ) . '</a>',
|
||||
);
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_user_photo_menu_view
|
||||
* @description Change user photo on menu view
|
||||
* @input_vars
|
||||
* [{"var":"$items","type":"array","desc":"User Photos"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_user_photo_menu_view', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_user_photo_menu_view', 'my_user_photo_menu_view', 10, 1 );
|
||||
* function my_user_photo_menu_view( $items ) {
|
||||
* // your code here
|
||||
* return $items;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$items = apply_filters( 'um_user_photo_menu_view', $items );
|
||||
|
||||
echo UM()->menu()->new_ui( 'bc', 'div.um-profile-photo', 'click', $items );
|
||||
@@ -389,6 +474,27 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
'<a href="#" class="um-dropdown-hide">' . __( 'Cancel', 'ultimate-member' ) . '</a>',
|
||||
);
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_user_photo_menu_edit
|
||||
* @description Change user photo on menu edit
|
||||
* @input_vars
|
||||
* [{"var":"$items","type":"array","desc":"User Photos"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_user_photo_menu_edit', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_user_photo_menu_edit', 'my_user_photo_menu_edit', 10, 1 );
|
||||
* function my_user_photo_menu_edit( $items ) {
|
||||
* // your code here
|
||||
* return $items;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$items = apply_filters( 'um_user_photo_menu_edit', $items );
|
||||
|
||||
echo UM()->menu()->new_ui( 'bc', 'div.um-profile-photo', 'click', $items );
|
||||
@@ -574,12 +680,55 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
$items = array_merge( $items, $actions );
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_profile_edit_menu_items
|
||||
* @description Edit menu items on profile page
|
||||
* @input_vars
|
||||
* [{"var":"$items","type":"array","desc":"User Menu"},
|
||||
* {"var":"$user_id","type":"int","desc":"Profile ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_profile_edit_menu_items', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_profile_edit_menu_items', 'my_profile_edit_menu_items', 10, 2 );
|
||||
* function my_profile_edit_menu_items( $items, $user_id ) {
|
||||
* // your code here
|
||||
* return $items;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$items = apply_filters( 'um_profile_edit_menu_items', $items, um_profile_id() );
|
||||
|
||||
$items['cancel'] = $cancel;
|
||||
|
||||
} else {
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_myprofile_edit_menu_items
|
||||
* @description Edit menu items on my profile page
|
||||
* @input_vars
|
||||
* [{"var":"$items","type":"array","desc":"User Menu"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_myprofile_edit_menu_items', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_myprofile_edit_menu_items', 'my_myprofile_edit_menu_items', 10, 1 );
|
||||
* function my_myprofile_edit_menu_items( $items ) {
|
||||
* // your code here
|
||||
* return $items;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$items = apply_filters( 'um_myprofile_edit_menu_items', $items );
|
||||
|
||||
}
|
||||
@@ -673,6 +822,27 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
// get active tabs
|
||||
$tabs = UM()->profile()->tabs_active();
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_user_profile_tabs
|
||||
* @description Extend profile tabs
|
||||
* @input_vars
|
||||
* [{"var":"$tabs","type":"array","desc":"Profile Tabs"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_user_profile_tabs', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_user_profile_tabs', 'my_user_profile_tabs', 10, 1 );
|
||||
* function my_user_profile_tabs( $tabs ) {
|
||||
* // your code here
|
||||
* return $tabs;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$tabs = apply_filters( 'um_user_profile_tabs', $tabs );
|
||||
|
||||
UM()->user()->tabs = $tabs;
|
||||
@@ -710,6 +880,27 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
$nav_link = remove_query_arg( 'subnav', $nav_link );
|
||||
$nav_link = add_query_arg( 'profiletab', $id, $nav_link );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_profile_menu_link_{$id}
|
||||
* @description Change profile menu link by tab $id
|
||||
* @input_vars
|
||||
* [{"var":"$nav_link","type":"string","desc":"Profile Tab Link"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_profile_menu_link_{$id}', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_profile_menu_link_{$id}', 'my_profile_menu_link', 10, 1 );
|
||||
* function my_profile_menu_link( $nav_link ) {
|
||||
* // your code here
|
||||
* return $nav_link;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$nav_link = apply_filters( "um_profile_menu_link_{$id}", $nav_link );
|
||||
|
||||
?>
|
||||
|
||||
@@ -149,6 +149,27 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( isset( UM()->form()->errors ) )
|
||||
return false;
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_add_user_frontend_submitted
|
||||
* @description Extend user data on registration form submit
|
||||
* @input_vars
|
||||
* [{"var":"$submitted","type":"array","desc":"Registration data"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_add_user_frontend_submitted', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_add_user_frontend_submitted', 'my_add_user_frontend_submitted', 10, 1 );
|
||||
* function my_add_user_frontend_submitted( $submitted ) {
|
||||
* // your code here
|
||||
* return $submitted;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$args = apply_filters( 'um_add_user_frontend_submitted', $args );
|
||||
|
||||
extract( $args );
|
||||
@@ -198,6 +219,27 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! isset( $user_email ) ) {
|
||||
$site_url = @$_SERVER['SERVER_NAME'];
|
||||
$user_email = 'nobody' . $unique_userID . '@' . $site_url;
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_user_register_submitted__email
|
||||
* @description Change user default email if it's empty on registration
|
||||
* @input_vars
|
||||
* [{"var":"$user_email","type":"string","desc":"Default email"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_user_register_submitted__email', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_user_register_submitted__email', 'my_user_register_submitted__email', 10, 1 );
|
||||
* function my_user_register_submitted__email( $user_email ) {
|
||||
* // your code here
|
||||
* return $user_email;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$user_email = apply_filters( 'um_user_register_submitted__email', $user_email );
|
||||
}
|
||||
|
||||
@@ -210,6 +252,28 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
$args['submitted'] = array_merge( $args['submitted'], $credentials );
|
||||
$args = array_merge( $args, $credentials );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_registration_user_role
|
||||
* @description Change user role on registration process
|
||||
* @input_vars
|
||||
* [{"var":"$role","type":"string","desc":"User role"},
|
||||
* {"var":"$submitted","type":"array","desc":"Registration data"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_registration_user_role', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_registration_user_role', 'my_registration_user_role', 10, 2 );
|
||||
* function my_user_register_submitted__email( $role, $submitted ) {
|
||||
* // your code here
|
||||
* return $role;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$user_role = apply_filters( 'um_registration_user_role', UM()->form()->assigned_role( UM()->form()->form_id ), $args );
|
||||
|
||||
$userdata = array(
|
||||
@@ -245,6 +309,27 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if( empty( $role ) ) return;
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_register_hidden_role_field
|
||||
* @description Display hidden role field
|
||||
* @input_vars
|
||||
* [{"var":"$role","type":"string","desc":"Hidden user role"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_register_hidden_role_field', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_register_hidden_role_field', 'my_register_hidden_role_field', 10, 1 );
|
||||
* function my_register_hidden_role_field( $role ) {
|
||||
* // your code here
|
||||
* return $role;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$role = apply_filters('um_register_hidden_role_field', $role );
|
||||
if( $role ){
|
||||
echo '<input type="hidden" name="role" id="role" value="' . $role . '" />';
|
||||
@@ -261,12 +346,78 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( isset( UM()->user()->preview ) && UM()->user()->preview == true && is_admin() ) return;
|
||||
|
||||
$primary_btn_word = $args['primary_btn_word'];
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_register_form_button_one
|
||||
* @description Change Register Form Primary button
|
||||
* @input_vars
|
||||
* [{"var":"$primary_btn_word","type":"string","desc":"Button text"},
|
||||
* {"var":"$args","type":"array","desc":"Registration Form arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_register_form_button_one', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_register_form_button_one', 'my_register_form_button_one', 10, 2 );
|
||||
* function my_register_form_button_one( $primary_btn_word, $args ) {
|
||||
* // your code here
|
||||
* return $primary_btn_word;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$primary_btn_word = apply_filters('um_register_form_button_one', $primary_btn_word, $args );
|
||||
|
||||
$secondary_btn_word = $args['secondary_btn_word'];
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_register_form_button_two
|
||||
* @description Change Registration Form Secondary button
|
||||
* @input_vars
|
||||
* [{"var":"$secondary_btn_word","type":"string","desc":"Button text"},
|
||||
* {"var":"$args","type":"array","desc":"Registration Form arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_register_form_button_two', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_register_form_button_two', 'my_register_form_button_two', 10, 2 );
|
||||
* function my_register_form_button_two( $secondary_btn_word, $args ) {
|
||||
* // your code here
|
||||
* return $secondary_btn_word;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$secondary_btn_word = apply_filters('um_register_form_button_two', $secondary_btn_word, $args );
|
||||
|
||||
$secondary_btn_url = ( isset( $args['secondary_btn_url'] ) && $args['secondary_btn_url'] ) ? $args['secondary_btn_url'] : um_get_core_page('login');
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_register_form_button_two_url
|
||||
* @description Change Registration Form Secondary button URL
|
||||
* @input_vars
|
||||
* [{"var":"$secondary_btn_url","type":"string","desc":"Button URL"},
|
||||
* {"var":"$args","type":"array","desc":"Registration Form arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_register_form_button_two_url', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_register_form_button_two_url', 'my_register_form_button_two_url', 10, 2 );
|
||||
* function my_register_form_button_two_url( $secondary_btn_url, $args ) {
|
||||
* // your code here
|
||||
* return $secondary_btn_url;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$secondary_btn_url = apply_filters('um_register_form_button_two_url', $secondary_btn_url, $args );
|
||||
|
||||
?>
|
||||
@@ -332,6 +483,27 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_user_pre_updating_files_array
|
||||
* @description Change submitted files before register new user
|
||||
* @input_vars
|
||||
* [{"var":"$files","type":"array","desc":"Profile data files"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_user_pre_updating_files_array', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_user_pre_updating_files_array', 'my_user_pre_updating_files', 10, 1 );
|
||||
* function my_user_pre_updating_files( $files ) {
|
||||
* // your code here
|
||||
* return $files;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$files = apply_filters( 'um_user_pre_updating_files_array', $files );
|
||||
|
||||
if ( !empty( $files ) ) {
|
||||
|
||||
@@ -12,7 +12,28 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
*/
|
||||
add_filter('um_account_secure_fields','um_account_secure_fields', 10, 2);
|
||||
function um_account_secure_fields( $fields, $tab_key ){
|
||||
$secure = apply_filters('um_account_secure_fields__enabled', true );
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_account_secure_fields__enabled
|
||||
* @description Active account secure fields
|
||||
* @input_vars
|
||||
* [{"var":"$enabled","type":"string","desc":"Enable secure account fields"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_account_secure_fields__enabled', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_account_secure_fields__enabled', 'my_account_secure_fields', 10, 1 );
|
||||
* function my_account_secure_fields( $enabled ) {
|
||||
* // your code here
|
||||
* return $enabled;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$secure = apply_filters( 'um_account_secure_fields__enabled', true );
|
||||
|
||||
if( ! $secure ) return $fields;
|
||||
|
||||
|
||||
@@ -39,7 +39,28 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
$avatar = um_user('profile_photo', $size);
|
||||
|
||||
$image_alt = apply_filters("um_avatar_image_alternate_text", um_user("display_name") );
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_avatar_image_alternate_text
|
||||
* @description Change avatar image alt
|
||||
* @input_vars
|
||||
* [{"var":"$avatar_alt","type":"string","desc":"Image alternate text. Display name by default"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_avatar_image_alternate_text', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_avatar_image_alternate_text', 'my_avatar_image_alternate_text', 10, 1 );
|
||||
* function my_avatar_image_alternate_text( $avatar_alt ) {
|
||||
* // your code here
|
||||
* return $avatar_alt;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$image_alt = apply_filters( "um_avatar_image_alternate_text", um_user("display_name") );
|
||||
|
||||
if ( ! $avatar && UM()->options()->get( 'use_gravatars' ) ) {
|
||||
|
||||
|
||||
@@ -206,8 +206,8 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
/***
|
||||
*** @global
|
||||
***/
|
||||
add_filter('um_profile_field_filter_hook__', 'um_profile_field_filter_hook__', 99, 2);
|
||||
function um_profile_field_filter_hook__( $value, $data ) {
|
||||
add_filter('um_profile_field_filter_hook__', 'um_profile_field_filter_hook__', 99, 3 );
|
||||
function um_profile_field_filter_hook__( $value, $data, $type = '' ) {
|
||||
if ( !$value ) return '';
|
||||
|
||||
if ( ( isset( $data['validate'] ) && $data['validate'] != '' && strstr( $data['validate'], 'url' ) ) || ( isset( $data['type'] ) && $data['type'] == 'url' ) ) {
|
||||
@@ -322,8 +322,8 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
* @return mixed
|
||||
* @uses hook filter: um_profile_field_filter_hook__
|
||||
*/
|
||||
add_filter('um_profile_field_filter_hook__','um_force_utf8_fields', 10, 2 );
|
||||
function um_force_utf8_fields( $value, $data ) {
|
||||
add_filter('um_profile_field_filter_hook__','um_force_utf8_fields', 9, 3 );
|
||||
function um_force_utf8_fields( $value, $data, $type = '' ) {
|
||||
|
||||
if( ! UM()->options()->get('um_force_utf8_strings') )
|
||||
return $value;
|
||||
@@ -470,7 +470,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
* @return string $value
|
||||
* @uses hook filters: um_profile_field_filter_hook__
|
||||
*/
|
||||
function um_profile_field_filter_xss_validation( $value, $data, $type ) {
|
||||
function um_profile_field_filter_xss_validation( $value, $data, $type = '' ) {
|
||||
if ( ! empty( $value ) && is_string( $value ) ) {
|
||||
$value = stripslashes( $value );
|
||||
$data['validate'] = isset( $data['validate'] ) ? $data['validate'] : '';
|
||||
|
||||
@@ -3,23 +3,67 @@
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
|
||||
/***
|
||||
*** @Support multisite
|
||||
***/
|
||||
add_filter('um_upload_basedir_filter','um_multisite_urls_support', 99 );
|
||||
add_filter('um_upload_baseurl_filter','um_multisite_urls_support', 99 );
|
||||
function um_multisite_urls_support( $dir ) {
|
||||
|
||||
if ( is_multisite() ) { // Need to the work
|
||||
|
||||
if ( get_current_blog_id() == '1' ) return $dir;
|
||||
|
||||
$sites_dir = apply_filters('um_multisite_upload_sites_directory', 'sites/' );
|
||||
$split = explode( $sites_dir, $dir );
|
||||
$um_dir = apply_filters('um_multisite_upload_directory','ultimatemember/');
|
||||
$dir = $split[0] . $um_dir;
|
||||
/***
|
||||
*** @Support multisite
|
||||
***/
|
||||
add_filter('um_upload_basedir_filter','um_multisite_urls_support', 99 );
|
||||
add_filter('um_upload_baseurl_filter','um_multisite_urls_support', 99 );
|
||||
function um_multisite_urls_support( $dir ) {
|
||||
|
||||
if ( is_multisite() ) { // Need to the work
|
||||
|
||||
if ( get_current_blog_id() == '1' ) {
|
||||
return $dir;
|
||||
}
|
||||
|
||||
return $dir;
|
||||
}
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_multisite_upload_sites_directory
|
||||
* @description Change multisite uploads directory
|
||||
* @input_vars
|
||||
* [{"var":"$sites_dir","type":"string","desc":"Upload sites directory"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_multisite_upload_sites_directory', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_multisite_upload_sites_directory', 'my_multisite_upload_sites_directory', 10, 1 );
|
||||
* function my_multisite_upload_sites_directory( $sites_dir ) {
|
||||
* // your code here
|
||||
* return $sites_dir;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$sites_dir = apply_filters('um_multisite_upload_sites_directory', 'sites/' );
|
||||
$split = explode( $sites_dir, $dir );
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_multisite_upload_directory
|
||||
* @description Change multisite UM uploads directory
|
||||
* @input_vars
|
||||
* [{"var":"$um_dir","type":"string","desc":"Upload UM directory"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_multisite_upload_directory', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_multisite_upload_directory', 'my_multisite_upload_directory', 10, 1 );
|
||||
* function my_multisite_upload_directory( $um_dir ) {
|
||||
* // your code here
|
||||
* return $um_dir;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$um_dir = apply_filters('um_multisite_upload_directory','ultimatemember/');
|
||||
$dir = $split[0] . $um_dir;
|
||||
|
||||
}
|
||||
|
||||
return $dir;
|
||||
}
|
||||
@@ -151,6 +151,27 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
'relation' => 'OR',
|
||||
);
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_query_args_{$field}__filter
|
||||
* @description Change field's query for search at Members Directory
|
||||
* @input_vars
|
||||
* [{"var":"$field_query","type":"array","desc":"Field query"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_query_args_{$field}__filter', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_query_args_{$field}__filter', 'my_query_args_filter', 10, 1 );
|
||||
* function my_query_args_filter( $field_query ) {
|
||||
* // your code here
|
||||
* return $field_query;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$field_query = apply_filters( "um_query_args_{$field}__filter", $field_query );
|
||||
$query_args['meta_query'][] = $field_query;
|
||||
}
|
||||
@@ -164,7 +185,27 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
}
|
||||
|
||||
// allow filtering
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_query_args_filter
|
||||
* @description Change query for search at Members Directory
|
||||
* @input_vars
|
||||
* [{"var":"$query_args","type":"array","desc":"Query Arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_query_args_filter', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_query_args_filter', 'my_query_args_filter', 10, 1 );
|
||||
* function my_query_args_filter( $query_args ) {
|
||||
* // your code here
|
||||
* return $query_args;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$query_args = apply_filters( 'um_query_args_filter', $query_args );
|
||||
|
||||
if ( count( $query_args['meta_query'] ) == 1 )
|
||||
@@ -293,6 +334,28 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
$query_args['order'] = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_modify_sortby_parameter
|
||||
* @description Change query sort by attributes for search at Members Directory
|
||||
* @input_vars
|
||||
* [{"var":"$query_args","type":"array","desc":"Query Arguments"},
|
||||
* {"var":"$sortby","type":"string","desc":"Sort by"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_modify_sortby_parameter', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_modify_sortby_parameter', 'my_modify_sortby_parameter', 10, 2 );
|
||||
* function my_modify_sortby_parameter( $query_args, $sortby ) {
|
||||
* // your code here
|
||||
* return $query_args;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$query_args = apply_filters('um_modify_sortby_parameter', $query_args, $sortby);
|
||||
|
||||
}
|
||||
|
||||
@@ -75,7 +75,28 @@ if ( ! is_admin() ) {
|
||||
|
||||
}
|
||||
|
||||
// add filter to work with plugins that don't use traditional roles
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_nav_menu_roles_item_visibility
|
||||
* @description Add filter to work with plugins that don't use traditional roles
|
||||
* @input_vars
|
||||
* [{"var":"$visible","type":"bool","desc":"Visible?"},
|
||||
* {"var":"$item","type":"object","desc":"Menu Item"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_nav_menu_roles_item_visibility', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_nav_menu_roles_item_visibility', 'my_nav_menu_roles_item_visibility', 10, 2 );
|
||||
* function my_nav_menu_roles_item_visibility( $visible, $item ) {
|
||||
* // your code here
|
||||
* return $visible;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$visible = apply_filters( 'um_nav_menu_roles_item_visibility', $visible, $item );
|
||||
|
||||
// unset non-visible item
|
||||
|
||||
@@ -92,11 +92,31 @@ function um_clean_user_basename_filter( $value, $raw ){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$value = apply_filters("um_permalink_base_before_filter", $value );
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_permalink_base_before_filter
|
||||
* @description Base permalink before
|
||||
* @input_vars
|
||||
* [{"var":"$permalink","type":"string","desc":"User Permalink"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_permalink_base_before_filter', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_permalink_base_before_filter', 'my_permalink_base_before', 10, 1 );
|
||||
* function my_permalink_base_before( $permalink ) {
|
||||
* // your code here
|
||||
* return $permalink;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$value = apply_filters( "um_permalink_base_before_filter", $value );
|
||||
$raw_value = $value;
|
||||
|
||||
switch( $permalink_base ){
|
||||
switch( $permalink_base ) {
|
||||
case 'name':
|
||||
|
||||
|
||||
@@ -112,6 +132,28 @@ function um_clean_user_basename_filter( $value, $raw ){
|
||||
$value = str_replace( '.', ' ', $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_permalink_base_after_filter_name
|
||||
* @description Base permalink after if permalink is username
|
||||
* @input_vars
|
||||
* [{"var":"$permalink","type":"string","desc":"User Permalink"},
|
||||
* {"var":"$raw_permalink","type":"string","desc":"RAW User Permalink"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_permalink_base_after_filter_name', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_permalink_base_after_filter_name', 'my_permalink_base_after_filter_name', 10, 2 );
|
||||
* function my_permalink_base_after_filter_name( $permalink, $raw_permalink ) {
|
||||
* // your code here
|
||||
* return $permalink;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$value = apply_filters("um_permalink_base_after_filter_name", $value, $raw_value );
|
||||
|
||||
break;
|
||||
@@ -131,6 +173,28 @@ function um_clean_user_basename_filter( $value, $raw ){
|
||||
$value = str_replace( '_', '-', $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_permalink_base_after_filter_name_dash
|
||||
* @description Base permalink after if permalink is first name - last name
|
||||
* @input_vars
|
||||
* [{"var":"$permalink","type":"string","desc":"User Permalink"},
|
||||
* {"var":"$raw_permalink","type":"string","desc":"RAW User Permalink"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_permalink_base_after_filter_name_dash', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_permalink_base_after_filter_name_dash', 'my_permalink_base_after_filter_name_dash', 10, 2 );
|
||||
* function my_permalink_base_after_filter_name_dash( $permalink, $raw_permalink ) {
|
||||
* // your code here
|
||||
* return $permalink;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$value = apply_filters("um_permalink_base_after_filter_name_dash", $value, $raw_value );
|
||||
|
||||
break;
|
||||
@@ -146,6 +210,28 @@ function um_clean_user_basename_filter( $value, $raw ){
|
||||
$value = str_replace( '_', '+', $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_permalink_base_after_filter_name_plus
|
||||
* @description Base permalink after if permalink is first name + last name
|
||||
* @input_vars
|
||||
* [{"var":"$permalink","type":"string","desc":"User Permalink"},
|
||||
* {"var":"$raw_permalink","type":"string","desc":"RAW User Permalink"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_permalink_base_after_filter_name_plus', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_permalink_base_after_filter_name_plus', 'my_permalink_base_after_filter_name_plus', 10, 2 );
|
||||
* function my_permalink_base_after_filter_name_plus( $permalink, $raw_permalink ) {
|
||||
* // your code here
|
||||
* return $permalink;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$value = apply_filters("um_permalink_base_after_filter_name_plus", $value, $raw_value );
|
||||
|
||||
break;
|
||||
@@ -157,6 +243,28 @@ function um_clean_user_basename_filter( $value, $raw ){
|
||||
$value = str_replace( '_', '-', $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_permalink_base_after_filter
|
||||
* @description Base permalink after for default permalink
|
||||
* @input_vars
|
||||
* [{"var":"$permalink","type":"string","desc":"User Permalink"},
|
||||
* {"var":"$raw_permalink","type":"string","desc":"RAW User Permalink"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_permalink_base_after_filter', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_permalink_base_after_filter', 'my_permalink_base_after', 10, 2 );
|
||||
* function my_permalink_base_after( $permalink, $raw_permalink ) {
|
||||
* // your code here
|
||||
* return $permalink;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$value = apply_filters("um_permalink_base_after_filter", $value, $raw_value );
|
||||
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user