Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Wpct Http Bridge
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
codeccoop
WordPress
plugins
Wpct Http Bridge
Commits
32cea9b4
Commit
32cea9b4
authored
11 months ago
by
Lucas García
Browse files
Options
Downloads
Patches
Plain Diff
fix: abstract settings field render
parent
bb732991
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
abstract/class-settings.php
+29
-8
29 additions, 8 deletions
abstract/class-settings.php
with
29 additions
and
8 deletions
abstract/class-settings.php
+
29
−
8
View file @
32cea9b4
...
...
@@ -8,7 +8,6 @@ class Undefined
abstract
class
Settings
extends
Singleton
{
protected
$group_name
;
private
$_defaults
=
[];
...
...
@@ -67,7 +66,21 @@ abstract class Settings extends Singleton
);
}
public
function
field_render
(
$setting
,
$field
,
$value
=
new
Undefined
())
public
function
field_render
()
{
$args
=
func_get_args
();
$setting
=
$args
[
0
];
$field
=
$args
[
1
];
if
(
count
(
$args
)
>=
3
)
{
$value
=
$args
[
3
];
}
else
{
$value
=
new
Undefined
();
}
return
$this
->
_field_render
(
$setting
,
$field
,
$value
);
}
private
function
_field_render
(
$setting
,
$field
,
$value
)
{
$is_root
=
false
;
if
(
$value
instanceof
Undefined
)
{
...
...
@@ -115,9 +128,11 @@ abstract class Settings extends Singleton
$is_list
=
is_list
(
$data
);
foreach
(
array_keys
(
$data
)
as
$key
)
{
$fieldset
.
=
'<tr>'
;
if
(
!
$is_list
)
$fieldset
.
=
"<th>
{
$key
}
</th>"
;
if
(
!
$is_list
)
{
$fieldset
.
=
"<th>
{
$key
}
</th>"
;
}
$_field
=
$field
.
']['
.
$key
;
$fieldset
.
=
"<td>
{
$this
->
field_render
(
$setting
,
$_field
,
$data
[
$key
])
}
</td>"
;
$fieldset
.
=
"<td>
{
$this
->
field_render
(
$setting
,
$_field
,
$data
[
$key
])
}
</td>"
;
$fieldset
.
=
'</tr>'
;
}
$fieldset
.
=
'</table>'
;
...
...
@@ -129,7 +144,7 @@ abstract class Settings extends Singleton
{
$defaults
=
$this
->
get_default
(
$setting
);
ob_start
();
?>
?>
<div
class=
"
<?=
$setting
;
?>
__
<?=
$field
?>
--controls"
>
<button
class=
"button button-primary"
data-action=
"add"
>
Add
</button>
<button
class=
"button button-secondary"
data-action=
"remove"
>
Remove
</button>
...
...
@@ -147,7 +162,9 @@ abstract class Settings extends Singleton
public
function
option_getter
(
$setting
,
$option
)
{
$setting
=
get_option
(
$setting
)
?
get_option
(
$setting
)
:
[];
if
(
!
key_exists
(
$option
,
$setting
))
return
null
;
if
(
!
key_exists
(
$option
,
$setting
))
{
return
null
;
}
return
$setting
[
$option
];
}
...
...
@@ -160,7 +177,11 @@ abstract class Settings extends Singleton
function
is_list
(
$arr
)
{
if
(
!
is_array
(
$arr
))
return
false
;
if
(
sizeof
(
$arr
)
===
0
)
return
true
;
if
(
!
is_array
(
$arr
))
{
return
false
;
}
if
(
sizeof
(
$arr
)
===
0
)
{
return
true
;
}
return
array_keys
(
$arr
)
===
range
(
0
,
count
(
$arr
)
-
1
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment