diff --git a/CHANGELOG.md b/CHANGELOG.md index d78b275c73934ee73f07eadf0400744d73fbcc1a..d564d5f9a93faa58153d678ddf3393f9a1f18213 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [1.2.0] - 2022-01-24 +### Changes +- Added TextPetition + ## [1.1.0] - 2019-12-02 ### Changes - RatingPetitionNotice can get url to redirect user when wants to rate diff --git a/composer.json b/composer.json index 12d200576a9572b9246434e223fb244611403551..bb88d1d30e97b0ab780050363bbe90bb41f7643d 100644 --- a/composer.json +++ b/composer.json @@ -7,8 +7,9 @@ } ], "require": { - "php": ">=5.6", - "wpdesk/wp-notice": "^3.1" + "php": ">=7.0", + "wpdesk/wp-notice": "^3.1", + "wpdesk/wp-plugin-flow": "^3.1" }, "require-dev": { "phpunit/phpunit": "<7", diff --git a/src/DisplayStrategy/DisplayDecision.php b/src/DisplayStrategy/DisplayDecision.php new file mode 100644 index 0000000000000000000000000000000000000000..c12d45fc0add0f572d7d570d67df4c0e04a15a79 --- /dev/null +++ b/src/DisplayStrategy/DisplayDecision.php @@ -0,0 +1,17 @@ +<?php + +namespace WPDesk\RepositoryRating\DisplayStrategy; + +/** + * ShouldDisplay interface. + */ +interface DisplayDecision { + + /** + * Returns true when element should be displayed. + * + * @return bool + */ + public function should_display(); + +} \ No newline at end of file diff --git a/src/DisplayStrategy/GetParametersDisplayDecision.php b/src/DisplayStrategy/GetParametersDisplayDecision.php new file mode 100644 index 0000000000000000000000000000000000000000..a96f42e6e561e032ea1d0bf7f5f4d1242e6fd335 --- /dev/null +++ b/src/DisplayStrategy/GetParametersDisplayDecision.php @@ -0,0 +1,46 @@ +<?php + +namespace WPDesk\RepositoryRating\DisplayStrategy; + +/** + * DisplayDecision based on GET parameters. + */ +class GetParametersDisplayDecision implements DisplayDecision { + + /** + * Whether to show beacon on the page or not. Array of arrays with condition for _GET. + * Inner arrays mean AND, outer arrays mean OR conditions. + * + * ie. [ [ ... and ... and ... ] or [ ... and ... and ... ] or ... ] + * + * @var array + */ + private $conditions; + + public function __construct( array $conditions ) { + $this->conditions = $conditions; + } + + /** + * Should Beacon be visible? + * + * @return bool + */ + public function should_display(): bool { + foreach ( $this->conditions as $or_conditions ) { + $display = true; + foreach ( $or_conditions as $parameter => $value ) { + if ( ! isset( $_GET[ $parameter ] ) || $_GET[ $parameter ] !== $value ) { + $display = false; + } + } + if ( $display ) { + + return $display; + } + } + + return false; + } + +} \ No newline at end of file diff --git a/src/TextPetition.php b/src/TextPetition.php new file mode 100644 index 0000000000000000000000000000000000000000..04c4d88e5cabc54d4b574e602809dd42442bcff1 --- /dev/null +++ b/src/TextPetition.php @@ -0,0 +1,33 @@ +<?php + +namespace WPDesk\RepositoryRating; + +use WPDesk\PluginBuilder\Plugin\Hookable; +use WPDesk\RepositoryRating\DisplayStrategy\DisplayDecision; + +/** + * Can display text petition. + */ +class TextPetition implements Hookable { + + /** + * @var string + */ + private $display_on_action; + + /** + * @var DisplayDecision + */ + private $display_decision; + + public function hooks() { + add_action( $this->display_on_action, [ $this, 'display_petition_if_should' ] ); + } + + public function display_petition_if_should() { + if ( $this->display_decision->should_display() ) { + + } + } + +} \ No newline at end of file diff --git a/src/views/html-text-petition.php b/src/views/html-text-petition.php new file mode 100644 index 0000000000000000000000000000000000000000..18e89ed396ea33cf85936bfe4cbe83aa74e3603e --- /dev/null +++ b/src/views/html-text-petition.php @@ -0,0 +1,15 @@ +<?php + +?><div class="aligncenter"> + Created with + <span class="fcfSettings__footerIcon fcfSettings__footerIcon--heart"></span> + 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 + <span class="fcfSettings__footerIcon fcfSettings__footerIcon--star"></span> + <span class="fcfSettings__footerIcon fcfSettings__footerIcon--star"></span> + <span class="fcfSettings__footerIcon fcfSettings__footerIcon--star"></span> + <span class="fcfSettings__footerIcon fcfSettings__footerIcon--star"></span> + <span class="fcfSettings__footerIcon fcfSettings__footerIcon--star"></span> + </a> +</div> \ No newline at end of file