Skip to main content
Indented the plugin header code blocks for legibliity
Source Link
Pat J
  • 12.3k
  • 2
  • 28
  • 36
<?php
/**
 * @package FirstPlugin
 */
/*
    Plugin Name: FirstPlugin
    Plugin URI: https://example.com
    Description: This is the first plugin.
    Version: 1.0.0
    Author: First Lastname
    Author URI: http://www.example.com
*/

Second Plugin:

<?php
/**
* @package SecongPlugin
*/
/*
    Plugin Name: SecondPlugin
    Plugin URI: https://example.com
    Description: This is the second plugin
    Version: 1.0.1
    Author: Brad Ahrens
    Author URI: http://www.example.com
*/

The file names are exactly the same (other than the main folder name and the initial first-plugin.php / second-plugin.php files).

<?php
/**
 * @package FirstPlugin
 */
/*
    Plugin Name: FirstPlugin
    Plugin URI: https://example.com
    Description: This is the first plugin.
    Version: 1.0.0
    Author: First Lastname
    Author URI: http://www.example.com
*/

Second Plugin:

<?php
/**
* @package SecongPlugin
*/
/*
    Plugin Name: SecondPlugin
    Plugin URI: https://example.com
    Description: This is the second plugin
    Version: 1.0.1
    Author: Brad Ahrens
    Author URI: http://www.example.com
*/

The file names are exactly the same (other than the main folder name and the initial first-plugin.php / second-plugin.php files).

added 600 characters in body
Source Link

I built a WordPress plugin following Alessandro Castellani's tutorials with no problem.

However, when I built a second plugin and activate it, for some reason it overwrites the first one. In the sidebar, I get two links for the same (the second) plugin, whereas the first one does not appear. Even if I deactivate the first one, the second plugin appears as double.

Desired Behaviour: The two plugins work and act as separate units.

Current Behaviour: They seem to be overlapping and taking settings from each other and the second one removes the first one from the sidebar. What appears is the second plugin twice.

I have a different name for the plugin and reference this throughout

/**
 * @package PluginNumberTwo
 */

Could the problem be because my __construct function within the BaseController is nearly identical?

First Plugin:

namespace Inc\Base;

class BaseController
{


    public $plugin_path;
    public $plugin_url;
    public $plugin;

    public function __construct(){
        $this->plugin_path = plugin_dir_path( dirname( __DIR__ ) );
        $this->plugin_url = plugin_dir_url( dirname( __DIR__ ) );
        $this->plugin = plugin_basename(dirname(dirname(__DIR__))) .'/first-plugin.php';
    ...
    }
}

Second Plugin:

namespace Inc\Base;

class BaseController
{
    public $plugin_path;
    public $plugin_url;
    public $plugin;

    public function __construct(){
        $this->plugin_path = plugin_dir_path( dirname( __DIR__ ) );
        $this->plugin_url = plugin_dir_url( dirname( __DIR__ ) );
        $this->plugin = plugin_basename(dirname(dirname(__DIR__))) .'/second-plugin.php';
    ...
    }
}

One potential problem is that some of the functions have the same names.

public function register()
public function addPages( array $pages )
public function addAdminMenu()
public function setSettings( array $settings )
public function setSections( array $sections )
public function setFields( array $fields )
public function registerCustomFields()

Would this potentially cause the problem?

Also, here are the comments at the beginning of each plugin file:

First plugin:

I built a WordPress plugin following Alessandro Castellani's tutorials with no problem.

However, when I built a second plugin and activate it, for some reason it overwrites the first one. In the sidebar, I get two links for the same (the second) plugin, whereas the first one does not appear. Even if I deactivate the first one, the second plugin appears as double.

Desired Behaviour: The two plugins work and act as separate units.

Current Behaviour: They seem to be overlapping and taking settings from each other and the second one removes the first one from the sidebar. What appears is the second plugin twice.

I have a different name for the plugin and reference this throughout

/**
 * @package PluginNumberTwo
 */

Could the problem be because my __construct function within the BaseController is nearly identical?

First Plugin:

namespace Inc\Base;

class BaseController
{


    public $plugin_path;
    public $plugin_url;
    public $plugin;

    public function __construct(){
        $this->plugin_path = plugin_dir_path( dirname( __DIR__ ) );
        $this->plugin_url = plugin_dir_url( dirname( __DIR__ ) );
        $this->plugin = plugin_basename(dirname(dirname(__DIR__))) .'/first-plugin.php';
    ...
    }
}

Second Plugin:

namespace Inc\Base;

class BaseController
{
    public $plugin_path;
    public $plugin_url;
    public $plugin;

    public function __construct(){
        $this->plugin_path = plugin_dir_path( dirname( __DIR__ ) );
        $this->plugin_url = plugin_dir_url( dirname( __DIR__ ) );
        $this->plugin = plugin_basename(dirname(dirname(__DIR__))) .'/second-plugin.php';
    ...
    }
}

One potential problem is that some of the functions have the same names.

public function register()
public function addPages( array $pages )
public function addAdminMenu()
public function setSettings( array $settings )
public function setSections( array $sections )
public function setFields( array $fields )
public function registerCustomFields()

Would this potentially cause the problem?

I built a WordPress plugin following Alessandro Castellani's tutorials with no problem.

However, when I built a second plugin and activate it, for some reason it overwrites the first one. In the sidebar, I get two links for the same (the second) plugin, whereas the first one does not appear. Even if I deactivate the first one, the second plugin appears as double.

Desired Behaviour: The two plugins work and act as separate units.

Current Behaviour: They seem to be overlapping and taking settings from each other and the second one removes the first one from the sidebar. What appears is the second plugin twice.

I have a different name for the plugin and reference this throughout

/**
 * @package PluginNumberTwo
 */

Could the problem be because my __construct function within the BaseController is nearly identical?

First Plugin:

namespace Inc\Base;

class BaseController
{


    public $plugin_path;
    public $plugin_url;
    public $plugin;

    public function __construct(){
        $this->plugin_path = plugin_dir_path( dirname( __DIR__ ) );
        $this->plugin_url = plugin_dir_url( dirname( __DIR__ ) );
        $this->plugin = plugin_basename(dirname(dirname(__DIR__))) .'/first-plugin.php';
    ...
    }
}

Second Plugin:

namespace Inc\Base;

class BaseController
{
    public $plugin_path;
    public $plugin_url;
    public $plugin;

    public function __construct(){
        $this->plugin_path = plugin_dir_path( dirname( __DIR__ ) );
        $this->plugin_url = plugin_dir_url( dirname( __DIR__ ) );
        $this->plugin = plugin_basename(dirname(dirname(__DIR__))) .'/second-plugin.php';
    ...
    }
}

One potential problem is that some of the functions have the same names.

public function register()
public function addPages( array $pages )
public function addAdminMenu()
public function setSettings( array $settings )
public function setSections( array $sections )
public function setFields( array $fields )
public function registerCustomFields()

Would this potentially cause the problem?

Also, here are the comments at the beginning of each plugin file:

First plugin:

added 360 characters in body
Source Link

I built a WordPress plugin following Alessandro Castellani's tutorials with no problem.

However, when I built a second plugin and activate it, for some reason it overwrites the first one. In the sidebar, I get two links for the same (the second) plugin, whereas the first one does not appear. Even if I deactivate the first one, the second plugin appears as double.

Desired Behaviour: The two plugins work and act as separate units.

Current Behaviour: They seem to be overlapping and taking settings from each other and the second one removes the first one from the sidebar. What appears is the second plugin twice.

I have a different name for the plugin and reference this throughout

/**
 * @package PluginNumberTwo
 */

Could the problem be because my __construct function within the BaseController is nearly identical?

First Plugin:

namespace Inc\Base;

class BaseController
{


    public $plugin_path;
    public $plugin_url;
    public $plugin;

    public function __construct(){
        $this->plugin_path = plugin_dir_path( dirname( __DIR__ ) );
        $this->plugin_url = plugin_dir_url( dirname( __DIR__ ) );
        $this->plugin = plugin_basename(dirname(dirname(__DIR__))) .'/first-plugin.php';
    ...
    }
}

Second Plugin:

namespace Inc\Base;

class BaseController
{
    public $plugin_path;
    public $plugin_url;
    public $plugin;

    public function __construct(){
        $this->plugin_path = plugin_dir_path( dirname( __DIR__ ) );
        $this->plugin_url = plugin_dir_url( dirname( __DIR__ ) );
        $this->plugin = plugin_basename(dirname(dirname(__DIR__))) .'/second-plugin.php';
    ...
    }
}

One potential problem is that some of the functions have the same names.

public function register()
public function addPages( array $pages )
public function addAdminMenu()
public function setSettings( array $settings )
public function setSections( array $sections )
public function setFields( array $fields )
public function registerCustomFields()

Would this potentially cause the problem?

I built a WordPress plugin following Alessandro Castellani's tutorials with no problem.

However, when I built a second plugin and activate it, for some reason it overwrites the first one. In the sidebar, I get two links for the same (the second) plugin, whereas the first one does not appear. Even if I deactivate the first one, the second plugin appears as double.

Desired Behaviour: The two plugins work and act as separate units.

Current Behaviour: They seem to be overlapping and taking settings from each other and the second one removes the first one from the sidebar. What appears is the second plugin twice.

I have a different name for the plugin and reference this throughout

/**
 * @package PluginNumberTwo
 */

Could the problem be because my __construct function within the BaseController is nearly identical?

First Plugin:

public function __construct(){
    $this->plugin_path = plugin_dir_path( dirname( __DIR__ ) );
    $this->plugin_url = plugin_dir_url( dirname( __DIR__ ) );
    $this->plugin = plugin_basename(dirname(dirname(__DIR__))) .'/first-plugin.php';
...
}

Second Plugin:

public function __construct(){
    $this->plugin_path = plugin_dir_path( dirname( __DIR__ ) );
    $this->plugin_url = plugin_dir_url( dirname( __DIR__ ) );
    $this->plugin = plugin_basename(dirname(dirname(__DIR__))) .'/second-plugin.php';
...
}

One potential problem is that some of the functions have the same names.

public function register()
public function addPages( array $pages )
public function addAdminMenu()
public function setSettings( array $settings )
public function setSections( array $sections )
public function setFields( array $fields )
public function registerCustomFields()

Would this potentially cause the problem?

I built a WordPress plugin following Alessandro Castellani's tutorials with no problem.

However, when I built a second plugin and activate it, for some reason it overwrites the first one. In the sidebar, I get two links for the same (the second) plugin, whereas the first one does not appear. Even if I deactivate the first one, the second plugin appears as double.

Desired Behaviour: The two plugins work and act as separate units.

Current Behaviour: They seem to be overlapping and taking settings from each other and the second one removes the first one from the sidebar. What appears is the second plugin twice.

I have a different name for the plugin and reference this throughout

/**
 * @package PluginNumberTwo
 */

Could the problem be because my __construct function within the BaseController is nearly identical?

First Plugin:

namespace Inc\Base;

class BaseController
{


    public $plugin_path;
    public $plugin_url;
    public $plugin;

    public function __construct(){
        $this->plugin_path = plugin_dir_path( dirname( __DIR__ ) );
        $this->plugin_url = plugin_dir_url( dirname( __DIR__ ) );
        $this->plugin = plugin_basename(dirname(dirname(__DIR__))) .'/first-plugin.php';
    ...
    }
}

Second Plugin:

namespace Inc\Base;

class BaseController
{
    public $plugin_path;
    public $plugin_url;
    public $plugin;

    public function __construct(){
        $this->plugin_path = plugin_dir_path( dirname( __DIR__ ) );
        $this->plugin_url = plugin_dir_url( dirname( __DIR__ ) );
        $this->plugin = plugin_basename(dirname(dirname(__DIR__))) .'/second-plugin.php';
    ...
    }
}

One potential problem is that some of the functions have the same names.

public function register()
public function addPages( array $pages )
public function addAdminMenu()
public function setSettings( array $settings )
public function setSections( array $sections )
public function setFields( array $fields )
public function registerCustomFields()

Would this potentially cause the problem?

added 15 characters in body; edited tags
Source Link
Krzysiek Dróżdż
  • 25.5k
  • 9
  • 53
  • 74
Loading
added 322 characters in body
Source Link
Loading
added 28 characters in body
Source Link
Krzysiek Dróżdż
  • 25.5k
  • 9
  • 53
  • 74
Loading
added 322 characters in body
Source Link
Loading
Source Link
Loading