Skip to content
Snippets Groups Projects
Commit 6b5cd597 authored by Grzegorz Rola's avatar Grzegorz Rola
Browse files

feature(petition): added text petition

parent 244f79a3
No related branches found
No related tags found
1 merge request!1feature(petition): added text petition
...@@ -12,6 +12,6 @@ interface DisplayDecision { ...@@ -12,6 +12,6 @@ interface DisplayDecision {
* *
* @return bool * @return bool
*/ */
public function should_display(); public function should_display(): bool;
} }
\ No newline at end of file
<?php
namespace WPDesk\RepositoryRating\DisplayStrategy;
class ShippingMethodDisplayDecision implements DisplayDecision {
/**
* @var \WC_Shipping_Zones
*/
private $shipping_zones;
/**
* @var string
*/
private $shipping_method_id;
/**
* @param \WC_Shipping_Zones $shipping_zones
* @param string $shipping_method_id
*/
public function __construct( \WC_Shipping_Zones $shipping_zones, string $shipping_method_id ) {
$this->shipping_zones = $shipping_zones;
$this->shipping_method_id = $shipping_method_id;
}
/**
* @inheritDoc
*/
public function should_display(): bool {
if ( $this->is_in_shipping_settings() ) {
if ( $this->is_get_parameter_with_value( 'section', $this->shipping_method_id ) ) {
return true;
}
if ( isset( $_GET['instance_id'] ) ) {
$shipping_method = $this->shipping_zones::get_shipping_method( sanitize_key( $_GET['instance_id'] ) );
if ( $shipping_method instanceof \WC_Shipping_Method ) {
return $shipping_method->id === $this->shipping_method_id;
}
}
}
return false;
}
private function is_in_shipping_settings(): bool {
if ( $this->is_get_parameter_with_value( 'page', 'wc-settings' ) && $this->is_get_parameter_with_value( 'tab', 'shipping' ) ) {
return true;
}
return false;
}
private function is_get_parameter_with_value( string $parameter, string $value ): bool {
return isset( $_GET[ $parameter ] ) && $_GET[ $parameter ] === $value;
}
}
\ No newline at end of file
...@@ -20,6 +20,27 @@ class TextPetition implements Hookable { ...@@ -20,6 +20,27 @@ class TextPetition implements Hookable {
*/ */
private $display_decision; private $display_decision;
/**
* @var string
*/
private $text_align;
/**
* @var string
*/
private $plugin_author;
/**
* @var string
*/
private $plugin_title;
/**
* @var string
*/
private $rating_url;
/** /**
* @param string $display_on_action * @param string $display_on_action
* @param DisplayDecision $display_decision * @param DisplayDecision $display_decision
...@@ -29,14 +50,13 @@ class TextPetition implements Hookable { ...@@ -29,14 +50,13 @@ class TextPetition implements Hookable {
$this->display_decision = $display_decision; $this->display_decision = $display_decision;
} }
public function hooks() { public function hooks() {
add_action( $this->display_on_action, [ $this, 'display_petition_if_should' ] ); add_action( $this->display_on_action, [ $this, 'display_petition_if_should' ] );
} }
public function display_petition_if_should() { public function display_petition_if_should() {
if ( $this->display_decision->should_display() ) { if ( $this->display_decision->should_display() ) {
include __DIR__ . '/views/html-text-petition.php';
} }
} }
......
<?php <?php
/**
* @var string $text_align
* @var string $plugin_author
* @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%;
}
?><div class="aligncenter"> .wpdesk-rating-petition a {
Created with text-decoration: none;
<span class="fcfSettings__footerIcon fcfSettings__footerIcon--heart"></span> color: inherit;
by Rangers from <a href="https://wpde.sk/fcf-settings-footer-wpdesk-link-pl" target="_blank">WP Desk</a> }
- if you like FCF
<a href="https://wpde.sk/fcf-settings-footer-review-link-pl" target="_blank">rate us .wpdesk-rating-petition span.heart:before {
<span class="fcfSettings__footerIcon fcfSettings__footerIcon--star"></span> speak: none;
<span class="fcfSettings__footerIcon fcfSettings__footerIcon--star"></span> -webkit-font-smoothing: antialiased;
<span class="fcfSettings__footerIcon fcfSettings__footerIcon--star"></span> -moz-osx-font-smoothing: grayscale;
<span class="fcfSettings__footerIcon fcfSettings__footerIcon--star"></span> color: #dc3232;
<span class="fcfSettings__footerIcon fcfSettings__footerIcon--star"></span> font-size: 16px;
</a> 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">
<?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' ),
'<span class="heart"></span>',
$plugin_author,
$plugin_title,
'<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>'
)
); ?>
</div> </div>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment