整合wordpress插件一起工作

时间:2013-12-30 04:32:56

标签: wordpress plugins

首先非常感谢这个社区。非常有帮助,如果没有这里的帮助,我不知道该怎么做。这可能是我在这里发布WP问题的原因。

我的问题是一般性的,因此我在这里发帖。我已经尝试过发布到相应的插件论坛和WPExchange,但没有得到任何点击。

在wordpress中,当我使用多个插件时,它们是如何集成在一起工作的,这样它就是无缝的。例如,我使用2个插件:一个是分类广告插件,另一个是私人消息插件。目前,分类插件只允许用户通过发送类似craigslist的电子邮件进行通信,但我希望他们在我的网站上进行内部通信。所以在分类插件页面中,当我点击“回复用户”时,它会显示分类广告的回复页面。但是,此时我希望用户使用私人消息插件,以便他们可以在我的网站内部进行通信。

如何将用户定向到私人消息插件页面并让私人消息插件了解双方是谁?换句话说,这样的东西需要使用过滤器和钩子等更复杂的编程技巧吗?我猜这是我真正的问题。

抱歉在这里唠唠叨叨,我只是真正达到了对wordpress的挫败感,并且一直在努力完全掌握WP的概念。

无论如何,事先谢谢你 布赖恩

1 个答案:

答案 0 :(得分:2)

我在" Cartpauj PM"中添加了几行代码。插件添加新的短代码。我替换了"回复广告"上的短代码。我创建的shorcode页面打开了Cartpauj PM插件的新消息选项卡。我现在面临的问题是自动将广告所有者名称添加到" To"联系表格的字段。当我想出来时,我会再次更新你,但是现在,这里是如何集成Cartpauj PM插件。以下是有关如何更改消息传递方法的教程。您可以关注它,或者在Wordpress上创建一个临时帐户,我会为您完成。我的教程经过测试并且有效,但如果您做错了,我不想对出现的网站问题负责,因此编辑需要您自担风险。另外,在您更新此插件时请记住,它很可能会删除所有更改。

第一步:创建短代码

转到插件编辑器并选择Cartpauj PM插件

Selecting Cartpauj PM in the editor.

点击"选择"按钮,将加载新页面。在编辑器中向下滚动,直到看到以下代码:

//ADD SHORTCODES
add_shortcode('cartpauj-pm', array(&$cartpaujPMS, "displayAll"));

然后添加第二行,使其如下所示:

//ADD SHORTCODES
add_shortcode('cartpauj-pm', array(&$cartpaujPMS, "displayAll"));
add_shortcode('cartpauj-new', array(&$cartpaujPMS, "newMessage"));

点击"更新文件"按钮。



第二步:定义" newMessage"短代码

在场景的右侧,点击" cartpauj-pm / pm-class.php"链接。

然后向下滚动,直到看到如下代码: (靠近/ **************************************下方的底部主要显示开始****************************************** /)

//Display the proper contents
    function displayAll()
    {
      global $user_ID;
      if ($user_ID)
      {
        //Finish the setup since these wouldn't work in the constructor
        $this->userOps = $this->getUserOps($user_ID);
        $this->setPageURLs();

        //Add header
        $out = $this->dispHeader();

        //Add Menu
        $out .= $this->dispMenu();

        //Start the guts of the display
        switch ($_GET['pmaction'])
        {
          case 'newmessage':
            $out .= $this->dispNewMsg();
            break;
          case 'checkmessage':
            $out .= $this->dispCheckMsg();
            break;
          case 'viewmessage':
            $out .= $this->dispReadMsg();
            break;
          case 'deletemessage':
            $out .= $this->dispDelMsg();
            break;
          case 'directory':
            $out .= $this->dispDirectory();
            break;
          case 'settings':
            $out .= $this->dispUserPage();
            break;
          case 'viewannouncements':
            $out .= $this->dispAnnouncement();
            break;
          default: //Message box is shown by Default
            $out .= $this->dispMsgBox();
            break;
        }



        //Add footer
        $out .= $this->dispFooter();
      }
      else
      {
        $out = "<p><strong>".__("You must be logged-in to view this page.", "cartpaujpm")."</strong></p>";
      }
      return $out;
    }

您将在该函数下添加一些代码,使其如下所示: (我建议复制和粘贴以避免错误)

//Display the proper contents
    function displayAll()
    {
      global $user_ID;
      if ($user_ID)
      {
        //Finish the setup since these wouldn't work in the constructor
        $this->userOps = $this->getUserOps($user_ID);
        $this->setPageURLs();

        //Add header
        $out = $this->dispHeader();

        //Add Menu
        $out .= $this->dispMenu();

        //Start the guts of the display
        switch ($_GET['pmaction'])
        {
          case 'newmessage':
            $out .= $this->dispNewMsg();
            break;
          case 'checkmessage':
            $out .= $this->dispCheckMsg();
            break;
          case 'viewmessage':
            $out .= $this->dispReadMsg();
            break;
          case 'deletemessage':
            $out .= $this->dispDelMsg();
            break;
          case 'directory':
            $out .= $this->dispDirectory();
            break;
          case 'settings':
            $out .= $this->dispUserPage();
            break;
          case 'viewannouncements':
            $out .= $this->dispAnnouncement();
            break;
          default: //Message box is shown by Default
            $out .= $this->dispMsgBox();
            break;
        }



        //Add footer
        $out .= $this->dispFooter();
      }
      else
      {
        $out = "<p><strong>".__("You must be logged-in to view this page.", "cartpaujpm")."</strong></p>";
      }
      return $out;
    }

//Display the new message
    function newMessage()
    {
      global $user_ID;
      if ($user_ID)
      {
        //Finish the setup since these wouldn't work in the constructor
        $this->userOps = $this->getUserOps($user_ID);
        $this->setPageURLs();

        //Add header
        $out = $this->dispHeader();

        //Add Menu
        $out .= $this->dispMenu();

        //Start the guts of the display
        switch ($_GET['pmaction'])
        {
          case 'newmessage':
            $out .= $this->dispNewMsg();
            break;
          case 'checkmessage':
            $out .= $this->dispCheckMsg();
            break;
          case 'viewmessage':
            $out .= $this->dispReadMsg();
            break;
          case 'deletemessage':
            $out .= $this->dispDelMsg();
            break;
          case 'directory':
            $out .= $this->dispDirectory();
            break;
          case 'settings':
            $out .= $this->dispUserPage();
            break;
          case 'viewannouncements':
            $out .= $this->dispAnnouncement();
            break;
          default: //Message box is shown by Default
            $out .= $this->dispNewMsg();
            break;
        }



        //Add footer
        $out .= $this->dispFooter();
      }
      else
      {
        $out = "<p><strong>".__("You must be logged-in to view this page.", "cartpaujpm")."</strong></p>";
      }
      return $out;
    }

点击&#34;更新文件&#34;按钮。



第三步:更新回复页。

点击&#34;页面&#34;最左边的Wordpress栏上的选项卡。然后打开标题为“#34;回复广告”的页面。 (它前面会有一个&#34; - &#34;)。

删除当前的快捷方式(但请记下后端某处的短代码,以便在您想再次使用它时不要忘记它),并将其替换为以下内容:

[cartpauj-new]

点击&#34;更新。&#34;

你现在完成了。下一步是自动将收件人添加到我将为您处理的表单中。对不起,这需要很长时间才能回复。