Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Remove revision settings UI and filter #1319

Merged
merged 6 commits into from
Sep 21, 2024
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
4 changes: 2 additions & 2 deletions bluehost-wordpress-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Plugin URI: https://bluehost.com
* Update URI: https://github.com/bluehost/bluehost-wordpress-plugin
* Description: WordPress plugin that integrates a WordPress site with the Bluehost control panel, including performance, security, and update features.
* Version: 3.14.10
* Version: 3.14.11
* Requires at least: 6.4
* Requires PHP: 7.3
* Tested up to: 6.6.2
Expand All @@ -32,7 +32,7 @@
}

// Define constants
define( 'BLUEHOST_PLUGIN_VERSION', '3.14.10' );
define( 'BLUEHOST_PLUGIN_VERSION', '3.14.11' );
define( 'BLUEHOST_PLUGIN_FILE', __FILE__ );
define( 'BLUEHOST_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'BLUEHOST_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
Expand Down
12 changes: 0 additions & 12 deletions inc/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@

namespace Bluehost;

/**
* Filter wp revisions according to plugin setting
*
* @param int $num Number of posts to retain (unused).
* @param WP_Post|object $post Post object (unused).
* @return int
*/
function nfd_settings_revisions( $num, $post ) {
return get_option( 'nfd_wp_post_revisions', 5 );
}
add_filter( 'wp_revisions_to_keep', __NAMESPACE__ . '\\nfd_settings_revisions', 10, 2 );

if ( ! defined( 'EMPTY_TRASH_DAYS' ) ) {
$nfd_empty_trash_days = get_option( 'nfd_empty_trash_days', 30 );
define( 'EMPTY_TRASH_DAYS', $nfd_empty_trash_days );
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bluehost-wordpress-plugin",
"version": "3.14.10",
"version": "3.14.11",
"description": "WordPress plugin that integrates your WordPress site with the Bluehost control panel, including performance, security, and update features.",
"author": {
"name": "Bluehost",
Expand Down
92 changes: 0 additions & 92 deletions src/app/pages/settings/contentSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,97 +5,6 @@ import AppStore from 'App/data/store';
import { bluehostSettingsApiFetch } from 'App/util/helpers';
import { useNotification } from 'App/components/notifications';

const ContentRevisions = ( { setError, notify } ) => {
const { store, setStore } = useContext( AppStore );
const [ contentRevisions, setNumContentRevisions ] = useState(
store.contentRevisions
);

const contentRevisionsNoticeTitle = () => {
return __( 'Post revision setting saved ', 'wp-plugin-bluehost' );
};

const contentRevisionsNoticeText = () => {
return (
__( 'Posts will save ', 'wp-plugin-bluehost' ) +
contentRevisions +
_n(
' revision.',
' revisions.',
parseInt( contentRevisions ),
'wp-plugin-bluehost'
)
);
};

const contentRevisionsDescriptionText = () => {
return (
__(
'Saving drafts and updating published content creates revisions. Make changes with confidence, knowing you can take ',
'wp-plugin-bluehost'
) +
contentRevisions +
_n(
' step back.',
' steps back.',
parseInt( contentRevisions ),
'wp-plugin-bluehost'
)
);
};

const handleContentRevisionsChange = ( value ) => {
bluehostSettingsApiFetch(
{ contentRevisions: value },
setError,
// eslint-disable-next-line no-unused-vars
( response ) => {
setNumContentRevisions( value );
}
);
};

const notifySuccess = () => {
notify.push( 'content-revision-notice', {
title: contentRevisionsNoticeTitle(),
description: <span>{ contentRevisionsNoticeText() }</span>,
variant: 'success',
autoDismiss: 5000,
} );
};

useUpdateEffect( () => {
setStore( {
...store,
contentRevisions,
} );

notifySuccess();
}, [ contentRevisions ] );

return (
<SelectField
id="content-revisions-select"
label={ __(
'Number of revisions per post to save ',
'wp-plugin-bluehost'
) }
description={ contentRevisionsDescriptionText() }
value={ contentRevisions }
selectedLabel={ contentRevisions }
options={ [
{ label: '1', value: '1' },
{ label: '5', value: '5' },
{ label: '10', value: '10' },
{ label: '20', value: '20' },
{ label: '40', value: '40' },
] }
onChange={ handleContentRevisionsChange }
className="nfd-select-field__spaced"
/>
);
};

const EmptyTrash = ( { setError, notify } ) => {
const { store, setStore } = useContext( AppStore );
const [ emptyTrashDays, setNumEmptyTrashDays ] = useState(
Expand Down Expand Up @@ -200,7 +109,6 @@ const ContentSettings = () => {
) }
>
<div className="nfd-flex nfd-flex-col nfd-gap-4">
<ContentRevisions setError={ setError } notify={ notify } />
<EmptyTrash setError={ setError } notify={ notify } />

{ isError && (
Expand Down
34 changes: 0 additions & 34 deletions tests/cypress/integration/settings.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,40 +200,6 @@ describe( 'Settings Page', function () {
} );

it( 'Content Settings Work', () => {
cy.get( '[data-id="content-revisions-select"]' ).click();
cy.wait( 100 );
cy.get( '[data-id="content-revisions-select"]' )
.parent()
.next( 'ul.nfd-select__options' )
.find( 'li:first' )
.click(); // 1
cy.wait( 100 );
cy.get( '#content-revisions-select__description' )
.contains( 'you can take 1 step back.' )
.should( 'be.visible' );

cy.get( '[data-id="content-revisions-select"]' ).click();
cy.wait( 1000 );
cy.get( '[data-id="content-revisions-select"]' )
.parent()
.next( 'ul.nfd-select__options' )
.find( 'li:last' )
.click(); // 40
cy.wait( 100 );
cy.get( '#content-revisions-select__description' )
.contains( 'you can take 40 steps back.' )
.should( 'be.visible' );

cy.get( '[data-id="content-revisions-select"]' ).click();
cy.wait( 500 );
cy.get( '[data-id="content-revisions-select"]' )
.parent()
.next( 'ul.nfd-select__options' )
.find( 'li:nth-child(2)' )
.click(); // 5
cy.get( '#content-revisions-select__description' )
.contains( 'you can take 5 steps back.' )
.should( 'be.visible' );

// Empty Trash Setting
cy.get( '[data-id="empty-trash-select"]' ).click();
Expand Down
Loading