Resources to learn OOP for WordPress plugins, custom post types, etc

In a plugin, I need to create a custom post type and the associated admin menu modifications with a class rather than pr

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
Add a comment  | 

1 Answer 1

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' ) );

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

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

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

关注微信