Php 如何在wordpress上创建elementor的小部件类别

Php 如何在wordpress上创建elementor的小部件类别,php,wordpress,web,elementor,Php,Wordpress,Web,Elementor,我想在wordpress的元素编辑器中添加一个新类别。 我找到了链接, 但我不知道该怎么办。因为我是初学者。 如何将代码添加到哪个文件中。 我是说一步一步。 如何在任何路径中创建php文件,以及如何包含该php文件? 我可以为它创建一个新的php文件吗?或者将它们插入当前elementor php文件?在插件文件夹中创建一个单独的文件(例如:helper.php),并将其包含到主插件加载程序文件中。将以下代码粘贴到帮助文件中。这将在Elementor的小部件侧栏中创建一个单独的类别 <?p

我想在wordpress的元素编辑器中添加一个新类别。 我找到了链接, 但我不知道该怎么办。因为我是初学者。 如何将代码添加到哪个文件中。 我是说一步一步。 如何在任何路径中创建php文件,以及如何包含该php文件? 我可以为它创建一个新的php文件吗?或者将它们插入当前elementor php文件?

在插件文件夹中创建一个单独的文件(例如:helper.php),并将其包含到主插件加载程序文件中。将以下代码粘贴到帮助文件中。这将在Elementor的小部件侧栏中创建一个单独的类别

<?php 
namespace Elementor;

function category_elementor_init(){
    Plugin::instance()->elements_manager->add_category(
        'category-for-elementor',
        [
            'title'  => 'Elementor Category',
            'icon' => 'font'
        ],
        1
    );
}
add_action('elementor/init', 'Elementor\category_elementor_init');
在插件文件夹中创建一个单独的文件(例如:helper.php),并将其包含到主插件加载程序文件中。将以下代码粘贴到帮助文件中。这将在Elementor的小部件侧栏中创建一个单独的类别

<?php 
namespace Elementor;

function category_elementor_init(){
    Plugin::instance()->elements_manager->add_category(
        'category-for-elementor',
        [
            'title'  => 'Elementor Category',
            'icon' => 'font'
        ],
        1
    );
}
add_action('elementor/init', 'Elementor\category_elementor_init');

与文档一样:

首先创建自定义插件,希望您知道如何创建自定义插件:

简短演示: 请记住,完整的Elementor core是用OOP编写的。 假设插件名为elementtest

<?php
/**
 * Plugin Name: ElementorTest
 * Plugin URI:  https://example.com/plugins/ElementorTest/
 * Description: Basic Elementor Extension
 * Version:     1.1
 * Author:      Ahmed Maruf
 * Author URI:  https://author.example.com/
 * License:     GPL2
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: elementortestplugin
 * Domain Path: /languages
 */

其余的都是不言自明的。对于小部件类别,框架也类似。希望这会有所帮助

与文档一样:

首先创建自定义插件,希望您知道如何创建自定义插件:

简短演示: 请记住,完整的Elementor core是用OOP编写的。 假设插件名为elementtest

<?php
/**
 * Plugin Name: ElementorTest
 * Plugin URI:  https://example.com/plugins/ElementorTest/
 * Description: Basic Elementor Extension
 * Version:     1.1
 * Author:      Ahmed Maruf
 * Author URI:  https://author.example.com/
 * License:     GPL2
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: elementortestplugin
 * Domain Path: /languages
 */

其余的都是不言自明的。对于小部件类别,框架也类似。希望这会有所帮助

谢谢你的回答。但我有个问题要解决。我补充了以下内容code@Michael,很高兴知道你已经解决了这个问题。除此之外,这里还有输出自定义类别以及其中的小部件的代码的详细信息。你可以看一下:谢谢你的回答。但我有个问题要解决。我补充了以下内容code@Michael,很高兴知道你已经解决了这个问题。除此之外,这里还有输出自定义类别以及其中的小部件的代码的详细信息。你可以看一下:谢谢你的回答,罗比。但是我想一步一步地了解详细情况。你对
名称空间Elementor
是什么意思?谢谢你的回答,Robi。但我想一步一步地了解详细情况。您对
名称空间Elementor
是什么意思?