<?php
/**
 * @package uclwidget
 */

/*
Plugin Name: Free Forms and College Search Widget
Plugin URI: https://ultimatecollegelist.com/
Description: Free worldwide college search and create powerful form widgets to capture leads, create questionnaire, lead segmentation, lead qualification and more.
Version: 1.0
Author: ultimatecollegelist
Author URI: https://profiles.wordpress.org/ultimatecollegelist/
License: GPLv2
Text Domain: ultimatecollegelist.com
**/

function handler_ucl_widget($widget_ids)
{
    if (empty($widget_ids['widget_id']))
    {
        return 'No UCL Widget ID Specified';
    }
    if (isset($widget_ids['widget_id']))
    {
        if (ctype_digit(strval($widget_ids['widget_id'])))
        {
            // valid widget id
            (int)$widget_id = (int)($widget_ids['widget_id']);
            wp_enqueue_script('ucl_widget_' . (string)$widget_id, "https://" . (string)$widget_id . ".domarketing.ca/widgets/js/widget.js", array() , "1.0", true); /* Load script in footer */
            wp_add_inline_script('ucl_widget_' . (string)$widget_id, '(function(){
   			set_ucl_widget(' . (string)$widget_id . ');
		 })();', 'after'); /* Run JS Function After The Script Loads */
            wp_enqueue_style('ucl_widget_' . (string)$widget_id, "https://" . (string)$widget_id . ".domarketing.ca/widgets/css/widget.css", array() , "1.0"); /* Load Stylesheet */
            return '
 	   	<!-- UCL WIDGET STARTS HERE -->
		<div class="ucl-widget" id="ucl_widget">
		<div id="ucl_widget_frame_container"></div>
		<div id="ucl_widget_frame_loader"><span class="ucl-loader"></span></div>
		</div>		
		<!-- UCL WIDGET ENDS HERE  -->
 	   '; /* Return HTML Dom */
        }
        else
        {
            return 'Invalid UCL Widget ID';
        }
    }
    return 'Invalid UCL Widget ID';
}
add_shortcode('ucl_widget', 'handler_ucl_widget');

class FreeFormsAndCollegeSearchWidget
{
    private $free_forms_and_college_search_widget_options;

    public function __construct()
    {
        add_action('admin_menu', array(
            $this,
            'free_forms_and_college_search_widget_add_plugin_page'
        ));
    }

    public function free_forms_and_college_search_widget_add_plugin_page()
    {
        add_menu_page('Free Forms & College Search Widget', // page_title
        'Free Widgets', // menu_title
        'manage_options', // capability
        'free-forms-and-college-search-widget', // menu_slug
        array(
            $this,
            'free_forms_and_college_search_widget_create_admin_page'
        ) , // function
        'dashicons-admin-generic', // icon_url
        2
        // position
        );
    }

    public function free_forms_and_college_search_widget_create_admin_page()
    {
        $this->free_forms_and_college_search_widget_options = get_option('free_forms_and_college_search_widget_option_name'); ?>

		<div class="wrap">
			<h2>Free Forms and College Search Widget</h2>
			<div><img src="https://30096.domarketing.ca/images/quizes/30096.png" style="width:100%;max-width:80px;height:auto;display:block;"></div>
			<p>Create a UCL Widget for college search functionality, lead collection, user or lead segmentation, lead filtering, lead direction, and more – customized for your business needs.</p>
			<p>
			You can find detailed <a href="https://ucl.document360.io/docs/using-wordpress-plugin-to-display-widget" target="_blank">installation guide at link here.</a>
			</p>
			<p>
			<h3>Start by creating a widget <a href="https://ultimatecollegelist.com/account/quiz/all" target="_blank">here.</a></h3>
			</p>	
			<p>
			Once you have your widget ready in the UCL account, <a href="https://ucl.document360.io/docs/using-wordpress-plugin-to-display-widget" target="_blank">you can use it on your website.</a>
			</p>		
			<h3>Start collecting leads and website visitors information in under 5 mins!</h3>

			<h3>Need More or want to create your own colleges and programs listing website?</h3>
			<a href="https://business.ultimatecollegelist.com/" target="_blank">Visit UCL For Business</a>
            <div style="width:100%;display:block;margin-top: 2em;max-width: 500px;margin-bottom:2em;"><a style="display:inline-block;" href="https://wordpress.org/support/plugin/free-forms-and-college-search-widget/reviews/#new-post" target="_blank"><img src="https://30096.domarketing.ca/images/uclplugin/review/UCL-PLUGIN-REVIEW.png" style="max-width: 100%;height:auto;display:block;"></div>

			<a href="https://reputableloans.com/" target="_blank">Check Our Other Solution For Loans: Reputable Loans</a>
		</div>
	<?php
    }

}
if (is_admin())
{
    $free_forms_and_college_search_widget = new FreeFormsAndCollegeSearchWidget();
}

