-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpilot-configurator.php
192 lines (146 loc) · 7.19 KB
/
pilot-configurator.php
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
/**
Plugin Name: Pilot Configurator
Plugin URI: https://inno-oppiva.uta.fi/
Description: Pilot Configurator for providing matchmaking in the Inno-Oppiva project
Author: Pilot Configurator Team
Version: 1.0.0
Text Domain: pilot-configurator
-----------------
Glossary:
User - a WordPress user account
*/
#namespace Inno_Oppiva;
// Deny direct access to this file
if ( ! defined( 'ABSPATH' ) ) {
die( ' Access denied!' );
}
/**
* Define plugin settings as PHP globals.
*/
define( 'PILOT_CONFIGURATOR_DIR_PATH', plugin_dir_path( __FILE__ ) );
define( 'PILOT_CONFIGURATOR_PLUGIN_VERSION', '1.0.0' );
/**
* Require plugin files.
*
*/
require PILOT_CONFIGURATOR_DIR_PATH . 'includes/class-pilot-configurator.php';
require PILOT_CONFIGURATOR_DIR_PATH . 'includes/admin/class-pilot-configurator-admin.php';
require PILOT_CONFIGURATOR_DIR_PATH . 'includes/class-inno-oppiva-login.php';
require PILOT_CONFIGURATOR_DIR_PATH . 'includes/inno-user-roles.php';
require PILOT_CONFIGURATOR_DIR_PATH . 'includes/match-algorithm.php';
require PILOT_CONFIGURATOR_DIR_PATH . 'includes/class-page-templater.php';
require PILOT_CONFIGURATOR_DIR_PATH . 'includes/pages/company-view.php';
require PILOT_CONFIGURATOR_DIR_PATH . 'includes/pages/create-product-information.php';
require PILOT_CONFIGURATOR_DIR_PATH . 'includes/pages/splashes.php';
require PILOT_CONFIGURATOR_DIR_PATH . 'includes/pages/questionforms.php';
require PILOT_CONFIGURATOR_DIR_PATH . 'includes/shortcodes/splash-screen-shortcode.php';
require PILOT_CONFIGURATOR_DIR_PATH . 'includes/shortcodes/questionform-shortcode.php';
require PILOT_CONFIGURATOR_DIR_PATH . 'lib/helpers-ajax.php';
add_shortcode( 'pilotcfg_any_splash', 'pilotcfg_any_splash' );
add_shortcode( 'pilotcfg_questionform', 'pilotcfg_questionform' );
register_activation_hook (__FILE__, 'add_inno_user_roles');
register_deactivation_hook (__FILE__, 'remove_inno_user_roles');
require_once (dirname(__FILE__) . '/includes/createdb.php');
require_once (dirname(__FILE__) . '/includes/destroydb.php');
register_activation_hook (__FILE__, 'jal_install');
register_uninstall_hook( __FILE__, 'jal_uninstall' );
/**
* Inno-Oppiva platform login system initialization commands
*
*/
function inno_oppiva_init() {
$inno_oppiva_login = new Inno_Oppiva\Inno_Oppiva_Login();
$inno_oppiva_login->init();
}
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );
register_activation_hook (__FILE__, 'create_questionforms');
register_activation_hook (__FILE__, 'create_splashes');
register_activation_hook (__FILE__, 'create_product_information');
register_deactivation_hook (__FILE__, 'remove_questionforms');
register_deactivation_hook (__FILE__, 'remove_splashes');
register_deactivation_hook (__FILE__, 'remove_product_information');
// Registering PHP functions for the ajax functions
add_action('wp_ajax_list_active_companies', 'list_active_companies');
add_action('wp_ajax_school_question_insert', 'school_question_insert');
add_action('wp_ajax_company_question_insert', 'company_question_insert');
add_action('wp_ajax_company_id_cookie_set', 'company_id_cookie_set');
add_action('wp_ajax_back_button_function', 'back_button_function');
add_action('wp_ajax_company_csv_gen', 'company_csv_gen');
add_action('wp_ajax_school_csv_gen', 'school_csv_gen');
register_activation_hook (__FILE__, 'ajax_test_enqueue_scripts');
add_action( 'wp_enqueue_scripts', 'ajax_test_enqueue_scripts');
// Funtion that adds needed scripts and stylesheets
function ajax_test_enqueue_scripts() {
// The scripts and stylesheet for questionform slider initialization
wp_enqueue_style(' bootstrap_style', plugins_url( 'includes/javascript/bootstrap-slider/css/bootstrap.min.css', __FILE__ ));
wp_enqueue_style(' sliders_style', plugins_url( 'includes/javascript/bootstrap-slider/css/bootstrap-slider.css', __FILE__ ));
wp_enqueue_script( 'sliders_main', plugins_url( 'includes/javascript/bootstrap-slider/bootstrap-slider.js', __FILE__ ), array( 'jquery' ));
wp_localize_script( 'slidersmain', 'mainsliders', array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
));
wp_enqueue_script( 'sliders', plugins_url( 'includes/javascript/sliders.js', __FILE__ ), array( 'jquery' ), '1.0', true );
wp_localize_script( 'slidersown', 'ownmainsliders', array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
));
// The script for questionform button functions
wp_enqueue_script( 'questionform_functions', plugins_url( 'includes/javascript/questionform_functions.js', __FILE__ ), array( 'jquery' ), '1.0', true );
wp_localize_script( 'questionform_functions', 'questionFormFunctions', array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
));
//The script for listing the company products in school splash screens
wp_enqueue_script( 'companyLister', plugins_url( 'includes/javascript/companyLister.js', __FILE__ ), array( 'jquery' ), '1.0', true );
wp_localize_script( 'companyLister', 'company_lister', array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
));
wp_enqueue_script( 'plotly', plugins_url( 'includes/javascript/plotly-latest.min.js', __FILE__ ), array( 'jquery' ));
wp_enqueue_script( 'chart', plugins_url( 'includes/javascript/Chart.min.js', __FILE__ ), array( 'jquery' ));
wp_enqueue_script( 'pilot_chart', plugins_url( 'includes/javascript/pilotti-Chart.js', __FILE__), array( 'jquery'));
wp_enqueue_script( 'heatmap', plugins_url( 'includes/javascript/heatmap.js', __FILE__ ), array( 'jquery' ));
wp_enqueue_script( 'data_driven_docs', "https://d3js.org/d3.v3.min.js", array( 'jquery' ));
wp_enqueue_script( 'radarChart', plugins_url( 'includes/javascript/radarChart.js', __FILE__ ), array( 'jquery' ));
wp_enqueue_script( 'pilot_Radar', plugins_url( 'includes/javascript/pilotti-radarChart.js', __FILE__ ), array( 'jquery' ));
}
add_action( 'rest_api_init', 'register_rest_pilot_routes');
function register_rest_pilot_routes () {
register_rest_route( 'pilotconf/v1', '/questions', array(
'methods' => 'GET',
'callback' => 'pilotconf_questions',
) );
register_rest_route( 'pilotconf/v1', '/question_sets', array(
'methods' => 'GET',
'callback' => 'pilotconf_question_sets',
) );
}
function pilotconf_question_sets( $request ) {
global $wpdb;
$return_data = $wpdb->get_results('SELECT DISTINCT theme FROM wp_Questions');
wp_send_json($return_data);
}
function pilotconf_questions( $request ) {
global $wpdb;
$return_data = $wpdb->get_results("SELECT question FROM wp_Questions;");
wp_send_json($return_data);
}
function page_templater_init() {
$page_templater = new Inno_Oppiva\Page_Templater();
$page_templater->init();
}
register_activation_hook (__FILE__, 'create_company_view');
register_deactivation_hook (__FILE__, 'remove_company_view');
/**
* Begins the execution of the plugin. Pilot_Configurator_Admin is required only when
* currently in admin, but Pilot_Configurator needs to be initialized anyway.
*/
function pilot_configurator_init() {
$pilot_configurator_client = new Inno_Oppiva\Pilot_Configurator_Client();
$pilot_configurator_client->init();
if ( is_admin() ) {
$pilot_configurator_admin = new Inno_Oppiva\Admin\Pilot_Configurator_Admin();
$pilot_configurator_admin->init();
}
}
inno_oppiva_init();
page_templater_init();
pilot_configurator_init();