| 1 |
<?php |
| 2 |
|
| 3 |
defined( 'ABSPATH' ) or exit; |
| 4 |
|
| 5 |
/** @var \Boxzilla\Box $box */ |
| 6 |
/** @var array $opts */ |
| 7 |
/** @var array $global_opts */ |
| 8 |
|
| 9 |
/** @var array $rule_options */ |
| 10 |
$rule_options = array( |
| 11 |
'everywhere' => __( 'everywhere', 'boxzilla' ), |
| 12 |
'is_page' => __( 'if page', 'boxzilla' ), |
| 13 |
'is_single' => __( 'if post', 'boxzilla' ), |
| 14 |
'is_post_with_tag' => __( 'if post tag', 'boxzilla' ), |
| 15 |
'is_post_in_category' => __( 'if post category', 'boxzilla' ), |
| 16 |
'is_post_type' => __( 'if post type', 'boxzilla' ), |
| 17 |
'is_url' => __( 'if URL', 'boxzilla' ), |
| 18 |
'is_referer' => __( 'if referer', 'boxzilla' ), |
| 19 |
'is_user_logged_in' => __( 'if user', 'boxzilla' ), |
| 20 |
); |
| 21 |
|
| 22 |
/** |
| 23 |
* @ignore |
| 24 |
*/ |
| 25 |
$rule_options = apply_filters( 'boxzilla_rules_options', $rule_options ); |
| 26 |
|
| 27 |
?> |
| 28 |
<table class="form-table"> |
| 29 |
<?php |
| 30 |
|
| 31 |
/** |
| 32 |
* @ignore |
| 33 |
*/ |
| 34 |
do_action( 'boxzilla_before_box_option_controls', $box, $opts ); |
| 35 |
|
| 36 |
?> |
| 37 |
<tr> |
| 38 |
<th><?php _e( 'Load this box if', 'boxzilla' ); ?></th> |
| 39 |
<td> |
| 40 |
<label> |
| 41 |
<?php _e( 'Request matches', 'boxzilla' ); ?> |
| 42 |
<select name="boxzilla_box[rules_comparision]" id="boxzilla-rule-comparison"> |
| 43 |
<option value="any" <?php selected( $opts['rules_comparision'], 'any' ); ?>><?php _e( 'any', 'boxzilla' ); ?></option> |
| 44 |
<option value="all" <?php selected( $opts['rules_comparision'], 'all' ); ?>><?php _e( 'all', 'boxzilla' ); ?></option> |
| 45 |
</select> |
| 46 |
<?php _e( 'of the following conditions.', 'boxzilla' ); ?> |
| 47 |
</label> |
| 48 |
</td> |
| 49 |
</tr> |
| 50 |
<tbody id="boxzilla-box-rules"> |
| 51 |
<?php |
| 52 |
$key = 0; |
| 53 |
foreach ( $opts['rules'] as $rule ) { |
| 54 |
// skip invalid looking rules |
| 55 |
if ( ! array_key_exists( 'condition', $rule ) ) { |
| 56 |
continue; |
| 57 |
} |
| 58 |
|
| 59 |
// output row showing "and" or "or" between rules |
| 60 |
if ( $key > 0 ) { |
| 61 |
$or = __( 'or', 'boxzilla' ); |
| 62 |
$and = __( 'and', 'boxzilla' ); |
| 63 |
$text = $opts['rules_comparision'] === 'any' ? $or : $and; |
| 64 |
|
| 65 |
echo '<tr>'; |
| 66 |
echo '<th class="boxzilla-no-vpadding"></th>'; |
| 67 |
echo '<td class="boxzilla-no-vpadding"><span class="boxzilla-andor boxzilla-muted">' . $text . '</span></td>'; |
| 68 |
echo '</tr>'; |
| 69 |
} |
| 70 |
?> |
| 71 |
<tr valign="top" class="boxzilla-rule-row boxzilla-rule-row-<?php echo $key; ?>"> |
| 72 |
<th style="text-align: right; font-weight: normal;"> |
| 73 |
<span class="boxzilla-close boxzilla-remove-rule" title="<?php esc_attr_e( 'Remove rule', 'boxzilla' ); ?>"><span class="dashicons dashicons-dismiss"></span></span> |
| 74 |
</th> |
| 75 |
<td> |
| 76 |
<select class="boxzilla-rule-condition" name="boxzilla_box[rules][<?php echo $key; ?>][condition]"> |
| 77 |
<?php |
| 78 |
foreach ( $rule_options as $value => $label ) { |
| 79 |
printf( '<option value="%s" %s>%s</option>', $value, selected( $rule['condition'], $value ), $label ); |
| 80 |
} |
| 81 |
?> |
| 82 |
</select> |
| 83 |
|
| 84 |
<select class="boxzilla-rule-qualifier" name="boxzilla_box[rules][<?php echo $key; ?>][qualifier]" style="min-width: 135px;"> |
| 85 |
<option value="1" <?php selected( ! isset( $rule['qualifier'] ) || $rule['qualifier'] ); ?>><?php _e( 'is', 'boxzilla' ); ?></option> |
| 86 |
<option value="0" <?php selected( isset( $rule['qualifier'] ) && ! $rule['qualifier'] ); ?>><?php _e( 'is not', 'boxzilla' ); ?></option> |
| 87 |
<option value="contains" <?php selected( isset( $rule['qualifier'] ) && $rule['qualifier'] === 'contains' ); ?> style="display: none;"><?php _e( 'contains', 'boxzilla' ); ?> |
| 88 |
<option value="not_contains" <?php selected( isset( $rule['qualifier'] ) && $rule['qualifier'] === 'not_contains' ); ?> style="display: none;"><?php _e( 'does not contain', 'boxzilla' ); ?></option> |
| 89 |
</select> |
| 90 |
|
| 91 |
<input class="boxzilla-rule-value regular-text" name="boxzilla_box[rules][<?php echo $key; ?>][value]" type="text" value="<?php echo esc_attr( $rule['value'] ); ?>" placeholder="<?php _e( 'Leave empty for any or enter (comma-separated) names or ID\'s', 'boxzilla' ); ?>" style="<?php echo in_array( $rule['condition'], array( '', 'everywhere' ), true ) ? 'display: none;' : ''; ?>" /> |
| 92 |
</td> |
| 93 |
</tr> |
| 94 |
<?php |
| 95 |
$key++; |
| 96 |
} |
| 97 |
?> |
| 98 |
</tbody> |
| 99 |
<tr> |
| 100 |
<th></th> |
| 101 |
<td><button type="button" class="button boxzilla-add-rule"><?php _e( 'Add another rule', 'boxzilla' ); ?></button></td> |
| 102 |
</tr> |
| 103 |
<tr valign="top"> |
| 104 |
<th><label for="boxzilla_position"><?php _e( 'Box Position', 'boxzilla' ); ?></label></th> |
| 105 |
<td> |
| 106 |
<table class="window-positions"> |
| 107 |
<tr> |
| 108 |
<td> |
| 109 |
<?php |
| 110 |
$value = 'top-left'; |
| 111 |
$label = __( 'Top Left', 'boxzilla' ); |
| 112 |
printf( '<label><input type="radio" name="boxzilla_box[css][position]" value="%s" %s> %s</label>', $value, checked( $opts['css']['position'], $value, false ), $label ); |
| 113 |
?> |
| 114 |
</td> |
| 115 |
<td></td> |
| 116 |
<td> |
| 117 |
<?php |
| 118 |
$value = 'top-right'; |
| 119 |
$label = __( 'Top Right', 'boxzilla' ); |
| 120 |
printf( '<label><input type="radio" name="boxzilla_box[css][position]" value="%s" %s> %s</label>', $value, checked( $opts['css']['position'], $value, false ), $label ); |
| 121 |
?> |
| 122 |
</td> |
| 123 |
</tr> |
| 124 |
<tr> |
| 125 |
<td></td> |
| 126 |
<td> |
| 127 |
<?php |
| 128 |
$value = 'center'; |
| 129 |
$label = __( 'Center', 'boxzilla' ); |
| 130 |
printf( '<label><input type="radio" name="boxzilla_box[css][position]" value="%s" %s> %s</label>', $value, checked( $opts['css']['position'], $value, false ), $label ); |
| 131 |
?> |
| 132 |
</td> |
| 133 |
<td></td> |
| 134 |
</tr> |
| 135 |
<tr> |
| 136 |
<td> |
| 137 |
<?php |
| 138 |
$value = 'bottom-left'; |
| 139 |
$label = __( 'Bottom Left', 'boxzilla' ); |
| 140 |
printf( '<label><input type="radio" name="boxzilla_box[css][position]" value="%s" %s> %s</label>', $value, checked( $opts['css']['position'], $value, false ), $label ); |
| 141 |
?> |
| 142 |
</td> |
| 143 |
<td></td> |
| 144 |
<td> |
| 145 |
<?php |
| 146 |
$value = 'bottom-right'; |
| 147 |
$label = __( 'Bottom Right', 'boxzilla' ); |
| 148 |
printf( '<label><input type="radio" name="boxzilla_box[css][position]" value="%s" %s> %s</label>', $value, checked( $opts['css']['position'], $value, false ), $label ); |
| 149 |
?> |
| 150 |
</td> |
| 151 |
</tr> |
| 152 |
</table> |
| 153 |
</td> |
| 154 |
</tr> |
| 155 |
<tr valign="top"> |
| 156 |
<th><label><?php _e( 'Animation', 'boxzilla' ); ?></label></th> |
| 157 |
<td> |
| 158 |
<label><input type="radio" name="boxzilla_box[animation]" value="fade" <?php checked( $opts['animation'], 'fade' ); ?> /> <?php _e( 'Fade In', 'boxzilla' ); ?></label> |
| 159 |
<label><input type="radio" name="boxzilla_box[animation]" value="slide" <?php checked( $opts['animation'], 'slide' ); ?> /> <?php _e( 'Slide In', 'boxzilla' ); ?></label> |
| 160 |
<p class="help"><?php _e( 'Which animation type should be used to show the box when triggered?', 'boxzilla' ); ?></p> |
| 161 |
</td> |
| 162 |
</tr> |
| 163 |
<tr valign="top"> |
| 164 |
<th><label for="boxzilla_trigger"><?php _e( 'Auto-show box?', 'boxzilla' ); ?></label></th> |
| 165 |
<td> |
| 166 |
<label><input type="radio" class="boxzilla-auto-show-trigger" name="boxzilla_box[trigger]" value="" <?php checked( $opts['trigger'], '' ); ?> /> <?php _e( 'Never', 'boxzilla' ); ?></label><br /> |
| 167 |
<label><input type="radio" class="boxzilla-auto-show-trigger" name="boxzilla_box[trigger]" value="time_on_page" <?php checked( $opts['trigger'], 'time_on_page' ); ?> /> <?php printf( __( 'Yes, after %s seconds on the page.', 'boxzilla' ), '<input type="number" name="boxzilla_box[trigger_time_on_page]" min="0" value="' . esc_attr( $opts['trigger_time_on_page'] ) . '" />' ); ?></label><br /> |
| 168 |
<label><input type="radio" class="boxzilla-auto-show-trigger" name="boxzilla_box[trigger]" value="percentage" <?php checked( $opts['trigger'], 'percentage' ); ?> /> <?php printf( __( 'Yes, when at %s of page height', 'boxzilla' ), '<input type="number" name="boxzilla_box[trigger_percentage]" min="0" max="100" value="' . esc_attr( $opts['trigger_percentage'] ) . '" />%' ); ?></label><br /> |
| 169 |
<label><input type="radio" class="boxzilla-auto-show-trigger" name="boxzilla_box[trigger]" value="element" <?php checked( $opts['trigger'], 'element' ); ?> /> <?php printf( __( 'Yes, when at element %s', 'boxzilla' ), '<input type="text" name="boxzilla_box[trigger_element]" value="' . esc_attr( $opts['trigger_element'] ) . '" placeholder="' . __( 'Example: #comments', 'boxzilla' ) . '" />' ); ?></label><br /> |
| 170 |
<?php do_action( 'boxzilla_output_auto_show_trigger_options', $opts ); ?> |
| 171 |
</td> |
| 172 |
</tr> |
| 173 |
<tbody class="boxzilla-trigger-options" style="display: <?php echo ( $opts['trigger'] === '' ) ? 'none' : 'table-row-group'; ?>;"> |
| 174 |
<tr valign="top"> |
| 175 |
<th><label for="boxzilla_cookie"><?php _e( 'Cookie expiration', 'boxzilla' ); ?></label></th> |
| 176 |
<td> |
| 177 |
<div style="display: inline-block; margin-right: 20px;"> |
| 178 |
<label for="boxzilla_cookie_triggered" style="font-weight: bold; display: block;"><?php esc_html_e( 'Triggered', 'boxzilla' ); ?></label> |
| 179 |
<input type="number" id="boxzilla_cookie_triggered" name="boxzilla_box[cookie][triggered]" min="0" step="1" value="<?php echo esc_attr( $opts['cookie']['triggered'] ); ?>" /> |
| 180 |
<small><?php _e( 'hours', 'boxzilla' ); ?></small> |
| 181 |
</div> |
| 182 |
<div style="display: inline-block;"> |
| 183 |
<label for="boxzilla_cookie_dismissed" style="font-weight: bold; display: block;"><?php esc_html_e( 'Dismissed', 'boxzilla' ); ?></label> |
| 184 |
<input type="number" id="boxzilla_cookie_dismissed" name="boxzilla_box[cookie][dismissed]" min="0" step="1" value="<?php echo esc_attr( $opts['cookie']['dismissed'] ); ?>" /> |
| 185 |
<small><?php _e( 'hours', 'boxzilla' ); ?></small> |
| 186 |
</div> |
| 187 |
<br /> |
| 188 |
|
| 189 |
<p class="help"><?php _e( 'After this box is triggered or dismissed, how many hours should it stay hidden?', 'boxzilla' ); ?></p> |
| 190 |
</td> |
| 191 |
</tr> |
| 192 |
<tr valign="top"> |
| 193 |
<th><label><?php _e( 'Screen width', 'boxzilla' ); ?></label></th> |
| 194 |
<td> |
| 195 |
<?php |
| 196 |
$condition_type = $opts['screen_size_condition']['condition']; |
| 197 |
$condition_value = $opts['screen_size_condition']['value']; |
| 198 |
$condition_select = '<select name="boxzilla_box[screen_size_condition][condition]"><option value="larger" ' . ( $condition_type === 'larger' ? 'selected' : '' ) . '>' . __( 'larger', 'boxzilla' ) . '</option><option value="smaller" ' . ( $condition_type === 'smaller' ? 'selected' : '' ) . '>' . __( 'smaller', 'boxzilla' ) . '</option></select>'; |
| 199 |
?> |
| 200 |
<p><?php printf( __( 'Only show on screens %1$s than %2$s.', 'boxzilla' ), $condition_select, '<input type="number" min="0" name="boxzilla_box[screen_size_condition][value]" value="' . esc_attr( $condition_value ) . '" style="max-width: 70px;" />px' ); ?></p> |
| 201 |
<p class="help"><?php _e( 'Leave empty if you want to show the box on all screen sizes.', 'boxzilla' ); ?></p> |
| 202 |
</td> |
| 203 |
|
| 204 |
</tr> |
| 205 |
<tr valign="top"> |
| 206 |
<th><label for="boxzilla_auto_hide"><?php _e( 'Auto-hide?', 'boxzilla' ); ?></label></th> |
| 207 |
<td> |
| 208 |
<label><input type="radio" name="boxzilla_box[auto_hide]" value="1" <?php checked( $opts['auto_hide'], 1 ); ?> /> <?php _e( 'Yes', 'boxzilla' ); ?></label> |
| 209 |
<label><input type="radio" name="boxzilla_box[auto_hide]" value="0" <?php checked( $opts['auto_hide'], 0 ); ?> /> <?php _e( 'No', 'boxzilla' ); ?></label> |
| 210 |
<p class="help"><?php _e( 'Hide box again when visitors scroll back up?', 'boxzilla' ); ?></p> |
| 211 |
</td> |
| 212 |
</tr> |
| 213 |
<tr valign="top"> |
| 214 |
<th><label for="boxzilla_closable"><?php _e( 'Show close icon?', 'boxzilla' ); ?></label></th> |
| 215 |
<td> |
| 216 |
<label><input type="radio" id="boxzilla_closable_1" name="boxzilla_box[show_close_icon]" value="1" <?php checked( $opts['show_close_icon'], 1 ); ?> /> <?php _e( 'Yes', 'boxzilla' ); ?></label> |
| 217 |
<label><input type="radio" id="boxzilla_closable_0" name="boxzilla_box[show_close_icon]" value="0" <?php checked( $opts['show_close_icon'], 0 ); ?> /> <?php _e( 'No', 'boxzilla' ); ?></label> |
| 218 |
<p class="help"> |
| 219 |
<?php _e( 'If you decide to hide the close icon, make sure to offer an alternative way to close the box.', 'boxzilla' ); ?><br /> |
| 220 |
<?php _e( 'Example: ', 'boxzilla' ); ?> <code>[boxzilla-close]No, thanks![/boxzilla-close]</code> |
| 221 |
</p> |
| 222 |
</td> |
| 223 |
</tr> |
| 224 |
<tr valign="top"> |
| 225 |
<th><label for="boxzilla_test_mode"><?php _e( 'Enable test mode?', 'boxzilla' ); ?></label></th> |
| 226 |
<td> |
| 227 |
<label><input type="radio" id="boxzilla_test_mode_1" name="boxzilla_global_settings[test_mode]" value="1" <?php checked( $global_opts['test_mode'], 1 ); ?> /> <?php _e( 'Yes', 'boxzilla' ); ?></label> |
| 228 |
<label><input type="radio" id="boxzilla_test_mode_0" name="boxzilla_global_settings[test_mode]" value="0" <?php checked( $global_opts['test_mode'], 0 ); ?> /> <?php _e( 'No', 'boxzilla' ); ?></label> |
| 229 |
<p class="help"><?php _e( 'If test mode is enabled, all boxes will show up regardless of whether a cookie has been set.', 'boxzilla' ); ?></p> |
| 230 |
</td> |
| 231 |
</tr> |
| 232 |
<?php |
| 233 |
|
| 234 |
/** |
| 235 |
* @ignore |
| 236 |
*/ |
| 237 |
do_action( 'boxzilla_after_box_option_controls', $box, $opts ); |
| 238 |
?> |
| 239 |
</tbody> |
| 240 |
</table> |
| 241 |
|
| 242 |
|
| 243 |
<script type="text/html" id="tmpl-rule-row-template"> |
| 244 |
<tr> |
| 245 |
<th class="boxzilla-no-vpadding"></th> |
| 246 |
<td class="boxzilla-no-vpadding"><span class="boxzilla-andor boxzilla-muted">{{data.andor}}</span></td> |
| 247 |
</tr> |
| 248 |
<tr valign="top" class="boxzilla-rule-row boxzilla-rule-row-{{{data.key}}}"> |
| 249 |
<th style="text-align: right; font-weight: normal;"> |
| 250 |
<span class="boxzilla-close boxzilla-remove-rule" title="<?php esc_attr_e( 'Remove rule', 'boxzilla' ); ?>"><span class="dashicons dashicons-dismiss"></span></span> |
| 251 |
</th> |
| 252 |
<td class="boxzilla-sm"> |
| 253 |
<select class="boxzilla-rule-condition" name="boxzilla_box[rules][{{{data.key}}}][condition]"> |
| 254 |
<?php |
| 255 |
foreach ( $rule_options as $value => $label ) { |
| 256 |
printf( '<option value="%s" %s %s>%s</option>', $value, disabled( $value, '', false ), '', $label ); |
| 257 |
} |
| 258 |
?> |
| 259 |
</select> |
| 260 |
<select class="boxzilla-rule-qualifier" name="boxzilla_box[rules][{{{data.key}}}][qualifier]" style="display: none; min-width: 135px;" > |
| 261 |
<option value="1" selected><?php _e( 'is', 'boxzilla' ); ?></option> |
| 262 |
<option value="0"><?php _e( 'is not', 'boxzilla' ); ?></option> |
| 263 |
<option value="contains" style="display: none;"><?php _e( 'contains', 'boxzilla' ); ?></option> |
| 264 |
<option value="not_contains" style="display: none;"><?php _e( 'does not contain', 'boxzilla' ); ?></option> |
| 265 |
</select> |
| 266 |
|
| 267 |
<input class="boxzilla-rule-value regular-text" name="boxzilla_box[rules][{{{data.key}}}][value]" type="text" value="" placeholder="<?php _e( 'Leave empty for any or enter (comma-separated) names or ID\'s', 'boxzilla' ); ?>" style="display: none;" /> |
| 268 |
</td> |
| 269 |
</tr> |
| 270 |
</script> |
| 271 |
|