Skip to content

Commit

Permalink
Merge branch 'development' into fix/issue-139
Browse files Browse the repository at this point in the history
  • Loading branch information
HardeepAsrani authored Aug 19, 2024
2 parents 10bdc87 + 631f8f6 commit 1c5a6b4
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Setup PHP version
uses: shivammathur/setup-php@v2
with:
php-version: '7.1'
php-version: '7.2'
extensions: simplexml, mysql
tools: phpunit-polyfills
- name: Checkout source code
Expand All @@ -69,4 +69,4 @@ jobs:
- name: Install composer
run: composer install --prefer-dist --no-progress --no-suggest
- name: Run phpunit
run: phpunit
run: composer run-script phpunit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ assets/js/build
languages/neve-fse.pot

.DS_Store
.phpunit.result.cache
7 changes: 7 additions & 0 deletions assets/js/src/welcome-notice.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function handleWelcomeNotice( $ ) {
activationUrl,
ajaxUrl,
nonce,
otterRefNonce,
otterStatus,
} = neveFSEData;

Expand All @@ -30,6 +31,12 @@ function handleWelcomeNotice( $ ) {
const activateOtter = async () => {
installText.text( activating );
await activatePlugin( activationUrl );

await $.post( ajaxUrl, {
nonce: otterRefNonce,
action: 'neve_fse_set_otter_ref',
} );

installSpinner.removeClass( 'dashicons-update' );
installSpinner.addClass( 'dashicons-yes' );
installText.text( done );
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"format": "phpcbf --standard=phpcs.xml --report-summary --report-source -s --runtime-set testVersion 7.0- ",
"phpcs": "phpcs --standard=phpcs.xml -s --runtime-set testVersion 7.0-",
"lint": "composer run-script phpcs",
"phpcs-i": "phpcs -i"
"phpcs-i": "phpcs -i",
"phpunit": "phpunit"
}
}
22 changes: 11 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 29 additions & 5 deletions inc/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ class Admin {
*/
private $suspend_survey = true;

/**
* Otter reference key.
*
* @var string
*/
const OTTER_REF = 'otter_reference_key';

/**
* Admin constructor.
*/
Expand Down Expand Up @@ -60,6 +67,7 @@ public function setup_admin_hooks() {
add_action( 'enqueue_block_editor_assets', array( $this, 'add_fse_design_pack_notice' ) );
add_action( 'wp_ajax_neve_fse_dismiss_design_pack_notice', array( $this, 'remove_design_pack_notice' ) );
add_action( 'activated_plugin', 'after_otter_activation' );
add_action( 'wp_ajax_neve_fse_set_otter_ref', array( $this, 'set_otter_ref' ) );
}

/**
Expand All @@ -79,11 +87,12 @@ public function add_fse_design_pack_notice() {
true,
array(),
array(
'nonce' => wp_create_nonce( 'neve-fse-dismiss-design-pack-notice' ),
'ajaxUrl' => esc_url( admin_url( 'admin-ajax.php' ) ),
'ajaxAction' => 'neve_fse_dismiss_design_pack_notice',
'buttonLink' => tsdk_utmify( 'https://themeisle.com/plugins/fse-design-pack', 'editor', 'neve-fse' ),
'strings' => array(
'nonce' => wp_create_nonce( 'neve-fse-dismiss-design-pack-notice' ),
'otterRefNonce' => wp_create_nonce( 'neve-fse-set-otter-ref' ),
'ajaxUrl' => esc_url( admin_url( 'admin-ajax.php' ) ),
'ajaxAction' => 'neve_fse_dismiss_design_pack_notice',
'buttonLink' => tsdk_utmify( 'https://themeisle.com/plugins/fse-design-pack', 'editor', 'neve-fse' ),
'strings' => array(
'dismiss' => __( 'Dismiss', 'neve-fse' ),
'recommends' => __( 'Neve FSE recommends', 'neve-fse' ),
'learnMore' => __( 'Learn More', 'neve-fse' ),
Expand Down Expand Up @@ -467,6 +476,21 @@ public function after_otter_activation( $plugin ) {

wp_safe_redirect( $onboarding );
exit;
}

/**
* Update Otter reference key.
*
* @return void
*/
public function set_otter_ref() {
if ( empty( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( $_POST['nonce'] ), 'neve-fse-set-otter-ref' ) ) {
return;
}

update_option( self::OTTER_REF, 'neve-fse' );

wp_send_json_success();
}

/**
Expand Down
5 changes: 5 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
define( 'NEVE_FSE_IGNORE_SOURCE_CHECK', true );

$_tests_dir = getenv( 'WP_TESTS_DIR' );

if ( class_exists( '\Yoast\PHPUnitPolyfills\Autoload' ) === false ) {
require_once dirname( dirname( __FILE__ ) ) . '/vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
}

if ( ! $_tests_dir ) {
$_tests_dir = '/tmp/wordpress-tests-lib';
}
Expand Down

0 comments on commit 1c5a6b4

Please sign in to comment.