最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Using Wordpress Boilerplate (WPBP) for WP Multisite Plugin

programmeradmin1浏览0评论

I want to write a simple Wordpress plugin for Wordpress Multisite and am using the WPBP template. I am not sure how I create code that runs in the master (Network) portion, or how I can make it run only on one site.

My questions are:

  1. I am planning to place everything into a class. Should I instantiate the class in the main (global) portion of the plugin file, or only in the callback method?

  2. How do I make my code run only on one of my sites (of the multisite)? How can I make it run for all sites?(Do I need to do a PHP check for a URI?

I want to write a simple Wordpress plugin for Wordpress Multisite and am using the WPBP template. I am not sure how I create code that runs in the master (Network) portion, or how I can make it run only on one site.

My questions are:

  1. I am planning to place everything into a class. Should I instantiate the class in the main (global) portion of the plugin file, or only in the callback method?

  2. How do I make my code run only on one of my sites (of the multisite)? How can I make it run for all sites?(Do I need to do a PHP check for a URI?

Share Improve this question asked Sep 25, 2019 at 22:14 TSGTSG 1054 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Depending on what you're doing, generally the code will only run on one site at a time. Multi site blogs have a "blog id". Most WP code will simply assume that you're referring the the current running site.

Each site has the ability to enable the plugin, or you can enable it for your entire network.

发布评论

评论列表(0)

  1. 暂无评论