<?php

/**
* Plugin Name: Counter for Divi
* Plugin URI: https://divi-sensei.com/counter-for-divi/
* Description: A more powerful counter for Divi
* Author: Divi Sensei
* Author URI: https://divi-sensei.com
* Version: 1.5.1
*/

//Load Base Module Class
require_once plugin_dir_path(__FILE__).'/includes/jt-divi-module/class-jt-divi-module.php';

//Load Theme Customizer settings stuff
if (!function_exists('jt_divi_module_customize_preview_init')) {
  function jt_divi_module_customize_preview_init()
  {
      wp_enqueue_script(
          'jt_divi_module_customize_preview_init',
          plugin_dir_url(__FILE__) . '/includes/jt-divi-module/jt-divi-module-customizer-preview.js',
          array('customize-preview'),
          true
      );
  }
  add_action('customize_preview_init', 'jt_divi_module_customize_preview_init');
}




//Load Counter Module
require_once plugin_dir_path(__FILE__).'/jt-divi-counter-module.php';

//Load Customizer
require_once plugin_dir_path(__FILE__).'/jt-divi-counter-module-customizer.php';

//Load Updater
// require_once plugin_dir_path(__FILE__).'/jt-divi-counter-updater.php';
//Load Updater
require plugin_dir_path(__FILE__) . '/includes/plugin-update-checker/plugin-update-checker.php';
$MyUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
	'http://divi-sensei.com/wp-update-server/?action=get_metadata&slug=jt-divi-counter', //Metadata URL.
	__FILE__, //Full path to the main plugin file.
	'jt-divi-counter' //Plugin slug. Usually it's the same as the name of the directory.
);


//Lod Frontend CSS and JS
function jt_divicounter_enqueue_scripts() {
  wp_enqueue_style ( 'jt_divi_counter_css', plugins_url( 'css/style.css', __FILE__ ));
  wp_enqueue_script( 'jt_divi_counter_resize_sensor', plugin_dir_url( __FILE__ ) . 'includes/ResizeSensor.js', array('jquery'), true );
  wp_enqueue_script( 'jt_divi_counter', plugin_dir_url( __FILE__ ) . 'js/jt-divi-counter.js', array( 'jquery', 'et-builder-modules-global-functions-script', 'jt_divi_counter_resize_sensor' ), true );
}
add_action( 'wp_enqueue_scripts', 'jt_divicounter_enqueue_scripts' );


//Load Admin CSS
add_action( 'admin_enqueue_scripts', 'jt_divicounter_admin_enqueue_scripts' );
function jt_divicounter_admin_enqueue_scripts() {
  wp_enqueue_style ( 'jt_divicounter_admin_css', plugins_url( 'admin/css/admin-style.css', __FILE__ ));
  wp_enqueue_script( 'jt_divi_counter', plugin_dir_url( __FILE__ ) . '/admin/js/jt-divi-counter-admin.js', array( 'jquery' ), true );
}


//Load Module Customizer extensions
// require_once plugin_dir_path(__FILE__).'/jt-divi-counter-module-customizer.php';
function et_jt_divi_counter_customize_preview_js() {
	wp_enqueue_script( 'jt-divi-counter-module-customizer', plugin_dir_url( __FILE__ ) . 'js/jt-divi-counter-module-customizer.js', array( 'customize-preview' ), true );
}
add_action( 'customize_preview_init', 'et_jt_divi_counter_customize_preview_js' );
