Plugin Directory

Changeset 3208667


Ignore:
Timestamp:
12/16/2024 03:51:16 PM (16 months ago)
Author:
blapps
Message:

Bug fix and ready for WP 6.7

Location:
customize-external-links-and-add-icon/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • customize-external-links-and-add-icon/trunk/customize-external-links-form.php

    r3208637 r3208667  
    77{
    88    $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 . "' />";
    1016}
     17// TEXTBOX - Name: plugin_options[text_cssclass]
    1118
    12 // TEXTBOX - Name: plugin_options[text_cssclass]
    1319function cuexlinks_setting_string_fn()
    1420{
    1521    $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 . "' />";
    1729}
    1830
     
    6173}
    6274
     75// CHECKBOX - Name: plugin_options[chkNoOpener]
     76function 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]
     94function 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
    63110// CHECKBOX - Name: plugin_options[chkNoReferrer]
    64111function cuexlinks_setting_plugin_chknoreferrer_fn()
     
    100147{
    101148    $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
    102156    $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", "&#8599; " . __("(recommened)"), "&#8625;", "&#8663;", "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        "&#8599; " . __("(recommened)"),
     162        "&#8625;",
     163        "&#8663;",
     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';
    104169
    105170    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 />";
    108173    }
    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 } */
    114174}
    115175
     176
    116177cuexlinks_options_page_fn();
  • customize-external-links-and-add-icon/trunk/customize-external-links.php

    r3208644 r3208667  
    55 * Description: Add nofollow and remove noreferrer attributes in external links. Choose between different icons to show users which link is an external one.
    66 * Author: blapps
    7  * Version: 2.3
     7 * Version: 2.3.1
    88 * Tested up to: 6.7
    99 * Text Domain: customize-external-links
     
    139139function cuexlinks_add_target_blank($url, $tag)
    140140{
    141     $no_follow = '';
     141    $options = get_option('plugin_options');
     142    $target_attr = '';
    142143    $pattern = '/target\s*=\s*"\s*_(blank|parent|self|top)\s*"/';
    143144
    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);
    150155    }
    151156
    152157    return $tag;
    153158}
     159
    154160
    155161function cuexlinks_add_rel_nofollow($url, $tag)
     
    463469    add_settings_field('plugin_chknoopener', __('Add Noopener to External Links', 'customize-external-links'), 'cuexlinks_setting_plugin_chknoopener_fn', __FILE__, 'main_section');
    464470    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');
    465472    add_settings_section('sub_section', __('Icon Settings', 'customize-external-links'), 'cuexlinks_section_icon_text_fn', __FILE__);
    466473    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  
    1919        "chkNoReferrer" => "1",
    2020        "chkNoOpener" => "1",
     21        "chkNewWindow" => "1", // neu
    2122        "chkNoFollowImage" => "1",
    2223        "option_iconType" => "None",
  • customize-external-links-and-add-icon/trunk/readme.txt

    r3208644 r3208667  
    55Requires at least: 4
    66Tested up to: 6.7
    7 Stable tag: 2.3
     7Stable tag: 2.3.1
    88License: GPL2
    99
     
    5555
    5656== Changelog ==
     57
     58= 2.3.1 =
     59- new feature open in a new tab
     60- ready for WP 6.7
     61- major bugfixes
     62
    5763
    5864= 2.3 =
Note: See TracChangeset for help on using the changeset viewer.