Move flush_rewrite_rules to install()

It adds significant overhead to each pageload and is only needed when
the rules change (aka after install).
master
Mahmoud Al-Qudsi 2018-02-10 13:22:31 -06:00
parent fb6b4da93d
commit 8ad7ef9d8f
1 changed files with 3 additions and 3 deletions

@ -83,6 +83,7 @@ class visitors_edits{
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql ); dbDelta( $sql );
flush_rewrite_rules(true);
} }
public function query_vars($query_vars){ public function query_vars($query_vars){
$query_vars[] = 'visitors_edits_post_name'; $query_vars[] = 'visitors_edits_post_name';
@ -94,7 +95,6 @@ class visitors_edits{
'index.php?visitors_edits_post_name=$matches[1]', 'index.php?visitors_edits_post_name=$matches[1]',
'top' 'top'
); );
flush_rewrite_rules(true);
} }
public function parse_request($request){ public function parse_request($request){
if( isset( $request->query_vars['visitors_edits_post_name'] ) ): if( isset( $request->query_vars['visitors_edits_post_name'] ) ):
@ -126,10 +126,10 @@ function visitors_editsDIFF($oldHtml,$newHtml){
require "vendor/autoload.php"; require "vendor/autoload.php";
$htmlDiff = new HtmlDiff($oldHtml, $newHtml); $htmlDiff = new HtmlDiff($oldHtml, $newHtml);
$htmlDiff->getConfig()->setGroupDiffs(false); $htmlDiff->getConfig()->setGroupDiffs(false);
return $htmlDiff->build(); return $htmlDiff->build();
} }
function visitors_editsDOM(){ function visitors_editsDOM(){
return new Dom; return new Dom;
} }
?> ?>