PluginProbe
wpForo Forum / 1.4.2
wpForo Forum v1.4.2
3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.2 All 137 releases
wpforo / wpf-includes / class-template.php

class-template.php in wpForo Forum 1.4.2, at wpf-includes/class-template.php

1,777 lines 87.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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') ?>:&nbsp; </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">&nbsp;&nbsp;
123 <i class="fa fa-exclamation fa-0x"></i>&nbsp;&nbsp;<label for="t_sticky" style="padding-bottom:2px; cursor: pointer;"><?php wpforo_phrase('Set Topic Sticky'); ?>&nbsp;</label>
124 <span class="wpfbs">&nbsp;&nbsp;|&nbsp;&nbsp;</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">&nbsp;&nbsp;
128 <i class="fa fa-eye-slash fa-0x"></i>&nbsp;&nbsp;<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'); ?>&nbsp;</label>
129 <span class="wpfbs">&nbsp;&nbsp;|&nbsp;&nbsp;</span>
130 <?php endif; ?>
131 <?php do_action('wpforo_topic_form_buttons_hook'); ?>&nbsp;&nbsp;
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" ' : ''; ?>/>&nbsp;<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'); ?>&nbsp;&nbsp;
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" ' : ''; ?> />&nbsp;<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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</a>
570 </div>
571
572 <?php break;
573 case 'recent': ?>
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="#" class="active"><?php wpforo_phrase('Recently Added') ?></a>
579
580 <a href="#" class="wpf-end">&nbsp;</a>
581 </div>
582
583 <?php break;
584 case 'profile': ?>
585
586 <div class="wpf-breadcrumb">
587 <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i></a>
588
589 <a href="<?php echo wpforo_home_url('members') ?>"><?php wpforo_phrase('Members') ?></a>
590 <a href="#" class="active"><?php @wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), 19 ) ?></a>
591
592 <a href="#" class="wpf-end">&nbsp;</a>
593 </div>
594
595 <?php break;
596 case 'account': ?>
597
598 <div class="wpf-breadcrumb">
599 <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i>
600
601 <a href="<?php echo wpforo_home_url('members') ?>"><?php wpforo_phrase('Members') ?></a>
602 <a href="<?php echo esc_url($user['profile_url']) ?>"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), 19 ) ?></a>
603 <a href="#" class="active"><?php wpforo_phrase('Account') ?></a>
604
605 <a href="#" class="wpf-end">&nbsp;</a>
606 </div>
607
608 <?php break;
609 case 'activity': ?>
610
611 <div class="wpf-breadcrumb">
612 <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i>
613
614 <a href="<?php echo wpforo_home_url('members') ?>"><?php wpforo_phrase('Members') ?></a>
615 <a href="<?php echo esc_url($user['profile_url']) ?>"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), 19 ) ?></a>
616 <a href="#" class="active"><?php wpforo_phrase('Activity') ?></a>
617
618 <a href="#" class="wpf-end">&nbsp;</a>
619 </div>
620
621 <?php break;
622 case 'subscriptions': ?>
623
624 <div class="wpf-breadcrumb">
625 <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i>
626
627 <a href="<?php echo wpforo_home_url('members') ?>"><?php wpforo_phrase('Members') ?></a>
628 <a href="<?php echo esc_url($user['profile_url']) ?>"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), 19 ) ?></a>
629 <a href="#" class="active"><?php wpforo_phrase('Subscriptions') ?></a>
630
631 <a href="#" class="wpf-end">&nbsp;</a>
632 </div>
633
634 <?php break;
635 // TODO: move code to pm plugin
636 case 'messages': ?>
637
638 <div class="wpf-breadcrumb">
639 <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i>
640
641 <a href="<?php echo wpforo_home_url('members') ?>"><?php wpforo_phrase('Members') ?></a>
642
643 <?php if(!empty($user)) : ?>
644
645 <a href="<?php echo esc_url($user['profile_url']) ?>"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), 19 ) ?></a>
646
647 <?php endif ?>
648
649 <a href="#" class="active"><?php wpforo_phrase('Messages') ?></a>
650
651 <a href="#" class="wpf-end">&nbsp;</a>
652 </div>
653
654 <?php break;
655 case 'topic': ?>
656
657 <div class="wpf-breadcrumb">
658 <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>
659
660 <?php if(isset($forumid)) : ?>
661 <?php $relative_ids = array();
662 $this->wpforo->forum->get_all_relative_ids($forumid, $relative_ids);
663 foreach( $relative_ids as $key => $rel_forumid ) : ?>
664 <?php $forum = wpforo_forum($rel_forumid) ?>
665 <?php if(!empty($forum)): ?>
666 <?php if( $key != ( count($relative_ids) - 1 ) ) : ?>
667 <a href="<?php echo esc_url( $forum['url'] ) ?>" title="<?php echo esc_attr($forum['title']) ?>"><?php wpforo_text($forum['title'], 19) ?></a>
668 <?php else : ?>
669 <a href="#" class="active" title="<?php echo esc_attr($forum['title']) ?>"><?php wpforo_text($forum['title'], 19) ?></a>
670 <?php endif ?>
671 <?php endif ?>
672 <?php endforeach ?>
673 <?php endif ?>
674
675 <a href="#" class="wpf-end">&nbsp;</a>
676 </div>
677
678 <?php break;
679 case 'post': ?>
680
681 <div class="wpf-breadcrumb">
682 <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>
683
684 <?php if(isset($forumid)) : ?>
685 <?php $relative_ids = array();
686 $this->wpforo->forum->get_all_relative_ids($forumid, $relative_ids);
687 foreach( $relative_ids as $key => $rel_forumid ) : ?>
688 <?php $forum = wpforo_forum($rel_forumid) ?>
689 <?php if(!empty($forum)): ?>
690 <a href="<?php echo esc_url( $forum['url'] ) ?>" title="<?php echo esc_attr($forum['title']) ?>"><?php wpforo_text($forum['title'], 19) ?></a>
691 <?php endif ?>
692 <?php endforeach ?>
693 <?php endif ?>
694 <?php if(!empty($topic)) : ?>
695
696 <a href="#" class="active" title="<?php echo esc_attr($topic['title']) ?>"><?php wpforo_text($topic['title'], 19) ?></a>
697
698 <?php endif ?>
699 <a href="#" class="wpf-end">&nbsp;</a>
700 </div>
701
702 <?php break;
703 default: ?>
704
705 <div class="wpf-breadcrumb">
706 <a href="#" class="wpf-root active"><?php wpforo_phrase('Forums') ?></a>
707 <a href="#" class="wpf-end">&nbsp;</a>
708 </div>
709
710 <?php
711 endswitch;
712
713 }
714
715 function icon($type, $item = array(), $echo = true, $data = 'icon' ){
716
717 $icon = array();
718 $status = false;
719
720 if( isset($item['status']) && $item['status'] ){
721 $icon['class'] = 'fa-exclamation-circle';
722 $icon['color'] = 'wpfcl-5';
723 $icon['title'] = wpforo_phrase('Unapproved', false);
724 if($echo) {
725 $status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title'];
726 }
727 else{
728 return ($data == 'icon') ? implode(' ', $icon) : $icon['title'];
729 }
730 }
731
732 if(isset($item['type'])){
733
734 if( $type == 'topic' ){
735 if($this->wpforo->topic->is_private($item['topicid'])){
736 $icon['class'] = 'fa-eye-slash';
737 $icon['color'] = 'wpfcl-1';
738 $icon['title'] = wpforo_phrase('Private', 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 if( wpforo_topic($item['topicid'], 'is_answer') ){
747 $icon['class'] = 'fa-check-circle';
748 $icon['color'] = 'wpfcl-8';
749 $icon['title'] = wpforo_phrase('Solved', false);
750 if($echo) {
751 $status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title'];
752 }
753 else{
754 return ($data == 'icon') ? implode(' ', $icon) : $icon['title'];
755 }
756 }
757 }
758
759 if( $item['closed'] && $item['type'] == 1 ){
760 $icon['class'] = 'fa-lock';
761 $icon['color'] = 'wpfcl-1';
762 $icon['title'] = wpforo_phrase('Closed', false);
763 if($echo) { $status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title']; } else{ return ($data == 'icon') ? implode(' ', $icon) : $icon['title']; }
764 }
765 elseif( $item['closed'] && $item['type'] != 1 ){
766 $icon['class'] = 'fa-lock';
767 $icon['color'] = 'wpfcl-1';
768 $icon['title'] = wpforo_phrase('Closed', false);
769 if($echo) { $status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title']; } else{ return ($data == 'icon') ? implode(' ', $icon) : $icon['title']; }
770 }
771 elseif( !$item['closed'] && $item['type'] == 1 ){
772 $icon['class'] = 'fa-thumb-tack';
773 $icon['color'] = 'wpfcl-5';
774 $icon['title'] = wpforo_phrase('Sticky', false);
775 if($echo) { $status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title']; } else{ return ($data == 'icon') ? implode(' ', $icon) : $icon['title']; }
776 }
777
778 if( $status ){
779 //do nothing
780 }
781 else{
782 if( $type == 'forum' ){
783 $icon['class'] = 'fa-comments';
784 $icon['color'] = 'wpfcl-2';
785 }
786 elseif( $type == 'topic' ){
787 if( $item['posts'] == 1 ){
788 $icon['class'] = 'fa-file-o';
789 $icon['color'] = 'wpfcl-2';
790 $icon['title'] = '';
791 }
792 elseif( $item['posts'] > 1 && $item['posts'] <= 5 ){
793 $icon['class'] = 'fa-file-text-o';
794 $icon['color'] = 'wpfcl-2';
795 $icon['title'] = '';
796 }
797 elseif( $item['posts'] > 5 && $item['posts'] <= 20 ){
798 $icon['class'] = 'fa-file-text';
799 $icon['color'] = 'wpfcl-2';
800 $icon['title'] = '';
801 }
802 elseif( $item['posts'] > 20 ){
803 $icon['class'] = 'fa-file-text';
804 $icon['color'] = 'wpfcl-5';
805 $icon['title'] = '';
806 }
807 else{
808 $icon['class'] = 'fa-file-o';
809 $icon['color'] = 'wpfcl-2';
810 $icon['title'] = '';
811 }
812 }
813 if($echo) { echo ($data == 'icon') ? implode(' ', $icon) : $icon['title']; } else{ return ($data == 'icon') ? implode(' ', $icon) : $icon['title']; }
814 }
815
816 }
817 else{
818 return false;
819 }
820
821 }
822
823 public function member_buttons( $member ){
824
825 if(empty($member)) return false;
826 $profile_access = ( $this->wpforo->perm->usergroup_can('vprf') ? true : false );
827
828 if( $profile_access ){
829 ?>
830 <a class="wpf-member-profile-button" title="<?php wpforo_phrase('Profile') ?>" href="<?php echo esc_url($this->wpforo->member->profile_url($member)) ?>">
831 <i class="fa fa-user"></i>
832 </a>
833 <a class="wpf-member-profile-button" title="<?php wpforo_phrase('Activity') ?>" href="<?php echo esc_url($this->wpforo->member->profile_url($member, 'activity')) ?>">
834 <i class="fa fa-comments-o"></i>
835 </a>
836 <a class="wpf-member-profile-button" title="<?php wpforo_phrase('Subscriptions') ?>" href="<?php echo esc_url($this->wpforo->member->profile_url($member, 'subscriptions')) ?>">
837 <i class="fa fa-rss"></i>
838 </a>
839 <?php do_action( 'wpforo_member_info_buttons', $member ); ?>
840 <?php
841 }
842 }
843
844 public function member_social_buttons( $member ){
845
846 $socnets = array();
847 if(empty($member)) return false;
848 $social_access = ( $this->wpforo->perm->usergroup_can('vmsn') ? true : false );
849
850 if( $social_access ){
851
852 if( isset($member['facebook']) && $member['facebook'] ){
853 $socnets['facebook']['set'] = $member['facebook'];
854 $member['facebook'] = ( strpos($member['facebook'], 'facebook.com') === FALSE ) ? 'https://www.facebook.com/' . trim($member['facebook'], '/') : $member['facebook'] ;
855 $socnets['facebook']['value'] = $member['facebook'];
856 $socnets['facebook']['protocol'] = 'https://';
857 $socnets['facebook']['title'] = wpforo_phrase('Facebook', false);
858 }
859
860 if( isset($member['twitter']) && $member['twitter'] ){
861 $socnets['twitter']['set'] = $member['twitter'];
862 $member['twitter'] = ( strpos($member['twitter'], 'twitter.com') === FALSE ) ? 'http://twitter.com/' . trim($member['twitter'], '/') : $member['twitter'] ;
863 $socnets['twitter']['value'] = $member['twitter'];
864 $socnets['twitter']['protocol'] = 'https://';
865 $socnets['twitter']['title'] = wpforo_phrase('Twitter', false);
866 }
867
868 if( isset($member['gtalk']) && $member['gtalk'] ){
869 $socnets['gtalk']['set'] = $member['gtalk'];
870 $socnets['gtalk']['value'] = $member['gtalk'];
871 $socnets['gtalk']['protocol'] = 'https://';
872 $socnets['gtalk']['title'] = wpforo_phrase('Google+', false);
873 }
874
875 if( isset($member['yahoo']) && $member['yahoo'] ){
876 $socnets['yahoo']['set'] = $member['yahoo'];
877 $socnets['yahoo']['value'] = $member['yahoo'];
878 $socnets['yahoo']['protocol'] = 'mailto:';
879 $socnets['yahoo']['title'] = wpforo_phrase('Yahoo', false);
880 }
881
882 if( isset($member['aim']) && $member['aim'] ){
883 $socnets['aim']['set'] = $member['aim'];
884 $socnets['aim']['value'] = $member['aim'];
885 $socnets['aim']['protocol'] = 'mailto:';
886 $socnets['aim']['title'] = wpforo_phrase('AOL IM', false);
887 }
888
889 if( isset($member['icq']) && $member['icq'] ){
890 $socnets['icq']['set'] = $member['icq'];
891 $socnets['icq']['value'] = 'www.icq.com/whitepages/cmd.php?uin=' . $member['icq'] . '&action=message';
892 $socnets['icq']['protocol'] = 'https://';
893 $socnets['icq']['title'] = wpforo_phrase('ICQ', false);
894 }
895
896 if( isset($member['msn']) && $member['msn'] ){
897 $socnets['msn']['set'] = $member['msn'];
898 $socnets['msn']['value'] = $member['msn'];
899 $socnets['msn']['protocol'] = 'mailto:';
900 $socnets['msn']['title'] = wpforo_phrase('MSN', false);
901 }
902
903 if( isset($member['skype']) && $member['skype'] ){
904 $socnets['skype']['set'] = $member['skype'];
905 $socnets['skype']['value'] = $member['skype'];
906 $socnets['skype']['protocol'] = 'skype:';
907 $socnets['skype']['title'] = wpforo_phrase('Skype', false);
908 }
909
910 ?>
911 <div class="wpf-member-socnet-wrap">
912 <?php if(!empty($socnets)): ?>
913 <?php foreach( $socnets as $key => $socnet ): ?>
914 <?php if( !$socnet['set'] ) continue; ?>
915 <?php $title = $member['display_name'] . ' - ' . $socnet['title']; ?>
916 <?php $url = ($key == 'skype') ? 'skype:' . esc_attr($socnet['value']) : esc_url($socnet['protocol'] . str_replace( array('https://', 'http://', 'skype:', 'mailto:'), '', $socnet['value'])); ?>
917 <a href="<?php echo $url ?>" class="wpf-member-socnet-button" title="<?php echo esc_attr($title) ?>">
918 <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) ?>" />
919 </a>
920 <?php endforeach; ?>
921 <?php endif; ?>
922 <?php do_action( 'wpforo_member_socnet_buttons', $member ); ?>
923 </div>
924 <?php
925 }
926 }
927
928 public function init_member_templates(){
929 $this->wpforo->member_tpls = array(
930 'account' => wpftpl('profile-account.php'),
931 'activity' => wpftpl('profile-activity.php'),
932 'subscriptions' => wpftpl('profile-subscriptions.php')
933 );
934 $this->wpforo->member_tpls = apply_filters('wpforo_member_templates_filter', $this->wpforo->member_tpls);
935 $this->wpforo->member_tpls['profile'] = wpftpl('profile-home.php');
936 }
937
938 function has_menu(){
939 return has_nav_menu( 'wpforo-menu' );
940 }
941
942 function nav_menu(){
943 if ( has_nav_menu( 'wpforo-menu' ) ){
944 $defaults = array(
945 'theme_location' => 'wpforo-menu',
946 'menu' => '',
947 'container' => '',
948 'container_class' => '',
949 'container_id' => '',
950 'menu_class' => 'wpf-menu',
951 'menu_id' => 'wpf-menu',
952 'echo' => true,
953 'fallback_cb' => 'wp_page_menu',
954 'before' => '',
955 'after' => '',
956 'link_before' => '',
957 'link_after' => '',
958 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
959 'depth' => 0,
960 'walker' => ''
961 );
962 wp_nav_menu( $defaults );
963 }
964 }
965
966 function init_nav_menu(){
967
968 if(isset($this->wpforo->current_object) && !empty($this->wpforo->current_object)){
969
970 extract($this->wpforo->current_object, EXTR_OVERWRITE);
971
972 $this->wpforo->menu['wpforo-home'] = array(
973 'href' => wpforo_home_url(),
974 'label' => wpforo_phrase('forums', FALSE),
975 'attr' => ( $template == 'forum' || $template == 'topic' || $template == 'post' ? ' class="wpforo-active"' : '' ),
976 'submenues' => array()
977 );
978
979 if($this->wpforo->perm->usergroup_can('vmem')){
980 $this->wpforo->menu['wpforo-members'] = array(
981 'href' => wpforo_home_url('members'),
982 'label' => wpforo_phrase('members', FALSE),
983 'attr' => ( $template == 'members' ? ' class="wpforo-active"' : '' ),
984 'submenues' => array()
985 );
986 }
987
988 $this->wpforo->menu['wpforo-recent'] = array(
989 'href' => wpforo_home_url('recent'),
990 'label' => wpforo_phrase('Recent Posts', FALSE),
991 'attr' => ( $template == 'recent' ? ' class="wpforo-active"' : '' ),
992 'submenues' => array()
993 );
994
995 if( is_user_logged_in() ){
996
997 $this->wpforo->menu['wpforo-profile-home'] = array(
998 'href' => $this->wpforo->member->get_profile_url($this->wpforo->current_userid),
999 'label' => wpforo_phrase('my profile', FALSE),
1000 'attr' => ( isset($this->wpforo->member_tpls[$template]) && $this->wpforo->member_tpls[$template] && $this->wpforo->current_object['user_is_same_current_user'] ? ' class="wpforo-active"' : '' ),
1001 'submenues' => array()
1002 );
1003 $this->wpforo->menu['wpforo-profile-account'] = array(
1004 'href' => $this->wpforo->member->get_profile_url($this->wpforo->current_userid, 'account'),
1005 'label' => wpforo_phrase('account', FALSE),
1006 'attr' => ( $template == 'account' && $this->wpforo->current_object['user_is_same_current_user'] ? ' class="wpforo-active"' : '' ),
1007 'submenues' => array()
1008 );
1009 $this->wpforo->menu['wpforo-profile-activity'] = array(
1010 'href' => $this->wpforo->member->get_profile_url($this->wpforo->current_userid, 'activity'),
1011 'label' => wpforo_phrase('activity', FALSE),
1012 'attr' => ( $template == 'activity' && $this->wpforo->current_object['user_is_same_current_user'] ? ' class="wpforo-active"' : '' ),
1013 'submenues' => array()
1014 );
1015 $this->wpforo->menu['wpforo-profile-subscriptions'] = array(
1016 'href' => $this->wpforo->member->get_profile_url($this->wpforo->current_userid, 'subscriptions'),
1017 'label' => wpforo_phrase('subscriptions', FALSE),
1018 'attr' => ( $template == 'subscriptions' && $this->wpforo->current_object['user_is_same_current_user'] ? ' class="wpforo-active"' : '' ),
1019 'submenues' => array()
1020 );
1021 $this->wpforo->menu['wpforo-logout'] = array(
1022 'href' => wpforo_home_url('?wpforo=logout'),
1023 'label' => wpforo_phrase('logout', FALSE),
1024 'attr' => '',
1025 'submenues' => array()
1026 );
1027
1028 }else{
1029
1030 if( wpforo_feature('user-register', $this->wpforo) ){
1031 $this->wpforo->menu['wpforo-register'] = array(
1032 'href' => wpforo_register_url(),
1033 'label' => wpforo_phrase('register', FALSE),
1034 'attr' => ( isset($_GET['wpforo']) && $_GET['wpforo'] == 'signup' ? ' class="wpforo-active"' : '' ),
1035 'submenues' => array()
1036 );
1037 }
1038 $this->wpforo->menu['wpforo-login'] = array(
1039 'href' => wpforo_login_url(),
1040 'label' => wpforo_phrase('login', FALSE),
1041 'attr' => ( isset($_GET['wpforo']) && $_GET['wpforo'] == 'signin' ? ' class="wpforo-active"' : '' ),
1042 'submenues' => array()
1043 );
1044 }
1045
1046 $this->wpforo->menu = apply_filters('wpforo_menu_array_filter', $this->wpforo->menu);
1047 }
1048 }
1049
1050 /**
1051 *
1052 * Checks in current active theme options if certain layout exists.
1053 *
1054 * @since 1.0.0
1055 *
1056 * @param mixed $identifier Layout id (folder name) OR @layout variable in header ( 1 or Extended )
1057 * @param string $identifier_type The type of first parameter 'id' OR 'name' (@layout)
1058 *
1059 * @return boolean true/false
1060 *
1061 **/
1062 function layout_exists( $identifier, $identifier_type = 'id' ){
1063
1064 $layouts = $this->options['layouts'];
1065
1066 if( $identifier_type == 'id' ){
1067 if( isset($layouts[$identifier]) && !empty($layouts[$identifier])){
1068 return true;
1069 }
1070 else{
1071 return false;
1072 }
1073 }
1074 elseif( $identifier_type = 'name' ){
1075 foreach( $layouts as $id => $layout ){
1076 if( !isset($layout['name']) && $layout['name'] == $identifier ){
1077 return true;
1078 }
1079 }
1080 return false;
1081 }
1082 }
1083
1084 /**
1085 *
1086 * Finds and returns all layouts information in array from theme's /layouts/ folder
1087 *
1088 * @since 1.0.0
1089 *
1090 * @param string $theme Theme id ( folder name ) e.g. 'classic'
1091 *
1092 * @return array
1093 *
1094 **/
1095 function find_layouts( $theme ){
1096 $layout_data = array();
1097 $layouts = $this->find_themes('/'.$theme.'/layouts', 'php', 'layout');
1098 if(!empty($layouts)){
1099 foreach( $layouts as $layout ){
1100 $lid = trim(basename(dirname( $layout['file']['value'] )), '/');
1101 $layout_data[$lid]['id'] = $lid;
1102 $layout_data[$lid]['name'] = $layout['name']['value'];
1103 $layout_data[$lid]['version'] = $layout['version']['value'];
1104 $layout_data[$lid]['description'] = $layout['description']['value'];
1105 $layout_data[$lid]['author'] = $layout['author']['value'];
1106 $layout_data[$lid]['url'] = $layout['layout_url']['value'];
1107 $layout_data[$lid]['file'] = $layout['file']['value'];
1108 }
1109 }
1110 return $layout_data;
1111 }
1112
1113 function show_layout_selectbox($layoutid = 0){
1114 $layouts = $this->find_layouts( WPFORO_THEME );
1115 if( !empty($layouts) ){
1116 foreach( $layouts as $layout ) : ?>
1117 <option value="<?php echo esc_attr(trim($layout['id'])) ?>" <?php echo ( $layoutid == $layout['id'] ? 'selected' : '' ); ?> ><?php echo esc_html($layout['name']) ?></option>
1118 <?php
1119 endforeach;
1120 }
1121 }
1122
1123 /**
1124 *
1125 * Finds and returns styles array from theme's /styles/colors.php file
1126 *
1127 * @since 1.0.0
1128 *
1129 * @param string $theme Theme id ( folder name ) e.g. 'classic'
1130 *
1131 * @return array
1132 *
1133 **/
1134 function find_styles( $theme ){
1135 $colors = array();
1136 $color_file = WPFORO_THEME_DIR . '/' . $theme . '/styles/colors.php';
1137 if( file_exists($color_file) ){
1138 include( $color_file );
1139 }
1140 return $colors;
1141 }
1142
1143 /**
1144 *
1145 * Scans certain theme directory and returns all information in array ( theme header, layouts, styles ).
1146 *
1147 * @since 1.0.0
1148 *
1149 * @param string $theme_file Theme folder name or main css file base path ( 'classic' OR classic/style.css' )
1150 *
1151 * @return array
1152 *
1153 **/
1154 function find_theme( $theme_file ){
1155 $theme = array();
1156 $theme_file = trim(trim($theme_file, '/'));
1157
1158 if( preg_match('|\.[\w\d]{2,4}$|is', $theme_file) ){
1159 $theme_folder = trim(basename(dirname($theme_file)), '/');
1160 }
1161 else{
1162 $theme_folder = $theme_file;
1163 $theme_file = $theme_file . '/style.css';
1164 }
1165
1166 if( !is_readable( WPFORO_THEME_DIR . '/' . $theme_file ) ){
1167 return $theme['error'] = __('Theme file not readable', 'wpforo') .' ('.$theme_file.')';
1168 }
1169 else{
1170 $theme_data = $this->find_theme_headers( WPFORO_THEME_DIR . '/' . $theme_file );
1171 $theme['id'] = $theme_folder;
1172 $theme['name'] = $theme_data['name']['value'];
1173 $theme['version'] = $theme_data['version']['value'];
1174 $theme['description'] = $theme_data['description']['value'];
1175 $theme['author'] = $theme_data['author']['value'];
1176 $theme['url'] = $theme_data['theme_url']['value'];
1177 $theme['file'] = $theme_file;
1178 $theme['folder'] = $theme_folder;
1179 $theme['layouts'] = $this->find_layouts( $theme_folder );
1180 $styles = $this->find_styles( $theme_folder );
1181 if(!empty($styles)){
1182 reset($styles);
1183 $theme['style'] = key($styles);
1184 $theme['styles'] = $styles;
1185 }
1186 return $theme;
1187 }
1188
1189 }
1190
1191 /**
1192 *
1193 * Scans wpForo themes (wpf-themes) folder, reads main files' headers and returns information about all themes in array.
1194 * This function can also be used to scan and get information about layouts in each theme /layouts/ folder.
1195 *
1196 * @since 1.0.0
1197 *
1198 * @param string $base_dir Absolute path to scan directory (e.g. /home/public_html/wp-content/plugins/wpforo/wpf-themes/)
1199 * @param string $ext File extension which may contain header information
1200 * @param string $mode 'theme' or 'layout'
1201 *
1202 * @return array
1203 *
1204 **/
1205 function find_themes( $base_dir = '', $ext = 'css', $mode = 'theme' ){
1206 $themes = array ();
1207 $themes_dir = @opendir( WPFORO_THEME_DIR . $base_dir );
1208 $theme_files = array();
1209 if( $themes_dir ){
1210 while( ($file = readdir( $themes_dir )) !== false ){
1211 if( substr($file, 0, 1) == '.' ) continue;
1212 if( is_dir( WPFORO_THEME_DIR . $base_dir .'/'.$file ) ){
1213 $themes_subdir = @opendir( WPFORO_THEME_DIR . $base_dir .'/'.$file );
1214 if( $themes_subdir ){
1215 while(($subfile = readdir( $themes_subdir ) ) !== false ){
1216 if( substr($subfile, 0, 1) == '.' ) continue;
1217 if( substr($subfile, -4) == '.' . $ext ) $theme_files[] = "$file/$subfile";
1218 }
1219 closedir( $themes_subdir );
1220 }
1221 }
1222 else{
1223 if( substr($file, -4) == '.' . $ext ) $theme_files[] = $file;
1224 }
1225 }
1226 closedir( $themes_dir );
1227 }
1228 if( empty($theme_files) ) return $themes;
1229 foreach( $theme_files as $theme_file ){
1230 if( !is_readable( WPFORO_THEME_DIR . $base_dir . '/' . $theme_file ) ) continue;
1231 if( $mode == 'theme' ){
1232 $theme_data = $this->find_theme_headers( WPFORO_THEME_DIR . $base_dir . '/' . $theme_file );
1233 }
1234 elseif( $mode == 'layout' ){
1235 $theme_data = $this->find_layout_headers( WPFORO_THEME_DIR . $base_dir . '/' . $theme_file );
1236 }
1237 if( empty($theme_data['name']['value']) ) continue;
1238 $themes[wpforo_clear_basename($theme_file)] = $theme_data;
1239 }
1240 return $themes;
1241 }
1242
1243 /**
1244 *
1245 * Reads theme main file's header variables and returns information in array.
1246 *
1247 * @since 1.0.0
1248 *
1249 * @param string $file Absolute path to file (e.g. /home/public_html/wp-content/plugins/wpforo/wpf-themes/style.css)
1250 *
1251 * @return array
1252 *
1253 **/
1254 function find_theme_headers( $file ){
1255 $theme_headers = array();
1256 $headers = array(
1257 'name' => 'Theme Name',
1258 'version' => 'Version',
1259 'description' => 'Description',
1260 'author' => 'Author',
1261 'theme_url' => 'Theme URI',
1262 );
1263 $fp = fopen( $file, 'r' );
1264 $data = fread( $fp, 8192 );
1265 fclose( $fp );
1266 $data = str_replace( "\r", "\n", $data );
1267 foreach ( $headers as $header_key => $header_name ){
1268 if ( preg_match( '|^[\s\t\/*#@]*' . preg_quote( $header_name, '|' ) . ':(.*)$|mi', $data, $match ) && $match[1] ){
1269 $theme_headers[$header_key]['name'] = $header_name;
1270 $theme_headers[$header_key]['value'] = trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $match[1]));
1271 }
1272 else{
1273 $theme_headers[$header_key]['name'] = $header_name;
1274 $theme_headers[$header_key]['value'] = '';
1275 }
1276 }
1277 $theme_headers['file']['name'] = 'file';
1278 $theme_headers['file']['value'] = $file;
1279 return $theme_headers;
1280 }
1281
1282 /**
1283 *
1284 * Reads layout main file's header variables and returns information in array.
1285 *
1286 * @since 1.0.0
1287 *
1288 * @param string $file Absolute path to file (e.g. /home/public_html/wp-content/plugins/wpforo/wpf-themes/layouts/1/forum.php)
1289 *
1290 * @return array
1291 *
1292 **/
1293 function find_layout_headers( $file ){
1294 $theme_headers = array();
1295 $headers = array(
1296 'name' => 'layout',
1297 'version' => 'version',
1298 'description' => 'description',
1299 'author' => 'author',
1300 'layout_url' => 'url',
1301 );
1302 $fp = fopen( $file, 'r' );
1303 $data = fread( $fp, 8192 );
1304 fclose( $fp );
1305 $data = str_replace( "\r", "\n", $data );
1306 foreach ( $headers as $header_key => $header_name ){
1307 if ( preg_match( '|^[\s\t\/*#@]*' . preg_quote( $header_name, '|' ) . ':(.*)$|mi', $data, $match ) && $match[1] ){
1308 $theme_headers[$header_key]['name'] = $header_name;
1309 $theme_headers[$header_key]['value'] = trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $match[1]));
1310 }
1311 else{
1312 $theme_headers[$header_key]['name'] = $header_name;
1313 $theme_headers[$header_key]['value'] = '';
1314 }
1315 }
1316 $theme_headers['file']['name'] = 'file';
1317 $theme_headers['file']['value'] = trim(str_replace( WPFORO_THEME_DIR, '', $file), '/');
1318 return $theme_headers;
1319 }
1320
1321 public function copyright(){
1322 if( wpforo_feature('copyright', $this->wpforo) ): ?>
1323 <div id="wpforo-poweredby">
1324 <p class="wpf-by">
1325 <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/">&nbsp;<?php wpforo_phrase('Powered by') ?> wpForo version <?php echo esc_html(WPFORO_VERSION) ?></a>
1326 </p>
1327 </div>
1328 <?php
1329 endif;
1330 }
1331
1332 public function member_menu( $userid, $menu = array() ){
1333 if( empty($menu) ) $menu = array('profile' => 'fa-user', 'account' => 'fa-cog', 'activity' => 'fa-comments-o', 'subscriptions' => 'fa-rss');
1334 $menu = apply_filters('wpforo_member_menu_filter', $menu, $userid);
1335 if( !($userid == $this->wpforo->current_userid || $this->wpforo->perm->usergroup_can('em')) ) unset($menu['account']);
1336 foreach( $menu as $key => $value ) :
1337 ?>
1338 <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) ) ?>">
1339 <i class="fa <?php echo sanitize_html_class($value) ?>"></i> <?php wpforo_phrase($key) ?>
1340 </a>
1341 <?php
1342 endforeach;
1343 }
1344
1345 public function member_template(){
1346 global $wpforo;
1347 extract($this->wpforo->current_object, EXTR_OVERWRITE);
1348 extract($user, EXTR_OVERWRITE);
1349
1350 include( (isset($this->wpforo->member_tpls[$template]) && $this->wpforo->member_tpls[$template] ? $this->wpforo->member_tpls[$template] : $this->wpforo->member_tpls['profile']) );
1351 }
1352
1353 public function member_error(){
1354 echo apply_filters('wpforo_member_error_filter', wpforo_phrase('Members not found', FALSE));
1355 }
1356
1357 public function field( $args, $wrap = true ){
1358
1359 $default = array(
1360 'label' => '',
1361 'title' => '',
1362 'name' => '',
1363 'value' => '', //url
1364 'values' => '',
1365 'type' => 'text',
1366 'placeholder' => '',
1367 'description' => '',
1368 'id' => '',
1369 'class' => '',
1370 'attributes' => '',
1371 'isWrapItem' => '',
1372 'isLabelFirst' => '',
1373 'isDisabled' => false,
1374 'isEditable' => 1,
1375 'isRequired' => 1,
1376 'isMultiChoice' => 0,
1377 'isConfirmPassword' => 1,
1378 'minLength' => 0,
1379 'maxLength' => 0,
1380 'faIcon' => '',
1381 'html' => '',
1382 'varname' => (( isset($this->wpforo->form['varname']) ) ? $this->wpforo->form['varname'] : 'wpfdata'),
1383 'template' => (( isset($this->wpforo->form['template']) ) ? $this->wpforo->form['template'] : $this->wpforo->current_object['template']),
1384 'canBeInactive' => 1,
1385 'canEdit' => array('1'),
1386 'canView' => array('1', '2', '3', '5'),
1387 'can' => ''
1388 );
1389
1390
1391 $args = wpforo_parse_args( $args, $default );
1392 extract( $args );
1393 $field_html = '';
1394 $minLength_attr = '';
1395 $maxLength_attr = '';
1396 $isRequired = ( $isRequired ) ? ' required="required" ' : '';
1397 $isDisabled = ( $isDisabled ) ? ' disabled="disabled" ' : '';
1398 $isDisabled = ( !$isEditable && $template != 'register' && $name != 'user_login') ? ' disabled="disabled" style="display:none" ' : '';
1399 if( !$isDefault ){ $varname = 'data'; }
1400 $fieldName = ( !empty($varname) ? $varname . '[' . $name . ']' : $name );
1401 $fieldId = ( !empty($varname) ? $varname . '_' : '' ) . ( ($id) ? $id : $name );
1402 $minLength = ($minLength) ? intval($minLength): '';
1403 $maxLength = ($maxLength) ? intval($maxLength): '';
1404 if( $minLength ) { $minLength_attr = ($type == 'date' || $type == 'number' || $type == 'range') ? ' min="' . $minLength . '" ' : ' minlength="' . $minLength . '" '; }
1405 if( $maxLength ) { $maxLength_attr = ($type == 'date' || $type == 'number' || $type == 'range') ? ' max="' . $maxLength . '" ' : ' maxlength="' . $maxLength . '" '; }
1406 $minmax = $minLength_attr . ' ' . $maxLength_attr;
1407
1408 $args['value'] = ( isset($this->wpforo->form['value'][$name]) ) ? $this->wpforo->form['value'][$name] : $args['value'];
1409 if( !$isDefault && $varname ) $args['value'] = ( isset($this->wpforo->form['value'][$varname][$name]) ) ? $this->wpforo->form['value'][$varname][$name] : $args['value'];
1410 $value = $args['value'];
1411
1412 if( $type == 'textarea' ){
1413 $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>';
1414 }
1415 elseif( $type == 'password' ){
1416 $password_html = '';
1417 if( $template == 'account' ){
1418 $isRequired = 0;
1419 $args['label'] = wpforo_phrase('Old password', false); $args['description'] = '';
1420 $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>';
1421 $field_html .= ( $wrap ) ? $this->field_wrap( $args, $password_html ) : $password_html;
1422 }
1423 if( $template == 'register' && wpforo_feature('user-register-email-confirm') ){
1424 //If the option "User Registration with Email Confirmation" is enabled password fields should be removed on registration page.
1425 }
1426 else{
1427 if( $isConfirmPassword ) { $p1 = '1'; $p2 = '2'; } else{ $p1 = ''; $p2 = ''; } $fieldName = ( !empty($varname) ? $varname . '[' . $name . $p1 . ']' : $name . $p1 );
1428 if( $template == 'account' ) { $label = wpforo_phrase('New', false) . ' ' . $label; } $args['label'] = $label; $args['description'] = $description;
1429 $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>';
1430 $field_html .= ( $wrap ) ? $this->field_wrap( $args, $password_html ) : $password_html;
1431 if( $isConfirmPassword ){
1432 $args['label'] = wpforo_phrase('Confirm Password', false); $args['description'] = '';
1433 $fieldName = ( !empty($varname) ? $varname . '[' . $name . $p2 . ']' : $name . $p2 );
1434 $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>';
1435 $field_html .= ( $wrap ) ? $this->field_wrap( $args, $password_html ) : $password_html;
1436 }
1437 }
1438 }
1439 elseif( $type == 'file' ){
1440 $extensions = '';
1441 if( $fileExtensions ) {
1442 $fileExtensions = wpforo_parse_args($fileExtensions);
1443 foreach($fileExtensions as $key => $ext ){ if( strpos($ext, '.') === FALSE ) $fileExtensions[ $key ] = '.' . $ext; }
1444 $fileExtensions = implode(', ', $fileExtensions);
1445 if( $fileExtensions ) $extensions = 'accept="' .$fileExtensions . '"';
1446 }
1447 $field_html = '<input '. $isRequired .' type="file" name="' . esc_attr($fieldName) . '" value="" id="' . esc_attr($fieldId) . '" class="' . esc_attr($class) . '" ' . $isDisabled . ' ' . $attributes . ' ' . $extensions . ' />';
1448 }
1449 elseif( $type == 'checkbox' ){
1450 $step = 0;
1451 $field_html = '';
1452 $value = (is_serialized($value)) ? unserialize($value) : (array)$value;
1453 if( !is_array($values) ) $values = wpforo_string2array($values);
1454 if( !empty($values) ){
1455 foreach( $values as $v ){
1456 $v = trim($v);
1457 $data = explode('=>', $v);
1458 $item_value = isset($data[0]) ? $data[0] : 'no_value';
1459 $item_label = isset($data[1]) ? $data[1] : $item_value;
1460 $item_fieldid = $fieldId . '_' . ($step + 1);
1461 $item_fieldname = $fieldName . '[]';
1462 $checked = ( in_array($item_value, $value) ) ? 'checked="checked"' : '';
1463 $field_html .= '<div class="wpf-field-item">';
1464 $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.' />';
1465 if ($isWrapItem) {
1466 $field_html .= '<label>';
1467 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>'; }
1468 $field_html .= '</label>';
1469 }
1470 else {
1471 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>'; }
1472 }
1473 $field_html .= '</div>';
1474 $step++;
1475 }
1476 }
1477 }
1478 elseif( $type == 'radio' ){
1479 $step = 0;
1480 $field_html = '';
1481 if (!is_array($values)) $values = wpforo_string2array($values);
1482 if (!empty($values)) {
1483 $item_values = array();
1484 foreach ($values as $v) {
1485 $v = trim($v);
1486 $data = explode('=>', $v);
1487 $item_value = $data[0];
1488 $item_label = isset($data[1]) ? $data[1] : $item_value;
1489 $item_fieldid = $fieldId . '_' . ($step + 1);
1490 $attrs = ($isRequired) ? 'required="required"' : '';
1491 $attrs .= ($item_value == $value) ? ' checked="checked"' : '';
1492
1493 $field_html .= '<div class="wpf-field-item">';
1494 $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 . ' />';
1495 if ($isWrapItem) {
1496 $field_html .= '<label>';
1497 if ($isLabelFirst) {
1498 $field_html .= '<span class="wpf-radio-label">' . stripslashes($item_label) . '</span> ' . $input_html;
1499 } else {
1500 $field_html .= $input_html . ' <span class="wpf-radio-label">' . stripslashes($item_label) . '</span>';
1501 }
1502 $field_html .= '</label>';
1503 } else {
1504 if ($isLabelFirst) {
1505 $field_html .= '<span class="wpf-radio-label">' . stripslashes($item_label) . '</span> ' . $input_html;
1506 } else {
1507 $field_html .= $input_html . ' <span class="wpf-radio-label">' . stripslashes($item_label) . '</span>';
1508 }
1509 }
1510 $field_html .= '</div>';
1511 $step++;
1512 }
1513
1514 }
1515 }
1516 elseif( $type == 'select' ){
1517
1518 $isMultiChoice = $isMultiChoice ? 'multiple="multiple"' : '';
1519 $field_html = '<select '. $isRequired .' name="' . esc_attr($fieldName) . '" id="' . esc_attr($fieldId) . '" class="' . esc_attr($class) . '" ' . $isMultiChoice . ' ' . $isDisabled . ' '.$attributes.'>';
1520 if(!$isRequired) $field_html .= '<option value="">' . wpforo_phrase('--- Choose ---', false) . '</option>';
1521 if( !empty($values) ){
1522 foreach ($values as $k => $v) {
1523 if( is_array($v) ){
1524 $field_html .= '<optgroup label="' . esc_attr($k) . '">';
1525 foreach ($v as $_k => $_v){
1526 // >>> its some #1 code
1527 $data = explode('=>', $_v);
1528 $item_value = isset($data[0]) ? $data[0] : 'no_value';
1529 $item_label = isset($data[1]) ? $data[1] : $item_value;
1530 $value = stripslashes(htmlspecialchars($value));
1531 $item_value = stripslashes(htmlspecialchars($item_value));
1532 $selected = ( $item_value == $value ) ? 'selected="selected"' : '';
1533
1534 $field_html .= '<option value="' . esc_attr($item_value) . '" ' . $selected . '>' . stripslashes($item_label) . '</option>';
1535 // <<< its some #1 code
1536 }
1537 $field_html .= '</optgroup>';
1538 }else{
1539 // >>> its some #1 code
1540 $data = explode('=>', $v);
1541 $item_value = isset($data[0]) ? $data[0] : 'no_value';
1542 $item_label = isset($data[1]) ? $data[1] : $item_value;
1543 $value = stripslashes(htmlspecialchars($value));
1544 $item_value = stripslashes(htmlspecialchars($item_value));
1545 $selected = ( $item_value == $value ) ? 'selected="selected"' : '';
1546
1547 $field_html .= '<option value="' . esc_attr($item_value) . '" ' . $selected . '>' . stripslashes($item_label) . '</option>';
1548 // <<< its some #1 code
1549 }
1550 }
1551 }
1552 $field_html .= '</select>';
1553 }
1554 elseif ($type == 'usergroup') {
1555 $groupids = array();
1556
1557 if ($allowedGroupIds) {
1558 if (!is_array($allowedGroupIds)) $allowedGroupIds = explode(',', trim($allowedGroupIds));
1559 $groupids = $allowedGroupIds;
1560 }
1561 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');
1562
1563 if( $this->wpforo->current_object['user_is_same_current_user'] && !in_array($this->wpforo->current_user_groupid, $allowedGroupIds) ) $groupids = array();
1564
1565 $groupids = array_filter($groupids);
1566 if( $groupids ){
1567 $field_html = '<select ' . $isRequired . ' name="' . esc_attr($fieldName) . '" id="' . esc_attr($fieldId) . '" class="' . esc_attr($class) . '" ' . $isDisabled . ' ' . $attributes . '>';
1568 if (!$isRequired) $field_html .= '<option value="">' . wpforo_phrase('--- Choose ---', false) . '</option>';
1569 foreach ($groupids as $groupid) {
1570 if ( $group = $this->wpforo->usergroup->get_usergroup($groupid) ) {
1571 $selected = ($groupid == $value) ? 'selected="selected"' : '';
1572 $field_html .= '<option value="' . esc_attr($groupid) . '" ' . $selected . '>' . $group['name'] . '</option>';
1573 }
1574 }
1575 $field_html .= '</select>';
1576 }
1577 }
1578 elseif( $type == 'avatar' ){
1579 $field_html = '<ul>
1580 <li><input ' . $isRequired . ' name="' . esc_attr($varname) . '[avatar_type]" id="wpfat_gravatar" value="gravatar" ' . ( $value == '' || $value == NULL ? 'checked="checked"' : '' ) . ' type="radio" />&nbsp; <label for="wpfat_gravatar">' . wpforo_phrase('Wordpress avatar system', false) . '</label></li>
1581 <li><input name="' . esc_attr($varname) . '[avatar_type]" id="wpfat_remote" value="remote" ' . ( $value && strpos($value, 'wpforo/avatars') === FALSE ? 'checked="checked"' : '' ) . ' type="radio" />&nbsp; <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>';
1582 if( $this->wpforo->perm->usergroup_can('upa') ) {
1583 $field_html .= '<li><input name="' . esc_attr($varname) . '[avatar_type]" id="wpfat_custom" value="custom" type="radio" />&nbsp;<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"/>' : '' ) .'&nbsp; <input class="wpf-custom-avatar" name="avatar" type="file" />&nbsp;</li>';
1584 }
1585 $field_html .= '</ul>
1586 <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>';
1587 }
1588 elseif( $type == 'html' ){
1589 $field_html = stripslashes($html);
1590 }
1591 elseif( $type == 'url' || $name == 'user_nicename' ){
1592 $field_html = '<input ' . $isRequired . ' type="' . $type .'" value="' . esc_attr( urldecode($value) ) . '" name="' . esc_attr($fieldName) .'" id="' . esc_attr($fieldId) . '" class="' . esc_attr($class) . '" ' . $isDisabled . ' '.$attributes.' ' . trim($minmax) . ' placeholder="' . esc_attr($placeholder) . '"/>';
1593 }
1594 else{
1595 $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) . '"/>';
1596 }
1597
1598 if( $wrap && $type != 'password' && $field_html ) $field_html = $this->field_wrap( $args, $field_html );
1599
1600 return $field_html;
1601
1602 }
1603
1604
1605 public function field_wrap( $args, $field_html ){
1606 if( !is_array($args) || empty($args) ) return $field_html; extract( $args ); $field_wrap_html = ''; $is_owner = false; $rIcon = '';
1607 if( isset($this->wpforo->current_object['user']['ID']) ) { $is_owner = wpforo_is_owner( $this->wpforo->current_object['user']['ID'] ); }
1608 $field_name_class = sanitize_text_field($name);
1609 if( $isRequired ) $rIcon = ' <span class="wpf-field-required-icon" title="' . esc_attr(wpforo_phrase('Required field', false)) . '">*</span>';
1610 $field_required_class = ( $isRequired ) ? 'wpf-field-required' : '';
1611 if( $template == 'register' ){
1612 $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) . '">';
1613 if( $type == 'html' ){
1614 $field_wrap_html .= $field_html;
1615 }
1616 else{
1617 if ( $label || $description ) {
1618 $field_wrap_html .= '<div class="wpf-label-wrap">';
1619 if ($label){ $field_wrap_html .= '<p class="wpf-label wpfcl-1">' . stripslashes($label) . $rIcon . '</p>'; }
1620 if ($description){ $field_wrap_html .= '<div class="wpf-desc wpfcl-2">' . $description . '</div>'; }
1621 $field_wrap_html .= '</div>';
1622 }
1623 $field_wrap_html .= '<div class="wpf-field-wrap">';
1624 if($faIcon){ $field_wrap_html .= '<i class="fa ' . esc_attr($faIcon) . ' wpf-field-icon"></i>'; }
1625 $field_wrap_html .= $field_html;
1626 $field_wrap_html .= '</div>';
1627 }
1628 $field_wrap_html .= '<div class="wpf-field-cl"></div></div>';
1629 }
1630 elseif( $template == 'account' ){
1631 //if( !$isEditable && !$value ) return;
1632 if( isset($this->wpforo->current_user_groupid) && isset($canEdit) && !empty($canEdit) ){
1633 $canEdit = ( is_array($canEdit) ) ? $canEdit : array(1);
1634 if( !$is_owner && !in_array( $this->wpforo->current_user_groupid, $canEdit )) return;
1635 if( $type == 'usergroup' && (!$this->wpforo->current_user_groupid == 1 || !current_user_can('administrator'))) return;
1636 if( $type == 'avatar' && (!$this->wpforo->perm->usergroup_can('va') || !wpforo_feature('custom-avatars') || !wpforo_feature('avatars'))) return;
1637 if( $name == 'signature' && (!$this->wpforo->perm->usergroup_can('ups') || !wpforo_feature('signature'))) return;
1638 if( $name == 'user_login' ){ $description = ''; $faIcon = ''; $field_html = '<span class="wpf-username">' . $value . '</span>'; }
1639 if( !$isEditable && $name != 'user_login' ){
1640 $description = '';
1641 $field_html = '<span class="wpf-filed-value"><i class="fa ' . esc_attr($faIcon) . '"></i> ' . $value . '</span>' . $field_html;
1642 $faIcon = '';
1643 }
1644 }
1645 $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) . '">';
1646 if( $type == 'html' ){
1647 $field_wrap_html .= $field_html;
1648 }
1649 else{
1650 if ( $label || $description ) {
1651 $field_wrap_html .= '<div class="wpf-label-wrap">';
1652 if ($label){ $field_wrap_html .= '<p class="wpf-label wpfcl-1">' . stripslashes($label) . $rIcon . '</p>'; }
1653 if ($description){ $field_wrap_html .= '<div class="wpf-desc wpfcl-2">' . $description . '</div>'; }
1654 $field_wrap_html .= '</div>';
1655 }
1656 $field_wrap_html .= '<div class="wpf-field-wrap">';
1657 if($faIcon){ $field_wrap_html .= '<i class="fa ' . esc_attr($faIcon) . ' wpf-field-icon"></i>'; }
1658 $field_wrap_html .= $field_html;
1659
1660 switch ($type){
1661 case 'file':
1662 if( !empty($value) ) {
1663 $wp_upload_dir = wp_upload_dir();
1664 $value = $wp_upload_dir['baseurl'] . "/" . trim($value, '/');
1665 $field_wrap_html .= '<br/>' . sprintf('<a href="%s" target="_blank">%s</a>', $value, basename($value));
1666 }
1667 break;
1668 }
1669
1670 $field_wrap_html .= '</div>';
1671 }
1672 $field_wrap_html .= '<div class="wpf-field-cl"></div></div>';
1673 }
1674 elseif( $template == 'profile' ){
1675 if( !isset($value) || empty($value) || !$value || ( !$is_owner && !in_array( $this->wpforo->current_user_groupid, $canView )) ){ return ''; }
1676 if( $type == 'textarea' ) $value = wpautop(wpforo_kses(stripslashes($value)));
1677 $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) . '">';
1678 if( $type == 'html' ){
1679 $field_wrap_html .= $field_html;
1680 }
1681 else{
1682 if( !$faIcon ) { $faIcon .= 'fa-address-card'; }
1683 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>';}
1684 if( $faIcon ) { $field_wrap_html .= ''; }
1685 if( isset($value) && !empty($value) ){
1686 if( is_array($value) ){
1687 $field_wrap_html .= esc_html(implode( ', ', $value));
1688 }
1689 else{
1690 switch ($args['type']){
1691 case 'url':
1692 $value = sprintf('<a href="%s" target="_blank">%s</a>', $value, $value);
1693 break;
1694 case 'email':
1695 $value = sprintf('<a href="mailto:%s">%s</a>', $value, $value);
1696 break;
1697 case 'phone':
1698 $value = sprintf('<a href="tel:%s">%s</a>', $value, $value);
1699 break;
1700 case 'file':
1701 if( !empty($value) ){
1702 $wp_upload_dir = wp_upload_dir();
1703 $value = $wp_upload_dir['baseurl'] . "/" . trim($value, '/');
1704 $value = sprintf('<a href="%s" target="_blank">%s</a>', $value, basename($value));
1705 }
1706 break;
1707 }
1708
1709 switch ($args['name']){
1710 case 'skype':
1711 $value = sprintf('<a href="skype:%s?userinfo">%s</a>', $value, $value);
1712 break;
1713 case 'location':
1714 $value = sprintf('<a href="//maps.google.com/?q=%s" target="_blank">%s</a>', $value, $value);
1715 break;
1716 }
1717
1718
1719 $field_wrap_html .= '<div class="wpf-field-wrap">';
1720 $field_wrap_html .= $value;
1721 $field_wrap_html .= '</div>';
1722 }
1723 }
1724 }
1725 $field_wrap_html .= '<div class="wpf-field-cl"></div></div>';
1726 }
1727 elseif( $template == 'members' ){
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 if( $type == 'html' ){
1730 $field_wrap_html .= $field_html;
1731 }
1732 else{
1733 if ( $label || $description ) {
1734 $field_wrap_html .= '<div class="wpf-label-wrap">';
1735 if ($label){ $field_wrap_html .= '<p class="wpf-label wpfcl-1">' . stripslashes($label) . $rIcon . '</p>'; }
1736 if ($description){ $field_wrap_html .= '<div class="wpf-desc wpfcl-2">' . $description . '</div>'; }
1737 $field_wrap_html .= '</div>';
1738 }
1739 $field_wrap_html .= '<div class="wpf-field-wrap">';
1740 if($faIcon){
1741 $field_wrap_html .= '<i class="fa ' . esc_attr($faIcon) . ' wpf-field-icon"></i>';
1742 }
1743 $field_wrap_html .= $field_html;
1744 $field_wrap_html .= '</div>';
1745 }
1746 $field_wrap_html .= '<div class="wpf-field-cl"></div></div>';
1747 }
1748 else{
1749 $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) . '">';
1750 $field_wrap_html .= '<div class="wpf-field-wrap">' . $field_html . '<div class="wpf-field-cl"></div></div>';
1751 $field_wrap_html .= '<div class="wpf-field-cl"></div></div>';
1752 }
1753 return $field_wrap_html;
1754 }
1755
1756
1757 public function form_fields( $fields ){
1758 if(empty($fields)) return '';
1759 $html = '';
1760 foreach ($fields as $row_key => $row){
1761 $rowClasses = "row-$row_key " . apply_filters('wpforo_row_classes', '', $row_key);
1762 $html .= '<div class="wpf-tr ' . esc_attr( $rowClasses ) . '">';
1763 foreach ( $row as $col_key => $col ){
1764 $colClasses = "row_$row_key-col_$col_key " . apply_filters('wpforo_col_classes', '', $row_key, $col_key);
1765 $html .= '<div class="wpf-td wpfw-' . count($row) . ' ' . esc_attr( $colClasses ) . '">';
1766 foreach ( $col as $field ){
1767 if( !empty($field) ) $html .= $this->field( $field );
1768 }
1769 $html .= '</div>';
1770 }
1771 $html .= '<div class="wpf-cl"></div></div>';
1772 }
1773
1774 return $html;
1775 }
1776
1777 }