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
!4
WIP: Initial release
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
WIP: Initial release
develop
into
master
Overview
0
Commits
18
Pipelines
29
Changes
12
Merged
Erick Hitter
requested to merge
develop
into
master
6 years ago
Overview
0
Commits
18
Pipelines
29
Changes
12
Expand
Fixes
#1
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
592f0567
18 commits,
6 years ago
12 files
+
510
−
17
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
12
Search (e.g. *.vue) (Ctrl+P)
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