Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fonts Library: update properties name from snake case to camel case to match the rest of the properties #53746

Merged
merged 4 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/experimental/fonts-library/class-wp-font-family.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ private function move_font_face_asset( $font_face, $file ) {

// Remove the uploaded font asset reference from the font face definition
// because it is no longer needed.
unset( $new_font_face['uploaded_file'] );
unset( $new_font_face['uploadedFile'] );

// If the filename has no font mime type, don't move the file and
// return the font face definition without src to be ignored later.
Expand Down Expand Up @@ -329,7 +329,7 @@ private function sanitize() {
*/
private function download_font_face_assets( $font_face ) {
$new_font_face = $font_face;
$sources = (array) $font_face['download_from_url'];
$sources = (array) $font_face['downloadFromUrl'];
$new_font_face['src'] = array();
$index = 0;

Expand All @@ -353,7 +353,7 @@ private function download_font_face_assets( $font_face ) {

// Remove the download url reference from the font face definition
// because it is no longer needed.
unset( $new_font_face['download_from_url'] );
unset( $new_font_face['downloadFromUrl'] );

return $new_font_face;
}
Expand All @@ -380,16 +380,16 @@ private function download_or_move_font_faces( $files ) {
$new_font_face = $font_face;

// If installing google fonts, download the font face assets.
if ( ! empty( $font_face['download_from_url'] ) ) {
if ( ! empty( $font_face['downloadFromUrl'] ) ) {
$new_font_face = $this->download_font_face_assets( $new_font_face );
}

// If installing local fonts, move the font face assets from
// the temp folder to the wp fonts directory.
if ( ! empty( $font_face['uploaded_file'] ) && ! empty( $files ) ) {
if ( ! empty( $font_face['uploadedFile'] ) && ! empty( $files ) ) {
$new_font_face = $this->move_font_face_asset(
$new_font_face,
$files[ $new_font_face['uploaded_file'] ]
$files[ $new_font_face['uploadedFile'] ]
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,17 @@ private function get_validation_errors( $font_families, $files ) {
);
}

if ( isset( $font_face['download_from_url'] ) && isset( $font_face['uploaded_file'] ) ) {
if ( isset( $font_face['downloadFromUrl'] ) && isset( $font_face['uploadedFile'] ) ) {
$error_messages[] = sprintf(
// translators: 1: font family index, 2: font face index.
__( 'Font family [%1$s] Font face [%2$s] should have only one of the download_from_url or uploaded_file properties defined and not both.', 'gutenberg' ),
__( 'Font family [%1$s] Font face [%2$s] should have only one of the downloadFromUrl or uploadedFile properties defined and not both.', 'gutenberg' ),
$family_index,
$face_index
);
}

if ( isset( $font_face['uploaded_file'] ) ) {
if ( ! isset( $files[ $font_face['uploaded_file'] ] ) ) {
if ( isset( $font_face['uploadedFile'] ) ) {
if ( ! isset( $files[ $font_face['uploadedFile'] ] ) ) {
$error_messages[] = sprintf(
// translators: 1: font family index, 2: font face index.
__( 'Font family [%1$s] Font face [%2$s] file is not defined in the request files.', 'gutenberg' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ public function data_install_and_uninstall_fonts() {
'name' => 'Piazzolla',
'fontFace' => array(
array(
'fontFamily' => 'Piazzolla',
'fontStyle' => 'normal',
'fontWeight' => '400',
'src' => 'http://fonts.gstatic.com/s/piazzolla/v33/N0b72SlTPu5rIkWIZjVgI-TckS03oGpPETyEJ88Rbvi0_TzOzKcQhZqx3gX9BRy5m5M.ttf',
'download_from_url' => 'http://fonts.gstatic.com/s/piazzolla/v33/N0b72SlTPu5rIkWIZjVgI-TckS03oGpPETyEJ88Rbvi0_TzOzKcQhZqx3gX9BRy5m5M.ttf',
'fontFamily' => 'Piazzolla',
'fontStyle' => 'normal',
'fontWeight' => '400',
'src' => 'http://fonts.gstatic.com/s/piazzolla/v33/N0b72SlTPu5rIkWIZjVgI-TckS03oGpPETyEJ88Rbvi0_TzOzKcQhZqx3gX9BRy5m5M.ttf',
'downloadFromUrl' => 'http://fonts.gstatic.com/s/piazzolla/v33/N0b72SlTPu5rIkWIZjVgI-TckS03oGpPETyEJ88Rbvi0_TzOzKcQhZqx3gX9BRy5m5M.ttf',
),
),
),
Expand All @@ -145,11 +145,11 @@ public function data_install_and_uninstall_fonts() {
'name' => 'Montserrat',
'fontFace' => array(
array(
'fontFamily' => 'Montserrat',
'fontStyle' => 'normal',
'fontWeight' => '100',
'src' => 'http://fonts.gstatic.com/s/montserrat/v25/JTUHjIg1_i6t8kCHKm4532VJOt5-QNFgpCtr6Uw-Y3tcoqK5.ttf',
'download_from_url' => 'http://fonts.gstatic.com/s/montserrat/v25/JTUHjIg1_i6t8kCHKm4532VJOt5-QNFgpCtr6Uw-Y3tcoqK5.ttf',
'fontFamily' => 'Montserrat',
'fontStyle' => 'normal',
'fontWeight' => '100',
'src' => 'http://fonts.gstatic.com/s/montserrat/v25/JTUHjIg1_i6t8kCHKm4532VJOt5-QNFgpCtr6Uw-Y3tcoqK5.ttf',
'downloadFromUrl' => 'http://fonts.gstatic.com/s/montserrat/v25/JTUHjIg1_i6t8kCHKm4532VJOt5-QNFgpCtr6Uw-Y3tcoqK5.ttf',
),
),
),
Expand Down Expand Up @@ -272,10 +272,10 @@ public function data_install_and_uninstall_fonts() {
'name' => 'Piazzolla',
'fontFace' => array(
array(
'fontFamily' => 'Piazzolla',
'fontStyle' => 'normal',
'fontWeight' => '400',
'uploaded_file' => 'files0',
'fontFamily' => 'Piazzolla',
'fontStyle' => 'normal',
'fontWeight' => '400',
'uploadedFile' => 'files0',
),
),
),
Expand All @@ -285,10 +285,10 @@ public function data_install_and_uninstall_fonts() {
'name' => 'Montserrat',
'fontFace' => array(
array(
'fontFamily' => 'Montserrat',
'fontStyle' => 'normal',
'fontWeight' => '100',
'uploaded_file' => 'files1',
'fontFamily' => 'Montserrat',
'fontStyle' => 'normal',
'fontWeight' => '100',
'uploadedFile' => 'files1',
),
),
),
Expand Down Expand Up @@ -418,10 +418,10 @@ public function data_install_with_improper_inputs() {
'slug' => 'piazzolla',
'fontFace' => array(
array(
'fontFamily' => 'Piazzolla',
'fontStyle' => 'normal',
'fontWeight' => '400',
'uploaded_file' => 'files0',
'fontFamily' => 'Piazzolla',
'fontStyle' => 'normal',
'fontWeight' => '400',
'uploadedFile' => 'files0',
),
),
),
Expand All @@ -437,10 +437,10 @@ public function data_install_with_improper_inputs() {
'slug' => 'piazzolla',
'fontFace' => array(
array(
'fontFamily' => 'Piazzolla',
'fontStyle' => 'normal',
'fontWeight' => '400',
'uploaded_file' => 'files666',
'fontFamily' => 'Piazzolla',
'fontStyle' => 'normal',
'fontWeight' => '400',
'uploadedFile' => 'files666',
),
),
),
Expand All @@ -456,20 +456,20 @@ public function data_install_with_improper_inputs() {
),
),

'fontface with incompatible properties (download_from_url and uploaded_file together)' => array(
'fontface with incompatible properties (downloadFromUrl and uploadedFile together)' => array(
'font_families' => array(
array(
'fontFamily' => 'Piazzolla',
'slug' => 'piazzolla',
'name' => 'Piazzolla',
'fontFace' => array(
array(
'fontFamily' => 'Piazzolla',
'fontStyle' => 'normal',
'fontWeight' => '400',
'src' => 'http://fonts.gstatic.com/s/piazzolla/v33/N0b72SlTPu5rIkWIZjVgI-TckS03oGpPETyEJ88Rbvi0_TzOzKcQhZqx3gX9BRy5m5M.ttf',
'download_from_url' => 'http://fonts.gstatic.com/s/piazzolla/v33/N0b72SlTPu5rIkWIZjVgI-TckS03oGpPETyEJ88Rbvi0_TzOzKcQhZqx3gX9BRy5m5M.ttf',
'uploaded_file' => 'files0',
'fontFamily' => 'Piazzolla',
'fontStyle' => 'normal',
'fontWeight' => '400',
'src' => 'http://fonts.gstatic.com/s/piazzolla/v33/N0b72SlTPu5rIkWIZjVgI-TckS03oGpPETyEJ88Rbvi0_TzOzKcQhZqx3gX9BRy5m5M.ttf',
'downloadFromUrl' => 'http://fonts.gstatic.com/s/piazzolla/v33/N0b72SlTPu5rIkWIZjVgI-TckS03oGpPETyEJ88Rbvi0_TzOzKcQhZqx3gX9BRy5m5M.ttf',
'uploadedFile' => 'files0',
),
),
),
Expand Down
8 changes: 4 additions & 4 deletions phpunit/fonts-library/wpFontFamily/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public function set_up() {
'fontFamily' => 'Merriweather',
'fontFace' => array(
array(
'fontFamily' => 'Merriweather',
'fontStyle' => 'normal',
'fontWeight' => '400',
'uploaded_file' => 'files0',
'fontFamily' => 'Merriweather',
'fontStyle' => 'normal',
'fontWeight' => '400',
'uploadedFile' => 'files0',
),
),
),
Expand Down
26 changes: 13 additions & 13 deletions phpunit/fonts-library/wpFontFamily/getData-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public function data_should_get_data() {
'fontFamily' => 'Piazzolla',
'fontFace' => array(
array(
'fontFamily' => 'Piazzolla',
'fontStyle' => 'italic',
'fontWeight' => '400',
'src' => 'http://fonts.gstatic.com/s/piazzolla/v33/N0b72SlTPu5rIkWIZjVgI-TckS03oGpPETyEJ88Rbvi0_TzOzKcQhZqx3gX9BRy5m5M.ttf',
'download_from_url' => 'http://fonts.gstatic.com/s/piazzolla/v33/N0b72SlTPu5rIkWIZjVgI-TckS03oGpPETyEJ88Rbvi0_TzOzKcQhZqx3gX9BRy5m5M.ttf',
'fontFamily' => 'Piazzolla',
'fontStyle' => 'italic',
'fontWeight' => '400',
'src' => 'http://fonts.gstatic.com/s/piazzolla/v33/N0b72SlTPu5rIkWIZjVgI-TckS03oGpPETyEJ88Rbvi0_TzOzKcQhZqx3gX9BRy5m5M.ttf',
'downloadFromUrl' => 'http://fonts.gstatic.com/s/piazzolla/v33/N0b72SlTPu5rIkWIZjVgI-TckS03oGpPETyEJ88Rbvi0_TzOzKcQhZqx3gX9BRy5m5M.ttf',
),
),
),
Expand Down Expand Up @@ -75,16 +75,16 @@ public function data_should_get_data() {
'fontFamily' => 'Inter',
'fontFace' => array(
array(
'fontFamily' => 'Inter',
'fontStyle' => 'normal',
'fontWeight' => '400',
'uploaded_file' => 'files0',
'fontFamily' => 'Inter',
'fontStyle' => 'normal',
'fontWeight' => '400',
'uploadedFile' => 'files0',
),
array(
'fontFamily' => 'Inter',
'fontStyle' => 'normal',
'fontWeight' => '500',
'uploaded_file' => 'files1',
'fontFamily' => 'Inter',
'fontStyle' => 'normal',
'fontWeight' => '500',
'uploadedFile' => 'files1',
),
),
),
Expand Down
54 changes: 27 additions & 27 deletions phpunit/fonts-library/wpFontFamily/install-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ public function data_should_download_fontfaces() {
'fontFamily' => 'Piazzolla',
'fontFace' => array(
array(
'fontFamily' => 'Piazzolla',
'fontStyle' => 'italic',
'fontWeight' => '400',
'src' => 'http://fonts.gstatic.com/s/piazzolla/v33/N0b72SlTPu5rIkWIZjVgI-TckS03oGpPETyEJ88Rbvi0_TzOzKcQhZqx3gX9BRy5m5M.ttf',
'download_from_url' => 'http://fonts.gstatic.com/s/piazzolla/v33/N0b72SlTPu5rIkWIZjVgI-TckS03oGpPETyEJ88Rbvi0_TzOzKcQhZqx3gX9BRy5m5M.ttf',
'fontFamily' => 'Piazzolla',
'fontStyle' => 'italic',
'fontWeight' => '400',
'src' => 'http://fonts.gstatic.com/s/piazzolla/v33/N0b72SlTPu5rIkWIZjVgI-TckS03oGpPETyEJ88Rbvi0_TzOzKcQhZqx3gX9BRy5m5M.ttf',
'downloadFromUrl' => 'http://fonts.gstatic.com/s/piazzolla/v33/N0b72SlTPu5rIkWIZjVgI-TckS03oGpPETyEJ88Rbvi0_TzOzKcQhZqx3gX9BRy5m5M.ttf',
),
),
),
Expand All @@ -131,18 +131,18 @@ public function data_should_download_fontfaces() {
'fontFamily' => 'Lato',
'fontFace' => array(
array(
'fontFamily' => 'Lato',
'fontStyle' => 'normal',
'fontWeight' => '400',
'src' => 'http://fonts.gstatic.com/s/lato/v24/S6uyw4BMUTPHvxk6XweuBCY.ttf',
'download_from_url' => 'http://fonts.gstatic.com/s/lato/v24/S6uyw4BMUTPHvxk6XweuBCY.ttf',
'fontFamily' => 'Lato',
'fontStyle' => 'normal',
'fontWeight' => '400',
'src' => 'http://fonts.gstatic.com/s/lato/v24/S6uyw4BMUTPHvxk6XweuBCY.ttf',
'downloadFromUrl' => 'http://fonts.gstatic.com/s/lato/v24/S6uyw4BMUTPHvxk6XweuBCY.ttf',
),
array(
'fontFamily' => 'Lato',
'fontStyle' => 'italic',
'fontWeight' => '400',
'src' => 'http://fonts.gstatic.com/s/lato/v24/S6u8w4BMUTPHjxswWyWrFCbw7A.ttf',
'download_from_url' => 'http://fonts.gstatic.com/s/lato/v24/S6u8w4BMUTPHjxswWyWrFCbw7A.ttf',
'fontFamily' => 'Lato',
'fontStyle' => 'italic',
'fontWeight' => '400',
'src' => 'http://fonts.gstatic.com/s/lato/v24/S6u8w4BMUTPHjxswWyWrFCbw7A.ttf',
'downloadFromUrl' => 'http://fonts.gstatic.com/s/lato/v24/S6u8w4BMUTPHjxswWyWrFCbw7A.ttf',
),
),
),
Expand Down Expand Up @@ -187,10 +187,10 @@ public function data_should_move_local_fontfaces() {
'fontFamily' => 'Inter',
'fontFace' => array(
array(
'fontFamily' => 'Inter',
'fontStyle' => 'italic',
'fontWeight' => '900',
'uploaded_file' => 'files0',
'fontFamily' => 'Inter',
'fontStyle' => 'italic',
'fontWeight' => '900',
'uploadedFile' => 'files0',
),
),
),
Expand All @@ -212,16 +212,16 @@ public function data_should_move_local_fontfaces() {
'fontFamily' => 'Lato',
'fontFace' => array(
array(
'fontFamily' => 'Lato',
'fontStyle' => 'normal',
'fontWeight' => '400',
'uploaded_file' => 'files1',
'fontFamily' => 'Lato',
'fontStyle' => 'normal',
'fontWeight' => '400',
'uploadedFile' => 'files1',
),
array(
'fontFamily' => 'Lato',
'fontStyle' => 'normal',
'fontWeight' => '500',
'uploaded_file' => 'files2',
'fontFamily' => 'Lato',
'fontStyle' => 'normal',
'fontWeight' => '500',
'uploadedFile' => 'files2',
),
),
),
Expand Down
24 changes: 12 additions & 12 deletions phpunit/fonts-library/wpFontFamily/uninstall-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ public function data_should_uninstall() {
'fontFamily' => 'Inter',
'fontFace' => array(
array(
'fontFamily' => 'Inter',
'fontStyle' => 'italic',
'fontWeight' => '900',
'uploaded_file' => 'files0',
'fontFamily' => 'Inter',
'fontStyle' => 'italic',
'fontWeight' => '900',
'uploadedFile' => 'files0',
),
),
),
Expand All @@ -158,16 +158,16 @@ public function data_should_uninstall() {
'fontFamily' => 'Lato',
'fontFace' => array(
array(
'fontFamily' => 'Lato',
'fontStyle' => 'normal',
'fontWeight' => '400',
'uploaded_file' => 'files1',
'fontFamily' => 'Lato',
'fontStyle' => 'normal',
'fontWeight' => '400',
'uploadedFile' => 'files1',
),
array(
'fontFamily' => 'Lato',
'fontStyle' => 'normal',
'fontWeight' => '500',
'uploaded_file' => 'files2',
'fontFamily' => 'Lato',
'fontStyle' => 'normal',
'fontWeight' => '500',
'uploadedFile' => 'files2',
),
),
),
Expand Down