_post_meta( $post->ID, '_rocket_exclude_async_css', true ) ) { $this->disabled_data['option_excluded'] = 1; } if ( ! is_post_type_viewable( get_post_type( $post ) ) ) { $this->disabled_data['not_viewable'] = 1; } return $this->disabled_data; } /** * Checks if critical CSS generation is enabled for the current post. * * @since 3.6 * * @return bool */ private function is_enabled() { return ! empty( $this->get_disabled_data() ); } /** * Returns the reason why actions are disabled. * * @since 3.6 * * @return string */ private function get_disabled_description() { global $post; $disabled_data = $this->get_disabled_data(); if ( empty( $disabled_data ) ) { return ''; } if ( isset( $disabled_data['not_viewable'] ) ) { return __( 'This feature is not available for non-public post types.', 'rocket' ); } $notice = __( '%l to use this feature.', 'rocket' ); $list = [ // translators: %s = post type. 'not_published' => sprintf( __( 'Publish the %s', 'rocket' ), $post->post_type ), 'option_disabled' => __( 'Enable Load CSS asynchronously in WP Rocket settings', 'rocket' ), 'option_excluded' => __( 'Enable Load CSS asynchronously in the options above', 'rocket' ), ]; return wp_sprintf_l( $notice, array_intersect_key( $list, $disabled_data ) ); } /** * Checks if a specific critical css file exists for the current post. * * @since 3.6 * * @return bool */ private function cpcss_exists() { global $post; $post_cpcss = "{$this->critical_css_path}{$post->post_type}-{$post->ID}.css"; return rocket_direct_filesystem()->exists( $post_cpcss ); } }