diff --git a/includes/admin/core/class-admin-builder.php b/includes/admin/core/class-admin-builder.php index 9dc7216c..270a8d64 100644 --- a/includes/admin/core/class-admin-builder.php +++ b/includes/admin/core/class-admin-builder.php @@ -318,7 +318,49 @@ if ( ! class_exists( 'Admin_Builder' ) ) { 'post' => $_POST ); - $array = apply_filters("um_admin_pre_save_fields_hook", $array ); + /** + * UM hook + * + * @type filter + * @title um_admin_pre_save_fields_hook + * @description Filter field data before save + * @input_vars + * [{"var":"$array","type":"array","desc":"Save Field data"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_admin_pre_save_fields_hook', 'function_name', 10, 1 ); + * @example + * + */ + $array = apply_filters( "um_admin_pre_save_fields_hook", $array ); + + /** + * UM hook + * + * @type filter + * @title um_admin_field_update_error_handling + * @description Change error string on save field + * @input_vars + * [{"var":"$error","type":"string","desc":"Error String"}, + * {"var":"$array","type":"array","desc":"Save Field data"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_admin_field_update_error_handling', 'function_name', 10, 2 ); + * @example + * + */ $output['error'] = apply_filters( 'um_admin_field_update_error_handling', $output['error'], $array ); extract( $array['post'] ); @@ -347,10 +389,50 @@ if ( ! class_exists( 'Admin_Builder' ) ) { $field_ID = $_metakey; $field_args = $save[ $_metakey ]; + /** + * UM hook + * + * @type filter + * @title um_admin_pre_save_field_to_form + * @description Change field options before save to form + * @input_vars + * [{"var":"$field_args","type":"array","desc":"Field Options"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_admin_pre_save_field_to_form', 'function_name', 10, 1 ); + * @example + * + */ $field_args = apply_filters("um_admin_pre_save_field_to_form", $field_args ); UM()->fields()->update_field( $field_ID, $field_args, $post_id ); + /** + * UM hook + * + * @type filter + * @title um_admin_pre_save_field_to_db + * @description Change field options before save to DB + * @input_vars + * [{"var":"$field_args","type":"array","desc":"Field Options"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_admin_pre_save_field_to_db', 'function_name', 10, 1 ); + * @example + * + */ $field_args = apply_filters("um_admin_pre_save_field_to_db", $field_args ); if ( ! isset( $array['args']['form_only'] ) ) { diff --git a/includes/admin/core/class-admin-columns.php b/includes/admin/core/class-admin-columns.php index 32af20c6..457b9db4 100644 --- a/includes/admin/core/class-admin-columns.php +++ b/includes/admin/core/class-admin-columns.php @@ -131,7 +131,7 @@ if ( ! class_exists( 'Admin_Columns' ) ) { public function add_display_post_states( $post_states, $post ) { foreach ( UM()->config()->core_pages as $page_key => $page_value ) { - $page_id = UM()->options()->get( apply_filters( 'um_core_page_id_filter', 'core_' . $page_key ) ); + $page_id = UM()->options()->get( UM()->options()->get_core_page_id( $page_key ) ); if ( $page_id == $post->ID ) { $post_states['um_core_page_' . $page_key] = sprintf( 'UM %s', $page_value['title'] ); diff --git a/includes/admin/core/class-admin-enqueue.php b/includes/admin/core/class-admin-enqueue.php index 4b1f561a..38281314 100644 --- a/includes/admin/core/class-admin-enqueue.php +++ b/includes/admin/core/class-admin-enqueue.php @@ -348,6 +348,26 @@ if ( ! class_exists( 'Admin_Enqueue' ) ) { */ function load_localize_scripts(){ + /** + * UM hook + * + * @type filter + * @title um_admin_enqueue_localize_data + * @description Extend localize data at wp-admin side + * @input_vars + * [{"var":"$localize_data","type":"array","desc":"Localize Data"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_admin_enqueue_localize_data', 'function_name', 10, 1 ); + * @example + * + */ $localize_data = apply_filters('um_admin_enqueue_localize_data', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) diff --git a/includes/admin/core/class-admin-forms.php b/includes/admin/core/class-admin-forms.php index 33cc0626..a00f2cb6 100644 --- a/includes/admin/core/class-admin-forms.php +++ b/includes/admin/core/class-admin-forms.php @@ -106,7 +106,7 @@ if ( ! class_exists( 'Admin_Forms' ) ) { } else { - $html .= apply_filters( 'um_render_field_type_' . $data['type'], '', $data, $this->form_data ); + $html .= $this->render_field_by_hook( $data ); } @@ -127,7 +127,7 @@ if ( ! class_exists( 'Admin_Forms' ) ) { } else { - $html .= apply_filters( 'um_render_field_type_' . $data['type'], '', $data, $this->form_data ); + $html .= $this->render_field_by_hook( $data ); } @@ -146,7 +146,7 @@ if ( ! class_exists( 'Admin_Forms' ) ) { } else { - $html .= apply_filters( 'um_render_field_type_' . $data['type'], '', $data, $this->form_data ); + $html .= $this->render_field_by_hook( $data ); } @@ -170,7 +170,7 @@ if ( ! class_exists( 'Admin_Forms' ) ) { } else { - $html .= apply_filters( 'um_render_field_type_' . $data['type'], '', $data, $this->form_data ); + $html .= $this->render_field_by_hook( $data ); } @@ -192,7 +192,7 @@ if ( ! class_exists( 'Admin_Forms' ) ) { } else { - $html .= apply_filters( 'um_render_field_type_' . $data['type'], '', $data, $this->form_data ); + $html .= $this->render_field_by_hook( $data ); } @@ -213,7 +213,7 @@ if ( ! class_exists( 'Admin_Forms' ) ) { } else { - $html .= apply_filters( 'um_render_field_type_' . $data['type'], '', $data, $this->form_data ); + $html .= $this->render_field_by_hook( $data ); } @@ -233,7 +233,7 @@ if ( ! class_exists( 'Admin_Forms' ) ) { } else { - $html .= apply_filters( 'um_render_field_type_' . $data['type'], '', $data, $this->form_data ); + $html .= $this->render_field_by_hook( $data ); } } @@ -242,6 +242,33 @@ if ( ! class_exists( 'Admin_Forms' ) ) { } + function render_field_by_hook( $data ) { + /** + * UM hook + * + * @type filter + * @title um_render_field_type_{$type} + * @description Render admin form field by hook + * @input_vars + * [{"var":"$html","type":"string","desc":"Field's HTML"}, + * {"var":"$data","type":"array","desc":"Field's data"}, + * {"var":"$form_data","type":"array","desc":"Form data"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_render_field_type_{$type}', 'function_name', 10, 3 ); + * @example + * + */ + return apply_filters( 'um_render_field_type_' . $data['type'], '', $data, $this->form_data ); + } + + function render_field_label( $data ) { if ( empty( $data['label'] ) ) return false; diff --git a/includes/admin/core/class-admin-metabox.php b/includes/admin/core/class-admin-metabox.php index abeb7eba..83c57857 100644 --- a/includes/admin/core/class-admin-metabox.php +++ b/includes/admin/core/class-admin-metabox.php @@ -85,6 +85,26 @@ if ( ! class_exists( 'Admin_Metabox' ) ) { $post_types = UM()->options()->get( 'restricted_access_post_metabox' ); if ( ! empty( $post_types[ $current_screen->id ] ) ) { + /** + * UM hook + * + * @type filter + * @title um_restrict_content_hide_metabox + * @description Show/Hide Restrict content metabox + * @input_vars + * [{"var":"$show","type":"bool","desc":"Show Metabox"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_restrict_content_hide_metabox', 'function_name', 10, 1 ); + * @example + * + */ $hide_metabox = apply_filters( 'um_restrict_content_hide_metabox', false ); if ( ! $hide_metabox ) { @@ -195,6 +215,35 @@ if ( ! class_exists( 'Admin_Metabox' ) ) { function um_category_access_fields_create() { $data = array(); + /** + * UM hook + * + * @type filter + * @title um_admin_category_access_settings_fields + * @description Settings fields for terms + * @input_vars + * [{"var":"$access_settings_fields","type":"array","desc":"Settings Fields"}, + * {"var":"$data","type":"array","desc":"Settings Data"}, + * {"var":"$screen","type":"string","desc":"Category Screen"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_admin_category_access_settings_fields', 'function_name', 10, 3 ); + * @example + * 'my-field-key', + * 'type' => 'my-field-type', + * 'label' => __( 'My field Label', 'ultimate-member' ), + * 'description' => __( 'My Field Description', 'ultimate-member' ), + * 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0, + * ); + * return $access_settings_fields; + * } + * ?> + */ $fields = apply_filters( 'um_admin_category_access_settings_fields', array( array( 'id' => '_um_custom_access_settings', @@ -312,7 +361,35 @@ if ( ! class_exists( 'Admin_Metabox' ) ) { } } - + /** + * UM hook + * + * @type filter + * @title um_admin_category_access_settings_fields + * @description Settings fields for terms + * @input_vars + * [{"var":"$access_settings_fields","type":"array","desc":"Settings Fields"}, + * {"var":"$data","type":"array","desc":"Settings Data"}, + * {"var":"$screen","type":"string","desc":"Category Screen"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_admin_category_access_settings_fields', 'function_name', 10, 3 ); + * @example + * 'my-field-key', + * 'type' => 'my-field-type', + * 'label' => __( 'My field Label', 'ultimate-member' ), + * 'description' => __( 'My Field Description', 'ultimate-member' ), + * 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0, + * ); + * return $access_settings_fields; + * } + * ?> + */ $fields = apply_filters( 'um_admin_category_access_settings_fields', array( array( 'id' => '_um_custom_access_settings', @@ -649,6 +726,35 @@ if ( ! class_exists( 'Admin_Metabox' ) ) { ) ) ); + /** + * UM hook + * + * @type filter + * @title um_admin_role_metaboxes + * @description Extend metaboxes at Add/Edit User Role + * @input_vars + * [{"var":"$roles_metaboxes","type":"array","desc":"Metaboxes at Add/Edit UM Role"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_admin_role_metaboxes', 'function_name', 10, 1 ); + * @example + * 'um-admin-form-your-custom', + * 'title' => __( 'My Roles Metabox', 'ultimate-member' ), + * 'callback' => 'my-metabox-callback', + * 'screen' => 'um_role_meta', + * 'context' => 'side', + * 'priority' => 'default' + * ); + * + * return $roles_metaboxes; + * } + * ?> + */ $roles_metaboxes = apply_filters( 'um_admin_role_metaboxes', $roles_metaboxes ); $wp_caps_metabox = false; @@ -959,8 +1065,31 @@ if ( ! class_exists( 'Admin_Metabox' ) ) { builtin()->validation_types() as $key => $name ) { ?> + /** + * UM hook + * + * @type filter + * @title um_builtin_validation_types_continue_loop + * @description Builtin Validation Types + * @input_vars + * [{"var":"$continue","type":"bool","desc":"Validate?"}, + * {"var":"$key","type":"string","desc":"Field Key"}, + * {"var":"$form_id","type":"int","desc":"Form ID"}, + * {"var":"$field_args","type":"array","desc":"Field Settings"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_builtin_validation_types_continue_loop', 'function_name', 10, 4 ); + * @example + * + */ + $continue = apply_filters( "um_builtin_validation_types_continue_loop", true, $key, $form_id, $field_args ); + if ( $continue ) { ?> diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php index dfc9df22..e92e6c6c 100644 --- a/includes/admin/core/class-admin-settings.php +++ b/includes/admin/core/class-admin-settings.php @@ -73,7 +73,7 @@ if ( ! class_exists( 'Admin_Settings' ) ) { foreach ( $core_pages as $page_s => $page ) { $have_pages = UM()->query()->wp_pages(); - $page_id = apply_filters( 'um_core_page_id_filter', 'core_' . $page_s ); + $page_id = UM()->options()->get_core_page_id( $page_s ); $page_title = ! empty( $page['title'] ) ? $page['title'] : ''; @@ -188,6 +188,26 @@ if ( ! class_exists( 'Admin_Settings' ) ) { } } + /** + * UM hook + * + * @type filter + * @title um_settings_structure + * @description Extend UM Settings + * @input_vars + * [{"var":"$settings","type":"array","desc":"UM Settings"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_settings_structure', 'function_name', 10, 1 ); + * @example + * + */ $this->settings_structure = apply_filters( 'um_settings_structure', array( '' => array( 'title' => __( 'General', 'ultimate-member' ), @@ -1101,7 +1121,7 @@ if ( ! class_exists( 'Admin_Settings' ) ) { um_js_redirect( add_query_arg( array( 'page' => 'um_options', 'tab' => $current_tab ), admin_url( 'admin.php' ) ) ); } - echo '

Ultimate Member - Settings

'; + echo '

' . __( 'Ultimate Member - Settings', 'ultimate-member' ) . '

'; echo $this->generate_tabs_menu() . $this->generate_subtabs_menu( $current_tab ); @@ -1111,7 +1131,32 @@ if ( ! class_exists( 'Admin_Settings' ) ) { do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" ); $section_fields = $this->get_section_fields( $current_tab, $current_subtab ); - echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content', $this->render_settings_section( $section_fields, $current_tab, $current_subtab ), $section_fields ); + + /** + * UM hook + * + * @type filter + * @title um_settings_section_{$current_tab}_{$current_subtab}_content + * @description Render settings section + * @input_vars + * [{"var":"$content","type":"string","desc":"Section content"}, + * {"var":"$section_fields","type":"array","desc":"Section Fields"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 ); + * @example + * + */ + echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content', + $this->render_settings_section( $section_fields, $current_tab, $current_subtab ), + $section_fields + ); } else { ?> @@ -1129,7 +1174,32 @@ if ( ! class_exists( 'Admin_Settings' ) ) { get_section_fields( $current_tab, $current_subtab ); - echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content', $this->render_settings_section( $section_fields, $current_tab, $current_subtab ), $section_fields ); + + /** + * UM hook + * + * @type filter + * @title um_settings_section_{$current_tab}_{$current_subtab}_content + * @description Render settings section + * @input_vars + * [{"var":"$content","type":"string","desc":"Section content"}, + * {"var":"$section_fields","type":"array","desc":"Section Fields"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 ); + * @example + * + */ + echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content', + $this->render_settings_section( $section_fields, $current_tab, $current_subtab ), + $section_fields + ); ?>

@@ -1180,6 +1250,26 @@ if ( ! class_exists( 'Admin_Settings' ) ) { break; default: + /** + * UM hook + * + * @type filter + * @title um_generate_tabs_menu_{$page} + * @description Generate tabs menu + * @input_vars + * [{"var":"$tabs","type":"array","desc":"UM menu tabs"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_generate_tabs_menu_{$page}', 'function_name', 10, 1 ); + * @example + * + */ $tabs = apply_filters( 'um_generate_tabs_menu_' . $page, $tabs ); break; } @@ -1222,6 +1312,26 @@ if ( ! class_exists( 'Admin_Settings' ) ) { if ( isset( $_POST['um-settings-action'] ) && 'save' == $_POST['um-settings-action'] && ! empty( $_POST['um_options'] ) ) { do_action( "um_settings_before_save" ); + /** + * UM hook + * + * @type filter + * @title um_change_settings_before_save + * @description Change settings before save + * @input_vars + * [{"var":"$settings","type":"array","desc":"UM Settings on save"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_change_settings_before_save', 'function_name', 10, 1 ); + * @example + * + */ $settings = apply_filters( 'um_change_settings_before_save', $_POST['um_options'] ); foreach ( $settings as $key => $value ) { @@ -1473,6 +1583,27 @@ if ( ! class_exists( 'Admin_Settings' ) ) { $in_theme = UM()->mail()->template_in_theme( $email_key ); + /** + * UM hook + * + * @type filter + * @title um_admin_settings_email_section_fields + * @description Extend UM Email Settings + * @input_vars + * [{"var":"$settings","type":"array","desc":"UM Email Settings"}, + * {"var":"$email_key","type":"string","desc":"Email Key"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_admin_settings_email_section_fields', 'function_name', 10, 2 ); + * @example + * + */ $section_fields = apply_filters( 'um_admin_settings_email_section_fields', array( array( 'id' => 'um_email_template', diff --git a/includes/admin/core/class-admin-users.php b/includes/admin/core/class-admin-users.php index c9288e81..544dfb35 100644 --- a/includes/admin/core/class-admin-users.php +++ b/includes/admin/core/class-admin-users.php @@ -56,6 +56,29 @@ if ( ! class_exists( 'Admin_Users' ) ) { */ function get_bulk_admin_actions() { + /** + * UM hook + * + * @type filter + * @title um_admin_bulk_user_actions_hook + * @description Admin Users List Table bulk actions + * @input_vars + * [{"var":"$actions","type":"array","desc":"User List Table bulk actions"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_admin_bulk_user_actions_hook', 'function_name', 10, 1 ); + * @example + * 'My Custom Bulk Action' + * ); + * return $actions; + * } + * ?> + */ $actions = apply_filters( 'um_admin_bulk_user_actions_hook', array( 'um_approve_membership' => array( 'label' => __( 'Approve Membership', 'ultimate-member' ) @@ -101,6 +124,27 @@ if ( ! class_exists( 'Admin_Users' ) ) { if ( ! empty( $submitted ) ) $actions['view_info'] = '' . __( 'Info', 'ultimate-member' ) . ''; + /** + * UM hook + * + * @type filter + * @title um_admin_user_row_actions + * @description Admin views array + * @input_vars + * [{"var":"$actions","type":"array","desc":"User List Table actions"}, + * {"var":"$user_id","type":"int","desc":"User ID"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_admin_user_row_actions', 'function_name', 10, 2 ); + * @example + * + */ $actions = apply_filters( 'um_admin_user_row_actions', $actions, $user_id ); return $actions; @@ -202,6 +246,26 @@ if ( ! class_exists( 'Admin_Users' ) ) { $views[$k] = ''. $v . ' ('.UM()->query()->count_users_by_status( $k ).')'; } + /** + * UM hook + * + * @type filter + * @title um_admin_views_users + * @description Admin views array + * @input_vars + * [{"var":"$views","type":"array","desc":"User Views"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_admin_views_users', 'function_name', 10, 1 ); + * @example + * + */ $views = apply_filters( 'um_admin_views_users', $views ); // remove all filters diff --git a/includes/admin/core/list-tables/emails-list-table.php b/includes/admin/core/list-tables/emails-list-table.php index d0d2e350..015b1e5e 100644 --- a/includes/admin/core/list-tables/emails-list-table.php +++ b/includes/admin/core/list-tables/emails-list-table.php @@ -172,6 +172,27 @@ $ListTable = new UM_Emails_List_Table( array( $per_page = 20; $paged = $ListTable->get_pagenum(); +/** + * UM hook + * + * @type filter + * @title um_email_templates_columns + * @description Email Notifications List Table columns + * @input_vars + * [{"var":"$columns","type":"array","desc":"Columns"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_email_templates_columns', 'function_name', 10, 1 ); + * @example + * + */ $columns = apply_filters( 'um_email_templates_columns', array( 'email' => __( 'Email', 'ultimate-member' ), 'recipients' => __( 'Recipient(s)', 'ultimate-member' ), diff --git a/includes/admin/core/um-admin-filters-fields.php b/includes/admin/core/um-admin-filters-fields.php index 96e2c0e0..f3434a2c 100644 --- a/includes/admin/core/um-admin-filters-fields.php +++ b/includes/admin/core/um-admin-filters-fields.php @@ -41,11 +41,36 @@ if ( ! defined( 'ABSPATH' ) ) exit; *** @Some fields may require extra fields before saving ***/ add_filter('um_admin_pre_save_fields_hook', 'um_admin_pre_save_fields_hook', 1 ); - function um_admin_pre_save_fields_hook( $array ){ + function um_admin_pre_save_fields_hook( $array ) { extract( $array ); - $fields_without_metakey = array('block','shortcode','spacing','divider','group'); - $fields_without_metakey = apply_filters('um_fields_without_metakey', $fields_without_metakey ); + /** + * UM hook + * + * @type filter + * @title um_fields_without_metakey + * @description Field Types without meta key + * @input_vars + * [{"var":"$types","type":"array","desc":"Field Types"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_fields_without_metakey', 'function_name', 10, 1 ); + * @example + * + */ + $fields_without_metakey = apply_filters( 'um_fields_without_metakey', array( + 'block', + 'shortcode', + 'spacing', + 'divider', + 'group' + ) ); $fields = UM()->query()->get_attr('custom_fields', $form_id); $count = 1; diff --git a/includes/admin/templates/access/restrict_content.php b/includes/admin/templates/access/restrict_content.php index b8291ff6..34055e55 100644 --- a/includes/admin/templates/access/restrict_content.php +++ b/includes/admin/templates/access/restrict_content.php @@ -18,6 +18,27 @@ if ( ! defined( 'ABSPATH' ) ) exit; } } + /** + * UM hook + * + * @type filter + * @title um_admin_access_settings_fields + * @description Extend Admin Access Settings Fields + * @input_vars + * [{"var":"$fields","type":"array","desc":"Access Settings Fields"}, + * {"var":"$data","type":"array","desc":"Form Data"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_admin_access_settings_fields', 'function_name', 10, 2 ); + * @example + * + */ $fields = apply_filters( 'um_admin_access_settings_fields', array( array( 'id' => '_um_custom_access_settings', diff --git a/includes/admin/templates/directory/general.php b/includes/admin/templates/directory/general.php index 9bde9b62..db20f255 100644 --- a/includes/admin/templates/directory/general.php +++ b/includes/admin/templates/directory/general.php @@ -21,7 +21,39 @@ if ( $show_these_users ) {

- + */ + $sort_options = apply_filters( 'um_admin_directory_sort_users_select', array( + 'user_registered_desc' => __( 'New users first', 'ultimate-member' ), + 'user_registered_asc' => __( 'Old users first', 'ultimate-member' ), + 'last_login' => __( 'Last login', 'ultimate-member' ), + 'display_name' => __( 'Display Name', 'ultimate-member' ), + 'first_name' => __( 'First Name', 'ultimate-member' ), + 'last_name' => __( 'Last Name', 'ultimate-member' ), + 'random' => __( 'Random', 'ultimate-member' ), + 'other' => __( 'Other (custom field)', 'ultimate-member' ), + ) ); + + $fields = array( array( 'id' => '_um_mode', 'type' => 'hidden', @@ -54,16 +86,7 @@ if ( $show_these_users ) { 'type' => 'select', 'label' => __( 'Sort users by', 'ultimate-member' ), 'tooltip' => __( 'Sort users by a specific parameter in the directory', 'ultimate-member' ), - 'options' => apply_filters( 'um_admin_directory_sort_users_select', array( - 'user_registered_desc' => __( 'New users first', 'ultimate-member' ), - 'user_registered_asc' => __( 'Old users first', 'ultimate-member' ), - 'last_login' => __( 'Last login', 'ultimate-member' ), - 'display_name' => __( 'Display Name', 'ultimate-member' ), - 'first_name' => __( 'First Name', 'ultimate-member' ), - 'last_name' => __( 'Last Name', 'ultimate-member' ), - 'random' => __( 'Random', 'ultimate-member' ), - 'other' => __( 'Other (custom field)', 'ultimate-member' ), - ) ), + 'options' => $sort_options, 'value' => UM()->query()->get_meta_value( '_um_sortby' ), ), array( @@ -82,6 +105,26 @@ if ( $show_these_users ) { ) ); + /** + * UM hook + * + * @type filter + * @title um_admin_extend_directory_options_general + * @description Extend Directory options fields + * @input_vars + * [{"var":"$fields","type":"array","desc":"Directory options fields"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_admin_directory_sort_users_select', 'function_name', 10, 1 ); + * @example + * + */ $fields = apply_filters( 'um_admin_extend_directory_options_general', $fields ); UM()->admin_forms( array( diff --git a/includes/admin/templates/directory/search.php b/includes/admin/templates/directory/search.php index 0b85ca2a..fa33f47c 100644 --- a/includes/admin/templates/directory/search.php +++ b/includes/admin/templates/directory/search.php @@ -7,6 +7,27 @@ $can_search_array[] = $_um_roles_can_search; } + /** + * UM hook + * + * @type filter + * @title um_admin_custom_search_filters + * @description Custom Search Filters + * @input_vars + * [{"var":"$custom_search","type":"array","desc":"Filters"}] + * @change_log + * ["Since: 2.0"] + * @usage + * + * @example + * + */ $custom_search = apply_filters( 'um_admin_custom_search_filters', array() ); $searchable_fields = UM()->builtin()->all_user_fields('date,time,url'); $searchable_fields = $searchable_fields + $custom_search; diff --git a/includes/class-config.php b/includes/class-config.php index 50b3eec1..6a81643b 100644 --- a/includes/class-config.php +++ b/includes/class-config.php @@ -31,6 +31,29 @@ if ( ! class_exists( 'um\Config' ) ) { 'members', ); + + /** + * UM hook + * + * @type filter + * @title um_core_pages + * @description Extend UM core pages + * @input_vars + * [{"var":"$pages","type":"array","desc":"UM core pages"}] + * @change_log + * ["Since: 2.0"] + * @usage + * + * @example + * __( 'My Page Title', 'my-translate-key' ) ); + * return $pages; + * } + * ?> + */ $this->core_pages = apply_filters( 'um_core_pages', array( 'user' => array( 'title' => __( 'User', 'ultimate-member' ) ), 'login' => array( 'title' => __( 'Login', 'ultimate-member' ) ), @@ -84,6 +107,29 @@ if ( ! class_exists( 'um\Config' ) ) { '_um_secondary_color', ); + + /** + * UM hook + * + * @type filter + * @title um_core_form_meta_all + * @description Extend UM forms meta keys + * @input_vars + * [{"var":"$meta","type":"array","desc":"UM forms meta"}] + * @change_log + * ["Since: 2.0"] + * @usage + * + * @example + * + */ $this->core_form_meta_all = apply_filters( 'um_core_form_meta_all', array( '_um_profile_show_name' => 1, '_um_profile_show_social_links' => 0, @@ -152,6 +198,38 @@ if ( ! class_exists( 'um\Config' ) ) { '_um_profile_use_custom_settings' => 0, ); + + /** + * UM hook + * + * @type filter + * @title um_email_notifications + * @description Extend UM email notifications + * @input_vars + * [{"var":"$emails","type":"array","desc":"UM email notifications"}] + * @change_log + * ["Since: 2.0"] + * @usage + * + * @example + * 'my_email', + * 'title' => __( 'my_email_title','ultimate-member' ), + * 'subject' => 'my_email_subject', + * 'body' => 'my_email_body', + * 'description' => 'my_email_description', + * 'recipient' => 'user', // set 'admin' for make administrator as recipient + * 'default_active' => true // can be false for make disabled by default + * ); + * + * return $emails; + * } + * ?> + */ $this->email_notifications = apply_filters( 'um_email_notifications', array( 'welcome_email' => array( 'key' => 'welcome_email', @@ -384,16 +462,37 @@ if ( ! class_exists( 'um\Config' ) ) { $this->settings_defaults[$key] = $notification['body']; } - foreach ( $this->core_pages as $page_s => $page ) { - $page_id = apply_filters( 'um_core_page_id_filter', 'core_' . $page_s ); - $this->settings_defaults[$page_id] = ''; - } + foreach ( $this->core_pages as $page_s => $page ) { + $page_id = UM()->options()->get_core_page_id( $page_s ); + $this->settings_defaults[ $page_id ] = ''; + } foreach( $this->core_form_meta_all as $key => $value ) { $this->settings_defaults[ str_replace( '_um_', '', $key ) ] = $value; } + /** + * UM hook + * + * @type filter + * @title um_default_settings_values + * @description Extend UM default settings + * @input_vars + * [{"var":"$settings","type":"array","desc":"UM default settings"}] + * @change_log + * ["Since: 2.0"] + * @usage + * + * @example + * + */ $this->settings_defaults = apply_filters( 'um_default_settings_values', $this->settings_defaults ); $this->permalinks = $this->get_core_pages(); @@ -523,19 +622,19 @@ if ( ! class_exists( 'um\Config' ) ) { } - function get_core_pages() { - $permalink = array(); - $core_pages = array_keys( $this->core_pages ); - if ( empty( $core_pages ) ) - return $permalink; + function get_core_pages() { + $permalink = array(); + $core_pages = array_keys( $this->core_pages ); + if ( empty( $core_pages ) ) + return $permalink; - foreach ( $core_pages as $page_key ) { - $page_option_key = apply_filters( 'um_core_page_id_filter', 'core_' . $page_key ); - $permalink[$page_key] = UM()->options()->get( $page_option_key ); - } + foreach ( $core_pages as $page_key ) { + $page_option_key = UM()->options()->get_core_page_id( $page_key ); + $permalink[ $page_key ] = UM()->options()->get( $page_option_key ); + } - return $permalink; - } + return $permalink; + } //end class } } \ No newline at end of file diff --git a/includes/class-dependencies.php b/includes/class-dependencies.php index 1dfeb5b2..f2b4f552 100644 --- a/includes/class-dependencies.php +++ b/includes/class-dependencies.php @@ -30,13 +30,13 @@ if ( ! class_exists( 'um\Dependencies' ) ) { 'messaging' => '2.0.1', 'mycred' => '2.0', 'notices' => '2.0.1', - 'notifications' => '2.0', + 'notifications' => '2.0.1', 'online' => '2.0', 'private-content' => '2.0', 'profile-completeness' => '2.0.1', 'recaptcha' => '2.0', 'reviews' => '2.0.1', - 'social-activity' => '2.0', + 'social-activity' => '2.0.1', 'social-login' => '2.0.1', 'terms-conditions' => '2.0', 'user-location' => '2.0', diff --git a/includes/class-functions.php b/includes/class-functions.php index 9350e486..edb15b3c 100644 --- a/includes/class-functions.php +++ b/includes/class-functions.php @@ -142,6 +142,27 @@ if ( ! class_exists( 'UM_Functions' ) ) { 'post_format', ); + /** + * UM hook + * + * @type filter + * @title um_excluded_taxonomies + * @description Exclude taxonomies for UM + * @input_vars + * [{"var":"$taxes","type":"array","desc":"Taxonomies keys"}] + * @change_log + * ["Since: 2.0"] + * @usage + * + * @example + * + */ return apply_filters( 'um_excluded_taxonomies', $taxes ); } @@ -174,11 +195,81 @@ if ( ! class_exists( 'UM_Functions' ) ) { return; } + + /** + * UM hook + * + * @type filter + * @title um_get_template + * @description Change template location + * @input_vars + * [{"var":"$located","type":"string","desc":"template Located"}, + * {"var":"$template_name","type":"string","desc":"Template Name"}, + * {"var":"$path","type":"string","desc":"Template Path at server"}, + * {"var":"$t_args","type":"array","desc":"Template Arguments"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_get_template', 'function_name', 10, 4 ); + * @example + * + */ $located = apply_filters( 'um_get_template', $located, $template_name, $path, $t_args ); ob_start(); + + /** + * UM hook + * + * @type action + * @title um_before_template_part + * @description Make some action before include template file + * @input_vars + * [{"var":"$template_name","type":"string","desc":"Template Name"}, + * {"var":"$path","type":"string","desc":"Template Path at server"}, + * {"var":"$located","type":"string","desc":"template Located"}, + * {"var":"$t_args","type":"array","desc":"Template Arguments"}] + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_before_template_part', 'function_name', 10, 4 ); + * @example + * + */ do_action( 'um_before_template_part', $template_name, $path, $located, $t_args ); include( $located ); + + /** + * UM hook + * + * @type action + * @title my_after_template_part + * @description Make some action after include template file + * @input_vars + * [{"var":"$template_name","type":"string","desc":"Template Name"}, + * {"var":"$path","type":"string","desc":"Template Path at server"}, + * {"var":"$located","type":"string","desc":"template Located"}, + * {"var":"$t_args","type":"array","desc":"Template Arguments"}] + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_after_template_part', 'function_name', 10, 4 ); + * @example + * + */ do_action( 'um_after_template_part', $template_name, $path, $located, $t_args ); $html = ob_get_clean(); @@ -213,7 +304,30 @@ if ( ! class_exists( 'UM_Functions' ) ) { } $template .= 'templates/' . $template_name; } - // Return what we found. + + + /** + * UM hook + * + * @type filter + * @title um_locate_template + * @description Change template locate + * @input_vars + * [{"var":"$template","type":"string","desc":"Template locate"}, + * {"var":"$template_name","type":"string","desc":"Template Name"}, + * {"var":"$path","type":"string","desc":"Template Path at server"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_locate_template', 'function_name', 10, 3 ); + * @example + * + */ return apply_filters( 'um_locate_template', $template, $template_name, $path ); } diff --git a/includes/class-init.php b/includes/class-init.php index ecd6a035..f4f12cf0 100644 --- a/includes/class-init.php +++ b/includes/class-init.php @@ -89,8 +89,30 @@ if ( ! class_exists( 'UM' ) ) { */ public function __call( $name, array $params ) { - if ( empty( $this->classes[ $name ] ) ) - $this->classes[ $name ] = apply_filters( 'um_call_object_' . $name, false ); + if ( empty( $this->classes[ $name ] ) ) { + + /** + * UM hook + * + * @type filter + * @title um_call_object_{$class_name} + * @description Extend call classes of Extensions for use UM()->class_name()->method|function + * @input_vars + * [{"var":"$class","type":"object","desc":"Class Instance"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_call_object_{$class_name}', 'function_name', 10, 1 ); + * @example + * + */ + $this->classes[ $name ] = apply_filters( 'um_call_object_' . $name, false ); + } return $this->classes[ $name ]; @@ -172,13 +194,75 @@ if ( ! class_exists( 'UM' ) ) { 'ar' => 'العربية', ); + /** + * UM hook + * + * @type filter + * @title um_language_textdomain + * @description Change UM textdomain + * @input_vars + * [{"var":"$domain","type":"string","desc":"UM Textdomain"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_language_textdomain', 'function_name', 10, 1 ); + * @example + * + */ $language_domain = apply_filters( 'um_language_textdomain', 'ultimate-member' ); $language_locale = ( get_locale() != '' ) ? get_locale() : 'en_US'; + + /** + * UM hook + * + * @type filter + * @title um_language_locale + * @description Change UM language locale + * @input_vars + * [{"var":"$locale","type":"string","desc":"UM language locale"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_language_locale', 'function_name', 10, 1 ); + * @example + * + */ $language_locale = apply_filters( 'um_language_locale', $language_locale ); $language_file = WP_LANG_DIR . '/plugins/' . $language_domain . '-' . $language_locale . '.mo'; - $language_file = apply_filters( 'um_language_file', $language_file ); + + /** + * UM hook + * + * @type filter + * @title um_language_file + * @description Change UM language file path + * @input_vars + * [{"var":"$language_file","type":"string","desc":"UM language file path"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_language_file', 'function_name', 10, 1 ); + * @example + * + */ + $language_file = apply_filters( 'um_language_file', $language_file ); load_textdomain( $language_domain, $language_file ); diff --git a/includes/core/class-access.php b/includes/core/class-access.php index 2bf67eed..61cea339 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -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 + * + */ + 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 + * + */ $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 ) { diff --git a/includes/core/class-account.php b/includes/core/class-account.php index 72819848..4a3fb705 100644 --- a/includes/core/class-account.php +++ b/includes/core/class-account.php @@ -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 + * + */ 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 + * + */ $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 + * + */ + $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 + * + */ $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 + * + */ $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 + * + */ $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 + * + */ $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 + * + */ $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 + * + */ + $classes = apply_filters( 'um_form_official_classes__hook', $classes ); return $classes; } } diff --git a/includes/core/class-builtin.php b/includes/core/class-builtin.php index b1bf90f9..7c75af79 100644 --- a/includes/core/class-builtin.php +++ b/includes/core/class-builtin.php @@ -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 + * + */ + $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 + * + */ + $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 + * + */ + $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 + * + */ + $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 + * + */ + $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 + * + */ + $array = apply_filters( "um_{$data}_predefined_field_options", $array ); return $array; - } } diff --git a/includes/core/class-cron.php b/includes/core/class-cron.php index f0749dc7..c89175a8 100644 --- a/includes/core/class-cron.php +++ b/includes/core/class-cron.php @@ -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 + * + */ + $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' ); + } + } + + } } \ No newline at end of file diff --git a/includes/core/class-date-time.php b/includes/core/class-date-time.php index 4781fb6c..f53b0fa7 100644 --- a/includes/core/class-date-time.php +++ b/includes/core/class-date-time.php @@ -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 + * + */ + 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; + } + + } } \ No newline at end of file diff --git a/includes/core/class-enqueue.php b/includes/core/class-enqueue.php index 18a89ea4..de27c016 100644 --- a/includes/core/class-enqueue.php +++ b/includes/core/class-enqueue.php @@ -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 + * + */ + $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 + * + */ + $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'); + + } + + } } \ No newline at end of file diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index 29c9d67e..559d18f5 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -356,11 +356,72 @@ if ( ! class_exists( 'Fields' ) ) { $output .= '
'; } - if ($this->viewing == true) { + if ( $this->viewing == true ) { + /** + * UM hook + * + * @type filter + * @title um_view_label_{$key} + * @description Change field label on view by field $key + * @input_vars + * [{"var":"$label","type":"string","desc":"Field Label"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_view_label_{$key}', 'function_name', 10, 1 ); + * @example + * + */ $label = apply_filters( "um_view_label_{$key}", $label ); } else { + /** + * UM hook + * + * @type filter + * @title um_edit_label_{$key} + * @description Change field label on edit by field $key + * @input_vars + * [{"var":"$label","type":"string","desc":"Field Label"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_edit_label_{$key}', 'function_name', 10, 1 ); + * @example + * + */ $label = apply_filters( "um_edit_label_{$key}", $label ); - $label = apply_filters( "um_edit_label_all_fields", $label, $data ); + /** + * UM hook + * + * @type filter + * @title um_edit_label_all_fields + * @description Change field label on view by field $key + * @input_vars + * [{"var":"$label","type":"string","desc":"Field Label"}, + * {"var":"$data","type":"array","desc":"Field Data"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_edit_label_all_fields', 'function_name', 10, 2 ); + * @example + * + */ + $label = apply_filters( 'um_edit_label_all_fields', $label, $data ); } $output .= ''; @@ -455,44 +516,195 @@ if ( ! class_exists( 'Fields' ) ) { } // normal state - if (isset( UM()->form()->post_form[$key] )) { + if ( isset( UM()->form()->post_form[ $key ] ) ) { - if (strstr( $key, 'user_pass' ) && $this->set_mode != 'password') return ''; + if ( strstr( $key, 'user_pass' ) && $this->set_mode != 'password' ) { + return ''; + } return stripslashes_deep( UM()->form()->post_form[$key] ); - } else if (um_user( $key ) && $this->editing == true) { + } elseif ( um_user( $key ) && $this->editing == true ) { - if (strstr( $key, 'user_pass' )) return ''; + if ( strstr( $key, 'user_pass' ) ) { + return ''; + } $value = um_user( $key ); + /** + * UM hook + * + * @type filter + * @title um_edit_{$key}_field_value + * @description Change field value on edit by field $key + * @input_vars + * [{"var":"$value","type":"string","desc":"Field Value"}, + * {"var":"$key","type":"string","desc":"Field Key"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_edit_{$key}_field_value', 'function_name', 10, 2 ); + * @example + * + */ $value = apply_filters( "um_edit_{$key}_field_value", $value, $key ); + /** + * UM hook + * + * @type filter + * @title um_edit_{$type}_field_value + * @description Change field value on edit by field $type + * @input_vars + * [{"var":"$value","type":"string","desc":"Field Value"}, + * {"var":"$key","type":"string","desc":"Field Key"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_edit_{$type}_field_value', 'function_name', 10, 2 ); + * @example + * + */ $value = apply_filters( "um_edit_{$type}_field_value", $value, $key ); return $value; - } else if (( um_user( $key ) || isset( $data['show_anyway'] ) ) && $this->viewing == true) { + } elseif ( ( um_user( $key ) || isset( $data['show_anyway'] ) ) && $this->viewing == true ) { $value = um_filtered_value( $key, $data ); return $value; - } else if( isset( UM()->user()->profile[$key] ) ){ + } elseif ( isset( UM()->user()->profile[ $key ] ) ) { - $value = UM()->user()->profile[$key]; + $value = UM()->user()->profile[ $key ]; + /** + * UM hook + * + * @type filter + * @title um_edit_{$key}_field_value + * @description Change field value on edit by field $key + * @input_vars + * [{"var":"$value","type":"string","desc":"Field Value"}, + * {"var":"$key","type":"string","desc":"Field Key"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_edit_{$key}_field_value', 'function_name', 10, 2 ); + * @example + * + */ $value = apply_filters( "um_edit_{$key}_field_value", $value, $key ); return $value; - } else if ($default) { + } elseif ( $default ) { + /** + * UM hook + * + * @type filter + * @title um_field_default_value + * @description Change field default value + * @input_vars + * [{"var":"$default","type":"string","desc":"Field Default Value"}, + * {"var":"$data","type":"array","desc":"Field Data"}, + * {"var":"$type","type":"string","desc":"Field Type"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_field_default_value', 'function_name', 10, 2 ); + * @example + * + */ $default = apply_filters( "um_field_default_value", $default, $data, $type ); + /** + * UM hook + * + * @type filter + * @title um_field_{$key}_default_value + * @description Change field default value by $key + * @input_vars + * [{"var":"$default","type":"string","desc":"Field Default Value"}, + * {"var":"$data","type":"array","desc":"Field Data"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_field_{$key}_default_value', 'function_name', 10, 2 ); + * @example + * + */ $default = apply_filters( "um_field_{$key}_default_value", $default, $data ); + /** + * UM hook + * + * @type filter + * @title um_field_{$type}_default_value + * @description Change field default value by $type + * @input_vars + * [{"var":"$default","type":"string","desc":"Field Default Value"}, + * {"var":"$data","type":"array","desc":"Field Data"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_field_{$type}_default_value', 'function_name', 10, 2 ); + * @example + * + */ $default = apply_filters( "um_field_{$type}_default_value", $default, $data ); - return $default; - } else if ($this->editing == true) { + } elseif ( $this->editing == true ) { + /** + * UM hook + * + * @type filter + * @title um_edit_{$key}_field_value + * @description Change field value on edit by field $key + * @input_vars + * [{"var":"$value","type":"string","desc":"Field Value"}, + * {"var":"$key","type":"string","desc":"Field Key"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_edit_{$key}_field_value', 'function_name', 10, 2 ); + * @example + * + */ return apply_filters( "um_edit_{$key}_field_value", '', $key ); } @@ -511,15 +723,35 @@ if ( ! class_exists( 'Fields' ) ) { * @return boolean */ function is_selected( $key, $value, $data ) { + /** + * UM hook + * + * @type filter + * @title um_is_selected_filter_key + * @description Change is selected filter key + * @input_vars + * [{"var":"$key","type":"string","desc":"Selected filter key"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_is_selected_filter_key', 'function_name', 10, 1 ); + * @example + * + */ $key = apply_filters( 'um_is_selected_filter_key', $key ); - if (isset( UM()->form()->post_form[$key] ) && is_array( UM()->form()->post_form[$key] )) { + if ( isset( UM()->form()->post_form[ $key ] ) && is_array( UM()->form()->post_form[ $key ] ) ) { - if (in_array( $value, UM()->form()->post_form[$key] )) { + if ( in_array( $value, UM()->form()->post_form[ $key ] ) ) { return true; } - if (in_array( html_entity_decode( $value ), UM()->form()->post_form[$key] )) { + if ( in_array( html_entity_decode( $value ), UM()->form()->post_form[ $key ] ) ) { return true; } @@ -541,7 +773,50 @@ if ( ! class_exists( 'Fields' ) ) { } + /** + * UM hook + * + * @type filter + * @title um_is_selected_filter_value + * @description Change is selected filter value + * @input_vars + * [{"var":"$value","type":"string","desc":"Selected filter value"}, + * {"var":"$key","type":"string","desc":"Selected filter key"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_is_selected_filter_value', 'function_name', 10, 2 ); + * @example + * + */ $field_value = apply_filters( 'um_is_selected_filter_value', $field_value, $key ); + /** + * UM hook + * + * @type filter + * @title um_is_selected_filter_data + * @description Change is selected filter data + * @input_vars + * [{"var":"$data","type":"array","desc":"Selected filter value"}, + * {"var":"$key","type":"string","desc":"Selected filter key"}, + * {"var":"$value","type":"string","desc":"Selected filter value"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_is_selected_filter_data', 'function_name', 10, 3 ); + * @example + * + */ $data = apply_filters( 'um_is_selected_filter_data', $data, $key, $field_value ); if ($field_value && $this->editing == true && is_array( $field_value ) && ( in_array( $value, $field_value ) || in_array( html_entity_decode( $value ), $field_value ) )) { @@ -796,9 +1071,27 @@ if ( ! class_exists( 'Fields' ) ) { * @return array */ function get_fields() { - $this->fields = array(); - $this->fields = apply_filters( "um_get_form_fields", $this->fields ); - + /** + * UM hook + * + * @type filter + * @title um_get_form_fields + * @description Extend form fields + * @input_vars + * [{"var":"$fields","type":"array","desc":"Selected filter value"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_get_form_fields', 'function_name', 10, 1 ); + * @example + * + */ + $this->fields = apply_filters( 'um_get_form_fields', array() ); return $this->fields; } @@ -1122,12 +1415,57 @@ if ( ! class_exists( 'Fields' ) ) { if (!isset( $array['visibility'] )) $array['visibility'] = 'all'; + /** + * UM hook + * + * @type filter + * @title um_get_field__{$key} + * @description Extend field data by field $key + * @input_vars + * [{"var":"$data","type":"array","desc":"Field Data"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_get_field__{$key}', 'function_name', 10, 1 ); + * @example + * + */ $array = apply_filters( "um_get_field__{$key}", $array ); - return $array; } + + function filter_field_non_utf8_value( $option_value ) { + /** + * UM hook + * + * @type filter + * @title um_field_non_utf8_value + * @description Change dropdown option text + * @input_vars + * [{"var":"$value","type":"string","desc":"Option Value"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_field_non_utf8_value', 'function_name', 10, 1 ); + * @example + * + */ + return apply_filters( 'um_field_non_utf8_value', $option_value ); + } + + /** * Gets a field in 'input mode' * @@ -1223,14 +1561,56 @@ if ( ! class_exists( 'Fields' ) ) { } } + /** + * UM hook + * + * @type filter + * @title um_hook_for_field_{$type} + * @description Change field type + * @input_vars + * [{"var":"$type","type":"string","desc":"Field Type"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_hook_for_field_{$type}', 'function_name', 10, 1 ); + * @example + * + */ $type = apply_filters( "um_hook_for_field_{$type}", $type ); /* Begin by field type */ - switch ($type) { + switch ( $type ) { /* Default: Integration */ default: $mode = ( isset( $this->set_mode ) ) ? $this->set_mode : 'no_mode'; + + /** + * UM hook + * + * @type filter + * @title um_edit_field_{$mode}_{$type} + * @description Change field html by $mode and field $type + * @input_vars + * [{"var":"$output","type":"string","desc":"Field HTML"}, + * {"var":"$data","type":"array","desc":"Field Data"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_edit_field_{$mode}_{$type}', 'function_name', 10, 2 ); + * @example + * + */ $output .= apply_filters( "um_edit_field_{$mode}_{$type}", $output, $data ); break; @@ -1593,6 +1973,26 @@ if ( ! class_exists( 'Fields' ) ) { $textarea_settings['tinymce']['readonly'] = true; } + /** + * UM hook + * + * @type filter + * @title um_form_fields_textarea_settings + * @description Change WP Editor options for textarea init + * @input_vars + * [{"var":"$textarea_settings","type":"array","desc":"WP Editor settings"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_form_fields_textarea_settings', 'function_name', 10, 1 ); + * @example + * + */ $textarea_settings = apply_filters( 'um_form_fields_textarea_settings', $textarea_settings ); // turn on the output buffer @@ -1864,6 +2264,27 @@ if ( ! class_exists( 'Fields' ) ) { $has_parent_option = true; + /** + * UM hook + * + * @type filter + * @title um_custom_dropdown_options_parent__{$form_key} + * @description Change parent dropdown relationship by $form_key + * @input_vars + * [{"var":"$parent","type":"string","desc":"Parent dropdown relationship"}, + * {"var":"$data","type":"array","desc":"Field Data"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_custom_dropdown_options_parent__{$form_key}', 'function_name', 10, 2 ); + * @example + * + */ $parent_dropdown_relationship = apply_filters( "um_custom_dropdown_options_parent__{$form_key}", $data['parent_dropdown_relationship'], $data ); $atts_ajax .= " data-um-parent='{$parent_dropdown_relationship}' "; @@ -1882,18 +2303,79 @@ if ( ! class_exists( 'Fields' ) ) { if (!empty( $data['custom_dropdown_options_source'] )) { + /** + * UM hook + * + * @type filter + * @title um_custom_dropdown_options_source__{$form_key} + * @description Change custom dropdown options source by $form_key + * @input_vars + * [{"var":"$source","type":"string","desc":"Dropdown options source"}, + * {"var":"$data","type":"array","desc":"Field Data"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_custom_dropdown_options_source__{$form_key}', 'function_name', 10, 2 ); + * @example + * + */ $ajax_source = apply_filters( "um_custom_dropdown_options_source__{$form_key}", $data['custom_dropdown_options_source'], $data ); $atts_ajax .= " data-um-ajax-source='{$ajax_source}' "; + /** + * UM hook + * + * @type filter + * @title um_custom_dropdown_options_source_url__{$form_key} + * @description Change custom dropdown options source URL by $form_key + * @input_vars + * [{"var":"$url","type":"string","desc":"Dropdown options source URL"}, + * {"var":"$data","type":"array","desc":"Field Data"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_custom_dropdown_options_source_url__{$form_key}', 'function_name', 10, 2 ); + * @example + * + */ $ajax_source_url = apply_filters( "um_custom_dropdown_options_source_url__{$form_key}", admin_url( 'admin-ajax.php' ), $data ); $atts_ajax .= " data-um-ajax-url='{$ajax_source_url}' "; - } $output .= ''; - if (isset( $options ) && $options == 'builtin') { + if ( isset( $options ) && $options == 'builtin' ) { $options = UM()->builtin()->get( $filter ); } - if (!isset( $options )) { + if ( ! isset( $options ) ) { $options = UM()->builtin()->get( 'countries' ); } - if (isset( $options )) { + if ( isset( $options ) ) { + /** + * UM hook + * + * @type filter + * @title um_multiselect_options + * @description Extend multiselect options + * @input_vars + * [{"var":"$options","type":"array","desc":"Multiselect Options"}, + * {"var":"$data","type":"array","desc":"Field Data"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_multiselect_options', 'function_name', 10, 2 ); + * @example + * + */ $options = apply_filters( 'um_multiselect_options', $options, $data ); + /** + * UM hook + * + * @type filter + * @title um_multiselect_options_{$key} + * @description Extend multiselect options by field $key + * @input_vars + * [{"var":"$options","type":"array","desc":"Multiselect Options"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_multiselect_options_{$key}', 'function_name', 10, 1 ); + * @example + * + */ $options = apply_filters( "um_multiselect_options_{$key}", $options ); + /** + * UM hook + * + * @type filter + * @title um_multiselect_options_{$type} + * @description Extend multiselect options by field $type + * @input_vars + * [{"var":"$options","type":"array","desc":"Multiselect Options"}, + * {"var":"$data","type":"array","desc":"Field Data"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_multiselect_options_{$type}', 'function_name', 10, 2 ); + * @example + * + */ $options = apply_filters( "um_multiselect_options_{$data['type']}", $options, $data ); } // switch options pair for custom options from a callback function - if (isset( $data['custom_dropdown_options_source'] ) && !empty( $data['custom_dropdown_options_source'] )) { + if ( ! empty( $data['custom_dropdown_options_source'] ) ) { $use_keyword = true; } @@ -2043,7 +2649,7 @@ if ( ! class_exists( 'Fields' ) ) { $opt_value = $k; } - $opt_value = apply_filters( 'um_field_non_utf8_value', $opt_value ); + $opt_value = $this->filter_field_non_utf8_value( $opt_value ); $output .= '