> For the complete documentation index, see [llms.txt](https://docs.clipbucket.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clipbucket.com/guides/plugin-development.md).

# Plugin Development

{% hint style="info" %}
ClipBucket was inspired by Wordpress For the Development however its not as efficient as Wordpress, we will try to get things done vial available options

Good news is Vodlix & ClipBucket share the same Core for the Plugins
{% endhint %}

## Folder Strucuture

```
- plugins
  |-plugin_folder
    |- plugin_name.php
    |- plugin_name_install.php //Call when plugin is about to install
    |- plugin_name_uninstall.php //Caled when plugin is about to uninstall

//Example

- plugins
  |-global_announcement
    |-global_announcement.php
```

### Plugin Meta

Just like wordpress, you have mention the plugin detail at the top in comments just as shown below

```
<?php
/*
	Plugin Name: Global announcement
	Description: This will let you post a global announcement on your website
	Author: Arslan Hassan
	ClipBucket Version: 1.8
	Plugin Version: 1.0
	Website: http://google.com/
*/


```

### Plugin Installation Script

This is pure PHP Script, nothing fancy, we usually just call DB Queries in it. e.g

```

//Creating Table for anncoument if not exists
function install_global_announcement()
{
	global $db;
	$db->Execute(
	'CREATE TABLE IF NOT EXISTS '.tbl("global_announcement").' (
	  `announcement` text NOT NULL
	) ENGINE=InnoDB DEFAULT CHARSET=utf8;;'
	);
	
	//inserting new announcment
	$db->Execute("INSERT INTO  ".tbl('global_announcement')." (announcement) VALUES ('')");
}


//This will first check if plugin is installed or not, if not this function will install the plugin details
install_global_announcement();
```

### Plugin Uninstall Script

```
//Function used to uninstall Plugin
function un_install_global_announcement()
{
    global $db;
    $db->Execute(
        'DROP TABLE '.tbl("global_announcement").''
    );
}

un_install_global_announcement();
```

## Resource from ClipBucket

{% embed url="<https://clipbucket.com/docs/getting-started-with-plugins>" %}

### Global Announcement Tutorial

{% embed url="<https://clipbucket.com/docs/creating-advance-global-announcement-plugin-for-clipbucket>" %}

### Understanding Plugin Development

{% embed url="<https://youtu.be/JADQaKCqCGU>" %}
