diff --git a/camo-image-proxy.php b/camo-image-proxy.php index 35251e02dd967538d7ef36296b5a8124d4be9e1d..8ea8e5b240cba5c07dbdf847dc7bff4ef1c5b5dd 100755 --- a/camo-image-proxy.php +++ b/camo-image-proxy.php @@ -56,11 +56,14 @@ require_once PLUGIN_PATH . '/inc/functions.php'; */ function init() { Options::instance(); + URL::instance(); + // Don't rewrite in the admin! if ( is_admin() ) { Options_Page::instance(); + } else { + Rewrite_URLs::instance(); + Rewrite_Content::instance(); } - - Rewrite_URLs::instance(); } add_action( 'init', __NAMESPACE__ . '\init' ); diff --git a/inc/class-rewrite-content.php b/inc/class-rewrite-content.php index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..ccf31a0a317a083ed6eeedb47785d6f1fd33fb78 100644 --- a/inc/class-rewrite-content.php +++ b/inc/class-rewrite-content.php @@ -0,0 +1,43 @@ +<?php +/** + * Rewrite images in content + * + * @package Camo_Image_Proxy + */ + +namespace Camo_Image_Proxy; + +/** + * Class Rewrite_Content + */ +class Rewrite_Content { + use Singleton; + + /** + * Filter priority + * + * @var int + */ + private $priority; + + /** + * Hooks + */ + public function setup() { + $priority = apply_filters( 'camo_image_proxy_rewrite_content_priority', PHP_INT_MAX - 1 ); + $this->priority = absint( $priority ); + + add_filter( 'the_content', [ $this, 'filter_the_content' ], $this->priority ); + } + + /** + * Rewrite image URLs in content + * + * @param string $content Post content. + * @return string + */ + public function filter_the_content( string $content ) : string { + // TODO: only deal with image srcs, use DOM Document. + return $content; + } +}