Title: OOP in wordpress plugins &#8211; avoid multiple instances???
Last modified: August 20, 2016

---

# OOP in wordpress plugins – avoid multiple instances???

 *  [Jonas_](https://wordpress.org/support/users/jonas_/)
 * (@jonas_)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/oop-in-wordpress-plugins-avoid-multiple-instances/)
 * Hi,
 * I’m trying to add some OOP with php5 to my wordpress plugin..
 * so i have my class
 *     ```
       class Test {
       function __construct()
       {
       log("constructed");
       }
       }
   
       $instance = new Test();
       ```
   
 * now when i test it in wordpress.. it always get 2 instances.. because my log 
   shows “constructed” twice!
 * I tried avoiding it by an isset($instance) … but that didn’t work..
 * How can I avoid this, any help???
 * Thanks in advance!!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [Jonas_](https://wordpress.org/support/users/jonas_/)
 * (@jonas_)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/oop-in-wordpress-plugins-avoid-multiple-instances/#post-2335888)
 * anyone?
 *  Thread Starter [Jonas_](https://wordpress.org/support/users/jonas_/)
 * (@jonas_)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/oop-in-wordpress-plugins-avoid-multiple-instances/#post-2335903)
 * please….

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘OOP in wordpress plugins – avoid multiple instances???’ is closed to 
new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 1 participant
 * Last reply from: [Jonas_](https://wordpress.org/support/users/jonas_/)
 * Last activity: [14 years, 7 months ago](https://wordpress.org/support/topic/oop-in-wordpress-plugins-avoid-multiple-instances/#post-2335903)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
