PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.2
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.2
4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 All 200 releases
← All changes | includes/Editors/BlockEditor/FontLoader.php +75 -61 3.4.04.9.2 View file →
@@ -1,75 +1,89 @@
1 1 <?php
2 +namespace WPDeveloper\BetterDocs\Editors\BlockEditor;
2 3
3 -namespace WPDeveloper\BetterDocs\Editors\BlockEditor;
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
4 7
8 +
5 9 use WPDeveloper\BetterDocs\Utils\Base;
6 10
7 11 class FontLoader extends Base {
8 12
9 - public static $registered_blocks = [
10 - 'betterdocs/betterdocs-print',
11 - 'betterdocs/breadcrumb',
12 - 'betterdocs/categorybox',
13 - 'betterdocs/categorygrid',
14 - 'betterdocs/archive-doc-list',
15 - 'betterdocs/single-doc-content',
16 - 'betterdocs/date',
17 - 'betterdocs/doc-navigation',
18 - 'betterdocs/feedback-form',
19 - 'betterdocs/reactions',
20 - 'betterdocs/searchbox',
21 - 'betterdocs/sidebar',
22 - 'betterdocs/social-share',
23 - 'betterdocs/table-of-contents',
24 - 'betterdocs/multiple-kb'
25 - ];
13 + public static $registered_blocks = [
14 + 'betterdocs/betterdocs-print',
15 + 'betterdocs/breadcrumb',
16 + 'betterdocs/categorybox',
17 + 'betterdocs/categorygrid',
18 + 'betterdocs/category-slate-layout',
19 + 'betterdocs/archive-doc-list',
20 + 'betterdocs/single-doc-content',
21 + 'betterdocs/date',
22 + 'betterdocs/doc-navigation',
23 + 'betterdocs/feedback-form',
24 + 'betterdocs/reactions',
25 + 'betterdocs/searchbox',
26 + 'betterdocs/sidebar',
27 + 'betterdocs/social-share',
28 + 'betterdocs/table-of-contents',
29 + 'betterdocs/multiple-kb',
30 + 'betterdocs/betterdocs-encyclopedia',
31 + 'betterdocs/glossary-single-template',
32 + 'betterdocs/faq',
33 + 'betterdocs/multiple-kb-tab',
34 + 'betterdocs/categoryhandbook',
35 + 'betterdocs/popular-docs',
36 + 'betterdocs/related-categories',
37 + 'betterdocs/code-snippet',
38 + 'betterdocs/article-summary'
39 + ];
26 40
27 - public static $retrieved_fonts = [];
41 + public static $retrieved_fonts = [];
28 42
29 - public function __construct() {
30 - add_filter( 'render_block', [$this, 'get_betterdocs_blocks'], 10, 2 );
31 - add_action( 'wp_footer', [$this, 'enqueue_google_fonts'], 10 );
32 - }
43 + public function __construct() {
44 + add_filter( 'render_block', [ $this, 'get_betterdocs_blocks' ], 10, 2 );
45 + add_action( 'wp_footer', [ $this, 'enqueue_google_fonts' ], 10 );
46 + }
33 47
34 - public function get_betterdocs_blocks( $block_content, $block ) {
35 - if ( isset( $block['attrs'] ) ) {
36 - if ( in_array( $block['blockName'], self::$registered_blocks ) ) {
37 - $fonts = self::get_fonts_family( $block['attrs'] );
38 - self::$retrieved_fonts = array_unique( array_merge( self::$retrieved_fonts, $fonts ) );
39 - }
40 - }
48 + public function get_betterdocs_blocks( $block_content, $block ) {
49 + if ( isset( $block['attrs'] ) ) {
50 + if ( in_array( $block['blockName'], self::$registered_blocks ) ) {
51 + $fonts = self::get_fonts_family( $block['attrs'] );
52 + self::$retrieved_fonts = array_unique( array_merge( self::$retrieved_fonts, $fonts ) );
53 + }
54 + }
41 55
42 - return $block_content;
43 - }
56 + return $block_content;
57 + }
44 58
45 - public static function get_fonts_family( $attributes ) {
46 - $keys = preg_grep( '/^(\w+)FontFamily/i', array_keys( $attributes ), 0 );
47 - $google_font_family = [];
48 - foreach ( $keys as $key ) {
49 - $google_font_family[$attributes[$key]] = $attributes[$key];
50 - }
51 - return $google_font_family;
52 - }
59 + public static function get_fonts_family( $attributes ) {
60 + $keys = preg_grep( '/^(\w+)FontFamily/i', array_keys( $attributes ), 0 );
61 + $google_font_family = [];
62 + foreach ( $keys as $key ) {
63 + $google_font_family[ $attributes[ $key ] ] = $attributes[ $key ];
64 + }
65 + return $google_font_family;
66 + }
53 67
54 - public function enqueue_google_fonts() {
55 - if( ! empty( self::$retrieved_fonts ) ) {
56 - $google_fonts = '';
57 - $google_fonts_attr = ':100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic';
58 - foreach ( self::$retrieved_fonts as $font ) {
59 - $google_fonts .= str_replace( ' ', '+', trim( $font ) ) . $google_fonts_attr . '|';
60 - }
61 - if ( ! empty( $google_fonts ) ) {
62 - $query_args = [
63 - 'family' => $google_fonts
64 - ];
65 - wp_register_style(
66 - 'betterdocs-goggle-fonts',
67 - add_query_arg( $query_args, '//fonts.googleapis.com/css' ),
68 - [],
69 - betterdocs()->version
70 - );
71 - wp_enqueue_style( 'betterdocs-goggle-fonts' );
72 - }
73 - }
74 - }
68 + public function enqueue_google_fonts() {
69 + if ( ! empty( self::$retrieved_fonts ) ) {
70 + $google_fonts = '';
71 + $google_fonts_attr = ':100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic';
72 + foreach ( self::$retrieved_fonts as $font ) {
73 + $google_fonts .= str_replace( ' ', '+', trim( $font ) ) . $google_fonts_attr . '|';
74 + }
75 + if ( ! empty( $google_fonts ) ) {
76 + $query_args = [
77 + 'family' => $google_fonts
78 + ];
79 + wp_register_style(
80 + 'betterdocs-goggle-fonts',
81 + add_query_arg( $query_args, '//fonts.googleapis.com/css' ),
82 + [],
83 + betterdocs()->version
84 + );
85 + wp_enqueue_style( 'betterdocs-goggle-fonts' );
86 + }
87 + }
88 + }
75 89 }