實用的 WordPress ICP 備案許可管理器

可在 WordPress 多站點網路的任何站點上執行功能的程式碼段

如果需要在 WordPress 多站點的子站中的任何子站,執行任何功能,看嘗試使用下面的程式碼段進行開發工作。

/**  *  Perform any function on any site on the network  *  *  @param    integer         $site_id   site on which to perform the function  *  @param    string|array    $action    function name to perform  *  @param    array           $args      parameters passed as an indexed array  *  @return  */ function do_network_request( $site_id, $action, $args = array() ) {     switch_to_blog( $site_id );        if ( ( is_string( $action ) && function_exists( $action ) ) || ( is_array( $action ) && method_exists( ...$action ) ) )          $result = call_user_func( $action, ...$args );       else          $result = NULL;     restore_current_blog();     return $result;  } // end do_network_request

 

文章沒看懂?程式碼不會用?需要幫助您可以

風間 的頭像