Skip to content

Commit aba1fc9

Browse files
committed
Better Rewrite Update
1 parent 375ec7b commit aba1fc9

File tree

6 files changed

+31
-1
lines changed

6 files changed

+31
-1
lines changed

tootpress_database.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ function tootpress_restore_factory_settings() {
131131
// CSS Option requires an inverse value (please do not ask why)
132132
update_option('tootpress_css',"0");
133133
update_option('tootpress_backlink','0');
134+
update_option('tootpress_rewrite_update','0');
134135
update_option('tootpress_developer',"0");
135136

136137
global $wpdb;

tootpress_install.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function tootpress_activate () {
4444
add_option('tootpress_navigation',"standard");
4545
add_option('tootpress_css','1');
4646
add_option('tootpress_backlink','0');
47+
add_option('tootpress_rewrite_update','0');
4748
add_option('tootpress_developer',"0");
4849
}
4950

@@ -91,6 +92,7 @@ function tootpress_delete () {
9192
delete_option('tootpress_navigation');
9293
delete_option('tootpress_css');
9394
delete_option('tootpress_backlink');
95+
delete_option('tootpress_rewrite_update');
9496
delete_option('tootpress_developer');
9597
}
9698

tootpress_options.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ function tootpress_options_menu() {
3030

3131
function tootpress_options_content() {
3232

33+
// Post-Processing
34+
35+
if(get_option('tootpress_rewrite_update')) {
36+
tootpress_rewrite_update();
37+
}
38+
3339
// Header
3440
echo '
3541
<div class="wrap">

tootpress_update.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function tootpress_update() {
4040
if(tootpress_ready_to_retrieve_toots_from_mastodon_api()) {
4141
tootpress_retrieve_mastodon_account();
4242
}
43+
add_option('tootpress_rewrite_update','0');
4344
}
4445

4546
}

tootpress_utilities.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,24 @@ function tootpress_retrieve_mastodon_account() {
146146

147147
}
148148

149+
/**
150+
* Update Rewrite Rules
151+
*
152+
* @since 0.3
153+
*
154+
* @return null
155+
*/
156+
157+
function tootpress_rewrite_update() {
158+
159+
$update_rewrites=get_option('tootpress_rewrite_update');
160+
161+
if($update_rewrites) {
162+
flush_rewrite_rules();
163+
}
164+
165+
update_option('tootpress_rewrite_update','0');
166+
167+
}
168+
149169
?>

tootpress_validate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function tootpress_validate_page_id ($pageid) {
147147
}
148148
// If new ID is given
149149
elseif ($pageid<>get_option( 'tootpress_page_id')) {
150-
flush_rewrite_rules();
150+
update_option('tootpress_rewrite_update','1');
151151
}
152152
}
153153

0 commit comments

Comments
 (0)