Skip to content

Equalize theme folder naming conventions across Win/Mac/Linux#196

Merged
schlessera merged 10 commits intowp-cli:masterfrom
beaucollins:fix-121
Nov 8, 2019
Merged

Equalize theme folder naming conventions across Win/Mac/Linux#196
schlessera merged 10 commits intowp-cli:masterfrom
beaucollins:fix-121

Conversation

@beaucollins
Copy link
Contributor

@beaucollins beaucollins commented Sep 13, 2019

wp theme delete P2
Error: The 'P2' theme could not be found. Did you mean 'p2'?

Modified Theme Fetcher to strict compare specified theme slug against existing ones as a Workaround to Operating System folder naming conventions.

This will equalize the non-lowercase slugs across all operating systems. If exact slug is not found, error is returned.

Fix to #121 - More info added to the bug report

-- @achyuthajoy

@beaucollins beaucollins requested a review from a team as a code owner September 13, 2019 19:03
@beaucollins beaucollins changed the title Fix 121 WP-CLI Themes: Added workaround to equalize folder naming conventions across Win/Mac/Linux Sep 13, 2019
* a case sensitive name.
* @return string|boolean Case sensitive name if match found, otherwise false.
*/
private function find_inexact_match( $name, $existing_themes ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can integrate the suggestion algorithm in here that also accounts for typos.
First we need to add an import at the top of the file:

use WP_CLI\Utils;

Then we can use that to also recognise words that are "close enough":

private function find_inexact_match( $name, $existing_themes ) {
	$suggestion = Utils\find_suggestion(
		strtolower( $name ),
		array_keys( array_map( 'strtolower', $existing_themes ) )
	);

	if ( '' !== $suggestion ) {
		return $suggestion;
	}
	
	return false;
}

Now, you'll also receive suggestions with typos like:

Error: The 'Twentyelven' theme could not be found. Did you mean 'twentyeleven'?

@schlessera schlessera added command:theme Related to 'theme' command bug labels Sep 27, 2019
beaucollins and others added 3 commits September 26, 2019 23:22
Co-Authored-By: Alain Schlesser <alain.schlesser@gmail.com>
Co-Authored-By: Alain Schlesser <alain.schlesser@gmail.com>
@schlessera schlessera added this to the 2.0.7 milestone Nov 8, 2019
@schlessera
Copy link
Member

Failed tests are unrelated, merging regardless.

@schlessera schlessera merged commit e397cf2 into wp-cli:master Nov 8, 2019
@schlessera schlessera changed the title WP-CLI Themes: Added workaround to equalize folder naming conventions across Win/Mac/Linux Equalize theme folder naming conventions across Win/Mac/Linux Nov 8, 2019
@schlessera
Copy link
Member

Thanks for the PR, @achyuthajoy & @beaucollins !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug command:theme Related to 'theme' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: False positive result shown when theme slug is entered in non-lowercase for activation

3 participants