Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to support the site launch event #27

Merged
merged 11 commits into from
Jan 26, 2024
50 changes: 50 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version: 2
updates:

# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
target-branch: "develop"
allow:
- dependency-type: direct
schedule:
interval: "daily"
commit-message:
prefix: "GitHub Actions"
include: "scope"
labels:
- "dependencies"

# Maintain dependencies for npm
- package-ecosystem: "npm"
directory: "/"
target-branch: "develop"
allow:
- dependency-type: direct
schedule:
interval: "daily"
versioning-strategy: increase
commit-message:
prefix: "NPM"
prefix-development: "NPM Dev"
include: "scope"
labels:
- "dependencies"
- "javascript"

# Maintain dependencies for Composer
- package-ecosystem: "composer"
directory: "/"
target-branch: "develop"
schedule:
interval: "daily"
allow:
- dependency-type: direct
versioning-strategy: increase
commit-message:
prefix: "Composer"
prefix-development: "Composer Dev"
include: "scope"
labels:
- "dependencies"
- "php"
26 changes: 26 additions & 0 deletions .github/workflows/satis-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,38 @@ on:
types:
- created

env:
VERSION: ${GITHUB_REF#refs/tags/*}

jobs:
webhook:
name: Send Webhook
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v4

- name: Validate version number
if: ${{ (github.repository == 'newfold-labs/wp-module-coming-soon') && (github.event.release.prerelease == false) }}
run: |
taggedVersion=${{ env.VERSION }}
moduleVersion=`grep "NFD_COMING_SOON_MODULE_VERSION" bootstrap.php | grep -Eo "[0-9\.]*"`
packageVersion=`grep '"version"' package.json | grep -Eo "[0-9\.]*"`
echo "Tagged version: $taggedVersion"
echo "Module version: $moduleVersion"
echo "Package version: $packageVersion"
[[ "$taggedVersion" == "$moduleVersion" ]] || exit 1
[[ "$taggedVersion" == "$packageVersion" ]] || exit 1

- name: Validate build directory
if: ${{ (github.repository == 'newfold-labs/wp-module-coming-soon') && (github.event.release.prerelease == false) }}
run: |
if [[ ! -d "build/${{ env.VERSION }}" ]]; then
echo "Build directory for version ${{ env.VERSION }} does not exist.
exit 1
fi

- name: Set Package
id: package
env:
Expand Down
2 changes: 1 addition & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
return;
}

define( 'NFD_COMING_SOON_MODULE_VERSION', '1.1.17' );
define( 'NFD_COMING_SOON_MODULE_VERSION', '1.1.18' );

require __DIR__ . '/includes/functions.php';

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
}
},
"require": {
"newfold-labs/wp-module-data": ">=2.4.18",
"wp-forge/wp-upgrade-handler": "^1.0"
}
}
24 changes: 20 additions & 4 deletions includes/ComingSoon.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,33 @@ public function __construct( Container $container ) {
}

public function on_update_nfd_coming_soon( $old_value, $value ) {
remove_filter( 'pre_update_option_mm_coming_soon', array( $this, 'on_update_mm_coming_soon' ) );

// When the database value changes, make sure we fire the appropriate action for enabling/disabling.
add_action(
'shutdown',
function () use ( $value ) {
if ( wp_validate_boolean( $value ) ) {
do_action( 'newfold/coming-soon/enabled' );
} else {
do_action( 'newfold/coming-soon/disabled' );
}
}
);

// When the database value changes for the new value, make sure we update the legacy value.
remove_filter( 'update_option_mm_coming_soon', array( $this, 'on_update_mm_coming_soon' ) );
update_option( 'mm_coming_soon', $value );
add_filter( 'pre_update_option_mm_coming_soon', array( $this, 'on_update_mm_coming_soon' ) );
add_filter( 'update_option_mm_coming_soon', array( $this, 'on_update_mm_coming_soon' ), 10, 2 );

return $value;
}

public function on_update_mm_coming_soon( $old_value, $value ) {
remove_filter( 'pre_update_option_nfd_coming_soon', array( $this, 'on_update_nfd_coming_soon' ) );

// When the database value changes for the legacy value, make sure we update the new value.
remove_filter( 'update_option_nfd_coming_soon', array( $this, 'on_update_nfd_coming_soon' ) );
update_option( 'nfd_coming_soon', $value );
add_filter( 'pre_update_option_nfd_coming_soon', array( $this, 'on_update_nfd_coming_soon' ) );
add_filter( 'update_option_nfd_coming_soon', array( $this, 'on_update_nfd_coming_soon' ), 10, 2 );

return $value;
}
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "@newfold-labs/wp-module-coming-soon",
BrianHenryIE marked this conversation as resolved.
Show resolved Hide resolved
"version": "1.1.17",
"version": "1.1.18",
"description": "Coming Soon",
"license": "GPL-2.0-or-later",
"private": true,
Expand Down
5 changes: 4 additions & 1 deletion upgrades/1.1.16.php → upgrades/1.1.18.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Handles update for coming soon module version 1.1.14.
* Handles update for coming soon module version 1.1.18.
*
* Enable coming soon page on fresh installations.
*
Expand All @@ -15,5 +15,8 @@
if ( $isFreshInstall ) {
$comingSoonService = new Service();
$comingSoonService->enable( false );

// Initially set the `mm_coming_soon` option to true as well to keep things in sync.
update_option( 'mm_coming_soon', true );
}
} );
Loading