# Artist-diy-WordPress plugin

### Overview
This is a custom artist form WordPress plugin, which adds the artist detail form on the WordPress page. This has an API integration, which sends the artist details to the API endpoint.
This is a single standalone plugin which has the UI of artist form and API integration. No additional WordPress plugins or components are required.


### Components
This repository has a WordPress wp-content structure in which the plugin directory is added. In the plugin directory the artist form plugin files are available.


## Getting Started
To install the plugin in local instances following is required.

### Requirements

- PHP 7.2 or newer.
- Installed WordPress setup

After this setup, now get clone of the following repository clone.

    https://github.com/theorchard/artist-diy-WordPress.git


### Plugin Installation
In WordPress default installation, the wp-content folder already exists with some content, under the WordPress project root directory. Thus, Git clone into this folder will give an error. Hence follow the steps below for cloning the repository contents correctly without any errors:
1. Backup or rename the default wp-content folder and it’s contents.
2. Now navigate to the installed WordPress project root directory and run the Git clone. 
3. After getting all plugin content, you will notice that a new wp-content folder is created in the WordPress project root directory.
4. Now move the original wp-content folder content (the one that was backed up or renamed in step 1) to the newly cloned wp-content folder.

> If you are setting up this plugin on the server, Then process is exactly same as mentioned in installation.
> Make sure git is installed in server and all read, write permissions are given to the git and WordPress files.

### Installation On AWS LightSail
If you want to deploy artist form plugin on AWS LightSail then follow these steps.

 - Create the LightSail instance on AWS. Now open the bitnami SSH terminal of instance on AWS or connect your LightSail instance through SSH.
 - After successful connection with instance now install Git. Run command `sudo apt-get install git`.
 - Make sure Git and WordPress have read and write permissions on LightSail instance.
 - Now goto your WordPress Installation location on AWS LightSail. Default installation path is `apps/wordpress/htdocs/`.
 - Follow all the steps mentioned in Plugin Installation section.


### Plugin Activation
Login into the WordPress admin dashboard in browser, and search for plugins menu.
In the plugins menu select the installed option, in the installed plugin dashboard check the Artist Form title of plugin.
Below the Artist Form plugin section click on the Activate button to activate the artist form plugin.


### Configurations in plugin
The data entered on the artist form will be posted to an API endpoint.

For setting up the API endpoint following are the steps. 
- Login to the admin dashboard of WordPress.
- Search for the Settings menu in the dashboard.
- In the Settings menu click on the Artist API Settings option.

> In the artist API settings page there are different configuration values that need to be setup.  

Following configuration values are required.
- API URL - API endpoint goes here.
- Auth0 Api Url - Auth0 url must be available.
- Auth0 Audience - Auth0 Audience url.
- Spotify client Id - Spotify app client id required to search the artist profile.
- Spotify client Secret Key - Spotify app client secret key.
- Api Client Id - Auth0 api client id.
- Api Client Secret Key - Auth0 api secret key.

### Plugin Environment Modes
There are two modes available in the plugin settings page production and development.
##### Production mode
In this mode if the artist form fails to send data on API, then plugin will not provide any addition information about the errors which received from the API.
##### Development mode
If environment is set to development, then plugin will provide all the error details on screen if form get fail to send data on API.
##### Setting Environment Modes
To choose the plugin environment mode, Go to plugin settings page and find the Environment option and from the dropdown choose your preferable environment mode. By default plugin is set on production mode.

##### Adding Terms And Conditions. 
There is another option is available in the settings page for adding the terms and conditions in artist form. This has a text editor which enables to add text formatting according to requirement.  

![Settings page](https://raw.githubusercontent.com/abhishektsts/artist-diy-WordPress/master/formsettings.PNG?token=AUMGNSFVI345H2AGKKORTFLA5VBJS)

> After adding all the required configuration values in artist API settings now add the form to WordPress page.

To add the artist form UI in the WordPress page add the below ShortCode in the page and save the changes.  

    [awal-form]

Goto the form page and now artist form is ready to collect the details.
