B
B
bulkmaker2017-10-23 12:25:53
PHP
bulkmaker, 2017-10-23 12:25:53

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

3 answer(s)
U
user49981, 2019-07-24
@user49981

preg_replace('/((<span[^>]{0,}>)|(<\/span>))/', "", $html);

1
1210mk2, 2019-07-24
@1210mk2

<(span).*?class="\s*(?:.*\s)?wpcf7[^\>]*>(.*)<\/\1>

test

E
Edward, 2019-07-25
@IS-Builder

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:

Code
$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">

*/
But I do not guarantee that this code will correctly remove tags on other input lines (may need adjustment)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question