Add wpautop export more & Search URL Rewrite support in the free version
-
Add wpautop excerpt more style & Search URL Rewrite in the free version the was from a plugin i was working on before I found your plugin thes only thing thats came out of my plugin was a way to customize the login page form the customizer.
<?php if (!defined('ABSPATH')) { return; } class WPE_Expert_More_Style { public function init() { add_filter('the_content_more_link', array($this, 'wpe_modify_excerpt_more')); add_filter('excerpt_more', array($this, 'wpe_modify_excerpt_more')); add_action('admin_init', array($this, 'wpe_add_custom_settings')); } public function wpe_modify_excerpt_more($more) { global $post; $options = get_option('wpe_excerpt_more_style'); $wpe_more = ''; switch ($options) { case 'link': $wpe_more = '<a class="moretag" href="' . get_permalink($post->ID) . '">...</a>'; break; case 'custom_link': $custom_text = get_option('wpe_custom_link_text'); $wpe_more = '<a class="moretag" href="' . get_permalink($post->ID) . '">' . esc_html($custom_text) . '</a>'; break; case 'none': $wpe_more = ""; break; default: $wpe_more = $more; } return $wpe_more; } public function wpe_add_custom_settings() { add_settings_section('wpe_more_link_section', __('Customize Excerpt "More"', 'wpe'), array($this, 'wpe_excerpt_more_link_section_callback'), 'reading'); add_settings_field('wpe_excerpt_more_style', __('Excerpt More Style', 'wpe'), array($this, 'wpe_excerpt_more_style_callback'), 'reading', 'wpe_more_link_section'); add_settings_field('wpe_custom_link_text', __('Custom Link Text', 'wpe'), array($this, 'wpe_custom_link_text_callback'), 'reading', 'wpe_more_link_section'); register_setting('reading', 'wpe_excerpt_more_style'); // Set default value for wpe_custom_link_text $custom_text_default = 'Read more'; $custom_text_option = get_option('wpe_custom_link_text'); if (empty($custom_text_option)) { update_option('wpe_custom_link_text', $custom_text_default); } } public function wpe_excerpt_more_link_section_callback() { echo __('Control the look excerpt the "more"', 'wpe'); } public function wpe_excerpt_more_style_callback() { $options = get_option('wpe_excerpt_more_style'); ?> <fieldset> <label> <input type="radio" name="wpe_excerpt_more_style" value="default" <?php checked('default', $options); ?>> <?php esc_html_e('Default', 'wpe'); ?> </label> <br> <label> <input type="radio" name="wpe_excerpt_more_style" value="link" <?php checked('link', $options); ?>> <?php esc_html_e('Link', 'wpe'); ?> </label> <br> <label> <input type="radio" name="wpe_excerpt_more_style" value="custom_link" <?php checked('custom_link', $options); ?>> <?php esc_html_e('Custom Link', 'wpe'); ?> </label> <br> <label> <input type="radio" name="wpe_excerpt_more_style" value="none" <?php checked('none', $options); ?>> <?php esc_html_e('None', 'wpe'); ?> </label> </fieldset> <?php } public function wpe_custom_link_text_callback() { $custom_text = get_option('wpe_custom_link_text'); ?> <input type="text" name="wpe_custom_link_text" value="<?php echo esc_attr($custom_text); ?>" /> <?php } } $wpe_expert_more_style = new WPE_Expert_More_Style(); $wpe_expert_more_style->init(); ?>
<?php if (!defined('ABSPATH')) { return; } ?> <?php class WPE_URL_Rewrite { public $wpe_login_slug = 'login'; public $wpe_search_base = 'search'; public function init() { add_action('admin_init', array($this, 'wpe_register_settings')); add_action('template_redirect', array($this, 'wpe_change_search_url')); add_action('after_switch_theme', array($this, 'wpe_flush_rewrite_rules')); register_activation_hook(__FILE__, array($this, 'wpe_flush_rewrite_rules')); register_deactivation_hook(__FILE__, array($this, 'wpe_flush_rewrite_rules')); add_action('load-options-permalink.php', array($this, 'wpe_load_permalink_settings')); } public function wpe_new_section_callback() { // Echo the description echo '<p>Customize the permalink settings for login and search.</p>'; } public function search_base_callback() { $search_base_value = get_option('wpe_search_base', 'search'); echo '<p><code>' . esc_url(home_url('/')) . '</code>'; echo ' <input type="text" name="wpe_search_base" id="wpe_search_base" value="' . esc_attr($search_base_value) . '" class="regular-text code"/> <code>/test</code></p>'; echo '<p><code>' . esc_url(home_url('/')) . '</code>'; echo ' <input type="text" readonly value="' . esc_attr($search_base_value) . '" class="regular-text code"/> <code>' . esc_attr($login_slug_value) . '/test/page/1</code></p>'; echo '<p>Modify the search URL to enhance its readability and user-friendliness.</p>'; } public function wpe_load_permalink_settings() { // Add new section add_settings_section('wpe_custom_section', 'Custom Permalink Settings', array($this, 'wpe_new_section_callback'), 'permalink'); $custom_search_base_option = get_option('wpe_search_base'); if ($custom_search_base_option !== false) { $this->wpe_search_base = rtrim($custom_search_base_option, '/'); } add_settings_field('wpe_search_base', 'Search Base', array($this, 'search_base_callback'), 'permalink', 'wpe_custom_section'); } public function wpe_register_settings() { register_setting('permalink', 'wpe_search_base'); } public function wpe_change_search_url() { global $wp_rewrite; if ($wp_rewrite->using_permalinks()) { if (is_search() && !empty($_GET['s'])) { if (get_query_var('paged') == 0) { wp_redirect(home_url($wp_rewrite->search_base . '/') . urlencode(get_query_var('s'))); exit(); } else { wp_redirect(home_url($wp_rewrite->search_base . '/') . urlencode(get_query_var('s')) . $wp_rewrite->pagination_base . '/' . urlencode(get_query_var('paged'))); exit(); } } } } public function wpe_flush_rewrite_rules() { flush_rewrite_rules(); } } $wpe_url_rewrite = new WPE_URL_Rewrite(); $wpe_url_rewrite->init();
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Add wpautop export more & Search URL Rewrite support in the free version’ is closed to new replies.