diff --git a/README.md b/README.md index cd8fec4..92b2fbc 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ -# solo -🔍 Instantly display a single search result. +# Solo + +You know when you search for something on your site and it finds just one result? You then have to click into it to display it. That's annoying. It's also adding an extra page load which is not necessary. + +This plugin simply removes this middle step - if your search returns one result, it will be shown in all its post/page/whatever (delete as appropriate) glory. As well as a quicker answer for your user, removing this improves your site's sustainability (okay, just a little... but every little helps, right?). + +The code passes WordPress and WordPress VIP coding standards. Because you're worth it. + +
\ No newline at end of file diff --git a/assets/icon-128x128.png b/assets/icon-128x128.png new file mode 100644 index 0000000..3dcd6da Binary files /dev/null and b/assets/icon-128x128.png differ diff --git a/assets/icon-256x256.png b/assets/icon-256x256.png new file mode 100644 index 0000000..494031d Binary files /dev/null and b/assets/icon-256x256.png differ diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..4c2e64f --- /dev/null +++ b/readme.txt @@ -0,0 +1,43 @@ +=== Solo === +Contributors: dartiss +Donate link: https://artiss.blog/donate +Tags: search +Requires at least: 2.8 +Tested up to: 5.5 +Requires PHP: 5.3 +Stable tag: 0.1 +License: GPLv2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html + +🔍 Instantly display a single search result. + +== Description == + +You know when you search for something on your site and it finds just one result? You then have to click into it to display it. That's annoying. It's also adding an extra page load which is not necessary. + +This plugin simply removes this middle step - if your search returns one result, it will be shown in all its post/page/whatever (delete as appropriate) glory. As well as a quicker answer for your user, removing this improves your site's sustainability (okay, just a little... but every little helps, right?). + +The code passes WordPress and WordPress VIP coding standards. Because you're worth it. + +Please visit the [Github page](https://github.com/dartiss/solo-search "Github") for the latest code development, planned enhancements and known issues. + +== Installation == + +Solo can be found and installed via the Plugin menu within WordPress administration (Plugins -> Add New). Alternatively, it can be downloaded from WordPress.org and installed manually... + +1. Upload the entire `solo-search` folder to your `wp-content/plugins/` directory. +2. Activate the plugin through the 'Plugins' menu in WordPress administration. + +It's now ready to go. + +== Changelog == + +[Learn more about my version numbering methodology](https://artiss.blog/2016/09/wordpress-plugin-versioning/ "WordPress Plugin Versioning") + += 0.1 = +* Initial release + +== Upgrade Notice == + += 0.1 = +* Initial release \ No newline at end of file diff --git a/solo-search.php b/solo-search.php new file mode 100644 index 0000000..984e4a3 --- /dev/null +++ b/solo-search.php @@ -0,0 +1,57 @@ +' . __( 'Github', 'solo' ) . '' ) ); + + $links = array_merge( $links, array( '' . __( 'Support', 'solo' ) . '' ) ); + + $links = array_merge( $links, array( '' . __( 'Donate', 'solo' ) . '' ) ); + + $links = array_merge( $links, array( '' . __( 'Write a Review', 'solo' ) . ' ⭐️⭐️⭐️⭐️⭐️' ) ); + } + + return $links; +} + +add_filter( 'plugin_row_meta', 'solo_plugin_meta', 10, 2 ); + +/** + * If just one post in result just show it + */ +function solo_remove_single_results() { + + if ( is_search() ) { + + global $wp_query; + + if ( 1 == $wp_query->post_count && 1 == $wp_query->max_num_pages ) { + wp_safe_redirect( get_permalink( $wp_query->posts[0]->ID ) ); + exit; + } + } +} + +add_action( 'template_redirect', 'solo_remove_single_results' );