Skip to content

Commit

Permalink
Allow multiple URL disabling patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
kinging123 committed Mar 31, 2021
1 parent a8d5b8f commit 3211b50
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
10 changes: 5 additions & 5 deletions admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ public function init_fields() {
'supplemental' => __( 'Tip: Use this only if you know what you\'re doing!', 'ivrita' ),
'default' => false
),
'url_disable_pattern' => array(
'label' => __( 'URL Disable Pattern', 'ivrita' ),
'url_disable_patterns' => array(
'label' => __( 'URL Disable Patterns', 'ivrita' ),
'section' => 'global_settings',
'type' => 'text',
'type' => 'textarea',
'placeholder' => __( '(no URLs disabled by default)', 'ivrita' ),
'helper' => __( 'Ivrita will be disabled on URLs that match the given RegEx pattern.', 'ivrita' ),
'helper' => __( 'Ivrita will be disabled on URLs that match the given RegEx patterns (separated by new lines).', 'ivrita' ),
'supplemental' => __( 'e.g. ".*(\?|&)lang=en$" to disable Ivrita on pages with the GET parameter "lang=en"', 'ivrita' ),
'default' => false,
'style' => 'text-align: left; direction: ltr',
Expand Down Expand Up @@ -208,7 +208,7 @@ public function field_callback( $arguments ) {
printf( '<input name="%1$s" id="%1$s" type="%2$s" placeholder="%3$s" value="%4$s" %5$s />', $arguments['uid'], $arguments['type'], $arguments['placeholder'], $value, $css );
break;
case 'textarea':
printf( '<textarea name="%1$s" id="%1$s" placeholder="%2$s" rows="5" cols="50">%3$s</textarea>', $arguments['uid'], $arguments['placeholder'], $value );
printf( '<textarea name="%1$s" id="%1$s" placeholder="%2$s" rows="5" cols="50" %4$s>%3$s</textarea><br>', $arguments['uid'], $arguments['placeholder'], $value, $css );
break;
case 'checkbox':
if( ! empty ( $arguments['options'] ) && is_array( $arguments['options'] ) ){
Expand Down
11 changes: 7 additions & 4 deletions ivrita.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,15 @@ public function enabled_for_page( $id = null ) {
}

// URL-based disable
$url_disable_pattern = $this->settings->get_field('url_disable_pattern');
if ( $url_disable_pattern ) {
$url_disable_patterns = $this->settings->get_field('url_disable_patterns');
if ( $url_disable_patterns ) {
global $wp;
$current_req_url = $_SERVER['REQUEST_URI'];
if ( preg_match( '`' . $url_disable_pattern . '`', $current_req_url) ) {
return false;
$patterns = explode( "\n", $url_disable_patterns );
foreach ( $patterns as $pattern ) {
if ( preg_match( '`' . str_replace( "\r", "", $pattern) . '`', $current_req_url ) ) {
return false;
}
}
}

Expand Down
Binary file modified languages/ivrita-he_IL.mo
Binary file not shown.
14 changes: 9 additions & 5 deletions languages/ivrita-he_IL.po
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: Ivrita\n"
"POT-Creation-Date: 2021-03-31 18:24+0300\n"
"PO-Revision-Date: 2021-03-31 18:25+0300\n"
"POT-Creation-Date: 2021-03-31 20:09+0300\n"
"PO-Revision-Date: 2021-03-31 20:09+0300\n"
"Last-Translator: Reuven Karasik <[email protected]>\n"
"Language-Team: Reuven Karasik <[email protected]>\n"
"Language: he\n"
Expand Down Expand Up @@ -116,16 +116,20 @@ msgid "Tip: Use this only if you know what you're doing!"
msgstr "זהירות: אפשרות זו היא למתקדמות.ים!"

#: admin-settings.php:140
msgid "URL Disable Pattern"
msgid "URL Disable Patterns"
msgstr "כיבוי עבריתה בכתובות URL מסוימות"

#: admin-settings.php:143
msgid "(no URLs disabled by default)"
msgstr "(ללא סינון)"

#: admin-settings.php:144
msgid "Ivrita will be disabled on URLs that match the given RegEx pattern."
msgstr "עבריתה לא תופיע בעמודים שה־URL שלהם יתאים לתבנית הRegEx הזו"
msgid ""
"Ivrita will be disabled on URLs that match the given RegEx patterns "
"(separated by new lines)."
msgstr ""
"עבריתה לא תופיע בעמודים שה־URL שלהם יתאים לתבניות הRegEx האלו (מופרדות "
"בשורות חדשות)"

#: admin-settings.php:145
msgid ""
Expand Down

0 comments on commit 3211b50

Please sign in to comment.