![Logo of the project](https://staging.wowturf.org/wp-content/themes/wowturf/images/logo_rgb_sml.svg)

# WowTurf
> WowTurf is an educational platform that provides no strings attached bursaries to its users through ad revenue earned.

Users sign up to interact with campaigns/ads. They then earn points which convert to tokens which they use to enter into a draw bursaries. Users will also have access to a dashboard to manage their profile, notifications, invite friends etc.

Advertisers sign up to create campaigns/ads targeting WowTurf users. They can select specific interactions per ad/campaign and can monitor their campaigns via their dashboard.

## Installing / Getting started

To run the site locally you'll need a WAMP or similar setup.

1. import the database at public_html/db/wowturf.sql
2. do a find and replace on the database to your local install
3. setup your wp-config file to point to the new database
4. super admin login is u: ninjasforhire p: catty (the long one)
5. update permalinks in wp-admin
6. to work on the frontend js or sass open command line in theme folder and run the bellow code

```shell
npm install
gulp
```

"npm install" will import js dependencies and "gulp" will begin precompiler for sass and javascript files.

## Development

The staging site is hosted on AWS, and can only be accessed via OpenVPN.

### Open VPN

* OpenVPN details are as follows for the developers
* Open link https://34.252.140.75:943 and log in with below details
* Then download and install the OpenVPN application

> Use Access details in supplied text file

### Database and FTP access

* The DB can be accessed using MySQL Workbench via the OpenVPN link.
* The site can be accesed using ftp (FileZilla) via the OpenVPN link.


## Custom Plugins

### Ninja Frontend

> Functionality related to the frontend of the website that would usually go into the functions.php file and doesn't really make sense to put into the below plugins.

nff methods index:

* sendCampaignDraftMail //mail sent when a new campaign draft is created by a user

nffActions methods index:

* custom_posts_table_content //render custom columns for posts in wp-admin
* contribute_subs //add some points if contributed post is published
* dhemy_ajax_search //custom live search
* get_category_posts //callback for custom posts endpoint
* categoryposts_endpoint //create custom categoryposts endpint : /wp-json/nff/v1/categoryposts/
* get_campaigns_posts_NEW //callback for getcampaigns endpoint
* getcampaigns_endpoint //create custom getcampaigns endpoint : /wp-json/nff/v1/getcampaigns/
* theme_js //load theme js
* nfh_scripts //make wp/php vars available as js object eg. wp.root

### Ninja Payment STRIPE

> Functionality related to Stripe payment processing.

nfps methods index:

* process_stripe_payment //process a payment through stripe
* save_stripe_payment_data //save stripe payment data
* create_customer_card //create a new stripe customer
* update_customer_card_data //update or create the stripe customer data in db
* remove_customer_card_data //remove customer card data from db
* remove_customer_card //remove users card from the system
* get_customer_cards //get card info for userid
* stripe_update_primary_card //update the customers primary card on stripe
* stripe_update_billing_address //update customers billing address
* update_billing //update billing details on site
* send_email //send an email
* save_error_data //save error data to database
* get_outstanding_amount //get outstanding balance of a campaign
* get_outstanding_amount_all_campaigns //get outstanding balance on all campaigns
* pay_outstanding_balance_all_campaigns //settles the outstanding balance on all campaigns
* pay_outstanding_balance_single_campaign //settles the outstanding balance on single campaign

nwpsActions methods index:

* periodicinvoicing_endpoint //create custom handlepayments : /wp-json/nff/v1/periodicinvoicing/
* periodicInvoicing //send periodic invoice
* can_run_payments //checks to see when last payments process was done > should be over 1 week ago
* can_invoice_campaign //checks to see when last payments process was done > should be over $invoicing_period

### Ninja Geo Manager

> Built by Gerhard. Connects Country,Region,City functionlaity on the site to a geo database table on the site. Also provides functionality to add / remove items from the db.

### Ninja Campaigns

> Functionality related to campaigns on the site. eg. how they are displayed and interacted with

nwc methods index:

* send_email //send an email
* filter_by_adsize //filter campaigns by adsize
* procudeIdsArray //produce an array of ids
* filter_by_region //filter campaigns by region
* filter_by_preferences //filter campaigns by preferences
* filter_by_age //filter campaigns by age
* filter_by_gender //filter campaigns by gender
* filter_by_hasbudget //filter by if campaign has budget
* filter_by_bid //filter by bid amount
* filter_by_startenddate //filter by start and end date
* filter_by_timeofday //filter by time of day
* filter_by_serves //filter how many times user has viewed the campaign
* filter_by_status //filter by campaign status
* filter_by_language //filter by language
* get_campaign_id //get the campaign id to serve based on filters
* adjust_campaign_spend_threshold //adds bid amount to Campaign Threshold Tracker, once campaign reaches threshold, billing is initiated for threshold amount, the threshold tracker is reset and any remaining spend is added
* log_campaign_spend //log campaign spending (called from single-campaign.php when ad has been interacted with)
* get_ip_location //get current user ip / location
* log_campaign_interaction //log campaign interaction
* create_a_campaign //handle create a campaign form
* get_campaign_clicks //get the campaign total clicks
* get_campaign_clicks_between_dates //get all campaign clicks between dates
* get_campaign_spending //get how much has been spent onthe campaign so far
* change_campaign_status //change the campaign status
* trashCampaign //trash a campaign (cancel it)
* pauseCampaign //pause the campaign
* unpauseCampaign //unpause the campaign
* disableCampaign //disable the campaign
* disableAllCampaigns //disable all this users campaigns
* removeDisableCampaign //un-disable the campaign
* removeDisableAllCampaigns //un-disable all campaigns for user
* endCampaign //mark campaign as complete and wrap it up after it has come to an end
* confirmCampaign //confirm that the campaign is ready to be reviewed
* uploadMedia //uploads single media to wordpress library
* uploadMedias //uploads mutiple media to wordpress library
* get_campaign_color //get the campaign type color of the campaign
* getCampaignsData //get campaigns data for export > REPLACED BY NEW BELOW
* getCampaignsData_NEW //get campaigns data for export > CURRENTLY IN USE
* getBidIndicators //get bid indicators
* debuggerLog //campaigns debugger logger, logs debug info for campaigns to be displayed in wp-admin PLEASE PURGE THIS TABLE FROM TIME TO TIME AND TURN OFF DURING PRODUCTION

nwcActions methods index:

 * custom_campaign_table_content // For rendering the column
 * custom_campaign_orderby //custom orderby for newcolumns
 * flushCompletedCampaigns //go through all campaigns and if it's past the end date, end the campaign
 * save_campaign_callback //fires when campaign is saved or updated, updates status and custom fields / meta
 * campaignRegister // add custom post type - campaign
 * campaigntype_taxonomies // add custom taxonomy - campaigntype
 * getcampaigninfo_endpoint //create custom getcampaigninfo endpint : /wp-json/nff/v1/getcampaigninfo/
 * getcampaigninfo //get campaign info
 * sendadminmail_endpoint //create custom sendadminmail endpint : /wp-json/nff/v1/sendadminmail/
 * sendadminmail //send an admn mail notification
 * cdbt_create_menu //create menu for campaign debugger tool
 * cdbt_settings_page //create page for debugger tool

nwcFilters methods index:

 * custom_campaign_table_head //Adds ACF fields to Post List For registering the column
 * custom_campaign_column //make new columns sortable

### Ninja Notifications

> Functionality for the notifications diplayed in the user dashboard.

nwn methods index:

 * creatNotification //create a notifications
 * deletePost //delete notfication
 * seenNotification //add notification as seen by user

nwnActions methods index:

 * getNotification //get data for single notification
 * getnotification_endpoint //create custom getnotification endpint : /wp-json/nff/v1/getnotification/
 * seennotification_endpoint //create custom seennotification endpint : /wp-json/nff/v1/seennotification/
 * notificationRegister // add custom post type - notification
 * getNotification //get data for single notification
 * getNotification //get data for single notification

### Ninja Points Tokens

nwpt methods index:

* adjustUserPoints //adjusts user points uid, points, adjust = add or subtract
* getTokensAmount //returns how many tokens your points are worth plus remaining points
* convertPointstoEntries //converts points to entries in a db table for current draw
* runCompetition //converts all points to entries and runs a random search for a winner on the db
* getLatestCompDetails //get latest competition details
* getAllCompDetails //get all competition details
* markPayoutComplete //mark payout as complete
* isPayoutComplete //check if payout is complete
* countUserPayouts //count user payouts

nwptActions methods index:

* adjustuserpoints_endpoint //create custom adjustuserpoints endpint : /wp-json/nff/v1/adjustuserpoints/
* gettokensamount_endpoint //create custom sendadminmail endpint : /wp-json/nff/v1/gettokensamount/

### Ninja Users

> Additional funtionality to handle users on the site.

nwu methods index:

* send_email //send a mail
* processBookmarks //process user bookmarks
* getProfilePercentage //work out percentage of profile that has been filled out
* getProfileDetail //work get profile details
* getUserCatPref //get the user category preferences
* logView //logs a view in the db for a user (subscriber)
* getViewedPosts //get user viewed post entries
* getUniqueViewedPosts //get deduped user viewed post entries (ie. no duplicate postid's)
* handleProfileForm //handles the forms to update user profile

nwuFilters methods index:

* wpse_retrieve_password_message //custom reset password message
* email_set_content_type //set email to html

nwuActions methods index:

* check_invite_reminders //check if refferal invites and if been over 1 week
* do_custom_action_after_registration //if normal user signs up with coupn code > process coupon and send email
* ajaxGetUniqueViewedPosts //ajax get viewed posts
* bookmark_endpoint //create custom bookmark endpint : /wp-json/nff/v1/bookmark/
* viewedposts_endpoint //create custom categoryposts endpint : /wp-json/nff/v1/viewedposts/
* ajaxUpdateCatPreferences //update the users category prefereneces
* ajaxUpdateNotifyPreferences //update the users notification prefereneces
* subcribeControllerMailchimp //subscribes or unsubsrices a user from mailchimp list
* updatecats_endpoint //create custom updatecats endpint : /wp-json/nff/v1/updatecats/
* updatenotifications_endpoint //create custom updatenotifications endpint : /wp-json/nff/v1/updatenotifications/
* percentage_endpoint //get profile percentage : /wp-json/nff/v1/percentage/
* fbloginreg_endpoint //create custom fbloginreg endpoint : /wp-json/nff/v1/fbloginreg/
* sendinvite_endpoint //create custom sendinvite endpint : /wp-json/nff/v1/sendinvite/
* getprofiledata_endpoint //create custom sendinvite endpint : /wp-json/nff/v1/getprofiledata/
* registeruser_endpoint //create custom registeruser endpint : /wp-json/nff/v1/registeruser/
* loginuser_endpoint //create custom loginuser endpint : /wp-json/nff/v1/loginuser/
* registerUser //additional validation when user registers
* sendInvite //send an invite to a freind with a users coupon code
* sendInviteReminder //send an invite reminder to a freind with a users coupon code
* userpreferences_taxonomies // add custom taxonomy - userpreferences

### Redundant/Legacy Plugins not being used

- Ninja Payments ZOTAPAY