Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permalink flush isn't always happening #40

Closed
Shelob9 opened this issue Aug 3, 2015 · 4 comments
Closed

Permalink flush isn't always happening #40

Shelob9 opened this issue Aug 3, 2015 · 4 comments
Assignees
Labels
Milestone

Comments

@Shelob9
Copy link
Contributor

Shelob9 commented Aug 3, 2015

Issue #39 indicates that the necessary permalink flush is not always happening... I presume, since we havn't heard more that this is an edge case, but still.

@Shelob9 Shelob9 added the bug label Aug 3, 2015
@Shelob9 Shelob9 self-assigned this Aug 3, 2015
@soderlind
Copy link

Try this, replace

flush_rewrite_rules();

with

global $wp_rewrite;
$wp_rewrite->flush_rules();

@Shelob9
Copy link
Contributor Author

Shelob9 commented Aug 3, 2015

@soderlind Yes, that is often the best way to do it. -1 me.

I know that epoch-api, pre-this version worked properly with ugly permalinks. Which might mean that the flush never worked, but wasn't needed. Got to check if the new rewrite rule for the iFrame is in fact ugly permalinks compatible, and our flush enables that.

@soderlind
Copy link

In my example plugin, I only flush if the permalink doesn't exist:

/**************************************************************************
 * Flushes the permalink structure.
 * flush_rules is an extremely costly function in terms of performance, and
 * should only be run when changing the rule.
 *
 * @see http://codex.wordpress.org/Rewrite_API/flush_rules
 **************************************************************************/
function my_permalink_flush_rewrite_rules() {
    $rules = $GLOBALS['wp_rewrite']->wp_rewrite_rules();
    if ( ! isset( $rules['my-permalink/(.*)$'] ) ) { // must be the same rule as in my_permalink_rewrite_rule($wp_rewrite)
        global $wp_rewrite;
        $wp_rewrite->flush_rules();
    }
}

@Shelob9 Shelob9 added this to the 1.0.1 milestone Aug 4, 2015
Shelob9 added a commit that referenced this issue Aug 6, 2015
@Shelob9
Copy link
Contributor Author

Shelob9 commented Aug 6, 2015

close via a24c41f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants