Skip to content

Commit

Permalink
Merge pull request #396 from codepress/release/4.7.2
Browse files Browse the repository at this point in the history
Release 4.7.2
  • Loading branch information
DGStefan authored Jan 16, 2024
2 parents 9bd70cb + 3516de0 commit ed6a61f
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 83 deletions.
4 changes: 3 additions & 1 deletion classes/AdminColumns.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ private function create_container(): DI\Container
return $storage;
},
RestoreSettingsRequest::class => static function (Storage $storage): RestoreSettingsRequest {
return new RestoreSettingsRequest($storage->get_repository(Types::DATABASE));
return new RestoreSettingsRequest(
$storage->get_repository(Types::DATABASE)->get_list_screen_repository()
);
},
Plugin::class => static function (): Plugin {
return Plugin::create(AC_FILE, new Version(AC_VERSION));
Expand Down
2 changes: 1 addition & 1 deletion classes/Check/AddonAvailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function display(Screen $screen): void

$link = sprintf(
'<a href="%s">%s</a>',
'https://www.google.com',
'https://www.admincolumns.com',
__('Get Admin Columns Pro', 'codepress-admin-columns')
);
$message = sprintf('%s %s', $support_text, $link);
Expand Down
93 changes: 49 additions & 44 deletions classes/Controller/RestoreSettingsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +3,71 @@
namespace AC\Controller;

use AC\Capabilities;
use AC\ListScreenRepository\Storage\ListScreenRepository;
use AC\ListScreenRepository;
use AC\Message\Notice;
use AC\Registerable;

class RestoreSettingsRequest implements Registerable {
class RestoreSettingsRequest implements Registerable
{

/**
* @var ListScreenRepository
*/
private $repository;
/**
* @var ListScreenRepository
*/
private $repository;

public function __construct( ListScreenRepository $repository ) {
$this->repository = $repository;
}

public function register(): void
public function __construct(ListScreenRepository $repository)
{
add_action( 'admin_init', [ $this, 'handle_request' ] );
}
$this->repository = $repository;
}

public function handle_request() {
if ( ! current_user_can( Capabilities::MANAGE ) ) {
return;
}
public function register(): void
{
add_action('admin_init', [$this, 'handle_request']);
}

if ( 'restore' !== filter_input( INPUT_POST, 'ac_action' ) ) {
return;
}
public function handle_request()
{
if ( ! current_user_can(Capabilities::MANAGE)) {
return;
}

if ( ! wp_verify_nonce( filter_input( INPUT_POST, '_ac_nonce' ), 'restore' ) ) {
return;
}
if ('restore' !== filter_input(INPUT_POST, 'ac_action')) {
return;
}

foreach ( $this->repository->find_all() as $list_screen ) {
$this->repository->delete( $list_screen );
}
if ( ! wp_verify_nonce(filter_input(INPUT_POST, '_ac_nonce'), 'restore')) {
return;
}

$this->delete_options();
$this->delete_user_preferences();
foreach ($this->repository->find_all() as $list_screen) {
$this->repository->delete($list_screen);
}

do_action( 'ac/settings/restore' );
$this->delete_options();
$this->delete_user_preferences();

$notice = new Notice( __( 'Default settings successfully restored.', 'codepress-admin-columns' ) );
$notice->register();
}
do_action('ac/settings/restore');

private function delete_user_preferences() {
global $wpdb;
$notice = new Notice(__('Default settings successfully restored.', 'codepress-admin-columns'));
$notice->register();
}

$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key LIKE '{$wpdb->get_blog_prefix()}ac_preferences_%'" );
}
private function delete_user_preferences()
{
global $wpdb;

private function delete_options() {
global $wpdb;
$wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key LIKE '{$wpdb->get_blog_prefix()}ac_preferences_%'");
}

$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'ac_api_request%'" );
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'ac_cache_data%'" );
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'ac_sorting_%'" );
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'cpac_options%__default'" );
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'cpac_general_options'" );
}
private function delete_options()
{
global $wpdb;

$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'ac_api_request%'");
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'ac_cache_data%'");
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'ac_sorting_%'");
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'cpac_options%__default'");
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'cpac_general_options'");
}

}
4 changes: 2 additions & 2 deletions languages/codepress-admin-columns.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Language-Team: Admin Columns <info@admincolumns.com>\n"
"Last-Translator: Codepress <info@codepress.nl\n"
"POT-Creation-Date: 2024-01-09 09:08+0000\n"
"POT-Creation-Date: 2024-01-16 09:17+0000\n"
"X-Poedit-Basepath: ..\n"
"X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
"X-Poedit-SearchPath-0: .\n"
Expand Down Expand Up @@ -200,7 +200,7 @@ msgstr ""
msgid "Settings for %s restored successfully."
msgstr ""

#: classes/Controller/RestoreSettingsRequest.php:48
#: classes/Controller/RestoreSettingsRequest.php:51
msgid "Default settings successfully restored."
msgstr ""

Expand Down
9 changes: 7 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Contributors: codepress, tschutter, davidmosterd, engelen, dungengronovius
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZDZRSYLQ4Z76J
Tags: plugins, wordpress, admin, column, columns, custom columns, custom fields, image, dashboard, sortable, filters, posts, media, users, pages, posttypes, manage columns, wp-admin
Requires at least: 4.7.1
Tested up to: 6.3.1
Tested up to: 6.4.2
Requires PHP: 7.2
Stable tag: 4.7
Stable tag: 4.7.2

Customise columns on the administration screens for post(types), pages, media, comments, links and users with an easy to use drag-and-drop interface.

Expand Down Expand Up @@ -209,6 +209,11 @@ You can find a list of the available actions and filters (and examples on how to

== Changelog ==

= 4.7.2 =
Release Date: January 16th, 2024

* [Fixed] Fatal error when Restoring the settings in the Settings tab

= 4.7.1 =
Release Date: January 9th, 2024

Expand Down
70 changes: 37 additions & 33 deletions src/package-lock.json

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

0 comments on commit ed6a61f

Please sign in to comment.