Plugin Directory

Changeset 3335603


Ignore:
Timestamp:
07/28/2025 11:47:23 PM (8 months ago)
Author:
wpolstudio
Message:

1.0.1

  • Bug fix for post type = "post" also accepted for "post" archives
Location:
tiny-widget-manager/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tiny-widget-manager/trunk/includes/class-tiny-widget-manager.php

    r3335585 r3335603  
    2828    private function __construct()
    2929    {
    30         // $debug_mode = get_option('twim_debug_mode');
     30        $debug_mode = get_option('twim_debug_mode');
    3131
    3232        $Settings = TWIM_Settings::get_instance();
     
    5353            add_filter('sidebars_widgets',              [$Hooks, 'filter_widgets_before_output'], 10, 3);
    5454            add_filter('dynamic_sidebar_params',        [$Hooks, 'add_custom_widget_classes'], 10, 3);
    55             // if ($debug_mode) {
    56             //     add_filter('widget_display_callback',   [$Hooks, 'maybe_append_debug_info'], 10, 3);
    57             // }
     55            if ($debug_mode) {
     56                add_filter('widget_display_callback',   [$Hooks, 'maybe_append_debug_info'], 10, 3);
     57            }
    5858        }
    5959
  • tiny-widget-manager/trunk/includes/class-twim-hooks.php

    r3335585 r3335603  
    518518     * @return void
    519519     */
    520     // public function maybe_append_debug_info($instance, $widget, $args)
    521     // {
    522     //     $id_base = $widget->id_base;
    523     //     $widget_id = $widget->id;
    524 
    525     //     echo '<div class="twim-debug-info" style="border:1px dashed red; padding:5px; font-size:11px; margin-top:5px;">';
    526     //     echo '<div class="twim-debug-section" style="padding: 10px;">';
    527     //     echo 'Widget ID: <strong>' . esc_html($widget_id) . '</strong><br>';
    528     //     echo 'ID Base: <strong>' . esc_html($id_base) . '</strong><br>';
    529     //     if (isset($instance['twim_visibility_andor'])) {
    530     //        echo 'Visibility AND/OR: <strong>' . esc_html($instance['twim_visibility_andor']) . '</strong><br>';
    531     //     }
    532     //     echo 'wp_is_mobile() : <strong>' . (TWIMH::is_mobile() ? 'Is mobile' : 'Is not mobile') . '</strong><br>';
    533     //     echo '</div>';
    534     //     foreach ($this->sections as $section) {
    535     //         $mode = $instance['twim_visibility_' . $section . '_mode'] ?? 'none';
    536     //         $items = $instance['twim_visibility_' . $section . '_items'] ?? [];
    537     //         echo '<div class="twim-debug-section section-' . esc_attr($section) . '" style="border-top: 1px dashed gray;padding: 10px;">';
    538     //         echo esc_html(ucfirst($section)) . ' Mode: <strong>' . esc_html($mode) . '</strong><br>';
    539     //         echo esc_html(ucfirst($section)) . ' Items: <strong>' . implode(', ', array_map('esc_html', (array)$items)) . '</strong><br>';
    540     //         echo '</div>';
    541     //     }
    542     //     echo '</div>';
    543 
    544     //     return $instance;
    545     // }
     520    public function maybe_append_debug_info($instance, $widget, $args)
     521    {
     522        $id_base = $widget->id_base;
     523        $widget_id = $widget->id;
     524
     525        echo '<div class="twim-debug-info" style="border:1px dashed red; padding:5px; font-size:11px; margin-top:5px;">';
     526        echo '<div class="twim-debug-section" style="padding: 10px;">';
     527        echo 'Widget ID: <strong>' . esc_html($widget_id) . '</strong><br>';
     528        echo 'ID Base: <strong>' . esc_html($id_base) . '</strong><br>';
     529        if (isset($instance['twim_visibility_andor'])) {
     530           echo 'Visibility AND/OR: <strong>' . esc_html($instance['twim_visibility_andor']) . '</strong><br>';
     531        }
     532        echo 'wp_is_mobile() : <strong>' . (TWIMH::is_mobile() ? 'Is mobile' : 'Is not mobile') . '</strong><br>';
     533        echo '</div>';
     534        foreach ($this->sections as $section) {
     535            $mode = $instance['twim_visibility_' . $section . '_mode'] ?? 'none';
     536            $items = $instance['twim_visibility_' . $section . '_items'] ?? [];
     537            echo '<div class="twim-debug-section section-' . esc_attr($section) . '" style="border-top: 1px dashed gray;padding: 10px;">';
     538            echo esc_html(ucfirst($section)) . ' Mode: <strong>' . esc_html($mode) . '</strong><br>';
     539            echo esc_html(ucfirst($section)) . ' Items: <strong>' . implode(', ', array_map('esc_html', (array)$items)) . '</strong><br>';
     540            echo '</div>';
     541        }
     542        echo '</div>';
     543
     544        return $instance;
     545    }
    546546
    547547
     
    621621    private function match_section($section, $items)
    622622    {
     623        if ( empty($items )) return false;
     624
    623625        $post_id = get_the_ID();
    624626        $post_type = get_post_type($post_id);
     
    633635                break;
    634636            case 'posts':
    635                 $post_type = $args['post_type'] ?? get_post_type();
    636                 return in_array($post_type, $items);
     637                return is_singular($items);
    637638                break;
    638639            case 'archives':
  • tiny-widget-manager/trunk/readme.txt

    r3335585 r3335603  
    66Tested up to: 6.8
    77Requires PHP: 7.4
    8 Stable tag: 1.0.0
     8Stable tag: 1.0.1
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    8585* Initial release with support for page, post type, archive, user, and device-based visibility rules
    8686* Added input for applying custom CSS classes to widgets
     87= 1.0.1 =
     88* Bug fix for post type = "post" also accepted for "post" archives
    8789
    8890== Upgrade Notice ==
     
    9092= 1.0.0 =
    9193First stable version. No upgrade steps required.
     94
     95
Note: See TracChangeset for help on using the changeset viewer.