<?php
/*
* Plugin Name: Raffle Play Woo
* Requires Plugins: woocommerce
* Plugin URI: https://tuskcode.com
* Version: 2.5.2
* Author: dan009
* Author URI: https://tuskcode.com
* Description: Raffle Play Woo is the next raffle plugin for your website. It offers a complete workflow of managing raffle tickets from the admin view to the user experience.
* Text Domain: raffle-play-woo
* Requires at least: 5.6
* Requires PHP: 7.2
* License: GPLv3
* Domain Path: /languages
*/

if( ! defined('ABSPATH') )
    die('No Access to this page');

if( ! defined('RAFFLE_PLAY_WOO_VERSION')) define('RAFFLE_PLAY_WOO_VERSION', '2.5.2');
if( ! defined('RAFFLE_PLAY_WOO_WP_TESTED')) define('RAFFLE_PLAY_WOO_WP_TESTED', '6.9');
if( ! defined('RAFFLE_PLAY_WOO_URL')) define( 'RAFFLE_PLAY_WOO_URL', esc_url( plugins_url( '', __FILE__ ) ) );
if( ! defined('RAFFLE_PLAY_WOO_DIR_PATH') ) define('RAFFLE_PLAY_WOO_DIR_PATH', plugin_dir_path( __FILE__ ));
if( ! defined('RAFFLE_PLAY_WOO_LOG_FILE')) define( 'RAFFLE_PLAY_WOO_LOG_FILE', RAFFLE_PLAY_WOO_DIR_PATH . 'logs/RafflePlayWoo_error.log' );


function RafflePlayWoo_NoticeWoocommerceNotInstalled(){   
    echo '<div class="notice notice-error is-dismissible"><strong>' .
        esc_html__( 'Raffle Play Woo', 'raffle-play-woo' ). '<br/>' .
        esc_html__( ' WooCommerce is not installed/active', 'raffle-play-woo' ) .' </strong></div>';
}

function RafflePlayWoo_error_log( $message ){
    error_log( date( 'Y-m-d H:i:s' ) . ' - ' . esc_html( $message ) . PHP_EOL, 3, RAFFLE_PLAY_WOO_LOG_FILE, 3 );
}

function RafflePlayWoo_WoocommerceInstalled(){
    $result = false;
    require_once( ABSPATH . '/wp-admin/includes/plugin.php' );

    if ( is_plugin_active('woocommerce/woocommerce.php') ) 
        $result = true;
    else
        add_action('admin_notices', 'RafflePlayWoo_NoticeWoocommerceNotInstalled'); 

    return $result;
} 

function RafflePlayWoo_i18n_init(){
    $pluginDir = dirname( plugin_basename(__FILE__) );
    load_plugin_textdomain( 'raffle-play-woo' , false, $pluginDir . '/languages/');
}

if( RafflePlayWoo_WoocommerceInstalled()  ){    
    include_once( 'raffle-play-woo_init.php');     
    RafflePlayWoo_init\RafflePlayWoo_init::RafflePlayWoo_init_plugin( __FILE__ );
}

add_action( 'init', 'RafflePlayWoo_i18n_init');    