base_path = ABSPATH; $this->base_url = get_home_url() . '/'; $this->default_critical_path = $this->base_path . 'wp-content/cache/awpp/critical/'; $this->options = get_option( awpp_get_instance()->Settings->settings_option ); if ( ! file_exists( $this->default_critical_path ) ) { mkdir( $this->default_critical_path, 0777, true ); } } public function run() { add_action( 'admin_bar_menu', [ $this, 'add_toolbar_item' ] ); if ( awpp_is_frontend() && 'off' != $this->options['loadcss'] ) { add_action( 'wp_head', [ $this, 'add_critical_css' ], 1 ); } } /** * Toolbar */ public function add_toolbar_item( $wp_admin_bar ) { $html = ''; $html .= ''; $html .= ''; $args = [ 'id' => awpp_get_instance()->Settings->adminbar_id . '-criticalcss', 'parent' => awpp_get_instance()->Settings->adminbar_id, 'title' => 'Critical CSS', 'href' => '', 'meta' => [ 'class' => awpp_get_instance()->prefix . '-adminbar-criticalcss ' . $this->options['loadcss'], ], ]; if ( awpp_is_frontend() && 'off' != $this->options['loadcss'] ) { $args['meta']['html'] = '