-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwp-display-version.php
More file actions
64 lines (50 loc) · 2.04 KB
/
wp-display-version.php
File metadata and controls
64 lines (50 loc) · 2.04 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
<?php
/*
Plugin Name: WP Display Version
Plugin URI: https://github.com/jonatanbereta/wp-display-version.git
Description: Plugin to display versions of WP
Version: 1.0
Author: Jonatan Bereta
Author URI: https://jonatanbereta.netlify.app
Uninstaller
*/
require __DIR__ . "/inc/functions.php";
require __DIR__ . "/inc/helpers.php";
function wp_version_add_stylesheet()
{
wp_enqueue_style('wp-version-fontawesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css', array(), false, 'all');
wp_enqueue_style('wp-version-style', plugin_dir_url(__FILE__) . '/css/style.css', array(), filemtime(__DIR__ . '/css/style.css'), 'all');
}
add_action('wp_enqueue_scripts', 'wp_version_add_stylesheet');
function wp_version_add_script()
{
wp_enqueue_script('wp-version-jquery', plugin_dir_url(__FILE__) . '/js/jquery.js', array(), false, 'all');
wp_enqueue_script('wp-version-script', plugin_dir_url(__FILE__) . '/js/script.js', array(), filemtime(__DIR__ . '/js/script.js'), 'all');
}
add_action('wp_enqueue_scripts', 'wp_version_add_script');
function wp_version($atts)
{
$atts = shortcode_atts([
'type' => '',
'version' => '',
'color' => 'yes',
], $atts);
$data = get_wp_data();
if ($atts['type'] === 'latest') {
return wp_version_latest($data, $atts['color']);
} else if ($atts['type'] === 'validate') {
$status = wp_version_validate($atts['version'], $data);
return wp_version_status($atts['version'], $status, $atts['color']);
} else if ($atts['type'] === 'subversion') {
$list = "<div><p>Subversion of the version " . $atts['version'] . "</p><ul class='subversion'>";
$subversion = wp_version_subversion($atts['version'], $data);
foreach ($subversion as $item) {
$list .= "<li>" . $item . "</li>";
}
$list .= "</ul></div>" . display_wp_date();
return $list;
} else if ($atts['type'] === 'mine') {
return wp_version_mine($data, $atts['color']);
}
}
add_shortcode('wp_version', 'wp_version');