0

I have no idea what I'm doing. I'm using the WordPress Plugin Boilerplate

When activating my blank plugin, I receive the following error.

Fatal error: Cannot declare class Requests, because the name is already in use in /Applications/MAMP/htdocs/wordpress/wp-content/plugins/requests/includes/class-Requests.php on line 30

here's the code of that page up to line 30:

<?php

/**
 * The file that defines the core plugin class
 *
 * A class definition that includes attributes and functions used across both the
 * public-facing side of the site and the admin area.
 *
 * @link       http://codykaczynski.com
 * @since      1.0.0
 *
 * @package    Requests
 * @subpackage Requests/includes
 */

/**
 * The core plugin class.
 *
 * This is used to define internationalization, admin-specific hooks, and
 * public-facing site hooks.
 *
 * Also maintains the unique identifier of this plugin as well as the current
 * version of the plugin.
 *
 * @since      1.0.0
 * @package    Requests
 * @subpackage Requests/includes
 * @author     Cody Kaczynski <ckazynski@ampedsound.net>
 */
class Requests {

all i've done so far is replace PLUGIN_NAME and its variations with Requests, as it says in the installation directions on GitHub.

I'm sorry for such a dumb question, just not sure what's going on? I don't know anything about the WordPress API or OOP.

Thank you.

2

Because WordPress already have class named Request

https://developer.wordpress.org/reference/classes/requests/

When creating a plugin or using boilerplate to generate, you should add prefix for your plugin name/class name, or avoid using very basic name.

Example:

class Wpse309780_Request
{

    function __construct(argument)
    {
        # code...
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.