Skip to content

Commit 750c1f4

Browse files
edanzermatticbot
authored andcommitted
Forms: Add Akismet panel to form block (#41826)
Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/13642590652 Upstream-Ref: Automattic/jetpack@52155b4
1 parent 6a23f03 commit 750c1f4

File tree

11 files changed

+70
-18
lines changed

11 files changed

+70
-18
lines changed

CHANGELOG.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [0.40.1-alpha] - unreleased
8+
## [0.41.0-alpha] - unreleased
99

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

12+
### Added
13+
- Forms: Added Akismet panel to form block.
14+
1215
## [0.40.0] - 2025-03-03
1316
### Added
1417
- Forms: Add min/max options to number field. [#41783]
@@ -879,7 +882,7 @@ This is an alpha version! The changes listed here are not final.
879882
- Added a new jetpack/forms package [#28409]
880883
- Added a public load_contact_form method for initializing the contact form module. [#28416]
881884

882-
[0.40.1-alpha]: https://github.com/automattic/jetpack-forms/compare/v0.40.0...v0.40.1-alpha
885+
[0.41.0-alpha]: https://github.com/automattic/jetpack-forms/compare/v0.40.0...v0.41.0-alpha
883886
[0.40.0]: https://github.com/automattic/jetpack-forms/compare/v0.39.0...v0.40.0
884887
[0.39.0]: https://github.com/automattic/jetpack-forms/compare/v0.38.0...v0.39.0
885888
[0.38.0]: https://github.com/automattic/jetpack-forms/compare/v0.37.1...v0.38.0

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"link-template": "https://github.com/automattic/jetpack-forms/compare/v${old}...v${new}"
5858
},
5959
"branch-alias": {
60-
"dev-trunk": "0.40.x-dev"
60+
"dev-trunk": "0.41.x-dev"
6161
},
6262
"textdomain": "jetpack-forms",
6363
"version-constants": {

dist/blocks/editor.asset.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +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');
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' => '611378df1d3b9f782c5e');

dist/blocks/editor.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/blocks/editor.js

+7-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/blocks/editor.rtl.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@automattic/jetpack-forms",
4-
"version": "0.40.1-alpha",
4+
"version": "0.41.0-alpha",
55
"description": "Jetpack Forms",
66
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/forms/#readme",
77
"bugs": {

src/blocks/contact-form/class-contact-form-block.php

+11-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Automattic\Jetpack\Blocks;
1212
use Automattic\Jetpack\Forms\ContactForm\Contact_Form;
1313
use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin;
14+
use Automattic\Jetpack\Forms\Dashboard\Dashboard_View_Switch;
1415
use Jetpack;
1516

1617
/**
@@ -233,13 +234,19 @@ public static function load_editor_scripts() {
233234
);
234235

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

239243
$data = array(
240244
'defaults' => array(
241-
'to' => $defaults['to'],
242-
'subject' => $defaults['subject'],
245+
'to' => $defaults['to'],
246+
'subject' => $defaults['subject'],
247+
'formsAdminUrl' => $admin_url,
248+
'akismetActiveWithKey' => $akismet_active_with_key,
249+
'akismetUrl' => $akismet_key_url,
243250
),
244251
);
245252

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.jetpack-plugin-integration__status {
2+
display: flex;
3+
align-items: center;
4+
gap: 8px;
5+
}
6+
7+
.jetpack-plugin-integration__content {
8+
color: rgba(38, 46, 57, 0.7);
9+
}
10+
11+
.jetpack-plugin-integration__panel-content > *:not(:last-child) {
12+
margin-bottom: 16px;
13+
}
14+
15+
.jetpack-plugin-integration__spinner-icon {
16+
animation: rotation 2s infinite linear;
17+
}

src/class-jetpack-forms.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
class Jetpack_Forms {
1717

18-
const PACKAGE_VERSION = '0.40.1-alpha';
18+
const PACKAGE_VERSION = '0.41.0-alpha';
1919

2020
/**
2121
* Load the contact form module.

src/dashboard/class-dashboard-view-switch.php

+24
Original file line numberDiff line numberDiff line change
@@ -300,4 +300,28 @@ public function is_modern_view() {
300300
// Because of this, we need to support these two screens.
301301
return $screen && in_array( $screen->id, array( 'admin_page_jetpack-forms', 'toplevel_page_jetpack-forms' ), true );
302302
}
303+
304+
/**
305+
* Returns url of forms admin page.
306+
*
307+
* @param string|null $tab Tab to open in the forms admin page.
308+
*
309+
* @return string
310+
*/
311+
public function get_forms_admin_url( $tab = null ) {
312+
$is_classic = $this->get_preferred_view() === self::CLASSIC_VIEW;
313+
314+
$url = $is_classic
315+
? get_admin_url() . 'edit.php?post_type=feedback'
316+
: get_admin_url() . 'admin.php?page=jetpack-forms';
317+
318+
// Return url directly to spam tab.
319+
if ( $tab === 'spam' ) {
320+
$url = $is_classic
321+
? add_query_arg( 'post_status', 'spam', $url )
322+
: $url . '#/responses?status=spam';
323+
}
324+
325+
return $url;
326+
}
303327
}

0 commit comments

Comments
 (0)