array(
'relation' => 'AND',
array(
'slug' => 'ticket',
'compare' => '=',
'val' => $ticket->id,
),
array(
'slug' => 'type',
'compare' => '=',
'val' => 'reply',
),
),
'orderby' => 'id',
'order' => 'DESC',
'items_per_page' => 1,
)
);
if ( empty( $threads['results'] ) ) {
return $condition['operator'] == 'NOT LIKE';
}
$last_reply = $threads['results'][0];
$value = strtolower( stripslashes( wp_strip_all_tags( $last_reply->body ) ) );
$terms = array_filter(
array_map(
function ( $term ) {
return strtolower( trim( $term ) );
},
explode( PHP_EOL, $condition['operand_val_1'] )
)
);
switch ( $condition['operator'] ) {
case 'LIKE':
$is_valid = false;
foreach ( $terms as $term ) {
$index = strpos( $value, trim( stripslashes( $term ) ) );
if ( is_numeric( $index ) ) {
$is_valid = true;
break;
}
}
break;
case 'NOT LIKE':
$is_valid = true;
foreach ( $terms as $term ) {
$index = strpos( $value, trim( stripslashes( $term ) ) );
if ( is_numeric( $index ) ) {
$is_valid = false;
break;
}
}
break;
}
return $is_valid;
}
}
endif;
WPSC_TC_Last_Reply::init();