This repository was archived by the owner on Oct 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFleetManager.php
More file actions
executable file
·119 lines (92 loc) · 3.69 KB
/
FleetManager.php
File metadata and controls
executable file
·119 lines (92 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/**
* Plugin Name: WP Fleet Manager
* Description: Plugin de gestion de parc automobiles
* Version: 0.0.1
* Author: Romain DUMINIL
* Author URI: http://duminil.eu
*/
namespace FleetManager;
require_once 'vendor/autoload.php';
require_once 'app/socialnetwork/Facebook.php';
require_once 'app/vehicle/PostType.php';
require_once 'app/vehicle/Vehicle.php';
require_once 'app/main/Util.php';
require_once 'app/main/helpers.php';
require_once 'app/main/Settings.php';
require_once 'app/main/Notice.php';
require_once 'app/main/Logger.php';
require_once 'app/main/Install.php';
require_once 'app/transfer/Transfer.php';
require_once 'app/widget/Widget.php';
require_once 'app/widget/LastVehicleWidget.php';
require_once 'app/widget/VehicleSoldWidget.php';
class FleetManager
{
public static $settings;
public static $PLUGIN_URL;
public static $PLUGIN_PATH;
public static $notice;
public static $logger;
const PLUGIN_NAME = 'WP Fleet Manager';
const PLUGIN_SLUG = 'fleetmanager';
public function __construct()
{
self::$PLUGIN_URL = plugin_dir_url( __FILE__ );
self::$PLUGIN_PATH = plugin_dir_path( __FILE__ );
self::$settings = new Settings();
new Vehicle\PostType();
if( is_admin() )
{
self::$notice = new Notice();
self::$logger = new Logger();
if( self::$settings->getSetting( 'SocialNetwork', 'facebook', 'enabled' ) )
new SocialNetwork\Facebook();
}
register_activation_hook( __FILE__, array( '\FleetManager\Install', 'activate' ) );
register_deactivation_hook( __FILE__, array( '\FleetManager\Install', 'deactivate' ) );
register_uninstall_hook( __FILE__, array( '\FleetManager\Install', 'uninstall' ) );
add_action( 'init', array( $this, 'loadLanguages' ), 10, 0 );
add_action( 'admin_notices', array( self::$notice, 'displayNotice' ), 10, 0 );
add_action( 'admin_enqueue_scripts', array( $this, 'loadStyles' ), 10, 0 );
add_action( 'admin_enqueue_scripts', array( $this, 'loadScripts' ), 10, 0 );
add_action( 'admin_enqueue_scripts', array( $this, 'loadTransferScript' ), 10, 1 );
add_action( 'admin_post_FM_transfer', array( 'FleetManager\Transfer\Transfer', 'transferPostRequest' ), 10, 0 );
add_action( 'wp_dashboard_setup', array( $this, 'loadWidgets' ), 10, 0 );
}
public function loadStyles()
{
wp_register_style( 'animationCss', self::$PLUGIN_URL . 'ressources/css/animation.css' );
wp_enqueue_style( 'animationCss' );
wp_register_style( 'utilCss', self::$PLUGIN_URL . 'ressources/css/util.css' );
wp_enqueue_style( 'utilCss' );
}
function loadScripts()
{
wp_enqueue_script( 'jquery-ui', 'http://code.jquery.com/ui/1.12.1/jquery-ui.min.js', [], null, true );
wp_register_script( 'FM_mainScript', FleetManager::$PLUGIN_URL . 'ressources/js/main.js', array( 'jquery' ) );
wp_localize_script( 'FM_mainScript', 'util', array(
'isAdmin' => is_admin(),
'currentPage' => get_current_screen(),
) );
wp_enqueue_script( 'FM_mainScript' );
}
function loadTransferScript( $currentPage )
{
if ( 'settings_page_fleetmanager_settings_page' !== $currentPage )
return;
wp_register_script( 'FM_transferScript', FleetManager::$PLUGIN_URL . 'ressources/js/transfer.js', array( 'jquery' ) );
wp_enqueue_script( 'FM_transferScript' );
}
function loadLanguages()
{
// FIXME: ne fonctionne pas / je n'arrive pas à voir la version anglaise du plugin
load_plugin_textdomain( 'fleetmanager', false, self::$PLUGIN_URL . 'ressources/lang' );
}
function loadWidgets()
{
new LastVehicleWidget();
new VehicleSoldWidget();
}
}
new FleetManager();