PluginProbe ʕ •ᴥ•ʔ
Custom Post Type Permalinks / 3.4.1
Custom Post Type Permalinks v3.4.1
1.2.0 1.3.0 1.3.1 1.4.0 1.5.1 1.5.2 1.5.4 2.0.0 2.0.1 2.0.2 2.1.1 2.1.2 2.1.3 2.2.0 3.0.0 3.0.1 3.1.0 3.1.1 3.1.3 3.1.4 3.1.5 3.2.0 3.2.1 3.2.2 3.3.0 3.3.1 3.3.4 3.3.5 3.4.0 3.4.0-rc.1 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.5.2 3.5.3 3.5.4 3.5.5 trunk 0.6 0.6.1 0.6.2 0.7 0.7.1 0.7.10 0.7.2 0.7.2.1 0.7.3 0.7.3.1 0.7.4 0.7.4.1 0.7.5 0.7.5.1 0.7.5.2 0.7.5.6 0.7.6 0.7.8 0.7.9 0.7.9.1 0.7.9.2 0.8 0.8.1 0.8.6 0.8.7 0.8.7.1 0.8.7.5 0.8.7.6 0.9 0.9.1 0.9.2.1 0.9.3.1 0.9.3.2 0.9.3.3 0.9.5 0.9.5.1 0.9.5.2 0.9.5.3 0.9.5.4 0.9.5.6 0.9.6 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0
custom-post-type-permalinks / CPTP / Module / FlushRules.php
custom-post-type-permalinks / CPTP / Module Last commit date
Admin.php 5 years ago FlushRules.php 8 years ago GetArchives.php 5 years ago Option.php 5 years ago Permalink.php 5 years ago Rewrite.php 5 years ago Setting.php 6 years ago
FlushRules.php
76 lines
1 <?php
2 /**
3 * Refresh Rewrite Rules.
4 *
5 * @package Custom_Post_Type_Permalinks
6 */
7
8 /**
9 *
10 * Reflush Rewrite Rules
11 *
12 * @since 0.9.4
13 * */
14 class CPTP_Module_FlushRules extends CPTP_Module {
15
16 /**
17 * Add actions.
18 */
19 public function add_hook() {
20 add_action( 'init', array( $this, 'update_rules' ) );
21 add_action( 'add_option_cptp_version', array( $this, 'update_rules' ) );
22 add_action( 'update_option_cptp_version', array( $this, 'update_rules' ), 20 );
23 add_action( 'wp_loaded', array( __CLASS__, 'dequeue_flush_rules' ), 200 );
24 }
25
26 /**
27 * Add hook flush_rules
28 *
29 * @since 0.7.9
30 */
31 public function update_rules() {
32 $post_types = CPTP_Util::get_post_types();
33 foreach ( $post_types as $post_type ) {
34 add_action( 'update_option_' . $post_type . '_structure', array( __CLASS__, 'queue_flush_rules' ), 10, 2 );
35 }
36 add_action( 'update_option_no_taxonomy_structure', array( __CLASS__, 'queue_flush_rules' ), 10, 2 );
37 }
38
39 /**
40 * Dequeue flush rules
41 *
42 * @since 0.9
43 */
44 public static function dequeue_flush_rules() {
45 if ( get_option( 'queue_flush_rules' ) ) {
46 flush_rewrite_rules();
47 update_option( 'queue_flush_rules', 0 );
48 }
49 }
50
51 /**
52 * Flush rules
53 *
54 * @since 0.7.9
55 */
56 public static function queue_flush_rules() {
57 update_option( 'queue_flush_rules', 1 );
58 }
59
60 /**
61 * Uninstall hooks
62 *
63 * @staitc
64 */
65 public static function uninstall_hook() {
66 delete_option( 'queue_flush_rules' );
67 }
68
69 /**
70 * Fire on activate
71 */
72 public function activation_hook() {
73 CPTP_Module_FlushRules::queue_flush_rules();
74 }
75 }
76