Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #90 from pantheon-systems/release-0.2.14
Browse files Browse the repository at this point in the history
Release 0.2.14
  • Loading branch information
jazzsequence committed Apr 5, 2022
2 parents 6056a64 + 4977744 commit 977cdb9
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Code owners. See:
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners

* @pantheon-systems/edge-integrations
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pantheon WordPress Edge Integrations

Stable tag: 0.2.13
Stable tag: 0.2.14
Requires at least: 5.8
Tested up to: 5.9
Requires PHP: 7.4
Expand All @@ -10,7 +10,7 @@ Contributors: jazzs3quence, jspellman, getpantheon

WordPress plugin and developer toolkit to support Pantheon Edge Integrations and personalization features.

[![Unsupported](https://img.shields.io/badge/pantheon-unsupported-yellow?logo=pantheon&color=FFDC28)](https://pantheon.io/docs/oss-support-levels#unsupported) ![Pantheon WordPress Edge Integrations](https://github.com/pantheon-systems/pantheon-wordpress-edge-integrations/actions/workflows/test.yml/badge.svg) [![GitHub release](https://img.shields.io/github/release/pantheon-systems/pantheon-wordpress-edge-integrations.svg)](https://github.com/pantheon-systems/pantheon-wordpress-edge-integrations/releases/)
[![Unsupported](https://img.shields.io/badge/pantheon-unsupported-yellow?logo=pantheon&color=FFDC28)](https://pantheon.io/docs/oss-support-levels#unsupported) ![Pantheon WordPress Edge Integrations](https://github.com/pantheon-systems/pantheon-wordpress-edge-integrations/actions/workflows/test.yml/badge.svg) [![Packagist release](https://img.shields.io/packagist/v/pantheon-systems/pantheon-wordpress-edge-integrations.svg)](https://github.com/pantheon-systems/pantheon-wordpress-edge-integrations/releases/) ![Commits since latest release](https://img.shields.io/github/commits-since/pantheon-systems/pantheon-wordpress-edge-integrations/latest)

## Description

Expand Down
25 changes: 25 additions & 0 deletions inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,28 @@ function update_vary_headers( array $key = null, array $data = null ) : array {

return $vary_header;
}

/**
* Check if Edge Integrations have been configured.
*
* Validates header data for any supported vary headers, including those that have been added later.
*
* @return bool Whether Edge Integrations have been configured and the CDN is returning data.
*/
function edge_integrations_enabled() : bool {
// Get the software-supported headers.
$headers = get_supported_vary_headers();
$enabled_headers = [];

// Loop through the headers and see if we've got data.
foreach ( $headers as $header ) {
$data = EI\HeaderData::header( $header );

if ( ! empty( $data ) ) {
$enabled_headers[] = $header;
}
}

// If enabled_headers is not empty, edge integrations are enabled.
return apply_filters( 'pantheon.ei.enabled', ! empty( $enabled_headers ) );
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pantheon-wordpress-edge-integrations",
"version": "0.2.13",
"version": "0.2.14",
"description": "WordPress plugin to support Pantheon Edge Integrations and personalization features",
"scripts": {
"bump:patch": "bump patch --commit 'Version %s.' pantheon-wordpress-edge-integrations.php README.md",
Expand Down
2 changes: 1 addition & 1 deletion pantheon-wordpress-edge-integrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: WordPress plugin to support Pantheon Edge Integrations and personalization features.
* Author: Pantheon
* Author URI: https://pantheon.io
* Version: 0.2.13
* Version: 0.2.14
*
* @package Pantheon/EdgeIntegrations
*/
Expand Down
32 changes: 32 additions & 0 deletions tests/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,36 @@ public function testAddHeaderData() {
'Data does not match'
);
}

/**
* Test the edge_integrations_enabled function.
*/
public function testEIEnabled() {
$headers = get_supported_vary_headers();
$enabled_headers = [];

foreach ( $headers as $header ) {
$data = EI\HeaderData::header( $header );

if ( $data ) {
$enabled_headers[] = $header;
}
}

// If $enabled_headers is empty, edge_integrations_enabled should return false.
if ( empty( $enabled_headers ) ) {
$this->assertFalse( edge_integrations_enabled() );
} else {
$this->assertTrue( edge_integrations_enabled() );
}

// Force true or false with the filter.
add_filter( 'pantheon.ei.enabled', '__return_true' );
$this->assertTrue( edge_integrations_enabled() );
remove_filter( 'pantheon.ei.enabled', '__return_true' );

add_filter( 'pantheon.ei.enabled', '__return_false' );
$this->assertFalse( edge_integrations_enabled() );
remove_filter( 'pantheon.ei.enabled', '__return_false' );
}
}
4 changes: 2 additions & 2 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '6f679adced47b402ab242a4376703c1cbd2c3178',
'reference' => '0fc5588cb765f9333fd7dee29103b23690e9463e',
'name' => 'pantheon-systems/pantheon-wordpress-edge-integrations',
'dev' => false,
),
Expand All @@ -25,7 +25,7 @@
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '6f679adced47b402ab242a4376703c1cbd2c3178',
'reference' => '0fc5588cb765f9333fd7dee29103b23690e9463e',
'dev_requirement' => false,
),
),
Expand Down

0 comments on commit 977cdb9

Please sign in to comment.