Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Camo Image Proxy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
WP Plugins
Camo Image Proxy
Merge requests
!10
WIP: Add typehint checking
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
WIP: Add typehint checking
phpcs-typehint
into
master
Overview
0
Commits
9
Pipelines
2
Changes
12
Closed
Erick Hitter
requested to merge
phpcs-typehint
into
master
6 years ago
Overview
0
Commits
9
Pipelines
2
Changes
12
Expand
0
0
Merge request reports
Viewing commit
ecc43310
Prev
Next
Show latest version
12 files
+
516
−
20
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
12
Search (e.g. *.vue) (Ctrl+P)
ecc43310
Merge branch 'add/lint' into 'master'
· ecc43310
Erick Hitter
authored
6 years ago
add linting See merge request
!6
inc/class-options-page.php
0 → 100644
+
86
−
0
Options
<?php
/**
* Plugin options page
*
* @package Camo_Image_Proxy
*/
namespace
Camo_Image_Proxy
;
/**
* Class Options_Page
*/
class
Options_Page
{
use
Singleton
;
/**
* Settings screen section
*
* @var string
*/
private
$section
=
'camp-image-proxy'
;
/**
* Field labels
*
* @var array
*/
private
$labels
=
[];
/**
* Option name
*
* @var string
*/
private
$name
;
/**
* Hooks
*/
public
function
setup
()
{
$this
->
name
=
Options
::
instance
()
->
name
;
$this
->
labels
[
'host'
]
=
__
(
'Host'
,
'camo-image-proxy'
);
$this
->
labels
[
'key'
]
=
__
(
'Shared Key'
,
'camo-image-proxy'
);
add_action
(
'admin_init'
,
[
$this
,
'action_admin_init'
]
);
}
/**
* Add fields to Media settings page
*/
public
function
action_admin_init
()
{
register_setting
(
'media'
,
$this
->
name
,
[
Options
::
instance
(),
'sanitize_all'
]
);
add_settings_section
(
$this
->
section
,
__
(
'Camo Image Proxy'
,
'camo-image-proxy'
),
'__return_false'
,
'media'
);
foreach
(
$this
->
labels
as
$key
=>
$label
)
{
$args
=
[
'option'
=>
$key
,
'label'
=>
$label
,
];
add_settings_field
(
$key
,
$label
,
[
$this
,
'screen'
],
'media'
,
$this
->
section
,
$args
);
}
}
/**
* Render options field
*
* @param array $args Field arguments.
*/
public
function
screen
(
$args
)
{
$value
=
Options
::
instance
()
->
get
(
$args
[
'option'
]
);
$input_type
=
'host'
===
$args
[
'option'
]
?
'url'
:
'text'
;
$name
=
sprintf
(
'%1$s[%2$s]'
,
$this
->
name
,
$args
[
'option'
]
);
$html_id
=
sprintf
(
'%1$s-%2$s'
,
str_replace
(
'_'
,
'-'
,
$this
->
name
),
$args
[
'option'
]
);
?>
<input
type=
"
<?php
echo
esc_attr
(
$input_type
);
?>
"
name=
"
<?php
echo
esc_attr
(
$name
);
?>
"
class=
"regular-text"
id=
"
<?php
echo
esc_attr
(
$html_id
);
?>
"
value=
"
<?php
echo
esc_attr
(
$value
);
?>
"
/>
<?php
}
}
Loading