Skip to content

Commit

Permalink
Merge pull request #21 from dartiss/develop
Browse files Browse the repository at this point in the history
Version 1.0.1
  • Loading branch information
dartiss authored Jan 28, 2024
2 parents d9251ae + 852eebb commit 4af81a2
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Solo

<img src="https://ps.w.org/solo-search/assets/icon-128x128.png" align="left">You know when you search for something on a 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.
<img src="https://ps.w.org/solo-search/assets/icon.svg" width=128px align="left" style="padding: 0 20px 20px 0;">You know when you search for something on a 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.

And what about if you search for an exact match for a title and, well, it serves it up along with a number of other possible results. Hey, why didn't you just show me the one that I typed the name of in exactly? Well, you can do that too. Cool, eh?

Expand Down
Binary file modified 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.
1 change: 1 addition & 0 deletions assets/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 8 additions & 5 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Contributors: dartiss
Donate link: https://artiss.blog/donate
Tags: result, search, single, solo, title
Requires at least: 4.6
Tested up to: 6.3
Tested up to: 6.4
Requires PHP: 7.4
Stable tag: 1.0
Stable tag: 1.0.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -58,7 +58,10 @@ But, seriously, not at the moment. But if this interests you, please let me know

== Changelog ==

I use semantic versioning, with the first release being 0.1.
I use semantic versioning, with the first release being 0.1.

= 1.0.1 =
* Enhancement: Improved code quality

= 1.0 =
* Enhancement: You didn't ask for it, but you got it anyway - the search will now display content if you search for an exact match on the title
Expand All @@ -74,5 +77,5 @@ I use semantic versioning, with the first release being 0.1.

== Upgrade Notice ==

= 1.0 =
* 100% more features. 100% more settings. 0% bugs (I can hope, right?)
= 1.0.1 =
* Improved code quality
24 changes: 10 additions & 14 deletions solo-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Plugin Name: Solo
* Plugin URI: https://wordpress.org/plugins/solo-search/
* Description: 🔍 Instantly display a single search result
* Version: 1.0
* Version: 1.0.1
* Requires at least: 4.6
* Requires PHP: 5.3
* Requires PHP: 7.4
* Author: David Artiss
* Author URI: https://artiss.blog
* Text Domain: solo-search
Expand Down Expand Up @@ -96,30 +96,30 @@ function solo_remove_single_results() {
// If an exact match for a post or page title is found, go straight to that.
if ( function_exists( 'wpcom_vip_get_page_by_title' ) ) {

if ( wpcom_vip_get_page_by_title( get_search_query(), 'OBJECT', 'post' ) && 1 == $posts ) {
if ( wpcom_vip_get_page_by_title( get_search_query(), 'OBJECT', 'post' ) && 1 === $posts ) {
wp_safe_redirect( get_permalink( wpcom_vip_get_page_by_title( get_search_query() )->ID ) );
exit;
}

if ( wpcom_vip_get_page_by_title( get_search_query(), 'OBJECT', 'page' ) && 1 == $pages ) {
if ( wpcom_vip_get_page_by_title( get_search_query(), 'OBJECT', 'page' ) && 1 === $pages ) {
wp_safe_redirect( get_permalink( wpcom_vip_get_page_by_title( get_search_query() )->ID ) );
exit;
}
} else {

if ( get_page_by_title( get_search_query(), 'OBJECT', 'post' ) && 1 == $posts ) { // @codingStandardsIgnoreLine -- for non-VIP environments
if ( get_page_by_title( get_search_query(), 'OBJECT', 'post' ) && 1 === $posts ) { // @codingStandardsIgnoreLine -- for non-VIP environments
wp_safe_redirect( get_permalink( get_page_by_title( get_search_query() )->ID ) ); // @codingStandardsIgnoreLine -- for non-VIP environments
exit;
}

if ( get_page_by_title( get_search_query(), 'OBJECT', 'page' ) && 1 == $pages ) { // @codingStandardsIgnoreLine -- for non-VIP environments
if ( get_page_by_title( get_search_query(), 'OBJECT', 'page' ) && 1 === $pages ) { // @codingStandardsIgnoreLine -- for non-VIP environments
wp_safe_redirect( get_permalink( get_page_by_title( get_search_query() )->ID ) ); // @codingStandardsIgnoreLine -- for non-VIP environments
exit;
}
}

// If only one result is found, redirect straight to it!
if ( 1 == $single && 1 == $wp_query->post_count && 1 == $wp_query->max_num_pages ) {
if ( 1 === $single && 1 === $wp_query->post_count && 1 === $wp_query->max_num_pages ) {
wp_safe_redirect( get_permalink( $wp_query->posts[0]->ID ) );
exit;
}
Expand Down Expand Up @@ -160,7 +160,6 @@ function solo_settings_init() {
function solo_section_callback() {

echo esc_attr( __( 'Define how you want search results to be handled, when exact matches and single results are found.', 'solo-search' ) );

}

/**
Expand All @@ -170,8 +169,7 @@ function solo_section_callback() {
*/
function solo_setting_single_callback() {

echo '<label><input name="solo_option_single" type="checkbox" value="1" ' . checked( 1, get_option( 'solo_option_single', 1 ), false ) . '/>&nbsp;&nbsp;If a single result is found, redirect to that result</label>';

echo '<label><input name="solo_option_single" type="checkbox" value="1" ' . checked( 1, get_option( 'solo_option_single', 1 ), false ) . '>&nbsp;&nbsp;If a single result is found, redirect to that result</label>';
}

/**
Expand All @@ -181,8 +179,7 @@ function solo_setting_single_callback() {
*/
function solo_setting_exact_posts_callback() {

echo '<label><input name="solo_option_exact_posts" type="checkbox" value="1" ' . checked( 1, get_option( 'solo_option_exact_posts', '' ), false ) . '/>&nbsp;&nbsp;Posts</label>';

echo '<label><input name="solo_option_exact_posts" type="checkbox" value="1" ' . checked( 1, get_option( 'solo_option_exact_posts', '' ), false ) . '>&nbsp;&nbsp;Posts</label>';
}

/**
Expand All @@ -192,6 +189,5 @@ function solo_setting_exact_posts_callback() {
*/
function solo_setting_exact_pages_callback() {

echo '<label><input name="solo_option_exact_pages" type="checkbox" value="1" ' . checked( 1, get_option( 'solo_option_exact_pages', '' ), false ) . '/>&nbsp;&nbsp;Pages</label></br></br><p class="description">If an exact match to a title is found, redirect to it.</p>';

echo '<label><input name="solo_option_exact_pages" type="checkbox" value="1" ' . checked( 1, get_option( 'solo_option_exact_pages', '' ), false ) . '>&nbsp;&nbsp;Pages</label><br><br><p class="description">If an exact match to a title is found, redirect to it.</p>';
}

0 comments on commit 4af81a2

Please sign in to comment.