| 1 |
<?php |
| 2 |
// Exit if accessed directly |
| 3 |
if( !defined( 'ABSPATH' ) ) exit; |
| 4 |
|
| 5 |
|
| 6 |
register_nav_menus( array( |
| 7 |
'wpforo-menu' => esc_html__( 'wpForo Menu', 'wpforo' ), |
| 8 |
) ); |
| 9 |
|
| 10 |
|
| 11 |
function wpforo_login_url(){ |
| 12 |
if(isset(WPF()->member->options['login_url']) && WPF()->member->options['login_url']){ |
| 13 |
$wp_login_url = trim(get_bloginfo('url') , '/') . '/' . ltrim(WPF()->member->options['login_url'] , '/'); |
| 14 |
}else{ |
| 15 |
$request_uri = preg_replace( '#/?\?.*$#isu', '', wpforo_get_request_uri() ); |
| 16 |
$wp_login_url = (!is_wpforo_page() ? wpforo_home_url('?wpforo=signin') : wpforo_home_url( $request_uri . '?wpforo=signin' ) ); |
| 17 |
} |
| 18 |
|
| 19 |
return esc_url($wp_login_url); |
| 20 |
} |
| 21 |
|
| 22 |
|
| 23 |
function wpforo_register_url(){ |
| 24 |
if(isset(WPF()->member->options['register_url']) && WPF()->member->options['register_url']){ |
| 25 |
$wp_register_url = trim(get_bloginfo('url') , '/') . '/' . ltrim(WPF()->member->options['register_url'] , '/'); |
| 26 |
} |
| 27 |
else{ |
| 28 |
$wp_register_url = wpforo_home_url('?wpforo=signup'); |
| 29 |
} |
| 30 |
return esc_url($wp_register_url); |
| 31 |
} |
| 32 |
|
| 33 |
|
| 34 |
function wpforo_lostpass_url(){ |
| 35 |
if(isset(WPF()->member->options['lost_password_url']) && WPF()->member->options['lost_password_url']){ |
| 36 |
$wp_lostpass_url = trim(get_bloginfo('url') , '/') . '/' . ltrim(WPF()->member->options['lost_password_url'] , '/'); |
| 37 |
} |
| 38 |
else{ |
| 39 |
$wp_lostpass_url = wp_lostpassword_url( wpforo_get_request_uri() ); |
| 40 |
} |
| 41 |
return esc_url($wp_lostpass_url); |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
function wpforo_menu_filter( $items, $menu ) { |
| 46 |
if ( !wpforo_is_admin() ) { |
| 47 |
foreach ( $items as $key => $item ) { |
| 48 |
if(isset($item->url)){ |
| 49 |
if( strpos($item->url, '%wpforo-') !== FALSE ){ |
| 50 |
$shortcode = trim(str_replace(array('https://', 'http://', '/', '%'), '', $item->url)); |
| 51 |
if(isset(WPF()->menu) && isset(WPF()->menu[$shortcode])){ |
| 52 |
if(isset(WPF()->menu[$shortcode]['href'])) $item->url = WPF()->menu[$shortcode]['href']; |
| 53 |
if(isset(WPF()->menu[$shortcode]['attr']) && strpos(WPF()->menu[$shortcode]['attr'], 'wpforo-active') !== FALSE ) $item->classes[] = 'wpforo-active'; |
| 54 |
} |
| 55 |
else{ |
| 56 |
unset($items[$key]); |
| 57 |
} |
| 58 |
} |
| 59 |
} |
| 60 |
} |
| 61 |
} |
| 62 |
return $items; |
| 63 |
} |
| 64 |
add_filter( 'wp_get_nav_menu_items', 'wpforo_menu_filter', 1, 2 ); |
| 65 |
|
| 66 |
function wpforo_menu_nofollow_items($item_output, $item, $depth, $args) { |
| 67 |
//if( isset($item->url) && strpos($item->url, '?wpforo') !== FALSE ) { |
| 68 |
//$item_output = str_replace('<a ', '<a rel="nofollow" ', $item_output); |
| 69 |
//} |
| 70 |
return $item_output; |
| 71 |
} |
| 72 |
add_filter('walker_nav_menu_start_el', 'wpforo_menu_nofollow_items', 1, 4); |
| 73 |
|
| 74 |
function wpforo_profile_plugin_menu( $userid = 0 ){ |
| 75 |
|
| 76 |
$menu_html = '<div class="wpf-profile-plugin-menu">'; |
| 77 |
|
| 78 |
$forum_profile = false; |
| 79 |
if($url = wpforo_has_shop_plugin($userid)){ |
| 80 |
$forum_profile = true; |
| 81 |
$menu_html .= '<div id="wpf-pp-shop-menu" class="wpf-pp-menu"> |
| 82 |
<a class="wpf-pp-menu-item" href="' . esc_url($url) . '"> |
| 83 |
<i class="fas fa-shopping-cart" title="'.wpforo_phrase('Shop Account', false).'"></i> <span>'.wpforo_phrase('Shop Account', false).'</span> |
| 84 |
</a> |
| 85 |
</div>'; |
| 86 |
} |
| 87 |
if($url = wpforo_has_profile_plugin($userid)){ |
| 88 |
$forum_profile = true; |
| 89 |
$menu_html .= '<div id="wpf-pp-site-menu" class="wpf-pp-menu"> |
| 90 |
<a class="wpf-pp-menu-item" href="' . esc_url($url) . '"> |
| 91 |
<i class="fas fa-user" title="'.wpforo_phrase('Site Profile', false).'"></i> <span>'.wpforo_phrase('Site Profile', false).'</span> |
| 92 |
</a> |
| 93 |
</div>'; |
| 94 |
} |
| 95 |
if( $forum_profile ) { |
| 96 |
$menu_html .= '<div id="wpf-pp-forum-menu" class="wpf-pp-menu"> |
| 97 |
<div class="wpf-pp-menu-item"> |
| 98 |
<i class="fas fa-comments" title="' . wpforo_phrase('Forum Profile', false) . '"></i> <span>' . wpforo_phrase('Forum Profile', false) . '</span> |
| 99 |
</div> |
| 100 |
</div>'; |
| 101 |
$menu_html .= "\r\n<div class=\"wpf-clear\"></div>\r\n</div>"; |
| 102 |
$menu_html = apply_filters( 'wpforo_profile_plugin_menu_filter', $menu_html, $userid ); |
| 103 |
echo $menu_html; //This is a HTML content// |
| 104 |
} |
| 105 |
} |
| 106 |
add_action( 'wpforo_profile_plugin_menu_action', 'wpforo_profile_plugin_menu', 1 ); |
| 107 |
|
| 108 |
class wpforo_menu_walker extends Walker_Nav_Menu { |
| 109 |
public function start_lvl( &$output, $depth = 0, $args = array() ) { |
| 110 |
$indent = str_repeat("\t", $depth); |
| 111 |
$output .= "\n$indent<ul class=\"sub-menu\">\n"; |
| 112 |
} |
| 113 |
public function end_lvl( &$output, $depth = 0, $args = array() ) { |
| 114 |
$indent = str_repeat("\t", $depth); |
| 115 |
$output .= "$indent</ul>\n"; |
| 116 |
} |
| 117 |
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { |
| 118 |
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; |
| 119 |
$classes = empty( $item->classes ) ? array() : (array) $item->classes; |
| 120 |
$classes[] = 'menu-item-' . $item->ID; |
| 121 |
$args = apply_filters( 'wpforo_nav_menu_item_args', $args, $item, $depth ); |
| 122 |
$class_names = join( ' ', apply_filters( 'wpforo_nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) ); |
| 123 |
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; |
| 124 |
$id = apply_filters( 'wpforo_nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args, $depth ); |
| 125 |
$id = $id ? ' id="' . esc_attr( $id ) . '"' : ''; |
| 126 |
$output .= $indent . '<li' . $id . $class_names .'>'; |
| 127 |
$atts = array(); |
| 128 |
$atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : ''; |
| 129 |
$atts['target'] = ! empty( $item->target ) ? $item->target : ''; |
| 130 |
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : ''; |
| 131 |
$atts['href'] = ! empty( $item->url ) ? $item->url : ''; |
| 132 |
$atts = apply_filters( 'wpforo_nav_menu_link_attributes', $atts, $item, $args, $depth ); |
| 133 |
$attributes = ''; |
| 134 |
foreach ( $atts as $attr => $value ) { |
| 135 |
if ( ! empty( $value ) ) { |
| 136 |
$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value ); |
| 137 |
$attributes .= ' ' . $attr . '="' . $value . '"'; |
| 138 |
} |
| 139 |
} |
| 140 |
$title = apply_filters( 'wpforo_the_title', $item->title, $item->ID ); |
| 141 |
$title = apply_filters( 'wpforo_nav_menu_item_title', $title, $item, $args, $depth ); |
| 142 |
$item_output = $args->before; |
| 143 |
$item_output .= '<a'. $attributes .'>'; |
| 144 |
$item_output .= $args->link_before . $title . $args->link_after; |
| 145 |
$item_output .= '</a>'; |
| 146 |
$item_output .= $args->after; |
| 147 |
$output .= apply_filters( 'wpforo_walker_nav_menu_start_el', $item_output, $item, $depth, $args ); |
| 148 |
} |
| 149 |
public function end_el( &$output, $item, $depth = 0, $args = array() ) { |
| 150 |
$output .= "</li>"; |
| 151 |
} |
| 152 |
} |
| 153 |
|
| 154 |
function wpforo_widgets_init() { |
| 155 |
register_sidebar(array( |
| 156 |
'name' => __('wpForo Sidebar', 'wpforo'), |
| 157 |
'description' => __("NOTE: If you're going to add widgets in this sidebar, please use 'Full Width' template for wpForo index page to avoid sidebar duplication.", 'wpforo'), |
| 158 |
'id' => 'forum-sidebar', |
| 159 |
'before_widget' => '<aside id="%1$s" class="footer-widget-col %2$s clearfix">', |
| 160 |
'after_widget' => '</aside>', |
| 161 |
'before_title' => '<h3 class="widget-title">', |
| 162 |
'after_title' => '</h3>', |
| 163 |
)); |
| 164 |
} |
| 165 |
add_action('widgets_init', 'wpforo_widgets_init', 11); |
| 166 |
|
| 167 |
class wpForo_Widget_search extends WP_Widget { |
| 168 |
function __construct() { |
| 169 |
parent::__construct( |
| 170 |
'wpForo_Widget_search', // Base ID |
| 171 |
'wpForo Search', // Name |
| 172 |
array( 'description' => 'wpForo search form' ) // Args |
| 173 |
); |
| 174 |
} |
| 175 |
public function widget( $args, $instance ) { |
| 176 |
echo $args['before_widget']; //This is a HTML content// |
| 177 |
echo '<div id="wpf-widget-search" class="wpforo-widget-wrap">'; |
| 178 |
if ( ! empty( $instance['title'] ) ) { |
| 179 |
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title']; //This is a HTML content// |
| 180 |
} |
| 181 |
echo '<div class="wpforo-widget-content">'; |
| 182 |
?> |
| 183 |
<form action="<?php echo wpforo_home_url() ?>" method="get"> |
| 184 |
<?php wpforo_make_hidden_fields_from_url( wpforo_home_url() ) ?> |
| 185 |
<input type="text" placeholder="<?php wpforo_phrase('Search...') ?>" name="wpfs" class="wpfw-70" value="<?php echo isset($_GET['wpfs']) ? esc_attr(sanitize_text_field($_GET['wpfs'])) : '' ?>" ><input type="submit" class="wpfw-20" value="»"> |
| 186 |
</form> |
| 187 |
<?php |
| 188 |
echo '</div></div>'; |
| 189 |
echo $args['after_widget']; //This is a HTML content// |
| 190 |
} |
| 191 |
public function form( $instance ) { |
| 192 |
$title = isset( $instance['title'] ) ? $instance['title'] : 'Forum Search'; |
| 193 |
?> |
| 194 |
<p> |
| 195 |
<label><?php _e('Title', 'wpforo'); ?>:</label> |
| 196 |
<input class="widefat" name="<?php echo esc_attr($this->get_field_name( 'title' )); ?>" type="text" value="<?php echo esc_attr( $title ); ?>"> |
| 197 |
</p> |
| 198 |
<?php |
| 199 |
} |
| 200 |
public function update( $new_instance, $old_instance ) { |
| 201 |
$instance = array(); |
| 202 |
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; |
| 203 |
return $instance; |
| 204 |
} |
| 205 |
} // widget wpforo search |
| 206 |
|
| 207 |
class wpForo_Widget_login_form extends WP_Widget { |
| 208 |
function __construct() { |
| 209 |
parent::__construct( |
| 210 |
'wpForo_Widget_login_form', // Base ID |
| 211 |
'wpForo Login Form', // Name |
| 212 |
array( 'description' => 'wpForo login form' ) // Args |
| 213 |
); |
| 214 |
} |
| 215 |
public function widget( $args, $instance ) { |
| 216 |
echo $args['before_widget']; //This is a HTML content// |
| 217 |
echo '<div id="wpf-widget-login" class="wpforo-widget-wrap">'; |
| 218 |
if ( ! empty( $instance['title'] ) ) { |
| 219 |
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title']; //This is a HTML content// |
| 220 |
} |
| 221 |
echo '<div class="wpforo-widget-content">'; |
| 222 |
?> |
| 223 |
<?php if( is_user_logged_in() && !empty(WPF()->current_user) ) : ?> |
| 224 |
<?php extract(WPF()->current_object, EXTR_OVERWRITE); extract(WPF()->current_user, EXTR_OVERWRITE); ?> |
| 225 |
<div class="wpforo-profile-wrap"> |
| 226 |
<div class="wpforo-profile-head"> |
| 227 |
<div class="h-header"> |
| 228 |
<?php if( WPF()->perm->usergroup_can('va') && wpforo_feature('avatars') ): $rsz =''; ?> |
| 229 |
<div class="h-left"><?php echo WPF()->member->get_avatar($userid, 'alt="'.esc_attr($display_name).'"', 150); ?></div> |
| 230 |
<?php else: $rsz = ' style="margin-left:10px;"'; endif; ?> |
| 231 |
<div class="h-right" <?php echo $rsz; ?>> |
| 232 |
<div class="h-top"> |
| 233 |
<div class="profile-display-name"> |
| 234 |
<?php WPF()->member->show_online_indicator($userid) ?> |
| 235 |
<?php echo $display_name ? esc_html($display_name) : esc_html(urldecode($user_nicename)) ?> |
| 236 |
</div> |
| 237 |
<div class="profile-stat-data"> |
| 238 |
<div class="profile-stat-data-item"><?php wpforo_phrase('Group') ?>: <?php wpforo_phrase($groupname) ?></div> |
| 239 |
<div class="profile-stat-data-item"><?php wpforo_phrase('Joined') ?>: <?php esc_html(wpforo_date($user_registered, 'Y/m/d')) ?></div> |
| 240 |
</div> |
| 241 |
</div> |
| 242 |
</div> |
| 243 |
<div class="wpf-clear"></div> |
| 244 |
</div> |
| 245 |
<div class="h-footer wpfbg-2"> |
| 246 |
|
| 247 |
<div class="h-bottom"> |
| 248 |
<?php WPF()->tpl->member_menu($userid) ?> |
| 249 |
<a href="?wpforo=logout"><?php wpforo_phrase('logout') ?></a> |
| 250 |
<div class="wpf-clear"></div> |
| 251 |
</div> |
| 252 |
</div> |
| 253 |
</div> |
| 254 |
</div> |
| 255 |
|
| 256 |
<?php else : ?> |
| 257 |
|
| 258 |
<form name="wpflogin" action="" method="POST"> |
| 259 |
<div class="wpforo-login-wrap"> |
| 260 |
<div class="wpforo-login-content"> |
| 261 |
<table class="wpforo-login-table wpfcl-1" width="100%" border="0" cellspacing="0" cellpadding="0"> |
| 262 |
<tr class="wpfbg-9"> |
| 263 |
<td class="wpf-login-label"> |
| 264 |
<p class="wpf-label wpfcl-1"><?php wpforo_phrase('Username') ?>:</p> |
| 265 |
</td> |
| 266 |
<td class="wpf-login-field"><input autofocus required="TRUE" type="text" name="log" class="wpf-login-text wpfw-60" /></td> |
| 267 |
</tr> |
| 268 |
<tr class="wpfbg-9"> |
| 269 |
<td class="wpf-login-label"> |
| 270 |
<p class="wpf-label wpfcl-1"><?php wpforo_phrase('Password') ?>:</p> |
| 271 |
</td> |
| 272 |
<td class="wpf-login-field"><input required="TRUE" type="password" name="pwd" class="wpf-login-text wpfw-60" /></td> |
| 273 |
</tr> |
| 274 |
<tr class="wpfbg-9"><td colspan="2" style="text-align: center;"><?php do_action('login_form') ?></td></tr> |
| 275 |
<tr class="wpfbg-9"> |
| 276 |
<td class="wpf-login-label"> </td> |
| 277 |
<td class="wpf-login-field"> |
| 278 |
<p class="wpf-extra wpfcl-1"> |
| 279 |
<input type="checkbox" value="1" name="rememberme" id="wpf-login-remember"> |
| 280 |
<label for="wpf-login-remember"><?php wpforo_phrase('Remember Me') ?> |</label> |
| 281 |
<a href="<?php echo esc_url(wp_lostpassword_url(wpforo_get_request_uri())); ?>" class="wpf-forgot-pass"><?php wpforo_phrase('Lost your password?') ?></a> |
| 282 |
<a href="<?php echo esc_url( wpforo_home_url('?wpforo=register') ) ?>"><?php wpforo_phrase('register') ?></a> |
| 283 |
</p> |
| 284 |
<input type="submit" name="wpforologin" value="<?php wpforo_phrase('Sign In') ?>" /> |
| 285 |
</td> |
| 286 |
</tr> |
| 287 |
</table> |
| 288 |
</div> |
| 289 |
</div> |
| 290 |
</form> |
| 291 |
|
| 292 |
<?php endif ?> |
| 293 |
<?php |
| 294 |
echo '</div></div>'; |
| 295 |
echo $args['after_widget']; |
| 296 |
} |
| 297 |
public function form( $instance ) { |
| 298 |
$title = isset( $instance['title'] ) ? $instance['title'] : 'Account'; |
| 299 |
?> |
| 300 |
<p> |
| 301 |
<label><?php _e('Title', 'wpforo'); ?>:</label> |
| 302 |
<input class="widefat" name="<?php echo esc_attr($this->get_field_name( 'title' )); ?>" type="text" value="<?php echo esc_attr( $title ); ?>"> |
| 303 |
</p> |
| 304 |
<?php |
| 305 |
} |
| 306 |
public function update( $new_instance, $old_instance ) { |
| 307 |
$instance = array(); |
| 308 |
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; |
| 309 |
return $instance; |
| 310 |
} |
| 311 |
} // widget wpforo login |
| 312 |
|
| 313 |
|
| 314 |
class wpForo_Widget_online_members extends WP_Widget { |
| 315 |
function __construct() { |
| 316 |
parent::__construct( |
| 317 |
'wpForo_Widget_online_members', // Base ID |
| 318 |
'wpForo Online Members', // Name |
| 319 |
array( 'description' => 'Online members.' ) // Args |
| 320 |
); |
| 321 |
} |
| 322 |
public function widget( $args, $instance ) { |
| 323 |
echo $args['before_widget']; //This is a HTML content// |
| 324 |
echo '<div id="wpf-widget-online-users" class="wpforo-widget-wrap">'; |
| 325 |
if ( ! empty( $instance['title'] ) ) { |
| 326 |
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title']; |
| 327 |
} |
| 328 |
// widget content from front end |
| 329 |
$online_members = WPF()->member->get_online_members($instance['count']); |
| 330 |
echo '<div class="wpforo-widget-content">'; |
| 331 |
if(!empty($online_members)){ |
| 332 |
echo '<ul> |
| 333 |
<li> |
| 334 |
<div class="wpforo-list-item">'; |
| 335 |
foreach( $online_members as $member ){ |
| 336 |
if( $instance['display_avatar'] ): ?> |
| 337 |
<a href="<?php echo esc_url(WPF()->member->get_profile_url( $member['ID'] )) ?>" class="onlineavatar"> |
| 338 |
<?php echo WPF()->member->get_avatar( $member['ID'], 'style="width:95%;" class="avatar" title="'.esc_attr($member['display_name']).'"'); ?> |
| 339 |
</a> |
| 340 |
<?php else: ?> |
| 341 |
<a href="<?php echo esc_url(WPF()->member->get_profile_url( $member['ID'] )) ?>" class="onlineuser"><?php echo esc_html($member['display_name']) ?></a> |
| 342 |
<?php endif; ?> |
| 343 |
<?php |
| 344 |
} |
| 345 |
echo '<div class="wpf-clear"></div> |
| 346 |
</div> |
| 347 |
</li> |
| 348 |
</ul> |
| 349 |
</div>'; |
| 350 |
} |
| 351 |
else{ |
| 352 |
echo '<p class="wpf-widget-note"> '.wpforo_phrase('No online members at the moment', false).'</p>'; |
| 353 |
} |
| 354 |
echo '</div>'; |
| 355 |
echo $args['after_widget'];//This is a HTML content// |
| 356 |
} |
| 357 |
public function form( $instance ) { |
| 358 |
$title = ! empty( $instance['title'] ) ? $instance['title'] : 'Online Members'; |
| 359 |
$count = ! empty( $instance['count'] ) ? $instance['count'] : '15'; |
| 360 |
$display_avatar = isset( $instance['display_avatar'] ) ? (bool) $instance['display_avatar'] : false; |
| 361 |
?> |
| 362 |
<p> |
| 363 |
<label><?php _e('Title', 'wpforo'); ?>:</label> |
| 364 |
<input class="widefat" name="<?php echo esc_attr($this->get_field_name( 'title' )); ?>" type="text" value="<?php echo esc_attr( $title ); ?>"> |
| 365 |
</p><p> |
| 366 |
<label><?php _e('Number of Items', 'wpforo'); ?></label> |
| 367 |
<input type="number" min="1" style="width: 53px;" name="<?php echo esc_attr($this->get_field_name( 'count' )); ?>" value="<?php echo esc_attr( $count ) ; ?>"> |
| 368 |
</p><p> |
| 369 |
<label> |
| 370 |
<input<?php checked( $display_avatar ); ?> type="checkbox" value="1" name="<?php echo esc_attr( $this->get_field_name( 'display_avatar' )); ?>"/> |
| 371 |
<?php _e('Display Avatars', 'wpforo'); ?> |
| 372 |
</label> |
| 373 |
</p> |
| 374 |
<?php |
| 375 |
} |
| 376 |
public function update( $new_instance, $old_instance ) { |
| 377 |
$instance = array(); |
| 378 |
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; |
| 379 |
$instance['count'] = ( ! empty( $new_instance['count'] ) ) ? intval( $new_instance['count'] ) : ''; |
| 380 |
$instance['display_avatar'] = isset( $new_instance['display_avatar'] ) ? (bool) $new_instance['display_avatar'] : false; |
| 381 |
return $instance; |
| 382 |
} |
| 383 |
} // widget online members |
| 384 |
|
| 385 |
class wpForo_Widget_recent_topics extends WP_Widget { |
| 386 |
private $orderby_fields = array(); |
| 387 |
private $order_fields = array(); |
| 388 |
function __construct() { |
| 389 |
parent::__construct( |
| 390 |
'wpForo_Widget_recent_topics', // Base ID |
| 391 |
'wpForo Recent Topics', // Name |
| 392 |
array( 'description' => 'Your forum\'s recent topics.' ) // Args |
| 393 |
); |
| 394 |
$this->init_local_vars(); |
| 395 |
} |
| 396 |
|
| 397 |
private function init_local_vars(){ |
| 398 |
$this->orderby_fields = array( |
| 399 |
'created' => __('Created Date', 'wpforo'), |
| 400 |
'modified' => __('Modified Date', 'wpforo'), |
| 401 |
'posts' => __('Posts Count', 'wpforo'), |
| 402 |
'views' => __('Views Count', 'wpforo') |
| 403 |
); |
| 404 |
$this->order_fields = array( |
| 405 |
'DESC' => __('DESC', 'wpforo'), |
| 406 |
'ASC' => __('ASC', 'wpforo') |
| 407 |
); |
| 408 |
} |
| 409 |
|
| 410 |
public function widget( $args, $instance ) { |
| 411 |
echo $args['before_widget'];//This is a HTML content// |
| 412 |
echo '<div id="wpf-widget-recent-replies" class="wpforo-widget-wrap">'; |
| 413 |
if ( ! empty( $instance['title'] ) ) { |
| 414 |
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title'];//This is a HTML content// |
| 415 |
} |
| 416 |
// widget content from front end |
| 417 |
$private = (!is_user_logged_in() || !WPF()->perm->usergroup_can('aum')) ? 0 : NULL; |
| 418 |
$status = (!is_user_logged_in() || !WPF()->perm->usergroup_can('aum')) ? 0 : NULL; |
| 419 |
$topic_args = array( // forumid, order, parentid |
| 420 |
'orderby' => (key_exists($instance['orderby'], $this->orderby_fields) ? $instance['orderby'] : 'created' ), |
| 421 |
'order' => (key_exists($instance['order'], $this->order_fields) ? $instance['order'] : 'DESC' ), // ASC DESC |
| 422 |
'row_count' => $instance['count'], // 4 or 1 ... |
| 423 |
'private' => $private, |
| 424 |
'status' => $status |
| 425 |
); |
| 426 |
$topics = WPF()->topic->get_topics_filtered($topic_args); |
| 427 |
$ug_can_va = WPF()->perm->usergroup_can('va'); |
| 428 |
$is_avatar = wpforo_feature('avatars'); |
| 429 |
echo '<div class="wpforo-widget-content"><ul>'; |
| 430 |
foreach( $topics as $topic ){ |
| 431 |
$topic_url = wpforo_topic($topic['topicid'], 'url'); |
| 432 |
$member = wpforo_member($topic); |
| 433 |
?> |
| 434 |
<li> |
| 435 |
<div class="wpforo-list-item"> |
| 436 |
<?php if( $instance['display_avatar'] ): ?> |
| 437 |
<?php if( $ug_can_va && $is_avatar ): ?> |
| 438 |
<div class="wpforo-list-item-left"> |
| 439 |
<?php echo WPF()->member->avatar($member); ?> |
| 440 |
</div> |
| 441 |
<?php endif; ?> |
| 442 |
<?php endif; ?> |
| 443 |
<div class="wpforo-list-item-right" <?php if( !$instance['display_avatar'] ): ?> style="width:100%"<?php endif; ?>> |
| 444 |
<p class="posttitle"><a href="<?php echo esc_url($topic_url) ?>"><?php echo esc_html($topic['title']) ?></a></p> |
| 445 |
<p class="postuser"><?php wpforo_phrase('by') ?> <?php wpforo_member_link($member) ?>, <span style="white-space:nowrap;"><?php esc_html(wpforo_date($topic['created'])) ?></span></p> |
| 446 |
</div> |
| 447 |
<div class="wpf-clear"></div> |
| 448 |
</div> |
| 449 |
</li> |
| 450 |
<?php |
| 451 |
} |
| 452 |
echo '</ul></div>'; |
| 453 |
echo '</div>'; |
| 454 |
echo $args['after_widget'];//This is a HTML content// |
| 455 |
} |
| 456 |
public function form( $instance ) { |
| 457 |
$title = ! empty( $instance['title'] ) ? $instance['title'] : 'Recent Topics'; |
| 458 |
$orderby = ! empty( $instance['orderby'] ) ? $instance['orderby'] : 'created'; |
| 459 |
$order = ! empty( $instance['order'] ) ? $instance['order'] : 'DESC'; |
| 460 |
$count = ! empty( $instance['count'] ) ? $instance['count'] : '9'; |
| 461 |
$display_avatar = isset( $instance['display_avatar'] ) ? (bool) $instance['display_avatar'] : false; |
| 462 |
?> |
| 463 |
<p> |
| 464 |
<label><?php _e('Title', 'wpforo'); ?>:</label> |
| 465 |
<input class="widefat" name="<?php echo esc_attr($this->get_field_name( 'title' )); ?>" type="text" value="<?php echo esc_attr( $title ); ?>"> |
| 466 |
</p> |
| 467 |
<p> |
| 468 |
<label for="orderby"><?php _e('Order by', 'wpforo'); ?>:</label> |
| 469 |
<select name="<?php echo esc_attr($this->get_field_name( 'orderby' )); ?>" id="orderby"> |
| 470 |
<?php foreach ($this->orderby_fields as $orderby_key => $orderby_field ) : ?> |
| 471 |
<option value="<?php echo $orderby_key; ?>"<?php echo ( $orderby_key == $orderby ? ' selected' : '' ); ?>><?php echo $orderby_field; ?></option> |
| 472 |
<?php endforeach; ?> |
| 473 |
</select> |
| 474 |
<select name="<?php echo esc_attr($this->get_field_name( 'order' )); ?>"> |
| 475 |
<?php foreach ($this->order_fields as $order_key => $order_field ) : ?> |
| 476 |
<option value="<?php echo $order_key; ?>"<?php echo ( $order_key == $order ? ' selected' : '' ); ?>><?php echo $order_field; ?></option> |
| 477 |
<?php endforeach; ?> |
| 478 |
</select> |
| 479 |
</p> |
| 480 |
<p> |
| 481 |
<label><?php _e('Number of Items', 'wpforo'); ?></label> |
| 482 |
<input type="number" min="1" style="width: 53px;" name="<?php echo esc_attr($this->get_field_name( 'count' )); ?>" value="<?php echo esc_attr($count) ; ?>"> |
| 483 |
</p><p> |
| 484 |
<label><input <?php checked( $display_avatar ); ?> type="checkbox" name="<?php echo esc_attr($this->get_field_name( 'display_avatar' )); ?>" > |
| 485 |
<?php _e('Display with Avatars', 'wpforo'); ?></label> |
| 486 |
</p> |
| 487 |
<?php |
| 488 |
} |
| 489 |
public function update( $new_instance, $old_instance ) { |
| 490 |
$instance = array(); |
| 491 |
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; |
| 492 |
$instance['orderby'] = ( !empty($new_instance['orderby']) && key_exists($new_instance['orderby'], $this->orderby_fields) ) ? $new_instance['orderby'] : ''; |
| 493 |
$instance['order'] = ( !empty($new_instance['order']) && key_exists($new_instance['order'], $this->order_fields) ) ? $new_instance['order'] : ''; |
| 494 |
$instance['count'] = ( ! empty( $new_instance['count'] ) ) ? intval( $new_instance['count'] ) : ''; |
| 495 |
$instance['display_avatar'] = isset( $new_instance['display_avatar'] ) ? (bool) $new_instance['display_avatar'] : false; |
| 496 |
return $instance; |
| 497 |
} |
| 498 |
} // Recent topics |
| 499 |
|
| 500 |
|
| 501 |
class wpForo_Widget_recent_replies extends WP_Widget { |
| 502 |
function __construct() { |
| 503 |
parent::__construct( |
| 504 |
'wpForo_Widget_recent_replies', // Base ID |
| 505 |
'wpForo Recent Posts', // Name |
| 506 |
array( 'description' => 'Your forum\'s recent posts.' ) // Args |
| 507 |
); |
| 508 |
} |
| 509 |
|
| 510 |
public function widget( $args, $instance ) { |
| 511 |
echo $args['before_widget'];//This is a HTML content// |
| 512 |
echo '<div id="wpf-widget-recent-replies" class="wpforo-widget-wrap">'; |
| 513 |
if ( ! empty( $instance['title'] ) ) { |
| 514 |
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title'];//This is a HTML content// |
| 515 |
} |
| 516 |
$private = (!is_user_logged_in() || !WPF()->perm->usergroup_can('aum')) ? 0 : NULL; |
| 517 |
$status = (!is_user_logged_in() || !WPF()->perm->usergroup_can('aum')) ? 0 : NULL; |
| 518 |
// widget content from front end |
| 519 |
$posts_args = array( |
| 520 |
'orderby' => 'created', |
| 521 |
'order' => 'DESC', |
| 522 |
'row_count' => $instance['count'], |
| 523 |
'private' => $private, |
| 524 |
'status' => $status |
| 525 |
); |
| 526 |
$recent_posts = WPF()->post->get_posts_filtered($posts_args); |
| 527 |
$ug_can_va = WPF()->perm->usergroup_can('va'); |
| 528 |
$is_avatar = wpforo_feature('avatars'); |
| 529 |
echo '<div class="wpforo-widget-content"><ul>'; |
| 530 |
foreach( $recent_posts as $post ){ |
| 531 |
$post_url = wpforo_post( $post['postid'], 'url' ); |
| 532 |
$member = wpforo_member( $post ); |
| 533 |
?> |
| 534 |
<li> |
| 535 |
<div class="wpforo-list-item"> |
| 536 |
<?php if( $instance['display_avatar'] ): ?> |
| 537 |
<?php if( $ug_can_va && $is_avatar ): ?> |
| 538 |
<div class="wpforo-list-item-left"> |
| 539 |
<?php echo WPF()->member->avatar($member); ?> |
| 540 |
</div> |
| 541 |
<?php endif; ?> |
| 542 |
<?php endif; ?> |
| 543 |
<div class="wpforo-list-item-right" <?php if( !$instance['display_avatar'] ): ?> style="width:100%"<?php endif; ?>> |
| 544 |
<p class="posttitle"><a href="<?php echo esc_url($post_url) ?>"><?php echo esc_html($post['title']) ?></a></p> |
| 545 |
<p class="posttext"><?php echo esc_html(wpforo_text($post['body'], 55)); ?></p> |
| 546 |
<p class="postuser"><?php wpforo_phrase('by') ?> <?php wpforo_member_link($member) ?>, <?php esc_html(wpforo_date($post['created'])) ?></p> |
| 547 |
</div> |
| 548 |
<div class="wpf-clear"></div> |
| 549 |
</div> |
| 550 |
</li> |
| 551 |
<?php |
| 552 |
} |
| 553 |
echo '</ul></div>'; |
| 554 |
echo '</div>'; |
| 555 |
echo $args['after_widget'];//This is a HTML content// |
| 556 |
} |
| 557 |
public function form( $instance ) { |
| 558 |
$title = ! empty( $instance['title'] ) ? $instance['title'] : 'Recent Posts'; |
| 559 |
$count = ! empty( $instance['count'] ) ? $instance['count'] : '9'; |
| 560 |
$display_avatar = isset( $instance['display_avatar'] ) ? (bool) $instance['display_avatar'] : false; |
| 561 |
?> |
| 562 |
<p> |
| 563 |
<label><?php _e('Title', 'wpforo'); ?>:</label> |
| 564 |
<input class="widefat" name="<?php echo esc_attr($this->get_field_name( 'title' )); ?>" type="text" value="<?php echo esc_attr( $title ); ?>"> |
| 565 |
</p><p> |
| 566 |
<label><?php _e('Number of Items', 'wpforo'); ?></label> |
| 567 |
<input type="number" min="1" style="width: 53px;" name="<?php echo esc_attr($this->get_field_name( 'count' )); ?>" value="<?php echo esc_attr($count) ; ?>"> |
| 568 |
</p><p> |
| 569 |
<label><input <?php checked( $display_avatar ); ?> type="checkbox" name="<?php echo esc_attr($this->get_field_name( 'display_avatar' )); ?>" > |
| 570 |
<?php _e('Display with Avatars', 'wpforo'); ?></label> |
| 571 |
</p> |
| 572 |
<?php |
| 573 |
} |
| 574 |
public function update( $new_instance, $old_instance ) { |
| 575 |
$instance = array(); |
| 576 |
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; |
| 577 |
$instance['count'] = ( ! empty( $new_instance['count'] ) ) ? intval( $new_instance['count'] ) : ''; |
| 578 |
$instance['display_avatar'] = isset( $new_instance['display_avatar'] ) ? (bool) $new_instance['display_avatar'] : false; |
| 579 |
return $instance; |
| 580 |
} |
| 581 |
} // Recent replies |
| 582 |
|
| 583 |
|
| 584 |
class wpforo_widget_forums extends WP_Widget { |
| 585 |
function __construct() { |
| 586 |
parent::__construct( |
| 587 |
'wpforo_widget_forums', // Base ID |
| 588 |
'wpForo Forums', // Name |
| 589 |
array( 'description' => 'Forum tree.' ) // Args |
| 590 |
); |
| 591 |
} |
| 592 |
public function widget( $args, $instance ) { |
| 593 |
echo $args['before_widget'];//This is a HTML content// |
| 594 |
echo '<div id="wpf-widget-forums" class="wpforo-widget-wrap">'; |
| 595 |
if ( ! empty( $instance['title'] ) ) { |
| 596 |
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title'];//This is a HTML content// |
| 597 |
} |
| 598 |
echo '<div class="wpforo-widget-content">'; |
| 599 |
WPF()->forum->tree('front_list'); |
| 600 |
echo '</div>'; |
| 601 |
echo '</div>'; |
| 602 |
echo $args['after_widget'];//This is a HTML content// |
| 603 |
} |
| 604 |
public function form( $instance ) { |
| 605 |
$title = ! empty( $instance['title'] ) ? $instance['title'] : 'Forums'; |
| 606 |
$display_avatar = isset( $instance['display_avatar'] ) ? (bool) $instance['display_avatar'] : false; |
| 607 |
?> |
| 608 |
<p> |
| 609 |
<label><?php _e('Title', 'wpforo'); ?>:</label> |
| 610 |
<input class="widefat" name="<?php echo esc_attr($this->get_field_name( 'title' )); ?>" type="text" value="<?php echo esc_attr( $title ); ?>"> |
| 611 |
</p> |
| 612 |
<?php |
| 613 |
} |
| 614 |
public function update( $new_instance, $old_instance ) { |
| 615 |
$instance = array(); |
| 616 |
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; |
| 617 |
return $instance; |
| 618 |
} |
| 619 |
} // forums tree |
| 620 |
|
| 621 |
|
| 622 |
function wpforo_widget_search() { |
| 623 |
register_widget( 'wpForo_Widget_search' ); |
| 624 |
} |
| 625 |
add_action( 'widgets_init', 'wpforo_widget_search' ); |
| 626 |
|
| 627 |
function wpforo_widget_login() { |
| 628 |
//Under development.... |
| 629 |
//register_widget( 'wpForo_Widget_login_form' ); |
| 630 |
} |
| 631 |
add_action( 'widgets_init', 'wpforo_widget_login' ); |
| 632 |
|
| 633 |
function wpforo_widget_online_members() { |
| 634 |
register_widget( 'wpForo_Widget_online_members' ); |
| 635 |
} |
| 636 |
add_action( 'widgets_init', 'wpforo_widget_online_members' ); |
| 637 |
|
| 638 |
function wpforo_widget_recent_topics() { |
| 639 |
register_widget( 'wpForo_Widget_recent_topics' ); |
| 640 |
} |
| 641 |
add_action( 'widgets_init', 'wpforo_widget_recent_topics' ); |
| 642 |
|
| 643 |
function wpforo_widget_recent_replies() { |
| 644 |
register_widget( 'wpForo_Widget_recent_replies' ); |
| 645 |
} |
| 646 |
add_action( 'widgets_init', 'wpforo_widget_recent_replies' ); |
| 647 |
|
| 648 |
function wpforo_widget_forums() { |
| 649 |
//Under Development |
| 650 |
//register_widget( 'wpforo_widget_forums' ); |
| 651 |
} |
| 652 |
add_action( 'widgets_init', 'wpforo_widget_forums' ); |
| 653 |
|
| 654 |
function wpforo_post_edited($post, $echo = true){ |
| 655 |
$edit_html = ''; |
| 656 |
if(!empty($post)){ |
| 657 |
$created = wpforo_date($post['created'], 'd/m/Y g:i a', false); |
| 658 |
$modified = wpforo_date($post['modified'], 'd/m/Y g:i a', false); |
| 659 |
if( isset($modified) && $created != $modified ){ |
| 660 |
$edit_html = '<div class="wpf-post-edited">' . wpforo_phrase('Edited: ', false) . wpforo_date($post['modified'], 'ago', false) . '</div>'; |
| 661 |
} |
| 662 |
} |
| 663 |
if( $echo ) { |
| 664 |
echo $edit_html; |
| 665 |
} |
| 666 |
else{ |
| 667 |
return $edit_html; |
| 668 |
} |
| 669 |
} |
| 670 |
|
| 671 |
function wpforo_hide_title($title, $id = 0) { |
| 672 |
if( !wpforo_feature('page-title') ){ |
| 673 |
if( $wpforo_base_slug = basename( wpforo_home_url() ) ) $wpforo_page = get_page_by_path($wpforo_base_slug); |
| 674 |
if(!empty($wpforo_page)){ |
| 675 |
if (in_the_loop() && is_page($wpforo_page->ID) && $id == get_the_ID()) { |
| 676 |
$title = ''; |
| 677 |
} |
| 678 |
} |
| 679 |
} |
| 680 |
return $title; |
| 681 |
} |
| 682 |
add_filter('the_title', 'wpforo_hide_title', 10, 2); |
| 683 |
|
| 684 |
|
| 685 |
function wpforo_validate_gravatar( $email ) { |
| 686 |
$hashkey = md5(strtolower(trim($email))); |
| 687 |
$uri = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404'; |
| 688 |
$data = wp_cache_get($hashkey); |
| 689 |
if (false === $data) { |
| 690 |
$response = wp_remote_head($uri); |
| 691 |
if( is_wp_error($response) ) { |
| 692 |
$data = 'not200'; |
| 693 |
} else { |
| 694 |
$data = $response['response']['code']; |
| 695 |
} |
| 696 |
wp_cache_set($hashkey, $data, $group = '', $expire = 60*5); |
| 697 |
} |
| 698 |
if ($data == '200'){ |
| 699 |
return true; |
| 700 |
} else { |
| 701 |
return false; |
| 702 |
} |
| 703 |
} |
| 704 |
|
| 705 |
function wpforo_member_title( $member = array(), $echo = true, $before = '', $after = '' ){ |
| 706 |
$title = array(); |
| 707 |
|
| 708 |
if(empty($member) || !$member['groupid']) return ''; |
| 709 |
$rating_title_ug_enabled = ( isset(WPF()->member->options['rating_title_ug'][$member['groupid']]) && WPF()->member->options['rating_title_ug'][$member['groupid']] ) ? true : false ; |
| 710 |
$usergroup_title_ug_enabled = ( isset(WPF()->member->options['title_usergroup'][$member['groupid']]) && WPF()->member->options['title_usergroup'][$member['groupid']] ) ? true : false ; |
| 711 |
|
| 712 |
if( wpforo_feature('rating_title') && $rating_title_ug_enabled && isset($member['stat']['title']) ){ |
| 713 |
$title[] = '<span class="wpf-member-title wpfrt" title="' . wpforo_phrase('Rating Title', false) . '">' . esc_html($member['stat']['title']) . '</span>'; |
| 714 |
} |
| 715 |
if( empty($title) && WPF()->member->options['custom_title_is_on'] ){ |
| 716 |
$title[] = '<span class="wpf-member-title wpfct" title="' . wpforo_phrase('User Title', false) . '">' . wpforo_phrase($member['title'], false) . '</span>'; |
| 717 |
}else{ |
| 718 |
$before = $after = ''; |
| 719 |
} |
| 720 |
if( $usergroup_title_ug_enabled ){ |
| 721 |
$class = ''; |
| 722 |
if( $member['groupid'] == 1 ) $class = ' wpfbg-6 wpfcl-3'; |
| 723 |
if( $member['groupid'] == 2 ) $class = ' wpfbg-5 wpfcl-3'; |
| 724 |
if( $member['groupid'] == 4 ) $class = ' wpfbg-2 wpfcl-3'; |
| 725 |
$title[] = '<span class="wpf-member-title wpfut wpfug-' . intval($member['groupid']) . $class . '" title="' . wpforo_phrase('Usergroup', false) . '">' . esc_html($member['groupname']) . '</span>'; |
| 726 |
} |
| 727 |
if( !empty($title) ){ |
| 728 |
$title_html = $before . implode(' ', $title) . $after; |
| 729 |
$title_html = apply_filters('wpforo_member_title', $title_html, $member); |
| 730 |
if( $echo ) { |
| 731 |
echo $title_html; |
| 732 |
} |
| 733 |
else{ |
| 734 |
return $title_html; |
| 735 |
} |
| 736 |
} |
| 737 |
} |
| 738 |
|
| 739 |
function wpforo_member_badge( $member = array(), $sep = '', $type = 'full' ){ |
| 740 |
$rating_badge_ug_enabled = ( isset(WPF()->member->options['rating_badge_ug'][$member['groupid']]) && WPF()->member->options['rating_badge_ug'][$member['groupid']] ) ? true : false ; |
| 741 |
if( wpforo_feature('rating') && $rating_badge_ug_enabled && isset($member['stat']['rating']) ): ?> |
| 742 |
<div class="author-rating-<?php echo esc_attr($type) ?>" style="color:<?php echo esc_attr($member['stat']['color']) ?>" title="<?php wpforo_phrase('Member Rating Badge') ?>"> |
| 743 |
<?php echo WPF()->member->rating_badge($member['stat']['rating'], $type); ?> |
| 744 |
</div><?php if($sep): ?><span class="author-rating-sep"><?php echo esc_html($sep); ?></span><?php endif; ?> |
| 745 |
<?php endif; |
| 746 |
|
| 747 |
do_action('wpforo_after_member_badge', $member); |
| 748 |
} |
| 749 |
|
| 750 |
|
| 751 |
function wpforo_member_nicename( $member = array(), $prefix = '', $bracket = true, $wrap = true, $class = 'wpf-author-nicename', $echo = true ){ |
| 752 |
if( !wpforo_feature('mention-nicknames') || empty($member) || !isset($member['user_nicename']) ) return ''; |
| 753 |
$nicename = ''; |
| 754 |
if( $wrap ){ $nicename .= '<div class="' . $class . '" title="' . wpforo_phrase('You can mention a person using @nicename in post content to send that person an email message. When you post a topic or reply, forum sends an email message to the user letting them know that they have been mentioned on the post.', false) . '">';} |
| 755 |
if( $bracket ) $nicename .= '('; |
| 756 |
$nicename .= $prefix . urldecode($member['user_nicename']); |
| 757 |
if( $bracket ) $nicename .= ')'; |
| 758 |
if( $wrap ){ $nicename .= '</div>';} |
| 759 |
if( $echo ){ echo $nicename; } else{ return $nicename; } |
| 760 |
} |
| 761 |
|
| 762 |
|
| 763 |
add_filter( 'body_class', 'wpforo_page_class', 1, 10 ); |
| 764 |
function wpforo_page_class( $classes ) { |
| 765 |
if(!empty($classes)){ |
| 766 |
if( function_exists('is_wpforo_page') ){ |
| 767 |
if ( is_wpforo_page() ) { |
| 768 |
return array_merge( $classes, array( 'wpforo' ) ); |
| 769 |
} |
| 770 |
} |
| 771 |
} |
| 772 |
return (array)$classes; |
| 773 |
} |
| 774 |
|
| 775 |
############################################################################### |
| 776 |
########################## THEME API FUNCTIONS ################################ |
| 777 |
############################################################################### |
| 778 |
|
| 779 |
function wpforo_post( $postid, $var = 'item', $echo = false ){ |
| 780 |
$post = ( $var == 'item' ) ? array() : ''; |
| 781 |
if( !$postid ) return $post; |
| 782 |
$cache = WPF()->cache->on('object_cashe'); |
| 783 |
if( $cache ){ |
| 784 |
$post = WPF()->cache->get_item( $postid, 'post' ); |
| 785 |
} |
| 786 |
if( empty($post) ){ |
| 787 |
$post = array(); |
| 788 |
if( !$cache && $var == 'url' ){ |
| 789 |
$post['url'] = WPF()->post->get_post_url($postid); |
| 790 |
} |
| 791 |
elseif( !$cache && $var == 'is_answered' ){ |
| 792 |
$post['is_answered'] = WPF()->post->is_answered($postid); |
| 793 |
} |
| 794 |
elseif( !$cache && $var == 'votes_sum' ){ |
| 795 |
$post = WPF()->post->get_post($postid); |
| 796 |
$post['votes_sum'] = $post['votes']; |
| 797 |
} |
| 798 |
elseif( !$cache && $var == 'likes_count' ){ |
| 799 |
$post['likes_count'] = WPF()->post->get_post_likes_count($postid); |
| 800 |
} |
| 801 |
elseif( !$cache && $var == 'likers_usernames' ){ |
| 802 |
$post['likers_usernames'] = WPF()->post->get_likers_usernames($postid); |
| 803 |
} |
| 804 |
else{ |
| 805 |
$post = WPF()->post->get_post($postid); |
| 806 |
if( !empty($post) ){ |
| 807 |
$post['url'] = WPF()->post->get_post_url($post); |
| 808 |
if( $cache ){ |
| 809 |
$post['is_answered'] = WPF()->post->is_answered($postid); |
| 810 |
$post['votes_sum'] = $post['votes']; |
| 811 |
$post['likes_count'] = WPF()->post->get_post_likes_count($postid); |
| 812 |
$post['likers_usernames'] = WPF()->post->get_likers_usernames($postid); |
| 813 |
} |
| 814 |
if(!empty($post)){ |
| 815 |
$cache_item = array( $postid => $post ); |
| 816 |
WPF()->cache->create('item', $cache_item, 'post'); |
| 817 |
} |
| 818 |
} |
| 819 |
} |
| 820 |
} |
| 821 |
|
| 822 |
if( $var != 'item' && $var ){ |
| 823 |
$post = ( isset($post[$var]) ) ? $post[$var] : ''; |
| 824 |
} |
| 825 |
|
| 826 |
if( $echo ){ |
| 827 |
echo $post; |
| 828 |
} |
| 829 |
else{ |
| 830 |
return $post; |
| 831 |
} |
| 832 |
} |
| 833 |
|
| 834 |
function wpforo_topic( $topicid, $var = 'item', $echo = false ){ |
| 835 |
$topic = ( $var == 'item' ) ? array() : ''; |
| 836 |
if( !$topicid ) return $topic; |
| 837 |
$cache = WPF()->cache->on('object_cashe'); |
| 838 |
if( $cache ) $topic = WPF()->cache->get_item( $topicid, 'topic' ); |
| 839 |
|
| 840 |
if( empty($topic) ){ |
| 841 |
$topic = array(); |
| 842 |
if( !$cache && $var == 'url' ){ |
| 843 |
$topic['url'] = WPF()->topic->get_topic_url( $topicid ); |
| 844 |
} |
| 845 |
elseif( !$cache && $var == 'is_answer' ){ |
| 846 |
$topic['is_answer'] = WPF()->topic->is_solved( $topicid ); |
| 847 |
} |
| 848 |
else{ |
| 849 |
$topic = WPF()->topic->get_topic($topicid); |
| 850 |
if( !empty($topic) ){ |
| 851 |
$topic['url'] = WPF()->topic->get_topic_url($topic); |
| 852 |
$topic['is_answer'] = WPF()->topic->is_solved( $topic['topicid'] ); |
| 853 |
if(!empty($topic)){ |
| 854 |
$cache_item = array( $topicid => $topic ); |
| 855 |
WPF()->cache->create('item', $cache_item, 'topic'); |
| 856 |
} |
| 857 |
} |
| 858 |
} |
| 859 |
} |
| 860 |
|
| 861 |
if( $var != 'item' && $var ){ |
| 862 |
$topic = ( isset($topic[$var]) ) ? $topic[$var] : ''; |
| 863 |
} |
| 864 |
|
| 865 |
if( $echo ){ |
| 866 |
echo $topic; |
| 867 |
} |
| 868 |
else{ |
| 869 |
return $topic; |
| 870 |
} |
| 871 |
} |
| 872 |
|
| 873 |
|
| 874 |
function wpforo_forum( $forumid, $var = 'item', $echo = false ){ |
| 875 |
$data = array(); |
| 876 |
$forum = ( $var == 'item' ) ? array() : ''; |
| 877 |
$cache = WPF()->cache->on('object_cashe'); |
| 878 |
if( !$forumid ) return $forum; |
| 879 |
if( $cache ) $forum = WPF()->cache->get_item( $forumid, 'forum' ); |
| 880 |
|
| 881 |
if( empty($forum) ){ |
| 882 |
$forum = array(); |
| 883 |
if( !$cache && ($var == 'childs' || $var == 'counts') ){ |
| 884 |
if( $var == 'childs' ) { |
| 885 |
WPF()->forum->get_childs($forumid, $data); |
| 886 |
$forum['childs'] = $data; |
| 887 |
} |
| 888 |
else{ |
| 889 |
WPF()->forum->get_childs($forumid, $data); |
| 890 |
$forum['childs'] = $data; |
| 891 |
$forum['counts'] = WPF()->forum->get_counts( $data ); |
| 892 |
} |
| 893 |
} |
| 894 |
else{ |
| 895 |
$forum = WPF()->forum->get_forum($forumid); |
| 896 |
if( !empty($forum) ){ |
| 897 |
if( $cache ){ |
| 898 |
WPF()->forum->get_childs($forum['forumid'], $data); |
| 899 |
$forum['childs'] = $data; |
| 900 |
$forum['counts'] = WPF()->forum->get_counts( $data ); |
| 901 |
} |
| 902 |
if(!empty($forum)){ |
| 903 |
$cache_item = array( $forumid => $forum ); |
| 904 |
WPF()->cache->create('item', $cache_item, 'forum'); |
| 905 |
} |
| 906 |
} |
| 907 |
} |
| 908 |
} |
| 909 |
|
| 910 |
if( $var != 'item' && $var ){ |
| 911 |
$forum = ( isset($forum[$var]) ) ? $forum[$var] : ''; |
| 912 |
} |
| 913 |
|
| 914 |
if( $echo ){ |
| 915 |
echo $forum; |
| 916 |
} |
| 917 |
else{ |
| 918 |
return $forum; |
| 919 |
} |
| 920 |
} |
| 921 |
|
| 922 |
function wpforo_member( $object, $var = 'item', $echo = false ){ |
| 923 |
$member = array(); |
| 924 |
if( empty( $object ) ) return $member; |
| 925 |
|
| 926 |
if( is_array( $object ) && isset($object['userid']) && !$object['userid'] ){ |
| 927 |
$member = WPF()->member->get_guest( $object ); |
| 928 |
} |
| 929 |
else{ |
| 930 |
$userid = ( is_array( $object ) && isset($object['userid']) ) ? intval($object['userid']) : intval($object); |
| 931 |
$member = WPF()->member->get_member( $userid ); |
| 932 |
if( isset($member['fields']) && $member['fields'] ){ |
| 933 |
$member['fields'] = json_decode($member['fields'], true); |
| 934 |
} |
| 935 |
} |
| 936 |
if( $var != 'item' && $var ){ |
| 937 |
if( isset($member[$var]) ){ |
| 938 |
$member = $member[$var]; |
| 939 |
} |
| 940 |
elseif( isset($member['fields']) && isset($member['fields'][$var]) ){ |
| 941 |
$member = $member['fields'][$var]; |
| 942 |
} |
| 943 |
} |
| 944 |
if( $echo ){ |
| 945 |
echo $member; |
| 946 |
} |
| 947 |
else{ |
| 948 |
return $member; |
| 949 |
} |
| 950 |
} |
| 951 |
|
| 952 |
function wpforo_member_link( $member, $prefix = '', $length = 30, $class = '', $echo = true ){ |
| 953 |
$display_name = ( isset($member['display_name']) && $member['display_name'] ) ? $member['display_name'] : wpforo_phrase('Anonymous', false); |
| 954 |
$color = (isset($member['color']) && $member['color'] ) ? 'style="color:' . $member['color'] . '"' : ''; |
| 955 |
$class = ($class) ? 'class="' . $class . '"' : ''; |
| 956 |
$title = ($member['display_name']) ? 'title="' . esc_attr($member['display_name']) . '"' : ''; |
| 957 |
if( wpfval($member, 'profile_url') ){ |
| 958 |
?><a href="<?php echo esc_url($member['profile_url']) ?>" <?php echo $color ?> <?php echo $class ?> <?php echo $title ?>><?php if( strpos($prefix, '%s') !== FALSE ): ?><?php echo sprintf( wpforo_phrase($prefix, FALSE), esc_html(wpforo_text($display_name, $length, FALSE)) ); ?><?php else: ?><?php if( $prefix ){ echo wpforo_phrase( $prefix, false) . ' '; } ?><?php if( $length ){ echo esc_html(wpforo_text($display_name, $length, false)); } else { echo esc_html($display_name); } ?><?php endif; ?></a><?php |
| 959 |
} |
| 960 |
else{ |
| 961 |
?><?php if( strpos($prefix, '%s') !== FALSE ): ?><?php echo sprintf( wpforo_phrase($prefix, FALSE), esc_html(wpforo_text($display_name, $length, FALSE)) ); ?><?php else: ?><?php if( $prefix ){ echo wpforo_phrase( $prefix, false) . ' '; } ?><?php if( $length ){ echo esc_html(wpforo_text($display_name, $length, false)); } else { echo esc_html($display_name); } ?><?php endif; ?><?php |
| 962 |
} |
| 963 |
} |
| 964 |
|
| 965 |
add_shortcode('wpforo-lostpassword', 'wpforo_lostpassword'); |
| 966 |
function wpforo_lostpassword(){ ?> |
| 967 |
<p id="wpforo-title"><?php wpforo_phrase('Reset Password') ?></p> |
| 968 |
<form name="wpflogin" action="<?php echo wp_lostpassword_url(); ?>" method="POST"> |
| 969 |
<div class="wpforo-login-wrap wpfbg-9"> |
| 970 |
<div class="wpforo-login-content"> |
| 971 |
<h3><?php wpforo_phrase('Forgot Your Password?') ?></h3> |
| 972 |
<div class="wpforo-table wpforo-login-table"> |
| 973 |
<div class="wpf-tr row-0"> |
| 974 |
<div class="wpf-td wpfw-1 row_0-col_0" style="padding-top:10px;"> |
| 975 |
<div class="wpf-field wpf-field-type-text"> |
| 976 |
<div class="wpf-field-wrap"> |
| 977 |
<label for="userlogin" style="display: block; text-align: center; font-size: 14px; padding-bottom: 10px;"><?php wpforo_phrase('Please Insert Your Email or Username') ?></label> |
| 978 |
<input id="userlogin" autofocus required type="text" name="user_login" class="wpf-login-text" /> |
| 979 |
<div style="text-align: center; font-size: 13px; padding-top: 10px; line-height: 18px;"><?php wpforo_phrase('Enter your email address or username and we\'ll send you a link you can use to pick a new password.') ?></div> |
| 980 |
</div> |
| 981 |
<div class="wpf-field-cl"></div> |
| 982 |
</div> |
| 983 |
<div class="wpf-field wpf-field-type-text wpf-field-hook"> |
| 984 |
<div class="wpf-field-wrap"> |
| 985 |
<?php do_action('lostpassword_form') ?><div class="wpf-field-cl"></div> |
| 986 |
</div> |
| 987 |
<div class="wpf-field-cl"></div> |
| 988 |
</div> |
| 989 |
<div class="wpf-field"> |
| 990 |
<div class="wpf-field-wrap" style="text-align:center; width:100%;"> |
| 991 |
<input type="submit" name="wpfororp" value="<?php wpforo_phrase('Reset Password') ?>" /> |
| 992 |
</div> |
| 993 |
<div class="wpf-field-cl"></div> |
| 994 |
</div> |
| 995 |
<div class="wpf-field wpf-extra-field-end"> |
| 996 |
<div class="wpf-field-wrap" style="text-align:center; width:100%;"> |
| 997 |
<?php do_action('wpforo_lostpass_form_end') ?> |
| 998 |
<div class="wpf-field-cl"></div> |
| 999 |
</div> |
| 1000 |
</div> |
| 1001 |
<div class="wpf-cl"></div> |
| 1002 |
</div> |
| 1003 |
</div> |
| 1004 |
</div> |
| 1005 |
</div> |
| 1006 |
</div> |
| 1007 |
</form> |
| 1008 |
|
| 1009 |
<?php |
| 1010 |
} |
| 1011 |
|
| 1012 |
add_shortcode('wpforo-resetpassword', 'wpforo_resetpassword'); |
| 1013 |
function wpforo_resetpassword(){ ?> |
| 1014 |
<p id="wpforo-title"><?php wpforo_phrase('Reset Password') ?></p> |
| 1015 |
|
| 1016 |
<form name="wpflogin" action="<?php echo site_url( 'wp-login.php?action=resetpass' ); ?>" method="POST" autocomplete="off"> |
| 1017 |
<input type="hidden" name="rp_key" value="<?php echo esc_html($_REQUEST['rp_key']) ?>"> |
| 1018 |
<input type="hidden" name="rp_login" value="<?php echo esc_html($_REQUEST['rp_login']) ?>"> |
| 1019 |
<div class="wpforo-login-wrap"> |
| 1020 |
<div class="wpforo-login-content"> |
| 1021 |
<div class="wpforo-table wpforo-login-table"> |
| 1022 |
<div class="wpf-tr row-0"> |
| 1023 |
<div class="wpf-td wpfw-1 row_0-col_0" style="padding-top:10px;"> |
| 1024 |
<div class="wpf-field wpf-field-type-text"> |
| 1025 |
<div class="wpf-field-wrap"> |
| 1026 |
<label for="userlogin" style="display: block; text-align: center; font-size: 14px; padding-bottom: 10px;"><?php wpforo_phrase('New password') ?></label> |
| 1027 |
<input type="password" name="pass1" id="pass1" class="input" size="20" value="" autocomplete="off" required autofocus /> |
| 1028 |
</div> |
| 1029 |
<div class="wpf-field-cl"></div> |
| 1030 |
</div> |
| 1031 |
<div class="wpf-field wpf-field-type-text"> |
| 1032 |
<div class="wpf-field-wrap"> |
| 1033 |
<label for="userlogin" style="display: block; text-align: center; font-size: 14px; padding-bottom: 10px;"><?php wpforo_phrase('Repeat new password') ?></label> |
| 1034 |
<input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off" required /> |
| 1035 |
</div> |
| 1036 |
<div class="wpf-field-cl"></div> |
| 1037 |
</div> |
| 1038 |
<div class="wpf-field wpf-field-type-text"> |
| 1039 |
<div class="wpf-field-wrap"> |
| 1040 |
<?php echo wp_get_password_hint(); ?> |
| 1041 |
</div> |
| 1042 |
<div class="wpf-field-cl"></div> |
| 1043 |
</div> |
| 1044 |
<div class="wpf-field"> |
| 1045 |
<div class="wpf-field-wrap" style="text-align:center; width:100%;"> |
| 1046 |
<input type="submit" name="submit" value="<?php wpforo_phrase('Reset Password'); ?>" /> |
| 1047 |
</div> |
| 1048 |
<div class="wpf-field-cl"></div> |
| 1049 |
</div> |
| 1050 |
<div class="wpf-field wpf-extra-field-end"> |
| 1051 |
<div class="wpf-field-wrap" style="text-align:center; width:100%;"> |
| 1052 |
<?php do_action('wpforo_resetpass_form_end') ?> |
| 1053 |
<div class="wpf-field-cl"></div> |
| 1054 |
</div> |
| 1055 |
</div> |
| 1056 |
<div class="wpf-cl"></div> |
| 1057 |
</div> |
| 1058 |
</div> |
| 1059 |
</div> |
| 1060 |
</div> |
| 1061 |
</div> |
| 1062 |
</form> |
| 1063 |
|
| 1064 |
<?php |
| 1065 |
} |
| 1066 |
|
| 1067 |
############################################################################################# |
| 1068 |
/** |
| 1069 |
* Generates according page form fields using tpl->form_fields() function |
| 1070 |
* |
| 1071 |
* @since 1.4.0 |
| 1072 |
* |
| 1073 |
* @param array $fields arguments |
| 1074 |
* @param boolean $echo |
| 1075 |
* |
| 1076 |
* @return string form fields HTML |
| 1077 |
*/ |
| 1078 |
function wpforo_fields( $fields, $echo = true ){ |
| 1079 |
if( empty($fields) ) return ''; |
| 1080 |
$fields = apply_filters( 'wpforo_form_fields', $fields ); |
| 1081 |
$html = WPF()->tpl->form_fields( $fields ); |
| 1082 |
if( $echo ){ |
| 1083 |
echo $html; |
| 1084 |
} |
| 1085 |
else{ |
| 1086 |
return $html; |
| 1087 |
} |
| 1088 |
} |
| 1089 |
|
| 1090 |
################################################################################################## |
| 1091 |
/** |
| 1092 |
* Collects Registration Page POST data and sends to field generator function |
| 1093 |
* |
| 1094 |
* @since 1.4.0 |
| 1095 |
* |
| 1096 |
* @param array $fields arguments |
| 1097 |
* |
| 1098 |
* @return NULL |
| 1099 |
*/ |
| 1100 |
|
| 1101 |
function wpforo_register_page_field_values( $fields ){ |
| 1102 |
WPF()->form['value']['user_login'] = (isset($_POST['wpfreg']['user_login'])) ? sanitize_user($_POST['wpfreg']['user_login']) : ''; |
| 1103 |
WPF()->form['value']['user_email'] = (isset($_POST['wpfreg']['user_email'])) ? sanitize_email($_POST['wpfreg']['user_email']) : ''; |
| 1104 |
WPF()->form['varname'] = 'wpfreg'; |
| 1105 |
} |
| 1106 |
add_action( 'wpforo_register_page_start', 'wpforo_register_page_field_values', 10, 1 ); |
| 1107 |
|
| 1108 |
|
| 1109 |
################################################################################################## |
| 1110 |
/** |
| 1111 |
* Collects Account Page field data and sends to field generator function |
| 1112 |
* |
| 1113 |
* @since 1.4.0 |
| 1114 |
* |
| 1115 |
* @param array $fields arguments |
| 1116 |
* |
| 1117 |
* @return NULL |
| 1118 |
*/ |
| 1119 |
|
| 1120 |
function wpforo_account_page_field_values( $fields ){ |
| 1121 |
if( isset(WPF()->current_object['user']) && !empty(WPF()->current_object['user']) ){ |
| 1122 |
$user = WPF()->current_object['user']; |
| 1123 |
$user = apply_filters('wpforo_profile_header_obj', $user); |
| 1124 |
WPF()->form['value'] = $user; |
| 1125 |
WPF()->form['varname'] = 'member'; |
| 1126 |
} |
| 1127 |
} |
| 1128 |
add_action( 'wpforo_account_page_start', 'wpforo_account_page_field_values', 10, 1 ); |
| 1129 |
|
| 1130 |
|
| 1131 |
################################################################################################## |
| 1132 |
/** |
| 1133 |
* Collects Profile Page field data and sends to field generator function |
| 1134 |
* |
| 1135 |
* @since 1.4.0 |
| 1136 |
* |
| 1137 |
* @param array $fields arguments |
| 1138 |
* |
| 1139 |
* @return NULL |
| 1140 |
*/ |
| 1141 |
|
| 1142 |
function wpforo_profile_page_field_values( $fields ){ |
| 1143 |
if( isset(WPF()->current_object['user']) && !empty(WPF()->current_object['user']) ){ |
| 1144 |
$user = WPF()->current_object['user']; |
| 1145 |
WPF()->form['value'] = $user; |
| 1146 |
} |
| 1147 |
} |
| 1148 |
add_action( 'wpforo_profile_page_start', 'wpforo_profile_page_field_values', 10, 1 ); |
| 1149 |
|
| 1150 |
|
| 1151 |
function wpforo_search_page_field_values( $fields ){ |
| 1152 |
WPF()->form['value'] = ( !empty($_GET) ? (array) $_GET : array() ); |
| 1153 |
WPF()->form['varname'] = ''; |
| 1154 |
} |
| 1155 |
add_action( 'wpforo_search_page_start', 'wpforo_search_page_field_values', 10, 1 ); |
| 1156 |
|
| 1157 |
function wpforo_user_avatar( $user, $size, $attr = '', $lastmod = false ){ |
| 1158 |
$avatar_html = ''; |
| 1159 |
if( is_int($user) && $user ){ |
| 1160 |
$avatar_html = ($size) ? get_avatar($user, $size) : get_avatar($user); |
| 1161 |
if($attr) $avatar_html = str_replace('<img', '<img ' . $attr, $avatar_html); |
| 1162 |
} |
| 1163 |
elseif( is_array($user) && !empty($user) ){ |
| 1164 |
$avatar_html = WPF()->member->avatar($user, $attr, $size); |
| 1165 |
} |
| 1166 |
|
| 1167 |
if( $lastmod ){ |
| 1168 |
$url = wpforo_avatar_url( $avatar_html ); |
| 1169 |
if($url){ |
| 1170 |
if( strpos($url, '?') === FALSE ){ |
| 1171 |
$avatar_html = str_replace($url, $url . '?lm=' . time(), $avatar_html); |
| 1172 |
} |
| 1173 |
} |
| 1174 |
} |
| 1175 |
return $avatar_html; |
| 1176 |
} |
| 1177 |
|
| 1178 |
|
| 1179 |
function wpforo_signature( $member, $args = array() ){ |
| 1180 |
|
| 1181 |
$signature = ''; |
| 1182 |
$default = array('nofollow' => 1, 'kses' => 1, 'echo' => 1); |
| 1183 |
if( empty($args) ){ |
| 1184 |
$args = $default; |
| 1185 |
}else{ |
| 1186 |
$args = wpforo_parse_args( $args, $default ); |
| 1187 |
} |
| 1188 |
|
| 1189 |
if( is_int($member) && $member > 0 ){ |
| 1190 |
$member = wpforo_member( $member ); |
| 1191 |
$signature = ( isset($member['signature']) ) ? $member['signature'] : ''; |
| 1192 |
} |
| 1193 |
elseif( is_array($member) && !empty($member) ){ |
| 1194 |
$signature = ( isset($member['signature']) ) ? $member['signature'] : ''; |
| 1195 |
} |
| 1196 |
elseif( is_string($member) ){ |
| 1197 |
$signature = $member; |
| 1198 |
} |
| 1199 |
|
| 1200 |
$signature = stripslashes($signature); |
| 1201 |
|
| 1202 |
if(!empty($args)){ |
| 1203 |
extract($args, EXTR_OVERWRITE); |
| 1204 |
if(isset($kses) && $kses) $signature = wpforo_kses($signature, 'user_description'); |
| 1205 |
if(isset($nofollow) && $nofollow) $signature = wpforo_nofollow_tag($signature); |
| 1206 |
} |
| 1207 |
else{ |
| 1208 |
$signature = wpautop(wpforo_nofollow(wpforo_kses($signature, 'user_description'))); |
| 1209 |
} |
| 1210 |
|
| 1211 |
$signature = wpforo_text($signature, 0, false, false, false, false); |
| 1212 |
$signature = wpautop($signature); |
| 1213 |
|
| 1214 |
if($echo){ |
| 1215 |
echo $signature; |
| 1216 |
}else{ |
| 1217 |
return $signature; |
| 1218 |
} |
| 1219 |
} |
| 1220 |
|
| 1221 |
|
| 1222 |
function wpforo_register_fields(){ |
| 1223 |
$fields = WPF()->member->get_register_fields(); |
| 1224 |
do_action( 'wpforo_register_page_start', $fields ); |
| 1225 |
|
| 1226 |
return $fields; |
| 1227 |
} |
| 1228 |
|
| 1229 |
function wpforo_account_fields(){ |
| 1230 |
$fields = WPF()->member->get_account_fields(); |
| 1231 |
do_action( 'wpforo_account_page_start', $fields ); |
| 1232 |
|
| 1233 |
return $fields; |
| 1234 |
} |
| 1235 |
|
| 1236 |
function wpforo_profile_fields(){ |
| 1237 |
$fields = WPF()->member->get_profile_fields(); |
| 1238 |
do_action( 'wpforo_profile_page_start', $fields ); |
| 1239 |
|
| 1240 |
return $fields; |
| 1241 |
} |
| 1242 |
|
| 1243 |
function wpforo_search_fields(){ |
| 1244 |
$fields = WPF()->member->get_search_fields(); |
| 1245 |
do_action( 'wpforo_search_page_start', $fields ); |
| 1246 |
|
| 1247 |
if( WPF()->member->options['search_type'] == 'search' ){ |
| 1248 |
$fields = array( |
| 1249 |
array( |
| 1250 |
array( |
| 1251 |
array( |
| 1252 |
'type' => 'search', |
| 1253 |
'isDefault' => 1, |
| 1254 |
'isRemovable' => 0, |
| 1255 |
'isRequired' => 0, |
| 1256 |
'isEditable' => 1, |
| 1257 |
'class' => 'wpf-member-search-field', |
| 1258 |
'label' => wpforo_phrase('Find a member', false), |
| 1259 |
'title' => wpforo_phrase('Find a member', false), |
| 1260 |
'placeholder' => wpforo_phrase('Display Name or Nicename', false), |
| 1261 |
'faIcon' => 'fa-search', |
| 1262 |
'name' => 'wpfms', |
| 1263 |
'canBeInactive' => 0, |
| 1264 |
'can' => '', |
| 1265 |
'isSearchable' => 1 |
| 1266 |
) |
| 1267 |
) |
| 1268 |
) |
| 1269 |
); |
| 1270 |
} |
| 1271 |
|
| 1272 |
return $fields; |
| 1273 |
} |
| 1274 |
|
| 1275 |
|
| 1276 |
function wpforo_unread_forum( $logid, $return = 'class', $echo = true ){ |
| 1277 |
$unread = false; |
| 1278 |
if(!wpforo_feature('view-logging')) return; |
| 1279 |
$viwed_ids = wpforo_getcookie( 'wpf_viewed_forums', true ); |
| 1280 |
if( empty($viwed_ids) ) $unread = true; |
| 1281 |
if( is_array($viwed_ids) && !in_array( $logid, $viwed_ids ) ) $unread = true; |
| 1282 |
if( $unread ){ if( $return == 'class' ){ $log = 'wpf_forum_unread'; } else{ $log = true; } if( $echo ){ echo $log; } else { return $log; } } |
| 1283 |
} |
| 1284 |
|
| 1285 |
function wpforo_unread_topic( $logid, $return = 'class', $echo = true ){ |
| 1286 |
$unread = false; |
| 1287 |
if(!wpforo_feature('view-logging')) return; |
| 1288 |
$viwed_ids = wpforo_getcookie( 'wpf_viewed_topics', true ); |
| 1289 |
if( empty($viwed_ids) ) $unread = true; |
| 1290 |
if( is_array($viwed_ids) && !in_array( $logid, $viwed_ids ) ) $unread = true; |
| 1291 |
if( $unread ){ if( $return == 'class' ){ $log = 'wpf_topic_unread'; } else{ $log = true; } if( $echo ){ echo $log; } else { return $log; } } |
| 1292 |
} |
| 1293 |
|
| 1294 |
if( !function_exists('custom_wpforo_get_account_fields') ){ |
| 1295 |
function custom_wpforo_get_account_fields($fields){ |
| 1296 |
$hide = array( |
| 1297 |
'user_email', |
| 1298 |
'user_nicename' |
| 1299 |
); |
| 1300 |
|
| 1301 |
foreach ( $fields as $row_key => $row ){ |
| 1302 |
foreach ( $row as $col_key => $col ){ |
| 1303 |
foreach ( $col as $key => $field ){ |
| 1304 |
if( in_array($field['fieldKey'], $hide) ){ |
| 1305 |
unset($fields[$row_key][$col_key][$key]); |
| 1306 |
} |
| 1307 |
} |
| 1308 |
} |
| 1309 |
} |
| 1310 |
|
| 1311 |
return $fields; |
| 1312 |
} |
| 1313 |
} |
| 1314 |
|
| 1315 |
function wpforo_moderation_tools(){ |
| 1316 |
if( empty(WPF()->current_object['forumid']) || empty(WPF()->current_object['topicid']) ) return; |
| 1317 |
?> |
| 1318 |
<div id="wpf_moderation_tools" class="wpf-tools"> |
| 1319 |
<?php |
| 1320 |
$tabs = array(); |
| 1321 |
if( is_user_logged_in() && WPF()->perm->forum_can('mt') ){ |
| 1322 |
$posts = WPF()->post->get_posts( array('topicid' => WPF()->current_object['topicid']) ); |
| 1323 |
$tabs[] = array('title' => wpforo_phrase('Move Topic', false), 'id' => 'topic_move_form', 'class' => 'wpft-move', 'icon' => 'far fa-share-square'); |
| 1324 |
if( count($posts) > 1 ) { |
| 1325 |
$tabs[] = array('title' => wpforo_phrase('Move Reply', false), 'id' => 'reply_move_form', 'class' => 'wpft-reply-move', 'icon' => 'far fa-share-square'); |
| 1326 |
} |
| 1327 |
$tabs[] = array('title' => wpforo_phrase('Merge Topics', false), 'id' => 'topic_merge_form', 'class' => 'wpft-merge', 'icon' => 'fas fa-code-branch'); |
| 1328 |
if( count($posts) > 1 ) { |
| 1329 |
$tabs[] = array('title' => wpforo_phrase('Split Topic', false), 'id' => 'topic_split_form', 'class' => 'wpft-split', 'icon' => 'fas fa-cut'); |
| 1330 |
} |
| 1331 |
} |
| 1332 |
WPF()->tpl->topic_moderation_tabs($tabs); |
| 1333 |
?> |
| 1334 |
</div> |
| 1335 |
<?php |
| 1336 |
} |
| 1337 |
|
| 1338 |
function wpforo_subscription_tools(){ |
| 1339 |
|
| 1340 |
if ( !WPF()->current_object['user_is_same_current_user'] || !WPF()->sbscrb->is_email_confirmed() ) return; |
| 1341 |
$sbs = array(); |
| 1342 |
$allposts_checked = ''; |
| 1343 |
$alltopics_checked = ''; |
| 1344 |
|
| 1345 |
if( WPF()->sbscrb->get_subscribes(array('type' => 'forums-topics', 'userid' => WPF()->current_userid)) ) |
| 1346 |
$allposts_checked = ' checked'; |
| 1347 |
if( WPF()->sbscrb->get_subscribes(array('type' => 'forums', 'userid' => WPF()->current_userid)) ) |
| 1348 |
$alltopics_checked = ' checked'; |
| 1349 |
|
| 1350 |
if( !$allposts_checked && !$alltopics_checked ){ |
| 1351 |
if( $sbs_forum = WPF()->sbscrb->get_subscribes(array('type' => 'forum', 'userid' => WPF()->current_userid)) ) |
| 1352 |
foreach ($sbs_forum as $s) $sbs[$s['itemid']] = $s['type']; |
| 1353 |
if( $sbs_forum_topic = WPF()->sbscrb->get_subscribes(array('type' => 'forum-topic', 'userid' => WPF()->current_userid)) ) |
| 1354 |
foreach ($sbs_forum_topic as $s) $sbs[$s['itemid']] = $s['type']; |
| 1355 |
} |
| 1356 |
?> |
| 1357 |
<script type="text/javascript"> |
| 1358 |
jQuery(document).ready(function ($) { |
| 1359 |
if( $('#wpf_subscription_tools input[id^="wpf_sbs_allposts_"]').length === $('#wpf_subscription_tools input[id^="wpf_sbs_allposts_"]:checked').length ){ |
| 1360 |
$('#wpf_sbs_allposts').prop('checked', true); |
| 1361 |
} |
| 1362 |
if( $('#wpf_subscription_tools input[id^="wpf_sbs_alltopics_"]').length === $('#wpf_subscription_tools input[id^="wpf_sbs_alltopics_"]:checked').length ){ |
| 1363 |
$('#wpf_sbs_alltopics').prop('checked', true); |
| 1364 |
} |
| 1365 |
if( $('#wpf_sbs_allposts').is(':checked') ){ |
| 1366 |
$('#wpf_subscription_tools input[id^="wpf_sbs_allposts_"]').prop('checked', true); |
| 1367 |
} |
| 1368 |
if( $('#wpf_sbs_alltopics').is(':checked') ){ |
| 1369 |
$('#wpf_subscription_tools input[id^="wpf_sbs_alltopics_"]').prop('checked', true); |
| 1370 |
} |
| 1371 |
var wpforo_wrap = $('#wpforo-wrap'); |
| 1372 |
wpforo_wrap.on('change', '#wpf_sbs_allposts', function () { |
| 1373 |
var stat = $(this).is(':checked'); |
| 1374 |
$('#wpf_sbs_alltopics').prop('checked', false); |
| 1375 |
$('#wpf_subscription_tools input[id^="wpf_sbs_allposts_"]').prop('checked', stat); |
| 1376 |
if(stat) $('#wpf_subscription_tools input[id^="wpf_sbs_alltopics_"]').prop('checked', !stat); |
| 1377 |
}); |
| 1378 |
wpforo_wrap.on('change', '#wpf_sbs_alltopics', function () { |
| 1379 |
var stat = $(this).is(':checked'); |
| 1380 |
$('#wpf_sbs_allposts').prop('checked', false); |
| 1381 |
$('#wpf_subscription_tools input[id^="wpf_sbs_alltopics_"]').prop('checked', stat); |
| 1382 |
if(stat) $('#wpf_subscription_tools input[id^="wpf_sbs_allposts_"]').prop('checked', !stat); |
| 1383 |
}); |
| 1384 |
wpforo_wrap.on('change', '#wpf_subscription_tools input[id^="wpf_sbs_allposts_"]', function () { |
| 1385 |
var stat = $(this).is(':checked'); |
| 1386 |
$('#wpf_sbs_allposts,#wpf_sbs_alltopics').prop('checked', false); |
| 1387 |
if( stat ) { |
| 1388 |
if( $('#wpf_subscription_tools input[id^="wpf_sbs_allposts_"]').length === $('#wpf_subscription_tools input[id^="wpf_sbs_allposts_"]:checked').length ){ |
| 1389 |
$('#wpf_sbs_allposts').prop('checked', true); |
| 1390 |
} |
| 1391 |
$(this).siblings('input[id^="wpf_sbs_alltopics_"]').prop('checked', false); |
| 1392 |
} |
| 1393 |
}); |
| 1394 |
wpforo_wrap.on('change', '#wpf_subscription_tools input[id^="wpf_sbs_alltopics_"]', function () { |
| 1395 |
var stat = $(this).is(':checked'); |
| 1396 |
$('#wpf_sbs_allposts,#wpf_sbs_alltopics').prop('checked', false); |
| 1397 |
if( stat ) { |
| 1398 |
if( $('#wpf_subscription_tools input[id^="wpf_sbs_alltopics_"]').length === $('#wpf_subscription_tools input[id^="wpf_sbs_alltopics_"]:checked').length ){ |
| 1399 |
$('#wpf_sbs_alltopics').prop('checked', true); |
| 1400 |
} |
| 1401 |
$(this).siblings('input[id^="wpf_sbs_allposts_"]').prop('checked', false); |
| 1402 |
} |
| 1403 |
}); |
| 1404 |
}); |
| 1405 |
</script> |
| 1406 |
<div id="wpf_subscription_tools" class="wpf-tools"> |
| 1407 |
<p class="wpf-sbs-head"><?php wpforo_phrase('Subscription Manager') ?></p> |
| 1408 |
<form id="wpf_sbs_form" method="post" enctype="multipart/form-data" action=""> |
| 1409 |
<div class="wpf-sbs-bulk"> |
| 1410 |
<div class="wpf-sbs-bulk-posts"><input id="wpf_sbs_allposts" type="checkbox" name="wpforo[check_all]" value="forums-topics" <?php echo $allposts_checked ?>><label for="wpf_sbs_allposts"><?php wpforo_phrase('Subscribe to all new topics and posts') ?></label></div> |
| 1411 |
<div class="wpf-sbs-bulk-topics"><input id="wpf_sbs_alltopics" type="checkbox" name="wpforo[check_all]" value="forums" <?php echo $alltopics_checked ?>><label for="wpf_sbs_alltopics"><?php wpforo_phrase('Subscribe to all new topics') ?></label></div> |
| 1412 |
</div> |
| 1413 |
<div class="wpf-sbs-bulk-options"> |
| 1414 |
<ul> |
| 1415 |
<?php WPF()->forum->tree('subscribe_manager_form', false, $sbs); ?> |
| 1416 |
</ul> |
| 1417 |
</div> |
| 1418 |
<div class="wpf-sbs-tool-foot"><input type="submit" name="wpforo_subscribe_manager" value="<?php wpforo_phrase('Update Subscriptions') ?>"></div> |
| 1419 |
</form> |
| 1420 |
</div> |
| 1421 |
<?php |
| 1422 |
} |
| 1423 |
|
| 1424 |
|
| 1425 |
/** |
| 1426 |
* Add an activity item. |
| 1427 |
* @since 1.4.6 |
| 1428 |
* @param array $args { |
| 1429 |
* An array of arguments. |
| 1430 |
* @type string $action Optional. The activity action/description, typically something like "Joe posted an update". |
| 1431 |
* @type string $title Optional. The title of the activity item. |
| 1432 |
* @type string $content Optional. The content of the activity item. |
| 1433 |
* @type string $component The unique name of the component associated with the activity item - 'activity', etc. |
| 1434 |
* @type string $type The specific activity type, used for directory filtering. 'wpforo_topic', 'wpforo_post', etc. |
| 1435 |
* @type string $primary_link Optional. The URL for this item, as used in RSS feeds. Defaults to the URL for this activity item's permalink page. |
| 1436 |
* @type int|bool $user_id Optional. The ID of the user associated with the activity item. May be set to false or 0 if the item is not related to any user. Default: the ID of the currently logged-in user. |
| 1437 |
* @type string $date_recorded Optional. The GMT time, in Y-m-d h:i:s format, when the item was recorded. Defaults to the current time. |
| 1438 |
* } |
| 1439 |
* @return NULL |
| 1440 |
*/ |
| 1441 |
function wpforo_activity( $args = array() ){ |
| 1442 |
|
| 1443 |
$default = array( 'action' => '', 'title' => '', 'content' => '', 'component' => 'community', 'type' => '', 'primary_link' => '', 'user_id' => '', 'item_id'=> '', 'date_recorded' => ''); |
| 1444 |
$args = wpforo_parse_args( $args, $default ); |
| 1445 |
|
| 1446 |
//BuddyPress Member Activity |
| 1447 |
if( wpforo_feature('bp_activity') && function_exists('wpforo_bp_activity') ){ |
| 1448 |
wpforo_bp_activity( $args ); |
| 1449 |
} |
| 1450 |
} |
| 1451 |
|
| 1452 |
function wpforo_activity_delete( $args = array() ){ |
| 1453 |
|
| 1454 |
$default = array( 'action' => '', 'title' => '', 'content' => '', 'component' => 'community', 'type' => '', 'primary_link' => '', 'user_id' => '', 'item_id'=> '', 'date_recorded' => ''); |
| 1455 |
$args = wpforo_parse_args( $args, $default ); |
| 1456 |
|
| 1457 |
//Delete BuddyPress Member Activity |
| 1458 |
if( wpforo_feature('bp_activity') && function_exists('wpforo_bp_activity_delete') ){ |
| 1459 |
wpforo_bp_activity_delete( $args ); |
| 1460 |
} |
| 1461 |
} |
| 1462 |
|
| 1463 |
|
| 1464 |
function wpforo_activity_content( $item = array() ){ |
| 1465 |
$args = array(); |
| 1466 |
if( empty($item) ) return false; |
| 1467 |
if((isset($item['status']) && $item['status']) || (isset($item['private']) && $item['private'])) return false; |
| 1468 |
if( isset($item['forumid']) && $item['forumid'] ){ |
| 1469 |
$private_for_usergroups = array(3, 4, 5); |
| 1470 |
$private_for_usergroups = apply_filters( 'wpforo_activity_private_for_usergroups', $private_for_usergroups ); |
| 1471 |
if( !empty($private_for_usergroups) && WPF()->forum->private_forum($item['forumid'], $private_for_usergroups) ){ |
| 1472 |
return false; |
| 1473 |
} |
| 1474 |
} |
| 1475 |
|
| 1476 |
if( isset($item['first_postid']) && $item['first_postid'] ) { |
| 1477 |
$args['item_id'] = $item['first_postid']; |
| 1478 |
} |
| 1479 |
elseif( isset($item['postid']) && $item['postid'] ){ |
| 1480 |
$args['item_id'] = $item['postid']; |
| 1481 |
} |
| 1482 |
$args['user_id'] = ( isset($item['userid']) && $item['userid'] ) ? $item['userid'] : $args['user_id'] = WPF()->current_userid; |
| 1483 |
$member = wpforo_member( $args['user_id'] ); |
| 1484 |
if( isset($item['topicurl']) ){ |
| 1485 |
$args['type'] = 'wpforo_topic'; |
| 1486 |
$args['content'] = $item['body']; |
| 1487 |
$args['primary_link'] = $item['topicurl']; |
| 1488 |
if( isset($item['title']) ) $args['title'] = $item['title']; |
| 1489 |
if( $args['title'] ) $args['title'] = ' "' . esc_html($args['title']) . '"'; |
| 1490 |
$args['action'] = sprintf( wpforo_phrase('%s posted a new topic %s', false), '', ''); |
| 1491 |
} |
| 1492 |
elseif( isset($item['posturl']) ){ |
| 1493 |
$args['type'] = 'wpforo_post'; |
| 1494 |
$args['content'] = $item['body']; |
| 1495 |
$args['primary_link'] = $item['posturl']; |
| 1496 |
if( isset($item['title']) ) $args['title'] = preg_replace('|^.+?\:\s*|is', '', $item['title']); |
| 1497 |
if( $args['title'] ) $args['title'] = ' "' . esc_html($args['title']) . '"'; |
| 1498 |
$args['action'] = sprintf( wpforo_phrase('%s replied to the topic %s', false), '', ''); |
| 1499 |
} |
| 1500 |
if( $args['content'] ) { |
| 1501 |
$content_words = explode(' ', $args['content']); |
| 1502 |
$content_words = count($content_words); |
| 1503 |
$content_words_cut = apply_filters( 'wpforo_activity_content_words', '40' ); |
| 1504 |
if( (int)$content_words_cut < (int)$content_words && $args['primary_link'] ){ |
| 1505 |
$more = '... <a href="' . $args['primary_link'] . '">' . wpforo_phrase('read more', false) . '»</a>'; |
| 1506 |
$args['content'] = wp_trim_words( $args['content'], 40, $more ); |
| 1507 |
} |
| 1508 |
} |
| 1509 |
wpforo_activity( $args ); |
| 1510 |
} |
| 1511 |
|
| 1512 |
function wpforo_activity_content_delete( $item = array() ){ |
| 1513 |
$args = array(); |
| 1514 |
if( empty($item) ) return false; |
| 1515 |
if( wpfval($item, 'first_postid') ){ |
| 1516 |
$args['item_id'] = $item['first_postid']; |
| 1517 |
$args['type'] = 'wpforo_topic'; |
| 1518 |
} |
| 1519 |
elseif( wpfval($item, 'is_first_post') ) { |
| 1520 |
$args['item_id'] = $item['postid']; |
| 1521 |
$args['type'] = 'wpforo_topic'; |
| 1522 |
} |
| 1523 |
elseif( wpfval($item, 'postid') ){ |
| 1524 |
$args['item_id'] = $item['postid']; |
| 1525 |
$args['type'] = 'wpforo_post'; |
| 1526 |
} |
| 1527 |
if( wpfval($args, 'item_id') && wpfval($args, 'type') ) wpforo_activity_delete( $args ); |
| 1528 |
} |
| 1529 |
|
| 1530 |
function wpforo_activity_content_on_post_status_change( $postid, $status = 0 ) { |
| 1531 |
if( !$postid ) return; |
| 1532 |
$post = WPF()->post->get_post($postid); |
| 1533 |
if(!empty($post)){ |
| 1534 |
$post['status'] = $status; |
| 1535 |
$post['posturl'] = WPF()->post->get_post_url($postid); |
| 1536 |
if( !wpfval($post, 'is_first_post') ){ |
| 1537 |
if( $status ){ |
| 1538 |
wpforo_activity_content_delete( $post ); |
| 1539 |
} |
| 1540 |
else{ |
| 1541 |
wpforo_activity_content( $post ); |
| 1542 |
} |
| 1543 |
} |
| 1544 |
} |
| 1545 |
} |
| 1546 |
add_action( 'wpforo_post_status_update', 'wpforo_activity_content_on_post_status_change', 9, 2 ); |
| 1547 |
|
| 1548 |
function wpforo_activity_content_on_topic_status_change( $topicid, $status = 0 ) { |
| 1549 |
if( !$topicid ) return; |
| 1550 |
$topic = WPF()->topic->get_topic($topicid); |
| 1551 |
if(!empty($topic)){ |
| 1552 |
$topic['status'] = $status; |
| 1553 |
$topic['topicurl'] = WPF()->topic->get_topic_url($topicid); |
| 1554 |
if( $status ){ |
| 1555 |
wpforo_activity_content_delete( $topic ); |
| 1556 |
} |
| 1557 |
else{ |
| 1558 |
wpforo_activity_content( $topic ); |
| 1559 |
} |
| 1560 |
} |
| 1561 |
} |
| 1562 |
add_action( 'wpforo_topic_status_update', 'wpforo_activity_content_on_topic_status_change', 9, 2 ); |
| 1563 |
|
| 1564 |
function wpforo_activity_like( $item = array() ){ |
| 1565 |
$args = array(); |
| 1566 |
if( empty($item) ) return false; |
| 1567 |
if((isset($item['status']) && $item['status']) || (isset($item['private']) && $item['private'])) return false; |
| 1568 |
if( isset($item['forumid']) && $item['forumid'] ){ |
| 1569 |
$private_for_usergroups = array(3, 4, 5); |
| 1570 |
$private_for_usergroups = apply_filters( 'wpforo_activity_private_for_usergroups', $private_for_usergroups ); |
| 1571 |
if( !empty($private_for_usergroups) && WPF()->forum->private_forum($item['forumid'], $private_for_usergroups) ){ |
| 1572 |
return false; |
| 1573 |
} |
| 1574 |
} |
| 1575 |
if( isset($item['postid']) && $item['postid'] ) $args['item_id'] = $item['postid']; |
| 1576 |
$args['user_id'] = WPF()->current_userid; |
| 1577 |
$member = wpforo_member( $args['user_id'] ); |
| 1578 |
$args['type'] = 'wpforo_like'; |
| 1579 |
$item = wpforo_post($item['postid']); |
| 1580 |
if( isset($item['url']) && $item['url'] ) $args['primary_link'] = $item['url']; |
| 1581 |
if( isset($item['title']) ) $args['title'] = preg_replace('|^.+?\:\s*|is', '', $item['title']); |
| 1582 |
if( $args['title'] ) $args['title'] = ' "' . esc_html($args['title']) . '"'; |
| 1583 |
$args['action'] = sprintf( wpforo_phrase('%s liked forum post %s', false), '', ''); |
| 1584 |
wpforo_activity( $args ); |
| 1585 |
} |
| 1586 |
|
| 1587 |
function wpforo_activity_like_delete( $item = array() ){ |
| 1588 |
$args = array(); |
| 1589 |
if( empty($item) ) return false; |
| 1590 |
if( isset($item['postid']) && $item['postid'] ){ |
| 1591 |
$args['item_id'] = $item['postid']; |
| 1592 |
$args['type'] = 'wpforo_like'; |
| 1593 |
} |
| 1594 |
if($args['item_id'] && $args['type']) wpforo_activity_delete( $args ); |
| 1595 |
} |
| 1596 |
|
| 1597 |
add_action( 'wpforo_after_add_topic', 'wpforo_activity_content', 9 ); |
| 1598 |
add_action( 'wpforo_after_add_post', 'wpforo_activity_content', 9 ); |
| 1599 |
add_action( 'wpforo_like', 'wpforo_activity_like', 9 ); |
| 1600 |
add_action( 'wpforo_after_delete_post', 'wpforo_activity_content_delete', 9 ); |
| 1601 |
add_action( 'wpforo_after_delete_post', 'wpforo_activity_like_delete', 9 ); |
| 1602 |
|
| 1603 |
|
| 1604 |
function wpforo_user_field( $field = '', $userid = 0, $echo = true ){ |
| 1605 |
$userid = ( !$userid ) ? WPF()->current_userid : $userid; |
| 1606 |
if( !$field || !$userid ) return false; |
| 1607 |
$field = wpforo_member( $userid, $field ); |
| 1608 |
$field = apply_filters( 'wpforo_user_field', $field, $userid ); |
| 1609 |
if( !is_array($field) && $field ){ |
| 1610 |
if( $echo ){ |
| 1611 |
echo $field; |
| 1612 |
} |
| 1613 |
else{ |
| 1614 |
return $field; |
| 1615 |
} |
| 1616 |
} |
| 1617 |
} |
| 1618 |
|
| 1619 |
function wpforo_content( $post, $echo = true ){ |
| 1620 |
if(is_array($post) && isset($post['body'])){ |
| 1621 |
$content = apply_filters('wpforo_content_before', $post['body'], $post); |
| 1622 |
$content = wpforo_kses( $content, 'post' ); |
| 1623 |
$content = apply_filters('wpforo_content', $content, $post); |
| 1624 |
$content = wpforo_content_filter( $content ); |
| 1625 |
$content = apply_filters('wpforo_content_after', $content, $post); |
| 1626 |
if( $echo ){ |
| 1627 |
echo $content; |
| 1628 |
} |
| 1629 |
else{ |
| 1630 |
return $content; |
| 1631 |
} |
| 1632 |
} |
| 1633 |
} |
| 1634 |
|
| 1635 |
function wpforo_share_toggle( $url = '', $text = '', $location = 'side', $custom = false ){ |
| 1636 |
$set = WPF()->api->options; |
| 1637 |
$position = (($set['sb_location_toggle'] == 'left' || $set['sb_location_toggle'] == 'right')) ? 'side' : $set['sb_location_toggle']; |
| 1638 |
if( !$set['sb_toggle_on'] || ( $position != $location && !$custom ) ) return false; |
| 1639 |
$location_class = ( $custom ) ? $location : $set['sb_location_toggle']; |
| 1640 |
?> |
| 1641 |
<div class="wpf-sb wpf-sb-<?php echo esc_attr($location_class) ?> wpf-sb-<?php echo esc_attr($set['sb_toggle']) ?> sb-tt-<?php echo esc_attr($set['sb_toggle_type']) ?>"> |
| 1642 |
<div class="wpf-sb-toggle"><i class="fas fa-share-alt" title="<?php wpforo_phrase('Share this post') ?>"></i></div> |
| 1643 |
<div class="wpf-sb-buttons" style="display: <?php if( $set['sb_toggle_type'] == 'collapsed' ) echo 'none'; ?>;"> |
| 1644 |
<?php do_action('wpforo_share_toggle_before', $url, $text, $location, $custom) ?> |
| 1645 |
<?php WPF()->api->share_toggle($url, $text); ?> |
| 1646 |
<?php do_action('wpforo_share_toggle_after', $url, $text, $location, $custom) ?> |
| 1647 |
</div> |
| 1648 |
</div> |
| 1649 |
<?php |
| 1650 |
} |
| 1651 |
|
| 1652 |
function wpforo_share_buttons( $location = 'bottom', $url = '', $custom = false ){ |
| 1653 |
$set = WPF()->api->options; |
| 1654 |
if( !$set['sb_on'] || (!wpfval($set, 'sb_location', $location) && !$custom) ) return false; |
| 1655 |
?> |
| 1656 |
<div class="wpf-sbtn wpf-sb-<?php echo esc_attr($location) ?> wpf-sb-style-<?php echo esc_attr($set['sb_style']) ?>" style="display: block"> |
| 1657 |
<div class="wpf-sbtn-title"><i class="fas fa-share-alt"></i> <span><?php wpforo_phrase('Share:') ?></span></div> |
| 1658 |
<div class="wpf-sbtn-wrap"> |
| 1659 |
<?php do_action('wpforo_share_buttons_before', $location, $url, $custom ) ?> |
| 1660 |
<?php WPF()->api->share_buttons($url); ?> |
| 1661 |
<?php do_action('wpforo_share_buttons_after', $location, $url, $custom ) ?> |
| 1662 |
</div> |
| 1663 |
<div class="wpf-clear"></div> |
| 1664 |
</div> |
| 1665 |
<?php |
| 1666 |
} |
| 1667 |
|
| 1668 |
function wpforo_page(){ |
| 1669 |
$page_template = ( wpfval($_GET, 'view') ) ? sanitize_title($_GET['view']) : false; |
| 1670 |
do_action('wpforo_page', $page_template ); |
| 1671 |
} |