【问题标题】:Using SendGrid PHP API in Wordpress without Composer在没有 Composer 的 Wordpress 中使用 SendGrid PHP API
【发布时间】:2017-08-07 12:57:59
【问题描述】:

标题主要说明了一切,但我不知道如何在 Wordpress 中使用没有 Composer 的 SendGrid php 库。它并不像SendGrid github readme.md 所说的那么简单:

// If you are not using Composer
// require("path/to/sendgrid-php/sendgrid-php.php");

这是因为 sendgrid-php.php 包含以下内容:

<?php
require __DIR__ . '/vendor/autoload.php';
?>

所以即使你自己没有调用 autoload.php,sendgrid 文件也是。

有没有办法在没有作曲家的情况下使用库?因为作曲家不能与 Wordpress 一起使用(除非通过一些 janky 变通办法)。

如果有人有这方面的经验,我很想听听你的想法。

谢谢。

【问题讨论】:

  • 为什么你不能在你的functions.php中加载require __DIR__ . '/vendor/autoload.php';
  • 当我尝试它不起作用。我是 Composer 的新手,所以我不确定这是否属实,但是从网络上阅读 Composer 并不能很好地与 Wordpress 配合使用,除非你尝试一些 hacky 方法。

标签: wordpress wordpress-theming sendgrid sendgrid-api-v3


【解决方案1】:

如果你不想使用作曲家。尝试下载包here。然后将 lib 文件夹解压缩到您的(子)主题。然后在您的functions.php 中添加以下代码:

require_once(__DIR__ . '/lib/loader.php');
// Use Send grid right here...

【讨论】:

  • 感谢您的回复,我现在通过自己拉出所有类和文件并在我的functions.php中单独要求它们来运行它,但这看起来更干净。我会试一试,让你知道进展如何。再次感谢。
猜你喜欢
  • 2011-03-28
  • 2015-12-30
  • 2013-10-16
  • 2017-04-20
  • 2021-12-13
  • 1970-01-01
  • 2018-07-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多