Answer the question
In order to leave comments, you need to log in
How to make browsersync not reload admin?
I work with wordppress and gulp. At the same time, both the admin and the pages themselves are open. During the resaving of styles, all pages of the domain are reloaded, including the admin panel. How to exclude */wp-admin/* directory from reload?
Answer the question
In order to leave comments, you need to log in
denism300 it is quite difficult to parse nested tags with regular expressions. But you can go the other way - first look for internal spans, and then check external ones (theoretically). For example, it would look like this:
$text = '<span class="wpcf7-form-control wpcf7-acceptance">
<span class="wpcf7-list-item">
<input type="checkbox" name="our-policy" value="1" aria-invalid="false" class="form-check-input" id="our-policy">
</span>
<span class="list-item">
<input type="checkbox" name="our-policy" value="1" aria-invalid="false" class="form-check-input" id="our-policy">
</span>
<span class="wpcf7-list-item">
<input type="checkbox" name="our-policy" value="1" aria-invalid="false" class="form-check-input" id="our-policy">
</span>
</span>';
$patterns = [
'~<span[^>]*wpcf7[^>]*>\s*(<input[^>]+>)\s*</span>~s',
'~<span[^>]*wpcf7[^>]*>(.+)</span>~s'
];
$text = preg_replace($patterns, '$1', $text);
echo $text;
/* Результат:
<input type="checkbox" name="our-policy" value="1" aria-invalid="false" class="form-check-input" id="our-policy">
<span class="list-item">
<input type="checkbox" name="our-policy" value="1" aria-invalid="false" class="form-check-input" id="our-policy">
</span>
<input type="checkbox" name="our-policy" value="1" aria-invalid="false" class="form-check-input" id="our-policy">
*/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question