-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathshortcode.php
More file actions
116 lines (96 loc) · 3.23 KB
/
Copy pathshortcode.php
File metadata and controls
116 lines (96 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
class PP_Tabs_Shortcode {
function __construct() {
add_shortcode( 'pp-tabs', array( $this, 'output_field' ) );
}
function output_field( $atts ) {
$a = shortcode_atts( array(
'field' => '',
'label' => '0',
), $atts );
if ( strtolower( $a['field'] ) == "id" ) {
return um_profile_id();
}
um_fetch_user( um_profile_id() );
$key = $a['field'];
$showlabel = $a['label'];
if ( um_user( $key ) ) {
$output = null;
$data = UM()->fields()->get_field( $key );
extract( $data );
if ( ! isset( $data['type'] ) ) {
return;
}
if ( isset( $data['in_group'] ) && $data['in_group'] != '' && $rule != 'group' ) {
return;
}
if ( in_array( $type, array( 'block', 'shortcode', 'spacing', 'divider', 'group' ) ) ) {
} else {
if ( ! UM()->fields()->field_value( $key, $default, $data ) ) {
return;
}
}
if ( ! um_can_view_field( $data ) ) {
return;
}
if ( ! um_field_conditions_are_met( $data ) ) {
return;
}
switch ( $type ) {
/* Default */
default:
if ( $showlabel == '1' ) {
$output .= UM()->fields()->field_label( $label, $key, $data );
}
$res = stripslashes( UM()->fields()->field_value( $key, $default, $data ) );
$output .= $res;
break;
/* HTML */
case 'block':
$output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">
<div class="um-field-block">' . $content . '</div>
</div>';
break;
/* Shortcode */
case 'shortcode':
$content = str_replace( '{profile_id}', um_profile_id(), $content );
$output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">
<div class="um-field-shortcode">' . do_shortcode( $content ) . '</div>
</div>';
break;
/* Gap/Space */
case 'spacing':
$output .= '<div class="um-field um-field-spacing' . $classes . '"' . $conditional . ' style="height: ' . $spacing . '"></div>';
break;
/* A line divider */
case 'divider':
$output .= '<div class="um-field um-field-divider' . $classes . '"' . $conditional . ' style="border-bottom: ' . $borderwidth . 'px ' . $borderstyle . ' ' . $bordercolor . '">';
if ( $divider_text ) {
$output .= '<div class="um-field-divider-text"><span>' . $divider_text . '</span></div>';
}
$output .= '</div>';
break;
/* Rating */
case 'rating':
$output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
if ( isset( $data['label'] ) ) {
$output .= UM()->fields()->field_label( $label, $key, $data );
}
$output .= '<div class="um-field-area">';
$output .= '<div class="um-field-value">
<div class="um-rating-readonly um-raty" id="' . $key . '" data-key="' . $key . '" data-number="' . $data['number'] . '" data-score="' . UM()->fields()->field_value( $key, $default, $data ) . '"></div>
</div>';
$output .= '</div>';
$output .= '</div>';
break;
}
// Custom filter for field output
if ( isset( UM()->fields()->set_mode ) ) {
$output = apply_filters( "um_{$key}_form_show_field", $output, UM()->fields()->set_mode );
}
return $output;
} else {
return '';
}
}
}