| Total Complexity | 6 |
| Total Lines | 79 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class SiteReviewsSummaryBlock extends BlockGenerator |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @return array |
||
| 12 | */ |
||
| 13 | public function attributes() |
||
| 47 | ], |
||
| 48 | ]; |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @return string |
||
| 53 | */ |
||
| 54 | public function render( array $attributes ) |
||
| 55 | { |
||
| 56 | $attributes['class'] = $attributes['className']; |
||
| 57 | $shortcode = glsr( Shortcode::class ); |
||
| 58 | if( filter_input( INPUT_GET, 'context' ) == 'edit' ) { |
||
| 59 | $attributes = $this->normalize( $attributes ); |
||
| 60 | $this->filterShortcodeClass(); |
||
| 61 | if( !$this->hasVisibleFields( $shortcode, $attributes )) { |
||
| 62 | $this->filterInterpolation(); |
||
| 63 | } |
||
| 64 | } |
||
| 65 | return $shortcode->buildShortcode( $attributes ); |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @return void |
||
| 70 | */ |
||
| 71 | protected function filterInterpolation() |
||
| 72 | { |
||
| 73 | add_filter( 'site-reviews/interpolate/reviews-summary', function( $context ) { |
||
| 74 | $context['class'] = 'glsr-default glsr-block-disabled'; |
||
| 75 | $context['text'] = __( 'You have hidden all of the fields for this block.', 'site-reviews' ); |
||
| 76 | return $context; |
||
| 77 | }); |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @return void |
||
| 82 | */ |
||
| 83 | protected function filterShortcodeClass() |
||
| 87 | }); |
||
| 88 | } |
||
| 89 | } |
||
| 90 |