• Good Morning All.

    I’m building my first plugin and it will do three main tasks.

    It will submit a post, submit an email to an autoresponder API (getresponse) and take a payment via Paypal.

    So I have put together most of my functionality but I’m having an issue and as an additional question I’m trying to understand where to learn the “right” way to put my plugin together.

    The issue I have is that I have created an admin screen to store the credentials necessary to interact with the autoresponder and paypal. I’m using WordPress functions to pull the values when I need them.

    Well, when I am taking the payment via paypal I’m using a library I found so I am doing this on a php page that I am loading the headers and footers for wordpress in the php so that I can appear to stay inside the wordpress framework to the user. Well I’m not able to access the values stored through the admin page because I don’t yet have the wordpress functions available when I need the values.

    I’m sure none of this makes sense to you.

    I’m happy to provide someone access to my code if you are willing to give me a few pointers. I take no offense so you don’t need to be nice if I am way off base.

    I much prefer not to bother anyone and do it myself, I’m just not finding any documentation to guide me on the “right” or “best” way to make all this work together.

    I have pulled most my hair out off and on over the last few monthst trying to figure out how to make this happen to no avail.

    Thanks in advance for any advice or assistance you can offer.

    Thanks also for reading my long post.

    Have a great day.

    Shawn

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Sounds like your main issue is the paypal library and WP are two completely separate code bases and you need them to work together.

    There’s three main ways to deal with this. The least desirable is on the PHP page that’s handling the payment simply require_once the wp-load.php file. This loads the WP environment and gives your page access to all WP resources. This is poor practice mainly because you can’t positively know where wp-load.php resides for any random installation.

    A better approach is to skip over WP and access the WP database for the needed info directly with PHP mysql_*() functions. This will get the payment credentials, but not any WP theme styling for the page, a major flaw.

    The best approach is implement your payment page either as a custom page template or get all WP data via WP specific AJAX calls. Since you want WP theme headers and footer on your page, the custom page template is your best bet. You can still use AJAX for certain portions if that makes sense.

    If you want to post your code at pastebin.com and provide a link here, I’d be willing to take a very quick look. I can’t provide any in depth analysis, but I could give you my general impression, for what ever that’s worth. While I’ve managed to become a bit of a WP expert, I am in no way an expert coder. I have seen enough code to know the difference between well organized code and a hot mess, so my thoughts might be worth something in some small way.

Viewing 1 replies (of 1 total)
  • The topic ‘Where to learn the "right" way to code my plugin?’ is closed to new replies.