| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPAdminify; |
| 4 |
|
| 5 |
use WPAdminify\Inc\Classes\Assets; |
| 6 |
use WPAdminify\Inc\Admin\Admin; |
| 7 |
use WPAdminify\Inc\Admin\AdminSettings; |
| 8 |
|
| 9 |
if (!defined('ABSPATH')) { |
| 10 |
exit; |
| 11 |
} // No, Direct access Sir !!! |
| 12 |
|
| 13 |
if (!class_exists('WP_Adminify')) { |
| 14 |
|
| 15 |
class WP_Adminify |
| 16 |
{ |
| 17 |
|
| 18 |
const VERSION = WP_ADMINIFY_VER; |
| 19 |
private static $instance = null; |
| 20 |
|
| 21 |
public function __construct() |
| 22 |
{ |
| 23 |
add_action('plugins_loaded', [$this, 'jltwp_adminify_plugins_loaded'], 999); |
| 24 |
add_filter('plugin_action_links_' . WP_ADMINIFY_BASE, [$this, 'plugin_action_links']); |
| 25 |
add_filter('network_admin_plugin_action_links_' . WP_ADMINIFY_BASE, [$this, 'plugin_action_links']); |
| 26 |
|
| 27 |
add_filter('admin_body_class', [$this, 'jltwp_adminify_body_class']); |
| 28 |
$this->jltwp_is_plugin_row_meta(); |
| 29 |
$this->jltwp_adminify_include_files(); |
| 30 |
jltwp_adminify()->add_filter('freemius_pricing_js_path', [$this, 'jltwp_new_freemius_pricing_js']); |
| 31 |
} |
| 32 |
|
| 33 |
public function jltwp_is_plugin_row_meta() |
| 34 |
{ |
| 35 |
if (jltwp_adminify()->can_use_premium_code__premium_only()) { |
| 36 |
if (jltwp_adminify()->is_plan__premium_only('agency')) { |
| 37 |
$jltwp_adminify_wl_plugin_row_links = AdminSettings::get_instance()->get('jltwp_adminify_wl_plugin_row_links'); |
| 38 |
if (!empty($jltwp_adminify_wl_plugin_row_links)) { |
| 39 |
return; |
| 40 |
} else { |
| 41 |
add_filter('plugin_row_meta', [$this, 'jltwp_adminify_plugin_row_meta'], 10, 2); |
| 42 |
add_filter('network_admin_plugin_row_meta', [$this, 'jltwp_adminify_plugin_row_meta'], 10, 2); |
| 43 |
} |
| 44 |
} |
| 45 |
} else { |
| 46 |
add_filter('plugin_row_meta', [$this, 'jltwp_adminify_plugin_row_meta'], 10, 2); |
| 47 |
add_filter('network_admin_plugin_row_meta', [$this, 'jltwp_adminify_plugin_row_meta'], 10, 2); |
| 48 |
} |
| 49 |
} |
| 50 |
/** |
| 51 |
* Add Body Class |
| 52 |
*/ |
| 53 |
public function jltwp_adminify_body_class($classes) |
| 54 |
{ |
| 55 |
$classes .= ' wp-adminify '; |
| 56 |
|
| 57 |
if (is_rtl()) { |
| 58 |
$classes .= ' adminify-rtl '; |
| 59 |
} |
| 60 |
return $classes; |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
/** |
| 65 |
* Plugin action links |
| 66 |
* |
| 67 |
* @param array $links |
| 68 |
* |
| 69 |
* @return array |
| 70 |
*/ |
| 71 |
public function plugin_action_links($links) |
| 72 |
{ |
| 73 |
$links[] = sprintf( |
| 74 |
'<a class="adminify-plugin-settings" href="%1$s">%2$s</a>', |
| 75 |
admin_url('admin.php?page=wp-adminify-settings'), |
| 76 |
__('Settings', WP_ADMINIFY_TD) |
| 77 |
); |
| 78 |
|
| 79 |
// Check If Pro/Free |
| 80 |
if (!jltwp_adminify()->can_use_premium_code__premium_only()) { |
| 81 |
$links[] = sprintf( |
| 82 |
'<a href="%1$s" class="adminify-upgrade-pro" target="_blank" style="color: orangered;font-weight: bold;">%2$s</a>', |
| 83 |
'https://wpadminify.com/pricing', |
| 84 |
__('Go Pro', WP_ADMINIFY_TD) |
| 85 |
); |
| 86 |
} |
| 87 |
|
| 88 |
return $links; |
| 89 |
} |
| 90 |
|
| 91 |
public function jltwp_adminify_plugin_row_meta($plugin_meta, $plugin_file) |
| 92 |
{ |
| 93 |
if (WP_ADMINIFY_BASE === $plugin_file) { |
| 94 |
$row_meta = [ |
| 95 |
'docs' => sprintf( |
| 96 |
'<a href="%1$s" target="_blank">%2$s</a>', |
| 97 |
esc_url_raw('https://wpadminify.com/kb'), |
| 98 |
__('Docs', WP_ADMINIFY_TD) |
| 99 |
), |
| 100 |
'changelogs' => sprintf( |
| 101 |
'<a href="%1$s" target="_blank">%2$s</a>', |
| 102 |
esc_url_raw('https://wpadminify.com/changelogs/'), |
| 103 |
__('Changelogs', WP_ADMINIFY_TD) |
| 104 |
), |
| 105 |
'tutorials' => '<a href="https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8" aria-label="' . esc_attr(__('View WP Adminify Video Tutorials', WP_ADMINIFY_TD)) . '" target="_blank">' . __('Video Tutorials', WP_ADMINIFY_TD) . '</a>', |
| 106 |
]; |
| 107 |
|
| 108 |
$plugin_meta = array_merge($plugin_meta, $row_meta); |
| 109 |
} |
| 110 |
|
| 111 |
return $plugin_meta; |
| 112 |
} |
| 113 |
|
| 114 |
public function jltwp_adminify_plugins_loaded() |
| 115 |
{ |
| 116 |
self::jltwp_adminify_activation_hook(); |
| 117 |
} |
| 118 |
|
| 119 |
public function jltwp_adminify_include_files() |
| 120 |
{ |
| 121 |
new Assets(); |
| 122 |
new Admin(); |
| 123 |
|
| 124 |
if (jltwp_adminify()->can_use_premium_code__premium_only()) { |
| 125 |
if (!class_exists('Adminify_Pro')) { |
| 126 |
new \WPAdminify\Pro\Classes\Adminify_Pro(); |
| 127 |
} |
| 128 |
} |
| 129 |
} |
| 130 |
public function jltwp_adminify_init() |
| 131 |
{ |
| 132 |
|
| 133 |
$this->jltwp_adminify_load_textdomain(); |
| 134 |
|
| 135 |
//Redirect Hook |
| 136 |
// add_action('admin_init', [$this, 'jltwp_adminify_redirect_hook']); |
| 137 |
} |
| 138 |
|
| 139 |
// Text Domains |
| 140 |
public function jltwp_adminify_load_textdomain() |
| 141 |
{ |
| 142 |
$domain = 'wp-adminify'; |
| 143 |
$locale = apply_filters('plugin_locale', get_locale(), $domain); |
| 144 |
|
| 145 |
load_textdomain($domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo'); |
| 146 |
load_plugin_textdomain($domain, false, dirname(WP_ADMINIFY_BASE) . '/languages/'); |
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
/* |
| 151 |
* Activation Plugin redirect hook |
| 152 |
*/ |
| 153 |
public function jltwp_adminify_redirect_hook() |
| 154 |
{ |
| 155 |
wp_redirect('admin.php?page=wp-adminify-settings'); |
| 156 |
exit; |
| 157 |
} |
| 158 |
|
| 159 |
|
| 160 |
// Activation Hook |
| 161 |
public static function jltwp_adminify_activation_hook() |
| 162 |
{ |
| 163 |
if (get_option('jltwp_adminify_activation_time') === false) |
| 164 |
update_option('jltwp_adminify_activation_time', strtotime("now")); |
| 165 |
|
| 166 |
update_option('wp_adminify_version', self::VERSION); |
| 167 |
} |
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
// Deactivation Hook |
| 172 |
public static function jltwp_adminify_deactivation_hook() |
| 173 |
{ |
| 174 |
delete_option('jltwp_adminify_activation_time'); |
| 175 |
delete_option('jltwp_adminify_customizer_flush_url'); |
| 176 |
} |
| 177 |
|
| 178 |
public function jltwp_new_freemius_pricing_js($default_pricing_js_path) |
| 179 |
{ |
| 180 |
return WP_ADMINIFY_PATH . '/lib/freemius-pricing/freemius-pricing.js'; |
| 181 |
} |
| 182 |
|
| 183 |
|
| 184 |
/** |
| 185 |
* Returns the singleton instance of the class. |
| 186 |
*/ |
| 187 |
|
| 188 |
public static function get_instance() |
| 189 |
{ |
| 190 |
if (!isset(self::$instance) && !(self::$instance instanceof WP_Adminify)) { |
| 191 |
self::$instance = new WP_Adminify(); |
| 192 |
self::$instance->jltwp_adminify_init(); |
| 193 |
} |
| 194 |
|
| 195 |
return self::$instance; |
| 196 |
} |
| 197 |
} |
| 198 |
|
| 199 |
WP_Adminify::get_instance(); |
| 200 |
} |
| 201 |
|