| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
/** |
| 7 |
* UsersWP change password widget. |
| 8 |
* |
| 9 |
* @since 1.0.22 |
| 10 |
*/ |
| 11 |
class UWP_Change_Widget extends WP_Super_Duper { |
| 12 |
|
| 13 |
/** |
| 14 |
* Register the change 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','change']", |
| 25 |
'class_name' => __CLASS__, |
| 26 |
'base_id' => 'uwp_change', |
| 27 |
'name' => __('UWP > Change','userswp'), |
| 28 |
'widget_ops' => array( |
| 29 |
'classname' => 'uwp-change-class bsui', |
| 30 |
'description' => esc_html__('Displays change 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' => __('Change Password','userswp'), |
| 48 |
'advanced' => true |
| 49 |
), |
| 50 |
'design_style' => array( |
| 51 |
'title' => __('Design Style', 'userswp'), |
| 52 |
'desc' => __('The design style to use.', 'userswp'), |
| 53 |
'type' => 'select', |
| 54 |
'options' => array( |
| 55 |
"" => __('default', 'userswp'), |
| 56 |
"bootstrap" => __('Style 1', 'userswp'), |
| 57 |
), |
| 58 |
'default' => '', |
| 59 |
'desc_tip' => true, |
| 60 |
'advanced' => true |
| 61 |
), |
| 62 |
'css_class' => array( |
| 63 |
'type' => 'text', |
| 64 |
'title' => __('Extra class:', 'userswp'), |
| 65 |
'desc' => __('Give the wrapper an extra class so you can style things as you want.', 'userswp'), |
| 66 |
'placeholder' => '', |
| 67 |
'default' => '', |
| 68 |
'desc_tip' => true, |
| 69 |
'advanced' => true, |
| 70 |
), |
| 71 |
) |
| 72 |
|
| 73 |
); |
| 74 |
|
| 75 |
|
| 76 |
parent::__construct( $options ); |
| 77 |
} |
| 78 |
|
| 79 |
/** |
| 80 |
* The Super block output function. |
| 81 |
* |
| 82 |
* @param array $args |
| 83 |
* @param array $widget_args |
| 84 |
* @param string $content |
| 85 |
* |
| 86 |
* @return mixed|string|bool |
| 87 |
*/ |
| 88 |
public function output( $args = array(), $widget_args = array(), $content = '' ) { |
| 89 |
|
| 90 |
if (!is_user_logged_in()) { |
| 91 |
return false; |
| 92 |
} |
| 93 |
|
| 94 |
$defaults = array( |
| 95 |
'form_title' => __('Change Password','userswp'), |
| 96 |
'css_class' => '' |
| 97 |
); |
| 98 |
|
| 99 |
/** |
| 100 |
* Parse incoming $args into an array and merge it with $defaults |
| 101 |
*/ |
| 102 |
$args = wp_parse_args( $args, $defaults ); |
| 103 |
|
| 104 |
ob_start(); |
| 105 |
|
| 106 |
echo '<div class="uwp_widgets uwp_widget_change">'; |
| 107 |
|
| 108 |
$design_style = !empty($args['design_style']) ? esc_attr($args['design_style']) : uwp_get_option("design_style",'bootstrap'); |
| 109 |
$template = $design_style ? $design_style."/change.php" : "change.php"; |
| 110 |
|
| 111 |
echo '<div class="uwp_page">'; |
| 112 |
|
| 113 |
uwp_get_template($template, $args); |
| 114 |
|
| 115 |
echo '</div>'; |
| 116 |
|
| 117 |
echo '</div>'; |
| 118 |
|
| 119 |
uwp_password_strength_inline_js(); |
| 120 |
|
| 121 |
return ob_get_clean(); |
| 122 |
|
| 123 |
} |
| 124 |
|
| 125 |
} |