css
10 years ago
woct-activate.php
10 years ago
woct-admin-menu.php
10 years ago
woct-admin-settings.php
10 years ago
woct-deactivate.php
10 years ago
woct-miscellaneous.php
10 years ago
woct-option.php
10 years ago
woct-output.php
10 years ago
woct-option.php
62 lines
| 1 | <?php |
| 2 | |
| 3 | function rs_woct_option_defaults() { |
| 4 | $array = array( |
| 5 | 'website_open' => 'yes', |
| 6 | 'closed_message' => 'Our website is currently closed. Please try again soon.', |
| 7 | 'closed_html' => '', |
| 8 | 'bypass_paths' => '', |
| 9 | 'bypass_get_key' => 'bypass_', |
| 10 | 'delete_option_on_deactivate' => '0', |
| 11 | ); |
| 12 | return $array; |
| 13 | } |
| 14 | |
| 15 | function rs_woct_get_option() { |
| 16 | return get_option( RS_WOCT__OPTION ); |
| 17 | } |
| 18 | |
| 19 | function rs_woct_option_exists() { |
| 20 | if( !get_option( RS_WOCT__OPTION ) ) { return FALSE; } |
| 21 | else { return TRUE; } |
| 22 | } |
| 23 | |
| 24 | function rs_woct_update_option() { |
| 25 | if( $_POST == FALSE ) { return; } |
| 26 | else { |
| 27 | $option = rs_woct_get_option(); |
| 28 | $new_option = array(); |
| 29 | $new_option['website_open'] = sanitize_text_field( $_POST['website_open'] ); |
| 30 | $new_option['closed_message'] = sanitize_text_field( $_POST['closed_message'] ); |
| 31 | $new_option['closed_html'] = str_replace( "\n", '---NEWLINE---', $_POST['closed_html'] ); |
| 32 | $new_option['closed_html'] = str_replace( "\t", '---TAB---', $new_option['closed_html'] ); |
| 33 | $new_option['closed_html'] = str_replace( "\r", '', $new_option['closed_html'] ); |
| 34 | $new_option['closed_html'] = esc_html( $new_option['closed_html'] ); |
| 35 | $new_option['closed_html'] = str_replace( '---TAB---', "\t", $new_option['closed_html'] ); |
| 36 | $new_option['closed_html'] = str_replace( '---NEWLINE---', "\n", $new_option['closed_html'] ); |
| 37 | $new_option['bypass_paths'] = str_replace( "\n", '---NEWLINE---', $_POST['bypass_paths'] ); |
| 38 | $new_option['bypass_paths'] = str_replace( "\t", '---TAB---', $new_option['bypass_paths'] ); |
| 39 | $new_option['bypass_paths'] = str_replace( "\r", '', $new_option['bypass_paths'] ); |
| 40 | $new_option['bypass_paths'] = esc_html( $new_option['bypass_paths'] ); |
| 41 | $new_option['bypass_paths'] = str_replace( '---TAB---', "\t", $new_option['bypass_paths'] ); |
| 42 | $new_option['bypass_paths'] = str_replace( '---NEWLINE---', "\n", $new_option['bypass_paths'] ); |
| 43 | $new_option['bypass_get_key'] = sanitize_text_field( $_POST['bypass_get_key'] ); |
| 44 | $new_option['delete_option_on_deactivate'] = sanitize_text_field( $_POST['delete_option_on_deactivate'] ); |
| 45 | foreach( $new_option as $key => $value ) { |
| 46 | if( $value !== $option[$key] ) { |
| 47 | $update_option = 1; |
| 48 | if( $key == 'website_open' ) { |
| 49 | $delete_cache = 1; |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | if( $update_option == 1 ) { |
| 54 | $update = update_option( RS_WOCT__OPTION, $new_option ); |
| 55 | if( $delete_cache == 1 ) { |
| 56 | if( function_exists( 'w3tc_pgcache_flush' ) ) { w3tc_pgcache_flush(); } // delete w3 total cache content |
| 57 | if( function_exists( 'wp_cache_clear_cache' ) ) { wp_cache_clear_cache(); } // delete wp super cache content |
| 58 | } |
| 59 | return $update; |
| 60 | } |
| 61 | } |
| 62 | } |