Last active
July 28, 2023 18:27
-
-
Save dartiss/d0d117f251cf6b9bd750c19ec9377c23 to your computer and use it in GitHub Desktop.
WordPress fork detection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* WordPress fork detection | |
* | |
* Check if a WordPress fork is in use. The check is a seperate function, instead of simply using the current function_exists | |
* in case the method of detection needs to change. | |
*/ | |
function is_fork() { | |
$fork = false; | |
if ( function_exists( 'calmpress_version' ) ) { $fork = 'calmPress'; } | |
if ( function_exists( 'classicpress_version' ) ) { $fork = 'ClassicPress'; } | |
return $fork; | |
} | |
/** | |
* Show fork message | |
* | |
* Display a message, if user is using a WordPress fork | |
*/ | |
function fork_admin_message() { | |
if ( false !== is_fork() ) { | |
echo '<div class="notice notice-error"><p>' . __( '[Plugin name] does not support forks of WordPress. Please disable the plugin or consider switching to WordPress.', 'sample-text-domain' ) . '</p></div>'; | |
} | |
} | |
add_action( 'admin_notices', 'fork_admin_message' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment