Comment
3 years ago
Media
3 years ago
Post
3 years ago
User
3 years ago
Actions.php
3 years ago
AjaxValue.php
3 years ago
CustomField.php
3 years ago
LabelEncoder.php
3 years ago
Menu.php
3 years ago
Meta.php
3 years ago
Placeholder.php
3 years ago
Relation.php
3 years ago
Taxonomy.php
3 years ago
WooCommercePlaceholder.php
3 years ago
LabelEncoder.php
26 lines
| 1 | <?php |
| 2 | declare( strict_types=1 ); |
| 3 | |
| 4 | namespace AC\Column; |
| 5 | |
| 6 | class LabelEncoder { |
| 7 | |
| 8 | public function encode( string $url ): string { |
| 9 | return $this->convert( $url ); |
| 10 | } |
| 11 | |
| 12 | public function decode( string $url ): string { |
| 13 | return $this->convert( $url, 'decode' ); |
| 14 | } |
| 15 | |
| 16 | public function convert( string $url, string $action = 'encode' ): string { |
| 17 | $input = [ site_url(), '[cpac_site_url]' ]; |
| 18 | |
| 19 | if ( 'decode' === $action ) { |
| 20 | $input = array_reverse( $input ); |
| 21 | } |
| 22 | |
| 23 | return stripslashes( str_replace( $input[0], $input[1], trim( $url ) ) ); |
| 24 | } |
| 25 | |
| 26 | } |