| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package Polylang |
| 4 |
*/ |
| 5 |
|
| 6 |
namespace WP_Syntex\Polylang\Options\Business; |
| 7 |
|
| 8 |
use WP_Error; |
| 9 |
use WP_Syntex\Polylang\Options\Primitive\Abstract_Boolean; |
| 10 |
use WP_Syntex\Polylang\Options\Options; |
| 11 |
|
| 12 |
defined( 'ABSPATH' ) || exit; |
| 13 |
|
| 14 |
/** |
| 15 |
* Class defining the "Remove /language/ in pretty permalinks" boolean option. |
| 16 |
* |
| 17 |
* @since 3.7 |
| 18 |
*/ |
| 19 |
class Rewrite extends Abstract_Boolean { |
| 20 |
/** |
| 21 |
* Returns option key. |
| 22 |
* |
| 23 |
* @since 3.7 |
| 24 |
* |
| 25 |
* @return string |
| 26 |
* |
| 27 |
* @phpstan-return 'rewrite' |
| 28 |
*/ |
| 29 |
public static function key(): string { |
| 30 |
return 'rewrite'; |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Adds information to the site health info array. |
| 35 |
* |
| 36 |
* @since 3.8 |
| 37 |
* |
| 38 |
* @param Options $options An instance of the Options class providing additional configuration. |
| 39 |
* |
| 40 |
* @return array The updated site health information. |
| 41 |
*/ |
| 42 |
public function get_site_health_info( Options $options ): array { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 43 |
if ( $this->get() ) { |
| 44 |
$value = '1: ' . sprintf( |
| 45 |
/* translators: %s is a URL slug: `/language/`. */ |
| 46 |
__( 'Remove %s in pretty permalinks', 'polylang' ), |
| 47 |
'`/language/`' |
| 48 |
); |
| 49 |
} else { |
| 50 |
$value = '0: ' . sprintf( |
| 51 |
/* translators: %s is a URL slug: `/language/`. */ |
| 52 |
__( 'Keep %s in pretty permalinks', 'polylang' ), |
| 53 |
'`/language/`' |
| 54 |
); |
| 55 |
} |
| 56 |
|
| 57 |
return $this->format_single_value_for_site_health_info( $value ); |
| 58 |
} |
| 59 |
/** |
| 60 |
* Returns the default value. |
| 61 |
* |
| 62 |
* @since 3.7 |
| 63 |
* |
| 64 |
* @return bool |
| 65 |
*/ |
| 66 |
protected function get_default() { |
| 67 |
return true; |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* Returns the description used in the JSON schema. |
| 72 |
* |
| 73 |
* @since 3.7 |
| 74 |
* |
| 75 |
* @return string |
| 76 |
*/ |
| 77 |
protected function get_description(): string { |
| 78 |
return sprintf( |
| 79 |
/* translators: %1$s is a URL slug: `/language/`. %2$s and %3$s are "true/false" values. */ |
| 80 |
__( 'Remove %1$s in pretty permalinks: %2$s to remove, %3$s to keep.', 'polylang' ), |
| 81 |
'`/language/`', |
| 82 |
'`true`', |
| 83 |
'`false`' |
| 84 |
); |
| 85 |
} |
| 86 |
} |
| 87 |
|