Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 0 additions & 57 deletions .env.testing

This file was deleted.

9 changes: 7 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
name: Static Analysis
on:
push:

jobs:
phpstsan:
name: phpstan
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Configure PHP environment
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, intl
coverage: none

- uses: ramsey/composer-install@v3
with:
composer-options: "--ignore-platform-reqs --optimize-autoloader"
composer-options: "--optimize-autoloader"

- name: Run PHPStan static analysis
run: composer test:analysis
41 changes: 16 additions & 25 deletions .github/workflows/tests-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,20 @@ jobs:
name: "Tests: WP ${{ matrix.wordpress }} / PHP ${{ matrix.php }}"
steps:
- name: Checkout the repository
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 1000
submodules: recursive
# ------------------------------------------------------------------------------
# Checkout slic
# ------------------------------------------------------------------------------
- name: Checkout slic
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
repository: stellarwp/slic
ref: main
path: slic
fetch-depth: 1
# ------------------------------------------------------------------------------
# Prepare our composer cache directory
# ------------------------------------------------------------------------------
- name: Get Composer Cache Directory
id: get-composer-cache-dir
run: |
echo "DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v4
id: composer-cache
with:
path: ${{ steps.get-composer-cache-dir.outputs.DIR }}
key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ matrix.php }}-composer-

# ------------------------------------------------------------------------------
# Initialize slic
Expand Down Expand Up @@ -82,26 +67,32 @@ jobs:
${SLIC_BIN} xdebug off
${SLIC_BIN} debug on
${SLIC_BIN} php-version set ${{ matrix.php }} --skip-rebuild
${SLIC_BIN} composer-cache set ${{ steps.get-composer-cache-dir.outputs.DIR }}

- name: Set up StellarWP Uplink (Sets PHP version for containers)
run: |
${SLIC_BIN} use uplink
${SLIC_BIN} composer set-version 2
${SLIC_BIN} composer validate
${SLIC_BIN} composer install

- name: Show slic info / config
run: |
${SLIC_BIN} info
${SLIC_BIN} config

- name: Install specific WordPress version ${{ matrix.wordpress }}
run: |
${SLIC_BIN} wp core download --version=${{ matrix.wordpress }} --force
${SLIC_BIN} wp core download --version=${{ matrix.wordpress }} --force
${SLIC_BIN} wp core update-db

- name: Show WordPress version
run: ${SLIC_BIN} wp core version

- name: Update installed WordPress themes
run: ${SLIC_BIN} wp theme update --all

- name: Set up StellarWP Uplink
run: |
${SLIC_BIN} use uplink
${SLIC_BIN} composer set-version 2
${SLIC_BIN} composer validate
${SLIC_BIN} composer install
- name: Build codeception
run: ${SLIC_BIN} cc build

- name: Run muwpunit tests
run: ${SLIC_BIN} run muwpunit --ext DotReporter
Expand Down
4 changes: 2 additions & 2 deletions codeception.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ actor: Tester
bootstrap: _bootstrap.php
paths:
tests: tests
log: tests/_output
output: tests/_output
data: tests/_data
helpers: tests/_support
wp_root: "%WP_ROOT_FOLDER%"
Expand All @@ -11,4 +11,4 @@ settings:
memory_limit: 1024M
params:
# read dynamic configuration parameters from the .env file
- .env.testing
- .env.testing.slic
22 changes: 6 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,13 @@
}
},
"require-dev": {
"codeception/module-asserts": "^1.0",
"codeception/module-cli": "^1.0",
"codeception/module-db": "^1.0",
"codeception/module-filesystem": "^1.0",
"codeception/module-phpbrowser": "^1.0",
"codeception/module-rest": "^1.0",
"codeception/module-webdriver": "^1.0",
"codeception/util-universalframework": "^1.0",
"lucatume/codeception-snapshot-assertions": "^0.4.0",
"lucatume/codeception-snapshot-assertions": "*",
"lucatume/di52": "^3.0",
"lucatume/wp-browser": "^3.0.14",
"phpspec/prophecy": "^1.0",
"phpspec/prophecy-phpunit": "^1.0|^2.0",
"phpunit/phpunit": "^6.0|^7.0|^8.0|^9.0",
"symfony/event-dispatcher-contracts": "^2.5.1",
"symfony/string": "^5.4",
"szepeviktor/phpstan-wordpress": "^1.1"
"lucatume/wp-browser": "*",
"phpspec/prophecy": "*",
"phpspec/prophecy-phpunit": "*",
"phpunit/phpunit": "*",
"szepeviktor/phpstan-wordpress": ">=1.0"
},
"scripts": {
"test:analysis": [
Expand Down
78 changes: 70 additions & 8 deletions src/Uplink/Messages/Expired_Key.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,82 @@
<?php

namespace StellarWP\Uplink\Messages;
use StellarWP\Uplink\Config;

class Expired_Key extends Message_Abstract {
/**
* @inheritDoc
*/
public function get(): string {
$message = '<div class="notice notice-warning"><p>';
$message .= __( 'Your license is expired', '%TEXTDOMAIN%' );
$message .= '<a href="https://evnt.is/195y" target="_blank" class="button button-primary">' .
__( 'Renew Your License Now', '%TEXTDOMAIN%' ) .
'<span class="screen-reader-text">' .
__( ' (opens in a new window)', '%TEXTDOMAIN%' ) .
'</span></a>';
$message .= '</p> </div>';
// TEC only default link for backwards compatibility.
$default_link = in_array(
Config::get_hook_prefix(),
[
'the-events-calendar',
'events-calendar-pro',
'event-tickets',
'event-tickets-plus',
'tribe-filterbar',
'events-virtual',
'events-community',
'events-community-tickets',
'event-aggregator',
'events-elasticsearch',
'image-widget-plus',
'advanced-post-manager',
'tribe-eventbrite',
'event-automator',
'tec-seating',
],
true ) ? 'https://evnt.is/195y' : '';

$message_link = (string) apply_filters( 'stellarwp/uplink/' . Config::get_hook_prefix() . '/messages/expired_key_link', $default_link );
$renew_label = __( 'Renew Your License Now', '%TEXTDOMAIN%' );
$opens_in_new_window = __( '(opens in a new window)', '%TEXTDOMAIN%' );
$notice_text = __( 'Your license is expired', '%TEXTDOMAIN%' );

if ( filter_var( $message_link, FILTER_VALIDATE_URL ) !== false ) {
$message_content = sprintf(
'<p>%s <a href="%s" target="_blank" class="button button-primary" rel="noopener nofollow">%s <span class="screen-reader-text">%s</span></a></p>',
esc_html( $notice_text ),
esc_url( $message_link ),
esc_html( $renew_label ),
esc_html( $opens_in_new_window )
);
} else {
$message_content = sprintf(
'<p>%s</p>',
esc_html( $notice_text )
);
}

$message_content = apply_filters( 'stellarwp/uplink/' . Config::get_hook_prefix() . '/messages/expired_key', $message_content );

$allowed_html = [
'a' => [
'href' => [],
'title' => [],
'target' => [],
'class' => [],
'rel' => [],
],
'br' => [],
'em' => [],
'strong' => [],
'div' => [
'class' => [],
],
'p' => [
'class' => [],
],
'span' => [
'class' => [],
],
];

$message = '<div class="notice notice-warning">';
$message .= wp_kses( $message_content, $allowed_html );
$message .= '</div>';

return $message;
}
Expand Down
13 changes: 12 additions & 1 deletion tests/wpunit/Admin/NoticeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use StellarWP\Uplink\Admin\Notice;
use StellarWP\Uplink\Tests\UplinkTestCase;
use StellarWP\Uplink\Config;

class NoticeTest extends UplinkTestCase {

Expand All @@ -19,7 +20,17 @@ public function test_it_should_display_notice() {
$notice = new Notice();
$notice->add_notice( Notice::EXPIRED_KEY, 'uplink' );

$this->expectOutputString( '<div class="notice notice-warning"><p>Your license is expired<a href="https://evnt.is/195y" target="_blank" class="button button-primary">Renew Your License Now<span class="screen-reader-text"> (opens in a new window)</span></a></p> </div>' );
$this->expectOutputString( '<div class="notice notice-warning"><p>Your license is expired</p></div>' );

$notice->setup_notices();
}

public function test_it_should_display_notice_with_link() {
Config::set_hook_prefix( 'events-calendar-pro' );
$notice = new Notice();
$notice->add_notice( Notice::EXPIRED_KEY, 'uplink' );

$this->expectOutputString( '<div class="notice notice-warning"><p>Your license is expired <a href="https://evnt.is/195y" target="_blank" class="button button-primary" rel="noopener nofollow">Renew Your License Now <span class="screen-reader-text">(opens in a new window)</span></a></p></div>' );

$notice->setup_notices();
}
Expand Down