Skip to content

Commit 3d35883

Browse files
author
Marco Pereirinha
committed
Update the transformations title to take context in consideration
1 parent 28f9b87 commit 3d35883

4 files changed

Lines changed: 39 additions & 20 deletions

File tree

php/class-utils.php

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,11 +546,11 @@ public static function looks_like_json( $thing ) {
546546
}
547547

548548
$thing = trim( $thing );
549-
549+
550550
if ( empty( $thing ) ) {
551551
return false;
552552
}
553-
553+
554554
if ( ! in_array( $thing[0], array( '{', '[' ), true ) ) {
555555
return false;
556556
}
@@ -1267,4 +1267,38 @@ public static function rest_url( $path = '', $scheme = null ) {
12671267
*/
12681268
return apply_filters( 'cloudinary_rest_url', $rest_url, $path, $scheme );
12691269
}
1270+
1271+
/**
1272+
* Get the transformations title.
1273+
*
1274+
* @param string $context The context.
1275+
*
1276+
* @return string
1277+
*/
1278+
public static function get_transformations_title( $context ) {
1279+
$transformations_title = __( 'Cloudinary global transformations', 'cloudinary' );
1280+
$taxonomy_slug = static::get_sanitized_text( 'taxonomy' );
1281+
1282+
if ( $taxonomy_slug ) {
1283+
$taxonomy = get_taxonomy( $taxonomy_slug );
1284+
$transformations_title = sprintf(
1285+
// translators: %1$s is the taxonomy label and the %2$s is the context of the use.
1286+
__( '%1$s %2$s transformations', 'cloudinary' ),
1287+
$taxonomy->labels->singular_name,
1288+
$context
1289+
);
1290+
1291+
$taxonomy_id = static::get_sanitized_text( 'tag_ID' );
1292+
1293+
if ( $taxonomy_id ) {
1294+
$transformations_title = sprintf(
1295+
// translators: %s is the term name.
1296+
__( '%s transformations', 'cloudinary' ),
1297+
get_term( $taxonomy_id )->name
1298+
);
1299+
}
1300+
}
1301+
1302+
return $transformations_title;
1303+
}
12701304
}

php/templates/taxonomy-transformation-fields.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020
<div class="cloudinary-collapsible">
2121
<div class="cloudinary-collapsible__toggle">
2222
<h2>
23-
<?php
24-
// translators: The taxonomy label.
25-
echo esc_html( sprintf( __( 'Cloudinary %s transformations', 'cloudinary' ), strtolower( $tax_labels->singular_name ) ) );
26-
?>
23+
<?php esc_html_e( 'Cloudinary transformations', 'cloudinary' ); ?>
2724
</h2>
2825
<button type="button"><i class="dashicons dashicons-arrow-down-alt2"></i></button>
2926
</div>

ui-definitions/settings-image.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@
88
use Cloudinary\Utils;
99
use function Cloudinary\get_plugin_instance;
1010

11-
$transformations_title = __( 'Cloudinary global transformations', 'cloudinary' );
12-
13-
$taxonomy_slug = Utils::get_sanitized_text( 'taxonomy' );
14-
15-
if ( $taxonomy_slug ) {
16-
$transformations_title = __( 'Term transformations', 'cloudinary' );
17-
}
11+
$transformations_title = Utils::get_transformations_title( esc_html__( 'Image', 'cloudinary' ) );
1812

1913
$settings = array(
2014
array(

ui-definitions/settings-video.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@
88
use Cloudinary\Utils;
99
use function Cloudinary\get_plugin_instance;
1010

11-
$transformations_title = __( 'Cloudinary global transformations', 'cloudinary' );
12-
13-
$taxonomy_slug = Utils::get_sanitized_text( 'taxonomy' );
14-
15-
if ( $taxonomy_slug ) {
16-
$transformations_title = __( 'Term transformations', 'cloudinary' );
17-
}
11+
$transformations_title = Utils::get_transformations_title( esc_html__( 'Video', 'cloudinary' ) );
1812

1913
$settings = array(
2014
array(

0 commit comments

Comments
 (0)