File: /www/wwwroot/1.scey.cn/wp-content/plugins/hao-image-box/inc/hao-image-setting.php
<?php
add_action('admin_menu', 'hao_image_box_option_page');
if (!function_exists('hao_image_box_option_page')) {
function hao_image_box_option_page()
{
add_options_page("hao image box 设置", 'hao image box 设置', 'manage_options', 'hao-image-box', 'hao_image_box_display');
}
}
if (!function_exists('hao_image_box_display')) {
function hao_image_box_display()
{
?>
<div class="wrap">
<div id="icon-themes" class="icon32"></div>
<h2>Hao Image Box</h2>
<?php settings_errors(); ?>
<form method="post" action="options.php">
<?php settings_fields('hao_image_box_options');
do_settings_sections('hao_image_box_options');
submit_button(); ?>
</form>
</div>
<?php
}
}
if (!function_exists('hao_image_box_initialize_plugin_options')) {
function hao_image_box_initialize_plugin_options()
{
if (false == get_option('hao_image_box_options')) {
add_option('hao_image_box_options');
}
add_settings_section(
'general_settings_section',
'Hao Image Box 设置',
'sandbox_general_options_callback',
'hao_image_box_options'
);
add_settings_field(
'container_box',
'css选择器',
'hao_image_box_field_callback',
'hao_image_box_options',
'general_settings_section',
array(
'type' => 'input',
'name' => 'container_box',
'value' => '',
'desc' => '请设置包含图片的容器,如果是标签请直接填写标签名称,如<code>body</code>。如果是class请以<code>.</code>开头。如果是id,请以<code>#</code>开头。'
)
);
add_settings_field(
'overlay_disply',
'遮罩',
'hao_image_box_field_callback',
'hao_image_box_options',
'general_settings_section',
array(
'type' => 'checkbox',
'name' => 'overlay_disply',
'value' => '0',
'desc' => '是否显示遮罩'
)
);
add_settings_field(
'button_disply',
'关闭按钮',
'hao_image_box_field_callback',
'hao_image_box_options',
'general_settings_section',
array(
'type' => 'checkbox',
'name' => 'button_disply',
'value' => '0',
'desc' => '是否显示关闭按钮'
)
);
add_settings_field(
'caption_disply',
'图片标题',
'hao_image_box_field_callback',
'hao_image_box_options',
'general_settings_section',
array(
'type' => 'checkbox',
'name' => 'caption_disply',
'value' => '0',
'desc' => '是否显示图片标题'
)
);
add_settings_field(
'navigation_display',
'指示器',
'hao_image_box_field_callback',
'hao_image_box_options',
'general_settings_section',
array(
'type' => 'checkbox',
'name' => 'navigation_display',
'value' => '0',
'desc' => '是否显示指示器'
)
);
add_settings_field(
'arrows_display',
'左右箭头',
'hao_image_box_field_callback',
'hao_image_box_options',
'general_settings_section',
array(
'type' => 'checkbox',
'name' => 'arrows_display',
'value' => '0',
'desc' => '是否显示左右箭头'
)
);
add_settings_field(
'fullscreen_open',
'点击ENTER键进入全屏',
'hao_image_box_field_callback',
'hao_image_box_options',
'general_settings_section',
array(
'type' => 'checkbox',
'name' => 'fullscreen_open',
'value' => '0',
'desc' => '点击ENTER键进入全屏'
)
);
register_setting(
'hao_image_box_options',
'hao_image_box_options',
'hao_image_box_validate_input'
);
}
}
add_action('admin_init', 'hao_image_box_initialize_plugin_options');
if (!function_exists('hao_image_box_general_options_callback')) {
function hao_image_box_general_options_callback()
{
echo '<p>请设置Hao Image Box的参数,详细设置说明请访问:<a target="_blank" href="https://www.haozhuti.cn/wordpress/plugins/147.html">https://www.haozhuti.cn/wordpress/plugins/147.html</a></p>';
}
}
if (!function_exists('hao_image_box_field_callback')) {
function hao_image_box_field_callback($args)
{
$options = get_option('hao_image_box_options');
$value = isset($options[$args['name']]) ? $options[$args['name']] : $args['value'];
$html = "";
if ($args['type'] == 'checkbox') {
$html = '<input type="checkbox" id="' . $args['name'] . '" name="hao_image_box_options[' . $args['name'] . ']" value="1" ' . checked(1, $value, false) . '/>';
} else if ($args['type'] == 'input') {
$html = '<input type="text" id="' . $args['name'] . '" name="hao_image_box_options[' . $args['name'] . ']" value="' . $value . '" />';
}
$html .= '<label for="' . $args['name'] . '"> ' . $args["desc"] . '</label>';
echo $html;
}
}
if (!function_exists('hao_image_box_validate_input')) {
function hao_image_box_validate_input($input)
{
$output = array();
foreach ($input as $key => $value) {
if (isset($input[$key])) {
$output[$key] = sanitize_text_field(strip_tags(stripslashes($input[$key])));
}
}
return apply_filters('hao_image_box_validate_input', $output, $input);
}
}