我有以下代码,但wp告诉我:
警告: call_user_func_array()要求参数%1是有效的回调,在第287行的/home/deniztas/hekim.deniz-tasarim.site/wp-includes/class-wp-hook.php中找不到函数'widget_categories‘或函数名无效
那么,为什么我不能添加这个函数呢?我必须做什么?
<?php
/**
* Plugin Name: Hekim - Elementor Extension
* Description: For Hekim Theme
* Plugin URI: https://themeforest.net/user/helvatica
* Version: 1.0.0
* Author: Helvatica Themes
* Author URI: https://themeforest.net/user/helvatica
* Text Domain: hekim-plugin-elementor-extension
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Main Elementor Test Extension Class
*
* The main class that initiates and runs the plugin.
*
* @since 1.0.0
*/
final class Hekim_Elementor {
/**
* widget_categories
*
* Register new category for widgets.
*
* @since 1.2.0
* @access public
*/
public function widget_categories( $elements_manager ) {
$elements_manager->add_category(
'hero-section',
[
'title' => esc_html__( 'Hero Sections for elemntor', 'megaaddons' ),
'icon' => 'fa fa-plug',
]
);
}
etc.etc.
}
add_action( 'elementor/elements/categories_registered', 'widget_categories' );
?>发布于 2020-05-16 22:25:55
我认为您希望在Elementor中添加小部件类别,以便将小部件分组(请更清楚地说明您下次在问题中要达到的目标)。所以如果这就是你想要实现的,你的插件代码应该是这样的:
<?php
/**
* Plugin Name: Hekim - Elementor Extension
* Description: For Hekim Theme
* Plugin URI: https://themeforest.net/user/helvatica
* Version: 1.0.0
* Author: Helvatica Themes
* Author URI: https://themeforest.net/user/helvatica
* Text Domain: hekim-plugin-elementor-extension
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
function add_elementor_widget_categories( $elements_manager ) {
$elements_manager->add_category(
'hero-section',
[
'title' => esc_html__( 'Hero Sections for elemntor', 'megaaddons' ),
'icon' => 'fa fa-plug',
]
);
}
add_action( 'elementor/elements/categories_registered', 'add_elementor_widget_categories' );
?>我在文档中找到了正确的结构:https://developers.elementor.com/widget-categories/
您不需要这个类和所有其他东西,只需连接add_action即可。
希望这能有所帮助。
https://stackoverflow.com/questions/61837336
复制相似问题