-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from dartiss/develop
Adding code into master
- Loading branch information
Showing
5 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
|
||
<p align="right"><a href="https://wordpress.org/plugins/solo-search/"><img src="https://img.shields.io/wordpress/plugin/dt/solo-search?label=wp.org%20downloads&style=for-the-badge"> <img src="https://img.shields.io/wordpress/plugin/stars/solo-search?color=orange&style=for-the-badge"></a></p> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
/** | ||
Plugin Name: Solo | ||
Plugin URI: https://wordpress.org/plugins/solo-search/ | ||
Description: 🔍 Instantly display a single search result | ||
Version: 0.1 | ||
Author: David Artiss | ||
Author URI: https://artiss.blog | ||
Text Domain: solo | ||
@package solo | ||
*/ | ||
|
||
/** | ||
* Add meta to plugin details | ||
* | ||
* Add options to plugin meta line | ||
* | ||
* @param string $links Current links. | ||
* @param string $file File in use. | ||
* @return string Links, now with settings added. | ||
*/ | ||
function solo_plugin_meta( $links, $file ) { | ||
|
||
if ( false !== strpos( $file, 'solo-search.php' ) ) { | ||
|
||
$links = array_merge( $links, array( '<a href="https://github.com/dartiss/solo">' . __( 'Github', 'solo' ) . '</a>' ) ); | ||
|
||
$links = array_merge( $links, array( '<a href="https://wordpress.org/support/plugin/solo-search">' . __( 'Support', 'solo' ) . '</a>' ) ); | ||
|
||
$links = array_merge( $links, array( '<a href="https://artiss.blog/donate">' . __( 'Donate', 'solo' ) . '</a>' ) ); | ||
|
||
$links = array_merge( $links, array( '<a href="https://wordpress.org/support/plugin/solo-search/reviews/#new-post">' . __( 'Write a Review', 'solo' ) . ' ⭐️⭐️⭐️⭐️⭐️</a>' ) ); | ||
} | ||
|
||
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' ); |