| 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 |
'' => __( "Select a condition", 'boxzilla' ), |
| 12 |
'everywhere' => __( 'everywhere', 'boxzilla' ), |
| 13 |
'is_page' => __( 'if page', 'boxzilla' ), |
| 14 |
'is_single' => __( 'if post', 'boxzilla' ), |
| 15 |
'is_post_with_tag' => __( 'if post tag', 'boxzilla' ), |
| 16 |
'is_post_in_category' => __( 'if post category', 'boxzilla' ), |
| 17 |
'is_post_type' => __( 'if post type', 'boxzilla' ), |
| 18 |
'is_url' => __( 'if URL', 'boxzilla' ), |
| 19 |
'is_referer' => __( 'if referer', 'boxzilla' ), |
| 20 |
); |
| 21 |
|
| 22 |
/** |
| 23 |
* @ignore |
| 24 |
*/ |
| 25 |
$rule_options = apply_filters( 'boxzilla_rules_options', $rule_options ); |
| 26 |
|
| 27 |
$box_positions = array( |
| 28 |
'bottom-left' => __( 'Bottom Left', 'boxzilla' ), |
| 29 |
'bottom-right' => __( 'Bottom Right', 'boxzilla' ), |
| 30 |
'center' => __( 'Center', 'boxzilla' ), |
| 31 |
'top-left' => __( 'Top Left', 'boxzilla' ), |
| 32 |
'top-right' => __( 'Top Right', 'boxzilla' ), |
| 33 |
); |
| 34 |
|
| 35 |
?> |
| 36 |
<table class="form-table"> |
| 37 |
<?php |
| 38 |
|
| 39 |
/** |
| 40 |
* @ignore |
| 41 |
*/ |
| 42 |
do_action( 'boxzilla_before_box_option_controls', $box, $opts ); |
| 43 |
|
| 44 |
?> |
| 45 |
<tr> |
| 46 |
<th><?php _e( 'Load this box if', 'boxzilla' ); ?></th> |
| 47 |
<td> |
| 48 |
<label> |
| 49 |
<?php _e( 'Request matches', 'boxzilla' ); ?> |
| 50 |
<select name="boxzilla_box[rules_comparision]"> |
| 51 |
<option value="any" <?php selected( $opts['rules_comparision'], 'any' ); ?>><?php _e( 'any', 'boxzilla' ); ?></option> |
| 52 |
<option value="all" <?php selected( $opts['rules_comparision'], 'all' ); ?>><?php _e( 'all', 'boxzilla' ); ?></option> |
| 53 |
</select> |
| 54 |
<?php _e( 'of the following conditions.', 'boxzilla' ); ?> |
| 55 |
</label> |
| 56 |
</td> |
| 57 |
</tr> |
| 58 |
<tbody id="boxzilla-box-rules"> |
| 59 |
<?php |
| 60 |
$key = 0; |
| 61 |
foreach( $opts['rules'] as $rule ) { if( ! array_key_exists( 'condition', $rule ) ) { continue; } ?> |
| 62 |
<tr valign="top" class="boxzilla-rule-row boxzilla-rule-row-<?php echo $key; ?>"> |
| 63 |
<th style="text-align: right; font-weight: normal;"> |
| 64 |
<span class="boxzilla-close boxzilla-remove-rule"><span class="dashicons dashicons-dismiss"></span></span> |
| 65 |
</th> |
| 66 |
<td> |
| 67 |
<select class="boxzilla-rule-condition" name="boxzilla_box[rules][<?php echo $key; ?>][condition]"> |
| 68 |
<?php foreach( $rule_options as $value => $label ) { |
| 69 |
$readonly = $value == '' ? 'readonly': ''; |
| 70 |
printf( '<option value="%s" %s %s>%s</option>', $value, $readonly, selected( $rule['condition'], $value ), $label ); |
| 71 |
} ?> |
| 72 |
</select> |
| 73 |
|
| 74 |
<select class="boxzilla-rule-qualifier" name="boxzilla_box[rules][<?php echo $key; ?>][qualifier]"> |
| 75 |
<option value="1" <?php selected( ! isset( $rule['qualifier'] ) || $rule['qualifier'] ); ?>><?php _e( 'is', 'boxzilla' ); ?></option> |
| 76 |
<option value="0" <?php selected( isset( $rule['qualifier'] ) && !$rule['qualifier'] ); ?>><?php _e( 'is not', 'boxzilla' ); ?></option> |
| 77 |
</select> |
| 78 |
|
| 79 |
<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 if( in_array( $rule['condition'], array( '', 'everywhere' ) ) ) { echo 'display: none;'; } ?>" /> |
| 80 |
</td> |
| 81 |
</tr> |
| 82 |
<?php $key++; |
| 83 |
} ?> |
| 84 |
</tbody> |
| 85 |
<tr> |
| 86 |
<th></th> |
| 87 |
<td><button type="button" class="button boxzilla-add-rule"><?php _e( 'Add rule', 'boxzilla' ); ?></button></td> |
| 88 |
</tr> |
| 89 |
<tr valign="top"> |
| 90 |
<th><label for="boxzilla_position"><?php _e( 'Box Position', 'boxzilla' ); ?></label></th> |
| 91 |
<td> |
| 92 |
<select id="boxzilla_position" name="boxzilla_box[css][position]"> |
| 93 |
<?php foreach( $box_positions as $value => $label ) { |
| 94 |
printf( '<option value="%s" %s>%s</option>', $value, selected( $opts['css']['position'], $value ), $label ); |
| 95 |
} ?> |
| 96 |
</select> |
| 97 |
</td> |
| 98 |
</tr> |
| 99 |
<tr valign="top"> |
| 100 |
<th><label><?php _e( 'Animation', 'boxzilla' ); ?></label></th> |
| 101 |
<td> |
| 102 |
<label><input type="radio" name="boxzilla_box[animation]" value="fade" <?php checked($opts['animation'], 'fade'); ?> /> <?php _e( 'Fade In', 'boxzilla' ); ?></label> |
| 103 |
<label><input type="radio" name="boxzilla_box[animation]" value="slide" <?php checked($opts['animation'], 'slide'); ?> /> <?php _e( 'Slide In', 'boxzilla' ); ?></label> |
| 104 |
<p class="help"><?php _e( 'Which animation type should be used to show the box when triggered?', 'boxzilla' ); ?></p> |
| 105 |
</td> |
| 106 |
</tr> |
| 107 |
<tr valign="top"> |
| 108 |
<th><label for="boxzilla_trigger"><?php _e( 'Auto-show box?', 'boxzilla' ); ?></label></th> |
| 109 |
<td> |
| 110 |
<label><input type="radio" class="boxzilla-auto-show-trigger" name="boxzilla_box[trigger]" value="" <?php checked( $opts['trigger'], '' ); ?> /> <?php _e( 'Never', 'boxzilla' ); ?></label><br /> |
| 111 |
<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 /> |
| 112 |
<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 /> |
| 113 |
<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 /> |
| 114 |
<?php do_action( 'boxzilla_output_auto_show_trigger_options', $opts ); ?> |
| 115 |
</td> |
| 116 |
</tr> |
| 117 |
<tbody class="boxzilla-trigger-options" style="display: <?php echo ( $opts['trigger'] === '' ) ? 'none' : 'table-row-group'; ?>;"> |
| 118 |
<tr valign="top"> |
| 119 |
<th><label for="boxzilla_cookie"><?php _e( 'Cookie expiration days', 'boxzilla' ); ?></label></th> |
| 120 |
<td> |
| 121 |
<input type="number" id="boxzilla_cookie" name="boxzilla_box[cookie]" min="0" step="1" value="<?php echo esc_attr($opts['cookie']); ?>" /> |
| 122 |
<p class="help"><?php _e( 'After closing the box, how many days should it stay hidden?', 'boxzilla' ); ?></p> |
| 123 |
</td> |
| 124 |
</tr> |
| 125 |
<tr valign="top"> |
| 126 |
<th><label for="boxzilla_hide_on_screen_size"><?php _e( 'Do not auto-show box on small screens?', 'boxzilla' ); ?></label></th> |
| 127 |
<td> |
| 128 |
<p><?php printf( __( 'Do not auto-show on screens smaller than %s.', 'boxzilla' ), '<input type="number" min="0" name="boxzilla_box[hide_on_screen_size]" value="' . esc_attr( $opts['hide_on_screen_size'] ) . '" style="max-width: 70px;" />px' ); ?></p> |
| 129 |
<p class="help"><?php _e( 'Leave empty if you <strong>do</strong> want to auto-show the box on small screens.', 'boxzilla' ); ?></p> |
| 130 |
</td> |
| 131 |
|
| 132 |
</tr> |
| 133 |
<tr valign="top"> |
| 134 |
<th><label for="boxzilla_auto_hide"><?php _e( 'Auto-hide?', 'boxzilla' ); ?></label></th> |
| 135 |
<td> |
| 136 |
<label><input type="radio" name="boxzilla_box[auto_hide]" value="1" <?php checked( $opts['auto_hide'], 1 ); ?> /> <?php _e( 'Yes' ); ?></label> |
| 137 |
<label><input type="radio" name="boxzilla_box[auto_hide]" value="0" <?php checked( $opts['auto_hide'], 0 ); ?> /> <?php _e( 'No' ); ?></label> |
| 138 |
<p class="help"><?php _e( 'Hide box again when visitors scroll back up?', 'boxzilla' ); ?></p> |
| 139 |
</td> |
| 140 |
</tr> |
| 141 |
<tr valign="top"> |
| 142 |
<th><label for="boxzilla_test_mode"><?php _e( 'Enable test mode?', 'boxzilla' ); ?></label></th> |
| 143 |
<td> |
| 144 |
<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' ); ?></label> |
| 145 |
<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' ); ?></label> |
| 146 |
<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> |
| 147 |
</td> |
| 148 |
</tr> |
| 149 |
<?php |
| 150 |
|
| 151 |
/** |
| 152 |
* @ignore |
| 153 |
*/ |
| 154 |
do_action( 'boxzilla_after_box_option_controls', $box, $opts ); ?> |
| 155 |
</tbody> |
| 156 |
</table> |
| 157 |
|
| 158 |
|
| 159 |
<script type="text/html" id="tmpl-rule-row-template"> |
| 160 |
<tr valign="top" class="boxzilla-rule-row boxzilla-rule-row-{{{data.key}}}"> |
| 161 |
<th style="text-align: right; font-weight: normal;"> |
| 162 |
<span class="boxzilla-close boxzilla-remove-rule"><span class="dashicons dashicons-dismiss"></span></span> |
| 163 |
</th> |
| 164 |
<td class="boxzilla-sm"> |
| 165 |
<select class="boxzilla-rule-condition" name="boxzilla_box[rules][{{{data.key}}}][condition]"> |
| 166 |
<?php foreach( $rule_options as $value => $label ) { |
| 167 |
printf( '<option value="%s" %s %s>%s</option>', $value, disabled( $value, '', false ), '', $label ); |
| 168 |
} ?> |
| 169 |
</select> |
| 170 |
<select class="boxzilla-rule-qualifier" name="boxzilla_box[rules][{{{data.key}}}][qualifier]" style="display: none;" > |
| 171 |
<option value="1" selected><?php _e( 'is', 'boxzilla' ); ?></option> |
| 172 |
<option value="0"><?php _e( 'is not', 'boxzilla' ); ?></option> |
| 173 |
</select> |
| 174 |
|
| 175 |
<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;" /> |
| 176 |
</td> |
| 177 |
</tr> |
| 178 |
</script> |