| @@ -1,79 +1,99 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -namespace PXLBSAdminify; | |
| 3 | +namespace WPAdminify; | |
| 4 | 4 | |
| 5 | -use PXLBSAdminify\Libs\Featured; | |
| 6 | -use PXLBSAdminify\Inc\Admin\Admin; | |
| 7 | -use PXLBSAdminify\Inc\Classes\Assets; | |
| 8 | -use PXLBSAdminify\Inc\Classes\Upgrade; | |
| 9 | -use PXLBSAdminify\Inc\Classes\Feedback; | |
| 10 | -use PXLBSAdminify\Inc\Admin\AdminSettings; | |
| 11 | -use PXLBSAdminify\Inc\Classes\Pro_Upgrade; | |
| 12 | -use PXLBSAdminify\Inc\Classes\Addons_Plugins; | |
| 13 | -use PXLBSAdminify\Inc\Classes\GoogleFontsLocal; | |
| 14 | -use PXLBSAdminify\Inc\Classes\Notifications\Notifications; | |
| 5 | +use WPAdminify\Inc\Classes\Assets ; | |
| 6 | +use WPAdminify\Inc\Classes\Upgrade ; | |
| 7 | +use WPAdminify\Inc\Admin\Admin ; | |
| 8 | +use WPAdminify\Inc\Admin\AdminSettings ; | |
| 9 | +use WPAdminify\Libs\Featured ; | |
| 10 | +use WPAdminify\Inc\Classes\Recommended_Plugins ; | |
| 11 | +use WPAdminify\Inc\Classes\Pro_Upgrade ; | |
| 12 | +use WPAdminify\Inc\Classes\Feedback ; | |
| 13 | +use WPAdminify\Inc\Classes\Notifications\Notifications ; | |
| 15 | 14 | // No, Direct access Sir !!! |
| 16 | 15 | if ( !defined( 'ABSPATH' ) ) { |
| 17 | 16 | exit; |
| 18 | 17 | } |
| 18 | + | |
| 19 | 19 | if ( !class_exists( 'WP_Adminify' ) ) { |
| 20 | - class WP_Adminify { | |
| 21 | - const VERSION = PXLBSADMINIFY_VER; | |
| 22 | - | |
| 23 | - private static $instance = null; | |
| 24 | - | |
| 25 | - public function __construct() { | |
| 26 | - add_action( 'plugins_loaded', array($this, 'maybe_run_upgrades'), -100 ); | |
| 20 | + class WP_Adminify | |
| 21 | + { | |
| 22 | + const VERSION = WP_ADMINIFY_VER ; | |
| 23 | + private static $instance = null ; | |
| 24 | + public function __construct() | |
| 25 | + { | |
| 26 | + add_action( 'plugins_loaded', array( $this, 'maybe_run_upgrades' ), -100 ); | |
| 27 | 27 | // This should run earlier |
| 28 | - add_action( 'plugins_loaded', array($this, 'maybe_loaded_addons'), -200 ); | |
| 29 | - // add_action('plugins_loaded', array($this, 'pxlbsadminify_plugins_loaded'), 999); | |
| 30 | - add_filter( 'plugin_action_links_' . PXLBSADMINIFY_BASE, array($this, 'plugin_action_links') ); | |
| 31 | - add_filter( 'network_admin_plugin_action_links_' . PXLBSADMINIFY_BASE, array($this, 'plugin_action_links') ); | |
| 32 | - add_filter( 'admin_body_class', array($this, 'pxlbsadminify_body_class'), 99 ); | |
| 33 | - // Load textdomain and include files on init for WP 6.7+ compatibility | |
| 34 | - // Textdomain must be loaded before files that use translations | |
| 35 | - // Priority order: 0=textdomain, 1=include files (registers options), 5=framework setup | |
| 36 | - add_action( 'init', array($this, 'pxlbsadminify_load_textdomain'), 0 ); | |
| 37 | - add_action( 'init', array($this, 'pxlbsadminify_include_files'), 1 ); | |
| 38 | - add_action( 'init', array($this, 'pxlbsadminify_is_plugin_row_meta'), 1 ); | |
| 39 | - $is_finished = get_option( 'pxlbsadminify_setup_wizard_ran' ); | |
| 40 | - if ( $is_finished !== '1' ) { | |
| 41 | - if ( apply_filters( 'pxlbsadminify_show_setup_wizard', true ) ) { | |
| 42 | - new \PXLBSAdminify\Inc\Classes\Wizard\Setup_Wizard(); | |
| 43 | - set_transient( 'pxlbsadminify_activation_redirect', 1, 30 ); | |
| 44 | - } | |
| 28 | + add_action( 'plugins_loaded', array( $this, 'jltwp_adminify_plugins_loaded' ), 999 ); | |
| 29 | + add_filter( 'plugin_action_links_' . WP_ADMINIFY_BASE, array( $this, 'plugin_action_links' ) ); | |
| 30 | + add_filter( 'network_admin_plugin_action_links_' . WP_ADMINIFY_BASE, array( $this, 'plugin_action_links' ) ); | |
| 31 | + add_filter( 'admin_body_class', array( $this, 'jltwp_adminify_body_class' ) ); | |
| 32 | + $this->jltwp_is_plugin_row_meta(); | |
| 33 | + $this->jltwp_adminify_include_files(); | |
| 34 | + jltwp_adminify()->add_filter( 'freemius_pricing_js_path', array( $this, 'jltwp_new_freemius_pricing_js' ) ); | |
| 35 | + jltwp_adminify()->add_filter( 'plugin_icon', array( $this, 'jltwp_adminify_logo_icon' ) ); | |
| 36 | + | |
| 37 | + if ( apply_filters( 'jltwp_adminify_show_setup_wizard', true ) ) { | |
| 38 | + new \WPAdminify\Inc\Classes\Setup_Wizard(); | |
| 39 | + set_transient( '_adminify_activation_redirect', 1, 30 ); | |
| 45 | 40 | } |
| 46 | - jltwp_adminify()->add_filter( 'pricing_url', [$this, 'pxlbsadminify_pricing_url'] ); | |
| 41 | + | |
| 42 | + jltwp_adminify()->add_filter( 'support_forum_url', array( $this, 'jltwp_adminify_support_forum_url' ) ); | |
| 43 | + // Disable deactivation feedback form | |
| 44 | + jltwp_adminify()->add_filter( 'show_deactivation_feedback_form', '__return_false' ); | |
| 47 | 45 | } |
| 48 | - | |
| 49 | - function pxlbsadminify_pricing_url( $pricing_url ) { | |
| 50 | - $pricing_url = 'https://wpadminify.com/pricing'; | |
| 51 | - return $pricing_url; | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * Adminify Logo | |
| 49 | + * | |
| 50 | + * @param [type] $logo | |
| 51 | + * | |
| 52 | + * @return void | |
| 53 | + */ | |
| 54 | + public function jltwp_adminify_logo_icon( $logo ) | |
| 55 | + { | |
| 56 | + $logo = WP_ADMINIFY_PATH . '/assets/images/adminify.svg'; | |
| 57 | + return $logo; | |
| 52 | 58 | } |
| 53 | - | |
| 54 | - public function pxlbsadminify_is_plugin_row_meta() { | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * Support URL Changed | |
| 62 | + * | |
| 63 | + * @param [type] $wp_org_support_forum_url | |
| 64 | + * | |
| 65 | + * @return void | |
| 66 | + */ | |
| 67 | + public function jltwp_adminify_support_forum_url() | |
| 68 | + { | |
| 69 | + return 'https://wpadminify.com/contact'; | |
| 70 | + } | |
| 71 | + | |
| 72 | + public function jltwp_is_plugin_row_meta() | |
| 73 | + { | |
| 55 | 74 | add_filter( |
| 56 | 75 | 'plugin_row_meta', |
| 57 | - array($this, 'pxlbsadminify_plugin_row_meta'), | |
| 76 | + array( $this, 'jltwp_adminify_plugin_row_meta' ), | |
| 58 | 77 | 10, |
| 59 | 78 | 2 |
| 60 | 79 | ); |
| 61 | 80 | add_filter( |
| 62 | 81 | 'network_admin_plugin_row_meta', |
| 63 | - array($this, 'pxlbsadminify_plugin_row_meta'), | |
| 82 | + array( $this, 'jltwp_adminify_plugin_row_meta' ), | |
| 64 | 83 | 10, |
| 65 | 84 | 2 |
| 66 | 85 | ); |
| 67 | 86 | } |
| 68 | - | |
| 87 | + | |
| 69 | 88 | /** |
| 70 | 89 | * Add Body Class |
| 71 | 90 | */ |
| 72 | - public function pxlbsadminify_body_class( $classes ) { | |
| 91 | + public function jltwp_adminify_body_class( $classes ) | |
| 92 | + { | |
| 73 | 93 | $classes .= ' wp-adminify '; |
| 74 | 94 | $adminify_ui = AdminSettings::get_instance()->get( 'admin_ui' ); |
| 75 | - if ( !empty( $adminify_ui ) ) { | |
| 95 | + if ( !empty($adminify_ui) ) { | |
| 76 | 96 | $classes .= ' adminify-ui'; |
| 77 | 97 | } |
| 78 | 98 | if ( is_rtl() ) { |
| 79 | 99 | $classes .= ' adminify-rtl '; |
| @@ -79,9 +99,9 @@ | ||
| 79 | 99 | $classes .= ' adminify-rtl '; |
| 80 | 100 | } |
| 81 | 101 | return $classes; |
| 82 | 102 | } |
| 83 | - | |
| 103 | + | |
| 84 | 104 | /** |
| 85 | 105 | * Plugin action links |
| 86 | 106 | * |
| 87 | 107 | * @param array $links |
| @@ -87,40 +107,37 @@ | ||
| 87 | 107 | * @param array $links |
| 88 | 108 | * |
| 89 | 109 | * @return array |
| 90 | 110 | */ |
| 91 | - public function plugin_action_links( $links ) { | |
| 92 | - $links['settings'] = apply_filters( 'adminify_settings_link', sprintf( '<a class="adminify-plugin-settings" href="%1$s">%2$s</a>', admin_url( 'admin.php?page=wp-adminify-settings' ), __( 'Settings', 'adminify' ) ) ); | |
| 93 | - $links['pricing'] = apply_filters( 'pxlbsadminify_upgrade_now_link', sprintf( '<a href="%1$s" class="adminify-upgrade-pro" target="_blank" style="color: orangered;font-weight: bold;">%2$s</a>', 'https://wpadminify.com/pricing', __( 'Upgrade Now', 'adminify' ) ) ); | |
| 94 | - return apply_filters( 'adminify_plugin_row_links', $links ); | |
| 111 | + public function plugin_action_links( $links ) | |
| 112 | + { | |
| 113 | + $links[] = sprintf( '<a class="adminify-plugin-settings" href="%1$s">%2$s</a>', admin_url( 'admin.php?page=wp-adminify-settings' ), __( 'Settings', 'adminify' ) ); | |
| 114 | + $links[] = sprintf( '<a href="%1$s" class="adminify-upgrade-pro" target="_blank" style="color: orangered;font-weight: bold;">%2$s</a>', 'https://wpadminify.com/pricing', __( 'Go Pro', 'adminify' ) ); | |
| 115 | + return $links; | |
| 95 | 116 | } |
| 96 | - | |
| 97 | - public function pxlbsadminify_plugin_row_meta( $plugin_meta, $plugin_file ) { | |
| 98 | - if ( PXLBSADMINIFY_BASE === $plugin_file ) { | |
| 117 | + | |
| 118 | + public function jltwp_adminify_plugin_row_meta( $plugin_meta, $plugin_file ) | |
| 119 | + { | |
| 120 | + | |
| 121 | + if ( WP_ADMINIFY_BASE === $plugin_file ) { | |
| 99 | 122 | $row_meta = array( |
| 100 | - 'docs' => sprintf( '<a href="%1$s" target="_blank">%2$s</a>', esc_url_raw( 'https://wpadminify.com/docs/adminify/getting-started' ), __( 'Docs', 'adminify' ) ), | |
| 123 | + 'docs' => sprintf( '<a href="%1$s" target="_blank">%2$s</a>', esc_url_raw( 'https://wpadminify.com/kb' ), __( 'Docs', 'adminify' ) ), | |
| 101 | 124 | 'changelogs' => sprintf( '<a href="%1$s" target="_blank">%2$s</a>', esc_url_raw( 'https://wpadminify.com/changelogs/' ), __( 'Changelogs', 'adminify' ) ), |
| 102 | - 'tutorials' => '<a href="https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8" aria-label="' . esc_attr( __( 'View Adminify Video Tutorials', 'adminify' ) ) . '" target="_blank">' . __( 'Video Tutorials', 'adminify' ) . '</a>', | |
| 125 | + 'tutorials' => '<a href="https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8" aria-label="' . esc_attr( __( 'View WP Adminify Video Tutorials', 'adminify' ) ) . '" target="_blank">' . __( 'Video Tutorials', 'adminify' ) . '</a>', | |
| 103 | 126 | ); |
| 104 | 127 | $plugin_meta = array_merge( $plugin_meta, $row_meta ); |
| 105 | 128 | } |
| 129 | + | |
| 106 | 130 | return $plugin_meta; |
| 107 | 131 | } |
| 108 | - | |
| 109 | - public function pxlbsadminify_plugins_loaded() { | |
| 110 | - self::pxlbsadminify_activation_hook(); | |
| 132 | + | |
| 133 | + public function jltwp_adminify_plugins_loaded() | |
| 134 | + { | |
| 135 | + self::jltwp_adminify_activation_hook(); | |
| 111 | 136 | } |
| 112 | - | |
| 113 | - /** | |
| 114 | - * Addons Loaded Method | |
| 115 | - * | |
| 116 | - * @return void | |
| 117 | - */ | |
| 118 | - public function maybe_loaded_addons() { | |
| 119 | - do_action( 'pxlbsadminify_plugin_loaded', WP_Adminify::get_instance() ); | |
| 120 | - } | |
| 121 | - | |
| 122 | - public function maybe_run_upgrades() { | |
| 137 | + | |
| 138 | + public function maybe_run_upgrades() | |
| 139 | + { | |
| 123 | 140 | if ( !is_admin() && !current_user_can( 'manage_options' ) ) { |
| 124 | 141 | return; |
| 125 | 142 | } |
| 126 | 143 | $upgrade = new Upgrade(); |
| @@ -127,10 +144,11 @@ | ||
| 127 | 144 | if ( $upgrade->if_updates_available() ) { |
| 128 | 145 | $upgrade->run_updates(); |
| 129 | 146 | } |
| 130 | 147 | } |
| 131 | - | |
| 132 | - public function pxlbsadminify_include_files() { | |
| 148 | + | |
| 149 | + public function jltwp_adminify_include_files() | |
| 150 | + { | |
| 133 | 151 | new Assets(); |
| 134 | 152 | new Admin(); |
| 135 | 153 | new Featured(); |
| 136 | 154 | new Feedback(); |
| @@ -135,83 +153,73 @@ | ||
| 135 | 153 | new Featured(); |
| 136 | 154 | new Feedback(); |
| 137 | 155 | new Notifications(); |
| 138 | 156 | new Pro_Upgrade(); |
| 139 | - new Addons_Plugins(); | |
| 140 | - // Initialize Google Fonts Local early to catch option updates | |
| 141 | - GoogleFontsLocal::get_instance(); | |
| 157 | + new Recommended_Plugins(); | |
| 142 | 158 | } |
| 143 | - | |
| 144 | - public function pxlbsadminify_init() { | |
| 145 | - // Backup for OLD Database | |
| 146 | - $current_version = get_option( 'pxlbsadminify_version' ); | |
| 147 | - $is_backup = $old_data = get_option( 'pxlbsadminify_settings_backup' ); | |
| 148 | - if ( version_compare( $current_version, PXLBSADMINIFY_VER, '<' ) && empty( $is_backup ) ) { | |
| 149 | - $old_data = get_option( 'pxlbsadminify_settings' ); | |
| 150 | - update_option( 'pxlbsadminify_settings_backup', $old_data ); | |
| 151 | - } | |
| 159 | + | |
| 160 | + public function jltwp_adminify_init() | |
| 161 | + { | |
| 162 | + $this->jltwp_adminify_load_textdomain(); | |
| 163 | + // Redirect Hook | |
| 164 | + // add_action('admin_init', [$this, 'jltwp_adminify_redirect_hook']); | |
| 152 | 165 | } |
| 153 | - | |
| 154 | - /** | |
| 155 | - * Loads the text domain for localization. | |
| 156 | - * | |
| 157 | - * This function sets up the text domain for the WP Adminify plugin, | |
| 158 | - * allowing it to load translation files for the specified locale. | |
| 159 | - * It first attempts to load a custom translation file from the WordPress | |
| 160 | - * languages directory and then loads the default translation file from | |
| 161 | - * the plugin's languages directory. | |
| 162 | - * | |
| 163 | - * @return void | |
| 166 | + | |
| 167 | + // Text Domains | |
| 168 | + public function jltwp_adminify_load_textdomain() | |
| 169 | + { | |
| 170 | + $domain = 'adminify'; | |
| 171 | + $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); | |
| 172 | + load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' ); | |
| 173 | + load_plugin_textdomain( $domain, false, dirname( WP_ADMINIFY_BASE ) . '/languages/' ); | |
| 174 | + } | |
| 175 | + | |
| 176 | + /* | |
| 177 | + * Activation Plugin redirect hook | |
| 164 | 178 | */ |
| 165 | - public function pxlbsadminify_load_textdomain() { | |
| 166 | - $locale = apply_filters( 'plugin_locale', get_locale(), 'adminify' ); | |
| 167 | - load_textdomain( 'adminify', WP_LANG_DIR . '/adminify/adminify-' . $locale . '.mo' ); | |
| 168 | - // phpcs:ignore PluginCheck.CodeAnalysis.DiscouragedFunctions.load_plugin_textdomainFound -- retained for non-hosted / older-WP installs. | |
| 169 | - load_plugin_textdomain( 'adminify', false, dirname( PXLBSADMINIFY_BASE ) . '/languages/' ); | |
| 179 | + public function jltwp_adminify_redirect_hook() | |
| 180 | + { | |
| 181 | + wp_redirect( 'admin.php?page=wp-adminify-settings' ); | |
| 182 | + exit; | |
| 170 | 183 | } |
| 171 | - | |
| 184 | + | |
| 172 | 185 | // Activation Hook |
| 173 | - public static function pxlbsadminify_activation_hook() { | |
| 174 | - $current_adminify_version = get_option( 'pxlbsadminify_version', null ); | |
| 175 | - if ( get_option( 'pxlbsadminify_activation_time' ) === false ) { | |
| 176 | - update_option( 'pxlbsadminify_activation_time', strtotime( 'now' ) ); | |
| 186 | + public static function jltwp_adminify_activation_hook() | |
| 187 | + { | |
| 188 | + $current_adminify_version = get_option( 'wp_adminify_version', null ); | |
| 189 | + if ( get_option( 'jltwp_adminify_activation_time' ) === false ) { | |
| 190 | + update_option( 'jltwp_adminify_activation_time', strtotime( 'now' ) ); | |
| 177 | 191 | } |
| 178 | - if ( "dismissed" === get_option( 'pxlbsadminify_plugin_update_info_notice', true ) ) { | |
| 179 | - update_option( 'pxlbsadminify_plugin_update_info_notice', '' ); | |
| 180 | - } | |
| 181 | 192 | if ( is_null( $current_adminify_version ) ) { |
| 182 | - update_option( 'pxlbsadminify_version', self::VERSION ); | |
| 193 | + update_option( 'wp_adminify_version', self::VERSION ); | |
| 183 | 194 | } |
| 184 | - //database upgrade logic here | |
| 185 | - $old_data = get_option( 'pxlbsadminify_settings' ); | |
| 186 | - update_option( 'pxlbsadminify_settings_backup', $old_data ); | |
| 187 | - // Create term_order collumn in terms table, to support post type order | |
| 188 | - global $wpdb; | |
| 189 | - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- direct query required for one-time schema inspection on activation; not cached intentionally. | |
| 190 | - $check_term_order_column = $wpdb->query( "SHOW COLUMNS FROM {$wpdb->terms} LIKE 'term_order'" ); | |
| 191 | - if ( $check_term_order_column == 0 ) { | |
| 192 | - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.DirectDatabaseQuery.SchemaChange -- direct query required for one-time schema change on activation; not cached intentionally. | |
| 193 | - $wpdb->query( "ALTER TABLE {$wpdb->terms} ADD term_order INT( 4 ) NULL DEFAULT '0'" ); | |
| 194 | - } | |
| 195 | 195 | } |
| 196 | - | |
| 196 | + | |
| 197 | 197 | // Deactivation Hook |
| 198 | - public static function pxlbsadminify_deactivation_hook() { | |
| 199 | - delete_option( 'pxlbsadminify_activation_time' ); | |
| 200 | - delete_option( 'pxlbsadminify_customizer_flush_url' ); | |
| 198 | + public static function jltwp_adminify_deactivation_hook() | |
| 199 | + { | |
| 200 | + delete_option( 'jltwp_adminify_activation_time' ); | |
| 201 | + delete_option( 'jltwp_adminify_customizer_flush_url' ); | |
| 201 | 202 | } |
| 202 | - | |
| 203 | + | |
| 204 | + public function jltwp_new_freemius_pricing_js( $default_pricing_js_path ) | |
| 205 | + { | |
| 206 | + return WP_ADMINIFY_PATH . '/Libs/freemius-pricing/freemius-pricing.js'; | |
| 207 | + } | |
| 208 | + | |
| 203 | 209 | /** |
| 204 | 210 | * Returns the singleton instance of the class. |
| 205 | 211 | */ |
| 206 | - public static function get_instance() { | |
| 212 | + public static function get_instance() | |
| 213 | + { | |
| 214 | + | |
| 207 | 215 | if ( !isset( self::$instance ) && !self::$instance instanceof WP_Adminify ) { |
| 208 | 216 | self::$instance = new WP_Adminify(); |
| 209 | - self::$instance->pxlbsadminify_init(); | |
| 217 | + self::$instance->jltwp_adminify_init(); | |
| 210 | 218 | } |
| 219 | + | |
| 211 | 220 | return self::$instance; |
| 212 | 221 | } |
| 213 | - | |
| 222 | + | |
| 214 | 223 | } |
| 215 | - | |
| 216 | 224 | WP_Adminify::get_instance(); |
| 217 | -} | |
| 225 | +} | |