prefix = $prefix; $this->mainfile = $mainfile; $this->domain = $domain; $this->isPro = $isPro; // If there is no mainfile, it's either a Pro only Plugin (with no Free version available) or a Theme. if ( is_admin() ) { $license = get_option( $this->prefix . '_license', '' ); if ( !empty( $license ) && !$this->isPro ) { add_action( 'admin_notices', [ $this, 'admin_notices_licensed_free' ] ); } if ( $this->is_user_admin() ) { if ( !$disableReview ) { new MeowCommon_Ratings( $prefix, $mainfile, $domain ); } new MeowCommon_News( $domain ); } } add_filter( 'plugin_row_meta', [ $this, 'custom_plugin_row_meta' ], 10, 2 ); add_filter( 'edd_sl_api_request_verify_ssl', [ $this, 'request_verify_ssl' ], 10, 0 ); } public function is_user_admin() { if ( !function_exists( 'current_user_can' ) || !function_exists( 'wp_get_current_user' ) ) { error_log( 'MeowCommon_Admin is called too early. Please make sure it is called after the plugins_loaded filter.' ); return false; } return current_user_can( 'manage_options' ); } public function custom_plugin_row_meta( $links, $file ) { $path = pathinfo( $file ); $pathName = basename( $path['dirname'] ); $thisPath = pathinfo( $this->mainfile ); $thisPathName = basename( $thisPath['dirname'] ); $isActive = is_plugin_active( $file ); if ( !$isActive ) { return $links; } $isIssue = $this->isPro && !$this->is_registered(); if ( strpos( $pathName, $thisPathName ) !== false ) { $new_links = [ 'settings' => sprintf( __( 'Settings', $this->domain ), $this->prefix ), 'license' => $this->is_registered() ? ( '' . __( 'Pro Version', $this->domain ) . '' ) : ( $isIssue ? ( sprintf( '' . __( 'License Issue', $this->domain ), $this->prefix ) . '' ) : ( sprintf( '' . __( 'Get the Pro Version', $this->domain ), $this->prefix ) . '' ) ), ]; $links = array_merge( $new_links, $links ); } return $links; } public function request_verify_ssl() { return get_option( 'force_sslverify', false ); } public function nice_name_from_file( $file ) { $info = pathinfo( $file ); if ( !empty( $info ) ) { if ( $info['filename'] == 'wplr-sync' ) { return 'WP/LR Sync'; } $info['filename'] = str_replace( '-', ' ', $info['filename'] ); $file = ucwords( $info['filename'] ); } return $file; } public function admin_notices_licensed_free() { if ( isset( $_POST[$this->prefix . '_reset_sub'] ) ) { delete_option( $this->prefix . '_pro_serial' ); delete_option( $this->prefix . '_license' ); return; } $html = '
'; $html .= sprintf( __( '

It looks like you are using the free version of the plugin (%s) but a license for the Pro version was also found. The Pro version might have been replaced by the Free version during an update (might be caused by a temporarily issue). If it is the case, please download it again from the Meow Store. If you wish to continue using the free version and clear this message, click on this button.', $this->domain ), $this->nice_name_from_file( $this->mainfile ) ); $html .= '

'; $html .= '
'; wp_kses_post( $html ); } public function admin_menu_start() { // Hide the admin if user doesn't like Meow much if ( get_option( 'meowapps_hide_meowapps', false ) ) { register_setting( 'general', 'meowapps_hide_meowapps' ); add_settings_field( 'meowapps_hide_ads', 'Meow Apps Menu', [ $this, 'meowapps_hide_dashboard_callback' ], 'general' ); return; } // Create standard menu if it does not already exist global $submenu; if ( !isset( $submenu[ 'meowapps-main-menu' ] ) ) { add_menu_page( 'Meow Apps', 'Meow AppsMeow Apps', 'manage_options', 'meowapps-main-menu', [ $this, 'admin_meow_apps' ], '', 82 ); add_submenu_page( 'meowapps-main-menu', __( 'Dashboard', $this->domain ), __( 'Dashboard', $this->domain ), 'manage_options', 'meowapps-main-menu', [ $this, 'admin_meow_apps' ] ); } // Add CSS to hide the default icon add_action( 'admin_head', function () { echo ''; } ); } public function meowapps_hide_dashboard_callback() { $html = ''; $html .= __( '
Hide Meow Apps menu and all its components, for a cleaner admin. This option will be reset if a new Meow Apps plugin is installed.
Once activated, an option will be added in your General settings to display it again.
', $this->domain ); echo MeowCommon_Helpers::wp_kses( $html ); } public function is_registered() { $is_registered = apply_filters( $this->prefix . '_meowapps_is_registered', false, $this->prefix ); return $is_registered; } public function get_phpinfo() { if ( !$this->is_user_admin() || !function_exists( 'phpinfo' ) ) { return; } ob_start(); // phpcs:disable WordPress.PHP.DevelopmentFunctions phpinfo( INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES ); // phpcs:enable $html = ob_get_contents(); ob_end_clean(); $html = preg_replace( '%^.*(.*).*$%ms', '$1', $html ); return $html; } public function admin_meow_apps() { $html = "
"; $html .= "
"; $html .= $this->get_phpinfo(); $html .= '
'; $html = preg_replace( "/]+\>/i", '', $html ); echo wp_kses_post( $html ); } public function admin_footer_text( $current ) { return sprintf( // translators: %1$s is the version of the interface; %2$s is a file path. __( 'Thanks for using Meow Apps! This is the Meow Admin %1$s
Loaded from %2$s ', $this->domain ), MeowCommon_Admin::$version, __FILE__ ); } } }