Skip to content

Commit

Permalink
Forms: Add Akismet panel to form block (#41826)
Browse files Browse the repository at this point in the history
  • Loading branch information
edanzer authored and matticbot committed Mar 3, 2025
1 parent 6a23f03 commit 750c1f4
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 18 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.40.1-alpha] - unreleased
## [0.41.0-alpha] - unreleased

This is an alpha version! The changes listed here are not final.

### Added
- Forms: Added Akismet panel to form block.

## [0.40.0] - 2025-03-03
### Added
- Forms: Add min/max options to number field. [#41783]
Expand Down Expand Up @@ -879,7 +882,7 @@ This is an alpha version! The changes listed here are not final.
- Added a new jetpack/forms package [#28409]
- Added a public load_contact_form method for initializing the contact form module. [#28416]

[0.40.1-alpha]: https://github.com/automattic/jetpack-forms/compare/v0.40.0...v0.40.1-alpha
[0.41.0-alpha]: https://github.com/automattic/jetpack-forms/compare/v0.40.0...v0.41.0-alpha
[0.40.0]: https://github.com/automattic/jetpack-forms/compare/v0.39.0...v0.40.0
[0.39.0]: https://github.com/automattic/jetpack-forms/compare/v0.38.0...v0.39.0
[0.38.0]: https://github.com/automattic/jetpack-forms/compare/v0.37.1...v0.38.0
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"link-template": "https://github.com/automattic/jetpack-forms/compare/v${old}...v${new}"
},
"branch-alias": {
"dev-trunk": "0.40.x-dev"
"dev-trunk": "0.41.x-dev"
},
"textdomain": "jetpack-forms",
"version-constants": {
Expand Down
2 changes: 1 addition & 1 deletion dist/blocks/editor.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('jetpack-connection', 'lodash', 'react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => 'ff4ec9b76b23d86fbe89');
<?php return array('dependencies' => array('jetpack-connection', 'lodash', 'react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => '611378df1d3b9f782c5e');
2 changes: 1 addition & 1 deletion dist/blocks/editor.css

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions dist/blocks/editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/blocks/editor.rtl.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-forms",
"version": "0.40.1-alpha",
"version": "0.41.0-alpha",
"description": "Jetpack Forms",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/forms/#readme",
"bugs": {
Expand Down
15 changes: 11 additions & 4 deletions src/blocks/contact-form/class-contact-form-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Automattic\Jetpack\Blocks;
use Automattic\Jetpack\Forms\ContactForm\Contact_Form;
use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin;
use Automattic\Jetpack\Forms\Dashboard\Dashboard_View_Switch;
use Jetpack;

/**
Expand Down Expand Up @@ -233,13 +234,19 @@ public static function load_editor_scripts() {
);

// Create a Contact_Form instance to get the default values
$contact_form = new Contact_Form( array() );
$defaults = $contact_form->defaults;
$contact_form = new Contact_Form( array() );
$defaults = $contact_form->defaults;
$admin_url = ( new Dashboard_View_Switch() )->get_forms_admin_url( 'spam' );
$akismet_active_with_key = Jetpack::is_akismet_active();
$akismet_key_url = admin_url( 'admin.php?page=akismet-key-config' );

$data = array(
'defaults' => array(
'to' => $defaults['to'],
'subject' => $defaults['subject'],
'to' => $defaults['to'],
'subject' => $defaults['subject'],
'formsAdminUrl' => $admin_url,
'akismetActiveWithKey' => $akismet_active_with_key,
'akismetUrl' => $akismet_key_url,
),
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.jetpack-plugin-integration__status {
display: flex;
align-items: center;
gap: 8px;
}

.jetpack-plugin-integration__content {
color: rgba(38, 46, 57, 0.7);
}

.jetpack-plugin-integration__panel-content > *:not(:last-child) {
margin-bottom: 16px;
}

.jetpack-plugin-integration__spinner-icon {
animation: rotation 2s infinite linear;
}
2 changes: 1 addition & 1 deletion src/class-jetpack-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
class Jetpack_Forms {

const PACKAGE_VERSION = '0.40.1-alpha';
const PACKAGE_VERSION = '0.41.0-alpha';

/**
* Load the contact form module.
Expand Down
24 changes: 24 additions & 0 deletions src/dashboard/class-dashboard-view-switch.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,28 @@ public function is_modern_view() {
// Because of this, we need to support these two screens.
return $screen && in_array( $screen->id, array( 'admin_page_jetpack-forms', 'toplevel_page_jetpack-forms' ), true );
}

/**
* Returns url of forms admin page.
*
* @param string|null $tab Tab to open in the forms admin page.
*
* @return string
*/
public function get_forms_admin_url( $tab = null ) {
$is_classic = $this->get_preferred_view() === self::CLASSIC_VIEW;

$url = $is_classic
? get_admin_url() . 'edit.php?post_type=feedback'
: get_admin_url() . 'admin.php?page=jetpack-forms';

// Return url directly to spam tab.
if ( $tab === 'spam' ) {
$url = $is_classic
? add_query_arg( 'post_status', 'spam', $url )
: $url . '#/responses?status=spam';
}

return $url;
}
}

0 comments on commit 750c1f4

Please sign in to comment.