| 1 |
<?php |
| 2 |
// Exit if accessed directly |
| 3 |
if( !defined( 'ABSPATH' ) ) exit; |
| 4 |
|
| 5 |
define('WPFORO_THEME_DIR', WPFORO_DIR . '/wpf-themes' ); |
| 6 |
define('WPFORO_THEME_URL', WPFORO_URL . '/wpf-themes' ); |
| 7 |
|
| 8 |
class wpForoTemplate{ |
| 9 |
private $wpforo; |
| 10 |
public $default; |
| 11 |
public $options; |
| 12 |
public $style; |
| 13 |
public $theme; |
| 14 |
|
| 15 |
function __construct( $wpForo ){ |
| 16 |
if(!isset($this->wpforo)) $this->wpforo = $wpForo; |
| 17 |
|
| 18 |
$this->init_defaults(); |
| 19 |
$this->init_options(); |
| 20 |
$this->init_hooks(); |
| 21 |
} |
| 22 |
|
| 23 |
private function init_hooks(){ |
| 24 |
if( is_wpforo_page() ){ |
| 25 |
add_filter("mce_external_plugins", array(&$this, 'add_tinymce_buttons'), 15); |
| 26 |
add_filter("tiny_mce_plugins", array(&$this, 'filter_tinymce_plugins'), 15); |
| 27 |
add_filter("wp_mce_translation", array(&$this, 'add_tinymce_translations')); |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
private function init_defaults(){ |
| 32 |
$this->default = new stdClass; |
| 33 |
|
| 34 |
$this->default->style = array( |
| 35 |
'font_size_forum' => 17, |
| 36 |
'font_size_topic' => 16, |
| 37 |
'font_size_post_content' => 14, |
| 38 |
'custom_css' => "#wpforo-wrap {\r\n font-size: 13px; width: 100%; padding:10px 20px; margin:0px;\r\n}\r\n" |
| 39 |
); |
| 40 |
|
| 41 |
$theme = $this->find_theme( 'classic' ); |
| 42 |
if( $current_theme = get_option('wpforo_theme_options') ) $theme = wpforo_deep_merge($theme, $current_theme); |
| 43 |
$this->default->options = $theme; |
| 44 |
} |
| 45 |
|
| 46 |
private function init_options(){ |
| 47 |
$this->style = get_wpf_option('wpforo_style_options', $this->default->style); |
| 48 |
|
| 49 |
$this->options = get_wpf_option('wpforo_theme_options', $this->default->options); |
| 50 |
$this->theme = $this->options['folder']; |
| 51 |
|
| 52 |
$this->init_defines(); |
| 53 |
} |
| 54 |
|
| 55 |
private function init_defines(){ |
| 56 |
define('WPFORO_THEME', $this->theme ); |
| 57 |
define('WPFORO_TEMPLATE_DIR', WPFORO_THEME_DIR . '/' . $this->theme ); |
| 58 |
define('WPFORO_TEMPLATE_URL', WPFORO_THEME_URL . '/' . $this->theme ); |
| 59 |
} |
| 60 |
|
| 61 |
function add_tinymce_buttons($plugin_array) { |
| 62 |
$plugin_array = array(); |
| 63 |
$plugin_array['wpforo_pre_button'] = WPFORO_URL . '/wpf-assets/js/tinymce-pre.js'; |
| 64 |
$plugin_array['wpforo_link_button'] = WPFORO_URL . '/wpf-assets/js/tinymce-link.js'; |
| 65 |
$plugin_array['wpforo_source_code_button'] = WPFORO_URL . '/wpf-assets/js/tinymce-code.js'; |
| 66 |
return $plugin_array; |
| 67 |
} |
| 68 |
|
| 69 |
function filter_tinymce_plugins($plugins){ |
| 70 |
return array('hr','lists','textcolor','paste'); |
| 71 |
} |
| 72 |
|
| 73 |
function add_tinymce_translations($mce_translation){ |
| 74 |
$mce_translation['Insert link'] = __( 'Insert link' ); |
| 75 |
$mce_translation['Link Text'] = __( 'Link Text' ); |
| 76 |
$mce_translation['Open link in a new tab'] = __( 'Open link in a new tab' ); |
| 77 |
return $mce_translation; |
| 78 |
} |
| 79 |
|
| 80 |
function topic_form($forumid){ |
| 81 |
if(!isset($this->wpforo->post->options['max_upload_size']) || !$this->wpforo->post->options['max_upload_size']){ $server_mus = wpforo_human_size_to_bytes(ini_get('upload_max_filesize')); if( !$server_mus || $server_mus > 10485760 ) $server_mus = 10485760; $this->wpforo->post->options['max_upload_size'] = $server_mus;} |
| 82 |
?> |
| 83 |
<div id="wpf-topic-create" class="wpf-topic-create"> |
| 84 |
<form name="topic" action="" enctype="multipart/form-data" method="POST"> |
| 85 |
<?php wp_nonce_field( 'wpforo_verify_form', 'wpforo_form' ); ?> |
| 86 |
<input type="hidden" name="topic[action]" value="add"/> |
| 87 |
<input type="hidden" id="parent" name="topic[forumid]" value="<?php echo intval($forumid) ?>" /> |
| 88 |
|
| 89 |
<label style="padding-left: 8px;"> <?php wpforo_phrase('Topic Title') ?>: </label> |
| 90 |
<input required="true" autofocus type="text" name="topic[title]" class="wpf-subject" value="" id="title" autocomplete="off" placeholder="<?php esc_attr( wpforo_phrase('Enter title here') ) ?>"> |
| 91 |
<?php |
| 92 |
$content = ''; |
| 93 |
$editor_id = 'postbody'; |
| 94 |
$settings = array( |
| 95 |
'wpautop' => true,// use wpautop? |
| 96 |
'media_buttons'=> FALSE,// show insert / upload button(s) |
| 97 |
'textarea_name'=> $editor_id,// set the textarea name to something different, square brackets [] can be used here |
| 98 |
'textarea_rows'=> get_option('default_post_edit_rows', 20),// rows = "..." |
| 99 |
'tabindex'=> '', |
| 100 |
'editor_height' => '180', |
| 101 |
'editor_css' => '', // intended for extra styles for both visual and HTML editors buttons, needs to include the < style > tags, can use "scoped". |
| 102 |
'editor_class'=> '', // add extra class(es) to the editor textarea |
| 103 |
'teeny'=> FALSE, // output the minimal editor config used in Press This |
| 104 |
'dfw'=> false, // replace the default fullscreen with DFW (supported on the front - end in WordPress 3.4) |
| 105 |
'tinymce'=> array( |
| 106 |
'toolbar1' => 'bold,italic,underline,strikethrough,forecolor,bullist,numlist,hr,alignleft,aligncenter,alignright,alignjustify,link,unlink,blockquote,pre,undo,redo,pastetext,source_code', |
| 107 |
'toolbar2' => '', |
| 108 |
'toolbar3' => '', |
| 109 |
'toolbar4' => '', |
| 110 |
'content_style' => 'blockquote{border: #cccccc 1px dotted; background: #F7F7F7; padding:10px;font-size:12px; font-style:italic; margin: 20px 10px;}', |
| 111 |
'object_resizing' => false |
| 112 |
), // load TinyMCE, can be used to pass settings directly to TinyMCE using an array() |
| 113 |
'quicktags'=> true, // load Quicktags, can be used to pass settings directly to Quicktags using an array() |
| 114 |
'default_editor' => 'tinymce' |
| 115 |
); |
| 116 |
wp_editor( $content, $editor_id, $settings ); |
| 117 |
?> |
| 118 |
<div class="wpf-extra-fields"> |
| 119 |
<?php do_action('wpforo_topic_form_extra_fields_before') ?> |
| 120 |
<div class="wpf-main-fields"> |
| 121 |
<?php if($this->wpforo->perm->forum_can('s', $forumid)) : ?> |
| 122 |
<input id="t_sticky" name="topic[type]" type="checkbox" value="1"> |
| 123 |
<i class="fa fa-exclamation fa-0x"></i> <label for="t_sticky" style="padding-bottom:2px; cursor: pointer;"><?php wpforo_phrase('Set Topic Sticky'); ?> </label> |
| 124 |
<span class="wpfbs"> | </span> |
| 125 |
<?php endif; ?> |
| 126 |
<?php if($this->wpforo->perm->forum_can('p', $forumid) || $this->wpforo->perm->forum_can('op', $forumid)) : ?> |
| 127 |
<input id="t_private" name="topic[private]" type="checkbox" value="1"> |
| 128 |
<i class="fa fa-eye-slash fa-0x"></i> <label for="t_private" style="padding-bottom:2px; cursor: pointer;" title="<?php wpforo_phrase('Only Admins and Moderators can see your private topics.'); ?>"><?php wpforo_phrase('Private Topic'); ?> </label> |
| 129 |
<span class="wpfbs"> | </span> |
| 130 |
<?php endif; ?> |
| 131 |
<?php do_action('wpforo_topic_form_buttons_hook'); ?> |
| 132 |
</div> |
| 133 |
<?php if( $this->wpforo->perm->can_attach() ): ?> |
| 134 |
<?php if(!defined('WPFOROATTACH_BASENAME') && $this->wpforo->perm->forum_can('a', $forumid)): ?> |
| 135 |
<div class="wpf-default-attachment" style="padding-top:5px;"> |
| 136 |
<label for="file"><?php wpforo_phrase('Attach file:') ?> </label> <input id="file" type="file" name="attachfile" /> |
| 137 |
<p><?php wpforo_phrase('Maximum allowed file size is'); echo ' ' . wpforo_print_size($this->wpforo->post->options['max_upload_size']); ?></p> |
| 138 |
</div> |
| 139 |
<?php endif; ?> |
| 140 |
<?php endif; ?> |
| 141 |
<?php do_action('wpforo_topic_form_extra_fields_after') ?> |
| 142 |
</div> |
| 143 |
<?php if( wpforo_feature('subscribe_checkbox_on_post_editor', $this->wpforo) ) : ?> |
| 144 |
<div class="wpf-topic-sbs"><input id="wpf-topic-sbs" type="checkbox" name="wpforo_topic_subs" value="1" <?php echo ( wpforo_feature('subscribe_checkbox_default_status', $this->wpforo) ) ? 'checked="true" ' : ''; ?>/> <label for="wpf-topic-sbs"><?php wpforo_phrase('Subscribe to this topic') ?></label></div> |
| 145 |
<?php endif; ?> |
| 146 |
<input id="formbutton" type="submit" name="topic[save]" class="button button-primary forum_submit" value="<?php wpforo_phrase('Add Topic') ?>"> |
| 147 |
<div class="wpf-clear"></div> |
| 148 |
</form> |
| 149 |
</div> |
| 150 |
|
| 151 |
<?php |
| 152 |
} |
| 153 |
|
| 154 |
/** |
| 155 |
* |
| 156 |
* @param array $args |
| 157 |
* |
| 158 |
* Please note that all array elements are required! |
| 159 |
* example of args |
| 160 |
* $default = array( |
| 161 |
* "topic_closed" => $topic['closed'], // is topic closed or opened (values 1 or 0) |
| 162 |
* "topicid" => $topic['topicid'], // the id of topic |
| 163 |
* "forumid" => $forum_data['forumid'], |
| 164 |
* "layout" => $cat_layout, |
| 165 |
* "topic_title" => $topic['title'] // the title of topic |
| 166 |
* ); |
| 167 |
* |
| 168 |
* @return html form |
| 169 |
*/ |
| 170 |
|
| 171 |
function reply_form($args){ |
| 172 |
extract($args, EXTR_OVERWRITE); ?> |
| 173 |
<!-- Report Dialog --> |
| 174 |
|
| 175 |
<div id="reportdialog" title="<?php esc_attr( wpforo_phrase('Report to Administration') ) ?>" style="display: none"> |
| 176 |
<form id="reportform"> |
| 177 |
<input type="hidden" id="reportpostid" value=""/> |
| 178 |
<textarea required style="width:100%; height:105px;" id="reportmessagecontent" placeholder="<?php esc_attr( wpforo_phrase('Write message') ) ?>"></textarea> |
| 179 |
</form> |
| 180 |
<input style="float: right;" id="sendreport" type="submit" value="<?php wpforo_phrase('Send Report') ?>"/> |
| 181 |
</div> |
| 182 |
|
| 183 |
<!-- Report Dialog end --> |
| 184 |
|
| 185 |
<!-- Move Dialog --> |
| 186 |
|
| 187 |
<div id="movedialog" title="<?php esc_attr( wpforo_phrase('Move topic') ) ?>" style="display: none"> |
| 188 |
<div class="form-field"> |
| 189 |
<label for="parent"><?php wpforo_phrase('Choose target forum') ?></label> |
| 190 |
<form id="topicmoveform" method="POST"> |
| 191 |
<?php wp_nonce_field( 'wpforo_verify_form', 'wpforo_form' ); ?> |
| 192 |
<input type="hidden" name="movetopicid" value="<?php echo intval($topicid) ?>"/> |
| 193 |
<input type="hidden" name="post[save]" value="move"/> |
| 194 |
<select id="parent" name="topic[forumid]" class="postform"> |
| 195 |
<?php $this->wpforo->forum->tree('select_box', FALSE, $topicid ); ?> |
| 196 |
</select> |
| 197 |
<input type="submit" value="<?php wpforo_phrase('Move') ?>"/> |
| 198 |
</form> |
| 199 |
</div> |
| 200 |
</div> |
| 201 |
|
| 202 |
<!-- move Dialog end --> |
| 203 |
<?php |
| 204 |
if( $topic_closed ) return; |
| 205 |
|
| 206 |
$head_html = '<p id="wpf-reply-form-title">'.wpforo_phrase('Leave a reply', false).'</p>'; |
| 207 |
$head_html = apply_filters( 'wpforo_reply_form_head', $head_html, $args ); |
| 208 |
if(!isset($this->wpforo->post->options['max_upload_size']) || !$this->wpforo->post->options['max_upload_size']){$server_mus = wpforo_human_size_to_bytes(ini_get('upload_max_filesize')); if( !$server_mus || $server_mus > 10485760 ) $server_mus = 10485760; $this->wpforo->post->options['max_upload_size'] = $server_mus;} |
| 209 |
?> |
| 210 |
<div id="wpf-form-wrapper"> |
| 211 |
<?php echo $head_html; //this is a HTML content ?> |
| 212 |
<div id="wpf-post-create" class="wpf-post-create"> |
| 213 |
<form name="post" action="" enctype="multipart/form-data" method="POST" class="editor"> |
| 214 |
<?php wp_nonce_field( 'wpforo_verify_form', 'wpforo_form' ); ?> |
| 215 |
<input type="hidden" id="formaction" name="post[action]" value="add"/> |
| 216 |
<input type="hidden" id="formtopicid" name="post[topicid]" value="<?php echo intval($topicid) ?>"/> |
| 217 |
<input type="hidden" id="postparentid" name="post[parentid]" value="0"/> |
| 218 |
<input type="hidden" id="formpostid" name="post[postid]" value=""/> |
| 219 |
<input type="hidden" id="parent" name="post[forumid]" value="<?php echo intval($forumid) ?>" /> |
| 220 |
<?php |
| 221 |
$reply_title = wpforo_phrase('RE', false) . ': '. $topic_title; |
| 222 |
$reply_title = apply_filters( 'wpforo_reply_form_field_title', $reply_title, $args ); |
| 223 |
$reply_title = esc_attr($reply_title); |
| 224 |
?> |
| 225 |
<input id="title" required="true" type="text" name="post[title]" class="wpf-subject" value="<?php if($reply_title) echo esc_attr($reply_title); ?>" autocomplete="off" placeholder="<?php if($reply_title) echo esc_attr($reply_title); ?>"><br/> |
| 226 |
<?php |
| 227 |
$content = ''; |
| 228 |
$editor_id = 'postbody'; |
| 229 |
$settings = array( |
| 230 |
'wpautop' => true,// use wpautop? |
| 231 |
'media_buttons'=> FALSE,// show insert / upload button(s) |
| 232 |
'textarea_name'=> $editor_id,// set the textarea name to something different, square brackets [] can be used here |
| 233 |
'textarea_rows'=> get_option('default_post_edit_rows', 5),// rows = "..." |
| 234 |
'editor_class'=> 'wpeditor', // add extra class(es) to the editor textarea |
| 235 |
'teeny'=> false, // output the minimal editor config used in Press This |
| 236 |
'dfw'=> false, // replace the default fullscreen with DFW (supported on the front - end in WordPress 3.4) |
| 237 |
'editor_height' => '180', |
| 238 |
'tinymce'=> array( |
| 239 |
'toolbar1' => 'bold,italic,underline,strikethrough,forecolor,bullist,numlist,hr,alignleft,aligncenter,alignright,alignjustify,link,unlink,blockquote,pre,undo,redo,pastetext,source_code', |
| 240 |
'toolbar2' => '', |
| 241 |
'toolbar3' => '', |
| 242 |
'toolbar4' => '', |
| 243 |
'content_style' => 'blockquote{border: #cccccc 1px dotted; background: #F7F7F7; padding:10px;font-size:12px; font-style:italic; margin: 20px 10px;}', |
| 244 |
'object_resizing' => false |
| 245 |
), // load TinyMCE, can be used to pass settings directly to TinyMCE using an array() |
| 246 |
'quicktags'=> true, // load Quicktags, can be used to pass settings directly to Quicktags using an array() |
| 247 |
'default_editor' => 'tinymce', // load Quicktags, can be used to pass settings directly to Quicktags using an array() |
| 248 |
); |
| 249 |
wp_editor( $content, $editor_id, $settings ); |
| 250 |
?> |
| 251 |
<div class="wpf-extra-fields"> |
| 252 |
<?php do_action('wpforo_reply_form_extra_fields_before') ?> |
| 253 |
<?php do_action('wpforo_reply_form_buttons_hook'); ?> |
| 254 |
<?php if( $this->wpforo->perm->can_attach() ): ?> |
| 255 |
<?php if(!defined('WPFOROATTACH_BASENAME') && $this->wpforo->perm->forum_can('a', $forumid)): ?> |
| 256 |
<div class="wpf-default-attachment"> |
| 257 |
<label for="file"><?php wpforo_phrase('Attach file:') ?> </label> <input id="file" type="file" name="attachfile" /> |
| 258 |
<p><?php wpforo_phrase('Maximum allowed file size is'); echo ' ' . wpforo_print_size($this->wpforo->post->options['max_upload_size']); ?></p> |
| 259 |
</div> |
| 260 |
<?php endif; ?> |
| 261 |
<?php endif; ?> |
| 262 |
<?php do_action('wpforo_reply_form_extra_fields_after') ?> |
| 263 |
</div> |
| 264 |
<?php if( wpforo_feature('subscribe_checkbox_on_post_editor', $this->wpforo) ) : |
| 265 |
$args = array( "userid" => $this->wpforo->current_userid , "itemid" => intval($topicid), "type" => "topic" ); |
| 266 |
$subscribe = $this->wpforo->sbscrb->get_subscribe( $args ); |
| 267 |
if( !isset($subscribe['subid']) ) : ?> |
| 268 |
<div class="wpf-topic-sbs"><input id="wpf-topic-sbs" type="checkbox" name="wpforo_topic_subs" value="1" <?php echo ( wpforo_feature('subscribe_checkbox_default_status', $this->wpforo) ) ? 'checked="true" ' : ''; ?> /> <label for="wpf-topic-sbs"><?php wpforo_phrase('Subscribe to this topic') ?></label></div> |
| 269 |
<?php endif; |
| 270 |
endif; ?> |
| 271 |
<input id="formbutton" type="submit" name="post[save]" class="button button-primary forum_submit" value="<?php wpforo_phrase('Add Reply') ?>"> |
| 272 |
<div class="wpf-clear"></div> |
| 273 |
</form> |
| 274 |
</div> |
| 275 |
</div> |
| 276 |
<?php |
| 277 |
} |
| 278 |
|
| 279 |
function pagenavi($paged, $items_count, $permalink = TRUE, $class = ''){ |
| 280 |
$items_per_page = ( $this->wpforo->current_object['template'] == 'topic' ? $this->wpforo->post->options['topics_per_page'] : $this->wpforo->post->options['posts_per_page'] ); |
| 281 |
if($items_count <= $items_per_page) return; |
| 282 |
|
| 283 |
$pages_count = ceil($items_count/$items_per_page); |
| 284 |
|
| 285 |
if($permalink){ |
| 286 |
$url = trim( preg_replace('#\/paged\/[\d]+\/*.*$#is', '', wpforo_get_request_uri()), '/' ) . '/paged/'; |
| 287 |
}else{ |
| 288 |
$url = trim( preg_replace('#[\&\?]wpfpaged=[\d]*.*$#is', '', wpforo_get_request_uri()), '/' ); |
| 289 |
$url .= (strpos($url, '?') === FALSE ? '?' : '&') . 'wpfpaged='; |
| 290 |
} |
| 291 |
?> |
| 292 |
|
| 293 |
<div class="wpf-navi <?php echo esc_attr($class) ?>"> |
| 294 |
<div class="wpf-navi-wrap"> |
| 295 |
<span class="wpf-page-info"><?php wpforo_phrase('Page') ?> <?php echo intval($paged) ?> / <?php echo intval($pages_count) ?></span> |
| 296 |
<?php if( $paged - 1 > 0 ): ?><a href="<?php echo esc_url($url) . ($paged - 1) ?>" class="wpf-prev-button"><i class="fa fa-chevron-left fa-sx"></i> <?php wpforo_phrase('prev') ?></a><?php endif ?> |
| 297 |
<select class="wpf-navi-dropdown" onchange="if (this.value) window.location.href=this.value" title="<?php esc_attr( wpforo_phrase('Select Page') ) ?>"> |
| 298 |
<?php for($i = 1; $i <= $pages_count; $i++) : ?> |
| 299 |
<option value="<?php echo esc_url($url) . $i ?>" <?php echo $paged == $i ? ' selected="selected"' : '' ?>><?php echo intval($i); ?></option> |
| 300 |
<?php endfor; ?> |
| 301 |
</select> |
| 302 |
<?php if( $paged + 1 <= $pages_count ): ?><a href="<?php echo esc_url($url) . ($paged + 1) ?>" class="wpf-prev-button"><?php wpforo_phrase('next') ?> <i class="fa fa-chevron-right fa-sx"></i></a><?php endif ?> |
| 303 |
</div> |
| 304 |
</div> |
| 305 |
|
| 306 |
<?php |
| 307 |
} |
| 308 |
|
| 309 |
function likers($postid){ |
| 310 |
if(!$postid) return ''; |
| 311 |
|
| 312 |
$post = wpforo_post($postid); |
| 313 |
|
| 314 |
$l_count = wpforo_post($postid, 'likes_count'); |
| 315 |
$l_usernames = wpforo_post($postid, 'likers_usernames'); |
| 316 |
$return = ''; |
| 317 |
|
| 318 |
if( $l_count ){ |
| 319 |
if($l_usernames[0]['ID'] == $this->wpforo->current_userid) $l_usernames[0]['display_name'] = wpforo_phrase('You', FALSE); |
| 320 |
if($l_count == 1){ |
| 321 |
$return = sprintf( wpforo_phrase('%s liked', FALSE), '<a href="' . esc_url($this->wpforo->member->get_profile_url($l_usernames[0]['ID'])) . '">'.esc_html($l_usernames[0]['display_name']).'</a>' ); |
| 322 |
}elseif($l_count == 2){ |
| 323 |
$return = sprintf( wpforo_phrase('%s and %s liked', FALSE), '<a href="' . esc_url($this->wpforo->member->get_profile_url($l_usernames[0]['ID'])) . '">'.esc_html($l_usernames[0]['display_name']).'</a>', '<a href="'.esc_url($this->wpforo->member->get_profile_url($l_usernames[1]['ID'])).'">'.esc_html($l_usernames[1]['display_name']).'</a>' ); |
| 324 |
}elseif($l_count == 3){ |
| 325 |
$return = sprintf( wpforo_phrase('%s, %s and %s liked', FALSE), '<a href="' . esc_url($this->wpforo->member->get_profile_url($l_usernames[0]['ID'])) .'">'.esc_html($l_usernames[0]['display_name']).'</a>', '<a href="'.esc_url($this->wpforo->member->get_profile_url($l_usernames[1]['ID'])).'">'.esc_html($l_usernames[1]['display_name']).'</a>', '<a href="'.esc_url($this->wpforo->member->get_profile_url($l_usernames[2]['ID'])).'">'.esc_html($l_usernames[2]['display_name']).'</a>' ); |
| 326 |
}elseif($l_count >= 4){ |
| 327 |
$l_count = $l_count - 3; |
| 328 |
$return = sprintf( wpforo_phrase('%s, %s, %s and %d people liked', FALSE), '<a href="' . esc_url($this->wpforo->member->get_profile_url($l_usernames[0]['ID'])) .'">'.esc_html($l_usernames[0]['display_name']).'</a>', '<a href="'.esc_url($this->wpforo->member->get_profile_url($l_usernames[1]['ID'])).'">'.esc_html($l_usernames[1]['display_name']).'</a>', '<a href="'.esc_url($this->wpforo->member->get_profile_url($l_usernames[2]['ID'])).'">'.esc_html($l_usernames[2]['display_name']).'</a>', $l_count ); |
| 329 |
} |
| 330 |
} |
| 331 |
return $return; |
| 332 |
} |
| 333 |
|
| 334 |
|
| 335 |
/** |
| 336 |
* Get actions buttons |
| 337 |
* |
| 338 |
* @since 1.0.0 |
| 339 |
* |
| 340 |
* @param array buttons names function will return buttons by this array |
| 341 |
* |
| 342 |
* @param array $forum required |
| 343 |
* |
| 344 |
* @param array $topic required |
| 345 |
* |
| 346 |
* @param array $post required |
| 347 |
* |
| 348 |
* @param int $is_topic required this is a first post in the loop |
| 349 |
* |
| 350 |
* $buttons = array( 'reply', 'answer', 'comment', 'quote', 'like', 'report', 'sticky', 'close', 'move', 'edit', 'delete', 'link' ); |
| 351 |
* |
| 352 |
* @return html ( buttons ) |
| 353 |
*/ |
| 354 |
|
| 355 |
function buttons( $buttons, $forum = array(), $topic = array(), $post = array(), $is_topic = FALSE ){ |
| 356 |
|
| 357 |
$button_html = array(); |
| 358 |
|
| 359 |
$forumid = (isset($forum['forumid'])) ? $forum['forumid'] : 0; |
| 360 |
$topicid = (isset($topic['topicid'])) ? $topic['topicid'] : 0; |
| 361 |
$postid = (isset($post['postid'])) ? $post['postid'] : 0; |
| 362 |
|
| 363 |
$is_sticky = (isset($topic['type'])) ? $topic['type'] : 0; |
| 364 |
$is_closed = (isset($topic['closed'])) ? $topic['closed'] : 0; |
| 365 |
$is_private = (isset($topic['private'])) ? $topic['private'] : 0; |
| 366 |
$is_solved = (isset($post['is_answer'])) ? $post['is_answer'] : 0; |
| 367 |
$is_approve = (isset($post['status'])) ? $post['status'] : 0; |
| 368 |
|
| 369 |
foreach($buttons as $button){ |
| 370 |
|
| 371 |
switch($button){ |
| 372 |
|
| 373 |
case 'reply': |
| 374 |
if($is_closed) break; |
| 375 |
if( $this->wpforo->perm->forum_can('cr', $forumid) ){ |
| 376 |
$button_html[] = '<span id="parentpostid'.intval($postid).'" class="wpforo-reply wpf-action add_post_button"><i class="fa fa-reply fa-rotate-180"></i>' . wpforo_phrase('Reply', false).'</span>'; |
| 377 |
}else{ |
| 378 |
$button_html[] = '<span class="wpf-action not_reg_user"><i class="fa fa-reply fa-rotate-180"></i> ' . wpforo_phrase('Reply', false).'</span>'; |
| 379 |
} |
| 380 |
break; |
| 381 |
case 'answer': |
| 382 |
if( $this->wpforo->perm->forum_can('cr', $forumid) ){ |
| 383 |
$button_html[] = '<span class="wpforo-answer wpf-button add_post_button"><i class="fa fa-pencil"></i> ' . wpforo_phrase('Answer', false).'</span>'; |
| 384 |
}else{ |
| 385 |
$button_html[] = '<span class="wpf-button not_reg_user"><i class="fa fa-pencil"></i> ' . wpforo_phrase('Answer', false).'</span>'; |
| 386 |
} |
| 387 |
break; |
| 388 |
case 'comment': |
| 389 |
if($is_closed) break; |
| 390 |
$title = wpforo_phrase('Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.', false); |
| 391 |
if( $this->wpforo->perm->forum_can('cr', $forumid) ) { |
| 392 |
$button_html[] = '<span id="parentpostid'.intval($postid).'" class="wpforo-childreply wpf-button add_post_button" title="'.esc_attr($title).'"><i class="fa fa-comment"></i> ' . wpforo_phrase('Add a comment', false).'</span>'; |
| 393 |
}else{ |
| 394 |
$button_html[] = '<span class="not_reg_user wpf-button add_post_button" title="'.esc_attr($title).'"><i class="fa fa-comment"></i> ' . wpforo_phrase('Add a comment', false).'</span>'; |
| 395 |
} |
| 396 |
break; |
| 397 |
case 'quote': |
| 398 |
if($is_closed) break; |
| 399 |
if( $this->wpforo->perm->forum_can('cr', $forumid) ) { |
| 400 |
$button_html[] = '<span id="wpfquotepost'.intval($postid).'" class="wpforo-quote wpf-action"><i class="fa fa-quote-left fa-0x"></i>' . wpforo_phrase('Quote', false).'</span>'; |
| 401 |
}else{ |
| 402 |
$button_html[] = '<span class="wpf-action not_reg_user"><i class="fa fa-quote-left fa-0x"></i>' . wpforo_phrase('Quote', false).'</span>'; |
| 403 |
} |
| 404 |
break; |
| 405 |
case 'like': |
| 406 |
if( $this->wpforo->perm->forum_can('l', $forumid) ) { |
| 407 |
$like_status = ( $this->wpforo->post->is_liked( $postid, $this->wpforo->current_userid ) === FALSE ? 'wpforo-like' : 'wpforo-unlike' ); |
| 408 |
$like_icon = ( $like_status == 'wpforo-like') ? 'up' : 'down'; |
| 409 |
$button_html[] = '<span id="wpflike'. intval($postid) .'" class="wpf-action '. sanitize_html_class($like_status) .'"><i id="likeicon'. intval($postid) .'" class="fa fa-thumbs-o-'. esc_attr($like_icon) .' fa-0x"></i><span id="liketext'. intval($postid) .'">' . wpforo_phrase( str_replace('wpforo-', '', $like_status), false) . '</span></span>'; |
| 410 |
} |
| 411 |
break; |
| 412 |
case 'report': |
| 413 |
if( $this->wpforo->perm->forum_can('r', $forumid) ) { |
| 414 |
$button_html[] = '<span id="wpfreport'. intval($postid) .'" class="wpf-action wpforo-report"><i class="fa fa-exclamation-triangle"></i>' . wpforo_phrase('Report', false).'</span>'; |
| 415 |
} |
| 416 |
break; |
| 417 |
case 'sticky': |
| 418 |
if( $this->wpforo->perm->forum_can('s', $forumid) ) { |
| 419 |
$sticky_status = ( $is_sticky ? 'wpforo-unsticky' : 'wpforo-sticky'); |
| 420 |
$button_html[] = '<span id="wpfsticky'. intval($topicid) .'" class="wpf-action '. sanitize_html_class($sticky_status) .'"><i class="fa fa-exclamation fa-0x"></i><span id="stickytext'. intval($topicid) .'">' . wpforo_phrase( str_replace('wpforo-', '', $sticky_status), false).'</span></span>'; |
| 421 |
} |
| 422 |
break; |
| 423 |
case 'private': |
| 424 |
if( $this->wpforo->perm->forum_can('p', $forumid) || ($this->wpforo->current_userid == $post['userid'] && $this->wpforo->perm->forum_can('op', $forumid)) ) { |
| 425 |
$private_status = ( $is_private ? 'wpforo-public' : 'wpforo-private'); |
| 426 |
$private_icon = ( $private_status == 'wpforo-public') ? 'eye' : 'eye-slash'; |
| 427 |
$button_html[] = '<span id="wpfprivate'. intval($topicid) .'" class="wpf-action '. sanitize_html_class($private_status) .'"><i id="privateicon'. intval($topicid) .'" class="fa fa-'. esc_attr($private_icon) .' fa-0x"></i><span id="privatetext'. intval($topicid) .'">' . wpforo_phrase( str_replace('wpforo-', '', $private_status), false).'</span></span>'; |
| 428 |
} |
| 429 |
break; |
| 430 |
case 'solved': |
| 431 |
if( $this->wpforo->perm->forum_can('sv', $forumid) || ($this->wpforo->current_userid == $post['userid'] && $this->wpforo->perm->forum_can('osv', $forumid)) ) { |
| 432 |
$solved_status = ( $is_solved ? 'wpforo-unsolved' : 'wpforo-solved'); |
| 433 |
$button_html[] = '<span id="wpfsolved'. intval($postid) .'" class="wpf-action '. sanitize_html_class($solved_status) .'"><i class="fa fa-check-circle fa-0x"></i><span id="solvedtext'. intval($postid) .'">' . wpforo_phrase( str_replace('wpforo-', '', $solved_status), false).'</span></span>'; |
| 434 |
} |
| 435 |
break; |
| 436 |
case 'approved': |
| 437 |
if( $this->wpforo->perm->forum_can('au', $forumid) ) { |
| 438 |
$approve_status = ( !$is_approve ? 'wpforo-unapprove' : 'wpforo-approve'); |
| 439 |
$approve_icon = ( $approve_status == 'wpforo-unapprove') ? 'fa-exclamation-circle' : 'fa-check'; |
| 440 |
$button_html[] = '<span id="wpfapprove'. intval($postid) .'" class="wpf-action '. sanitize_html_class($approve_status) .'"><i id="approveicon'. intval($postid) .'" class="fa '. esc_attr($approve_icon) .' fa-0x"></i><span id="approvetext'. intval($postid) .'">' . wpforo_phrase( str_replace('wpforo-', '', $approve_status), false).'</span></span>'; |
| 441 |
} |
| 442 |
break; |
| 443 |
case 'close': |
| 444 |
if( $this->wpforo->perm->forum_can('cot', $forumid) ) { |
| 445 |
$open_status = ( $is_closed ? 'wpforo-open' : 'wpforo-close' ); |
| 446 |
$open_icon = ($open_status == 'wpforo-open') ? 'unlock' : 'lock'; |
| 447 |
$button_html[] = '<span id="wpfclose'. intval($topicid) .'" class="wpf-action '. sanitize_html_class($open_status) .'"><i id="closeicon'. intval($topicid) .'" class="fa fa-'. esc_attr($open_icon) .' fa-0x"></i><span id="closetext'. intval($topicid) .'">' . wpforo_phrase( str_replace('wpforo-', '', $open_status), false).'</span></span>'; |
| 448 |
} |
| 449 |
break; |
| 450 |
case 'move': |
| 451 |
if( $this->wpforo->perm->forum_can('mt', $forumid) ) { |
| 452 |
$button_html[] = '<span class="wpf-action wpforo-move"><i class="fa fa-share-square-o fa-0x"></i>' . wpforo_phrase('Move', false).'</span>'; |
| 453 |
} |
| 454 |
break; |
| 455 |
case 'edit': |
| 456 |
if($is_closed) break; |
| 457 |
if( $this->wpforo->member->current_user_is_new() && $post['status'] ){ |
| 458 |
//New registered user's unapproved topic/post | No Edit button. |
| 459 |
} |
| 460 |
else{ |
| 461 |
$diff = current_time( 'timestamp', 1 ) - strtotime($post['created']); |
| 462 |
if( $this->wpforo->perm->forum_can( ($is_topic ? 'et' : 'er'), $forumid ) || ($this->wpforo->current_userid == $post['userid'] && $this->wpforo->perm->forum_can( ($is_topic ? 'eot' : 'eor' ), $forumid ) && $diff < $this->wpforo->post->options[($is_topic ? 'eot' : 'eor' ).'_durr'] ) ) { |
| 463 |
$a = ( $is_topic ) ? 'wpfedittopicpid' : ''; |
| 464 |
$b = ( $is_topic ) ? $postid : $postid; |
| 465 |
$button_html[] = '<span id="'. esc_attr( $a . $b ) .'" class="wpforo-edit wpf-action"><i class="fa fa-edit fa-0x"></i>' . wpforo_phrase('Edit', false).'</span>'; |
| 466 |
} |
| 467 |
} |
| 468 |
break; |
| 469 |
case 'delete': |
| 470 |
if( $this->wpforo->member->current_user_is_new() && $post['status'] ){ |
| 471 |
//New registered user's unapproved topic/post | No Delete button. |
| 472 |
} |
| 473 |
else{ |
| 474 |
$diff = current_time( 'timestamp', 1 ) - strtotime($post['created']); |
| 475 |
if( $this->wpforo->perm->forum_can( ($is_topic ? 'dt' : 'dr' ), $forumid ) || ($this->wpforo->current_userid == $post['userid'] && $this->wpforo->perm->forum_can( ($is_topic ? 'dot' : 'dor' ), $forumid ) && $diff < $this->wpforo->post->options[($is_topic ? 'dot' : 'dor' ).'_durr']) ){ |
| 476 |
$a = ( $is_topic ) ? 'wpftopicdelete' : 'wpfreplydelete'; |
| 477 |
$b = ( $is_topic ) ? $topicid : $postid; |
| 478 |
$button_html[] = '<span id="'. esc_attr( $a . $b ) .'" class="wpf-action wpforo-delete"><i class="fa fa-times fa-0x"></i>' . wpforo_phrase('Delete', false).'</span>'; |
| 479 |
} |
| 480 |
} |
| 481 |
break; |
| 482 |
case 'link': |
| 483 |
$url = ( $is_topic ) ? $this->wpforo->topic->get_topic_url( $topic ) : wpforo_post( $postid, 'url' ); |
| 484 |
$button_html[] = '<a href="'. esc_url($url) .'"><i class="fa fa-link fa-0x"></i></a>'; |
| 485 |
break; |
| 486 |
case 'positivevote': |
| 487 |
if( $this->wpforo->perm->forum_can('v', $forumid) ) { |
| 488 |
$button_html[] = '<i itemtype="' . ( $is_topic ? 'topic' : 'reply' ) . '" id="wpfvote-up-'. intval($postid) .'" class="voteup fa fa-play fa-rotate-270 wpfcl-0"></i>'; |
| 489 |
}else{ |
| 490 |
$button_html[] = '<i class="not_reg_user fa fa-play fa-rotate-270 wpfcl-0"></i>'; |
| 491 |
} |
| 492 |
break; |
| 493 |
case 'negativevote': |
| 494 |
if( $this->wpforo->perm->forum_can('v', $forumid) ) { |
| 495 |
$button_html[] = '<i itemtype="' . ( $is_topic ? 'topic' : 'reply' ) . '" id="wpfvote-down-'. intval($postid) .'" class="votedown fa fa-play fa-rotate-90 wpfcl-0"></i>'; |
| 496 |
}else{ |
| 497 |
$button_html[] = '<i class="not_reg_user fa fa-play fa-rotate-90 wpfcl-0"></i>'; |
| 498 |
} |
| 499 |
break; |
| 500 |
case 'isanswer': |
| 501 |
$is_answer = $this->wpforo->post->is_answered( $postid ); |
| 502 |
$is_answer = ( $is_answer == 0 ) ? '-not' : ''; |
| 503 |
if( is_user_logged_in() ){ |
| 504 |
$button_html[] = '<div id="wpf-answer-'. intval($postid) .'" class="wpf-toggle'. esc_attr($is_answer) .'-answer"><i class="fa fa-check"></i></div>'; |
| 505 |
}else{ |
| 506 |
$button_html[] = '<div class="wpf-toggle'. esc_attr($is_answer) .'-answer not_reg_user"><i class="fa fa-check"></i></div>'; |
| 507 |
} |
| 508 |
break; |
| 509 |
} //switch |
| 510 |
} //foreach |
| 511 |
|
| 512 |
echo implode('', $button_html); |
| 513 |
|
| 514 |
} |
| 515 |
|
| 516 |
function breadcrumb($url_data){ |
| 517 |
extract($url_data, EXTR_OVERWRITE); |
| 518 |
|
| 519 |
switch($template) : |
| 520 |
case 'search': ?> |
| 521 |
|
| 522 |
<div class="wpf-breadcrumb"> |
| 523 |
<a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i></a> |
| 524 |
|
| 525 |
<a href="#" class="active"><?php wpforo_phrase('Search') ?></a> |
| 526 |
|
| 527 |
<a href="#" class="wpf-end"> </a> |
| 528 |
</div> |
| 529 |
|
| 530 |
<?php break; |
| 531 |
case 'signup': ?> |
| 532 |
|
| 533 |
<div class="wpf-breadcrumb"> |
| 534 |
<a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i></a> |
| 535 |
|
| 536 |
<a href="#" class="active"><?php wpforo_phrase('Register') ?></a> |
| 537 |
|
| 538 |
<a href="#" class="wpf-end"> </a> |
| 539 |
</div> |
| 540 |
|
| 541 |
<?php break; |
| 542 |
case 'signin': ?> |
| 543 |
|
| 544 |
<div class="wpf-breadcrumb"> |
| 545 |
<a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i></a> |
| 546 |
|
| 547 |
<a href="#" class="active"><?php wpforo_phrase('Login') ?></a> |
| 548 |
|
| 549 |
<a href="#" class="wpf-end"> </a> |
| 550 |
</div> |
| 551 |
|
| 552 |
<?php break; |
| 553 |
case 'members': ?> |
| 554 |
|
| 555 |
<div class="wpf-breadcrumb"> |
| 556 |
<a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i></a> |
| 557 |
|
| 558 |
<?php if(isset($_GET['wpfms'])) : ?> |
| 559 |
|
| 560 |
<a href="<?php echo wpforo_home_url('members') ?>"><?php wpforo_phrase('Members') ?></a> |
| 561 |
<a href="#" class="active"><?php wpforo_phrase('Search') ?></a> |
| 562 |
|
| 563 |
<?php else : ?> |
| 564 |
|
| 565 |
<a href="#" class="active"><?php wpforo_phrase('Members') ?></a> |
| 566 |
|
| 567 |
<?php endif ?> |
| 568 |
|
| 569 |
<a href="#" class="wpf-end"> </a> |
| 570 |
</div> |
| 571 |
|
| 572 |
<?php break; |
| 573 |
case 'profile': ?> |
| 574 |
|
| 575 |
<div class="wpf-breadcrumb"> |
| 576 |
<a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i></a> |
| 577 |
|
| 578 |
<a href="<?php echo wpforo_home_url('members') ?>"><?php wpforo_phrase('Members') ?></a> |
| 579 |
<a href="#" class="active"><?php @wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), 19 ) ?></a> |
| 580 |
|
| 581 |
<a href="#" class="wpf-end"> </a> |
| 582 |
</div> |
| 583 |
|
| 584 |
<?php break; |
| 585 |
case 'account': ?> |
| 586 |
|
| 587 |
<div class="wpf-breadcrumb"> |
| 588 |
<a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i> |
| 589 |
|
| 590 |
<a href="<?php echo wpforo_home_url('members') ?>"><?php wpforo_phrase('Members') ?></a> |
| 591 |
<a href="<?php echo esc_url($user['profile_url']) ?>"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), 19 ) ?></a> |
| 592 |
<a href="#" class="active"><?php wpforo_phrase('Account') ?></a> |
| 593 |
|
| 594 |
<a href="#" class="wpf-end"> </a> |
| 595 |
</div> |
| 596 |
|
| 597 |
<?php break; |
| 598 |
case 'activity': ?> |
| 599 |
|
| 600 |
<div class="wpf-breadcrumb"> |
| 601 |
<a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i> |
| 602 |
|
| 603 |
<a href="<?php echo wpforo_home_url('members') ?>"><?php wpforo_phrase('Members') ?></a> |
| 604 |
<a href="<?php echo esc_url($user['profile_url']) ?>"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), 19 ) ?></a> |
| 605 |
<a href="#" class="active"><?php wpforo_phrase('Activity') ?></a> |
| 606 |
|
| 607 |
<a href="#" class="wpf-end"> </a> |
| 608 |
</div> |
| 609 |
|
| 610 |
<?php break; |
| 611 |
case 'subscriptions': ?> |
| 612 |
|
| 613 |
<div class="wpf-breadcrumb"> |
| 614 |
<a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i> |
| 615 |
|
| 616 |
<a href="<?php echo wpforo_home_url('members') ?>"><?php wpforo_phrase('Members') ?></a> |
| 617 |
<a href="<?php echo esc_url($user['profile_url']) ?>"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), 19 ) ?></a> |
| 618 |
<a href="#" class="active"><?php wpforo_phrase('Subscriptions') ?></a> |
| 619 |
|
| 620 |
<a href="#" class="wpf-end"> </a> |
| 621 |
</div> |
| 622 |
|
| 623 |
<?php break; |
| 624 |
// TODO: move code to pm plugin |
| 625 |
case 'messages': ?> |
| 626 |
|
| 627 |
<div class="wpf-breadcrumb"> |
| 628 |
<a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i> |
| 629 |
|
| 630 |
<a href="<?php echo wpforo_home_url('members') ?>"><?php wpforo_phrase('Members') ?></a> |
| 631 |
|
| 632 |
<?php if(!empty($user)) : ?> |
| 633 |
|
| 634 |
<a href="<?php echo esc_url($user['profile_url']) ?>"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), 19 ) ?></a> |
| 635 |
|
| 636 |
<?php endif ?> |
| 637 |
|
| 638 |
<a href="#" class="active"><?php wpforo_phrase('Messages') ?></a> |
| 639 |
|
| 640 |
<a href="#" class="wpf-end"> </a> |
| 641 |
</div> |
| 642 |
|
| 643 |
<?php break; |
| 644 |
case 'topic': ?> |
| 645 |
|
| 646 |
<div class="wpf-breadcrumb"> |
| 647 |
<a href="<?php echo ( !isset($forumid) ? '#' : wpforo_home_url() ) ?>" class="wpf-root<?php echo ( !isset($forumid) ? ' active' : '' ) ?>" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i></a> |
| 648 |
|
| 649 |
<?php if(isset($forumid)) : ?> |
| 650 |
<?php $relative_ids = array(); |
| 651 |
$this->wpforo->forum->get_all_relative_ids($forumid, $relative_ids); |
| 652 |
foreach( $relative_ids as $key => $rel_forumid ) : ?> |
| 653 |
<?php $forum = wpforo_forum($rel_forumid) ?> |
| 654 |
<?php if(!empty($forum)): ?> |
| 655 |
<?php if( $key != ( count($relative_ids) - 1 ) ) : ?> |
| 656 |
<a href="<?php echo esc_url( $forum['url'] ) ?>" title="<?php echo esc_attr($forum['title']) ?>"><?php wpforo_text($forum['title'], 19) ?></a> |
| 657 |
<?php else : ?> |
| 658 |
<a href="#" class="active" title="<?php echo esc_attr($forum['title']) ?>"><?php wpforo_text($forum['title'], 19) ?></a> |
| 659 |
<?php endif ?> |
| 660 |
<?php endif ?> |
| 661 |
<?php endforeach ?> |
| 662 |
<?php endif ?> |
| 663 |
|
| 664 |
<a href="#" class="wpf-end"> </a> |
| 665 |
</div> |
| 666 |
|
| 667 |
<?php break; |
| 668 |
case 'post': ?> |
| 669 |
|
| 670 |
<div class="wpf-breadcrumb"> |
| 671 |
<a href="<?php echo ( !isset($forumid) ? '#' : wpforo_home_url() ) ?>" class="wpf-root<?php echo ( !isset($forumid) ? ' active' : '' ) ?>" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i></a> |
| 672 |
|
| 673 |
<?php if(isset($forumid)) : ?> |
| 674 |
<?php $relative_ids = array(); |
| 675 |
$this->wpforo->forum->get_all_relative_ids($forumid, $relative_ids); |
| 676 |
foreach( $relative_ids as $key => $rel_forumid ) : ?> |
| 677 |
<?php $forum = wpforo_forum($rel_forumid) ?> |
| 678 |
<?php if(!empty($forum)): ?> |
| 679 |
<a href="<?php echo esc_url( $forum['url'] ) ?>" title="<?php echo esc_attr($forum['title']) ?>"><?php wpforo_text($forum['title'], 19) ?></a> |
| 680 |
<?php endif ?> |
| 681 |
<?php endforeach ?> |
| 682 |
<?php endif ?> |
| 683 |
<?php if(!empty($topic)) : ?> |
| 684 |
|
| 685 |
<a href="#" class="active" title="<?php echo esc_attr($topic['title']) ?>"><?php wpforo_text($topic['title'], 19) ?></a> |
| 686 |
|
| 687 |
<?php endif ?> |
| 688 |
<a href="#" class="wpf-end"> </a> |
| 689 |
</div> |
| 690 |
|
| 691 |
<?php break; |
| 692 |
default: ?> |
| 693 |
|
| 694 |
<div class="wpf-breadcrumb"> |
| 695 |
<a href="#" class="wpf-root active"><?php wpforo_phrase('Forums') ?></a> |
| 696 |
<a href="#" class="wpf-end"> </a> |
| 697 |
</div> |
| 698 |
|
| 699 |
<?php |
| 700 |
endswitch; |
| 701 |
|
| 702 |
} |
| 703 |
|
| 704 |
function icon($type, $item = array(), $echo = true, $data = 'icon' ){ |
| 705 |
|
| 706 |
$icon = array(); |
| 707 |
$status = false; |
| 708 |
|
| 709 |
if( isset($item['status']) && $item['status'] ){ |
| 710 |
$icon['class'] = 'fa-exclamation-circle'; |
| 711 |
$icon['color'] = 'wpfcl-5'; |
| 712 |
$icon['title'] = wpforo_phrase('Unapproved', false); |
| 713 |
if($echo) { |
| 714 |
$status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title']; |
| 715 |
} |
| 716 |
else{ |
| 717 |
return ($data == 'icon') ? implode(' ', $icon) : $icon['title']; |
| 718 |
} |
| 719 |
} |
| 720 |
|
| 721 |
if(isset($item['type'])){ |
| 722 |
|
| 723 |
if( $type == 'topic' ){ |
| 724 |
if($this->wpforo->topic->is_private($item['topicid'])){ |
| 725 |
$icon['class'] = 'fa-eye-slash'; |
| 726 |
$icon['color'] = 'wpfcl-1'; |
| 727 |
$icon['title'] = wpforo_phrase('Private', false); |
| 728 |
if($echo) { |
| 729 |
$status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title']; |
| 730 |
} |
| 731 |
else{ |
| 732 |
return ($data == 'icon') ? implode(' ', $icon) : $icon['title']; |
| 733 |
} |
| 734 |
} |
| 735 |
if( wpforo_topic($item['topicid'], 'is_answer') ){ |
| 736 |
$icon['class'] = 'fa-check-circle'; |
| 737 |
$icon['color'] = 'wpfcl-8'; |
| 738 |
$icon['title'] = wpforo_phrase('Solved', false); |
| 739 |
if($echo) { |
| 740 |
$status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title']; |
| 741 |
} |
| 742 |
else{ |
| 743 |
return ($data == 'icon') ? implode(' ', $icon) : $icon['title']; |
| 744 |
} |
| 745 |
} |
| 746 |
} |
| 747 |
|
| 748 |
if( $item['closed'] && $item['type'] == 1 ){ |
| 749 |
$icon['class'] = 'fa-lock'; |
| 750 |
$icon['color'] = 'wpfcl-1'; |
| 751 |
$icon['title'] = wpforo_phrase('Closed', false); |
| 752 |
if($echo) { $status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title']; } else{ return ($data == 'icon') ? implode(' ', $icon) : $icon['title']; } |
| 753 |
} |
| 754 |
elseif( $item['closed'] && $item['type'] != 1 ){ |
| 755 |
$icon['class'] = 'fa-lock'; |
| 756 |
$icon['color'] = 'wpfcl-1'; |
| 757 |
$icon['title'] = wpforo_phrase('Closed', false); |
| 758 |
if($echo) { $status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title']; } else{ return ($data == 'icon') ? implode(' ', $icon) : $icon['title']; } |
| 759 |
} |
| 760 |
elseif( !$item['closed'] && $item['type'] == 1 ){ |
| 761 |
$icon['class'] = 'fa-thumb-tack'; |
| 762 |
$icon['color'] = 'wpfcl-5'; |
| 763 |
$icon['title'] = wpforo_phrase('Sticky', false); |
| 764 |
if($echo) { $status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title']; } else{ return ($data == 'icon') ? implode(' ', $icon) : $icon['title']; } |
| 765 |
} |
| 766 |
|
| 767 |
if( $status ){ |
| 768 |
//do nothing |
| 769 |
} |
| 770 |
else{ |
| 771 |
if( $type == 'forum' ){ |
| 772 |
$icon['class'] = 'fa-comments'; |
| 773 |
$icon['color'] = 'wpfcl-2'; |
| 774 |
} |
| 775 |
elseif( $type == 'topic' ){ |
| 776 |
if( $item['posts'] == 1 ){ |
| 777 |
$icon['class'] = 'fa-file-o'; |
| 778 |
$icon['color'] = 'wpfcl-2'; |
| 779 |
$icon['title'] = ''; |
| 780 |
} |
| 781 |
elseif( $item['posts'] > 1 && $item['posts'] <= 5 ){ |
| 782 |
$icon['class'] = 'fa-file-text-o'; |
| 783 |
$icon['color'] = 'wpfcl-2'; |
| 784 |
$icon['title'] = ''; |
| 785 |
} |
| 786 |
elseif( $item['posts'] > 5 && $item['posts'] <= 20 ){ |
| 787 |
$icon['class'] = 'fa-file-text'; |
| 788 |
$icon['color'] = 'wpfcl-2'; |
| 789 |
$icon['title'] = ''; |
| 790 |
} |
| 791 |
elseif( $item['posts'] > 20 ){ |
| 792 |
$icon['class'] = 'fa-file-text'; |
| 793 |
$icon['color'] = 'wpfcl-5'; |
| 794 |
$icon['title'] = ''; |
| 795 |
} |
| 796 |
else{ |
| 797 |
$icon['class'] = 'fa-file-o'; |
| 798 |
$icon['color'] = 'wpfcl-2'; |
| 799 |
$icon['title'] = ''; |
| 800 |
} |
| 801 |
} |
| 802 |
if($echo) { echo ($data == 'icon') ? implode(' ', $icon) : $icon['title']; } else{ return ($data == 'icon') ? implode(' ', $icon) : $icon['title']; } |
| 803 |
} |
| 804 |
|
| 805 |
} |
| 806 |
else{ |
| 807 |
return false; |
| 808 |
} |
| 809 |
|
| 810 |
} |
| 811 |
|
| 812 |
public function member_buttons( $member ){ |
| 813 |
|
| 814 |
if(empty($member)) return false; |
| 815 |
$profile_access = ( $this->wpforo->perm->usergroup_can('vprf') ? true : false ); |
| 816 |
|
| 817 |
if( $profile_access ){ |
| 818 |
?> |
| 819 |
<a class="wpf-member-profile-button" title="<?php wpforo_phrase('Profile') ?>" href="<?php echo esc_url($this->wpforo->member->profile_url($member)) ?>"> |
| 820 |
<i class="fa fa-user"></i> |
| 821 |
</a> |
| 822 |
<a class="wpf-member-profile-button" title="<?php wpforo_phrase('Activity') ?>" href="<?php echo esc_url($this->wpforo->member->profile_url($member, 'activity')) ?>"> |
| 823 |
<i class="fa fa-comments-o"></i> |
| 824 |
</a> |
| 825 |
<a class="wpf-member-profile-button" title="<?php wpforo_phrase('Subscriptions') ?>" href="<?php echo esc_url($this->wpforo->member->profile_url($member, 'subscriptions')) ?>"> |
| 826 |
<i class="fa fa-rss"></i> |
| 827 |
</a> |
| 828 |
<?php do_action( 'wpforo_member_info_buttons', $member ); ?> |
| 829 |
<?php |
| 830 |
} |
| 831 |
} |
| 832 |
|
| 833 |
public function member_social_buttons( $member ){ |
| 834 |
|
| 835 |
$socnets = array(); |
| 836 |
if(empty($member)) return false; |
| 837 |
$social_access = ( $this->wpforo->perm->usergroup_can('vmsn') ? true : false ); |
| 838 |
|
| 839 |
if( $social_access ){ |
| 840 |
|
| 841 |
if( isset($member['facebook']) && $member['facebook'] ){ |
| 842 |
$socnets['facebook']['set'] = $member['facebook']; |
| 843 |
$member['facebook'] = ( strpos($member['facebook'], 'facebook.com') === FALSE ) ? 'https://www.facebook.com/' . trim($member['facebook'], '/') : $member['facebook'] ; |
| 844 |
$socnets['facebook']['value'] = $member['facebook']; |
| 845 |
$socnets['facebook']['protocol'] = 'https://'; |
| 846 |
$socnets['facebook']['title'] = wpforo_phrase('Facebook', false); |
| 847 |
} |
| 848 |
|
| 849 |
if( isset($member['twitter']) && $member['twitter'] ){ |
| 850 |
$socnets['twitter']['set'] = $member['twitter']; |
| 851 |
$member['twitter'] = ( strpos($member['twitter'], 'twitter.com') === FALSE ) ? 'http://twitter.com/' . trim($member['twitter'], '/') : $member['twitter'] ; |
| 852 |
$socnets['twitter']['value'] = $member['twitter']; |
| 853 |
$socnets['twitter']['protocol'] = 'https://'; |
| 854 |
$socnets['twitter']['title'] = wpforo_phrase('Twitter', false); |
| 855 |
} |
| 856 |
|
| 857 |
if( isset($member['gtalk']) && $member['gtalk'] ){ |
| 858 |
$socnets['gtalk']['set'] = $member['gtalk']; |
| 859 |
$socnets['gtalk']['value'] = $member['gtalk']; |
| 860 |
$socnets['gtalk']['protocol'] = 'https://'; |
| 861 |
$socnets['gtalk']['title'] = wpforo_phrase('Google+', false); |
| 862 |
} |
| 863 |
|
| 864 |
if( isset($member['yahoo']) && $member['yahoo'] ){ |
| 865 |
$socnets['yahoo']['set'] = $member['yahoo']; |
| 866 |
$socnets['yahoo']['value'] = $member['yahoo']; |
| 867 |
$socnets['yahoo']['protocol'] = 'mailto:'; |
| 868 |
$socnets['yahoo']['title'] = wpforo_phrase('Yahoo', false); |
| 869 |
} |
| 870 |
|
| 871 |
if( isset($member['aim']) && $member['aim'] ){ |
| 872 |
$socnets['aim']['set'] = $member['aim']; |
| 873 |
$socnets['aim']['value'] = $member['aim']; |
| 874 |
$socnets['aim']['protocol'] = 'mailto:'; |
| 875 |
$socnets['aim']['title'] = wpforo_phrase('AOL IM', false); |
| 876 |
} |
| 877 |
|
| 878 |
if( isset($member['icq']) && $member['icq'] ){ |
| 879 |
$socnets['icq']['set'] = $member['icq']; |
| 880 |
$socnets['icq']['value'] = 'www.icq.com/whitepages/cmd.php?uin=' . $member['icq'] . '&action=message'; |
| 881 |
$socnets['icq']['protocol'] = 'https://'; |
| 882 |
$socnets['icq']['title'] = wpforo_phrase('ICQ', false); |
| 883 |
} |
| 884 |
|
| 885 |
if( isset($member['msn']) && $member['msn'] ){ |
| 886 |
$socnets['msn']['set'] = $member['msn']; |
| 887 |
$socnets['msn']['value'] = $member['msn']; |
| 888 |
$socnets['msn']['protocol'] = 'mailto:'; |
| 889 |
$socnets['msn']['title'] = wpforo_phrase('MSN', false); |
| 890 |
} |
| 891 |
|
| 892 |
if( isset($member['skype']) && $member['skype'] ){ |
| 893 |
$socnets['skype']['set'] = $member['skype']; |
| 894 |
$socnets['skype']['value'] = $member['skype']; |
| 895 |
$socnets['skype']['protocol'] = 'skype:'; |
| 896 |
$socnets['skype']['title'] = wpforo_phrase('Skype', false); |
| 897 |
} |
| 898 |
|
| 899 |
?> |
| 900 |
<div class="wpf-member-socnet-wrap"> |
| 901 |
<?php if(!empty($socnets)): ?> |
| 902 |
<?php foreach( $socnets as $key => $socnet ): ?> |
| 903 |
<?php if( !$socnet['set'] ) continue; ?> |
| 904 |
<?php $title = $member['display_name'] . ' - ' . $socnet['title']; ?> |
| 905 |
<?php $url = ($key == 'skype') ? 'skype:' . esc_attr($socnet['value']) : esc_url($socnet['protocol'] . str_replace( array('https://', 'http://', 'skype:', 'mailto:'), '', $socnet['value'])); ?> |
| 906 |
<a href="<?php echo $url ?>" class="wpf-member-socnet-button" title="<?php echo esc_attr($title) ?>"> |
| 907 |
<img src="<?php echo esc_url(WPFORO_URL) ?>/wpf-assets/images/sn/<?php echo $key ?>.png" alt="<?php echo esc_attr($title) ?>" title="<?php echo esc_attr($title) ?>" /> |
| 908 |
</a> |
| 909 |
<?php endforeach; ?> |
| 910 |
<?php endif; ?> |
| 911 |
<?php do_action( 'wpforo_member_socnet_buttons', $member ); ?> |
| 912 |
</div> |
| 913 |
<?php |
| 914 |
} |
| 915 |
} |
| 916 |
|
| 917 |
public function init_member_templates(){ |
| 918 |
$this->wpforo->member_tpls = array( |
| 919 |
'account' => wpftpl('profile-account.php'), |
| 920 |
'activity' => wpftpl('profile-activity.php'), |
| 921 |
'subscriptions' => wpftpl('profile-subscriptions.php') |
| 922 |
); |
| 923 |
$this->wpforo->member_tpls = apply_filters('wpforo_member_templates_filter', $this->wpforo->member_tpls); |
| 924 |
$this->wpforo->member_tpls['profile'] = wpftpl('profile-home.php'); |
| 925 |
} |
| 926 |
|
| 927 |
function has_menu(){ |
| 928 |
return has_nav_menu( 'wpforo-menu' ); |
| 929 |
} |
| 930 |
|
| 931 |
function nav_menu(){ |
| 932 |
if ( has_nav_menu( 'wpforo-menu' ) ){ |
| 933 |
$defaults = array( |
| 934 |
'theme_location' => 'wpforo-menu', |
| 935 |
'menu' => '', |
| 936 |
'container' => '', |
| 937 |
'container_class' => '', |
| 938 |
'container_id' => '', |
| 939 |
'menu_class' => 'wpf-menu', |
| 940 |
'menu_id' => 'wpf-menu', |
| 941 |
'echo' => true, |
| 942 |
'fallback_cb' => 'wp_page_menu', |
| 943 |
'before' => '', |
| 944 |
'after' => '', |
| 945 |
'link_before' => '', |
| 946 |
'link_after' => '', |
| 947 |
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', |
| 948 |
'depth' => 0, |
| 949 |
'walker' => '' |
| 950 |
); |
| 951 |
wp_nav_menu( $defaults ); |
| 952 |
} |
| 953 |
} |
| 954 |
|
| 955 |
function init_nav_menu(){ |
| 956 |
|
| 957 |
if(isset($this->wpforo->current_object) && !empty($this->wpforo->current_object)){ |
| 958 |
|
| 959 |
extract($this->wpforo->current_object, EXTR_OVERWRITE); |
| 960 |
|
| 961 |
$this->wpforo->menu['wpforo-home'] = array( |
| 962 |
'href' => wpforo_home_url(), |
| 963 |
'label' => wpforo_phrase('forums', FALSE), |
| 964 |
'attr' => ( $template == 'forum' || $template == 'topic' || $template == 'post' ? ' class="wpforo-active"' : '' ), |
| 965 |
'submenues' => array() |
| 966 |
); |
| 967 |
|
| 968 |
if($this->wpforo->perm->usergroup_can('vmem')){ |
| 969 |
$this->wpforo->menu['wpforo-members'] = array( |
| 970 |
'href' => wpforo_home_url('members'), |
| 971 |
'label' => wpforo_phrase('members', FALSE), |
| 972 |
'attr' => ( $template == 'members' ? ' class="wpforo-active"' : '' ), |
| 973 |
'submenues' => array() |
| 974 |
); |
| 975 |
} |
| 976 |
|
| 977 |
if( is_user_logged_in() ){ |
| 978 |
|
| 979 |
$this->wpforo->menu['wpforo-profile-home'] = array( |
| 980 |
'href' => $this->wpforo->member->get_profile_url($this->wpforo->current_userid), |
| 981 |
'label' => wpforo_phrase('my profile', FALSE), |
| 982 |
'attr' => ( isset($this->wpforo->member_tpls[$template]) && $this->wpforo->member_tpls[$template] && $this->wpforo->current_object['user_is_same_current_user'] ? ' class="wpforo-active"' : '' ), |
| 983 |
'submenues' => array() |
| 984 |
); |
| 985 |
$this->wpforo->menu['wpforo-profile-account'] = array( |
| 986 |
'href' => $this->wpforo->member->get_profile_url($this->wpforo->current_userid, 'account'), |
| 987 |
'label' => wpforo_phrase('account', FALSE), |
| 988 |
'attr' => ( $template == 'account' && $this->wpforo->current_object['user_is_same_current_user'] ? ' class="wpforo-active"' : '' ), |
| 989 |
'submenues' => array() |
| 990 |
); |
| 991 |
$this->wpforo->menu['wpforo-profile-activity'] = array( |
| 992 |
'href' => $this->wpforo->member->get_profile_url($this->wpforo->current_userid, 'activity'), |
| 993 |
'label' => wpforo_phrase('activity', FALSE), |
| 994 |
'attr' => ( $template == 'activity' && $this->wpforo->current_object['user_is_same_current_user'] ? ' class="wpforo-active"' : '' ), |
| 995 |
'submenues' => array() |
| 996 |
); |
| 997 |
$this->wpforo->menu['wpforo-profile-subscriptions'] = array( |
| 998 |
'href' => $this->wpforo->member->get_profile_url($this->wpforo->current_userid, 'subscriptions'), |
| 999 |
'label' => wpforo_phrase('subscriptions', FALSE), |
| 1000 |
'attr' => ( $template == 'subscriptions' && $this->wpforo->current_object['user_is_same_current_user'] ? ' class="wpforo-active"' : '' ), |
| 1001 |
'submenues' => array() |
| 1002 |
); |
| 1003 |
$this->wpforo->menu['wpforo-logout'] = array( |
| 1004 |
'href' => wpforo_home_url('?wpforo=logout'), |
| 1005 |
'label' => wpforo_phrase('logout', FALSE), |
| 1006 |
'attr' => '', |
| 1007 |
'submenues' => array() |
| 1008 |
); |
| 1009 |
|
| 1010 |
}else{ |
| 1011 |
|
| 1012 |
if( wpforo_feature('user-register', $this->wpforo) ){ |
| 1013 |
$this->wpforo->menu['wpforo-register'] = array( |
| 1014 |
'href' => wpforo_register_url(), |
| 1015 |
'label' => wpforo_phrase('register', FALSE), |
| 1016 |
'attr' => ( isset($_GET['wpforo']) && $_GET['wpforo'] == 'signup' ? ' class="wpforo-active"' : '' ), |
| 1017 |
'submenues' => array() |
| 1018 |
); |
| 1019 |
} |
| 1020 |
$this->wpforo->menu['wpforo-login'] = array( |
| 1021 |
'href' => wpforo_login_url(), |
| 1022 |
'label' => wpforo_phrase('login', FALSE), |
| 1023 |
'attr' => ( isset($_GET['wpforo']) && $_GET['wpforo'] == 'signin' ? ' class="wpforo-active"' : '' ), |
| 1024 |
'submenues' => array() |
| 1025 |
); |
| 1026 |
} |
| 1027 |
|
| 1028 |
$this->wpforo->menu = apply_filters('wpforo_menu_array_filter', $this->wpforo->menu); |
| 1029 |
} |
| 1030 |
} |
| 1031 |
|
| 1032 |
/** |
| 1033 |
* |
| 1034 |
* Checks in current active theme options if certain layout exists. |
| 1035 |
* |
| 1036 |
* @since 1.0.0 |
| 1037 |
* |
| 1038 |
* @param mixed $identifier Layout id (folder name) OR @layout variable in header ( 1 or Extended ) |
| 1039 |
* @param string $identifier_type The type of first parameter 'id' OR 'name' (@layout) |
| 1040 |
* |
| 1041 |
* @return boolean true/false |
| 1042 |
* |
| 1043 |
**/ |
| 1044 |
function layout_exists( $identifier, $identifier_type = 'id' ){ |
| 1045 |
|
| 1046 |
$layouts = $this->options['layouts']; |
| 1047 |
|
| 1048 |
if( $identifier_type == 'id' ){ |
| 1049 |
if( isset($layouts[$identifier]) && !empty($layouts[$identifier])){ |
| 1050 |
return true; |
| 1051 |
} |
| 1052 |
else{ |
| 1053 |
return false; |
| 1054 |
} |
| 1055 |
} |
| 1056 |
elseif( $identifier_type = 'name' ){ |
| 1057 |
foreach( $layouts as $id => $layout ){ |
| 1058 |
if( !isset($layout['name']) && $layout['name'] == $identifier ){ |
| 1059 |
return true; |
| 1060 |
} |
| 1061 |
} |
| 1062 |
return false; |
| 1063 |
} |
| 1064 |
} |
| 1065 |
|
| 1066 |
/** |
| 1067 |
* |
| 1068 |
* Finds and returns all layouts information in array from theme's /layouts/ folder |
| 1069 |
* |
| 1070 |
* @since 1.0.0 |
| 1071 |
* |
| 1072 |
* @param string $theme Theme id ( folder name ) e.g. 'classic' |
| 1073 |
* |
| 1074 |
* @return array |
| 1075 |
* |
| 1076 |
**/ |
| 1077 |
function find_layouts( $theme ){ |
| 1078 |
$layout_data = array(); |
| 1079 |
$layouts = $this->find_themes('/'.$theme.'/layouts', 'php', 'layout'); |
| 1080 |
if(!empty($layouts)){ |
| 1081 |
foreach( $layouts as $layout ){ |
| 1082 |
$lid = trim(basename(dirname( $layout['file']['value'] )), '/'); |
| 1083 |
$layout_data[$lid]['id'] = $lid; |
| 1084 |
$layout_data[$lid]['name'] = $layout['name']['value']; |
| 1085 |
$layout_data[$lid]['version'] = $layout['version']['value']; |
| 1086 |
$layout_data[$lid]['description'] = $layout['description']['value']; |
| 1087 |
$layout_data[$lid]['author'] = $layout['author']['value']; |
| 1088 |
$layout_data[$lid]['url'] = $layout['layout_url']['value']; |
| 1089 |
$layout_data[$lid]['file'] = $layout['file']['value']; |
| 1090 |
} |
| 1091 |
} |
| 1092 |
return $layout_data; |
| 1093 |
} |
| 1094 |
|
| 1095 |
function show_layout_selectbox($layoutid = 0){ |
| 1096 |
$layouts = $this->find_layouts( WPFORO_THEME ); |
| 1097 |
if( !empty($layouts) ){ |
| 1098 |
foreach( $layouts as $layout ) : ?> |
| 1099 |
<option value="<?php echo esc_attr(trim($layout['id'])) ?>" <?php echo ( $layoutid == $layout['id'] ? 'selected' : '' ); ?> ><?php echo esc_html($layout['name']) ?></option> |
| 1100 |
<?php |
| 1101 |
endforeach; |
| 1102 |
} |
| 1103 |
} |
| 1104 |
|
| 1105 |
/** |
| 1106 |
* |
| 1107 |
* Finds and returns styles array from theme's /styles/colors.php file |
| 1108 |
* |
| 1109 |
* @since 1.0.0 |
| 1110 |
* |
| 1111 |
* @param string $theme Theme id ( folder name ) e.g. 'classic' |
| 1112 |
* |
| 1113 |
* @return array |
| 1114 |
* |
| 1115 |
**/ |
| 1116 |
function find_styles( $theme ){ |
| 1117 |
$colors = array(); |
| 1118 |
$color_file = WPFORO_THEME_DIR . '/' . $theme . '/styles/colors.php'; |
| 1119 |
if( file_exists($color_file) ){ |
| 1120 |
include( $color_file ); |
| 1121 |
} |
| 1122 |
return $colors; |
| 1123 |
} |
| 1124 |
|
| 1125 |
/** |
| 1126 |
* |
| 1127 |
* Scans certain theme directory and returns all information in array ( theme header, layouts, styles ). |
| 1128 |
* |
| 1129 |
* @since 1.0.0 |
| 1130 |
* |
| 1131 |
* @param string $theme_file Theme folder name or main css file base path ( 'classic' OR classic/style.css' ) |
| 1132 |
* |
| 1133 |
* @return array |
| 1134 |
* |
| 1135 |
**/ |
| 1136 |
function find_theme( $theme_file ){ |
| 1137 |
$theme = array(); |
| 1138 |
$theme_file = trim(trim($theme_file, '/')); |
| 1139 |
|
| 1140 |
if( preg_match('|\.[\w\d]{2,4}$|is', $theme_file) ){ |
| 1141 |
$theme_folder = trim(basename(dirname($theme_file)), '/'); |
| 1142 |
} |
| 1143 |
else{ |
| 1144 |
$theme_folder = $theme_file; |
| 1145 |
$theme_file = $theme_file . '/style.css'; |
| 1146 |
} |
| 1147 |
|
| 1148 |
if( !is_readable( WPFORO_THEME_DIR . '/' . $theme_file ) ){ |
| 1149 |
return $theme['error'] = __('Theme file not readable', 'wpforo') .' ('.$theme_file.')'; |
| 1150 |
} |
| 1151 |
else{ |
| 1152 |
$theme_data = $this->find_theme_headers( WPFORO_THEME_DIR . '/' . $theme_file ); |
| 1153 |
$theme['id'] = $theme_folder; |
| 1154 |
$theme['name'] = $theme_data['name']['value']; |
| 1155 |
$theme['version'] = $theme_data['version']['value']; |
| 1156 |
$theme['description'] = $theme_data['description']['value']; |
| 1157 |
$theme['author'] = $theme_data['author']['value']; |
| 1158 |
$theme['url'] = $theme_data['theme_url']['value']; |
| 1159 |
$theme['file'] = $theme_file; |
| 1160 |
$theme['folder'] = $theme_folder; |
| 1161 |
$theme['layouts'] = $this->find_layouts( $theme_folder ); |
| 1162 |
$styles = $this->find_styles( $theme_folder ); |
| 1163 |
if(!empty($styles)){ |
| 1164 |
reset($styles); |
| 1165 |
$theme['style'] = key($styles); |
| 1166 |
$theme['styles'] = $styles; |
| 1167 |
} |
| 1168 |
return $theme; |
| 1169 |
} |
| 1170 |
|
| 1171 |
} |
| 1172 |
|
| 1173 |
/** |
| 1174 |
* |
| 1175 |
* Scans wpForo themes (wpf-themes) folder, reads main files' headers and returns information about all themes in array. |
| 1176 |
* This function can also be used to scan and get information about layouts in each theme /layouts/ folder. |
| 1177 |
* |
| 1178 |
* @since 1.0.0 |
| 1179 |
* |
| 1180 |
* @param string $base_dir Absolute path to scan directory (e.g. /home/public_html/wp-content/plugins/wpforo/wpf-themes/) |
| 1181 |
* @param string $ext File extension which may contain header information |
| 1182 |
* @param string $mode 'theme' or 'layout' |
| 1183 |
* |
| 1184 |
* @return array |
| 1185 |
* |
| 1186 |
**/ |
| 1187 |
function find_themes( $base_dir = '', $ext = 'css', $mode = 'theme' ){ |
| 1188 |
$themes = array (); |
| 1189 |
$themes_dir = @opendir( WPFORO_THEME_DIR . $base_dir ); |
| 1190 |
$theme_files = array(); |
| 1191 |
if( $themes_dir ){ |
| 1192 |
while( ($file = readdir( $themes_dir )) !== false ){ |
| 1193 |
if( substr($file, 0, 1) == '.' ) continue; |
| 1194 |
if( is_dir( WPFORO_THEME_DIR . $base_dir .'/'.$file ) ){ |
| 1195 |
$themes_subdir = @opendir( WPFORO_THEME_DIR . $base_dir .'/'.$file ); |
| 1196 |
if( $themes_subdir ){ |
| 1197 |
while(($subfile = readdir( $themes_subdir ) ) !== false ){ |
| 1198 |
if( substr($subfile, 0, 1) == '.' ) continue; |
| 1199 |
if( substr($subfile, -4) == '.' . $ext ) $theme_files[] = "$file/$subfile"; |
| 1200 |
} |
| 1201 |
closedir( $themes_subdir ); |
| 1202 |
} |
| 1203 |
} |
| 1204 |
else{ |
| 1205 |
if( substr($file, -4) == '.' . $ext ) $theme_files[] = $file; |
| 1206 |
} |
| 1207 |
} |
| 1208 |
closedir( $themes_dir ); |
| 1209 |
} |
| 1210 |
if( empty($theme_files) ) return $themes; |
| 1211 |
foreach( $theme_files as $theme_file ){ |
| 1212 |
if( !is_readable( WPFORO_THEME_DIR . $base_dir . '/' . $theme_file ) ) continue; |
| 1213 |
if( $mode == 'theme' ){ |
| 1214 |
$theme_data = $this->find_theme_headers( WPFORO_THEME_DIR . $base_dir . '/' . $theme_file ); |
| 1215 |
} |
| 1216 |
elseif( $mode == 'layout' ){ |
| 1217 |
$theme_data = $this->find_layout_headers( WPFORO_THEME_DIR . $base_dir . '/' . $theme_file ); |
| 1218 |
} |
| 1219 |
if( empty($theme_data['name']['value']) ) continue; |
| 1220 |
$themes[wpforo_clear_basename($theme_file)] = $theme_data; |
| 1221 |
} |
| 1222 |
return $themes; |
| 1223 |
} |
| 1224 |
|
| 1225 |
/** |
| 1226 |
* |
| 1227 |
* Reads theme main file's header variables and returns information in array. |
| 1228 |
* |
| 1229 |
* @since 1.0.0 |
| 1230 |
* |
| 1231 |
* @param string $file Absolute path to file (e.g. /home/public_html/wp-content/plugins/wpforo/wpf-themes/style.css) |
| 1232 |
* |
| 1233 |
* @return array |
| 1234 |
* |
| 1235 |
**/ |
| 1236 |
function find_theme_headers( $file ){ |
| 1237 |
$theme_headers = array(); |
| 1238 |
$headers = array( |
| 1239 |
'name' => 'Theme Name', |
| 1240 |
'version' => 'Version', |
| 1241 |
'description' => 'Description', |
| 1242 |
'author' => 'Author', |
| 1243 |
'theme_url' => 'Theme URI', |
| 1244 |
); |
| 1245 |
$fp = fopen( $file, 'r' ); |
| 1246 |
$data = fread( $fp, 8192 ); |
| 1247 |
fclose( $fp ); |
| 1248 |
$data = str_replace( "\r", "\n", $data ); |
| 1249 |
foreach ( $headers as $header_key => $header_name ){ |
| 1250 |
if ( preg_match( '|^[\s\t\/*#@]*' . preg_quote( $header_name, '|' ) . ':(.*)$|mi', $data, $match ) && $match[1] ){ |
| 1251 |
$theme_headers[$header_key]['name'] = $header_name; |
| 1252 |
$theme_headers[$header_key]['value'] = trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $match[1])); |
| 1253 |
} |
| 1254 |
else{ |
| 1255 |
$theme_headers[$header_key]['name'] = $header_name; |
| 1256 |
$theme_headers[$header_key]['value'] = ''; |
| 1257 |
} |
| 1258 |
} |
| 1259 |
$theme_headers['file']['name'] = 'file'; |
| 1260 |
$theme_headers['file']['value'] = $file; |
| 1261 |
return $theme_headers; |
| 1262 |
} |
| 1263 |
|
| 1264 |
/** |
| 1265 |
* |
| 1266 |
* Reads layout main file's header variables and returns information in array. |
| 1267 |
* |
| 1268 |
* @since 1.0.0 |
| 1269 |
* |
| 1270 |
* @param string $file Absolute path to file (e.g. /home/public_html/wp-content/plugins/wpforo/wpf-themes/layouts/1/forum.php) |
| 1271 |
* |
| 1272 |
* @return array |
| 1273 |
* |
| 1274 |
**/ |
| 1275 |
function find_layout_headers( $file ){ |
| 1276 |
$theme_headers = array(); |
| 1277 |
$headers = array( |
| 1278 |
'name' => 'layout', |
| 1279 |
'version' => 'version', |
| 1280 |
'description' => 'description', |
| 1281 |
'author' => 'author', |
| 1282 |
'layout_url' => 'url', |
| 1283 |
); |
| 1284 |
$fp = fopen( $file, 'r' ); |
| 1285 |
$data = fread( $fp, 8192 ); |
| 1286 |
fclose( $fp ); |
| 1287 |
$data = str_replace( "\r", "\n", $data ); |
| 1288 |
foreach ( $headers as $header_key => $header_name ){ |
| 1289 |
if ( preg_match( '|^[\s\t\/*#@]*' . preg_quote( $header_name, '|' ) . ':(.*)$|mi', $data, $match ) && $match[1] ){ |
| 1290 |
$theme_headers[$header_key]['name'] = $header_name; |
| 1291 |
$theme_headers[$header_key]['value'] = trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $match[1])); |
| 1292 |
} |
| 1293 |
else{ |
| 1294 |
$theme_headers[$header_key]['name'] = $header_name; |
| 1295 |
$theme_headers[$header_key]['value'] = ''; |
| 1296 |
} |
| 1297 |
} |
| 1298 |
$theme_headers['file']['name'] = 'file'; |
| 1299 |
$theme_headers['file']['value'] = trim(str_replace( WPFORO_THEME_DIR, '', $file), '/'); |
| 1300 |
return $theme_headers; |
| 1301 |
} |
| 1302 |
|
| 1303 |
public function copyright(){ |
| 1304 |
if( wpforo_feature('copyright', $this->wpforo) ): ?> |
| 1305 |
<div id="wpforo-poweredby"> |
| 1306 |
<p class="wpf-by"> |
| 1307 |
<span onclick='javascript:document.getElementById("bywpforo").style.display = "inline";document.getElementById("awpforo").style.display = "none";' id="awpforo"> <img align="absmiddle" title="<?php esc_attr( wpforo_phrase('Powered by') ) ?> wpForo version <?php echo esc_html(WPFORO_VERSION) ?>" alt="Powered by wpForo" class="wpdimg" src="<?php echo WPFORO_URL ?>/wpf-assets/images/wpforo-info.png" alt="wpForo"> </span><a id="bywpforo" target="_blank" href="http://wpforo.com/"> <?php wpforo_phrase('Powered by') ?> wpForo version <?php echo esc_html(WPFORO_VERSION) ?></a> |
| 1308 |
</p> |
| 1309 |
</div> |
| 1310 |
<?php |
| 1311 |
endif; |
| 1312 |
} |
| 1313 |
|
| 1314 |
public function member_menu( $userid, $menu = array() ){ |
| 1315 |
if( empty($menu) ) $menu = array('profile' => 'fa-user', 'account' => 'fa-cog', 'activity' => 'fa-comments-o', 'subscriptions' => 'fa-rss'); |
| 1316 |
$menu = apply_filters('wpforo_member_menu_filter', $menu, $userid); |
| 1317 |
if( !($userid == $this->wpforo->current_userid || $this->wpforo->perm->usergroup_can('em')) ) unset($menu['account']); |
| 1318 |
foreach( $menu as $key => $value ) : |
| 1319 |
?> |
| 1320 |
<a class="wpf-profile-menu <?php echo ( $this->wpforo->current_object['template'] == $key ? ' wpforo-active' : '' ) ?>" href="<?php echo esc_url( $this->wpforo->member->get_profile_url($userid, $key) ) ?>"> |
| 1321 |
<i class="fa <?php echo sanitize_html_class($value) ?>"></i> <?php wpforo_phrase($key) ?> |
| 1322 |
</a> |
| 1323 |
<?php |
| 1324 |
endforeach; |
| 1325 |
} |
| 1326 |
|
| 1327 |
public function member_template(){ |
| 1328 |
global $wpforo; |
| 1329 |
extract($this->wpforo->current_object, EXTR_OVERWRITE); |
| 1330 |
extract($user, EXTR_OVERWRITE); |
| 1331 |
|
| 1332 |
include( (isset($this->wpforo->member_tpls[$template]) && $this->wpforo->member_tpls[$template] ? $this->wpforo->member_tpls[$template] : $this->wpforo->member_tpls['profile']) ); |
| 1333 |
} |
| 1334 |
|
| 1335 |
public function member_error(){ |
| 1336 |
echo apply_filters('wpforo_member_error_filter', wpforo_phrase('Members not found', FALSE)); |
| 1337 |
} |
| 1338 |
|
| 1339 |
public function field( $args, $wrap = true ){ |
| 1340 |
|
| 1341 |
$default = array( |
| 1342 |
'label' => '', |
| 1343 |
'title' => '', |
| 1344 |
'name' => '', |
| 1345 |
'value' => '', //url |
| 1346 |
'values' => '', |
| 1347 |
'type' => 'text', |
| 1348 |
'placeholder' => '', |
| 1349 |
'description' => '', |
| 1350 |
'id' => '', |
| 1351 |
'class' => '', |
| 1352 |
'attributes' => '', |
| 1353 |
'isWrapItem' => '', |
| 1354 |
'isLabelFirst' => '', |
| 1355 |
'isDisabled' => false, |
| 1356 |
'isEditable' => 1, |
| 1357 |
'isRequired' => 1, |
| 1358 |
'isMultiChoice' => 0, |
| 1359 |
'isConfirmPassword' => 1, |
| 1360 |
'minLength' => 0, |
| 1361 |
'maxLength' => 0, |
| 1362 |
'faIcon' => '', |
| 1363 |
'html' => '', |
| 1364 |
'varname' => (( isset($this->wpforo->form['varname']) ) ? $this->wpforo->form['varname'] : 'wpfdata'), |
| 1365 |
'template' => (( isset($this->wpforo->form['template']) ) ? $this->wpforo->form['template'] : $this->wpforo->current_object['template']), |
| 1366 |
'canBeInactive' => 1, |
| 1367 |
'canEdit' => array('1'), |
| 1368 |
'canView' => array('1', '2', '3', '5'), |
| 1369 |
'can' => '' |
| 1370 |
); |
| 1371 |
|
| 1372 |
|
| 1373 |
$args = wpforo_parse_args( $args, $default ); |
| 1374 |
extract( $args ); |
| 1375 |
$field_html = ''; |
| 1376 |
$minLength_attr = ''; |
| 1377 |
$maxLength_attr = ''; |
| 1378 |
$isRequired = ( $isRequired ) ? ' required="required" ' : ''; |
| 1379 |
$isDisabled = ( $isDisabled ) ? ' disabled="disabled" ' : ''; |
| 1380 |
$isDisabled = ( !$isEditable && $template != 'register' && $name != 'user_login') ? ' disabled="disabled" style="display:none" ' : ''; |
| 1381 |
if( !$isDefault ){ $varname = 'data'; } |
| 1382 |
$fieldName = ( !empty($varname) ? $varname . '[' . $name . ']' : $name ); |
| 1383 |
$fieldId = ( !empty($varname) ? $varname . '_' : '' ) . ( ($id) ? $id : $name ); |
| 1384 |
$minLength = ($minLength) ? intval($minLength): ''; |
| 1385 |
$maxLength = ($maxLength) ? intval($maxLength): ''; |
| 1386 |
if( $minLength ) { $minLength_attr = ($type == 'date' || $type == 'number' || $type == 'range') ? ' min="' . $minLength . '" ' : ' minlength="' . $minLength . '" '; } |
| 1387 |
if( $maxLength ) { $maxLength_attr = ($type == 'date' || $type == 'number' || $type == 'range') ? ' max="' . $maxLength . '" ' : ' maxlength="' . $maxLength . '" '; } |
| 1388 |
$minmax = $minLength_attr . ' ' . $maxLength_attr; |
| 1389 |
|
| 1390 |
$args['value'] = ( isset($this->wpforo->form['value'][$name]) ) ? $this->wpforo->form['value'][$name] : $args['value']; |
| 1391 |
if( !$isDefault && $varname ) $args['value'] = ( isset($this->wpforo->form['value'][$varname][$name]) ) ? $this->wpforo->form['value'][$varname][$name] : $args['value']; |
| 1392 |
$value = $args['value']; |
| 1393 |
|
| 1394 |
if( $type == 'textarea' ){ |
| 1395 |
$field_html = '<textarea '. $isRequired .' name="' . esc_attr($fieldName) . '" id="' . esc_attr($fieldId) . '" class="' . esc_attr($class) . '" ' . $isDisabled . ' '.$attributes.' ' . trim($minmax) . ' placeholder="' . esc_attr($placeholder) . '">' . esc_textarea($value) . '</textarea>'; |
| 1396 |
} |
| 1397 |
elseif( $type == 'password' ){ |
| 1398 |
$password_html = ''; |
| 1399 |
if( $template == 'account' ){ |
| 1400 |
$isRequired = 0; |
| 1401 |
$args['label'] = wpforo_phrase('Old password', false); $args['description'] = ''; |
| 1402 |
$password_html = '<input '. $isRequired .' type="password" name="' . esc_attr($varname) . '[old_pass]" value="" id="' . esc_attr($fieldId) . '" class="' . esc_attr($class) . '" ' . $isDisabled . ' '.$attributes.' placeholder="' . esc_attr( wpforo_phrase('Old password', false) ) . '"/><i class="fa fa-eye-slash wpf-show-password"></i>'; |
| 1403 |
$field_html .= ( $wrap ) ? $this->field_wrap( $args, $password_html ) : $password_html; |
| 1404 |
} |
| 1405 |
if( $template == 'register' && wpforo_feature('user-register-email-confirm') ){ |
| 1406 |
//If the option "User Registration with Email Confirmation" is enabled password fields should be removed on registration page. |
| 1407 |
} |
| 1408 |
else{ |
| 1409 |
if( $isConfirmPassword ) { $p1 = '1'; $p2 = '2'; } else{ $p1 = ''; $p2 = ''; } $fieldName = ( !empty($varname) ? $varname . '[' . $name . $p1 . ']' : $name . $p1 ); |
| 1410 |
if( $template == 'account' ) { $label = wpforo_phrase('New', false) . ' ' . $label; } $args['label'] = $label; $args['description'] = $description; |
| 1411 |
$password_html = '<input '. $isRequired .' type="password" name="' . esc_attr($fieldName) . '" value="" id="' . esc_attr($fieldId) . '" class="' . esc_attr($class) . '" ' . $isDisabled . ' '.$attributes.' ' . trim($minmax) . ' placeholder="' . esc_attr($placeholder) . '"/><i class="fa fa-eye-slash wpf-show-password"></i>'; |
| 1412 |
$field_html .= ( $wrap ) ? $this->field_wrap( $args, $password_html ) : $password_html; |
| 1413 |
if( $isConfirmPassword ){ |
| 1414 |
$args['label'] = wpforo_phrase('Confirm Password', false); $args['description'] = ''; |
| 1415 |
$fieldName = ( !empty($varname) ? $varname . '[' . $name . $p2 . ']' : $name . $p2 ); |
| 1416 |
$password_html = '<input '. $isRequired .' type="password" name="' . esc_attr($fieldName) . '" value="" id="' . esc_attr($fieldId) . '" class="' . esc_attr($class) . '" ' . $isDisabled . ' ' . $attributes . ' ' . trim($minmax) . ' placeholder="' . esc_attr($placeholder) . '"/><i class="fa fa-eye-slash wpf-show-password"></i>'; |
| 1417 |
$field_html .= ( $wrap ) ? $this->field_wrap( $args, $password_html ) : $password_html; |
| 1418 |
} |
| 1419 |
} |
| 1420 |
} |
| 1421 |
elseif( $type == 'file' ){ |
| 1422 |
$extensions = ''; |
| 1423 |
if( $fileExtensions ) { |
| 1424 |
$fileExtensions = wpforo_parse_args($fileExtensions); |
| 1425 |
foreach($fileExtensions as $key => $ext ){ if( strpos($ext, '.') === FALSE ) $fileExtensions[ $key ] = '.' . $ext; } |
| 1426 |
$fileExtensions = implode(', ', $fileExtensions); |
| 1427 |
if( $fileExtensions ) $extensions = 'accept="' .$fileExtensions . '"'; |
| 1428 |
} |
| 1429 |
$field_html = '<input '. $isRequired .' type="file" name="' . esc_attr($fieldName) . '" value="" id="' . esc_attr($fieldId) . '" class="' . esc_attr($class) . '" ' . $isDisabled . ' ' . $attributes . ' ' . $extensions . ' />'; |
| 1430 |
} |
| 1431 |
elseif( $type == 'checkbox' ){ |
| 1432 |
$step = 0; |
| 1433 |
$field_html = ''; |
| 1434 |
$value = (is_serialized($value)) ? unserialize($value) : (array)$value; |
| 1435 |
if( !is_array($values) ) $values = wpforo_string2array($values); |
| 1436 |
if( !empty($values) ){ |
| 1437 |
foreach( $values as $v ){ |
| 1438 |
$v = trim($v); |
| 1439 |
$data = explode('=>', $v); |
| 1440 |
$item_value = isset($data[0]) ? $data[0] : 'no_value'; |
| 1441 |
$item_label = isset($data[1]) ? $data[1] : $item_value; |
| 1442 |
$item_fieldid = $fieldId . '_' . ($step + 1); |
| 1443 |
$item_fieldname = $fieldName . '[]'; |
| 1444 |
$checked = ( in_array($item_value, $value) ) ? 'checked="checked"' : ''; |
| 1445 |
$field_html .= '<div class="wpf-field-item">'; |
| 1446 |
$input_html = '<input type="checkbox" name="' . esc_attr($item_fieldname) . '" id="' . esc_attr($item_fieldid) . '" class="wpf-input-checkbox ' . esc_attr($class) . '" value="' . esc_attr($item_value) . '" ' . $checked . ' ' . $isDisabled . ' '.$attributes.' />'; |
| 1447 |
if ($isWrapItem) { |
| 1448 |
$field_html .= '<label>'; |
| 1449 |
if ($isLabelFirst) { $field_html .= '<span class="wpf-checkbox-label">'. stripslashes($item_label) .'</span> ' . $input_html; } else { $field_html .= $input_html . ' <span class="wpf-checkbox-label">' . stripslashes($item_label) . '</span>'; } |
| 1450 |
$field_html .= '</label>'; |
| 1451 |
} |
| 1452 |
else { |
| 1453 |
if ($isLabelFirst) { $field_html .= '<span class="wpf-checkbox-label">' . stripslashes($item_label) . '</span> ' . $input_html; } else { $field_html .= $input_html . ' <span class="wpf-checkbox-label">' . stripslashes($item_label) . '</span>'; } |
| 1454 |
} |
| 1455 |
$field_html .= '</div>'; |
| 1456 |
$step++; |
| 1457 |
} |
| 1458 |
} |
| 1459 |
} |
| 1460 |
elseif( $type == 'radio' ){ |
| 1461 |
$step = 0; |
| 1462 |
$field_html = ''; |
| 1463 |
if (!is_array($values)) $values = wpforo_string2array($values); |
| 1464 |
if (!empty($values)) { |
| 1465 |
$item_values = array(); |
| 1466 |
foreach ($values as $v) { |
| 1467 |
$v = trim($v); |
| 1468 |
$data = explode('=>', $v); |
| 1469 |
$item_value = $data[0]; |
| 1470 |
$item_label = isset($data[1]) ? $data[1] : $item_value; |
| 1471 |
$item_fieldid = $fieldId . '_' . ($step + 1); |
| 1472 |
$attrs = ($isRequired) ? 'required="required"' : ''; |
| 1473 |
$attrs .= ($item_value == $value) ? ' checked="checked"' : ''; |
| 1474 |
|
| 1475 |
$field_html .= '<div class="wpf-field-item">'; |
| 1476 |
$input_html = '<input type="radio" name="' . esc_attr($fieldName) . '" id="' . esc_attr($item_fieldid) . '" class="wpf-input-radio ' . esc_attr($class) . '" value="' . esc_attr($item_value) . '" ' . $attrs . ' ' . $isDisabled . ' ' . $attributes . ' />'; |
| 1477 |
if ($isWrapItem) { |
| 1478 |
$field_html .= '<label>'; |
| 1479 |
if ($isLabelFirst) { |
| 1480 |
$field_html .= '<span class="wpf-radio-label">' . stripslashes($item_label) . '</span> ' . $input_html; |
| 1481 |
} else { |
| 1482 |
$field_html .= $input_html . ' <span class="wpf-radio-label">' . stripslashes($item_label) . '</span>'; |
| 1483 |
} |
| 1484 |
$field_html .= '</label>'; |
| 1485 |
} else { |
| 1486 |
if ($isLabelFirst) { |
| 1487 |
$field_html .= '<span class="wpf-radio-label">' . stripslashes($item_label) . '</span> ' . $input_html; |
| 1488 |
} else { |
| 1489 |
$field_html .= $input_html . ' <span class="wpf-radio-label">' . stripslashes($item_label) . '</span>'; |
| 1490 |
} |
| 1491 |
} |
| 1492 |
$field_html .= '</div>'; |
| 1493 |
$step++; |
| 1494 |
} |
| 1495 |
|
| 1496 |
} |
| 1497 |
} |
| 1498 |
elseif( $type == 'select' ){ |
| 1499 |
|
| 1500 |
$isMultiChoice = $isMultiChoice ? 'multiple="multiple"' : ''; |
| 1501 |
$field_html = '<select '. $isRequired .' name="' . esc_attr($fieldName) . '" id="' . esc_attr($fieldId) . '" class="' . esc_attr($class) . '" ' . $isMultiChoice . ' ' . $isDisabled . ' '.$attributes.'>'; |
| 1502 |
if(!$isRequired) $field_html .= '<option value="">' . wpforo_phrase('--- Choose ---', false) . '</option>'; |
| 1503 |
if( !empty($values) ){ |
| 1504 |
foreach ($values as $k => $v) { |
| 1505 |
if( is_array($v) ){ |
| 1506 |
$field_html .= '<optgroup label="' . esc_attr($k) . '">'; |
| 1507 |
foreach ($v as $_k => $_v){ |
| 1508 |
// >>> its some #1 code |
| 1509 |
$data = explode('=>', $_v); |
| 1510 |
$item_value = isset($data[0]) ? $data[0] : 'no_value'; |
| 1511 |
$item_label = isset($data[1]) ? $data[1] : $item_value; |
| 1512 |
$value = stripslashes(htmlspecialchars($value)); |
| 1513 |
$item_value = stripslashes(htmlspecialchars($item_value)); |
| 1514 |
$selected = ( $item_value == $value ) ? 'selected="selected"' : ''; |
| 1515 |
|
| 1516 |
$field_html .= '<option value="' . esc_attr($item_value) . '" ' . $selected . '>' . stripslashes($item_label) . '</option>'; |
| 1517 |
// <<< its some #1 code |
| 1518 |
} |
| 1519 |
$field_html .= '</optgroup>'; |
| 1520 |
}else{ |
| 1521 |
// >>> its some #1 code |
| 1522 |
$data = explode('=>', $v); |
| 1523 |
$item_value = isset($data[0]) ? $data[0] : 'no_value'; |
| 1524 |
$item_label = isset($data[1]) ? $data[1] : $item_value; |
| 1525 |
$value = stripslashes(htmlspecialchars($value)); |
| 1526 |
$item_value = stripslashes(htmlspecialchars($item_value)); |
| 1527 |
$selected = ( $item_value == $value ) ? 'selected="selected"' : ''; |
| 1528 |
|
| 1529 |
$field_html .= '<option value="' . esc_attr($item_value) . '" ' . $selected . '>' . stripslashes($item_label) . '</option>'; |
| 1530 |
// <<< its some #1 code |
| 1531 |
} |
| 1532 |
} |
| 1533 |
} |
| 1534 |
$field_html .= '</select>'; |
| 1535 |
} |
| 1536 |
elseif ($type == 'usergroup') { |
| 1537 |
$groupids = array(); |
| 1538 |
|
| 1539 |
if ($allowedGroupIds) { |
| 1540 |
if (!is_array($allowedGroupIds)) $allowedGroupIds = explode(',', trim($allowedGroupIds)); |
| 1541 |
$groupids = $allowedGroupIds; |
| 1542 |
} |
| 1543 |
if ( !$this->wpforo->current_object['user_is_same_current_user'] && ($this->wpforo->current_user_groupid == 1 || current_user_can('administrator') ) ) $groupids = $this->wpforo->usergroup->get_usergroups('groupid'); |
| 1544 |
|
| 1545 |
if( $this->wpforo->current_object['user_is_same_current_user'] && !in_array($this->wpforo->current_user_groupid, $allowedGroupIds) ) $groupids = array(); |
| 1546 |
|
| 1547 |
$groupids = array_filter($groupids); |
| 1548 |
if( $groupids ){ |
| 1549 |
$field_html = '<select ' . $isRequired . ' name="' . esc_attr($fieldName) . '" id="' . esc_attr($fieldId) . '" class="' . esc_attr($class) . '" ' . $isDisabled . ' ' . $attributes . '>'; |
| 1550 |
if (!$isRequired) $field_html .= '<option value="">' . wpforo_phrase('--- Choose ---', false) . '</option>'; |
| 1551 |
foreach ($groupids as $groupid) { |
| 1552 |
if ( $group = $this->wpforo->usergroup->get_usergroup($groupid) ) { |
| 1553 |
$selected = ($groupid == $value) ? 'selected="selected"' : ''; |
| 1554 |
$field_html .= '<option value="' . esc_attr($groupid) . '" ' . $selected . '>' . $group['name'] . '</option>'; |
| 1555 |
} |
| 1556 |
} |
| 1557 |
$field_html .= '</select>'; |
| 1558 |
} |
| 1559 |
} |
| 1560 |
elseif( $type == 'avatar' ){ |
| 1561 |
$field_html = '<ul> |
| 1562 |
<li><input ' . $isRequired . ' name="' . esc_attr($varname) . '[avatar_type]" id="wpfat_gravatar" value="gravatar" ' . ( $value == '' || $value == NULL ? 'checked="checked"' : '' ) . ' type="radio" /> <label for="wpfat_gravatar">' . wpforo_phrase('Wordpress avatar system', false) . '</label></li> |
| 1563 |
<li><input name="' . esc_attr($varname) . '[avatar_type]" id="wpfat_remote" value="remote" ' . ( $value && strpos($value, 'wpforo/avatars') === FALSE ? 'checked="checked"' : '' ) . ' type="radio" /> <label for="wpfat_remote">' . wpforo_phrase('Specify avatar by URL:', false) . '</label> <input autocomplete="off" name="' . esc_attr($varname) . '[avatar_url]" value="" maxlength="300" data-wpfucf-minmaxlength="1,300" type="url" /></li>'; |
| 1564 |
if( $this->wpforo->perm->usergroup_can('upa') ) { |
| 1565 |
$field_html .= '<li><input name="' . esc_attr($varname) . '[avatar_type]" id="wpfat_custom" value="custom" type="radio" /> <label for="wpfat_custom">' . wpforo_phrase('Upload an avatar', false) . '</label>' . ( strpos($value, 'wpforo/avatars') !== FALSE ? '<br /><img src="' . esc_url($value) . '" class="wpf-custom-avatar-img"/>' : '' ) .' <input class="wpf-custom-avatar" name="avatar" type="file" /> </li>'; |
| 1566 |
} |
| 1567 |
$field_html .= '</ul> |
| 1568 |
<script type="text/javascript">jQuery(document).ready(function($){$( "input[name=\'member\[avatar_url\]\']" ).click(function(){$( "#wpfat_remote" ).prop(\'checked\', true);}); $( "input[name=\'avatar\']" ).click(function(){$( "#wpfat_custom" ).prop(\'checked\', true);});});</script>'; |
| 1569 |
} |
| 1570 |
elseif( $type == 'html' ){ |
| 1571 |
$field_html = stripslashes($html); |
| 1572 |
} |
| 1573 |
else{ |
| 1574 |
$field_html = '<input ' . $isRequired . ' type="' . $type .'" value="' . esc_attr($value) . '" name="' . esc_attr($fieldName) .'" id="' . esc_attr($fieldId) . '" class="' . esc_attr($class) . '" ' . $isDisabled . ' '.$attributes.' ' . trim($minmax) . ' placeholder="' . esc_attr($placeholder) . '"/>'; |
| 1575 |
} |
| 1576 |
|
| 1577 |
if( $wrap && $type != 'password' && $field_html ) $field_html = $this->field_wrap( $args, $field_html ); |
| 1578 |
|
| 1579 |
return $field_html; |
| 1580 |
|
| 1581 |
} |
| 1582 |
|
| 1583 |
|
| 1584 |
public function field_wrap( $args, $field_html ){ |
| 1585 |
if( !is_array($args) || empty($args) ) return $field_html; extract( $args ); $field_wrap_html = ''; $is_owner = false; $rIcon = ''; |
| 1586 |
if( isset($this->wpforo->current_object['user']['ID']) ) { $is_owner = wpforo_is_owner( $this->wpforo->current_object['user']['ID'] ); } |
| 1587 |
$field_name_class = sanitize_text_field($name); |
| 1588 |
if( $isRequired ) $rIcon = ' <span class="wpf-field-required-icon" title="' . esc_attr(wpforo_phrase('Required field', false)) . '">*</span>'; |
| 1589 |
$field_required_class = ( $isRequired ) ? 'wpf-field-required' : ''; |
| 1590 |
if( $template == 'register' ){ |
| 1591 |
$field_wrap_html .= '<div class="wpf-field wpf-field-type-' . esc_attr($type) . ' wpf-field-name-' . esc_attr($field_name_class) . ' ' . esc_attr($field_required_class) . '" title="' . esc_attr($title) . '">'; |
| 1592 |
if( $type == 'html' ){ |
| 1593 |
$field_wrap_html .= $field_html; |
| 1594 |
} |
| 1595 |
else{ |
| 1596 |
if ( $label || $description ) { |
| 1597 |
$field_wrap_html .= '<div class="wpf-label-wrap">'; |
| 1598 |
if ($label){ $field_wrap_html .= '<p class="wpf-label wpfcl-1">' . stripslashes($label) . $rIcon . '</p>'; } |
| 1599 |
if ($description){ $field_wrap_html .= '<div class="wpf-desc wpfcl-2">' . $description . '</div>'; } |
| 1600 |
$field_wrap_html .= '</div>'; |
| 1601 |
} |
| 1602 |
$field_wrap_html .= '<div class="wpf-field-wrap">'; |
| 1603 |
if($faIcon){ $field_wrap_html .= '<i class="fa ' . esc_attr($faIcon) . ' wpf-field-icon"></i>'; } |
| 1604 |
$field_wrap_html .= $field_html; |
| 1605 |
$field_wrap_html .= '</div>'; |
| 1606 |
} |
| 1607 |
$field_wrap_html .= '<div class="wpf-field-cl"></div></div>'; |
| 1608 |
} |
| 1609 |
elseif( $template == 'account' ){ |
| 1610 |
//if( !$isEditable && !$value ) return; |
| 1611 |
if( isset($this->wpforo->current_user_groupid) && isset($canEdit) && !empty($canEdit) ){ |
| 1612 |
$canEdit = ( is_array($canEdit) ) ? $canEdit : array(1); |
| 1613 |
if( !$is_owner && !in_array( $this->wpforo->current_user_groupid, $canEdit )) return; |
| 1614 |
if( $type == 'usergroup' && (!$this->wpforo->current_user_groupid == 1 || !current_user_can('administrator'))) return; |
| 1615 |
if( $type == 'avatar' && (!$this->wpforo->perm->usergroup_can('va') || !wpforo_feature('custom-avatars') || !wpforo_feature('avatars'))) return; |
| 1616 |
if( $name == 'signature' && (!$this->wpforo->perm->usergroup_can('ups') || !wpforo_feature('signature'))) return; |
| 1617 |
if( $name == 'user_login' ){ $description = ''; $faIcon = ''; $field_html = '<span class="wpf-username">' . $value . '</span>'; } |
| 1618 |
if( !$isEditable && $name != 'user_login' ){ |
| 1619 |
$description = ''; |
| 1620 |
$field_html = '<span class="wpf-filed-value"><i class="fa ' . esc_attr($faIcon) . '"></i> ' . $value . '</span>' . $field_html; |
| 1621 |
$faIcon = ''; |
| 1622 |
} |
| 1623 |
} |
| 1624 |
$field_wrap_html .= '<div class="wpf-field wpf-field-type-' . esc_attr($type) . ' wpf-field-name-' . esc_attr($field_name_class) . ' ' . esc_attr($field_required_class) . '" title="' . esc_attr($title) . '">'; |
| 1625 |
if( $type == 'html' ){ |
| 1626 |
$field_wrap_html .= $field_html; |
| 1627 |
} |
| 1628 |
else{ |
| 1629 |
if ( $label || $description ) { |
| 1630 |
$field_wrap_html .= '<div class="wpf-label-wrap">'; |
| 1631 |
if ($label){ $field_wrap_html .= '<p class="wpf-label wpfcl-1">' . stripslashes($label) . $rIcon . '</p>'; } |
| 1632 |
if ($description){ $field_wrap_html .= '<div class="wpf-desc wpfcl-2">' . $description . '</div>'; } |
| 1633 |
$field_wrap_html .= '</div>'; |
| 1634 |
} |
| 1635 |
$field_wrap_html .= '<div class="wpf-field-wrap">'; |
| 1636 |
if($faIcon){ $field_wrap_html .= '<i class="fa ' . esc_attr($faIcon) . ' wpf-field-icon"></i>'; } |
| 1637 |
$field_wrap_html .= $field_html; |
| 1638 |
|
| 1639 |
switch ($type){ |
| 1640 |
case 'file': |
| 1641 |
if( !empty($value) ) { |
| 1642 |
$wp_upload_dir = wp_upload_dir(); |
| 1643 |
$value = $wp_upload_dir['baseurl'] . "/" . trim($value, '/'); |
| 1644 |
$field_wrap_html .= '<br/>' . sprintf('<a href="%s" target="_blank">%s</a>', $value, basename($value)); |
| 1645 |
} |
| 1646 |
break; |
| 1647 |
} |
| 1648 |
|
| 1649 |
$field_wrap_html .= '</div>'; |
| 1650 |
} |
| 1651 |
$field_wrap_html .= '<div class="wpf-field-cl"></div></div>'; |
| 1652 |
} |
| 1653 |
elseif( $template == 'profile' ){ |
| 1654 |
if( !isset($value) || empty($value) || !$value ){ return; } |
| 1655 |
if( $type == 'textarea' ) $value = wpautop(wpforo_kses(stripslashes($value))); |
| 1656 |
$field_wrap_html .= '<div class="wpf-field wpf-field-type-' . esc_attr($type) . ' wpf-field-name-' . esc_attr($field_name_class) . ' ' . esc_attr($field_required_class) . '" title="' . esc_attr($title) . '">'; |
| 1657 |
if( $type == 'html' ){ |
| 1658 |
$field_wrap_html .= $field_html; |
| 1659 |
} |
| 1660 |
else{ |
| 1661 |
if( !$faIcon ) { $faIcon .= 'fa-address-card'; } |
| 1662 |
if( $label ) { $field_wrap_html .= '<div class="wpf-label-wrap">'; if ($label){ $field_wrap_html .= '<p class="wpf-label wpfcl-1"><i class="fa ' . esc_attr($faIcon) . ' wpf-field-icon"></i> ' . stripslashes($label) . '</p>'; } $field_wrap_html .= '</div>';} |
| 1663 |
if( $faIcon ) { $field_wrap_html .= ''; } |
| 1664 |
if( isset($value) && !empty($value) ){ |
| 1665 |
if( is_array($value) ){ |
| 1666 |
$field_wrap_html .= esc_html(implode( ', ', $value)); |
| 1667 |
} |
| 1668 |
else{ |
| 1669 |
switch ($args['type']){ |
| 1670 |
case 'url': |
| 1671 |
$value = sprintf('<a href="%s" target="_blank">%s</a>', $value, $value); |
| 1672 |
break; |
| 1673 |
case 'email': |
| 1674 |
$value = sprintf('<a href="mailto:%s">%s</a>', $value, $value); |
| 1675 |
break; |
| 1676 |
case 'phone': |
| 1677 |
$value = sprintf('<a href="tel:%s">%s</a>', $value, $value); |
| 1678 |
break; |
| 1679 |
case 'file': |
| 1680 |
if( !empty($value) ){ |
| 1681 |
$wp_upload_dir = wp_upload_dir(); |
| 1682 |
$value = $wp_upload_dir['baseurl'] . "/" . trim($value, '/'); |
| 1683 |
$value = sprintf('<a href="%s" target="_blank">%s</a>', $value, basename($value)); |
| 1684 |
} |
| 1685 |
break; |
| 1686 |
} |
| 1687 |
|
| 1688 |
switch ($args['name']){ |
| 1689 |
case 'skype': |
| 1690 |
$value = sprintf('<a href="skype:%s?userinfo">%s</a>', $value, $value); |
| 1691 |
break; |
| 1692 |
case 'location': |
| 1693 |
$value = sprintf('<a href="//maps.google.com/?q=%s" target="_blank">%s</a>', $value, $value); |
| 1694 |
break; |
| 1695 |
} |
| 1696 |
|
| 1697 |
|
| 1698 |
$field_wrap_html .= '<div class="wpf-field-wrap">'; |
| 1699 |
$field_wrap_html .= $value; |
| 1700 |
$field_wrap_html .= '</div>'; |
| 1701 |
} |
| 1702 |
} |
| 1703 |
} |
| 1704 |
$field_wrap_html .= '<div class="wpf-field-cl"></div></div>'; |
| 1705 |
} |
| 1706 |
elseif( $template == 'members' ){ |
| 1707 |
$field_wrap_html .= '<div class="wpf-field wpf-field-type-' . esc_attr($type) . ' wpf-field-name-' . esc_attr($field_name_class) . ' ' . esc_attr($field_required_class) . '" title="' . esc_attr($title) . '">'; |
| 1708 |
if( $type == 'html' ){ |
| 1709 |
$field_wrap_html .= $field_html; |
| 1710 |
} |
| 1711 |
else{ |
| 1712 |
if ( $label || $description ) { |
| 1713 |
$field_wrap_html .= '<div class="wpf-label-wrap">'; |
| 1714 |
if ($label){ $field_wrap_html .= '<p class="wpf-label wpfcl-1">' . stripslashes($label) . $rIcon . '</p>'; } |
| 1715 |
if ($description){ $field_wrap_html .= '<div class="wpf-desc wpfcl-2">' . $description . '</div>'; } |
| 1716 |
$field_wrap_html .= '</div>'; |
| 1717 |
} |
| 1718 |
$field_wrap_html .= '<div class="wpf-field-wrap">'; |
| 1719 |
if($faIcon){ |
| 1720 |
$field_wrap_html .= '<i class="fa ' . esc_attr($faIcon) . ' wpf-field-icon"></i>'; |
| 1721 |
} |
| 1722 |
$field_wrap_html .= $field_html; |
| 1723 |
$field_wrap_html .= '</div>'; |
| 1724 |
} |
| 1725 |
$field_wrap_html .= '<div class="wpf-field-cl"></div></div>'; |
| 1726 |
} |
| 1727 |
else{ |
| 1728 |
$field_wrap_html .= '<div class="wpf-field wpf-field-type-' . esc_attr($type) . ' wpf-field-name-' . esc_attr($field_name_class) . ' ' . esc_attr($field_required_class) . '" title="' . esc_attr($title) . '">'; |
| 1729 |
$field_wrap_html .= '<div class="wpf-field-wrap">' . $field_html . '<div class="wpf-field-cl"></div></div>'; |
| 1730 |
$field_wrap_html .= '<div class="wpf-field-cl"></div></div>'; |
| 1731 |
} |
| 1732 |
return $field_wrap_html; |
| 1733 |
} |
| 1734 |
|
| 1735 |
|
| 1736 |
public function form_fields( $fields ){ |
| 1737 |
|
| 1738 |
if(empty($fields)) return ''; |
| 1739 |
$rows = $fields; |
| 1740 |
$html = ''; |
| 1741 |
$rowClasses = ''; |
| 1742 |
$colClasses = ''; |
| 1743 |
|
| 1744 |
for ($i = 0; $i < count($rows); $i++) { |
| 1745 |
|
| 1746 |
if( !isset($rows[$i])) continue; $row = $rows[$i]; $rowClasses .= "row-$i "; $rowClasses .= apply_filters('wpforo_row_classes', '', $i); |
| 1747 |
|
| 1748 |
///////////////////////// ROW START ///////////////////////////////////// |
| 1749 |
|
| 1750 |
$html .= '<div class="wpf-tr ' . esc_attr( $rowClasses ) . '">'; |
| 1751 |
$cell_count = count($row); |
| 1752 |
|
| 1753 |
for ($j = 0; $j < $cell_count; $j++) { |
| 1754 |
|
| 1755 |
if( !isset($row[$j])) continue; $col = $row[$j]; $colClasses = "row_$i-col_$j "; $colClasses .= apply_filters('wpforo_col_classes', '', $i, $j); |
| 1756 |
|
| 1757 |
///////////////////////// COL START ///////////////////////////////// |
| 1758 |
|
| 1759 |
$html .= '<div class="wpf-td wpfw-' . $cell_count . ' ' . esc_attr( $colClasses ) . '">'; |
| 1760 |
|
| 1761 |
for ($k = 0; $k < count($col); $k++) { |
| 1762 |
|
| 1763 |
///////////////////////// FIELD START /////////////////////////// |
| 1764 |
|
| 1765 |
$field = $col[$k]; |
| 1766 |
if( !empty($field) ) { |
| 1767 |
$html .= $this->field( $field ); |
| 1768 |
} |
| 1769 |
|
| 1770 |
///////////////////////// FIELD END ///////////////////////////// |
| 1771 |
|
| 1772 |
} |
| 1773 |
|
| 1774 |
$html .= '</div>'; |
| 1775 |
|
| 1776 |
///////////////////////// COL END /////////////////////////////////// |
| 1777 |
} |
| 1778 |
|
| 1779 |
$html .= '<div class="wpf-cl"></div></div>'; |
| 1780 |
|
| 1781 |
///////////////////////// ROW END //////////////////////////////////////// |
| 1782 |
} |
| 1783 |
|
| 1784 |
return $html; |
| 1785 |
} |
| 1786 |
|
| 1787 |
} |