Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michael Iseard
Kudos-Donations
Commits
072e2d6d
Commit
072e2d6d
authored
Aug 17, 2020
by
Michael Iseard
Browse files
Add constructor to settings class
parent
c2df7d73
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/Admin/Admin.php
View file @
072e2d6d
...
...
@@ -327,7 +327,8 @@ class Admin {
*/
public
function
register_settings
()
{
Settings
::
register_settings
();
$settings
=
new
Settings
();
$settings
->
register_settings
();
}
}
app/Helpers/Settings.php
View file @
072e2d6d
...
...
@@ -10,16 +10,16 @@ class Settings {
* Settings configuration
* @var array
*/
private
static
$settings
;
private
$settings
;
/**
* Settings
init
.
* Settings
class constructor
.
*
* @since 2.0.0
*/
p
rivate
stat
ic
function
ini
t
()
{
p
ubl
ic
function
__construc
t
()
{
self
::
$
settings
=
apply_filters
(
'kudos_register_settings'
,
[
$this
->
settings
=
apply_filters
(
'kudos_register_settings'
,
[
'mollie_connected'
=>
[
'type'
=>
'boolean'
,
'show_in_rest'
=>
true
,
...
...
@@ -154,8 +154,7 @@ class Settings {
}
/**
* Gets the setting from the database, if no setting available
* then returns default value.
* Gets the setting from the database
*
* @param $name
* @return false|mixed|void
...
...
@@ -173,16 +172,15 @@ class Settings {
*
* @since 2.0.0
*/
public
static
function
register_settings
()
{
public
function
register_settings
()
{
self
::
init
();
foreach
(
self
::
$settings
as
$name
=>
$setting
)
{
foreach
(
$this
->
settings
as
$name
=>
$setting
)
{
register_setting
(
'kudos_donations'
,
self
::
PREFIX
.
$name
,
$setting
);
}
}
/**
...
...
@@ -190,11 +188,9 @@ class Settings {
*
* @since 2.0.0
*/
public
static
function
add_defaults
()
{
public
function
add_defaults
()
{
self
::
init
();
foreach
(
self
::
$settings
as
$name
=>
$setting
)
{
foreach
(
$this
->
settings
as
$name
=>
$setting
)
{
add_option
(
self
::
PREFIX
.
$name
,
$setting
[
'default'
]
??
''
);
}
...
...
@@ -205,11 +201,9 @@ class Settings {
*
* @since 2.0.0
*/
public
static
function
remove_settings
()
{
self
::
init
();
public
function
remove_settings
()
{
foreach
(
self
::
$
settings
as
$key
=>
$setting
)
{
foreach
(
$this
->
settings
as
$key
=>
$setting
)
{
delete_option
(
$key
);
}
...
...
app/Service/ActivatorService.php
View file @
072e2d6d
...
...
@@ -147,7 +147,9 @@ class ActivatorService {
private
static
function
set_defaults
()
{
update_option
(
'_kudos_donations_version'
,
KUDOS_VERSION
);
Settings
::
add_defaults
();
$settings
=
new
Settings
();
$settings
->
add_defaults
();
}
}
app/Service/DeactivatorService.php
View file @
072e2d6d
...
...
@@ -30,7 +30,8 @@ class DeactivatorService {
public
static
function
deactivate
()
{
// Clean-up settings from database
Settings
::
remove_settings
();
$settings
=
new
Settings
();
$settings
->
remove_settings
();
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment