-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelevant-density-optimizer.php
More file actions
73 lines (64 loc) · 2.17 KB
/
relevant-density-optimizer.php
File metadata and controls
73 lines (64 loc) · 2.17 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
<?php
/**
* Plugin Name: Relevant Density Optimizer (RDO) - On-Page SEO Tool
* Description: Highlight terms in Gutenberg editor and optimize relevant density for SEO.
* Author: Infinitnet
* Author URI: https://infinitnet.io/
* Plugin URI: https://infinitnet.io/relevant-density-optimizer/
* Version: 1.8.0
* License: GPLv2 or later
* Text Domain: relevant-density-optimizer
*/
namespace Infinitnet\RDOINFINITNET;
if (!defined('ABSPATH')) {
exit;
}
define('RDOINFINITNET_VERSION', '1.8.0');
function rdoinfinitnet_enqueue_block_editor_assets() {
// Only proceed if user has appropriate permissions
if (!current_user_can('edit_posts')) {
return;
}
if (!wp_script_is('rdoinfinitnet-plugin-js', 'enqueued')) {
wp_enqueue_script(
'rdoinfinitnet-plugin-js',
plugin_dir_url(__FILE__) . 'rdoinfinitnet.js',
array(
'wp-plugins',
'wp-editor',
'wp-element',
'wp-data',
'wp-compose',
'wp-components',
'wp-blocks',
'wp-i18n',
'wp-dom-ready'
),
RDOINFINITNET_VERSION,
true
);
// Add a nonce for the editor operations
wp_localize_script(
'rdoinfinitnet-plugin-js',
'rdoinfinitnetData',
array(
'nonce' => wp_create_nonce('rdoinfinitnet_nonce'),
'ajaxUrl' => admin_url('admin-ajax.php')
)
);
}
wp_enqueue_style('rdoinfinitnet-plugin-css', plugin_dir_url(__FILE__) . 'rdoinfinitnet.css', array(), RDOINFINITNET_VERSION);
}
function rdoinfinitnet_register_meta() {
register_meta('post', '_important_terms', array(
'show_in_rest' => true,
'single' => true,
'type' => 'string',
'auth_callback' => function() {
return current_user_can('edit_posts');
},
'sanitize_callback' => 'sanitize_textarea_field'
));
}
add_action('enqueue_block_editor_assets', __NAMESPACE__ . '\\rdoinfinitnet_enqueue_block_editor_assets');
add_action('init', __NAMESPACE__ . '\\rdoinfinitnet_register_meta');