-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
63 lines (56 loc) · 2.39 KB
/
index.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: ILR Import
Plugin URI: https://illlinoislawreview.org/plugins/ilr-import
Description: Import from Word files
Version: 20240906
Author: Matt Loar <[email protected]>
Author URI: https://github.com/mloar
License: BSD
License URI: https://directory.fsf.org/wiki/License:BSD_3Clause
Text Domain: ilr-import
Domain Path: /languages
*/
function ilr_import_docx_metabox() {
//must check that the user has the required capability
if (!current_user_can('edit_posts')) {
wp_die( __('You do not have sufficient permissions to access this page.') );
}
wp_enqueue_script("jszip", "/wp-content/plugins/ilr-import/js/jszip.min.js");
wp_enqueue_script("docx.js", "/wp-content/plugins/ilr-import/js/docx.js");
wp_enqueue_script("ilr-import-metabox.js", "/wp-content/plugins/ilr-import/js/ilr-import-metabox.js");
echo '<label class="screen-reader-text" for="import_docx_file">Import DOCX File</label>';
echo '<input type="file" id="import_docx_file">';
echo '<div class="spinner"></div>';
echo '<p>Selecting a DOCX file will replace the content of this post with the contents of the DOCX file converted to HTML.</p>';
}
function ilr_import_register_metabox() {
add_meta_box('import-docx', 'Import DOCX', 'ilr_import_docx_metabox', 'post');
}
function ilr_import_new_print_issue() {
if (isset($_POST['year']) && isset($_POST['issue'])) {
wp_insert_category(array(
'cat_name' => "Vol. {$_POST['year']} No. {$_POST['issue']}",
'category_nicename' => "volume-{$_POST['year']}-issue-{$_POST['issue']}",
'category_parent' => 36
));
} else {
echo '<div class="wrap">';
echo '<h1>New Print Issue</h1>';
echo '<form enctype="multipart/form-data" method="POST">';
echo '<label for="year">Year</label>';
echo '<input type="text" name="year" id="year"/>';
echo '<label for="issue">Issue</label>';
echo '<input type="text" name="issue" id="issue"/>';
echo '<input type="submit" value="Add"/>';
echo '</form>';
echo '</div>';
}
}
function ilr_import_add_submenu() {
add_posts_page('Create a new print issue', 'New Print Issue', 'manage_categories', 'ilr-import-new-print-issue',
'ilr_import_new_print_issue');
}
add_action('add_meta_boxes', 'ilr_import_register_metabox');
add_action('admin_menu', 'ilr_import_add_submenu');
?>