Skip to content

Commit

Permalink
Tagline's, Quote's commas were not display accurately and the last ta…
Browse files Browse the repository at this point in the history
…gline displayed was taking wrongfully a comma. Plot's breaking lines <hr> were not displayed after the second result.
  • Loading branch information
jcvignoli committed Sep 8, 2021
1 parent 7cbf212 commit 7182d2f
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 98 deletions.
1 change: 1 addition & 0 deletions dist/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ v.3.6.3
* [bug] Function to detect of whether a Lumiere widget is active was broken. Fixed lumiere_block_widget_isactive() in class-utils.php
* [bug] Biography length was not correctly counted and led to text being cut early. Added new condition for $esc_html_breaker in lumiere_medaillon_bio() in class-frontend.php
* [bug] Picture link url in taxonomy page for people was not built. Fixed class-taxonomy-people-standard.php
* [bug] Tagline's, Quote's commas were not display accurately and the last tagline displayed was taking wrongfully a comma. Plot's breaking lines <hr> were not displayed after the second result. Fixed the methods in class movie.

v.3.6.2
* [bug] On some configurations, the creations of cache folder could lead to a fatal error. Switched from WordPress builtin $wp_system functions to PHP core functions in method lumiere_create_cache() in class-settings.php.
Expand Down
111 changes: 62 additions & 49 deletions dist/class/frontend/class-movie.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ private function lumiere_movies_country ( \Imdb\Title $movie ): string {
$output .= sprintf( esc_attr( _n( 'Country', 'Countries', $nbtotalcountry, 'lumiere-movies' ) ), number_format_i18n( $nbtotalcountry ) );
$output .= ':</span>';

// Taxonomy is active.
if ( ( $this->imdb_admin_values['imdbtaxonomy'] === '1' ) && ( $this->imdb_widget_values['imdbtaxonomycountry'] === '1' ) ) {

for ( $i = 0; $i < $nbtotalcountry; $i++ ) {
Expand All @@ -605,15 +606,16 @@ private function lumiere_movies_country ( \Imdb\Title $movie ): string {

}

} else {
return $output;

for ( $i = 0; $i < $nbtotalcountry; $i++ ) {
$output .= sanitize_text_field( $country[ $i ] );
if ( $i < $nbtotalcountry - 1 ) {
$output .= ', ';
}
} // endfor
}

// Taxonomy is unactive.
for ( $i = 0; $i < $nbtotalcountry; $i++ ) {
$output .= sanitize_text_field( $country[ $i ] );
if ( $i < $nbtotalcountry - 1 ) {
$output .= ', ';
}
}

return $output;
Expand Down Expand Up @@ -662,6 +664,7 @@ private function lumiere_movies_language( \Imdb\Title $movie ): string {
$output .= sprintf( esc_attr( _n( 'Language', 'Languages', $nbtotallanguages, 'lumiere-movies' ) ), number_format_i18n( $nbtotallanguages ) );
$output .= ':</span>';

// Taxonomy is active.
if ( ( $this->imdb_admin_values['imdbtaxonomy'] === '1' ) && ( $this->imdb_widget_values['imdbtaxonomylanguage'] === '1' ) ) {

for ( $i = 0; $i < $nbtotallanguages; $i++ ) {
Expand All @@ -673,16 +676,19 @@ private function lumiere_movies_language( \Imdb\Title $movie ): string {

}

} else {
for ( $i = 0; $i < $nbtotallanguages; $i++ ) {
return $output;

}

$output .= sanitize_text_field( $languages[ $i ] );
// Taxonomy is unactive.
for ( $i = 0; $i < $nbtotallanguages; $i++ ) {

if ( $i < $nbtotallanguages - 1 ) {
$output .= ', ';
}
$output .= sanitize_text_field( $languages[ $i ] );

if ( $i < $nbtotallanguages - 1 ) {
$output .= ', ';
}

}

return $output;
Expand Down Expand Up @@ -735,6 +741,7 @@ private function lumiere_movies_genre( \Imdb\Title $movie ): string {

$output .= ':</span>';

// Taxonomy is active.
if ( ( $this->imdb_admin_values['imdbtaxonomy'] === '1' ) && ( $this->imdb_widget_values['imdbtaxonomygenre'] === '1' ) ) {

for ( $i = 0; $i < $nbtotalgenre; $i++ ) {
Expand All @@ -746,16 +753,18 @@ private function lumiere_movies_genre( \Imdb\Title $movie ): string {

}

} else {
return $output;

for ( $i = 0; $i < $nbtotalgenre; $i++ ) {
}

$output .= esc_attr( $genre[ $i ] );
if ( $i < $nbtotalgenre - 1 ) {
$output .= ', ';
}
// Taxonomy is unactive.
for ( $i = 0; $i < $nbtotalgenre; $i++ ) {

$output .= esc_attr( $genre[ $i ] );
if ( $i < $nbtotalgenre - 1 ) {
$output .= ', ';
}

}

return $output;
Expand All @@ -780,6 +789,7 @@ private function lumiere_movies_keyword( \Imdb\Title $movie ): string {
$output .= sprintf( esc_attr( _n( 'Keyword', 'Keywords', $nbtotalkeywords, 'lumiere-movies' ) ), number_format_i18n( $nbtotalkeywords ) );
$output .= ':</span>';

// Taxonomy is active.
if ( ( $this->imdb_admin_values['imdbtaxonomy'] === '1' ) && ( $this->imdb_widget_values['imdbtaxonomykeyword'] === '1' ) ) {

for ( $i = 0; $i < $nbtotalkeywords; $i++ ) {
Expand All @@ -791,14 +801,17 @@ private function lumiere_movies_keyword( \Imdb\Title $movie ): string {

}

} else {
for ( $i = 0; $i < $nbtotalkeywords; $i++ ) {
return $output;

$output .= esc_attr( $keywords[ $i ] );
}

if ( $i < $nbtotalkeywords - 1 ) {
$output .= ', ';
}
// Taxonomy is unactive.
for ( $i = 0; $i < $nbtotalkeywords; $i++ ) {

$output .= esc_attr( $keywords[ $i ] );

if ( $i < $nbtotalkeywords - 1 ) {
$output .= ', ';
}
}

Expand Down Expand Up @@ -882,9 +895,9 @@ private function lumiere_movies_comment( \Imdb\Title $movie ): string {
}

/**
* Display the quotes
* Display the quotes
*
* @param \Imdb\Title $movie -> takes the value of IMDbPHP class
* @param \Imdb\Title $movie -> takes the value of IMDbPHP class
*/
private function lumiere_movies_quote( \Imdb\Title $movie ): string {

Expand All @@ -907,21 +920,21 @@ private function lumiere_movies_quote( \Imdb\Title $movie ): string {

for ( $i = 0; $i < $nbquotes && ( $i < $nbtotalquotes ); $i++ ) {

//transform <p> tags into <div> tags so they're not impacted by the theme
//transform <p> tags into <div> tags so they're not impacted by the theme.
$currentquotes = preg_replace( '~<p>~', "\n\t\t\t<div>", $quotes[ $i ] ) ?? $quotes[ $i ];
$currentquotes = preg_replace( '~</p>~', "\n\t\t\t</div>", $currentquotes ) ?? $currentquotes;

// if "Remove all links" option is not selected
// if "Remove all links" option is not selected.
if ( $this->imdb_admin_values['imdblinkingkill'] === '0' ) {
$output .= "\n\t\t\t";
$output .= $this->lumiere_imdburl_to_popupurl( $currentquotes );

} else {
} elseif ( $this->imdb_admin_values['imdblinkingkill'] === '1' ) {

$output .= "\n\t\t" . $this->lumiere_remove_link( $currentquotes );

}
if ( $i < ( $nbquotes - 1 ) ) {
if ( $i < ( $nbquotes - 1 ) && $i < ( $nbtotalquotes - 1 ) ) {
$output .= "\n\t\t\t<hr>"; // add hr to every quote but the last
}

Expand All @@ -941,7 +954,7 @@ private function lumiere_movies_tagline( \Imdb\Title $movie ): string {
$taglines = $movie->taglines();
$nbtaglines = intval( $this->imdb_widget_values['imdbwidgettaglinenumber'] ) === 0 || $this->imdb_widget_values['imdbwidgettaglinenumber'] === false ? '1' : intval( $this->imdb_widget_values['imdbwidgettaglinenumber'] );

$nbtotaltaglines = intval( count( $taglines ) );
$nbtotaltaglines = count( $taglines );

// If no result, exit.
if ( $nbtotaltaglines === 0 ) {
Expand All @@ -957,7 +970,7 @@ private function lumiere_movies_tagline( \Imdb\Title $movie ): string {
for ( $i = 0; $i < $nbtaglines && ( $i < $nbtotaltaglines ); $i++ ) {

$output .= "\n\t\t\t&laquo; " . sanitize_text_field( $taglines[ $i ] ) . ' &raquo; ';
if ( $i < ( $nbtaglines - 1 ) ) {
if ( $i < ( $nbtaglines - 1 ) && $i < ( $nbtotaltaglines - 1 ) ) {
$output .= ', '; // add comma to every quote but the last
}

Expand Down Expand Up @@ -1004,8 +1017,8 @@ private function lumiere_movies_trailer( \Imdb\Title $movie ): string {

}

if ( ( $i < ( $nbtrailers - 1 ) ) && ( $i < ( $nbtotaltrailers - 1 ) ) ) {
$output .= ', '; // add comma to every quote but the last
if ( $i < ( $nbtrailers - 1 ) && $i < ( $nbtotaltrailers - 1 ) ) {
$output .= ', '; // add comma to every trailer but the last.
}
}

Expand Down Expand Up @@ -1035,7 +1048,7 @@ private function lumiere_movies_color( \Imdb\Title $movie ): string {
$output .= sprintf( esc_attr( _n( 'Color', 'Colors', $nbtotalcolors, 'lumiere-movies' ) ), number_format_i18n( $nbtotalcolors ) );
$output .= ':</span>';

// Taxonomy
// Taxonomy activated.
if ( ( $this->imdb_admin_values['imdbtaxonomy'] === '1' ) && ( $this->imdb_widget_values['imdbtaxonomycolor'] === '1' ) ) {

for ( $i = 0; $i < $nbtotalcolors; $i++ ) {
Expand All @@ -1047,18 +1060,18 @@ private function lumiere_movies_color( \Imdb\Title $movie ): string {

}

// No taxonomy
} else {
return $output;

$count_colors = count( $colors );
for ( $i = 0; $i < $count_colors; $i++ ) {
}

$output .= "\n\t\t\t" . sanitize_text_field( $colors[ $i ] );
if ( $i < $nbtotalcolors - 1 ) {
$output .= ', ';
}
}
// No taxonomy.
$count_colors = count( $colors );
for ( $i = 0; $i < $count_colors; $i++ ) {

$output .= "\n\t\t\t" . sanitize_text_field( $colors[ $i ] );
if ( $i < $nbtotalcolors - 1 ) {
$output .= ', ';
}
}

return $output;
Expand All @@ -1075,10 +1088,10 @@ private function lumiere_movies_alsoknow( \Imdb\Title $movie ): string {
$output = '';
$alsoknow = $movie->alsoknow();
$nbalsoknow = intval( $this->imdb_widget_values['imdbwidgetalsoknownumber'] ) === 0 || $this->imdb_widget_values['imdbwidgetalsoknownumber'] === false ? '1' : intval( $this->imdb_widget_values['imdbwidgetalsoknownumber'] );
$nbtotalalsoknow = intval( count( $alsoknow ) );
$nbtotalalsoknow = count( $alsoknow );

// if no result, exit.
if ( count( $alsoknow ) === 0 ) {
if ( $nbtotalalsoknow === 0 ) {

return $output;

Expand All @@ -1102,7 +1115,7 @@ private function lumiere_movies_alsoknow( \Imdb\Title $movie ): string {
$output .= ' )';
}

if ( ( $i < ( $nbtotalalsoknow - 1 ) ) && ( $i < ( $nbalsoknow - 1 ) ) ) {
if ( $i < ( $nbtotalalsoknow - 1 ) && $i < ( $nbalsoknow - 1 ) ) {
$output .= ', ';
}

Expand Down Expand Up @@ -1692,7 +1705,7 @@ private function lumiere_movies_plot( \Imdb\Title $movie ): string {

}

if ( $i < ( ( $i < ( $nbtotalplots - 1 ) ) && ( $i < ( $nbplots - 1 ) ) ) ) {
if ( $i < ( $nbtotalplots - 1 ) && $i < ( $nbplots - 1 ) ) {
$output .= "\n<hr>\n";
} // add hr to every quote but the last
}
Expand Down
1 change: 1 addition & 0 deletions src/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ v.3.6.3
* [bug] Function to detect of whether a Lumiere widget is active was broken. Fixed lumiere_block_widget_isactive() in class-utils.php
* [bug] Biography length was not correctly counted and led to text being cut early. Added new condition for $esc_html_breaker in lumiere_medaillon_bio() in class-frontend.php
* [bug] Picture link url in taxonomy page for people was not built. Fixed class-taxonomy-people-standard.php
* [bug] Tagline's, Quote's commas were not display accurately and the last tagline displayed was taking wrongfully a comma. Plot's breaking lines <hr> were not displayed after the second result. Fixed the methods in class movie.

v.3.6.2
* [bug] On some configurations, the creations of cache folder could lead to a fatal error. Switched from WordPress builtin $wp_system functions to PHP core functions in method lumiere_create_cache() in class-settings.php.
Expand Down
Loading

0 comments on commit 7182d2f

Please sign in to comment.