appzz/wof

用于生成设置页面的 wp 选项框架

2.1.6 2022-07-21 09:40 UTC

This package is auto-updated.

Last update: 2024-09-21 13:59:27 UTC


README

此框架帮助实现 WP 选项 API 并生成两步设置页面:)

设置

  • 在定义 ABSPATH 后,将 composer 自动加载 require 到 wp-config.php 中
/** Composer */
require_once(ABSPATH . 'composer/vendor/autoload.php');
  • 安装包 appzz/wof

如何使用

  • 在插件的主文件中
#!php
use AppZz\Wp\Options\Framework as WP_Options_Framework;

if ( ! class_exists('AppZz\Wp\Options\Framework')) {
	return;
}

$wof = new WP_Options_Framework ( 'Sample Plugin', 'sample_page', 'options-general.php', FALSE, FALSE );
$wof->addTab ( 'Main options', 'global', array ('player_options'=>'Define player options', 'api_options'=>'RM API') );
$wof->addTab ( 'Searh options', 'search', array ('sphinxql_options'=>'Setup SphinxQL') );

$wof->addFields ( 'global', array (
array (
	'fid'         => 'width',
	'title'       => 'Player width',
	'type'        => 'text',
	'section'     => 'player_options',
	'std'         => 620,
	'validator'   => 'intval',
	'class'       => NULL,
	'desc'        => 'Player width by default',
),
array (
	'fid'         => 'height',
	'title'       => 'Player height',
	'type'        => 'text',
	'section'     => 'player_options',
	'std'         => 465,
	'validator'   => 'intval',
	'class'       => NULL,
	'desc'        => 'Player height by default',
)
));

}