<?php

/**
 * @package docuchat
 * @version 0.0.1
 * @author Ricardo P Lavour
 * @param none 
 * @return none
 */

 if ( ! defined( 'ABSPATH' ) ) exit;

define('DOCUCHAT_ACTIVATION_SERIALIZACION', 'docuchat_activation_serializacion');
define('DOCUCHAT_TOKEN', 'docuchat_token');
define('DOCUCHAT_EMAIL', 'docuchat_email_registred');
define('DOCUCHAT_IMAGES_IDS', 'docuchat_images_ids');



// # file with the layout of the plugin
require_once plugin_dir_path(__FILE__) . '../front/docuchat_layout.php';

// #add plugin menu adminitration function 
require_once plugin_dir_path(__FILE__) . '../utils/docuchat_adminMenu.php';

// #add plugin submenu adminitration function
require_once plugin_dir_path(__FILE__) . '../utils/docuchat_deleteAcounSubMenu.php';

// #add plugin submenu adminitration function
require_once plugin_dir_path(__FILE__) . '../utils/docuchat_adminSubMenu.php';

// #add plugin style and js function
require_once plugin_dir_path(__FILE__) . '../utils/docuchat_script_styles_files.php';

// #add a link to configure the plugin
require_once plugin_dir_path(__FILE__) . '../utils/docuchat_add_action_links.php';

# add this action when activate the plg
require_once plugin_dir_path(__FILE__) . '../utils/docuchat_activation_process.php';

# ajax conectors
require_once plugin_dir_path(__FILE__) . '../utils/docuchat_ajaxconections.php';

# add images when active the plugion
require_once plugin_dir_path(__FILE__) . '../utils/docuchat_add_images_and_resources.php';

# remove images when desactive the plugion
require_once plugin_dir_path(__FILE__) . '../utils/docuchat_remove_images_and_resources.php';

 

// # tp add the menu plugion item
if(function_exists('docuchat_adminMenu')){
    add_action('admin_menu', 'docuchat_adminMenu');
}

// # add a submenu to the plugin
if(function_exists('docuchat_adminSubMenu')){
add_action('admin_menu', 'docuchat_adminSubMenu');
}

if(function_exists('docuchat_deleteAcounSubMenu')){
  add_action('admin_menu', 'docuchat_deleteAcounSubMenu');
}


# this for add css and js for the backen 
if(function_exists('docuchat_script_styles_files')){
add_action('admin_enqueue_scripts', 'docuchat_script_styles_files');
add_action('wp_enqueue_scripts', 'docuchat_script_styles_files_front');

}

# this for add css and js for the front
// if(function_exists('docuchat_script_styles_files_front')){
// add_action('wp_enqueue_scripts', 'docuchat_script_styles_files_front');
// }

# add this action when activate the plg
if(function_exists('docuchat_activation_process')){
add_action("activate_plugin", "docuchat_activation_process", 10, 1);
}

# add this action when activate the plg
if(function_exists('docuchat_add_images_and_resources')){
register_activation_hook( plugin_dir_path(__DIR__). 'docuchat.php' , 'docuchat_add_images_and_resources');
}

# add images when active the plugion
if(function_exists('docuchat_remove_images_and_resources')){
register_uninstall_hook( plugin_dir_path(__DIR__). 'docuchat.php' , 'docuchat_remove_images_and_resources' );
}

# add a link to the plugin settings and url to the plugin manager webpage
if(function_exists('docuchat_add_action_links')){
add_filter('plugin_action_links_docu_chat/docuchat.php', 'docuchat_add_action_links');
}
 
$showPLuginWidget = null !== get_option( DOCUCHAT_ACTIVATION_SERIALIZACION ) ? unserialize( get_option( DOCUCHAT_ACTIVATION_SERIALIZACION ) ) : null;

if( isset( $showPLuginWidget[3] )  && $showPLuginWidget[3] == 'active'){
    if(function_exists('docuchat_layout')){
    add_action('wp_footer', 'docuchat_layout');
    }
}; 