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

feature(petition): added text petition

parent 0dbc54c4
No related branches found
No related tags found
1 merge request!1feature(petition): added text petition
## [1.2.0] - 2022-01-24
### Changes
- Added TextPetition
## [1.1.0] - 2019-12-02 ## [1.1.0] - 2019-12-02
### Changes ### Changes
- RatingPetitionNotice can get url to redirect user when wants to rate - RatingPetitionNotice can get url to redirect user when wants to rate
......
...@@ -7,8 +7,9 @@ ...@@ -7,8 +7,9 @@
} }
], ],
"require": { "require": {
"php": ">=5.6", "php": ">=7.0",
"wpdesk/wp-notice": "^3.1" "wpdesk/wp-notice": "^3.1",
"wpdesk/wp-plugin-flow": "^3.1"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "<7", "phpunit/phpunit": "<7",
......
<?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
<?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
<?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
<?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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment