From 6fd7a289b780aa9af379b2d04706d35e53106834 Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Wed, 20 Jan 2021 10:09:32 -0300 Subject: [PATCH] fix: resolve warning cannot modify header information on enqueue style. --- src/classes/class-tainacan-media.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/classes/class-tainacan-media.php b/src/classes/class-tainacan-media.php index 934f4aa84..8810fd651 100644 --- a/src/classes/class-tainacan-media.php +++ b/src/classes/class-tainacan-media.php @@ -21,9 +21,8 @@ class Media { protected function __construct() { add_action( 'init', [$this, 'add_attachment_page_rewrite_rule'] ); - - global $TAINACAN_BASE_URL; - wp_enqueue_style( 'tainacan-media-page', $TAINACAN_BASE_URL . '/assets/css/tainacan-media-page.css', [], TAINACAN_VERSION ); + add_action( 'admin_enqueue_scripts', array( &$this, 'add_css' ) ); + add_action( 'wp_enqueue_scripts', array( &$this, 'add_css' ) ); add_filter( 'query_vars', [$this, 'attachment_page_add_var'] ); add_action( 'template_redirect', [$this, 'attachment_page'] ); @@ -37,6 +36,11 @@ class Media { ); } + public function add_css() { + global $TAINACAN_BASE_URL; + wp_enqueue_style( 'tainacan-media-page', $TAINACAN_BASE_URL . '/assets/css/tainacan-media-page.css', [], TAINACAN_VERSION ); + } + public function attachment_page_add_var($vars) { $vars[] = 'tainacan_attachment_page'; return $vars;