Changeset 3208667
- Timestamp:
- 12/16/2024 03:51:16 PM (16 months ago)
- Location:
- customize-external-links-and-add-icon/trunk
- Files:
-
- 4 edited
-
customize-external-links-form.php (modified) (3 diffs)
-
customize-external-links.php (modified) (3 diffs)
-
customizer-external-links-initiate.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
customize-external-links-and-add-icon/trunk/customize-external-links-form.php
r3208637 r3208667 7 7 { 8 8 $options = get_option('plugin_options'); 9 echo "<input id='plugin_text_manual' name='plugin_options[text_manual]' size='40' type='text' value='{$options['text_manual']}' />"; 9 // Überprüfe ob $options ein Array ist und der Wert existiert 10 $value = ''; 11 if (is_array($options) && isset($options['text_manual'])) { 12 $value = esc_attr($options['text_manual']); 13 } 14 15 echo "<input id='plugin_text_manual' name='plugin_options[text_manual]' size='40' type='text' value='" . $value . "' />"; 10 16 } 17 // TEXTBOX - Name: plugin_options[text_cssclass] 11 18 12 // TEXTBOX - Name: plugin_options[text_cssclass]13 19 function cuexlinks_setting_string_fn() 14 20 { 15 21 $options = get_option('plugin_options'); 16 echo "<input id='plugin_text_cssclass' name='plugin_options[text_cssclass]' size='40' type='text' value='{$options['text_cssclass']}' />"; 22 // Überprüfe ob $options ein Array ist und der Wert existiert 23 $value = ''; 24 if (is_array($options) && isset($options['text_cssclass'])) { 25 $value = esc_attr($options['text_cssclass']); 26 } 27 28 echo "<input id='plugin_text_cssclass' name='plugin_options[text_cssclass]' size='40' type='text' value='" . $value . "' />"; 17 29 } 18 30 … … 61 73 } 62 74 75 // CHECKBOX - Name: plugin_options[chkNoOpener] 76 function cuexlinks_setting_plugin_chknoopener_fn() 77 { 78 $checked = ""; 79 $options = get_option('plugin_options'); 80 if (isset($options['chkNoOpener'])) { 81 $checked = ' checked="checked" '; 82 } 83 ?> 84 85 <input <?=$checked?> 86 id='plugin_chknoopener' 87 name='plugin_options[chkNoOpener]' 88 type='checkbox' /> 89 <?php 90 } 91 92 93 // CHECKBOX - Name: plugin_options[chkNewWindow] 94 function cuexlinks_setting_plugin_chknewwindow_fn() 95 { 96 $checked = ""; 97 $options = get_option('plugin_options'); 98 if (is_array($options) && isset($options['chkNewWindow']) && $options['chkNewWindow']) { 99 $checked = ' checked="checked" '; 100 } 101 ?> 102 <input <?=$checked?> 103 id='plugin_chknewwindow' 104 name='plugin_options[chkNewWindow]' 105 type='checkbox' /> 106 <?php 107 } 108 109 63 110 // CHECKBOX - Name: plugin_options[chkNoReferrer] 64 111 function cuexlinks_setting_plugin_chknoreferrer_fn() … … 100 147 { 101 148 $options = get_option('plugin_options'); 149 // Überprüfe ob $options ein Array ist und setze Standardwerte falls nicht 150 if (!is_array($options)) { 151 $options = array( 152 'option_iconType' => 'None' // Standardwert 153 ); 154 } 155 102 156 $items = array("None", "fa-external-link-square-alt", "fa-external-link-alt", "ascii-8599", "ascii-8625", "ascii-8663", "manual"); 103 $item_tag = array("None", "<i class=\"fas fa-external-link-square-alt\"></i> Icon by Fontawesome", "<i class=\"fas fa-external-link-alt\"></i> Icon by Fontawesome", "↗ " . __("(recommened)"), "↱", "⇗", "manual"); 157 $item_tag = array( 158 "None", 159 "<i class=\"fas fa-external-link-square-alt\"></i> Icon by Fontawesome", 160 "<i class=\"fas fa-external-link-alt\"></i> Icon by Fontawesome", 161 "↗ " . __("(recommened)"), 162 "↱", 163 "⇗", 164 "manual" 165 ); 166 167 // Zusätzliche Sicherheitsüberprüfung für option_iconType 168 $current_value = isset($options['option_iconType']) ? $options['option_iconType'] : 'None'; 104 169 105 170 for ($i = 0; $i < count($items); $i++) { 106 $checked = ($ options['option_iconType']== $items[$i]) ? ' checked="checked" ' : '';107 echo "<label><input " . $checked . " value=' $items[$i]' name='plugin_options[option_iconType]' type='radio' /> $item_tag[$i]</label><br />";171 $checked = ($current_value == $items[$i]) ? ' checked="checked" ' : ''; 172 echo "<label><input " . $checked . " value='" . esc_attr($items[$i]) . "' name='plugin_options[option_iconType]' type='radio' /> " . $item_tag[$i] . "</label><br />"; 108 173 } 109 110 /* foreach($items as $item) {111 $checked = ($options['option_iconType']==$item) ? ' checked="checked" ' : '';112 echo "<label><input ".$checked." value='$item' name='plugin_options[option_iconType]' type='radio' /> $item</label><br />";113 } */114 174 } 115 175 176 116 177 cuexlinks_options_page_fn(); -
customize-external-links-and-add-icon/trunk/customize-external-links.php
r3208644 r3208667 5 5 * Description: Add nofollow and remove noreferrer attributes in external links. Choose between different icons to show users which link is an external one. 6 6 * Author: blapps 7 * Version: 2.3 7 * Version: 2.3.1 8 8 * Tested up to: 6.7 9 9 * Text Domain: customize-external-links … … 139 139 function cuexlinks_add_target_blank($url, $tag) 140 140 { 141 $no_follow = ''; 141 $options = get_option('plugin_options'); 142 $target_attr = ''; 142 143 $pattern = '/target\s*=\s*"\s*_(blank|parent|self|top)\s*"/'; 143 144 144 if (preg_match($pattern, $url) === 0) { 145 $no_follow .= ' target="_blank"'; 146 } 147 148 if ($no_follow) { 149 $tag = cuexlinks_update_close_tag($tag, $no_follow); 145 // Prüfe ob die Option aktiviert ist und ob bereits ein target-Attribut existiert 146 if (is_array($options) && isset($options['chkNewWindow']) && $options['chkNewWindow']) { 147 if (preg_match($pattern, $url) === 0) { 148 $target_attr .= ' target="_blank"'; 149 } 150 } 151 152 // Füge das target-Attribut nur hinzu, wenn die Option aktiviert ist 153 if ($target_attr) { 154 $tag = cuexlinks_update_close_tag($tag, $target_attr); 150 155 } 151 156 152 157 return $tag; 153 158 } 159 154 160 155 161 function cuexlinks_add_rel_nofollow($url, $tag) … … 463 469 add_settings_field('plugin_chknoopener', __('Add Noopener to External Links', 'customize-external-links'), 'cuexlinks_setting_plugin_chknoopener_fn', __FILE__, 'main_section'); 464 470 add_settings_field('plugin_chknoreferrer', __('Add Noreferrer to External Links', 'customize-external-links'), 'cuexlinks_setting_plugin_chknoreferrer_fn', __FILE__, 'main_section'); 471 add_settings_field('plugin_chknewwindow', __('Open Links in New Window', 'customize-external-links'), 'cuexlinks_setting_plugin_chknewwindow_fn', __FILE__, 'main_section'); 465 472 add_settings_section('sub_section', __('Icon Settings', 'customize-external-links'), 'cuexlinks_section_icon_text_fn', __FILE__); 466 473 add_settings_field('radio_buttons', __('Select Icon to indicate External Links', 'customize-external-links'), 'cuexlinks_setting_radio_fn', __FILE__, 'sub_section'); -
customize-external-links-and-add-icon/trunk/customizer-external-links-initiate.php
r3208637 r3208667 19 19 "chkNoReferrer" => "1", 20 20 "chkNoOpener" => "1", 21 "chkNewWindow" => "1", // neu 21 22 "chkNoFollowImage" => "1", 22 23 "option_iconType" => "None", -
customize-external-links-and-add-icon/trunk/readme.txt
r3208644 r3208667 5 5 Requires at least: 4 6 6 Tested up to: 6.7 7 Stable tag: 2.3 7 Stable tag: 2.3.1 8 8 License: GPL2 9 9 … … 55 55 56 56 == Changelog == 57 58 = 2.3.1 = 59 - new feature open in a new tab 60 - ready for WP 6.7 61 - major bugfixes 62 57 63 58 64 = 2.3 =
Note: See TracChangeset
for help on using the changeset viewer.