/** * Sets the author base and db version with support for previous * versions of the plugin. * * @since 1.2.0 * * @return void */ private function options_back_compat() { // Options. if ($base = get_option('_ba_eas_author_base')) { // Sanitize the db value. $base = ba_eas_sanitize_author_base($base); // Author base. if (!empty($base)) { $this->author_base = $base; } // Current DB version. $this->current_db_version = absint(get_option('_ba_eas_db_version')); // Pre-0.9 Back compat. } elseif ($options = get_option('ba_edit_author_slug')) { // Sanitize the db value. if (!empty($options['author_base'])) { $base = ba_eas_sanitize_author_base($options['author_base']); } // Author base. if (!empty($base)) { $this->author_base = $base; } // Current DB version. if (!empty($options['db_version'])) { $this->current_db_version = absint($options['db_version']); } } }
/** * Add Author Base settings field. * * @since 0.9.0 */ function ba_eas_admin_setting_callback_author_base() { $author_base = ba_eas_sanitize_author_base(ba_eas()->author_base); // Build the demo author link. $author_link = esc_url(home_url('/')); $author_link = $author_link . '<span class="eas-demo-author-base-front">' . esc_html(trim($GLOBALS['wp_rewrite']->front, '/')) . '/</span>'; $author_link = $author_link . '<span class="eas-demo-author-base">' . $author_base . '</span>'; $author_link = $author_link . user_trailingslashit('/author-slug'); ?> <input id="_ba_eas_author_base" name="_ba_eas_author_base" type="text" value="<?php echo esc_attr($author_base); ?> " class="regular-text code" /> <em><?php esc_html_e("Defaults to 'author'", 'edit-author-slug'); ?> </em> <br /><br /> <strong>Demo:</strong> <em><?php echo $author_link; ?> </em> <?php }