[Plugin: Author Slug] How to make it work in 2.9 if you get an $end error
-
Replace the contents of the plugin file with this, which replaces some less strict PHP:
<?php /* Plugin Name: Author slug Plugin URI: https://www.microkid.net/wordpress/author-slug/ Description: Change the author slug in the permalink for author pages. Author: Microkid Version: 1.0 Author URI: https://www.microkid.net */ function AS_activate() { if( ! get_option("AS_author_slug") ) { add_option( 'AS_author_slug', 'author', '', 'yes' ); } } function AS_flush() { global $wp_rewrite; $wp_rewrite->flush_rules(); } function AS_filter_author_link( $author_link ) { preg_match("|^(.+)/(.+?)/$|", $author_link, $matches ); $author_nickname = $matches[2]; return get_option("siteurl") . "/" . get_option("AS_author_slug") . "/" . $author_nickname . "/"; } function AS_add_options_page() { add_options_page("Author slug", "Author slug", "manage_options", __FILE__, "AS_options_page"); } function AS_options_page() { if( isset( $_POST['AS_author_slug'] ) ) { update_option( 'AS_author_slug', $_POST['AS_author_slug'] ); echo '<div id="message" class="updated fade"><p><strong>Settings saved.</strong></div>'; } $author_slug = get_option('AS_author_slug'); ?> <div class="wrap"> <h2>Author slug</h2> <form method="post" action=""> <p><strong>Current author page permalink structure: <code><?php echo get_option('siteurl');?>/<?php echo $author_slug; ?>/author-name/</code></strong></p> <p><label for="AS_author_slug">Change author slug: </label><input type="text" name="AS_author_slug" value="<?php $author_slug?>" /></p> <p id="AS_submit"> <input type="submit" name="AS_submit" value="Save settings" class="button-primary" /> </p> </form> </div> <?php } function AS_generate_rewrite_rules( $wp_rewrite ) { $author_slug = get_option('AS_author_slug'); $new_rules = array( $author_slug . '/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&paged=$matches[2]', $author_slug . '/(.+?)/?$' => 'index.php?author_name=$matches[1]' ); $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; return $wp_rewrite->rules; } if( ! is_admin() ) { add_action('init', 'AS_flush'); add_action('generate_rewrite_rules', 'AS_generate_rewrite_rules'); add_filter('author_link', 'AS_filter_author_link'); } else { add_action('admin_menu', 'AS_add_options_page'); } register_activation_hook( __FILE__, 'AS_activate' ); ?>
- The topic ‘[Plugin: Author Slug] How to make it work in 2.9 if you get an $end error’ is closed to new replies.