diff --git a/inc/Framework.php b/inc/Framework.php index 95267cc0..810d3c06 100644 --- a/inc/Framework.php +++ b/inc/Framework.php @@ -4,6 +4,7 @@ use BEA\Theme\Framework\Services\Acf; use BEA\Theme\Framework\Services\Assets; +use BEA\Theme\Framework\Services\Facet_WP; use BEA\Theme\Framework\Services\Performance; use BEA\Theme\Framework\Services\Assets_JS_Async; use BEA\Theme\Framework\Services\Editor; @@ -40,6 +41,7 @@ class Framework { Svg::class, Acf::class, Menu::class, + Facet_WP::class, // Services as Tools Body_Class::class, diff --git a/inc/Services/Facet_WP.php b/inc/Services/Facet_WP.php new file mode 100644 index 00000000..2825c460 --- /dev/null +++ b/inc/Services/Facet_WP.php @@ -0,0 +1,234 @@ + 1, + 'per_page' => 10, + 'total_rows' => 1, + ]; + $params = array_merge( $defaults, $params ); + $output = ''; + $page = (int) $params['page']; + $total_pages = (int) $params['total_pages']; + + // Only show pagination when > 1 page + if ( 1 < $total_pages ) { + + $text_page = esc_html__( 'Page', 'fwp-front' ); + $text_of = esc_html__( 'of', 'fwp-front' ); + $step = 10; + + $output .= '' . "$text_page $page $text_of $total_pages"; + + if ( $page > 1 ) { + $output .= sprintf( + '', + ( $page - 1 ) + ); + } else { + $output .= ''; + } + + if ( 3 < $page ) { + $output .= sprintf( + '', + __( 'First page', 'framework-textdomain' ) + ); + } + + if ( 1 < ( $page - $step ) ) { + $output .= ''; + } + + for ( $i = 2; $i > 0; $i -- ) { + if ( 0 < ( $page - $i ) ) { + $output .= ''; + } + } + + // Current page + $output .= '' . __( 'Current page', 'framework-textdomain' ) . ' ' . $page . ''; + + for ( $i = 1; $i <= 2; $i ++ ) { + if ( $total_pages >= ( $page + $i ) ) { + $output .= ''; + } + } + + if ( $total_pages > ( $page + $step ) ) { + $output .= ''; + } + + if ( $total_pages > ( $page + 2 ) ) { + $output .= sprintf( + '', + $total_pages, + __( 'Last page', 'framework-textdomain' ) + ); + } + + if ( $page < $total_pages && $total_pages > 1 ) { + $output .= ''; + } else { + $output .= ''; + } + } + + return $output; + } + + /** + * Customize pagination facet output + * This function apply only on pagination facets : facetwp_display( 'facet', 'pagination' ); + * For customization of the old way to display a pager, see accessible_facetwp_pager_html function. + * + * https://facetwp.com/help-center/developers/hooks/output-hooks/facetwp_facet_pager_link/ + * + * @param $output + * @param $params + * + * @return string + * + * @author Marie Comet + * + */ + public function facetwp_facet_pager_link( $html, $params ): string { + // Replace current link by a span + if ( str_contains( $html, 'active' ) ) { + $html = str_replace( '', '', $html ); + } + + // Replace links by buttons and add class + $html = str_replace( [ '' ], $html ); + + // Remove link tag for dots + if ( 'dots' === $params['extra_class'] ) { + $html = str_replace( '', '', $html ); + } + + return $html; + } + + /** + * Add labels or aria-label to facets + * Put in $excluded_facet_names the facets names for which you want to do not add the label. + * Put in $excluded_empty_facets the facets types for which you want to hide the label if the facet is empty. + * + * @param string $html + * @param array $args + * + * @return string + */ + public function facetwp_add_labels( string $html, array $args ): string { + $facet_name = $args['facet']['name']; + $facet_label = $args['facet']['label']; + if ( function_exists( 'facetwp_i18n' ) ) { + $facet_label = facetwp_i18n( $facet_label ); + } + + // Return default HTML if the facet is excluded by its name + $excluded_facet_names = apply_filters( 'facetwp_a11y_excluded_facet_names', [] ); + if ( in_array( $facet_name, $excluded_facet_names, true ) ) { + return $html; + } + + // Add aria-label attribute to per_page select + if ( 'per_page' === $facet_name ) { + return str_replace( + '', + esc_attr( $facet_label ) + ), + $html + ); + } + + // Return default HTML if these facets are empty + $excluded_empty_facets = apply_filters( 'facetwp_a11y_excluded_empty_facets', [ + 'checkboxes', + 'pager', + 'reset', + ] ); + if ( in_array( $args['facet']['type'], $excluded_empty_facets, true ) && empty( $args['values'] ) ) { + return $html; + } + + // Add fake labels + return sprintf( '%s', esc_html( $facet_label ), $html ); + } +} diff --git a/languages/beapi-frontend-framework.pot b/languages/beapi-frontend-framework.pot index dadf78be..41f2ef70 100644 --- a/languages/beapi-frontend-framework.pot +++ b/languages/beapi-frontend-framework.pot @@ -1,4 +1,4 @@ -# Copyright (C) 2022 BeAPI +# Copyright (C) 2024 BeAPI # This file is distributed under the . msgid "" msgstr "" @@ -9,10 +9,10 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2022-06-30T08:09:55+00:00\n" +"POT-Creation-Date: 2024-03-04T09:37:43+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"X-Generator: WP-CLI 2.6.0\n" -"X-Domain: beapi-frontend-framework\n" +"X-Generator: WP-CLI 2.9.0\n" +"X-Domain: framework-textdomain\n" #. Theme Name of the theme #. Description of the theme @@ -31,123 +31,32 @@ msgstr "" msgid "http://www.beapi.fr" msgstr "" -#: components/blocks/footer.php:4 -#: components/blocks/skip-links.php:12 -msgid "Footer" +#: inc/Services/Acf.php:55 +msgid "This theme can't work without ACF plugin. Please login to admin, and activate it !" msgstr "" -#: components/blocks/header.php:4 -msgid "Header" +#: inc/Services/Facet_WP.php:93 +msgid "Previous" msgstr "" -#: components/blocks/header.php:14 -msgid "Open/Close the menu" +#: inc/Services/Facet_WP.php:110 +#: inc/Services/Facet_WP.php:119 +msgid "Page" msgstr "" -#: components/blocks/header.php:17 -msgid "Main navigation" +#: inc/Services/Facet_WP.php:115 +msgid "Current page" msgstr "" -#: components/blocks/skip-links.php:4 -msgid "Fast access links" +#: inc/Services/Facet_WP.php:129 +msgid "Last page" msgstr "" -#: components/blocks/skip-links.php:6 -msgid "Main navigation menu" +#: inc/Services/Facet_WP.php:135 +msgid "Next" msgstr "" -#: components/blocks/skip-links.php:9 -#: header.php:26 -msgid "Main content" -msgstr "" - -#: inc/Helpers/Formatting/Link.php:144 -msgid "New window" -msgstr "" - -#: inc/Helpers/Formatting/Share.php:53 -msgid "Share on Facebook" -msgstr "" - -#: inc/Helpers/Formatting/Share.php:64 -msgid "Share on Twitter" -msgstr "" - -#: inc/Helpers/Formatting/Share.php:75 -msgid "Share on Linkedin" -msgstr "" - -#: inc/Helpers/Formatting/Share.php:86 -msgid "Share on Email" -msgstr "" - -#: inc/Helpers/Menu_Walker.php:26 -msgid "Toggle menu" -msgstr "" - -#: inc/Services/Editor.php:76 -msgid "Dark" -msgstr "" - -#: inc/Services/Editor.php:81 -msgid "Light" -msgstr "" - -#: inc/Services/Editor.php:86 -msgid "Primary" -msgstr "" - -#: inc/Services/Editor.php:91 -msgid "Secondary" -msgstr "" - -#: inc/Services/Editor.php:102 -msgid "Title 6" -msgstr "" - -#: inc/Services/Editor.php:108 -msgid "Title 5" -msgstr "" - -#: inc/Services/Editor.php:114 -msgid "Title 4" -msgstr "" - -#: inc/Services/Editor.php:120 -msgid "Title 3" -msgstr "" - -#: inc/Services/Editor.php:126 -msgid "Title 2" -msgstr "" - -#: inc/Services/Editor.php:132 -msgid "Title 1" -msgstr "" - -#: inc/Services/Editor_Patterns.php:40 -msgid "Common" -msgstr "" - -#. translators: %s: file name. -#: inc/Services/Editor_Patterns.php:125 -msgid "Could not register file \"%s\" as a block pattern (\"Slug\" field missing)" -msgstr "" - -#. translators: %1s: file name; %2s: slug value found. -#: inc/Services/Editor_Patterns.php:138 -msgid "Could not register file \"%1$s\" as a block pattern (invalid slug \"%2$s\")" -msgstr "" - -#. translators: %1s: file name; %2s: slug value found. -#: inc/Services/Editor_Patterns.php:155 -msgid "Could not register file \"%s\" as a block pattern (\"Title\" field missing)" -msgstr "" - -#: inc/Services/Menu.php:37 -msgid "Main menu" -msgstr "" - -#: inc/Services/Menu.php:38 -msgid "Footer menu" +#: patterns/media-text.php +msgctxt "Pattern title" +msgid "Media Text" msgstr "" diff --git a/languages/fr_FR.mo b/languages/fr_FR.mo index 78ec3186..8ac2242b 100644 Binary files a/languages/fr_FR.mo and b/languages/fr_FR.mo differ diff --git a/languages/fr_FR.po b/languages/fr_FR.po index f05cf192..83d9eba4 100644 --- a/languages/fr_FR.po +++ b/languages/fr_FR.po @@ -5,8 +5,8 @@ msgstr "" "Project-Id-Version: Be API Frontend Framework 1.0.0\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/theme/beapi-frontend-" "framework\n" -"POT-Creation-Date: 2022-06-30T08:09:55+00:00\n" -"PO-Revision-Date: 2022-07-08 17:01+0200\n" +"POT-Creation-Date: 2024-03-04T09:37:43+00:00\n" +"PO-Revision-Date: 2024-03-04 10:39+0100\n" "Last-Translator: \n" "Language-Team: \n" "Language: fr\n" @@ -14,7 +14,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -"X-Generator: Poedit 3.1\n" +"X-Generator: Poedit 3.3.2\n" "X-Domain: beapi-frontend-framework\n" #. Theme Name of the theme @@ -34,130 +34,131 @@ msgstr "" msgid "http://www.beapi.fr" msgstr "" -#: components/blocks/footer.php:4 components/blocks/skip-links.php:12 -msgid "Footer" -msgstr "Pied de Page" +#: inc/Services/Acf.php:55 +msgid "" +"This theme can't work without ACF plugin. Please login to " +"admin, and activate it !" +msgstr "" -#: components/blocks/header.php:4 -msgid "Header" -msgstr "Entête" +#: inc/Services/Facet_WP.php:93 +msgid "Previous" +msgstr "Précédent" -#: components/blocks/header.php:14 -msgid "Open/Close the menu" -msgstr "Ouvrir/Fermer le menu" +#: inc/Services/Facet_WP.php:110 inc/Services/Facet_WP.php:119 +msgid "Page" +msgstr "" -#: components/blocks/header.php:17 -msgid "Main navigation" -msgstr "Navigation principale" +#: inc/Services/Facet_WP.php:115 +msgid "Current page" +msgstr "Page courante" -#: components/blocks/skip-links.php:4 -msgid "Fast access links" -msgstr "Liens d’accès rapide" +#: inc/Services/Facet_WP.php:129 +msgid "Last page" +msgstr "Dernière page" -#: components/blocks/skip-links.php:6 -msgid "Main navigation menu" -msgstr "Menu de navigation principal" +#: inc/Services/Facet_WP.php:135 +msgid "Next" +msgstr "Suivant" -#: components/blocks/skip-links.php:9 header.php:26 -msgid "Main content" -msgstr "Contenu principal" +#: patterns/media-text.php +msgctxt "Pattern title" +msgid "Media Text" +msgstr "" -#: inc/Helpers/Formatting/Link.php:144 -msgid "New window" -msgstr "Nouvelle fenêtre" +#~ msgid "Footer" +#~ msgstr "Pied de Page" -#: inc/Helpers/Formatting/Share.php:53 -msgid "Share on Facebook" -msgstr "Partager sur Facebook" +#~ msgid "Header" +#~ msgstr "Entête" -#: inc/Helpers/Formatting/Share.php:64 -msgid "Share on Twitter" -msgstr "Partager sur Twitter" +#~ msgid "Open/Close the menu" +#~ msgstr "Ouvrir/Fermer le menu" -#: inc/Helpers/Formatting/Share.php:75 -msgid "Share on Linkedin" -msgstr "Partager sur Linkedin" +#~ msgid "Main navigation" +#~ msgstr "Navigation principale" -#: inc/Helpers/Formatting/Share.php:86 -msgid "Share on Email" -msgstr "Partager par email" +#~ msgid "Fast access links" +#~ msgstr "Liens d’accès rapide" -#: inc/Helpers/Menu_Walker.php:26 -msgid "Toggle menu" -msgstr "Ouvrir/Fermer le menu" +#~ msgid "Main navigation menu" +#~ msgstr "Menu de navigation principal" -#: inc/Services/Editor.php:76 -msgid "Dark" -msgstr "Sombre" +#~ msgid "Main content" +#~ msgstr "Contenu principal" -#: inc/Services/Editor.php:81 -msgid "Light" -msgstr "Clair" +#~ msgid "New window" +#~ msgstr "Nouvelle fenêtre" -#: inc/Services/Editor.php:86 -msgid "Primary" -msgstr "Primaire" +#~ msgid "Share on Facebook" +#~ msgstr "Partager sur Facebook" -#: inc/Services/Editor.php:91 -msgid "Secondary" -msgstr "Secondaire" +#~ msgid "Share on Twitter" +#~ msgstr "Partager sur Twitter" -#: inc/Services/Editor.php:102 -msgid "Title 6" -msgstr "Titre de niveau 6" +#~ msgid "Share on Linkedin" +#~ msgstr "Partager sur Linkedin" -#: inc/Services/Editor.php:108 -msgid "Title 5" -msgstr "Titre de niveau 5" +#~ msgid "Share on Email" +#~ msgstr "Partager par email" -#: inc/Services/Editor.php:114 -msgid "Title 4" -msgstr "Titre de niveau 4" +#~ msgid "Toggle menu" +#~ msgstr "Ouvrir/Fermer le menu" -#: inc/Services/Editor.php:120 -msgid "Title 3" -msgstr "Titre de niveau 3" +#~ msgid "Dark" +#~ msgstr "Sombre" -#: inc/Services/Editor.php:126 -msgid "Title 2" -msgstr "Titre de niveau 2" +#~ msgid "Light" +#~ msgstr "Clair" -#: inc/Services/Editor.php:132 -msgid "Title 1" -msgstr "Titre de niveau 1" +#~ msgid "Primary" +#~ msgstr "Primaire" -#: inc/Services/Editor_Patterns.php:40 -msgid "Common" -msgstr "Général" +#~ msgid "Secondary" +#~ msgstr "Secondaire" -#. translators: %s: file name. -#: inc/Services/Editor_Patterns.php:125 -msgid "" -"Could not register file \"%s\" as a block pattern (\"Slug\" field missing)" -msgstr "" -"Impossible de déclarer la composition de blocs à partir du fichier \"%s" -"\" (Le champ \"Slug\" est manquant)" +#~ msgid "Title 6" +#~ msgstr "Titre de niveau 6" -#. translators: %1s: file name; %2s: slug value found. -#: inc/Services/Editor_Patterns.php:138 -msgid "" -"Could not register file \"%1$s\" as a block pattern (invalid slug \"%2$s\")" -msgstr "" -"Impossible de déclarer la composition de blocs à partir du fichier \"%1$s" -"\" (Le slug \"%2$s\" n'est pas valide)" +#~ msgid "Title 5" +#~ msgstr "Titre de niveau 5" -#. translators: %1s: file name; %2s: slug value found. -#: inc/Services/Editor_Patterns.php:155 -msgid "" -"Could not register file \"%s\" as a block pattern (\"Title\" field missing)" -msgstr "" -"Impossible de déclarer la composition de blocs à partir du fichier \"%s" -"\" (Le champ \"Title\" est manquant)" +#~ msgid "Title 4" +#~ msgstr "Titre de niveau 4" + +#~ msgid "Title 3" +#~ msgstr "Titre de niveau 3" + +#~ msgid "Title 2" +#~ msgstr "Titre de niveau 2" + +#~ msgid "Title 1" +#~ msgstr "Titre de niveau 1" + +#~ msgid "Common" +#~ msgstr "Général" + +#~ msgid "" +#~ "Could not register file \"%s\" as a block pattern (\"Slug\" field missing)" +#~ msgstr "" +#~ "Impossible de déclarer la composition de blocs à partir du fichier " +#~ "\"%s\" (Le champ \"Slug\" est manquant)" + +#~ msgid "" +#~ "Could not register file \"%1$s\" as a block pattern (invalid slug " +#~ "\"%2$s\")" +#~ msgstr "" +#~ "Impossible de déclarer la composition de blocs à partir du fichier " +#~ "\"%1$s\" (Le slug \"%2$s\" n'est pas valide)" + +#~ msgid "" +#~ "Could not register file \"%s\" as a block pattern (\"Title\" field " +#~ "missing)" +#~ msgstr "" +#~ "Impossible de déclarer la composition de blocs à partir du fichier " +#~ "\"%s\" (Le champ \"Title\" est manquant)" -#: inc/Services/Menu.php:37 -msgid "Main menu" -msgstr "Menu principal" +#~ msgid "Main menu" +#~ msgstr "Menu principal" -#: inc/Services/Menu.php:38 -msgid "Footer menu" -msgstr "Menu pied de page" +#~ msgid "Footer menu" +#~ msgstr "Menu pied de page"