Skip to content

Commit adf3dd4

Browse files
committed
Merge branch 'dev'
2 parents 1547164 + 5aa1085 commit adf3dd4

File tree

4 files changed

+58
-20
lines changed

4 files changed

+58
-20
lines changed

pmpro-advanced-levels-shortcode.php

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,51 @@ function pmproal_getLevelLandingPage($level_id) {
6363
return $posts[0];
6464
}
6565

66+
/**
67+
* Function for allowed HTML tags in various templates
68+
*
69+
* @since TBD
70+
* @return array $allowed_html The allowed HTML to be used for wp_kses escaping.
71+
*/
72+
function pmproal_allowed_html() {
73+
$allowed_html = array (
74+
'a' => array (
75+
'class' => array(),
76+
'href' => array(),
77+
'target' => array(),
78+
'title' => array(),
79+
),
80+
'p' => array(
81+
'class' => array(),
82+
),
83+
'b' => array(
84+
'class' => array(),
85+
),
86+
'em' => array(
87+
'class' => array(),
88+
),
89+
'br' => array(),
90+
'strike' => array(),
91+
'strong' => array(),
92+
);
93+
94+
/**
95+
* Filters the allowed HTML tags for the Advanced Levels Shortcode.
96+
* @param array $allowed_html The allowed html elements for the Advanced Levels Shortcode escaping where wp_kses is used (like in compared elements etc.)
97+
* @since TBD
98+
*/
99+
return apply_filters( 'pmproal_allowed_html', $allowed_html );
100+
}
101+
66102
/*
67103
Function to add links to the plugin row meta
68104
*/
69105
function pmpro_advanced_levels_plugin_row_meta($links, $file) {
70106
if(strpos($file, 'pmpro-advanced-levels-shortcode.php') !== false)
71107
{
72108
$new_links = array(
73-
'<a href="' . esc_url('http://www.paidmembershipspro.com/add-ons/plus-add-ons/pmpro-advanced-levels-shortcode/') . '" title="' . esc_attr( __( 'View Documentation', 'pmpro-advanced-levels-shortcode' ) ) . '">' . esc_html__( 'Docs', 'pmpro-advanced-levels-shortcode' ) . '</a>',
74-
'<a href="' . esc_url('http://paidmembershipspro.com/support/') . '" title="' . esc_attr( __( 'Visit Customer Support Forum', 'pmpro-advanced-levels-shortcode' ) ) . '">' . esc_html__( 'Support', 'pmpro-advanced-levels-shortcode' ) . '</a>',
109+
'<a href="' . esc_url('http://www.paidmembershipspro.com/add-ons/plus-add-ons/pmpro-advanced-levels-shortcode/') . '" title="' . esc_attr__( 'View Documentation', 'pmpro-advanced-levels-shortcode' ) . '">' . esc_html__( 'Docs', 'pmpro-advanced-levels-shortcode' ) . '</a>',
110+
'<a href="' . esc_url('http://paidmembershipspro.com/support/') . '" title="' . esc_attr__( 'Visit Customer Support Forum', 'pmpro-advanced-levels-shortcode' ) . '">' . esc_html__( 'Support', 'pmpro-advanced-levels-shortcode' ) . '</a>',
75111
);
76112
$links = array_merge($links, $new_links);
77113
}

templates/levels-compare_table.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
{
1515
?>
1616
<th class="<?php if( pmpro_hasMembershipLevel( $level->id ) ) { echo 'pmpro_level-current '; } if(!empty($level) && $highlight == $level->id) { echo 'pmpro_level-highlight '; } ?>">
17-
<h2><?php echo esc_html( $level->name ); ?></h2>
17+
<h2><?php echo wp_kses( $level->name, pmproal_allowed_html() ); ?></h2>
1818
</th>
1919
<?php
2020
}
@@ -69,7 +69,7 @@
6969
if(empty($level_expiration))
7070
esc_html_e('Membership never expires.', 'pmpro-advanced-levels-shortcode');
7171
else
72-
echo esc_html( $level_expiration );
72+
echo wp_kses( $level_expiration, pmproal_allowed_html() );
7373
?>
7474
</th>
7575
<?php
@@ -137,8 +137,7 @@
137137
</tr>
138138
</thead>
139139
<tbody>
140-
<?php if(!empty($compareitems))
141-
{
140+
<?php if(!empty($compareitems)) {
142141
foreach($compareitems as $compareitem)
143142
{
144143
?>
@@ -159,9 +158,12 @@
159158
?>
160159
<td class="<?php if( ! empty( $level->id ) && pmpro_hasMembershipLevel( $level->id ) ) { echo 'pmpro_level-current '; } if(!empty($level) && $highlight == $level->id) { echo 'pmpro_level-highlight '; } ?>">
161160
<?php
162-
if($compareitem_value == '1') { echo '<span class="pmpro_level-compare-true"></span>'; }
163-
elseif($compareitem_value == '0') { echo '<span class="pmpro_level-compare-false"></span>'; }
164-
else { echo esc_html( $compareitem_value ); }
161+
162+
if( $compareitem_value == '1' ) {
163+
echo '<span class="pmpro_level-compare-true"></span>';
164+
} elseif( $compareitem_value == '0' ) {
165+
echo '<span class="pmpro_level-compare-false"></span>';
166+
} else { echo wp_kses( $compareitem_value, pmproal_allowed_html() ); }
165167
?>
166168
</td>
167169
<?php
@@ -245,7 +247,7 @@
245247
if(empty($level_expiration))
246248
esc_html_e('Membership never expires.', 'pmpro');
247249
else
248-
echo esc_html( $level_expiration );
250+
echo wp_kses( $level_expiration, pmproal_allowed_html() );
249251
?>
250252
</td>
251253
<?php
@@ -382,12 +384,12 @@
382384
{
383385
if($compareitem_values[$count] == '1')
384386
{
385-
echo ' <strong>' . esc_html( $compareitem_values[0] ) . '</strong>';
387+
echo ' <strong>' . wp_kses( $compareitem_values[0], pmproal_allowed_html() ) . '</strong>';
386388
}
387389
else
388390
{
389-
echo ' <strong>' . esc_html( $compareitem_values[0] ) . '</strong>: ';
390-
echo esc_html( $compareitem_values[$count] );
391+
echo ' <strong>' . wp_kses( $compareitem_values[0], pmproal_allowed_html() ) . '</strong>: ';
392+
echo wp_kses( $compareitem_values[$count], pmproal_allowed_html() );
391393
}
392394
echo '<br />';
393395
}
@@ -467,7 +469,7 @@
467469
if(empty($level_expiration))
468470
esc_html_e('Membership Never Expires.', 'pmpro-advanced-levels-shortcode');
469471
else
470-
echo esc_html( $level_expiration );
472+
echo wp_kses( $level_expiration, pmproal_allowed_html() );
471473
if($template === "bootstrap")
472474
echo '</span>';
473475
echo '</p>';

templates/levels-div.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
?>
114114
<?php if(!empty($description)) { ?>
115115
<li class="description">
116-
<?php echo esc_html( $level->description ); ?>
116+
<?php echo wp_kses( $level->description, pmproal_allowed_html() ); ?>
117117
</li>
118118
<?php } ?>
119119
<?php
@@ -124,7 +124,7 @@
124124
if(empty($level_expiration))
125125
esc_html_e('Membership Never Expires.', 'pmpro-advanced-levels-shortcode');
126126
else
127-
echo esc_html( $level_expiration );
127+
echo wp_kses( $level_expiration, pmproal_allowed_html() );
128128
echo '</li>';
129129
}
130130
?>
@@ -320,7 +320,7 @@
320320
if(empty($level_expiration))
321321
esc_html_e('Membership Never Expires.', 'pmpro-advanced-levels-shortcode');
322322
else
323-
echo esc_html( $level_expiration );
323+
echo wp_kses( $level_expiration, pmproal_allowed_html() );
324324
if($template === "bootstrap")
325325
echo '</span>';
326326
}
@@ -425,7 +425,7 @@
425425
if(empty($level_expiration))
426426
esc_html_e('Membership Never Expires.', 'pmpro-advanced-levels-shortcode');
427427
else
428-
echo esc_html( $level_expiration );
428+
echo wp_kses( $level_expiration, pmproal_allowed_html() );
429429
echo '</footer>';
430430
}
431431
?>

templates/levels-table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<tr id="pmpro_level-<?php echo esc_attr( $level->id ); ?>" class="<?php if($current_level) { echo 'pmpro_level-current '; } if($highlight == $level->id) { echo 'pmpro_level-highlight '; } ?>">
4040
<?php do_action('pmproal_extra_cols_before_body', $level->id, $template); ?>
4141
<td>
42-
<h2><?php echo esc_html( $level->name ); ?></h2>
42+
<h2><?php echo wp_kses( $level->name, pmproal_allowed_html() ); ?></h2>
4343
<?php if(!empty($description)) { echo wp_kses_post( wpautop($level->description) ); } ?>
4444
</td>
4545
<?php if(!empty($show_price)) { ?>
@@ -62,7 +62,7 @@
6262
if(empty($level_expiration))
6363
esc_html_e('Membership Never Expires.', 'pmpro-advanced-levels-shortcode');
6464
else
65-
echo esc_html( $level_expiration );
65+
echo wp_kses( $level_expiration, pmproal_allowed_html() );
6666
?>
6767
</td>
6868
<?php

0 commit comments

Comments
 (0)