创建于此:wp包括/类wp小部件。菲律宾比索#248
public function _register() {
$settings = $this->get_settings();
$empty = true;
// When $settings is an array-like object, get an intrinsic array for use with array_keys().
if ( $settings instanceof ArrayObject || $settings instanceof ArrayIterator ) {
$settings = $settings->getArrayCopy();
}
if ( is_array( $settings ) ) {
foreach ( array_keys( $settings ) as $number ) {
if ( is_numeric( $number ) ) {
$this->_set( $number );
$this->_register_one( $number );
$empty = false;
}
}
}
if ( $empty ) {
// If there are none, we register the widget\'s existence with a generic template.
$this->_set( 1 );
$this->_register_one();
}
}
get\\u settings函数检索保存在wp\\u options表中的小部件的选项。我在某种程度上把这些信息丢进了数据库。