admin管理员组文章数量:1395381
In a plugin, I need to create a custom post type and the associated admin menu modifications with a class rather than procedural code. What is the basic skeleton that I need to build off of in order to do so, and how does that class get hooked into WordPress (i.e., how do I do the "add_action('init','register_my_custom_post_type'), etc. with a class)?
In a plugin, I need to create a custom post type and the associated admin menu modifications with a class rather than procedural code. What is the basic skeleton that I need to build off of in order to do so, and how does that class get hooked into WordPress (i.e., how do I do the "add_action('init','register_my_custom_post_type'), etc. with a class)?
Share Improve this question edited Oct 6, 2013 at 11:12 philosophyguy asked Oct 5, 2013 at 15:21 philosophyguyphilosophyguy 1932 silver badges8 bronze badges 2- This very resource: wordpress.stackexchange/… – brasofilo Commented Oct 5, 2013 at 20:03
- Just for fun I did a quick google search »wordpress oop«. I'm not going to post links here, but I can tell you, the first page alone is very resourceful. You might want to start there, besides looking deeper into what WPSE already offers - like brasofilo suggested. Another hint would be looking for those existing wordpress plugin boilerplates/skeletons. – Nicolai Grossherr Commented Oct 6, 2013 at 11:35
1 Answer
Reset to default 0(i.e., how do I do the
add_action('init','register_my_custom_post_type')
, etc. with a class)?
You pass the callback from inside the class, using $this
:
add_action( 'init', array( $this, 'register_my_custom_post_type' ) );
本文标签: Resources to learn OOP for WordPress pluginscustom post typesetc
版权声明:本文标题:Resources to learn OOP for WordPress plugins, custom post types, etc 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744695756a2620265.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论