<?php
	/*
	Plugin name: Rich Forms
	Plugin URI: https://rich-web.org/wp-contact-form/
	Description: Form Builder plugin is fully responsive. Forms is awesome WordPress form plugin with many useful features and effects.
	Version: 1.2.4
	Author: richteam
	Author URI: https://rich-web.org
	License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
	*/

	add_action('widgets_init', 'Rich_Web_Forms_Widget');
	function Rich_Web_Forms_Widget()
	{
	 	register_widget('Rich_Web_Forms');
	}
	require_once(dirname(__FILE__) . '/Rich-Web-Forms-Widget.php');
 	require_once(dirname(__FILE__) . '/Rich-Web-Forms-Ajax.php');
	require_once(dirname(__FILE__) . '/Rich-Web-Forms-Shortcode.php');

	add_action('wp_enqueue_scripts','Rich_Web_Forms_Style');
	function Rich_Web_Forms_Style(){
		wp_enqueue_script('jquery');
		wp_enqueue_script('jquery-ui-core');
		wp_enqueue_script('jquery-ui-datepicker');
		wp_enqueue_script('Rich_Web_Forms-Phone',plugins_url('/Scripts/intlTelInput.min.js',__FILE__));
		wp_enqueue_style('Rich_Web_Forms-Phone',plugins_url('/Style/intlTelInput.css',__FILE__));
		wp_enqueue_script('Rich_Web_Forms-Country',plugins_url('/Scripts/countrySelect.min.js',__FILE__));
		wp_enqueue_style('Rich_Web_Forms-Country',plugins_url('/Style/countrySelect.min.css',__FILE__));
		wp_register_style('Rich_Web_Forms-admin-ui-css', plugins_url('/Style/rw-jquery-ui.css',__FILE__));
		wp_enqueue_style( 'Rich_Web_Forms-admin-ui-css' );	
		$rw_forms_root = sprintf('
			root { --rw_forms_icons_url: url(%1$s); }
			',
			esc_url(plugins_url('Images/icons.png',__FILE__))
		);
		wp_add_inline_style( 'Rich_Web_Forms-admin-ui-css', $rw_forms_root );
		wp_register_style( 'fontawesome-css', plugins_url('/Style/richwebicons.css', __FILE__)); 
   		wp_enqueue_style( 'fontawesome-css' );	
	}

	add_action("admin_menu", 'Rich_Web_Forms_Admin_Menu' );
	function Rich_Web_Forms_Admin_Menu() 
	{
		add_menu_page('Rich-Web Forms Admin','Contact Forms','manage_options','Rich-Web Forms Admin','Manage_Rich_Web_Forms_Admin', plugins_url('/Images/admin.png',__FILE__));
 		add_submenu_page( 'Rich-Web Forms Admin', 'Rich-Web Forms Admin', 'Forms Manager', 'manage_options', 'Rich-Web Forms Admin', 'Manage_Rich_Web_Forms_Admin');
		add_submenu_page( 'Rich-Web Forms Admin', 'Rich-Web Forms General', 'General Options', 'manage_options', 'Rich-Web Forms General', 'Manage_Rich_Web_Forms_General');
		add_submenu_page( 'Rich-Web Forms Admin', 'Rich-Web Forms Themes', 'Forms Themes', 'manage_options', 'Rich-Web Forms Themes', 'Manage_Rich_Web_Forms_Themes');
		add_submenu_page( 'Rich-Web Forms Admin', 'Rich-Web Forms Message', 'Messages Manager', 'manage_options', 'Rich-Web Forms Messages', 'Manage_Rich_Web_Forms_Messages');
		add_submenu_page( 'Rich-Web Forms Admin', 'Rich-Web Forms Submissions', 'Submissions', 'manage_options', 'Rich-Web Forms Submissions', 'Manage_Rich_Web_Forms_Submissions');
		add_submenu_page( 'Rich-Web Forms Admin', 'Rich-Web Forms Products', 'Our Products', 'manage_options', 'Rich-Web Forms Products', 'Manage_Rich_Web_Forms_Products');
	}
	function Manage_Rich_Web_Forms_Admin()
	{ 
		wp_register_script('Rich_Web_Forms', plugins_url('Scripts/Rich-Web-Forms-Admin.js',__FILE__),array('jquery','jquery-ui-core'),time(), false );
		wp_localize_script('Rich_Web_Forms', 'rw_form_json_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ),'rw_forms_nonce' => wp_create_nonce('rw_forms_nonce') ) );
		wp_enqueue_script('Rich_Web_Forms');

		require_once(dirname(__FILE__) . '/Rich-Web-Forms-Admin.php');
	}
	function Manage_Rich_Web_Forms_Themes()
	{
		wp_register_script('Rich_Web_Forms_Themes', plugins_url('Scripts/Rich-Web-Forms-Themes.js',__FILE__),array('jquery','jquery-ui-core'),time(), false );
		wp_localize_script('Rich_Web_Forms_Themes', 'rw_form_json_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ),'rw_forms_nonce' => wp_create_nonce('rw_forms_nonce') ) );
		wp_enqueue_script('Rich_Web_Forms_Themes');
		wp_enqueue_style('Rich_Web_Forms_Themes_Style', plugins_url('/Style/Rich-Web-Forms-Themes.css',__FILE__), array(), time(), 'all' );
		require_once(dirname(__FILE__) . '/Rich-Web-Forms-Theme.php');
	}
	function Manage_Rich_Web_Forms_General()
	{
		wp_register_script('Rich_Web_Forms_General', plugins_url('Scripts/Rich-Web-Forms-General.js',__FILE__),array('jquery','jquery-ui-core'),time(), false );
		wp_localize_script('Rich_Web_Forms_General', 'rw_form_json_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ),'rw_forms_nonce' => wp_create_nonce('rw_forms_nonce') ) );
		wp_enqueue_script('Rich_Web_Forms_General');
		wp_enqueue_style('Rich_Web_Forms_General_Style', plugins_url('/Style/Rich-Web-Forms-General.css',__FILE__), array(), time(), 'all' );
		require_once(dirname(__FILE__) . '/Rich-Web-Forms-General.php');
	}
	function Manage_Rich_Web_Forms_Messages()
	{
		wp_register_script('Rich_Web_Forms_Messages', plugins_url('Scripts/Rich-Web-Forms-Messages.js',__FILE__),array('jquery','jquery-ui-core'),time(), false );
		wp_localize_script('Rich_Web_Forms_Messages', 'rw_form_json_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ),'rw_forms_nonce' => wp_create_nonce('rw_forms_nonce') ) );
		wp_enqueue_script('Rich_Web_Forms_Messages');
		wp_enqueue_style('Rich_Web_Forms_Messages_Style', plugins_url('/Style/Rich-Web-Forms-Messages.css',__FILE__), array(), time(), 'all' );
		require_once(dirname(__FILE__) . '/Rich-Web-Forms-Messages.php');
	}
	function Manage_Rich_Web_Forms_Submissions()
	{
		wp_register_script('Rich_Web_Forms_Submissions', plugins_url('Scripts/Rich-Web-Forms-Submissions.js',__FILE__),array('jquery','jquery-ui-core'),time(), false );
		wp_localize_script('Rich_Web_Forms_Submissions', 'rw_form_json_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ),'rw_forms_nonce' => wp_create_nonce('rw_forms_nonce') ) );
		wp_enqueue_script('Rich_Web_Forms_Submissions');
		wp_enqueue_style('Rich_Web_Forms_Submissions_Style', plugins_url('/Style/Rich-Web-Forms-Submissions.css',__FILE__), array(), time(), 'all' );
		require_once(dirname(__FILE__) . '/Rich-Web-Forms-Submissions.php');
	}
	function Manage_Rich_Web_Forms_Products()
	{
		require_once(dirname(__FILE__) . '/Rich-Web-Products.php');
	}
	add_action('admin_init', 'Rich_Web_Forms_Admin_Style');	
	function Rich_Web_Forms_Admin_Style()
	{
		wp_enqueue_style('wp-color-picker');
		wp_enqueue_script('wp-color-picker');
		wp_enqueue_script('jquery');
		wp_enqueue_script('jquery-ui-core');
		wp_enqueue_script('jquery-ui-sortable');
		wp_enqueue_script('jquery-ui-datepicker');
		wp_enqueue_style('Rich_Web_Forms-admin-ui-css', plugins_url('/Style/rw-jquery-ui.css',__FILE__), array(), time(), 'all' );
		$rw_forms_root = sprintf('
			root { --rw_forms_icons_url: url(%1$s); }
			',
			esc_url(plugins_url('Images/icons.png',__FILE__))
		);
		wp_add_inline_style( 'Rich_Web_Forms-admin-ui-css', $rw_forms_root );
		wp_register_style( 'fontawesome-css', plugins_url('/Style/richwebicons.css', __FILE__), array(), time(), 'all' ); 
   		wp_enqueue_style( 'fontawesome-css' );	
		wp_register_style('Rich_Web_Forms', plugins_url('/Style/Rich-Web-Forms-Admin.css',__FILE__), array(), time(), 'all' );
		wp_enqueue_style('Rich_Web_Forms');
		wp_enqueue_script('RW_Tinymce', plugins_url('Scripts/tinymce.js',__FILE__),array('jquery','jquery-ui-core'),time(), false );
	}

	register_activation_hook(__FILE__,'Ric_Web_Forms_wp_activate');
	function Ric_Web_Forms_wp_activate()
	{
		require_once('Rich-Web-Forms-Install.php');
	}
	function Rich_Web_Forms_Color() 
	{
	    wp_enqueue_script(
	        'alpha-color-picker',
	        plugins_url('/Scripts/alpha-color-picker.js', __FILE__),	       
	        array( 'jquery', 'wp-color-picker' ), // You must include these here.
	        null,
	        true
	    );
	    wp_enqueue_style(
	        'alpha-color-picker',
	        plugins_url('/Style/alpha-color-picker.css', __FILE__),
	        array( 'wp-color-picker' ) // You must include these here.
	    );
	}
	add_action( 'admin_enqueue_scripts', 'Rich_Web_Forms_Color' );
?>