php 自定义小部件区域生成器
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 自定义小部件区域生成器相关的知识,希望对你有一定的参考价值。
<?php
if ( ! function_exists( 'pixel_designs_widget_area_generator' ) ) {
function pixel_designs_widget_area_generator( array $settings ) {
$defaults = [
'id' => '',
'name' => __('', 'sandstorm-2018'),
'description' => __('', 'sandstorm-2018'),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h6>',
'after_title' => '</h6>',
];
$settings = array_merge( $defaults, $settings );
register_sidebar( $settings );
}
}
if ( ! function_exists( 'pixel_designs_widget_areas' ) ) {
function pixel_designs_widget_areas() {
$widgets = [
'footer-area-1' => [
'id' => 'footer-area-1',
'name' => __( 'Footer Area 1', 'sandstorm-2018' ),
],
'footer-area-2' => [
'id' => 'footer-area-2',
'name' => __( 'Footer Area 2', 'sandstorm-2018' ),
],
'footer-area-3' => [
'id' => 'footer-area-3',
'name' => __( 'Footer Area 3', 'sandstorm-2018' ),
],
'footer-area-4' => [
'id' => 'footer-area-4',
'name' => __( 'Footer Area 4', 'sandstorm-2018' ),
],
'footer-area-5' => [
'id' => 'footer-area-5',
'name' => __( 'Footer Area 5', 'sandstorm-2018' ),
],
'footer-area-6' => [
'id' => 'footer-area-6',
'name' => __( 'Footer Area 6', 'sandstorm-2018' ),
],
];
foreach ( $widgets as $widget ) {
pixel_designs_widget_area_generator( $widget );
}
}
add_action( 'widgets_init', 'pixel_designs_widget_areas' );
}
以上是关于php 自定义小部件区域生成器的主要内容,如果未能解决你的问题,请参考以下文章
php 自定义小部件区域
php 自定义小部件区域
php 如何创建自定义小部件区域
php 添加自定义小部件区域
PHP Wordpress:自定义小部件区域
自定义 Qt 设计器小部件:包含自定义垂直布局的滚动区域