_html__( 'TinyPNG - JPEG, PNG & WebP image compression', 'tiny-compress-images' ); add_action( 'admin_notices', function() use ( $css, $name, $plugin_name, $message, $add ) { echo '

' . $plugin_name . ': ' . $message . $add . '

'; } ); } public function api_key_missing_notice() { $notice_class = 'error'; $notice = esc_html__( 'Please register or provide an API key to start compressing images.', 'tiny-compress-images' ); $link = sprintf( '%s', $notice ); $this->show( 'setting', $link, $notice_class, false ); } public function get_api_key_pending_notice() { $notice_class = 'notice-warning'; $notice = esc_html__( 'Please activate your account to start compressing images.', 'tiny-compress-images' ); $link = sprintf( '%s', $notice ); $this->show( 'setting', $link, $notice_class, false ); } public function add_limit_reached_notice( $email ) { $encoded_email = str_replace( '%20', '%2B', rawurlencode( $email ) ); $url = 'https://tinypng.com/dashboard/api?type=upgrade&mail=' . $encoded_email; $link = '' . esc_html__( 'TinyPNG API account', 'tiny-compress-images' ) . ''; $this->add('limit-reached', esc_html__( 'You have reached your free limit this month.', 'tiny-compress-images' ) . ' ' . sprintf( /* translators: %s: link saying TinyPNG API account */ esc_html__( 'Upgrade your %s if you like to compress more images.', 'tiny-compress-images' ), $link ) ); } public function outdated_platform_notice() { if ( ! Tiny_PHP::client_supported() ) { if ( ! Tiny_PHP::has_fully_supported_php() ) { $details = 'PHP ' . PHP_VERSION; if ( Tiny_PHP::curl_available() ) { $curlinfo = curl_version(); $details .= ' ' . sprintf( /* translators: %s: curl version */ esc_html__( 'with curl %s', 'tiny-compress-images' ), $curlinfo['version'] ); } else { $details .= ' ' . esc_html__( 'without curl', 'tiny-compress-images' ); } if ( Tiny_PHP::curl_exec_disabled() ) { $details .= ' ' . esc_html__( 'and curl_exec disabled', 'tiny-compress-images' ); } $message = sprintf( /* translators: %s: details of outdated platform */ esc_html__( 'You are using an outdated platform (%s).', 'tiny-compress-images' ), $details ); } elseif ( ! Tiny_PHP::curl_available() ) { $message = esc_html__( 'We noticed that cURL is not available. For the best experience we recommend to make sure cURL is available.', // WPCS: Needed for proper translation. 'tiny-compress-images' ); } elseif ( Tiny_PHP::curl_exec_disabled() ) { $message = esc_html__( 'We noticed that curl_exec is disabled in your PHP configuration. Please update this setting for the best experience.', // WPCS: Needed for proper translation. 'tiny-compress-images' ); } $this->show( 'deprecated', $message, 'notice-warning', false ); } // End if(). } public function incompatible_plugins_notice() { $incompatible_plugins = array_filter( self::$incompatible_plugins, 'is_plugin_active' ); if ( count( $incompatible_plugins ) > 0 ) { $this->show_incompatible_plugins( $incompatible_plugins ); } } private function show_incompatible_plugins( $incompatible_plugins ) { $notice = '
'; $notice .= '

'; $notice .= esc_html__( 'TinyPNG - JPEG, PNG & WebP image compression', 'tiny-compress-images' ); $notice .= '

'; $notice .= '

'; $notice .= esc_html__( 'You have activated multiple image optimization plugins. This may lead to unexpected results. The following plugins were detected:', // WPCS: Needed for proper translation. 'tiny-compress-images' ); $notice .= '

'; $notice .= ''; $notice .= ''; foreach ( $incompatible_plugins as $name => $file ) { $notice .= ''; } $notice .= '
'; $notice .= esc_html__( 'TinyPNG - JPEG, PNG & WebP image compression', 'tiny-compress-images' ); $notice .= '
'; $notice .= $name; $notice .= ''; $nonce = wp_create_nonce( 'deactivate-plugin_' . $file ); $query_string = 'action=deactivate&plugin=' . $file . '&_wpnonce=' . $nonce; $url = admin_url( 'plugins.php?' . $query_string ); $notice .= ''; $notice .= esc_html__( 'Deactivate' ); $notice .= '
'; $notice .= '
'; add_action( 'admin_notices', function() use ( $notice ) { echo $notice; } ); } }