How to define the slug for my custom plugin?

I have created a custom plugin.How do I define its slug?To clarify, if I attach a custom PHP function to themanage_p

I have created a custom plugin. How do I define its slug?

To clarify, if I attach a custom PHP function to the manage_plugins_custom_column hook, and in that function print the value of the $plugin_data array for each plugin in my WordPress installation, that array will contain information about each plugin. Here is such a function:

function opn_render_date( $column_name, $plugin_file, $plugin_data ) {
  error_log( print_r( $plugin_data, true ) );
}
add_action( 'manage_plugins_custom_column', 'opn_render_date', 10, 3 );

And here is example output for one popular plugin in the WordPress repo (Classic Editor). In that output, the array element $plugin_data['slug'] => classic-editor can be seen. I have created a plugin, installed it, and activated it. The plugin functions as expected. But when I print out the same $plugin_data[] for my plugin, $plugin_data['slug'] does not exist. Why is that? How do I define the slug for my plugin?

If the issue is related to the header in my main plugin PHP file, that header can be seen here.

Maybe a slug is assigned by WordPress, only after a plugin is accepted to the WordPress plugin repo? I have not yet submitted it there.

edit: To clarify, I've written a plugin that is installed/activated via Dashboard-->Plugins.

I have created a custom plugin. How do I define its slug?

To clarify, if I attach a custom PHP function to the manage_plugins_custom_column hook, and in that function print the value of the $plugin_data array for each plugin in my WordPress installation, that array will contain information about each plugin. Here is such a function:

function opn_render_date( $column_name, $plugin_file, $plugin_data ) {
  error_log( print_r( $plugin_data, true ) );
}
add_action( 'manage_plugins_custom_column', 'opn_render_date', 10, 3 );

And here is example output for one popular plugin in the WordPress repo (Classic Editor). In that output, the array element $plugin_data['slug'] => classic-editor can be seen. I have created a plugin, installed it, and activated it. The plugin functions as expected. But when I print out the same $plugin_data[] for my plugin, $plugin_data['slug'] does not exist. Why is that? How do I define the slug for my plugin?

If the issue is related to the header in my main plugin PHP file, that header can be seen here.

Maybe a slug is assigned by WordPress, only after a plugin is accepted to the WordPress plugin repo? I have not yet submitted it there.

edit: To clarify, I've written a plugin that is installed/activated via Dashboard-->Plugins.

Share Improve this question edited Oct 21, 2019 at 13:36 cag8f asked Sep 16, 2019 at 14:22 cag8fcag8f 1,9973 gold badges21 silver badges31 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

I eventually submitted this plugin to the WordPress repo. As soon as it was accepted, my plugin was assigned a slug. So it looks like the WordPress plugin admins assign your plugin a slug during the initial review process.

By default, it should be the folder of your plugin.

If you use wp cli, you can use

wp plugin list

to show all the plugin slugs.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745064979a4609201.html

相关推荐

  • How to define the slug for my custom plugin?

    I have created a custom plugin.How do I define its slug?To clarify, if I attach a custom PHP function to themanage_p

    16小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信