-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcitation-note.php
More file actions
130 lines (115 loc) · 3.94 KB
/
citation-note.php
File metadata and controls
130 lines (115 loc) · 3.94 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
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
<?php
/**
* Plugin Name: Citation Note
* Plugin URI:
* Description: Easily add, manage, and display citations, references, and footnotes in posts, pages, or custom post types using a user-friendly editor interface.
* Tags: CITENOTE, Citation, reference, footnotes, citation note
* Contributors: santoshtmp7, younginnovations
* Requires at least: 6.8
* Requires PHP: 8.0
* Tested up to: 6.9
* Version: 1.1.1
* Author: santoshtmp7
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: citation-note
*/
// Exit if accessed directly.
if (!defined('ABSPATH')) {
exit;
}
// define constant named
define('CITENOTE_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('CITENOTE_PLUGIN_URL', plugin_dir_url(__FILE__));
define('CITENOTE_PLUGIN_BASENAME', plugin_basename(__FILE__));
//
if (! class_exists('CITENOTE')) {
/**
* CITENOTE main class
*
*/
class CITENOTE {
/**
* construction
*/
function __construct() {
$include_paths = [
CITENOTE_PLUGIN_DIR . '/lib',
];
$this->citenote_include_path_files($include_paths);
new \citenote\CITENOTE_Data();
new \citenote\CITENOTE_Admin_Settings();
new \citenote\CITENOTE_Editor_Fields();
add_action('wp_enqueue_scripts', [$this, 'enqueue_citenote_scripts']);
}
/**
*
*/
function enqueue_citenote_scripts() {
wp_register_style(
"citation-note-style",
CITENOTE_PLUGIN_URL . 'assets/css/citation-note-style.css',
[],
filemtime(CITENOTE_PLUGIN_DIR . 'assets/css/citation-note-style.css')
);
wp_enqueue_script(
'citation-note-script',
CITENOTE_PLUGIN_URL . 'assets/js/citation-note.js',
['jquery'],
filemtime(CITENOTE_PLUGIN_DIR . 'assets/js/citation-note.js'),
true
);
}
/**
* citenote_get_path
*
* Returns the plugin path to a specified file.
*
* @param string $filename The specified file.
* @return string
*/
function citenote_get_path($filename = '') {
return CITENOTE_PLUGIN_DIR . ltrim($filename, '/');
}
/**
* Includes a file within the plugin.
*
* @param string $filename The specified file.
* @return void
*/
function citenote_include($filename = '') {
$file_path = $this->citenote_get_path($filename);
if (file_exists($file_path)) {
include_once $file_path;
}
}
/**
* requires all ".php" files from dir defined in "include_dir_paths" at first level.
* @param array $include_dir_paths will be [__DIR__.'/inc'];
*/
function citenote_include_path_files($include_dir_paths) {
foreach ($include_dir_paths as $key => $file_path) {
if (!file_exists($file_path)) {
continue;
}
foreach (new \DirectoryIterator($file_path) as $file) {
if ($file->isDot() || $file->isDir()) {
continue;
}
$fileExtension = $file->getExtension(); // Get the current file extension
if ($fileExtension != "php") {
continue;
}
// $fileName = $file->getFilename(); // Get the full name of the current file.
$filePath = $file->getPathname(); // Get the full path of the current file
if ($filePath) {
require_once $filePath;
}
}
}
}
// ======== END =======
}
}
// Execute CITENOTE main class
new CITENOTE();