Skip to content

Commit

Permalink
Make it possible for a variant to be a short code. #218
Browse files Browse the repository at this point in the history
  • Loading branch information
Shelob9 committed Jan 26, 2016
1 parent b3e49d8 commit a1fb51b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
4 changes: 2 additions & 2 deletions classes/ui/render/click_tests/button.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class button extends \ingot\ui\render\click_tests\click {
*/
protected function make_html() {
$test_id = (int) $this->get_variant()[ 'ID' ];
$text = $this->get_variant()[ 'content' ];
$text = $this->get_variant_content();
$link = $this->link();
$style = $this->make_style( $this->get_group() );
$group_id = $this->get_group()[ 'ID' ];
Expand All @@ -42,7 +42,7 @@ protected function make_html() {
esc_url( $link ),
esc_attr( $test_id ),
$style,
esc_html( $text )
wp_kses_post( $text )
);

remove_filter( 'ingot_default_button_color', array( $this, 'get_group_default_color' ) );
Expand Down
2 changes: 1 addition & 1 deletion classes/ui/render/click_tests/button_color.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function make_html() {
esc_url( $link ),
esc_attr( $test_id ),
$style,
esc_html( $text )
wp_kses_post( $text )
);

remove_filter( 'ingot_default_button_color', array( $this, 'get_group_default_color' ) );
Expand Down
20 changes: 20 additions & 0 deletions classes/ui/render/click_tests/click.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,26 @@ public function get_chosen_variant_id(){
return (int) $this->variant[ 'ID' ];
}

/**
* Get variant content
*
* @since 1.1.0
*
* @return string
*/
protected function get_variant_content(){
/**
* Filter the content of the chosen variant before rendering the test
*
* @since 1.1.0
*
* @param string $content The content
* @param int $variant_ID The variant ID
* @param int $gorup_ID The group ID
*/
return apply_filters( 'ingot_click_test_content', $this->variant[ 'content'], $this->variant[ 'ID' ], $this->group[ 'ID'] );
}

/**
* Get variant property
*
Expand Down
4 changes: 2 additions & 2 deletions classes/ui/render/click_tests/destination.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ class destination extends \ingot\ui\render\click_tests\click {
*/
protected function make_html() {
$test_id = $this->get_variant()[ 'ID' ];
$text = $this->get_variant()[ 'content' ];
$text = $this->get_variant_content();
$group_id = $this->get_group()[ 'ID' ];

$this->html = sprintf(
'<span id="%s" class="ingot-test ingot-click-test ingot-click-test-link ingot-group-%d" data-ingot-test-id="%d" >%s</span>',
esc_attr( $this->attr_id() ),
esc_attr( $group_id ),
esc_attr( $test_id ),
esc_html( $text )
wp_kses_post( $text )
);

}
Expand Down
4 changes: 2 additions & 2 deletions classes/ui/render/click_tests/link.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class link extends \ingot\ui\render\click_tests\click {
*/
protected function make_html() {
$test_id = $this->get_variant()[ 'ID' ];
$text = $this->get_variant()[ 'content' ];
$text = $this->get_variant_content();
$link = $this->link();
$group_id = $this->get_group()[ 'ID' ];

Expand All @@ -36,7 +36,7 @@ protected function make_html() {
esc_url( $link ),
esc_attr( $group_id ),
esc_attr( $test_id ),
esc_html( $text )
wp_kses_post( $text )
);

}
Expand Down

0 comments on commit a1fb51b

Please sign in to comment.