| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
/** |
| 7 |
* UsersWP reset password widget. |
| 8 |
* |
| 9 |
* @since 1.0.22 |
| 10 |
*/ |
| 11 |
class UWP_Reset_Widget extends WP_Super_Duper { |
| 12 |
|
| 13 |
/** |
| 14 |
* Register the reset password widget with WordPress. |
| 15 |
* |
| 16 |
*/ |
| 17 |
public function __construct() { |
| 18 |
|
| 19 |
|
| 20 |
$options = array( |
| 21 |
'textdomain' => 'userswp', |
| 22 |
'block-icon' => 'admin-site', |
| 23 |
'block-category'=> 'widgets', |
| 24 |
'block-keywords'=> "['userswp','reset']", |
| 25 |
'class_name' => __CLASS__, |
| 26 |
'base_id' => 'uwp_reset', |
| 27 |
'name' => __('UWP > Reset','userswp'), |
| 28 |
'widget_ops' => array( |
| 29 |
'classname' => 'uwp-reset-class bsui', |
| 30 |
'description' => esc_html__('Displays reset password form.','userswp'), |
| 31 |
), |
| 32 |
'arguments' => array( |
| 33 |
'title' => array( |
| 34 |
'title' => __( 'Widget title', 'userswp' ), |
| 35 |
'desc' => __( 'Enter widget title.', 'userswp' ), |
| 36 |
'type' => 'text', |
| 37 |
'desc_tip' => true, |
| 38 |
'default' => '', |
| 39 |
'advanced' => false |
| 40 |
), |
| 41 |
'form_title' => array( |
| 42 |
'title' => __( 'Form title', 'userswp' ), |
| 43 |
'desc' => __( 'Enter the form title (or "0" for no title)', 'userswp' ), |
| 44 |
'type' => 'text', |
| 45 |
'desc_tip' => true, |
| 46 |
'default' => '', |
| 47 |
'placeholder' => __('Reset Password','userswp'), |
| 48 |
'advanced' => true |
| 49 |
), |
| 50 |
'css_class' => array( |
| 51 |
'type' => 'text', |
| 52 |
'title' => __('Extra class:', 'userswp'), |
| 53 |
'desc' => __('Give the wrapper an extra class so you can style things as you want.', 'userswp'), |
| 54 |
'placeholder' => '', |
| 55 |
'default' => '', |
| 56 |
'desc_tip' => true, |
| 57 |
'advanced' => true, |
| 58 |
), |
| 59 |
) |
| 60 |
|
| 61 |
); |
| 62 |
|
| 63 |
|
| 64 |
parent::__construct( $options ); |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* The Super block output function. |
| 69 |
* |
| 70 |
* @param array $args |
| 71 |
* @param array $widget_args |
| 72 |
* @param string $content |
| 73 |
* |
| 74 |
* @return mixed|string|bool |
| 75 |
*/ |
| 76 |
public function output( $args = array(), $widget_args = array(), $content = '' ) { |
| 77 |
|
| 78 |
if (is_user_logged_in() && !is_admin()) { |
| 79 |
return false; |
| 80 |
} |
| 81 |
|
| 82 |
$defaults = array( |
| 83 |
'form_title' => __('Reset Password','userswp'), |
| 84 |
'css_class' => '' |
| 85 |
); |
| 86 |
|
| 87 |
/** |
| 88 |
* Parse incoming $args into an array and merge it with $defaults |
| 89 |
*/ |
| 90 |
$args = wp_parse_args( $args, $defaults ); |
| 91 |
|
| 92 |
ob_start(); |
| 93 |
|
| 94 |
echo '<div class="uwp_widgets uwp_widget_reset">'; |
| 95 |
|
| 96 |
$design_style = !empty($args['design_style']) ? esc_attr($args['design_style']) : uwp_get_option("design_style",'bootstrap'); |
| 97 |
$template = $design_style ? $design_style."/reset.php" : "reset.php"; |
| 98 |
|
| 99 |
echo '<div class="uwp_page">'; |
| 100 |
|
| 101 |
uwp_get_template($template, $args); |
| 102 |
|
| 103 |
echo '</div>'; |
| 104 |
|
| 105 |
echo '</div>'; |
| 106 |
|
| 107 |
uwp_password_strength_inline_js(); |
| 108 |
|
| 109 |
$output = ob_get_clean(); |
| 110 |
|
| 111 |
return trim($output); |
| 112 |
|
| 113 |
} |
| 114 |
|
| 115 |
} |