I am trying to create a custom WordPress plugin and I created a new folder inside the "plugins" folder. It's called "wp-services-table". Inside this folder I created two files: wp-services-table.php and wp-services-table-shortcode.php
For now the wp-services-table-shortcode.php file is blank. I only wrote this in the wp-services-table.php file:
<?php
/**
* Plugin Name: Table and Modal Window for Displaying Services
* Description: Displays Services in a table, by Categories and opens a Modal Window when the user clicks for more information.
* Version: 0.1.0
* Author: Ami
*/
//Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
require_once ( plugin_dir_path(__FILE__) . 'wp-services-table-shortcode.php' );
But I get this error:
Fatal error: Call to undefined function plugin_dir_path() in /home/mysitedomain/public_html/wpfoldername/contentfolder/plugins/wp-services-table/wp-services-table.php on line 14
Could this be because I have a custom name instead of "wp-content"? Or because I installed WordPress in a subfolder ("wpfoldername") and not directly in the "public_html" folder?
Because oterwise I think that the what I wrote in the plugin's file is correct for creating a new plugin.
I also tried to add this:
$dir = plugin_dir_path(__FILE__);
var_dump($dir);
die();
To see what path it would show for the plugin, but of course I still got the same error regarding the undefined function plugin_dir_path()
I hope someone knows why this is happening because I'm very puzzled here. Thank you!
I edited the question to add the contents of wp-config: it might be useful because I have changed the name of the wp-content folder and also WordPress is installed in a subfolder. I think this is the part that is relevant:
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Renaming the wp-content folder. */
define ('WP_CONTENT_FOLDERNAME', 'contentfolder');
define ('WP_CONTENT_DIR', ABSPATH . WP_CONTENT_FOLDERNAME) ;
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/wpfoldername/');
define('WP_CONTENT_URL', WP_SITEURL . WP_CONTENT_FOLDERNAME);
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
Also the index.php file is in the "wpfoldername" folder and it contains the following code:
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
$dir = plugin_dir_path( __FILE__ ); echo $dir
give you ?contentfolder
?ABSPATH
within plugin, if that works, that means you have problem somewhere. Please edit your question and include the entire content ofwp-config.php
(excluding database info and keys and salts) + the content of theindex.php
file of the web root.