diff --git a/includes/admin/core/class-admin-forms-settings.php b/includes/admin/core/class-admin-forms-settings.php index 18db32e0..13143d93 100644 --- a/includes/admin/core/class-admin-forms-settings.php +++ b/includes/admin/core/class-admin-forms-settings.php @@ -22,23 +22,24 @@ if ( ! class_exists( 'Admin_Forms_Settings' ) ) { * Get field value * * @param array $field_data + * @param string $i * @return string|array */ - function get_field_value( $field_data ) { - $default = isset( $field_data['default'] ) ? $field_data['default'] : UM()->options()->get_default( $field_data['id'] ); + function get_field_value( $field_data, $i = '' ) { + $default = isset( $field_data['default' . $i] ) ? $field_data['default' . $i] : UM()->options()->get_default( $field_data['id' . $i] ); if ( $field_data['type'] == 'checkbox' || $field_data['type'] == 'multi_checkbox' ) { - if ( isset( $field_data['value'] ) ) { - return $field_data['value']; + if ( isset( $field_data['value' . $i] ) ) { + return $field_data['value' . $i]; } else { - $value = UM()->options()->get( $field_data['id'] ); + $value = UM()->options()->get( $field_data['id' . $i] ); return '' !== $value ? $value : $default; } } else { - if ( isset( $field_data['value'] ) ) { - return $field_data['value']; + if ( isset( $field_data['value' . $i] ) ) { + return $field_data['value'. $i]; } else { - $value = UM()->options()->get( $field_data['id'] ); + $value = UM()->options()->get( $field_data['id' . $i] ); return isset( $value ) ? $value : $default; } } diff --git a/includes/admin/core/class-admin-forms.php b/includes/admin/core/class-admin-forms.php index 7221e616..20b06b77 100644 --- a/includes/admin/core/class-admin-forms.php +++ b/includes/admin/core/class-admin-forms.php @@ -468,8 +468,8 @@ if ( ! class_exists( 'Admin_Forms' ) ) { $name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name; $name_attr = ' name="' . $name . '" '; - $default = isset( $field_data['default'. $i] ) ? $field_data['default'. $i] : ''; - $value = isset( $field_data['value'. $i] ) ? $field_data['value'. $i] : $default; + $value = $this->get_field_value( $field_data, $i ); + $value_attr = ' value="' . $value . '" '; $fields[$i] = ""; @@ -976,16 +976,17 @@ if ( ! class_exists( 'Admin_Forms' ) ) { * Get field value * * @param array $field_data + * @param string $i * @return string|array */ - function get_field_value( $field_data ) { + function get_field_value( $field_data, $i = '' ) { $default = ( $field_data['type'] == 'multi_checkbox' ) ? array() : ''; - $default = isset( $field_data['default'] ) ? $field_data['default'] : $default; + $default = isset( $field_data['default' . $i] ) ? $field_data['default' . $i] : $default; if ( $field_data['type'] == 'checkbox' || $field_data['type'] == 'multi_checkbox' ) { - return ( isset( $field_data['value'] ) && '' !== $field_data['value'] ) ? $field_data['value'] : $default; + return ( isset( $field_data['value' . $i] ) && '' !== $field_data['value' . $i] ) ? $field_data['value' . $i] : $default; } else { - return isset( $field_data['value'] ) ? $field_data['value'] : $default; + return isset( $field_data['value' . $i] ) ? $field_data['value' . $i] : $default; } } } diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php index c50d33f2..3742ca08 100644 --- a/includes/admin/core/class-admin-settings.php +++ b/includes/admin/core/class-admin-settings.php @@ -489,7 +489,7 @@ if ( ! class_exists( 'Admin_Settings' ) ) { 'options' => $all_post_types, 'columns' => 3, 'value' => $restricted_access_post_metabox_value, - 'default' => UM()->um_get_default( 'restricted_access_post_metabox' ), + 'default' => UM()->options()->get_default( 'restricted_access_post_metabox' ), ), array( 'id' => 'restricted_access_taxonomy_metabox', @@ -499,7 +499,7 @@ if ( ! class_exists( 'Admin_Settings' ) ) { 'options' => $all_taxonomies, 'columns' => 3, 'value' => $restricted_access_taxonomy_metabox_value, - 'default' => UM()->um_get_default( 'restricted_access_taxonomy_metabox' ), + 'default' => UM()->options()->get_default( 'restricted_access_taxonomy_metabox' ), ), ) ), @@ -1206,7 +1206,7 @@ if ( ! class_exists( 'Admin_Settings' ) ) { $settings = apply_filters( 'um_change_settings_before_save', $_POST['um_options'] ); foreach ( $settings as $key => $value ) { - um_update_option( $key, $value ); + UM()->options()->update( $key, $value ); } do_action( "um_settings_save" ); diff --git a/includes/admin/core/packages/2.0-beta1.php b/includes/admin/core/packages/2.0-beta1.php index 757ea5db..59fc6b2b 100644 --- a/includes/admin/core/packages/2.0-beta1.php +++ b/includes/admin/core/packages/2.0-beta1.php @@ -877,35 +877,35 @@ fwrite( $css_doc_file, $css ); fclose( $css_doc_file ); //remove old options -um_remove_option( 'active_color' ); -um_remove_option( 'secondary_color' ); -um_remove_option( 'profile_align' ); -um_remove_option( 'register_align' ); -um_remove_option( 'login_align' ); -um_remove_option( 'primary_btn_color' ); -um_remove_option( 'primary_btn_hover' ); -um_remove_option( 'primary_btn_text' ); -um_remove_option( 'secondary_btn_color' ); -um_remove_option( 'secondary_btn_hover' ); -um_remove_option( 'secondary_btn_text' ); -um_remove_option( 'help_tip_color' ); -um_remove_option( 'form_field_label' ); -um_remove_option( 'form_border' ); -um_remove_option( 'form_border_hover' ); -um_remove_option( 'form_bg_color' ); -um_remove_option( 'form_bg_color_focus' ); -um_remove_option( 'form_text_color' ); -um_remove_option( 'form_placeholder' ); -um_remove_option( 'form_icon_color' ); -um_remove_option( 'form_asterisk_color' ); -um_remove_option( 'profile_photocorner' ); -um_remove_option( 'profile_main_bg' ); -um_remove_option( 'profile_header_bg' ); -um_remove_option( 'profile_header_text' ); -um_remove_option( 'profile_header_link_color' ); -um_remove_option( 'profile_header_link_hcolor' ); -um_remove_option( 'profile_header_icon_color' ); -um_remove_option( 'profile_header_icon_hcolor' ); +UM()->options()->remove( 'active_color' ); +UM()->options()->remove( 'secondary_color' ); +UM()->options()->remove( 'profile_align' ); +UM()->options()->remove( 'register_align' ); +UM()->options()->remove( 'login_align' ); +UM()->options()->remove( 'primary_btn_color' ); +UM()->options()->remove( 'primary_btn_hover' ); +UM()->options()->remove( 'primary_btn_text' ); +UM()->options()->remove( 'secondary_btn_color' ); +UM()->options()->remove( 'secondary_btn_hover' ); +UM()->options()->remove( 'secondary_btn_text' ); +UM()->options()->remove( 'help_tip_color' ); +UM()->options()->remove( 'form_field_label' ); +UM()->options()->remove( 'form_border' ); +UM()->options()->remove( 'form_border_hover' ); +UM()->options()->remove( 'form_bg_color' ); +UM()->options()->remove( 'form_bg_color_focus' ); +UM()->options()->remove( 'form_text_color' ); +UM()->options()->remove( 'form_placeholder' ); +UM()->options()->remove( 'form_icon_color' ); +UM()->options()->remove( 'form_asterisk_color' ); +UM()->options()->remove( 'profile_photocorner' ); +UM()->options()->remove( 'profile_main_bg' ); +UM()->options()->remove( 'profile_header_bg' ); +UM()->options()->remove( 'profile_header_text' ); +UM()->options()->remove( 'profile_header_link_color' ); +UM()->options()->remove( 'profile_header_link_hcolor' ); +UM()->options()->remove( 'profile_header_icon_color' ); +UM()->options()->remove( 'profile_header_icon_hcolor' ); //remove duplicates for UM Pages settings delete_option( 'um_core_pages' ); @@ -1042,8 +1042,8 @@ foreach ( $all_taxonomies as $key => $value ) { $all_taxonomies[ $key ] = true; } -um_update_option( 'restricted_access_post_metabox', $all_post_types ); -um_update_option( 'restricted_access_taxonomy_metabox', $all_taxonomies ); +UM()->options()->update( 'restricted_access_post_metabox', $all_post_types ); +UM()->options()->update( 'restricted_access_taxonomy_metabox', $all_taxonomies ); $roles_array = UM()->roles()->get_roles( false, array( 'administrator' ) ); @@ -1279,7 +1279,7 @@ if ( ! empty( $profile_tab_main_roles ) ) { return 'um_' . $item; }, $profile_tab_main_roles ); - um_update_option( 'profile_tab_main_roles', $profile_tab_main_roles ); + UM()->options()->update( 'profile_tab_main_roles', $profile_tab_main_roles ); } $profile_tab_posts_roles = UM()->options()->get( 'profile_tab_posts_roles' ); @@ -1289,7 +1289,7 @@ if ( ! empty( $profile_tab_posts_roles ) ) { return 'um_' . $item; }, $profile_tab_posts_roles ); - um_update_option( 'profile_tab_posts_roles', $profile_tab_posts_roles ); + UM()->options()->update( 'profile_tab_posts_roles', $profile_tab_posts_roles ); } $profile_tab_comments_roles = UM()->options()->get( 'profile_tab_comments_roles' ); @@ -1299,7 +1299,7 @@ if ( ! empty( $profile_tab_comments_roles ) ) { return 'um_' . $item; }, $profile_tab_comments_roles ); - um_update_option( 'profile_tab_comments_roles', $profile_tab_comments_roles ); + UM()->options()->update( 'profile_tab_comments_roles', $profile_tab_comments_roles ); } $profile_tab_activity_roles = UM()->options()->get( 'profile_tab_activity_roles' ); @@ -1309,7 +1309,7 @@ if ( ! empty( $profile_tab_activity_roles ) ) { return 'um_' . $item; }, $profile_tab_activity_roles ); - um_update_option( 'profile_tab_activity_roles', $profile_tab_activity_roles ); + UM()->options()->update( 'profile_tab_activity_roles', $profile_tab_activity_roles ); } $profile_tab_messages_roles = UM()->options()->get( 'profile_tab_messages_roles' ); @@ -1319,7 +1319,7 @@ if ( ! empty( $profile_tab_messages_roles ) ) { return 'um_' . $item; }, $profile_tab_messages_roles ); - um_update_option( 'profile_tab_messages_roles', $profile_tab_messages_roles ); + UM()->options()->update( 'profile_tab_messages_roles', $profile_tab_messages_roles ); } $profile_tab_reviews_roles = UM()->options()->get( 'profile_tab_reviews_roles' ); @@ -1329,7 +1329,7 @@ if ( ! empty( $profile_tab_reviews_roles ) ) { return 'um_' . $item; }, $profile_tab_reviews_roles ); - um_update_option( 'profile_tab_reviews_roles', $profile_tab_reviews_roles ); + UM()->options()->update( 'profile_tab_reviews_roles', $profile_tab_reviews_roles ); } $profile_tab_purchases_roles = UM()->options()->get( 'profile_tab_purchases_roles' ); @@ -1339,7 +1339,7 @@ if ( ! empty( $profile_tab_purchases_roles ) ) { return 'um_' . $item; }, $profile_tab_purchases_roles ); - um_update_option( 'profile_tab_purchases_roles', $profile_tab_purchases_roles ); + UM()->options()->update( 'profile_tab_purchases_roles', $profile_tab_purchases_roles ); } $profile_tab_product_reviews = UM()->options()->get( 'profile_tab_product-reviews_roles' ); @@ -1349,7 +1349,7 @@ if ( ! empty( $profile_tab_product_reviews ) ) { return 'um_' . $item; }, $profile_tab_product_reviews ); - um_update_option( 'profile_tab_product-reviews_roles', $profile_tab_product_reviews ); + UM()->options()->update( 'profile_tab_product-reviews_roles', $profile_tab_product_reviews ); } @@ -1360,7 +1360,7 @@ if ( ! empty( $profile_tab_forums_roles ) ) { return 'um_' . $item; }, $profile_tab_forums_roles ); - um_update_option( 'profile_tab_forums_roles', $profile_tab_forums_roles ); + UM()->options()->update( 'profile_tab_forums_roles', $profile_tab_forums_roles ); } $profile_tab_friends_roles = UM()->options()->get( 'profile_tab_friends_roles' ); @@ -1370,20 +1370,20 @@ if ( ! empty( $profile_tab_friends_roles ) ) { return 'um_' . $item; }, $profile_tab_friends_roles ); - um_update_option( 'profile_tab_friends_roles', $profile_tab_friends_roles ); + UM()->options()->update( 'profile_tab_friends_roles', $profile_tab_friends_roles ); } $register_role = UM()->options()->get( 'register_role' ); if ( ! empty( $register_role ) ) { $register_role = 'um_' . $register_role; - um_update_option( 'register_role', $register_role ); + UM()->options()->update( 'register_role', $register_role ); } $woo_oncomplete_role = UM()->options()->get( 'woo_oncomplete_role' ); if ( ! empty( $woo_oncomplete_role ) ) { $woo_oncomplete_role = 'um_' . $woo_oncomplete_role; - um_update_option( 'woo_oncomplete_role', $woo_oncomplete_role ); + UM()->options()->update( 'woo_oncomplete_role', $woo_oncomplete_role ); } $woo_oncomplete_except_roles = UM()->options()->get( 'woo_oncomplete_except_roles' ); @@ -1393,7 +1393,7 @@ if ( ! empty( $woo_oncomplete_except_roles ) ) { return 'um_' . $item; }, $woo_oncomplete_except_roles ); - um_update_option( 'woo_oncomplete_except_roles', $woo_oncomplete_except_roles ); + UM()->options()->update( 'woo_oncomplete_except_roles', $woo_oncomplete_except_roles ); } //for metadata for all bbPress forums diff --git a/includes/admin/core/um-admin-actions.php b/includes/admin/core/um-admin-actions.php index 6ca9c99e..f922303b 100644 --- a/includes/admin/core/um-admin-actions.php +++ b/includes/admin/core/um-admin-actions.php @@ -160,8 +160,8 @@ add_action('um_admin_do_action__opt_into_tracking', 'um_admin_do_action__opt_into_tracking'); function um_admin_do_action__opt_into_tracking( $action ) { if ( !is_admin() || !current_user_can('manage_options') ) die(); - - um_update_option( 'um_allow_tracking', 1 ); + + UM()->options()->update( 'um_allow_tracking', 1 ); update_option( 'um_tracking_notice', 1 ); $tracking = new um\core\Tracking(); @@ -176,8 +176,8 @@ add_action('um_admin_do_action__opt_out_of_tracking', 'um_admin_do_action__opt_out_of_tracking'); function um_admin_do_action__opt_out_of_tracking( $action ){ if ( !is_admin() || !current_user_can('manage_options') ) die(); - - um_update_option( 'um_allow_tracking', 0 ); + + UM()->options()->update( 'um_allow_tracking', 0 ); update_option('um_tracking_notice', 1 ); exit( wp_redirect( remove_query_arg('um_adm_action') ) ); diff --git a/includes/admin/templates/directory/appearance.php b/includes/admin/templates/directory/appearance.php index 2b8153fe..385747e5 100644 --- a/includes/admin/templates/directory/appearance.php +++ b/includes/admin/templates/directory/appearance.php @@ -8,7 +8,7 @@ 'id' => '_um_directory_template', 'type' => 'select', 'label' => __( 'Template', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_directory_template', null, um_get_option( 'directory_template' ) ), + 'value' => UM()->query()->get_meta_value( '_um_directory_template', null, UM()->options()->get( 'directory_template' ) ), 'options' => UM()->shortcodes()->get_templates( 'members' ), ) ) diff --git a/includes/admin/templates/form/login_customize.php b/includes/admin/templates/form/login_customize.php index 85a17556..a4ed6046 100644 --- a/includes/admin/templates/form/login_customize.php +++ b/includes/admin/templates/form/login_customize.php @@ -18,7 +18,7 @@ 'id' => '_um_login_template', 'type' => 'select', 'label' => __( 'Template', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_login_template', null, um_get_option( 'login_template' ) ), + 'value' => UM()->query()->get_meta_value( '_um_login_template', null, UM()->options()->get( 'login_template' ) ), 'options' => UM()->shortcodes()->get_templates( 'login' ), 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ) ), @@ -27,7 +27,7 @@ 'type' => 'text', 'label' => __( 'Max. Width (px)', 'ultimate-member' ), 'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value('_um_login_max_width', null, um_get_option( 'login_max_width' ) ), + 'value' => UM()->query()->get_meta_value('_um_login_max_width', null, UM()->options()->get( 'login_max_width' ) ), 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ) ), array( @@ -35,7 +35,7 @@ 'type' => 'select', 'label' => __( 'Field Icons', 'ultimate-member' ), 'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_login_icons', null, um_get_option( 'login_icons' ) ) , + 'value' => UM()->query()->get_meta_value( '_um_login_icons', null, UM()->options()->get( 'login_icons' ) ) , 'options' => array( 'field' => __( 'Show inside text field', 'ultimate-member' ), 'label' => __( 'Show with label', 'ultimate-member' ), @@ -48,14 +48,14 @@ 'type' => 'text', 'label' => __( 'Primary Button Text', 'ultimate-member' ), 'tooltip' => __( 'Customize the button text', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_login_primary_btn_word', null, um_get_option( 'login_primary_btn_word' ) ), + 'value' => UM()->query()->get_meta_value( '_um_login_primary_btn_word', null, UM()->options()->get( 'login_primary_btn_word' ) ), 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ) ), array( 'id' => '_um_login_secondary_btn', 'type' => 'select', 'label' => __( 'Show Secondary Button', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_login_secondary_btn', null, um_get_option( 'login_secondary_btn' ) ), + 'value' => UM()->query()->get_meta_value( '_um_login_secondary_btn', null, UM()->options()->get( 'login_secondary_btn' ) ), 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ), 'options' => array( 0 => __( 'No', 'ultimate-member' ), @@ -67,14 +67,14 @@ 'type' => 'text', 'label' => __( 'Primary Button Text', 'ultimate-member' ), 'tooltip' => __( 'Customize the button text', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_login_secondary_btn_word', null, um_get_option( 'login_secondary_btn_word' ) ), + 'value' => UM()->query()->get_meta_value( '_um_login_secondary_btn_word', null, UM()->options()->get( 'login_secondary_btn_word' ) ), 'conditional' => array( '_um_login_secondary_btn', '=', 1 ) ), array( 'id' => '_um_login_forgot_pass_link', 'type' => 'select', 'label' => __( 'Show Forgot Password Link?', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_login_forgot_pass_link', null, um_get_option('login_forgot_pass_link') ), + 'value' => UM()->query()->get_meta_value( '_um_login_forgot_pass_link', null, UM()->options()->get('login_forgot_pass_link') ), 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ), 'options' => array( 0 => __( 'No', 'ultimate-member' ), @@ -85,7 +85,7 @@ 'id' => '_um_login_show_rememberme', 'type' => 'select', 'label' => __( 'Show "Remember Me"?', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_login_show_rememberme', null, um_get_option('login_show_rememberme') ), + 'value' => UM()->query()->get_meta_value( '_um_login_show_rememberme', null, UM()->options()->get('login_show_rememberme') ), 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ), 'options' => array( 0 => __( 'No', 'ultimate-member' ), diff --git a/includes/admin/templates/form/profile_customize.php b/includes/admin/templates/form/profile_customize.php index b0246061..9ed7016a 100644 --- a/includes/admin/templates/form/profile_customize.php +++ b/includes/admin/templates/form/profile_customize.php @@ -34,7 +34,7 @@ 'id' => '_um_profile_template', 'type' => 'select', 'label' => __( 'Template', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_profile_template', null, um_get_option( 'profile_template' ) ), + 'value' => UM()->query()->get_meta_value( '_um_profile_template', null, UM()->options()->get( 'profile_template' ) ), 'options' => UM()->shortcodes()->get_templates( 'profile' ), 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ) ), @@ -43,7 +43,7 @@ 'type' => 'text', 'label' => __( 'Max. Width (px)', 'ultimate-member' ), 'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value('_um_profile_max_width', null, um_get_option( 'profile_max_width' ) ), + 'value' => UM()->query()->get_meta_value('_um_profile_max_width', null, UM()->options()->get( 'profile_max_width' ) ), 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ) ), array( @@ -51,7 +51,7 @@ 'type' => 'text', 'label' => __( 'Profile Area Max. Width (px)', 'ultimate-member' ), 'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value('_um_profile_area_max_width', null, um_get_option( 'profile_area_max_width' ) ), + 'value' => UM()->query()->get_meta_value('_um_profile_area_max_width', null, UM()->options()->get( 'profile_area_max_width' ) ), 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ) ), array( @@ -59,7 +59,7 @@ 'type' => 'select', 'label' => __( 'Field Icons', 'ultimate-member' ), 'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_profile_icons', null, um_get_option( 'profile_icons' ) ) , + 'value' => UM()->query()->get_meta_value( '_um_profile_icons', null, UM()->options()->get( 'profile_icons' ) ) , 'options' => array( 'field' => __( 'Show inside text field', 'ultimate-member' ), 'label' => __( 'Show with label', 'ultimate-member' ), @@ -72,14 +72,14 @@ 'type' => 'text', 'label' => __( 'Primary Button Text', 'ultimate-member' ), 'tooltip' => __( 'Customize the button text', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_profile_primary_btn_word', null, um_get_option( 'profile_primary_btn_word' ) ), + 'value' => UM()->query()->get_meta_value( '_um_profile_primary_btn_word', null, UM()->options()->get( 'profile_primary_btn_word' ) ), 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ) ), array( 'id' => '_um_profile_secondary_btn', 'type' => 'select', 'label' => __( 'Show Secondary Button', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_profile_secondary_btn', null, um_get_option( 'profile_secondary_btn' ) ), + 'value' => UM()->query()->get_meta_value( '_um_profile_secondary_btn', null, UM()->options()->get( 'profile_secondary_btn' ) ), 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ), 'options' => array( 0 => __( 'No', 'ultimate-member' ), @@ -91,7 +91,7 @@ 'type' => 'text', 'label' => __( 'Primary Button Text', 'ultimate-member' ), 'tooltip' => __( 'Customize the button text', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_profile_secondary_btn_word', null, um_get_option( 'profile_secondary_btn_word' ) ), + 'value' => UM()->query()->get_meta_value( '_um_profile_secondary_btn_word', null, UM()->options()->get( 'profile_secondary_btn_word' ) ), 'conditional' => array( '_um_profile_secondary_btn', '=', 1 ) ), array( @@ -110,7 +110,7 @@ 'type' => 'select', 'label' => __( 'Cover photo ratio', 'ultimate-member' ), 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_profile_cover_ratio', null, um_get_option( 'profile_cover_ratio' ) ), + 'value' => UM()->query()->get_meta_value( '_um_profile_cover_ratio', null, UM()->options()->get( 'profile_cover_ratio' ) ), 'options' => array( '2.7:1' => '2.7:1', '2.2:1' => '2.2:1', @@ -123,7 +123,7 @@ 'type' => 'text', 'label' => __( 'Profile Photo Size', 'ultimate-member' ), 'tooltip' => __( 'Set the profile photo size in pixels here', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_profile_photosize', null, um_get_option( 'profile_photosize' ) ), + 'value' => UM()->query()->get_meta_value( '_um_profile_photosize', null, UM()->options()->get( 'profile_photosize' ) ), 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ) ), array( @@ -153,7 +153,7 @@ 'id' => '_um_profile_show_social_links', 'type' => 'select', 'label' => __( 'Show social links in profile header?', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_profile_show_social_links', null, UM()->um_get_option( 'profile_show_social_links' ) ), + 'value' => UM()->query()->get_meta_value( '_um_profile_show_social_links', null, UM()->options()->get( 'profile_show_social_links' ) ), 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ), 'options' => array( 0 => __( 'No', 'ultimate-member' ), diff --git a/includes/admin/templates/form/register_customize.php b/includes/admin/templates/form/register_customize.php index 408a8e43..d2628881 100644 --- a/includes/admin/templates/form/register_customize.php +++ b/includes/admin/templates/form/register_customize.php @@ -33,7 +33,7 @@ 'id' => '_um_register_template', 'type' => 'select', 'label' => __( 'Template', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_register_template', null, um_get_option( 'register_template' ) ), + 'value' => UM()->query()->get_meta_value( '_um_register_template', null, UM()->options()->get( 'register_template' ) ), 'options' => UM()->shortcodes()->get_templates( 'register' ), 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ) ), @@ -42,7 +42,7 @@ 'type' => 'text', 'label' => __( 'Max. Width (px)', 'ultimate-member' ), 'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value('_um_register_max_width', null, um_get_option( 'register_max_width' ) ), + 'value' => UM()->query()->get_meta_value('_um_register_max_width', null, UM()->options()->get( 'register_max_width' ) ), 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ) ), array( @@ -50,7 +50,7 @@ 'type' => 'select', 'label' => __( 'Field Icons', 'ultimate-member' ), 'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_register_icons', null, um_get_option( 'register_icons' ) ) , + 'value' => UM()->query()->get_meta_value( '_um_register_icons', null, UM()->options()->get( 'register_icons' ) ) , 'options' => array( 'field' => __( 'Show inside text field', 'ultimate-member' ), 'label' => __( 'Show with label', 'ultimate-member' ), @@ -63,14 +63,14 @@ 'type' => 'text', 'label' => __( 'Primary Button Text', 'ultimate-member' ), 'tooltip' => __( 'Customize the button text', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_register_primary_btn_word', null, um_get_option( 'register_primary_btn_word' ) ), + 'value' => UM()->query()->get_meta_value( '_um_register_primary_btn_word', null, UM()->options()->get( 'register_primary_btn_word' ) ), 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ) ), array( 'id' => '_um_register_secondary_btn', 'type' => 'select', 'label' => __( 'Show Secondary Button', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_register_secondary_btn', null, um_get_option( 'register_secondary_btn' ) ), + 'value' => UM()->query()->get_meta_value( '_um_register_secondary_btn', null, UM()->options()->get( 'register_secondary_btn' ) ), 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ), 'options' => array( 0 => __( 'No', 'ultimate-member' ), @@ -82,7 +82,7 @@ 'type' => 'text', 'label' => __( 'Primary Button Text', 'ultimate-member' ), 'tooltip' => __( 'Customize the button text', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_register_secondary_btn_word', null, um_get_option( 'register_secondary_btn_word' ) ), + 'value' => UM()->query()->get_meta_value( '_um_register_secondary_btn_word', null, UM()->options()->get( 'register_secondary_btn_word' ) ), 'conditional' => array( '_um_register_secondary_btn', '=', 1 ) ) ) diff --git a/includes/class-functions.php b/includes/class-functions.php index 3a35f48c..9350e486 100644 --- a/includes/class-functions.php +++ b/includes/class-functions.php @@ -90,29 +90,6 @@ if ( ! class_exists( 'UM_Functions' ) ) { } - function um_update_option( $option_id, $value ) { - $this->options[ $option_id ] = $value; - update_option( 'um_options', $this->options ); - } - - - function um_remove_option( $option_id ) { - if ( ! empty( $this->options[ $option_id ] ) ) - unset( $this->options[ $option_id ] ); - - update_option( 'um_options', $this->options ); - } - - - function um_get_default( $option_id ) { - $settings_defaults = UM()->config()->settings_defaults; - if ( ! isset( $settings_defaults[$option_id] ) ) - return false; - - return $settings_defaults[$option_id]; - } - - /** * Help Tip displaying * diff --git a/includes/class-init.php b/includes/class-init.php index 82db78c7..9f499487 100644 --- a/includes/class-init.php +++ b/includes/class-init.php @@ -198,6 +198,7 @@ if ( ! class_exists( 'UM' ) ) { //include short non class functions require_once 'um-short-functions.php'; + require_once 'um-deprecated-functions.php'; } } diff --git a/includes/core/class-options.php b/includes/core/class-options.php index 9c19a047..8b441a0a 100644 --- a/includes/core/class-options.php +++ b/includes/core/class-options.php @@ -7,7 +7,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; if ( ! class_exists( 'Options' ) ) { class Options { - var $options; + var $options = array(); /** * Access constructor. @@ -66,7 +66,7 @@ if ( ! class_exists( 'Options' ) ) { * * @param $option_id */ - function delete( $option_id ) { + function remove( $option_id ) { if ( ! empty( $this->options[ $option_id ] ) ) unset( $this->options[ $option_id ] ); diff --git a/includes/core/class-setup.php b/includes/core/class-setup.php index a8523b42..a923c143 100644 --- a/includes/core/class-setup.php +++ b/includes/core/class-setup.php @@ -49,7 +49,6 @@ if ( ! class_exists( 'Setup' ) ) { //Install default options foreach ( UM()->config()->settings_defaults as $key => $value ) { $options[$key] = $value; - //UM()->um_update_option( $key, $value ); } // Install Core Forms @@ -191,7 +190,6 @@ if ( ! class_exists( 'Setup' ) ) { foreach ( $core_pages as $slug => $page_id ) { $key = apply_filters( 'um_core_page_id_filter', 'core_' . $slug ); $options[$key] = $page_id; - //UM()->um_update_option( apply_filters( 'um_core_page_id_filter', 'core_' . $slug ), $page_id ); } } diff --git a/includes/um-deprecated-functions.php b/includes/um-deprecated-functions.php new file mode 100644 index 00000000..7a5ffeb5 --- /dev/null +++ b/includes/um-deprecated-functions.php @@ -0,0 +1,75 @@ +options()->get() instead + * + * @deprecated 2.0.1 + * @param $option_id + * @return mixed|string|void + */ +function um_get_option( $option_id ) { + //um_deprecated_function( 'um_get_option', '2.0', 'UM()->options()->get' ); + return UM()->options()->get( $option_id ); +} + + +/** + * Update option value + * + * Please use UM()->options()->update() instead + * + * @deprecated 2.0.1 + * @param $option_id + * @param $value + */ +function um_update_option( $option_id, $value ) { + //um_deprecated_function( 'um_update_option', '2.0', 'UM()->options()->update' ); + UM()->options()->update( $option_id, $value ); +} + + +/** + * Update option value + * + * Please use UM()->options()->remove() instead + * + * @deprecated 2.0.1 + * @param $option_id + */ +function um_remove_option( $option_id ) { + //um_deprecated_function( 'um_remove_option', '2.0', 'UM()->options()->remove' ); + UM()->options()->remove( $option_id ); +} \ No newline at end of file diff --git a/includes/um-short-functions.php b/includes/um-short-functions.php index 1ccfc2db..c0cb10af 100644 --- a/includes/um-short-functions.php +++ b/includes/um-short-functions.php @@ -1143,76 +1143,6 @@ return UM()->options()->get( 'admin_email' ); } - /** - * @function um_get_option() - * - * @description This function returns the value of an option or setting. - * - * @usage - * - * @param $option_id (string) (required) The option or setting that you want to retrieve - * - * @returns Returns the value of the setting you requested, or a blank value if the setting - * does not exist. - * - * @example Get default user role set in global options - * - * - * - * @example Get blocked IP addresses set in backend - * - * - * @return mixed - */ - function um_get_option( $option_id ) { - if (!isset( UM()->options )) - return ''; - - $um_options = UM()->options; - if (!empty( $um_options[$option_id] )) - return apply_filters( "um_get_option_filter__{$option_id}", $um_options[$option_id] ); - - switch ($option_id) { - - case 'site_name': - return get_bloginfo( 'name' ); - break; - - case 'admin_email': - return get_bloginfo( 'admin_email' ); - break; - default: - return ''; - break; - - } - } - - - function um_update_option( $option_id, $value ) { - if (!isset( UM()->options )) - UM()->options = array(); - - $um_options = UM()->options; - $um_options[$option_id] = $value; - UM()->options = $um_options; - - update_option( 'um_options', $um_options ); - } - - - function um_remove_option( $option_id ) { - if (!isset( UM()->options )) - UM()->options = array(); - - $um_options = UM()->options; - if (!empty( $um_options[$option_id] )) - unset( $um_options[$option_id] ); - - UM()->options = $um_options; - - update_option( 'um_options', $um_options ); - } /*** *** @Display a link to profile page diff --git a/uninstall.php b/uninstall.php index 327c5064..980a032f 100644 --- a/uninstall.php +++ b/uninstall.php @@ -37,7 +37,7 @@ if ( ! empty( $delete_options ) ) { //remove core settings $settings_defaults = UM()->config()->settings_defaults; foreach ( $settings_defaults as $k => $v ) { - UM()->um_remove_option( $k ); + UM()->options()->remove( $k ); } //delete UM Custom Post Types posts