themeum / kirki

Extending the customizer
https://kirki.org
MIT License
1.26k stars 327 forks source link

Typography Control saves a new font file on every page refresh #2182

Closed onuro closed 5 years ago

onuro commented 5 years ago

Issue description:

Hey Ari!

After the latest update, Kirki creates a new file to the uploads folder and calls that new file for the selected Google Font on every page change or refresh, causing a huge page load performance issue.

I've observed this on the existing WordPress installations. With a fresh WP installation it seems fine.

Version used:

3.0.43

Using theme_mods or options?

options

Screen Shot 2019-06-21 at 21 24 25

DannyCooper commented 5 years ago

Hi @onuro,

Could you share the following information:

Thanks

onuro commented 5 years ago

Hey, sure.

Site Info:

`

wp-core

version: 5.2.2 site_language: en_US user_language: en_US permalink: /%year%/%monthnum%/%day%/%postname%/ https_status: false user_registration: 0 default_comment_status: open multisite: false user_count: 2 dotorg_communication: true

wp-paths-sizes

wordpress_path: /app/public wordpress_size: loading... uploads_path: /app/public/wp-content/uploads uploads_size: loading... themes_path: /app/public/wp-content/themes themes_size: loading... plugins_path: /app/public/wp-content/plugins plugins_size: loading... database_size: loading... total_size: loading...

wp-active-theme

name: GutenBooster version: 1.0.0 author: Kioken Theme author_website: https://kiokentheme.com parent_theme: none theme_features: editor-style, editor-styles, dark-theme, align-wide, wp-block-styles, responsive-embeds, editor-color-palette, automatic-feed-links, title-tag, woocommerce, wc-product-gallery-lightbox, wc-product-gallery-zoom, wc-product-gallery-slider, post-formats, menus, html5, customize-selective-refresh-widgets, post-thumbnails, widgets theme_path: /app/public/wp-content/themes/gutenbooster

wp-themes (13)

Frontenberg: version: 1.1, author: Tom J Nowell Ascension: version: 1.1.5, author: GoDaddy Bavarian Child: version: 1.0.0, author: Kioken Theme Bavarian: version: 1.0.1, author: Kioken Theme CoBlocks: version: 1.2.4, author: CoBlocks Gutenwp: version: 1.1.0, author: Themeum OceanWP: version: 1.6.8, author: Nick Primer: version: 1.8.6, author: GoDaddy Salient: version: 9.0.1, author: ThemeNectar Sober: version: 2.0.22, author: UIX Themes Stockholm: version: 4.5, author: Select Themes Super 5: version: 1.0.2, author: Theme Kioken Twenty Nineteen: version: 1.4, author: the WordPress team

wp-plugins-active (6)

Kirki Customizer Framework: version: 3.0.43, author: Ari Stathopoulos (@aristath)

wp-plugins-inactive (25)

Advanced WordPress Backgrounds: version: 1.5.8, author: nK Akismet Anti-Spam: version: 4.1.2, author: Automattic Atomic Blocks - Gutenberg Blocks Collection: version: 1.8.1, author: atomicblocks Blocks Export Import: version: 1.0.0, author: ThemeIsle CoBlocks: version: 1.10.0, author: GoDaddy Contact Form 7: version: 5.1.3, author: Takayuki Miyoshi Customizer Reset: version: 1.0.1, author: WPZOOM Envato Theme Check: version: 20180222, author: Scott Parry Essential Blocks: version: 1.1.2, author: WPDeveloper Ghost Kit: version: 2.4.2, author: nK Instant Images: version: 4.0.1, author: Darren Cooney One Click Demo Import: version: 2.5.1, author: ProteusThemes Qubely Blocks - Full-fledged Gutenberg Toolkit: version: 1.0.0, author: Themeum.com Regenerate Thumbnails: version: 3.1.1, author: Alex Mills (Viper007Bond) Safe SVG: version: 1.9.4, author: Daryll Doyle Stackable - Gutenberg Blocks: version: 1.15.5, author: Gambit Technologies, Inc Ultimate Addons for Gutenberg: version: 1.13.3, author: Brainstorm Force Visual Portfolio: version: 1.12.0, author: nK WE Blocks - Image, Testimonial And Logo Slider Gutenberg Blocks: version: 1.1, author: WORDPRESTEEM WooCommerce: version: 3.6.4, author: Automattic WordPress Beta Tester: version: 2.0.4, author: Peter Westwood, Andy Fragen WP Block Pack: version: 1.1.0, author: Falcon Theme WP Instagram Widget: version: 2.0.3, author: Scott Evans WP Reset: version: 1.60, author: WebFactory Ltd

wp-media

image_editor: WP_Image_Editor_Imagick imagick_module_version: 1673 imagemagick_version: ImageMagick 6.8.9-9 Q16 x86_64 2018-05-18 http://www.imagemagick.org imagick_limits: imagick::RESOURCETYPE_AREA: 2 GB imagick::RESOURCETYPE_DISK: -1 imagick::RESOURCETYPE_FILE: 786432 imagick::RESOURCETYPE_MAP: 2 GB imagick::RESOURCETYPE_MEMORY: 996 MB imagick::RESOURCETYPE_THREAD: 1 gd_version: bundled (2.1.0 compatible) ghostscript_version: 9.06

wp-server

server_architecture: Linux 4.9.93-boot2docker x86_64 httpd_software: nginx/1.10.1 php_version: 7.2.0 64bit php_sapi: fpm-fcgi max_input_variables: 3000 time_limit: 900 memory_limit: 256M max_input_time: -1 upload_max_size: 1000M php_post_max_size: 1000M curl_version: 7.38.0 OpenSSL/1.0.1t suhosin: false imagick_availability: true

wp-database

extension: mysqli server_version: 5.6.34 client_version: mysqlnd 5.0.12-dev - 20150407 - $Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $

wp-constants

WP_HOME: undefined WP_SITEURL: undefined WP_CONTENT_DIR: /app/public/wp-content WP_PLUGIN_DIR: /app/public/wp-content/plugins WP_MAX_MEMORY_LIMIT: 256M WP_DEBUG: true WP_DEBUG_DISPLAY: true WP_DEBUG_LOG: false SCRIPT_DEBUG: false WP_CACHE: false CONCATENATE_SCRIPTS: undefined COMPRESS_SCRIPTS: undefined COMPRESS_CSS: undefined WP_LOCAL_DEV: undefined

wp-filesystem

wordpress: writable wp-content: writable uploads: writable plugins: writable themes: writable

`

onuro commented 5 years ago

And following is my typography control array:

//headings font
        'font_heading'      => array(
            'type'        => 'typography',
            'label'       => esc_html__( 'Headings Typography', 'gutenbooster' ),
            'description'       => esc_html__( 'Select the default font for headings. Default is Poppins', 'gutenbooster' ),
            'section'     => 'typo_headings',
            'transport'     => 'auto',
            'default'     => array(
                'font-family'    => 'Poppins',
                'variant'        => '600',
                'letter-spacing'  => '',
                'text-transform'  => 'none',
                'color'  => get_theme_mod('color_gb_secondary') ? get_theme_mod('color_gb_secondary') : $color_secondary,
            ),
            'choices' => [
                    'fonts' => [
                        'google'   => [ 'popularity', $gFontsNumber ],
                        'standard' => [
                            'Georgia,Times,"Times New Roman",serif',
                            '"Poppins", Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif',
                            'Raleway, "Helvetica Neue", sans-serif',
                        ],
                    ],
                    'variant' => $heading_std !== '' && $heading_std !== 'Poppins' ? [ 'regular','italic','100','200','300','400','500','600','700','800','900', ] : [],
            ],
            'output'      => [
                [
                    'element'  => array(
                        'h1',
                        'h2',
                        'h3',
                        'h4',
                        'h5',
                        'h6',
                        '.comment article .comment-meta .author-name',
                        '.comment article .comment-meta .author-name a',
                    ),
                ],
            ],
        ),
DannyCooper commented 5 years ago

I understand now, it's because the plugin bypasses the transient when WP_DEBUG is true. It's not a very sane action as it re-downloads the font files on every page load.

@aristath we should ignore WP_DEBUG and only trigger the re-download on ( ! empty( $_GET['action'] ) && 'kirki-reset-cache' === $_GET['action'] )

aristath commented 5 years ago

Yeah, I was just looking into this too, and WP_DEBUG does seem like the most reasonable cause for this. I agree, we should remove that check. @DannyCooper I was thinking that we may also want to use options instead of transients to store the local font URLs... Some hosts do non-standard things with transients ans they are not as reliable

DannyCooper commented 5 years ago

https://github.com/aristath/kirki/commit/12fab555c4c389da4121daef987820637de4dea3 works for me, appears to be backwards compatible too 👍.

onuro commented 5 years ago

Cheers fellas! So the commit is coming w the next plugin update yeah

aristath commented 5 years ago

fixed in v3.0.44