From 96efa14919c4a4c246708389c20ee604c3a84735 Mon Sep 17 00:00:00 2001
From: Grzegorz Rola <grola@seostudio.pl>
Date: Sun, 23 Jan 2022 13:32:45 +0100
Subject: [PATCH] feature(petition): added text petition

---
 assets/css/style.css             | 43 +++++++++++++++++++++++++++++
 src/TextPetitionDisplayer.php    | 15 +++++++++++
 src/views/html-text-petition.php | 46 +++-----------------------------
 3 files changed, 61 insertions(+), 43 deletions(-)
 create mode 100644 assets/css/style.css

diff --git a/assets/css/style.css b/assets/css/style.css
new file mode 100644
index 0000000..9002a6a
--- /dev/null
+++ b/assets/css/style.css
@@ -0,0 +1,43 @@
+.wpdesk-rating-petition {
+    font-size: 15px;
+    width: 100%;
+}
+
+.wpdesk-rating-petition a {
+    text-decoration: none;
+    color: inherit;
+    font-weight: 600;
+}
+
+.wpdesk-rating-petition span.plugin-title {
+    font-weight: 600;
+}
+
+.wpdesk-rating-petition span.heart:before {
+    speak: none;
+    -webkit-font-smoothing: antialiased;
+    -moz-osx-font-smoothing: grayscale;
+    color: #dc3232;
+    font-size: 16px;
+    font-family: "dashicons";
+    content: "\f487";
+    font-style: normal;
+    font-variant: normal;
+    font-weight: 400;
+    text-transform: none;
+}
+
+.wpdesk-rating-petition span.star:before {
+    speak: none;
+    -webkit-font-smoothing: antialiased;
+    -moz-osx-font-smoothing: grayscale;
+    color: #ffb900;
+    font-size: 16px;
+    font-family: "dashicons";
+    content: "\f155";
+    font-style: normal;
+    font-variant: normal;
+    font-weight: 400;
+    text-transform: none;
+    text-decoration: none;
+}
diff --git a/src/TextPetitionDisplayer.php b/src/TextPetitionDisplayer.php
index 3fd0f1f..ed179b4 100644
--- a/src/TextPetitionDisplayer.php
+++ b/src/TextPetitionDisplayer.php
@@ -10,6 +10,8 @@ use WPDesk\RepositoryRating\DisplayStrategy\DisplayDecision;
  */
 class TextPetitionDisplayer implements Hookable {
 
+	const SCRIPTS_VERSION = '2';
+
 	/**
 	 * @var string
 	 */
@@ -38,8 +40,21 @@ class TextPetitionDisplayer implements Hookable {
 
 	public function hooks() {
 		add_action( $this->display_on_action, [ $this, 'display_petition_if_should' ] );
+		add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_css_if_should' ] );
 	}
 
+	/**
+	 * @internal
+	 */
+	public function enqueue_css_if_should() {
+		if ( $this->display_decision->should_display() ) {
+			wp_enqueue_style( 'wpdesk-rating-petition', plugin_dir_url( __DIR__ . '/../assets/css' ) . 'style.css', array(), self::SCRIPTS_VERSION );
+		}
+	}
+
+	/**
+	 * @internal
+	 */
 	public function display_petition_if_should() {
 		if ( $this->display_decision->should_display() ) {
 			echo wp_kses_post( $this->petition_text_generator->get_petition_text() );
diff --git a/src/views/html-text-petition.php b/src/views/html-text-petition.php
index d4b54f7..1513aca 100644
--- a/src/views/html-text-petition.php
+++ b/src/views/html-text-petition.php
@@ -5,53 +5,13 @@
  * @var string $plugin_title
  * @var string $rating_url
  */
-?><style>
-    .wpdesk-rating-petition {
-        font-size: 15px;
-        text-align: <?php echo esc_attr( $text_align ); ?>;
-        width: 100%;
-    }
-
-    .wpdesk-rating-petition a {
-        text-decoration: none;
-        color: inherit;
-    }
-
-    .wpdesk-rating-petition span.heart:before {
-        speak: none;
-        -webkit-font-smoothing: antialiased;
-        -moz-osx-font-smoothing: grayscale;
-        color: #dc3232;
-        font-size: 16px;
-        font-family: "dashicons";
-        content: "\f487";
-        font-style: normal;
-        font-variant: normal;
-        font-weight: 400;
-        text-transform: none;
-    }
-    .wpdesk-rating-petition span.star:before {
-        speak: none;
-        -webkit-font-smoothing: antialiased;
-        -moz-osx-font-smoothing: grayscale;
-        color: #ffb900;
-        font-size: 16px;
-        font-family: "dashicons";
-        content: "\f155";
-        font-style: normal;
-        font-variant: normal;
-        font-weight: 400;
-        text-transform: none;
-        text-decoration: none;
-    }
-</style>
-<div class="wpdesk-rating-petition">
+?><div class="wpdesk-rating-petition" style="text-align: <?php echo esc_attr( $text_align ); ?>;">
 	<?php echo wp_kses_post(
         sprintf(
-            __( 'Created with %1$s by %2$s - If you like %3$s %4$srate us %5$s%6$s', 'wp-wpdesk-rating-petition' ),
+            __( 'Created with %1$s by %2$s - If you like %3$s %4$srate us %5$s in plugins repository%6$s', 'wp-wpdesk-rating-petition' ),
             '<span class="heart"></span>',
             $plugin_author,
-            $plugin_title,
+            '<span class="plugin-title">' . $plugin_title . '</span>',
             '<a href="' . $rating_url . '" target="_blank">',
             '<span class="star"></span><span class="star"></span><span class="star"></span><span class="star"></span><span class="star"></span>',
             '</a>'
-- 
GitLab