Codeception\Module\WPSugarMethods::setPermalinkStructureAndFlush PHP Method

setPermalinkStructureAndFlush() public method

j
public setPermalinkStructureAndFlush ( string $permalinkStructure = '/%postname%/', boolean $hardFlush = true )
$permalinkStructure string The new permalink structure; if empty then the `permalink_structure` option will be removed.
$hardFlush boolean Whether the rewrite rules should be written to the .htaccess file or not.
    public function setPermalinkStructureAndFlush($permalinkStructure = '/%postname%/', $hardFlush = true)
    {
        if (!empty($permalinkStructure)) {
            update_option('permalink_structure', $permalinkStructure);
            codecept_debug("Updated permalink structure to '{$permalinkStructure}'.");
        } else {
            delete_option('permalink_structure');
            codecept_debug("Restored permalink structure to WordPress default.");
        }
        flush_rewrite_rules($hardFlush);
        codecept_debug('Flushed rewrite rules.');
    }