Member
Member
Epsilon   19-12-2015, 02:05
#1

I am building another plugin to add Disqus Commenting system to Zenphoto.

I have the plugin working but whenever I call it I get the php "undefined function" error.

The plugin is setup like:

class disqus_comment_form {

//options function

function printDisqusCommentForm {
//print stuff
}

}

I have tested that the class exists on the page with:

if (class_exists('disqus_comment_form')){//test}

But it still can't find the function unless I use:

$disqus = new disqus_comment_form();

$disqus->printDisqusCommentForm();

All of the other example plugins I have been looking through don't have to do this but I can't figure out what I have done differently.

I've probably missed something very simple but any help would be greatly appreciated.

Administrator
Administrator
acrylian   19-12-2015, 10:42
#2

$disqus = new disqus_comment_form(); $disqus->printDisqusCommentForm();
Yes, as you cannot use a class method directly. This is how object orientation works and how you setup it. However you class is missing a constructor. Otherwise you can make the method static if it is standalone having no other depencencies to call it without creating an object first.

Our official comment_form plugin is based on a class as well but it also additionally has the plain function printCommentForm() that directly can be used on themes.

Administrator
Administrator
acrylian   19-12-2015, 19:34
#3

FYI, our team member gjr once had made disqus plugin we have rediscovered so we put it on our unsuppported repository: http://www.zenphoto.org/news/zpdisqus
It may naturally not work anymore since it isn't maintained but maybe it does or could be a starting point for you.

Member
Member
Epsilon   20-12-2015, 23:59
#4

I moved my function out of the class and got it to work as I wanted. I'm still pretty new to using classes etc. so I appreciate your help

With my Disqus plugin I am hoping to use Single Sign On (SSO) so the user wont have to register for my site twice (once to use favorites etc. and the other to use Disqus comments).

To do this I need to be able to get the current user's id, name and email and use it on any page that Disqus is active. What would be the best way to get this information?

Member
Member
Epsilon   21-12-2015, 01:19
#5

Looking over the documentation you provided I'm guessing I need to use some combination of the class Zenphoto_Administrator and the functions getID(), getName() and getEmail() but I can't seem to get it right.

Administrator
Administrator
fretzl   21-12-2015, 09:47
#6

You can use the global (always available) variable $_zp_current_admin_obj
(http://www.zenphoto.org/news/zenphotos-global-variables)

$_zp_current_admin_obj->getUser() // Login name $_zp_current_admin_obj->getID() // User ID (number) $_zp_current_admin_obj->getEmail() // Email

Administrator
Administrator
acrylian   21-12-2015, 13:08
#7

Quote:I'm still pretty new to using classes etc. so I appreciate your help
As you probably assume "teaching" the general PHP class stuff (unless you meant the ZP class stuff specifially) is a bit outside the scope of this forum but we try ;-)

There is a federated logon plugin available for similar things. Never used it myself and we don't really maintain it although it is included I admit.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.