Plugin Directory

Changeset 2279493


Ignore:
Timestamp:
04/08/2020 04:51:54 PM (6 years ago)
Author:
imageengine
Message:

Fixed empty content bug when plugin is disabled

Location:
image-cdn/trunk
Files:
3 edited

Legend:

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

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

    r2267011 r2279493  
    2525     */
    2626    public function __construct() {
    27         // Rewriter hook.
    28         add_action( 'template_redirect', array( self::class, 'handle_rewrite_hook' ) );
    29 
    30         // Rewrite rendered content in REST API.
    31         add_filter( 'the_content', array( self::class, 'rewrite_the_content' ), 100 );
    32 
    33         // Resource hints.
    34         add_action( 'wp_head', array( self::class, 'add_head_tags' ), 0 );
     27
     28        // Only enable the hooks if the configuration is valid and the plugin is enabled.
     29        if ( self::should_rewrite() ) {
     30            // Rewriter hook.
     31            add_action( 'template_redirect', array( self::class, 'handle_rewrite_hook' ) );
     32
     33            // Rewrite rendered content in REST API.
     34            add_filter( 'the_content', array( self::class, 'rewrite_the_content' ), 100 );
     35
     36            // Resource hints.
     37            add_action( 'wp_head', array( self::class, 'add_head_tags' ), 0 );
     38        }
    3539
    3640        // Hooks.
     
    4751     */
    4852    public static function add_head_tags() {
    49         if ( ! self::should_rewrite() ) {
    50             return;
    51         }
    52 
    5353        // Add client hints.
    5454        echo '    <meta http-equiv="Accept-CH" content="DPR, Viewport-Width, Width, Save-Data">' . "\n";
     
    209209     */
    210210    public static function handle_rewrite_hook() {
    211         if ( ! self::should_rewrite() ) {
    212             return false;
    213         }
    214 
    215211        $rewriter = self::get_rewriter();
    216212        ob_start( array( $rewriter, 'rewrite' ) );
     
    223219     */
    224220    public static function rewrite_the_content( $html ) {
    225         if ( ! self::should_rewrite() ) {
    226             return false;
    227         }
    228 
    229221        $rewriter = self::get_rewriter();
    230222        return $rewriter->rewrite( $html );
  • image-cdn/trunk/readme.txt

    r2267011 r2279493  
    7272== Changelog ==
    7373
     74= 1.0.1 =
     75* Fixed issue with blank content rendering
     76
     77= 1.0.0 =
     78* Initial stable release
     79
    7480= 0.9.0 =
    7581* Initial beta release
Note: See TracChangeset for help on using the changeset viewer.