/
hc-suggestions.php
63 lines (57 loc) · 1.48 KB
/
hc-suggestions.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
<?php
/**
* Plugin Name: HC Suggestions
* Plugin URI: https://github.com/mlaa/hc-suggestions
* Description: Widget to suggest content to members based on selected terms.
* Author: MLA
* Author URI: https://github.com/mlaa
* Text Domain: hc-suggestions
* Domain Path: /languages
* Version: 0.1.0
*
* @package HC_Suggestions
*/
/**
* Main file
*/
/**
* Register widget
*/
add_action(
'widgets_init', function() {
require_once trailingslashit( __DIR__ ) . 'classes/class-hc-suggestions-widget.php';
register_widget( 'HC_Suggestions_Widget' );
}
);
/**
* Register REST controller
*/
add_action(
'rest_api_init', function() {
require_once trailingslashit( __DIR__ ) . 'classes/class-hc-suggestions-rest-controller.php';
$controller = new HC_Suggestions_REST_Controller;
$controller->register_routes();
}
);
/**
* Register template stack
*/
add_action(
'bp_loaded', function () {
bp_register_template_stack(
function() {
return trailingslashit( __DIR__ ) . 'templates/';
}
);
}
);
/**
* Enqueue scripts
*/
add_action(
'wp_enqueue_scripts', function () {
wp_enqueue_script( 'hc-suggestions', trailingslashit( plugins_url() ) . 'hc-suggestions/public/js/hc-suggestions.js' );
wp_localize_script( 'hc-suggestions', 'wpApiSettings', [ 'nonce' => wp_create_nonce( 'wp_rest' ) ] );
wp_enqueue_style( 'hc-suggestions', trailingslashit( plugins_url() ) . 'hc-suggestions/public/css/hc-suggestions.css' );
}
);