Skip to content

Jetpack Forms move method to Util class #43823

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

Merged
merged 2 commits into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: changed

Forms: move get_export_filename method from Admin to Util
Original file line number Diff line number Diff line change
Expand Up @@ -2201,13 +2201,13 @@ public function download_feedback_as_csv() {
if ( ! empty( $post_data['post'] ) && $post_data['post'] !== 'all' ) {
$filename = sprintf(
'%s - %s.csv',
Admin::init()->get_export_filename( get_the_title( (int) $post_data['post'] ) ),
Util::get_export_filename( get_the_title( (int) $post_data['post'] ) ),
gmdate( 'Y-m-d H:i' )
);
} else {
$filename = sprintf(
'%s - %s.csv',
Admin::init()->get_export_filename(),
Util::get_export_filename(),
gmdate( 'Y-m-d H:i' )
);
}
Expand Down
21 changes: 21 additions & 0 deletions projects/packages/forms/src/contact-form/class-util.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,4 +339,25 @@ function ( $match ) use ( $new_attr ) {
$content
);
}

/**
* Get a filename for export tasks
*
* @param string $source The filtered source for exported data.
* @return string The filename without source nor date suffix.
*/
public static function get_export_filename( $source = '' ) {
return $source === ''
? sprintf(
/* translators: Site title, used to craft the export filename, eg "MySite - Jetpack Form Responses" */
__( '%s - Jetpack Form Responses', 'jetpack-forms' ),
sanitize_file_name( get_bloginfo( 'name' ) )
)
: sprintf(
/* translators: 1: Site title; 2: post title. Used to craft the export filename, eg "MySite - Jetpack Form Responses - Contact" */
__( '%1$s - Jetpack Form Responses - %2$s', 'jetpack-forms' ),
sanitize_file_name( get_bloginfo( 'name' ) ),
sanitize_file_name( $source )
);
}
Copy link
Contributor

@edanzer edanzer Jun 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Looks like but wanted to confirm: we duplicated the method exactly?

  2. Do we need to delete this method from the admin class? Or are we not worried about that because we intend to delete the whole class later?

  3. Also small question for context: why or what changed that we are planning on deleting the admin class? Is it related to menu changes or some other recent change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is related somehow. With the legacy view gone, there's no real use for the Admin class.

#43821

FORMS-133

FORMS-132

}
Loading