| 1 |
<?php |
| 2 |
/** |
| 3 |
* Shared Functions |
| 4 |
* |
| 5 |
* A group of functions shared across my plugins, for consistency. |
| 6 |
* |
| 7 |
* @package plugins-list |
| 8 |
*/ |
| 9 |
|
| 10 |
// Exit if accessed directly. |
| 11 |
|
| 12 |
if ( ! defined( 'ABSPATH' ) ) { |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
/** |
| 17 |
* Add meta to plugin details |
| 18 |
* |
| 19 |
* Add options to plugin meta line |
| 20 |
* |
| 21 |
* @version 1.1 |
| 22 |
* @param string $links Current links. |
| 23 |
* @param string $file File in use. |
| 24 |
* @return string Links, now with settings added. |
| 25 |
*/ |
| 26 |
function pll_plugin_meta( $links, $file ) { |
| 27 |
|
| 28 |
if ( false !== strpos( $file, 'plugins-list.php' ) ) { |
| 29 |
|
| 30 |
$links = array_merge( |
| 31 |
$links, |
| 32 |
array( '<a href="https://github.com/dartiss/plugins-list">' . __( 'Github', 'plugins-list' ) . '</a>' ), |
| 33 |
array( '<a href="https://wordpress.org/support/plugin/plugins-list">' . __( 'Support', 'plugins-list' ) . '</a>' ), |
| 34 |
array( '<a href="https://artiss.blog/donate">' . __( 'Donate', 'plugins-list' ) . '</a>' ), |
| 35 |
array( '<a href="https://wordpress.org/support/plugin/plugins-list/reviews/?filter=5" title="' . __( 'Rate the plugin on WordPress.org', 'plugins-list' ) . '" style="color: #ffb900">' . str_repeat( '<span class="dashicons dashicons-star-filled" style="font-size: 16px; width:16px; height: 16px"></span>', 5 ) . '</a>' ), |
| 36 |
); |
| 37 |
} |
| 38 |
|
| 39 |
return $links; |
| 40 |
} |
| 41 |
|
| 42 |
add_filter( 'plugin_row_meta', 'pll_plugin_meta', 10, 2 ); |
| 43 |
|
| 44 |
/** |
| 45 |
* WordPress Fork Check |
| 46 |
* |
| 47 |
* Deactivate the plugin if an unsupported fork of WordPress is detected. |
| 48 |
* |
| 49 |
* @version 1.0 |
| 50 |
*/ |
| 51 |
function pll_fork_check() { |
| 52 |
|
| 53 |
// Check for a fork. |
| 54 |
|
| 55 |
if ( function_exists( 'calmpress_version' ) || function_exists( 'classicpress_version' ) ) { |
| 56 |
|
| 57 |
// Grab the plugin details. |
| 58 |
|
| 59 |
$plugins = get_plugins(); |
| 60 |
$name = $plugins[ PLUGINS_LIST_PLUGIN_BASE ]['Name']; |
| 61 |
|
| 62 |
// Deactivate this plugin. |
| 63 |
|
| 64 |
deactivate_plugins( PLUGINS_LIST_PLUGIN_BASE ); |
| 65 |
|
| 66 |
// Set up a message and output it via wp_die. |
| 67 |
|
| 68 |
/* translators: 1: The plugin name. */ |
| 69 |
$message = '<p><b>' . sprintf( __( '%1$s has been deactivated', 'plugins-list' ), $name ) . '</b></p><p>' . __( 'Reason:', 'plugins-list' ) . '</p>'; |
| 70 |
/* translators: 1: The plugin name. */ |
| 71 |
$message .= '<ul><li>' . __( 'A fork of WordPress was detected.', 'plugins-list' ) . '</li></ul><p>' . sprintf( __( 'The author of %1$s will not provide any support until the above are resolved.', 'plugins-list' ), $name ) . '</p>'; |
| 72 |
|
| 73 |
$allowed = array( |
| 74 |
'p' => array(), |
| 75 |
'b' => array(), |
| 76 |
'ul' => array(), |
| 77 |
'li' => array(), |
| 78 |
); |
| 79 |
|
| 80 |
wp_die( wp_kses( $message, $allowed ), '', array( 'back_link' => true ) ); |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
add_action( 'admin_init', 'pll_fork_check' ); |
| 85 |
|