Skip to content

Instantly share code, notes, and snippets.

@dartiss
Last active July 28, 2023 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dartiss/d0d117f251cf6b9bd750c19ec9377c23 to your computer and use it in GitHub Desktop.
Save dartiss/d0d117f251cf6b9bd750c19ec9377c23 to your computer and use it in GitHub Desktop.
WordPress fork detection
<?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