: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if ( ! defined( 'ABSPATH' ) ) {
* Revisions management panel.
class WPForms_Builder_Panel_Revisions extends WPForms_Builder_Panel {
// Define panel information.
$this->name = esc_html__( 'Revisions', 'wpforms-lite' );
$this->slug = 'revisions';
$this->icon = 'fa-history';
$this->title = $this->form && $this->form->post_type === 'wpforms-template' ?
__( 'Form Template Revisions', 'wpforms-lite' ) :
__( 'Form Revisions', 'wpforms-lite' );
* Hook into WordPress lifecycle.
private function hooks() {
// Add a notice above all panels if revision is loaded.
add_action( 'wpforms_builder_panels', [ $this, 'panel_notice' ], 100, 2 );
* Primary panel button in the left panel navigation.
* @param mixed $form The form object.
* @param string $view Current view/panel.
public function button( $form, $view ) {
$classes = 'wpforms-panel-revisions-button';
if ( $view === $this->slug ) {
if ( $this->form && ! wp_revisions_enabled( $this->form ) && ! wpforms()->get( 'revisions' )->panel_viewed() ) {
<span class="badge-exclamation">
<svg width="4" height="10" fill="none">
<path fill="#fff" fill-rule="evenodd" d="M3.5 8.1c0-.8-.7-1.5-1.5-1.5S.5 7.3.5 8.1 1.2 9.6 2 9.6 3.5 8.9 3.5 8ZM1 .9c-.3 0-.5.2-.4.4l.2 4.4c0 .2.2.3.4.3h1.6c.2 0 .3-.1.4-.3l.2-4.4c0-.2-.2-.4-.4-.4H1Z" clip-rule="evenodd"/>
'<div class="wpforms-panel-revisions-button-spacer"></div>
<button class="%1$s" data-panel="%2$s" title="%6$s">
<span class="screen-reader-text">%5$s</span>
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
* Output the Settings panel sidebar.
public function panel_sidebar() {
// Sidebar contents are not valid unless we have a form.
'<div class="wpforms-revisions-header">
esc_html( $this->title ),
esc_html__( 'Select a revision to roll back to that version. All changes, including settings, will be reverted.', 'wpforms-lite' )
// Render a list of form revisions, including current version. All data is safe, escaped in the template.
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo wpforms()->get( 'revisions' )->render_revisions_list();
$revisions_to_keep = wp_revisions_to_keep( $this->form );
if ( $revisions_to_keep === 0 ) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo wpforms_render( 'builder/revisions/notice-disabled' );
if ( $revisions_to_keep > 0 ) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'builder/revisions/notice-limited',
'revisions_to_keep' => $revisions_to_keep,
* Output revision notice above the panels.
public function panel_notice() {
$revision = wpforms()->get( 'revisions' )->get_revision();
'<a href="%1$s">%2$s</a>',
wpforms()->get( 'revisions' )->get_url(
'revision_id' => $revision->ID,
'action' => 'restore_revision',
__( 'Restore this revision', 'wpforms-lite' )
'<a href="%1$s">%2$s</a>',
esc_url( wpforms()->get( 'revisions' )->get_url() ),
__( 'go back to the current version', 'wpforms-lite' )
$message = sprintf( /* translators: %1$s - revision date, %2$s - revision time, %3$s - "Restore this revision" link, %4$s - "go back to the current version" link. */
__( 'You’re currently viewing a form revision from %1$s at %2$s. %3$s or %4$s.', 'wpforms-lite' ),
wpforms()->get( 'revisions' )->get_formatted_datetime( $revision->post_modified_gmt ),
wpforms()->get( 'revisions' )->get_formatted_datetime( $revision->post_modified_gmt, 'time' ),
'<div class="wpforms-revision-notice">
<p><i class="fa fa-history"></i>%s</p>
new WPForms_Builder_Panel_Revisions();