| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
/** |
| 7 |
* UsersWP profile section widget. |
| 8 |
* |
| 9 |
* @since 1.1.2 |
| 10 |
*/ |
| 11 |
class UWP_Profile_Section_Widget extends WP_Super_Duper { |
| 12 |
|
| 13 |
/** |
| 14 |
* Register the profile section widget with WordPress. |
| 15 |
* |
| 16 |
*/ |
| 17 |
public function __construct() { |
| 18 |
|
| 19 |
|
| 20 |
$options = array( |
| 21 |
'textdomain' => 'userswp', |
| 22 |
'block-icon' => 'admin-site', |
| 23 |
'block-wrap' => '', |
| 24 |
'block-category'=> 'layout', |
| 25 |
'block-keywords'=> "['userswp','profile']", |
| 26 |
'class_name' => __CLASS__, |
| 27 |
'base_id' => 'uwp_profile_section', |
| 28 |
'name' => __('UWP > Profile Section','userswp'), |
| 29 |
'no_wrap' => true, |
| 30 |
'widget_ops' => array( |
| 31 |
'classname' => 'uwp-profile-section', |
| 32 |
'description' => esc_html__('Display section to contain other elements.','userswp'), |
| 33 |
), |
| 34 |
'arguments' => array( |
| 35 |
'type' => array( |
| 36 |
'title' => __('Type:', 'userswp'), |
| 37 |
'desc' => __('This is the opening or closing section.', 'userswp'), |
| 38 |
'type' => 'select', |
| 39 |
'options' => array( |
| 40 |
"open" => __('Open', 'userswp'), |
| 41 |
"close" => __('Close', 'userswp'), |
| 42 |
), |
| 43 |
'default' => 'open', |
| 44 |
'desc_tip' => true, |
| 45 |
'advanced' => false |
| 46 |
), |
| 47 |
'position' => array( |
| 48 |
'title' => __('Position:', 'userswp'), |
| 49 |
'desc' => __('This is position of the section.', 'userswp'), |
| 50 |
'type' => 'select', |
| 51 |
'options' => array( |
| 52 |
"left" => __('Left', 'userswp'), |
| 53 |
"right" => __('Right', 'userswp'), |
| 54 |
"full" => __('Full', 'userswp'), |
| 55 |
), |
| 56 |
'default' => 'full', |
| 57 |
'desc_tip' => true, |
| 58 |
'advanced' => false |
| 59 |
), |
| 60 |
) |
| 61 |
|
| 62 |
); |
| 63 |
|
| 64 |
|
| 65 |
parent::__construct( $options ); |
| 66 |
} |
| 67 |
|
| 68 |
public function output( $args = array(), $widget_args = array(), $content = '' ) { |
| 69 |
|
| 70 |
$defaults = array( |
| 71 |
'type' => 'open', |
| 72 |
'position' => 'full', |
| 73 |
); |
| 74 |
|
| 75 |
$args = wp_parse_args( $args, $defaults ); |
| 76 |
$output = ''; |
| 77 |
|
| 78 |
$design_style = uwp_get_option("design_style",'bootstrap'); |
| 79 |
if($design_style){ |
| 80 |
return $output; |
| 81 |
} |
| 82 |
|
| 83 |
if(isset($args['type']) && $args['type']=='open'){ |
| 84 |
$class = !empty($args['class']) ? esc_attr($args['class']) : ''; |
| 85 |
$position = isset($args['position']) ? $args['position'] : 'full'; |
| 86 |
$output = '<div class="uwp_page uwp-section-'.$position.' '.$class.'">'; |
| 87 |
}elseif(isset($args['type']) && $args['type']=='close'){ |
| 88 |
$output = "</div>"; |
| 89 |
} |
| 90 |
|
| 91 |
// if block demo return empty to show placeholder text |
| 92 |
if($this->is_block_content_call()){ |
| 93 |
$section_type = $args['type']=='open' ? __('closing','userswp') : __('opening','userswp'); |
| 94 |
$output = '<div style="background:#0185ba33;padding: 10px;">'.sprintf( __('Archive Item Section: <b>%s : %s</b> <small>(requires %s section to work)</small>', 'userswp'),strtoupper($args['type']),strtoupper($args['position']),$section_type).'</div>'; |
| 95 |
} |
| 96 |
|
| 97 |
return $output; |
| 98 |
|
| 99 |
} |
| 100 |
|
| 101 |
} |