Repository navigation
Expand file tree
/
Copy pathedit-post-link.php
More file actions
executable file
·68 lines (60 loc) · 2.31 KB
/
Copy pathedit-post-link.php
File metadata and controls
executable file
·68 lines (60 loc) · 2.31 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
<?php
/**
* Plugin Name: Edit Post Link
* Plugin URI: https://github.com/rafaelfunchal/edit-post-link
* Description: A plugin to insert a stylized link to edit posts and pages
* Author: rafaelfunchal
* Author URI: http://rafaelfunchal.com/
* Version: 0.4.0
* License: GPLv2 or later
* Text Domain: edit-post-link
* Domain Path: /languages/
* Requires at least: 6.0
* Requires PHP: 7.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'EDIT_POST_LINK_MIN_PHP_VERSION', '7.0' );
/**
* Check the PHP version and give a useful error message if the user's version is less than the required version
* @return boolean true if version check passed. If false, triggers an error which WP will handle, by displaying
* an error message on the Admin page
*/
function EditPostLink_noticePhpVersionWrong() {
echo '<div class="notice notice-error"><p>' .
esc_html__( 'Error: plugin "Edit Post Link" requires a newer version of PHP to be running.', 'edit-post-link' ) .
'<br/>' . esc_html__( 'Minimal version of PHP required: ', 'edit-post-link' ) . '<strong>' . esc_html( EDIT_POST_LINK_MIN_PHP_VERSION ) . '</strong>' .
'<br/>' . esc_html__( 'Your server\'s PHP version: ', 'edit-post-link' ) . '<strong>' . esc_html( phpversion() ) . '</strong>' .
'</p></div>';
}
function EditPostLink_PhpVersionCheck() {
if (version_compare(phpversion(), EDIT_POST_LINK_MIN_PHP_VERSION) < 0) {
add_action('admin_notices', 'EditPostLink_noticePhpVersionWrong');
return false;
}
return true;
}
/**
* Initialize internationalization (i18n) for this plugin.
* References:
* http://codex.wordpress.org/I18n_for_WordPress_Developers
* http://www.wdmac.com/how-to-create-a-po-language-translation#more-631
* @return void
*/
function EditPostLink_i18n_init() {
$pluginDir = dirname(plugin_basename(__FILE__));
load_plugin_textdomain('edit-post-link', false, $pluginDir . '/languages/');
}
//////////////////////////////////
// Run initialization
/////////////////////////////////
// First initialize i18n
add_action( 'init', 'EditPostLink_i18n_init' );
// Next, run the version check.
// If it is successful, continue with initialization for this plugin
if (EditPostLink_PhpVersionCheck()) {
// Only load and run the init function if we know PHP version can parse it
include_once('edit-post-link_init.php');
EditPostLink_init(__FILE__);
}