Plugin Directory

Changeset 2318196


Ignore:
Timestamp:
06/04/2020 01:57:39 PM (6 years ago)
Author:
imageengine
Message:

added CH and FP

Location:
image-cdn/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • image-cdn/trunk/image-cdn.php

    r2279493 r2318196  
    77 * Author URI: https://imageengine.io/
    88 * License: GPLv2 or later
    9  * Version: 1.0.1
     9 * Version: 1.0.3
    1010 */
    1111
  • image-cdn/trunk/imageengine/class-imagecdn.php

    r2279493 r2318196  
    3535
    3636            // Resource hints.
    37             add_action( 'wp_head', array( self::class, 'add_head_tags' ), 0 );
     37            //add_action( 'wp_head', array( self::class, 'add_head_tags' ), 0 );
     38      add_action( 'send_headers', array( self::class, 'add_headers' ), 0 );
    3839        }
    3940
     
    4647        add_filter( 'plugin_action_links_' . IMAGE_CDN_BASE, array( self::class, 'add_action_link' ) );
    4748    }
     49
     50    /**
     51     * Add http headers for Client Hints, Feature Policy and Preconnect Resource Hint.
     52     */
     53    public static function add_headers() {
     54        // Add client hints.
     55        header( 'Accept-CH: viewport-width, width, device-memory, dpr, rtt, downlink, ect' );
     56
     57        // Add resource hints and feature policy.
     58        $options = self::get_options();
     59        $host    = wp_parse_url( $options['url'], PHP_URL_HOST );
     60        if ( ! empty( $host ) ) {
     61            $protocol = (is_ssl()) ? "https://" : "http://";
     62        header( 'Link: <'.$protocol.$host.'>; rel=preconnect' );
     63        header( 'Feature-Policy: ch-viewport-width '.$protocol.$host.'; ch-width '.$protocol.$host.'; ch device-memory '.$protocol.$host.'; ch-dpr '.$protocol.$host.'; ch-rtt '.$protocol.$host.'; ch-downlink '.$protocol.$host.'; ch-ect '.$protocol.$host.';' );
     64        }
     65    }
     66
    4867
    4968    /**
  • image-cdn/trunk/readme.txt

    r2295220 r2318196  
    120120== Changelog ==
    121121
     122= 1.0.3 =
     123* Support for Client Hints and Feature Policy
     124
    122125= 1.0.2 =
    123126* Updated readme with better documentation
  • image-cdn/trunk/templates/settings.php

    r2295220 r2318196  
    2121        <p><?php esc_html_e( 'To obtain an ImageEngine CDN hostname' ); ?>:</p>
    2222        <ol>
    23             <li><a target="_blank" href="https://imageengine.io/signup/?utm_source=WP-plugin-settigns&utm_medium=page&utm_term=wp-imageengine&utm_campaign=wp-imageengine">Sign up for an ImageEngine account</a></li>
     23            <li><a target="_blank" href="https://imageengine.io/signup/?website=<?php echo get_site_url();?>&?utm_source=WP-plugin-settigns&utm_medium=page&utm_term=wp-imageengine&utm_campaign=wp-imageengine">Sign up for an ImageEngine account</a></li>
    2424            <li>
    2525            <?php
Note: See TracChangeset for help on using the changeset viewer.