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 = '
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 .= '