Plugin Directory

Changeset 1794220


Ignore:
Timestamp:
12/29/2017 02:48:58 PM (8 years ago)
Author:
bulledev
Message:

Tag V1.0 and update to 1.1

Location:
ttfb-toolkit
Files:
50 added
3 edited

Legend:

Unmodified
Added
Removed
  • ttfb-toolkit/trunk/includes/performance/lazyload.php

    r1790790 r1794220  
    7373
    7474/*
    75 * Detect on page lazyload disabled
    76 */
    77 add_action('wp', 'ttfb_toolkit_on_page_lazyload_off');
    78 function ttfb_toolkit_on_page_lazyload_off(){
     75* Detect on page lazyload disabled for image
     76*/
     77add_action('wp', 'ttfb_toolkit_on_page_lazyload_image_disabled');
     78function ttfb_toolkit_on_page_lazyload_image_disabled(){
    7979    if( !is_page() && !is_single() ){ return; }
    8080
    8181    global $post;
    8282    if( is_object( $post ) && get_post_meta($post->ID, 'ttfb_toolkit_options_disable_image_lazy_load', true) ){
    83         add_filter( 'do_ttfb_toolkit_lazyload', '__return_false' );
     83        add_filter( 'do_ttfb_toolkit_lazyload_image', '__return_false' );
     84    }
     85}
     86
     87/*
     88* Detect on page lazyload disabled for iframe
     89*/
     90add_action('wp', 'ttfb_toolkit_on_page_lazyload_iframe_disabled');
     91function ttfb_toolkit_on_page_lazyload_iframe_disabled(){
     92    if( !is_page() && !is_single() ){ return; }
     93
     94    global $post;
     95    if( is_object( $post ) && get_post_meta($post->ID, 'ttfb_toolkit_options_disable_iframe_lazy_load', true) ){
     96        add_filter( 'do_ttfb_toolkit_lazyload_iframe', '__return_false' );
    8497    }
    8598}
     
    99112
    100113    if ( ! get_option('ttfb_toolkit_perf_lazyload_img', false) ||
    101             ! apply_filters( 'do_ttfb_toolkit_lazyload', true ) ||
     114            ! apply_filters( 'do_ttfb_toolkit_lazyload_image', true ) ||
    102115            is_admin() ||
    103116            ttfb_toolkit_is_rest() ) {
     
    180193 */
    181194add_filter( 'the_content', 'ttfb_toolkit_lazyload_iframes', PHP_INT_MAX );
    182 add_filter( 'widget_text', 'ttfb_toolkit_lazyload_iframes', PHP_INT_MAX );
     195//add_filter( 'widget_text', 'ttfb_toolkit_lazyload_iframes', PHP_INT_MAX );
    183196function ttfb_toolkit_lazyload_iframes( $html ) {
    184197
    185198    if ( ! get_option('ttfb_toolkit_perf_lazyload_iframe', false) ||
    186         ! apply_filters( 'do_ttfb_toolkit_lazyload', true ) ||
     199        ! apply_filters( 'do_ttfb_toolkit_lazyload_iframe', true ) ||
    187200        is_search() ||
    188201        is_admin() ) {
     
    190203    }
    191204
    192     global $post;
    193 
    194205    $matches = array();
    195206    preg_match_all( '/<iframe\s+.*?>/', $html, $matches );
     
    197208    foreach ( $matches[0] as $k=>$iframe ) {
    198209
    199         // Don't mess with the Gravity Forms ajax iframe
    200         if ( strpos( $iframe, 'gform_ajax_frame' ) ) {
     210       
     211        if ( strpos( $iframe, 'gform_ajax_frame' ) || // Don't mess with the Gravity Forms ajax iframe
     212        strpos( $iframe, 'data-src' ) ) { // Don't mess with already lazy iframe
    201213            continue;
    202214        }
     
    204216        $placeholder = 'data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=';
    205217
    206         $iframe = preg_replace( '/<iframe(.*?)src=/is', '<iframe$1src="' . $placeholder . '" class="lazyload blur-up" data-src=', $iframe );
     218        $iframe = preg_replace( '/<iframe(.*?)src=/is', '<iframe$1src="' . $placeholder . '" class="lazyload" data-src=', $iframe );
    207219
    208220        $html = str_replace( $matches[0][ $k ], $iframe, $html );
     
    211223   
    212224
    213     return $html;
     225    return $html;
    214226}
    215227
     
    217229add_action("wp_head","ttfb_toolkit_lazyload_picturefill");
    218230function ttfb_toolkit_lazyload_picturefill(){
    219     if ( ( ! get_option('ttfb_toolkit_perf_lazyload_img', false) && ! get_option('ttfb_toolkit_perf_lazyload_iframe', false) ) || ! apply_filters( 'do_ttfb_toolkit_lazyload', true ) ) {
     231    if(
     232        ( ! get_option('ttfb_toolkit_perf_lazyload_img', false) && ! get_option('ttfb_toolkit_perf_lazyload_iframe', false) ) ||
     233        ( !apply_filters('do_ttfb_toolkit_lazyload_image', true) && !apply_filters('do_ttfb_toolkit_lazyload_iframe', true) ) ) {
    220234        return;
    221235    }
  • ttfb-toolkit/trunk/includes/performance/performance-init.php

    r1790790 r1794220  
    1616        'capability' => 'edit_theme_options',
    1717    ) );
     18}
     19
     20/**
     21 * Performance Panel Customizer Styles
     22 */
     23add_action( 'customize_controls_print_styles', 'ttfb_toolkit_performance_panel_styles', 999 );
     24function ttfb_toolkit_performance_panel_styles() { ?>
     25    <style>
     26        li#accordion-panel-ttfb_toolkit_performance > h3.accordion-section-title:before {
     27            content: "\f226";
     28            font-family: dashicons;
     29            padding: 0 3px 0 0;
     30            vertical-align: middle;
     31            font-size: 22px;
     32            line-height: 1;
     33        }
     34    </style>
     35    <?php
    1836}
    1937
  • ttfb-toolkit/trunk/readme.txt

    r1790790 r1794220  
    66Requires at least: 4.6
    77Tested up to: 4.9
    8 Stable tag: 1.0
     8Stable tag: 1.1
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3333
    3434==Changelog==
     35= v1.1 - December 29, 2017 =
     36* Fix - Iframe lazy load.
     37* Fix - Add missing performance icon
     38
    3539= v1.0 - December 20, 2017 =
    3640* Original Release.
Note: See TracChangeset for help on using the changeset viewer.