meta-appearance.php
11 years ago
meta-behavior.php
11 years ago
meta-content.php
11 years ago
meta-rules.php
11 years ago
meta-submitdiv.php
11 years ago
network.php
11 years ago
settings.php
11 years ago
settings.php
327 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Display the popup settings page. |
| 4 | */ |
| 5 | |
| 6 | global $shortcode_tags; |
| 7 | |
| 8 | $loading_methods = array(); |
| 9 | |
| 10 | $loading_methods[] = (object) array( |
| 11 | 'id' => 'footer', |
| 12 | 'label' => __( 'Page Footer', PO_LANG ), |
| 13 | 'info' => __( |
| 14 | 'Include PopUp as part of your site\'s HTML (no AJAX call).', |
| 15 | PO_LANG |
| 16 | ), |
| 17 | ); |
| 18 | |
| 19 | $loading_methods[] = (object) array( |
| 20 | 'id' => 'ajax', |
| 21 | 'label' => __( 'WordPress AJAX', PO_LANG ), |
| 22 | 'info' => __( |
| 23 | 'Load PopUp separately from the page via a WordPress AJAX call. ' . |
| 24 | 'This is the best option if you use caching.', |
| 25 | PO_LANG |
| 26 | ), |
| 27 | ); |
| 28 | |
| 29 | $loading_methods[] = (object) array( |
| 30 | 'id' => 'front', |
| 31 | 'label' => __( 'Custom AJAX', PO_LANG ), |
| 32 | 'info' => __( |
| 33 | 'Load PopUp separately from the page via a custom front-end AJAX call.', |
| 34 | PO_LANG |
| 35 | ), |
| 36 | ); |
| 37 | |
| 38 | /** |
| 39 | * Allow addons to register additional loading methods. |
| 40 | * |
| 41 | * @var array |
| 42 | */ |
| 43 | $loading_methods = apply_filters( 'popup-settings-loading-method', $loading_methods ); |
| 44 | |
| 45 | $settings = IncPopupDatabase::get_settings(); |
| 46 | $cur_method = @$settings['loadingmethod']; |
| 47 | |
| 48 | $form_url = remove_query_arg( array( 'message', 'action', '_wpnonce' ) ); |
| 49 | |
| 50 | // Theme compatibility. |
| 51 | $theme_compat = IncPopupAddon_HeaderFooter::check(); |
| 52 | $theme_class = $theme_compat->okay ? 'msg-ok' : 'msg-err'; |
| 53 | $shortcodes = array(); |
| 54 | // Add Admin-Shortcodes to the list. |
| 55 | foreach ( $shortcode_tags as $code => $handler ) { |
| 56 | @$shortcodes[ $code ] .= 'sc-admin '; |
| 57 | } |
| 58 | // Add Front-End Shortcodes to the list. |
| 59 | foreach ( $theme_compat->shortcodes as $code ) { |
| 60 | @$shortcodes[ $code ] .= 'sc-front '; |
| 61 | } |
| 62 | |
| 63 | $rules = IncPopup::get_rules(); |
| 64 | $rule_headers = array( |
| 65 | 'name' => 'Name', |
| 66 | 'desc' => 'Description', |
| 67 | 'rules' => 'Rules', |
| 68 | 'limit' => 'Limit', |
| 69 | ); |
| 70 | $ordered_rules = array(); |
| 71 | |
| 72 | ?> |
| 73 | <div class="wrap nosubsub"> |
| 74 | |
| 75 | <h2><?php _e( 'PopUp Settings', PO_LANG ); ?></h2> |
| 76 | |
| 77 | <div id="poststuff" class="metabox-holder m-settings"> |
| 78 | <form method="post" action="<?php echo esc_url( $form_url ); ?>"> |
| 79 | |
| 80 | <input type="hidden" name="action" value="updatesettings" /> |
| 81 | |
| 82 | <?php wp_nonce_field( 'update-popup-settings' ); ?> |
| 83 | |
| 84 | <div class="wpmui-box static"> |
| 85 | <h3> |
| 86 | <span><?php _e( 'PopUp Loading Method', PO_LANG ); ?></span> |
| 87 | </h3> |
| 88 | |
| 89 | <div class="inside"> |
| 90 | <p><?php _e( |
| 91 | 'Select how you would like to load PopUp.', PO_LANG |
| 92 | ); ?></p> |
| 93 | |
| 94 | <table class="form-table"> |
| 95 | <tbody> |
| 96 | |
| 97 | <?php /* === LOADING METHOD === */ ?> |
| 98 | <tr valign="top"> |
| 99 | <th scope="row"> |
| 100 | <?php _e( 'Load PopUp using', PO_LANG ); ?> |
| 101 | </th> |
| 102 | <td> |
| 103 | <select name="po_option[loadingmethod]" id="loadingmethod"> |
| 104 | <?php foreach ( $loading_methods as $item ) : ?> |
| 105 | <option |
| 106 | value="<?php echo esc_attr( $item->id ); ?>" |
| 107 | <?php selected( $cur_method, $item->id ); ?>> |
| 108 | <?php _e( $item->label, PO_LANG ); ?> |
| 109 | </option> |
| 110 | <?php endforeach; ?> |
| 111 | </select> |
| 112 | |
| 113 | <ul> |
| 114 | <?php foreach ( $loading_methods as $item ) : ?> |
| 115 | <li> |
| 116 | <?php if ( $cur_method == $item->id ) : ?> |
| 117 | <strong><i class="dashicons dashicons-yes" |
| 118 | style="margin-left:-20px"> |
| 119 | </i><?php _e( $item->label, PO_LANG ); ?></strong>: |
| 120 | <?php else : ?> |
| 121 | <?php _e( $item->label, PO_LANG ); ?>: |
| 122 | <?php endif; ?> |
| 123 | <em><?php echo '' . $item->info; ?> |
| 124 | </em></li> |
| 125 | <?php endforeach; ?> |
| 126 | </ul> |
| 127 | </td> |
| 128 | </tr> |
| 129 | </tbody> |
| 130 | </table> |
| 131 | </div> |
| 132 | </div> |
| 133 | |
| 134 | <?php if ( 'footer' == $cur_method ) : ?> |
| 135 | <div class="wpmui-box <?php echo esc_attr( $theme_compat->okay ? 'closed' : '' ); ?>"> |
| 136 | <h3> |
| 137 | <a href="#" class="toggle" title="<?php _e( 'Click to toggle' ); ?>"><br></a> |
| 138 | <span><?php _e( 'Theme compatibility', PO_LANG ); ?></span> |
| 139 | </h3> |
| 140 | |
| 141 | <div class="inside"> |
| 142 | <?php _e( |
| 143 | 'Here you can see if your theme is compatible with the ' . |
| 144 | '"Page Footer" loading method.', PO_LANG |
| 145 | ); ?> |
| 146 | <div class="<?php echo esc_attr( $theme_class ); ?>"> |
| 147 | <?php foreach ( $theme_compat->msg as $row ) { |
| 148 | echo '<p>' . $row . '</p>'; |
| 149 | } ?> |
| 150 | </div> |
| 151 | </div> |
| 152 | </div> |
| 153 | <?php endif; ?> |
| 154 | |
| 155 | <div class="wpmui-box closed"> |
| 156 | <h3> |
| 157 | <a href="#" class="toggle" title="<?php _e( 'Click to toggle' ); ?>"><br></a> |
| 158 | <span><?php _e( 'Supported Shortcodes', PO_LANG ); ?></span> |
| 159 | </h3> |
| 160 | |
| 161 | <div class="inside"> |
| 162 | <?php _e( |
| 163 | 'You can use all your shortcodes inside the PopUp contents, ' . |
| 164 | 'however some Plugins or Themes might provide shortcodes that ' . |
| 165 | 'only work with the loading method "Page Footer".<br /> ' . |
| 166 | 'This list explains which shortcodes can be used with each ' . |
| 167 | 'loading method:', PO_LANG |
| 168 | ); ?> |
| 169 | <?php if ( IncPopup::use_global() ) : ?> |
| 170 | <p><em> |
| 171 | <?php _e( |
| 172 | 'Important notice for shortcodes in <strong>Global ' . |
| 173 | 'PopUps</strong>:<br />' . |
| 174 | 'Shortcodes can be provided by a plugin or theme, so ' . |
| 175 | 'each blog can have a different list of shortcodes. The ' . |
| 176 | 'following list is valid for the current blog only!', PO_LANG |
| 177 | ); ?> |
| 178 | </em></p> |
| 179 | <?php endif; ?> |
| 180 | <table class="widefat tbl-shortcodes load-<?php echo esc_attr( $cur_method ); ?>"> |
| 181 | <thead> |
| 182 | <tr> |
| 183 | <th width="40%"> |
| 184 | <div> |
| 185 | <?php _e( 'Shortcode', PO_LANG ); ?> |
| 186 | </div> |
| 187 | </th> |
| 188 | <th class="flag load-footer"> |
| 189 | <div data-tooltip="<?php _e( 'Loading method \'Page Footer\'', PO_LANG ); ?>"> |
| 190 | <?php _e( 'Page Footer', PO_LANG ); ?> |
| 191 | </div> |
| 192 | </th> |
| 193 | <th class="flag load-ajax load-front"> |
| 194 | <div data-tooltip="<?php _e( 'Loading method \'WordPress AJAX\' and \'Custom AJAX\'', PO_LANG ); ?>"> |
| 195 | <?php _e( 'AJAX', PO_LANG ); ?> |
| 196 | </div> |
| 197 | </th> |
| 198 | <th class="flag"> |
| 199 | <div data-tooltip="<?php _e( 'When opening a PopUp-Preview in the Editor', PO_LANG ); ?>"> |
| 200 | <?php _e( 'Preview', PO_LANG ); ?> |
| 201 | </div> |
| 202 | </th> |
| 203 | </tr> |
| 204 | </thead> |
| 205 | <tbody> |
| 206 | <?php foreach ( $shortcodes as $code => $classes ) : ?> |
| 207 | <tr class="shortcode <?php echo esc_attr( $classes ); ?>"> |
| 208 | <td><code>[<?php echo esc_html( $code ); ?>]</code></td> |
| 209 | <td class="flag sc-front load-footer"><i class="icon dashicons"></i></td> |
| 210 | <td class="flag sc-admin load-ajax load-front"><i class="icon dashicons"></i></td> |
| 211 | <td class="flag sc-admin"><i class="icon dashicons"></i></td> |
| 212 | </tr> |
| 213 | <?php endforeach; ?> |
| 214 | </tbody> |
| 215 | </table> |
| 216 | </div> |
| 217 | </div> |
| 218 | |
| 219 | <p class="submit"> |
| 220 | <button class="button-primary"> |
| 221 | <?php _e( 'Save All Changes', PO_LANG ) ?> |
| 222 | </button> |
| 223 | </p> |
| 224 | |
| 225 | <h2><?php _e( 'Available Conditions', PO_LANG ); ?></h2> |
| 226 | |
| 227 | <?php /* === ACTIVE RULES === */ ?> |
| 228 | <table class="widefat tbl-addons"> |
| 229 | <?php foreach ( array( 'thead', 'tfoot' ) as $tag ) : ?> |
| 230 | <<?php echo esc_attr( $tag ); ?>> |
| 231 | <tr> |
| 232 | <th class="manage-column column-cb check-column" id="cb" scope="col"> |
| 233 | <input type="checkbox" /> |
| 234 | </th> |
| 235 | <th class="manage-column column-name" scope="col"> |
| 236 | <?php _e( 'Name', PO_LANG ); ?> |
| 237 | </th> |
| 238 | <th class="manage-column column-items" scope="col"> |
| 239 | <?php _e( 'Activated Rules', PO_LANG ); ?> |
| 240 | </th> |
| 241 | </tr> |
| 242 | </<?php echo esc_attr( $tag ); ?>> |
| 243 | <?php endforeach; ?> |
| 244 | |
| 245 | <?php foreach ( $rules as $rule ) { |
| 246 | $data = get_file_data( |
| 247 | PO_INC_DIR . 'rules/' . $rule, |
| 248 | $rule_headers, |
| 249 | 'popup-rule' |
| 250 | ); |
| 251 | $is_active = ( in_array( $rule, $settings['rules'] ) ); |
| 252 | if ( empty( $data['name'] ) ) { continue; } |
| 253 | $data['limit'] = explode( ',', @$data['limit'] ); |
| 254 | $data['limit'] = array_map( 'trim', $data['limit'] ); |
| 255 | |
| 256 | $name = __( trim( $data['name'] ), PO_LANG ); |
| 257 | |
| 258 | $ordered_rules[ $name ] = $data; |
| 259 | $ordered_rules[ $name ]['key'] = $rule; |
| 260 | $ordered_rules[ $name ]['name'] = $name; |
| 261 | $ordered_rules[ $name ]['active'] = $is_active; |
| 262 | $ordered_rules[ $name ]['desc'] = __( trim( $data['desc'] ), PO_LANG ); |
| 263 | |
| 264 | if ( PO_VERSION != 'pro' && in_array( 'pro', $data['limit'] ) ) { |
| 265 | $ordered_rules[ $name ]['disabled'] = sprintf( |
| 266 | __( 'Available in the <a href="%s" target="_blank">PRO version</a>', PO_LANG ), |
| 267 | 'http://premium.wpmudev.org/project/the-pop-over-plugin/' |
| 268 | ); |
| 269 | } else if ( IncPopup::use_global() && in_array( 'no global', $data['limit'] ) ) { |
| 270 | $ordered_rules[ $name ]['disabled'] = __( 'Not available for global PopUps', PO_LANG ); |
| 271 | } else if ( ! IncPopup::use_global() && in_array( 'global', $data['limit'] ) ) { |
| 272 | $ordered_rules[ $name ]['disabled'] = true; |
| 273 | } else { |
| 274 | $ordered_rules[ $name ]['disabled'] = false; |
| 275 | } |
| 276 | } ?> |
| 277 | <?php ksort( $ordered_rules ); ?> |
| 278 | |
| 279 | <?php foreach ( $ordered_rules as $data ) { |
| 280 | // Ignore Addons that have no name. |
| 281 | $data['rules'] = explode( ',', $data['rules'] ); |
| 282 | $rule_id = 'po-rule-' . sanitize_html_class( $data['key'] ); |
| 283 | if ( true === $data['disabled'] ) { continue; } |
| 284 | ?> |
| 285 | <tr valign="top" class="<?php echo esc_attr( $data['disabled'] ? 'locked' : '' ); ?>"> |
| 286 | <th class="check-column" scope="row"> |
| 287 | <?php if ( false == $data['disabled'] ) : ?> |
| 288 | <input type="checkbox" |
| 289 | id="<?php echo esc_attr( $rule_id ); ?>" |
| 290 | name="po_option[rules][<?php echo esc_attr( $data['key'] ); ?>]" |
| 291 | <?php checked( $data['active'] ); ?> |
| 292 | /> |
| 293 | <?php endif; ?> |
| 294 | </th> |
| 295 | <td class="column-name"> |
| 296 | <label for="<?php echo esc_attr( $rule_id ); ?>"> |
| 297 | <strong><?php echo esc_html( $data['name'] ); ?></strong> |
| 298 | </label> |
| 299 | <div><em><?php echo '' . $data['desc']; ?></em></div> |
| 300 | <?php if ( $data['disabled'] ) : ?> |
| 301 | <div class="locked-msg"> |
| 302 | <?php echo '' . $data['disabled']; ?> |
| 303 | </div> |
| 304 | <?php endif; ?> |
| 305 | </td> |
| 306 | <td class="column-items"> |
| 307 | <?php foreach ( $data['rules'] as $rule_name ) : ?> |
| 308 | <?php $rule_name = trim( $rule_name ); ?> |
| 309 | <?php if ( empty( $rule_name ) ) { continue; } ?> |
| 310 | <code><?php _e( trim( $rule_name ), PO_LANG ); ?></code><br /> |
| 311 | <?php endforeach; ?> |
| 312 | </td> |
| 313 | </tr> |
| 314 | <?php } ?> |
| 315 | </table> |
| 316 | |
| 317 | <p class="submit"> |
| 318 | <button class="button-primary"> |
| 319 | <?php _e( 'Save All Changes', PO_LANG ) ?> |
| 320 | </button> |
| 321 | </p> |
| 322 | |
| 323 | </form> |
| 324 | </div> |
| 325 | |
| 326 | </div> <!-- wrap --> |
| 327 |