Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
CRAP | n/a |
0 / 0 |
|
| jpcrm_do_flush_rewrite | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
| jpcrm_flag_for_flush_rewrite | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Handle rewrite rules for Jetpack CRM |
| 4 | * |
| 5 | * @package automattic/jetpack-crm |
| 6 | */ |
| 7 | |
| 8 | // prevent direct access |
| 9 | if ( ! defined( 'ZEROBSCRM_PATH' ) ) { |
| 10 | exit( 0 ); |
| 11 | } |
| 12 | |
| 13 | /** |
| 14 | * Flush rewrite rules if flagged to do so |
| 15 | */ |
| 16 | function jpcrm_do_flush_rewrite() { |
| 17 | $flush_rewrite_option = get_option( 'jpcrm_flush_rewrite_flag', 0 ); |
| 18 | // no need for flush/rewrite |
| 19 | if ( $flush_rewrite_option <= 0 ) { |
| 20 | return; |
| 21 | } |
| 22 | flush_rewrite_rules(); |
| 23 | delete_option( 'jpcrm_flush_rewrite_flag' ); |
| 24 | } |
| 25 | add_action( 'init', 'jpcrm_do_flush_rewrite' ); |
| 26 | |
| 27 | /** |
| 28 | * Add flag to flush rewrite rules |
| 29 | */ |
| 30 | function jpcrm_flag_for_flush_rewrite() { |
| 31 | update_option( 'jpcrm_flush_rewrite_flag', time(), false ); |
| 32 | } |