| Conditions | 8 |
| Paths | 16 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 38 | function render_block( $attributes, $content ) { |
||
| 39 | Jetpack_Gutenberg::load_assets_as_required( FEATURE_NAME ); |
||
| 40 | |||
| 41 | $classes = Jetpack_Gutenberg::block_classes( FEATURE_NAME, $attributes ); |
||
| 42 | |||
| 43 | $count = isset( $_COOKIE['jp-visit-counter'] ) ? intval( $_COOKIE['jp-visit-counter'] ) : 0; |
||
| 44 | $criteria = isset( $attributes['criteria'] ) ? $attributes['criteria'] : 'after-visits'; |
||
| 45 | $threshold = isset( $attributes['threshold'] ) ? intval( $attributes['threshold'] ) : 3; |
||
| 46 | |||
| 47 | if ( |
||
| 48 | ( 'after-visits' === $criteria && $count >= $threshold ) || |
||
| 49 | ( 'before-visits' === $criteria && $count < $threshold ) |
||
| 50 | ) { |
||
| 51 | return $content; |
||
| 52 | } |
||
| 53 | |||
| 54 | // return an empty div so that view script increments the visit counter in the cookie. |
||
| 55 | return '<div class="' . esc_attr( $classes ) . '"></div>'; |
||
| 56 | } |
||
| 57 |