# 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>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clipbucket.com/guides/plugin-development.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
