| 1 |
<?php |
| 2 |
namespace MBSocial; |
| 3 |
defined('ABSPATH') or die('No direct access permitted'); |
| 4 |
|
| 5 |
class Install |
| 6 |
{ |
| 7 |
protected static $issue; |
| 8 |
|
| 9 |
public static function getIssue() |
| 10 |
{ |
| 11 |
if (! is_null(self::$issue)) |
| 12 |
return self::$issue; |
| 13 |
|
| 14 |
return false; |
| 15 |
|
| 16 |
} |
| 17 |
|
| 18 |
public static function verifyPlugin() |
| 19 |
{ |
| 20 |
$not_fatal = true; |
| 21 |
|
| 22 |
$status = static::checkMaxButtons(); |
| 23 |
if (! $status) |
| 24 |
{ |
| 25 |
self::$issue = 'no-maxclass'; |
| 26 |
return false; // prevent loading |
| 27 |
} |
| 28 |
|
| 29 |
$version = self::check_mb_version(); |
| 30 |
if ( ! $version ) |
| 31 |
self::$issue = 'mb-wrong-version'; |
| 32 |
|
| 33 |
return true; |
| 34 |
} |
| 35 |
|
| 36 |
protected static function checkMaxButtons() |
| 37 |
{ |
| 38 |
if (! class_exists('MaxButtons\maxButtonsPlugin')) |
| 39 |
{ |
| 40 |
add_action('admin_notices', array(__NAMESPACE__ . '\Install', 'noMaxButtons')); |
| 41 |
return false; |
| 42 |
} |
| 43 |
return true; |
| 44 |
} |
| 45 |
|
| 46 |
protected static function check_mb_version() |
| 47 |
{ |
| 48 |
$result = version_compare( MAXBUTTONS_VERSION_NUM, MBSOCIAL_REQUIRED_MB ); |
| 49 |
|
| 50 |
if ($result >= 0) |
| 51 |
return true; |
| 52 |
else |
| 53 |
return false; |
| 54 |
|
| 55 |
} |
| 56 |
|
| 57 |
public static function noMaxButtons() |
| 58 |
{ |
| 59 |
|
| 60 |
$action = 'install-plugin'; |
| 61 |
$slug = 'maxbuttons'; |
| 62 |
$url = wp_nonce_url( |
| 63 |
add_query_arg( |
| 64 |
array( |
| 65 |
'action' => $action, |
| 66 |
'plugin' => $slug |
| 67 |
), |
| 68 |
admin_url( 'update.php' ) |
| 69 |
), |
| 70 |
$action.'_'.$slug |
| 71 |
); |
| 72 |
|
| 73 |
|
| 74 |
$message = sprintf( __("MaxButtons Social Share requires MaxButtons, which doesn't seem to be active or installed","maxbuttons"), PHP_VERSION); |
| 75 |
echo"<div class='error'> <h4>$message</h4> |
| 76 |
<p><a href='$url'>" . __('Install MaxButtons Now','mbsocial') . "</a></p> |
| 77 |
</div>"; |
| 78 |
return; |
| 79 |
|
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
} |
| 85 |
|