/**
* Plugin Name: Statics Um
* Description: Modulo con estadisticas de tu web
* Version: 2.0
* Author: Undermarket Servicios Informáticos
* Plugin URI: https://undermarket.cl
*
*
*
*
/** Evitar que se acceda directamente a la clase */
if ( ! defined( 'ABSPATH' ) ) { exit; }
class StaticsUm
{
public function __construct()
{
define( 'STATICS_VERSION', '2.0' );
define( 'STATICS_TEMPLATE_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/templates/' );
define( 'STATICS_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
define( 'STATICS_MAIN_FILE', __FILE__ );
define( 'STATICS_ABSPATH', dirname( __FILE__ ) . '/' );
add_action( 'wp_enqueue_scripts', array( $this, 'StaticsJs' ), 999 );
add_action( 'plugins_loaded', array( $this, 'StaticsIncludes' ) );
add_action( 'plugins_loaded', array( $this, 'StaticsInit' ) );
if ( is_admin() ) {
$this->StaticsAdminIncludes();
}
}
public function StaticsIncludes()
{
include_once( STATICS_ABSPATH . 'functions.php' );
}
public function StaticsInit()
{
add_filter( 'template_include', array( $this, 'StaticsTemplate' ), 11 );
add_filter( 'wc_get_template', array( $this, 'StaticTemplate' ), 11, 5 );
}
public function StaticsAdminIncludes()
{
}
public function StaticsTemplate( $template ) {
if ( file_exists( untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/templates/' . basename( $template ) ) ) {
$template = untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/templates/' . basename( $template );
}
return $template;
}
public function StaticTemplate( $located, $template_name, $args, $template_path, $default_path ) {
$plugin_template_path = untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/templates/woocommerce/' . $template_name;
if ( file_exists( $plugin_template_path ) ) {
$located = $plugin_template_path;
}
return $located;
}
public function StaticsJs()
{
// Estilos css
wp_register_style( 'StaticsCss', STATICS_PLUGIN_URL . '/style.css', null, STATICS_VERSION );
wp_enqueue_style( 'StaticsCss' );
// Scripts de javascript
wp_enqueue_script('StaticsJs', STATICS_PLUGIN_URL . '/script.js' , array('jquery'));
}
}
function StaticsActivate() {
global $wpdb;
$table_name1 = $wpdb->prefix . 'AStaticsUm';
$table_name2 = $wpdb->prefix . 'AStaticsSesions';
$table_name3 = $wpdb->prefix . 'AStaticsData';
$table_name4 = $wpdb->prefix . 'AStaticsConvertions';
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE $table_name1 (
id mediumint(9) NOT NULL AUTO_INCREMENT,
meta_key varchar(255) NOT NULL,
meta_value longtext NOT NULL,
PRIMARY KEY (id)
) $charset_collate;
CREATE TABLE $table_name2 (
Id mediumint(9) NOT NULL AUTO_INCREMENT,
Ip varchar(255) NOT NULL,
DateTime datetime NOT NULL,
PRIMARY KEY (Id)
) $charset_collate;
CREATE TABLE $table_name3 (
IdData mediumint(9) NOT NULL AUTO_INCREMENT,
IdEvento mediumint(9) NOT NULL,
Evento varchar(255) NOT NULL,
Valor longtext NOT NULL,
DateTimeData datetime NOT NULL,
PRIMARY KEY (IdData)
) $charset_collate;
CREATE TABLE $table_name4 (
Id mediumint(9) NOT NULL AUTO_INCREMENT,
Type mediumint(9) NOT NULL,
TypeObj mediumint(9) NOT NULL,
Name varchar(255) NOT NULL,
Target longtext NOT NULL,
Description longtext NOT NULL,
DateTime datetime NOT NULL,
PRIMARY KEY (Id)
) $charset_collate;";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql );
}
register_activation_hook(__FILE__, 'StaticsActivate');
function StaticsDeactivate() {
global $wpdb;
$table_name = $wpdb->prefix . 'AStaticsUm';
$wpdb->query("DROP TABLE IF EXISTS $table_name");
}
register_deactivation_hook(__FILE__, 'StaticsDeactivate');
$GLOBALS['StaticsUm'] = new StaticsUm();
Deluxe - Planytrip.cl
Traductor »
Aún no agregaste productos.
0
¡Hola! Me gustaría que me contacte un agente Planytrip.