Changeset 2536605
- Timestamp:
- 05/24/2021 05:51:18 PM (5 years ago)
- Location:
- wp-seo-search/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (3 diffs)
-
wp-seo-search.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-seo-search/trunk/readme.txt
r2097596 r2536605 2 2 === WP SEO Search === 3 3 Contributors: angelcosta 4 Donate link: https:// netmundo.com.br/4 Donate link: https://angelcosta.com.br/apoie 5 5 Tags: search, seo, permalink, pretty urls, friendly urls 6 Requires at least: 3.0.17 Tested up to: 5. 28 Requires PHP: 5.2.49 Stable tag: 0.36 Requires at least: 5.4 7 Tested up to: 5.7.2 8 Requires PHP: 7.0 9 Stable tag: 1.0 10 10 License: GPLv2 or later 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 14 14 15 15 == Description == 16 This plugin makes the url for the search results page look like http ://site.com/search/keyword16 This plugin makes the url for the search results page look like https://site.com/search/keyword 17 17 18 Credit : https://wordpress.org/plugins/nice-search/18 Credit/Inspired by: [Nice Search](https://wordpress.org/) 19 19 20 20 == Installation == … … 22 22 23 23 == Frequently Asked Questions == 24 = I want to change the word "search" in the permalink . How? =25 Go to Permalinks and change your search base24 = I want to change the word "search" in the permalinks. How do I do that? = 25 Go to your Wordpress's Admin Dashboard and click on *Permalinks* under *Configuration*. In the *Optional* section you can change your search base to whatever you want. 26 26 27 27 == Screenshots == 28 29 1. How it looks on the panel 28 29 1. This is how your URL will look 30 2. This is how you change your search base 30 31 31 32 == Changelog == 33 = 1.0 = 34 * Cleaner code 35 * Compatibility with WP 5.7.2 36 * Added link to configuration in plugin list 37 * Fixed correct URL for my website 32 38 = 0.2.1 = 33 39 * Added i18n code. Plugin is now translation-ready. -
wp-seo-search/trunk/wp-seo-search.php
r1351031 r2536605 1 1 <?php 2 /* 2 /** 3 3 * Plugin Name: WP SEO Search 4 * Plugin URI: https://angelcosta.com.br/wp-seo-search/ 4 5 * Description: Get a better permalink for your search results page. 5 * Version: 0.2.1 6 * Author: Angelica Costa 7 * Author URI: http://webangie.com/ 6 * Version: 1.0 7 * Requires at least: 5.4 8 * Requires PHP: 7.0 9 * Author: Angel Costa 10 * Author URI: https://angelcosta.com.br/ 11 * License: GPL v2 or later 12 * License URI: https://www.gnu.org/licenses/gpl-2.0.html 8 13 * Text Domain: wpseosearch 9 * Domain Path: /languages /14 * Domain Path: /languages 10 15 */ 11 16 17 //Let's make this plugin available in all languages 12 18 load_plugin_textdomain( 'wpseosearch', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); 13 19 20 //Creates the form in the permalinks page 14 21 add_action( 'load-options-permalink.php', 'wpseosearch_settings' ); 15 function wpseosearch_settings(){ 16 if( isset( $_POST['wpseosearch_base'] ) ){ 17 update_option( 'wpseosearch_base', sanitize_title_with_dashes( $_POST['wpseosearch_base'] ) ); 22 23 if ( !function_exists( 'wpseosearch_settings' ) ) { 24 25 function wpseosearch_settings(){ 26 if( isset( $_POST[ 'wpseosearch_base' ] ) ){ 27 update_option( 'wpseosearch_base', sanitize_key( $_POST[ 'wpseosearch_base' ] ) ); 28 } 29 add_settings_field( 'wpseosearch_base', __( 'Search Base', 'wpseosearch' ), 'wpseosearch_input', 'permalink', 'optional' ); 18 30 } 19 add_settings_field( 'wpseosearch_base', __( 'Search Base', 'wpseosearch' ), 'wpseosearch_input', 'permalink', 'optional' ); 20 } 21 function wpseosearch_input(){ 22 $value = get_option( 'wpseosearch_base', 'search'); 23 echo '<input type="text" value="' . esc_attr( $value ) . '" name="wpseosearch_base" id="wpseosearch_base" class="regular-text" />'; 31 24 32 } 25 33 26 function wpseosearch_base() { 27 global $wp_rewrite; 28 $wp_rewrite->search_base = get_option( 'wpseosearch_base', 'search' ); 29 $wp_rewrite->flush_rules(); 34 if ( !function_exists( 'wpseosearch_input' ) ){ 35 36 function wpseosearch_input(){ 37 $value = get_option( 'wpseosearch_base', 'search'); 38 echo '<input type="text" value="' . esc_attr( $value ) . '" name="wpseosearch_base" id="wpseosearch_base" class="regular-text" />'; 39 } 40 30 41 } 31 42 32 add_action('init', 'wpseosearch_base'); 43 //Let's do some rewriting as soon as WP loads 44 add_action( 'init', 'wpseosearch_base' ); 33 45 34 function wpseosearch_rewrite() { 35 global $wp_rewrite; 36 if ( !isset( $wp_rewrite ) || !is_object( $wp_rewrite ) || !$wp_rewrite->using_permalinks() ) 37 return; 38 $search_base = $wp_rewrite->search_base; 39 if ( is_search() && !is_admin() && strpos( $_SERVER['REQUEST_URI'], "/{$search_base}/" ) === false ) { 40 wp_redirect( home_url( "/{$search_base}/" . urlencode( get_query_var( 's' ) ) ) ); 41 exit(); 46 if ( !function_exists( 'wpseosearch_base' ) ){ 47 48 function wpseosearch_base() { 49 global $wp_rewrite; 50 $wp_rewrite->search_base = get_option( 'wpseosearch_base', 'search' ); 51 $wp_rewrite->flush_rules(); 52 } 53 54 } 55 56 //And also some redirecting... 57 add_action( 'template_redirect', 'wpseosearch_rewrite' ); 58 59 if ( !function_exists( 'wpseosearch_rewrite' ) ){ 60 61 function wpseosearch_rewrite() { 62 global $wp_rewrite; 63 64 if ( !isset( $wp_rewrite ) || !is_object( $wp_rewrite ) || !$wp_rewrite->using_permalinks() ){ 65 return; 66 } 67 68 $search_base = $wp_rewrite->search_base; 69 70 if ( is_search() && !is_admin() && strpos( $_SERVER['REQUEST_URI'], "/{$search_base}/" ) === false ) { 71 wp_redirect( home_url( "/{$search_base}/" . urlencode( get_query_var( 's' ) ) ) ); 72 exit(); 73 } 74 } 75 76 } 77 78 //Easy shortcut for the configuration 79 add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'wpseosearch_settings_link'); 80 81 if ( !function_exists('wpseosearch_settings_link')) { 82 83 function wpseosearch_settings_link( $links ) { 84 $links[] = '<a href="' . 85 admin_url( 'options-permalink.php' ) . 86 '">' . __('Settings') . '</a>'; 87 return $links; 88 } 89 90 } 91 92 // Let's add some useful links 93 add_filter( 'plugin_row_meta', 'wpseosearch_row_meta', 10, 4 ); 94 if ( !function_exists( 'wpseosearch_row_meta' )) { 95 function wpseosearch_row_meta( $links, $file ) { 96 if ( $file == plugin_basename( __FILE__ ) ){ 97 $links[] = '<a href="https://angelcosta.com.br/wp-seo-search">'. __( 'Documentation' ). '</a>'; 98 $links[] = '<a href="https://angelcosta.com.br/apoie">'. __( 'Donations' ). '</a>'; 99 $links[] = '<a href="options-permalink.php">'. __( 'Settings' ). '</a>'; 100 $links[] = '<a href="https://wordpress.org/support/plugin/wp-seo-search/">'. __( 'Support' ). '</a>'; 101 } 102 return $links; 42 103 } 43 104 } 44 add_action( 'template_redirect', 'wpseosearch_rewrite' ); 105 //In the next episode... 45 106 46 if ( version_compare( $wp_version, '3.5', '<=' ) ) { 47 function rewrite_seo_bug( $q ) { 48 if ( $q->get( 's' ) && empty( $_GET['s'] ) && is_main_query() ) 49 $q->set( 's', urldecode( $q->get( 's' ) ) ); 50 } 51 add_action( 'pre_get_posts', 'rewrite_seo_bug' ); 52 } 53 ?> 107 //Run after plugin is activated 108 //register_activation_hook( __FILE__, 'pluginprefix_function_to_run' ); 109 //Run after plugin is deactivated 110 //register_deactivation_hook( __FILE__, 'pluginprefix_function_to_run' );
Note: See TracChangeset
for help on using the changeset viewer.