1547 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Made it to the Authors' Hall of Fame
+2 more

Hi guys, I am developing a plugin that includes a form for submitting content. Because of that, I need WP functions available in that file.

What is the best practice to do that? Note that I will include ajax in a form and will use the proper, WordPress way of doing that, but I am building this as a fallback for users that do not have JavaScript enabled.

This is the way I am doing it currently, I believe it should always return a proper relative path.

First, I store plugin url and wordpress url in a session (you will notice session variables). The rest is self explanatory.

$fng_relative_include = '';
$fng_includepath = str_replace($_SESSION['fng-wp'], '', $_SESSION['fng-plugin']);
$fng_includepath = explode('/', $fng_includepath);
foreach ($fng_includepath as $fng_add_one){
    $fng_relative_include .= '../';
require_once(realpath( $fng_relative_include . 'wp-blog-header.php'));
echo home_url('/#it-worked');

Is there a better way to do this?

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes