Skip to content

Commit

Permalink
Merge branch 'main' into feature/code-standards-2
Browse files Browse the repository at this point in the history
  • Loading branch information
bradp committed Oct 2, 2024
2 parents e5a6f21 + f94f7e8 commit d4f93e1
Show file tree
Hide file tree
Showing 49 changed files with 1,989 additions and 306 deletions.
2 changes: 2 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ node_modules
cypress.config.js
set-latest-wp-version.js
webpack.config.js
tailwind.config.js
postcss.config.js

# File Types
/*.json
Expand Down
83 changes: 83 additions & 0 deletions .github/workflows/create-milestones.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Create Milestone

on:
workflow_dispatch:
inputs:
due_date:
description: "Provide the due date for the milestone (format: YYYY-MM-DD)"
required: false
default: ""
schedule:
- cron: '0 12 * * 3' # Every Wednesday at noon UTC

permissions:
issues: write
contents: read

jobs:
create-milestone:
runs-on: ubuntu-latest

steps:
- name: Create Milestone
run: |
#!/bin/bash
# Explicitly set the timezone to UTC
export TZ=UTC
echo "Debug: Manually Entered Due Date: ${{ github.event.inputs.due_date }}"
# Get the input date from workflow_dispatch (if provided) or use default logic
if [ -n "${{ github.event.inputs.due_date }}" ]; then
# Use the provided date from workflow_dispatch input
DUE_DATE="${{ github.event.inputs.due_date }}"
echo "Manual input provided. Using input date: $DUE_DATE"
else
# No manual input, use the default: 2 weeks from now
DUE_DATE=$(date -u -d '2 weeks' '+%Y-%m-%d')
echo "No manual input. Using default date 2 weeks from now: $DUE_DATE"
fi
# Set the date format for the milestone title and due date
DATE=$(date -u -d "$DUE_DATE" '+%B %-d, %Y') # Human-readable date
DATE_ISO8601=$(date -u -d "$DUE_DATE" '+%Y-%m-%dT23:59:59Z') # ISO8601 format
# Prepare the description for the milestone
DESCRIPTION="The release is scheduled for $DATE, and PRs should be submitted and made mergeable by EOD $DATE. This means they should have tests passing and merge conflicts resolved. The description for the PR must include details of what is included in the PR and how to test it, and preferably new tests supporting the update.\n\nAny PRs submitted after the deadline will not be included in the release but go in the next release. This includes PRs with tests failing, no description, no screenshots/video demonstrating the update, sufficient Cypress tests, no link to associated JIRA ticket, etc. If no mergeable PRs are submitted for a release, there will be no release that week (unless there is a need for an out-of-cycle release)."
# Debugging outputs
echo "Debug: Human-readable Date: $DATE"
echo "Debug: ISO8601 Date: $DATE_ISO8601"
echo "Debug: Description content: $DESCRIPTION"
# Prepare the JSON payload for the API request
PAYLOAD="{\"title\":\"$DATE Release\", \"description\":\"$DESCRIPTION\", \"due_on\":\"$DATE_ISO8601\", \"state\":\"open\"}"
# Debugging the JSON payload
echo "Debug: Payload: $PAYLOAD"
# Perform the curl request and capture the response
RESPONSE=$(curl -s -w "%{http_code}" -o response_body.txt -X POST \
-H "User-Agent: GitHub-API-Request" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/milestones \
-d "$PAYLOAD")
# Capture HTTP status code and response body
HTTP_STATUS=$(tail -n1 <<< "$RESPONSE")
RESPONSE_BODY=$(cat response_body.txt)
# Debugging the HTTP status and response body
echo "Debug: HTTP Status: $HTTP_STATUS"
echo "Debug: Response Body: $RESPONSE_BODY"
# If the request fails, exit with an error
if [[ "$HTTP_STATUS" -ge 400 ]]; then
echo "Error: Failed to create a milestone."
exit 1
fi
echo "Milestone created successfully."
echo "Response body: $RESPONSE_BODY"
4 changes: 2 additions & 2 deletions .github/workflows/cypress-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jobs:
- '8.2'
- '8.3'
wpVersion:
- '6.2'
- '6.3'
- '6.4'
- '6.5'
- '6.6'

steps:

Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/upload-asset-on-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,3 @@ jobs:
-H "Content-Type: application/json" \
--data '{"files":["https://hiive.cloud/workers/release-api/plugins/bluehost/bluehost-wordpress-plugin"]}'
- name: Send message to ms teams
uses: dhollerbach/actions.send-message-to-ms-teams@1.0.10
with:
webhook: '${{ secrets.TEAMS_WEBHOOK_URL }}'
message: "Bluehost plugin version ${{ env.VERSION }} has been released!"
2 changes: 1 addition & 1 deletion .wp-env.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"core": "WordPress/WordPress#tags/6.4.3",
"core": "WordPress/WordPress#tags/6.6.2",
"config": {
"WP_DEBUG": true,
"WP_DEBUG_LOG": true,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Steps to follow when releasing a new version of the plugin:
- Ensure `release` branch has properly bumped the version.
- The [plugin header version](bluehost-wordpress-plugin.php#L5).
- The [plugin constant version](bluehost-wordpress-plugin.php#L35).
- The [plugin package veresion](package.json#L5).
- The [plugin package version](package.json#L5).
- Ensure the `release` branch has passing tests.
- Ensure the `release` branch passes linting.
- Tag an initial release candidate version of the plugin (e.g. `X.Y.Z-rc.1`) and be sure to mark it as a pre-release.
Expand Down
Binary file added assets/images/ecomm-addon-ctb-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions bluehost-wordpress-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
*
* @package WPPluginBluehost
* @author Newfold Digital
* @copyright Copyright 2023 by Newfold Digital - All rights reserved.
* @copyright Copyright 2024 by Newfold Digital - All rights reserved.
* @license GPL-2.0-or-later
*
* @wordpress-plugin
* Plugin Name: The Bluehost Plugin
* Plugin URI: https://bluehost.com
* Update URI: https://github.com/bluehost/bluehost-wordpress-plugin
* Description: WordPress plugin that integrates a WordPress site with the Bluehost control panel, including performance, security, and update features.
* Version: 3.9.2
* Requires at least: 6.0
* Requires PHP: 7.1
* Tested up to: 6.4.3
* Version: 3.14.12
* Requires at least: 6.4
* Requires PHP: 7.3
* Tested up to: 6.6.2
* Author: Bluehost
* Author URI: https://bluehost.com
* Text Domain: wp-plugin-bluehost
Expand All @@ -32,7 +32,7 @@
}

// Define constants
define( 'BLUEHOST_PLUGIN_VERSION', '3.9.2' );
define( 'BLUEHOST_PLUGIN_VERSION', '3.14.12' );
define( 'BLUEHOST_PLUGIN_FILE', __FILE__ );
define( 'BLUEHOST_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'BLUEHOST_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
Expand Down
4 changes: 4 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use NewfoldLabs\WP\ModuleLoader\Container;
use NewfoldLabs\WP\ModuleLoader\Plugin;
use NewfoldLabs\WP\Context\Context;
use NewfoldLabs\WP\Module\Features\Features;
use function NewfoldLabs\WP\ModuleLoader\container as setContainer;
use function NewfoldLabs\WP\Context\setContext;
use function NewfoldLabs\WP\Context\getContext;
Expand Down Expand Up @@ -199,3 +200,6 @@ function () {
if ( is_admin() ) {
new Admin();
}

// Instantiate the Features singleton
Features::getInstance();
8 changes: 5 additions & 3 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ module.exports = defineConfig( {
}
}

// Exclude ecommerce tests for WordPress lower than 6.3 (6.2) or PHP lower than 7.4 (7.1, 7.2 and 7.3)
if ( semver.satisfies( config.env.wpSemverVersion, '<6.3.0' ) || semver.satisfies( config.env.phpSemverVersion, '<7.4.0' )) {
// Exclude Onboarding and ecommerce tests for WordPress lower than 6.5 (6.4 or 6.3) or PHP lower than 7.4 (7.1, 7.2 and 7.3)
if ( semver.satisfies( config.env.wpSemverVersion, '<6.5.0' ) || semver.satisfies( config.env.phpSemverVersion, '<7.4.0' )) {
config.excludeSpecPattern = config.excludeSpecPattern.concat( [
'vendor/newfold-labs/wp-module-ecommerce/tests/cypress/integration/Site-Capabilities/**',
'vendor/newfold-labs/wp-module-ecommerce/tests/cypress/integration/Home/homePageWithWoo.cy.js'
'vendor/newfold-labs/wp-module-ecommerce/tests/cypress/integration/Home/homePageWithWoo.cy.js',
'vendor/newfold-labs/wp-module-ecommerce/tests/cypress/integration/Home/ecommerce-next-steps.cy.js', // Skip this since Onboarding does not support this version
'vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/**' // Onboarding requires WP 6.5 or greater, as it uses the Wonder Theme which has the same requirement
] );
}

Expand Down
57 changes: 35 additions & 22 deletions inc/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Bluehost;

use function NewfoldLabs\WP\Context\getContext;
use function NewfoldLabs\WP\Module\Features\isEnabled;

/**
* \Bluehost\Admin
Expand Down Expand Up @@ -37,6 +38,8 @@ public function __construct() {

if ( isset( $_GET['page'] ) && strpos( filter_input( INPUT_GET, 'page', FILTER_UNSAFE_RAW ), 'bluehost' ) >= 0 ) { // phpcs:ignore
\add_action( 'admin_footer_text', array( __CLASS__, 'add_brand_to_admin_footer' ) );
/* Disable admin notices on App pages */
\add_action( 'admin_init', array( __CLASS__, 'disable_admin_notices' ) );
}
}

Expand All @@ -63,41 +66,40 @@ public static function add_to_runtime( $sdk ) {
public static function subpages() {
global $bluehost_module_container;

$home = array(
$home = array(
'bluehost#/home' => __( 'Home', 'wp-plugin-bluehost' ),
);
$store = array(
$pagesAndPosts = array(
'bluehost#/pages-and-posts' => __( 'Pages & Posts', 'wp-plugin-bluehost' ),
);
$store = array(
'bluehost#/store' => __( 'Store', 'wp-plugin-bluehost' ),
);
$marketplace = array(
$marketplace = array(
'bluehost#/marketplace' => __( 'Marketplace', 'wp-plugin-bluehost' ),
);
$performance = array(
'bluehost#/performance' => __( 'Performance', 'wp-plugin-bluehost' ),
);
// add performance if enabled
$performance = isEnabled( 'performance' )
? array(
'bluehost#/performance' => __( 'Performance', 'wp-plugin-bluehost' ),
)
: array();
$settings = array(
'bluehost#/settings' => __( 'Settings', 'wp-plugin-bluehost' ),
);
$staging = array(
'bluehost#/staging' => __( 'Staging', 'wp-plugin-bluehost' ),
);
$help = array(
// add staging if enabled
$staging = isEnabled( 'staging' )
? array(
'bluehost#/staging' => __( 'Staging', 'wp-plugin-bluehost' ),
)
: array();
$help = array(
'bluehost#/help' => __( 'Help', 'wp-plugin-bluehost' ),
);

// wp-cloud adjustments
if ( 'atomic' === getContext( 'platform' ) ) {
return array_merge(
$home,
$store,
$marketplace,
$settings,
$help
);
}

return array_merge(
$home,
$pagesAndPosts,
$store,
$marketplace,
$performance,
Expand All @@ -116,6 +118,7 @@ public static function admin_nav_style() {
echo 'ul#adminmenu a.toplevel_page_bluehost.wp-has-current-submenu:after, ul#adminmenu>li#toplevel_page_bluehost.current>a.current:after { border-right-color: #fff !important; }';
echo 'li#toplevel_page_bluehost > ul > li.wp-first-item { display: none !important; }';
echo '#wp-toolbar #wp-admin-bar-bluehost-coming_soon .ab-item { padding: 0; }';
echo 'body.folded #adminmenu .toplevel_page_bluehost div.wp-menu-image { width: 36px; height: 34px; }';
echo '</style>';
}

Expand Down Expand Up @@ -203,7 +206,7 @@ public static function assets( $hook ) {
\wp_register_script(
'bluehost-script',
BLUEHOST_BUILD_URL . '/index.js',
array_merge( $asset['dependencies'], array( 'nfd-runtime' ) ),
array_merge( $asset['dependencies'], array( 'newfold-features', 'nfd-runtime' ) ),
$asset['version'],
true
);
Expand Down Expand Up @@ -278,6 +281,16 @@ public static function actions( $actions ) {
);
}

/**
* Disable admin notices on App pages
*
* @return void
*/
public static function disable_admin_notices() {
remove_all_actions( 'admin_notices' );
remove_all_actions( 'all_admin_notices' );
}

/**
* Filter WordPress Admin Footer Text "Thank you for creating with..."
*
Expand Down
2 changes: 1 addition & 1 deletion inc/alt-experience/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ <h2 class="heading screen-reader-text">Bluehost WordPress Plugin</h2>
<path stroke-linecap="round" stroke-linejoin="round"
d="M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z">
</path>
</svg>Help</a></li>
</svg>Help with WordPress</a></li>
</ul>
</div>
</nav>
Expand Down
12 changes: 0 additions & 12 deletions inc/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@

namespace Bluehost;

/**
* Filter wp revisions according to plugin setting
*
* @param int $num Number of posts to retain (unused).
* @param WP_Post|object $post Post object (unused).
* @return int
*/
function nfd_settings_revisions( $num, $post ) {
return get_option( 'nfd_wp_post_revisions', 5 );
}
add_filter( 'wp_revisions_to_keep', __NAMESPACE__ . '\\nfd_settings_revisions', 10, 2 );

if ( ! defined( 'EMPTY_TRASH_DAYS' ) ) {
$nfd_empty_trash_days = get_option( 'nfd_empty_trash_days', 30 );
define( 'EMPTY_TRASH_DAYS', $nfd_empty_trash_days );
Expand Down
Loading

0 comments on commit d4f93e1

Please sign in to comment.