WordPress.org

Ready to get started?Download WordPress

Forums

Plugin error: Use of undefined constant ABSPATH (3 posts)

  1. moisb
    Member
    Posted 11 months ago #

    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?

  2. moisb
    Member
    Posted 11 months ago #

    anyone?

  3. mybadstudios
    Member
    Posted 4 months ago #

    Maybe wp-load hasn't been loaded by the time your code runs?

    Is all I can think of. Perhaps don't run your code on "api" but at a later time?

Reply

You must log in to post.

About this Topic

Tags