PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.14
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.14
1.2.73 1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 All 173 releases
userswp / widgets / authorbox.php

authorbox.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.2.14, at widgets/authorbox.php

144 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5
6 /**
7 * UsersWP author box widget.
8 *
9 * @since 1.0.22
10 */
11 class UWP_Author_Box_Widget extends WP_Super_Duper {
12
13 /**
14 * Register the profile 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','author','authorbox']",
25 'class_name' => __CLASS__,
26 'base_id' => 'uwp_author_box',
27 'name' => __('UWP > Author Box','userswp'),
28 'widget_ops' => array(
29 'classname' => 'uwp_widgets uwp_widget_author_box bsui',
30 'description' => esc_html__('Displays author box.','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 )
42
43 );
44
45
46 parent::__construct( $options );
47 }
48
49 /**
50 * The Super block output function.
51 *
52 * @param array $args
53 * @param array $widget_args
54 * @param string $content
55 *
56 * @return mixed|string|bool
57 */
58 public function output( $args = array(), $widget_args = array(), $content = '' ) {
59
60 global $post, $wpdb;
61
62 if(empty($post->ID)){
63 return '';
64 }
65
66 ob_start();
67
68 if(!wp_style_is('uwp-authorbox')){
69 wp_enqueue_style( 'uwp-authorbox' );
70 }
71
72 $design_style = uwp_get_option("design_style",'bootstrap');
73 if( $design_style =='bootstrap'){
74 $output = uwp_get_option('author_box_content_bootstrap');
75 if(!$output){$output = UsersWP_Defaults::author_box_content_bootstrap();}
76 }else{
77 $output = uwp_get_option('author_box_content');
78 if(!$output){$output = UsersWP_Defaults::author_box_content();}
79 }
80
81 $output = apply_filters('uwp_author_box_pre_output', $output, $args);
82
83 $output = do_shortcode($output );
84
85 $author_id = $post->post_author;
86 $author_link = uwp_build_profile_tab_url($author_id);
87 $user = get_user_by('id', $author_id);
88 $author_name = esc_attr( $user->display_name );
89 $author_bio = get_user_meta($author_id, 'description', true);
90 $limit_words = apply_filters('uwp_author_bio_content_limit', uwp_get_option('author_box_bio_limit', 200));
91 $author_bio = wp_trim_words( $author_bio, $limit_words, '...' );
92 $meta_table = get_usermeta_table_prefix() . 'uwp_usermeta';
93 $user_meta = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$meta_table} WHERE user_id = %d", $author_id), ARRAY_A);
94
95 $user_meta = apply_filters('uwp_author_box_user_meta_fields', $user_meta, $args);
96 $avatar_size = apply_filters('uwp_author_box_avatar_size', 100, $args);
97
98 $replace_array = array(
99 '[#post_id#]' => absint( $post->ID ),
100 '[#post_modified#]' => esc_attr( $post->post_modified ),
101 '[#post_date#]' => esc_attr( $post->post_date ),
102 '[#author_id#]' => absint( $post->post_author ),
103 '[#author_name#]' => esc_attr( $author_name ),
104 '[#author_link#]' => esc_url( $author_link ),
105 '[#author_bio#]' => esc_textarea( $author_bio ),
106 '[#author_image#]' => get_avatar($post->post_author, $avatar_size),
107 '[#author_image_url#]' => get_avatar_url($post->post_author, $avatar_size),
108 '[#author_nicename#]' => esc_attr( $user->user_nicename ),
109 '[#author_registered#]' => esc_attr( $user->user_registered ),
110 '[#author_website#]' => esc_url( $user->user_url ),
111 );
112
113 if( !empty( $user_meta ) && '' !== $user_meta ) {
114 foreach ( $user_meta as $meta_key => $meta_val ) {
115
116 if(in_array($meta_key, array('avatar_thumb', 'banner_thumb')) && !empty($meta_val)){
117 $uploads = wp_upload_dir();
118 $upload_url = $uploads['baseurl'];
119 $meta_val = esc_url( $upload_url.$meta_val );
120 }
121
122 if( in_array($meta_key, array('user_privacy')) ) {
123 continue;
124 }
125
126 $replace_array['[#'.$meta_key.'#]'] = esc_attr( $meta_val );
127 }
128 }
129
130 $replace_array = apply_filters('uwp_author_box_replace_array', $replace_array);
131
132 foreach ( $replace_array as $key => $value ) {
133 $value = apply_filters('uwp_author_box_'.$key.'_value', $value, $post);
134 $output = str_replace( $key, $value, $output );
135 }
136
137 echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
138
139 $output = ob_get_clean();
140
141 return apply_filters('uwp_author_box_output', $output, $args);
142 }
143
144 }