*/ class UsersWP_Admin { /** * Register all of the hooks related to the admin area functionality * of the plugin. * * @since 1.0.0 */ public function __construct() { add_action( 'admin_init', array( $this, 'preview_emails' ) ); add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) ); } /** * Maybe show the AyeCode Connect Notice. */ public function init_ayecode_connect_helper(){ // AyeCode Connect notice if ( is_admin() ){ // set the strings so they can be translated $strings = array( 'connect_title' => __("UsersWP - an AyeCode product!","userswp"), 'connect_external' => __( "Please confirm you wish to connect your site?","userswp" ), 'connect' => sprintf( __( "Have a license? Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","userswp" ),"","" ), 'connect_button' => __("Connect Site","userswp"), 'connecting_button' => __("Connecting...","userswp"), 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","userswp" ), 'error' => __( "Something went wrong, please refresh and try again.","userswp" ), ); new AyeCode_Connect_Helper($strings,array('uwp-addons')); } } /** * Register the stylesheets for the admin area. * * @since 1.0.0 * @param $hook_suffix */ public function enqueue_styles( $hook_suffix ) { if ( $hook_suffix == 'profile.php' || $hook_suffix == 'user-edit.php' ) { wp_register_style( 'jquery-ui', USERSWP_PLUGIN_URL . 'assets/css/jquery-ui.css' ); wp_enqueue_style( 'jquery-ui' ); wp_enqueue_style( 'jcrop' ); wp_enqueue_style( "userswp", USERSWP_PLUGIN_URL . 'assets/css/users-wp.css', array(), USERSWP_VERSION, 'all' ); wp_enqueue_style( "uwp_timepicker_css", USERSWP_PLUGIN_URL . 'assets/css/jquery.ui.timepicker.css', array(), USERSWP_VERSION, 'all' ); } if ( $hook_suffix == 'userswp_page_uwp_tools' ) { wp_enqueue_style( "userswp", USERSWP_PLUGIN_URL . 'assets/css/users-wp.css', array(), USERSWP_VERSION, 'all' ); } wp_enqueue_style( "userswp_admin_css", USERSWP_PLUGIN_URL . 'admin/assets/css/users-wp-admin.css', array(), USERSWP_VERSION, 'all' ); if ( $hook_suffix == 'toplevel_page_userswp' ) { wp_enqueue_style( 'wp-color-picker' ); } } /** * Register the JavaScript for the admin area. * * @since 1.0.0 * @param $hook_suffix */ public function enqueue_scripts($hook_suffix) { $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; if ( $hook_suffix == 'profile.php' || $hook_suffix == 'user-edit.php' ) { wp_enqueue_script( 'jquery-ui-datepicker', array( 'jquery' ) ); wp_enqueue_script( "uwp_timepicker", USERSWP_PLUGIN_URL . 'assets/js/jquery.ui.timepicker.min.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-core' ), USERSWP_VERSION ); wp_enqueue_script( "userswp", USERSWP_PLUGIN_URL . 'assets/js/users-wp' . $suffix . '.js', array( 'jquery' ), USERSWP_VERSION, false ); $uwp_localize_data = uwp_get_localize_data(); wp_localize_script('userswp', 'uwp_localize_data', $uwp_localize_data ); wp_enqueue_script( 'jquery-ui-progressbar', array( 'jquery' ) ); wp_enqueue_script( 'jcrop', array( 'jquery' ) ); wp_enqueue_script( "country-select", USERSWP_PLUGIN_URL . 'assets/js/countrySelect' . $suffix . '.js', array( 'jquery' ), USERSWP_VERSION ); } if ( $hook_suffix == 'userswp_page_uwp_status' ) { wp_enqueue_script( 'jquery-ui-progressbar', array( 'jquery' ) ); wp_enqueue_script( "uwp_status", USERSWP_PLUGIN_URL . 'admin/assets/js/system-status.js', array( 'jquery' ), USERSWP_VERSION, true ); } wp_enqueue_script( 'jquery-ui-sortable' ); wp_enqueue_script( 'uwp-nestable-script', USERSWP_PLUGIN_URL . 'admin/assets/js/jquery.nestable' . $suffix . '.js', array('jquery-ui-sortable'), USERSWP_VERSION ); wp_enqueue_script( "userswp_admin", USERSWP_PLUGIN_URL . 'admin/assets/js/users-wp-admin' . $suffix . '.js', array( 'jquery' ), USERSWP_VERSION, false ); wp_enqueue_script( "jquery-ui-tooltip" ); wp_enqueue_script( 'wp-color-picker' ); $ajax_cons_data = array( 'url' => admin_url( 'admin-ajax.php' ), 'custom_field_not_blank_var' => __( 'Field key must not be blank', 'userswp' ), 'custom_field_options_not_blank_var' => __( 'Option Values must not be blank', 'userswp' ), 'custom_field_not_special_char' => __( 'Please do not use special character and spaces in field key.', 'userswp' ), 'custom_field_unique_name' => __( 'Field key should be a unique name.', 'userswp' ), 'custom_field_delete' => __( 'Are you sure you wish to delete this field?', 'userswp' ), 'custom_field_id_required' => __( 'This field is required.', 'userswp' ), 'img_spacer' => admin_url( 'images/media-button-image.gif' ), 'txt_choose_image' => __( 'Choose an image', 'userswp' ), 'txt_use_image' => __( 'Use image', 'userswp' ), ); wp_localize_script( "userswp_admin", 'uwp_admin_ajax', $ajax_cons_data ); $country_data = uwp_get_country_data(); wp_localize_script( USERSWP_NAME, 'uwp_country_data', $country_data ); } /** * Adds UsersWP css to admin area * * @since 1.0.0 * @package userswp * * @return void */ public function admin_only_css() { ?> Profile Page.', 'userswp' ), uwp_build_profile_tab_url( $user_id )); } } return $description; } /** * Adds avatar and banner fields in admin side. * * @since 1.0.0 * @package userswp * * @param object $user User object. * * @return void */ public function edit_profile_banner_fields($user) { global $wpdb; $file_obj = new UsersWP_Files(); $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; $fields = $wpdb->get_results("SELECT * FROM " . $table_name . " WHERE (form_type = 'avatar' OR form_type = 'banner') ORDER BY sort_order ASC"); if ($fields) { ?>
field_icon ); if ($field->field_type == 'fieldset') { ?>

site_title; ?>

site_title; ?> htmlvar_name == "avatar" ) { $value = uwp_get_usermeta( $user->ID, "avatar_thumb", "" ); } elseif ( $field->htmlvar_name == "banner" ) { $value = uwp_get_usermeta( $user->ID, "banner_thumb", "" ); } else { $value = ""; } echo $file_obj->file_upload_preview( $field, $value ); if ( $field->htmlvar_name == "avatar" ) { if ( ! empty( $value ) ) { $label = __( "Change Avatar", "userswp" ); } else { $label = __( "Upload Avatar", "userswp" ); } ?> htmlvar_name == "banner" ) { if ( ! empty( $value ) ) { $label = __( "Change Banner", "userswp" ); } else { $label = __( "Upload Banner", "userswp" ); } ?>
base || 'user-edit' == $screen->base ) $classes .= 'uwp_page'; return $classes; } /** * Preview email template for UWP emails. */ public function preview_emails() { if ( isset( $_GET['uwp_preview_mail'] ) ) { if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'uwp-preview-mail' ) ) { die( 'Security check failed.' ); } $email_name = 'preview_mail'; $email_vars = array(); $plain_text = UsersWP_Mails::get_email_type() != 'html' ? true : false; // Get the preview email content. ob_start(); include( 'views/html-email-template-preview.php' ); $message = ob_get_clean(); $message = UsersWP_Mails::email_wrap_message( $message, $email_name, $email_vars, '', $plain_text ); $message = UsersWP_Mails::style_body( $message, $email_name, $email_vars ); $message = apply_filters( 'uwp_mail_content', $message, $email_name, $email_vars ); // Print the preview email content. if ( $plain_text ) { echo '
'; } echo $message; if ( $plain_text ) { echo '
'; } exit; } } }