WordPress.org

Support

Support » Plugins and Hacks » Plugin error: Use of undefined constant ABSPATH

Plugin error: Use of undefined constant ABSPATH

  • My plugin (personalized for extension on my website) have this function:

    function install_tables () {
       	global $wpdb;
    
       	$be = $wpdb->prefix . "browser_extension";
    
    	$sql = "CREATE TABLE IF NOT EXISTS '".$be."' (
      'id' int(11) NOT NULL AUTO_INCREMENT,
      'date' datetime NOT NULL,
      'merchant' int(11) NULL,
      'code' varchar(64) NULL,
      'voucher_id' int(11) NULL,
      'voucher_nome' varchar(128) NULL,
      'url' varchar(256) NULL,
      'browser' varchar(64) NULL,
      PRIMARY KEY ('id')
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1";
    
    	require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    	$wpdb->query($sql);
    }
    
    register_activation_hook(__FILE__,'install_tables');
    add_action("parse_request", "api");

    and now when I try to activate it, shows me the following error in my Nginx log:

    2013/07/22 17:21:54 [error] 19071#0: *276037 FastCGI sent in stderr: "PHP message: PHP Notice:  Use of undefined constant WP_CONTENT_DIR - assumed 'WP_CONTENT_DIR' in /srv/www/wp-admin/includes/upgra$
    PHP message: PHP Notice:  Use of undefined constant ABSPATH - assumed 'ABSPATH' in /srv/www/wp-admin/includes/upgrade.php on line 16
    PHP message: PHP Warning:  require_once(ABSPATHwp-admin/includes/admin.php): failed to open stream: No such file or directory in /srv/www/wp-admin/includes/upgrade.php on line 16
    PHP message: PHP Fatal error:  require_once(): Failed opening required 'ABSPATHwp-admin/includes/admin.php' (include_path='.:/usr/share/php:/usr/share/pear') in /srv/www/wp-admin/includes/upgrade.php$

    I observe that the error started after I updated the version of PHP 5.3.10 to 5.4.17. I do not want to downgrade. Anyone have another solution?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Plugin error: Use of undefined constant ABSPATH’ is closed to new replies.