-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwp-react.php
More file actions
47 lines (40 loc) · 1.37 KB
/
Copy pathwp-react.php
File metadata and controls
47 lines (40 loc) · 1.37 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
<?php
/**
* Plugin Name: WP React
* Plugin URI: https://baranozdemir.com
* Description: React app in WordPress
* Version: 1.0.0
* Author: Baran Özdemir
* Author URI: https://baranozdemir.com
* License: MIT
* License URI: https://raw.githubusercontent.com/baranozdemir1/wordpress-react-plugin/main/LICENSE
* Text Domain: wp-react
*/
if (!defined('ABSPATH'))
exit();
/**
* Define Plugin Constants
*/
define('WP_REACT_PLUGIN_DIR', trailingslashit(plugin_dir_path(__FILE__)));
define('WP_REACT_PLUGIN_URL', trailingslashit(plugins_url('/', __FILE__)));
/**
* Include Plugin Classes
*/
require_once WP_REACT_PLUGIN_DIR . 'classes/class-helper.php';
require_once WP_REACT_PLUGIN_DIR . 'classes/class-create-admin-menu.php';
/**
* Load Scripts
*/
if (WP_React_Helper::is_wp_react_page()) {
add_action('admin_enqueue_scripts', 'wp_react_admin_scripts');
function wp_react_admin_scripts()
{
wp_enqueue_style('wp-react', WP_REACT_PLUGIN_URL . 'dist/output.css', array(), filemtime(WP_REACT_PLUGIN_DIR . 'dist/output.css'));
wp_enqueue_script('wp-react', WP_REACT_PLUGIN_URL . 'dist/bundle.js', array('jquery', 'wp-element'), filemtime(WP_REACT_PLUGIN_DIR . 'dist/bundle.js'), true);
wp_localize_script('wp-react', 'appLocalizer', [
'ajaxUrl' => admin_url('admin-ajax.php'),
'apiUrl' => rest_url(),
'nonce' => wp_create_nonce('wp_rest')
]);
}
}