Skip to content

Commit

Permalink
Merge pull request #1 from dartiss/develop
Browse files Browse the repository at this point in the history
Adding code into master
  • Loading branch information
dartiss authored Sep 25, 2020
2 parents a0d5d93 + c548e16 commit 8f60900
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 2 deletions.
11 changes: 9 additions & 2 deletions README.md
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">&nbsp;<img src="https://img.shields.io/wordpress/plugin/stars/solo-search?color=orange&style=for-the-badge"></a></p>
Binary file added assets/icon-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon-256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions readme.txt
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
57 changes: 57 additions & 0 deletions solo-search.php
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' ) . '&nbsp;⭐️⭐️⭐️⭐️⭐️</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' );

0 comments on commit 8f60900

Please sign in to comment.