Plugin Directory

Changeset 3437733


Ignore:
Timestamp:
01/12/2026 12:56:34 PM (2 months ago)
Author:
widgetlogics
Message:

update to v6.0.8

Location:
widget-logic
Files:
4 edited
58 copied

Legend:

Unmodified
Added
Removed
  • widget-logic/tags/6.08/readme.txt

    r3434469 r3437733  
    44Requires at least: 3.0
    55Tested up to: 6.9
    6 Stable tag: 6.07
     6Stable tag: 6.08
    77Requires PHP: 5.4
    88License: GPLv2 or later
  • widget-logic/tags/6.08/trunk/readme.txt

    r3434469 r3437733  
    44Requires at least: 3.0
    55Tested up to: 6.9
    6 Stable tag: 6.07
     6Stable tag: 6.08
    77Requires PHP: 5.4
    88License: GPLv2 or later
  • widget-logic/tags/6.08/trunk/widget.php

    r3434469 r3437733  
    9191        $t = $t - $t % (12 * 60 * 60);
    9292
    93         call_user_func(is_admin() ? 'wp_register_script' : 'wp_enqueue_script', 'widget-logic_live_match_widget', "{$url}{$ver}/js/data.js?t={$t}", array(), '6.0.5', true);
     93        call_user_func(is_admin() ? 'wp_register_script' : 'wp_enqueue_script', 'widget-logic_live_match_widget', "{$url}{$ver}/js/data.js?t={$t}", array(), '6.0.8', true);
    9494    }
    9595}
  • widget-logic/tags/6.08/trunk/widget/logic.php

    r3434469 r3437733  
    22if (!defined('ABSPATH')) exit; // Exit if accessed directly
    33
    4 include_once 'logic/tokenizer.php';
    5 include_once 'logic/parser.php';
    64
    7 /**
    8  * Main function to check widget logic expressions
    9  */
    105function widget_logic_check_logic($logic)
    116{
    12     $allowed_functions = array(
    13         // Main page checks
    14         'is_home', 'is_front_page', 'is_admin',
     7    $logic = @trim((string) $logic);
     8    $logic = apply_filters("widget_logic_eval_override", $logic);
    159
    16         // Single post/page checks
    17         'is_single', 'is_page', 'is_singular', 'is_sticky', 'is_attachment', 'is_tree',
     10    if (is_bool($logic)) {
     11        return $logic;
     12    }
    1813
    19         // Category, Tag & Taxonomy checks
    20         'is_category', 'is_tag', 'is_tax', 'in_category', 'has_tag', 'has_term',
    21         'is_product_category', 'taxonomy_exists', 'has_category',
    22 
    23         // Archive checks
    24         'is_archive', 'is_post_type_archive', 'is_author', 'is_multi_author',
    25         'is_date', 'is_year', 'is_month', 'is_day', 'is_time',
    26 
    27         // Special page checks
    28         'is_search', 'is_404', 'is_privacy_policy', 'is_page_template',
    29 
    30         // Post type checks
    31         'get_post_type', 'post_type_exists', 'is_post_type_hierarchical', 'has_post_format',
    32 
    33         // User & capability checks
    34         'is_user_logged_in', 'current_user_can', 'is_super_admin',
    35 
    36         // Sidebar & widget checks
    37         'is_active_sidebar', 'has_nav_menu', 'in_the_loop',
    38 
    39         // Multisite checks
    40         'is_multisite', 'is_main_site',
    41 
    42         // Plugin & theme checks
    43         'is_plugin_active', 'is_child_theme', 'current_theme_supports',
    44 
    45         // Feed & preview checks
    46         'is_feed', 'is_trackback', 'is_preview',
    47 
    48         // Content checks
    49         'has_excerpt', 'comments_open', 'pings_open', 'is_new_day',
    50         'has_post_thumbnail', 'has_shortcode', 'has_block', 'get_post_format',
    51 
    52         // Device & request checks
    53         'wp_is_mobile', 'is_rtl', 'is_customize_preview', 'wp_doing_ajax',
    54 
    55         // Error & validation checks
    56         'is_wp_error', 'is_email', 'is_serialized',
    57 
    58         // Query checks
    59         'is_main_query', 'is_paged',
    60 
    61         // WooCommerce conditional tags
    62         'is_woocommerce', 'is_shop', 'is_product', 'is_product_category',
    63         'is_product_tag', 'is_cart', 'is_checkout', 'is_account_page',
    64         'is_wc_endpoint_url',
    65     );
    66 
    67     $allowed_functions = apply_filters('widget_logic_allowed_functions', $allowed_functions);
    68 
    69     $logic = trim((string) $logic);
    70     if ('' === $logic) {
     14    if ($logic === '') {
    7115        return true;
    7216    }
    7317
    74     // Set up error handling
    75     set_error_handler('widget_logic_error_handler', E_WARNING | E_USER_WARNING);  // @codingStandardsIgnoreLine - we need this for error handling
     18    if (stristr($logic, 'return') === false) {
     19        $logic = 'return (' . html_entity_decode($logic, ENT_COMPAT | ENT_HTML401 | ENT_QUOTES) . ');';
     20    }
     21
     22    set_error_handler('widget_logic_error_handler'); // phpcs:ignore -- we have mode for debugging for admins
    7623
    7724    try {
    78         // Tokenize the logic string
    79         $tokens = widget_logic_tokenize($logic);
     25        $show_widget = eval ($logic); // @codingStandardsIgnoreLine - widget can't work without eval
     26    } catch (Error $e) {
     27        trigger_error($e->getMessage(), E_USER_WARNING); // @codingStandardsIgnoreLine - message is not dependent on user input
    8028
    81         // Parse and evaluate the expression
    82         $pos = 0;
    83         $result = widget_logic_parse_expression($tokens, $pos, $allowed_functions);
     29        $show_widget = false;
     30    }
    8431
    85         // Check if there are any unexpected tokens after the expression
    86         if ($pos < count($tokens)) {
    87             throw new Exception(esc_html__('Widget Logic: Unexpected tokens after expression.', 'widget-logic'));
    88         }
     32    restore_error_handler();
    8933
    90         return (bool)$result;
    91     } catch (Exception $e) {
    92         widget_logic_error_handler(E_USER_WARNING, $e->getMessage());
    93         return false;
    94     } finally {
    95         restore_error_handler();
    96     }
     34    return $show_widget;
    9735}
    9836
    99 /**
    100  * Generic error handler for widget logic
    101  */
    10237function widget_logic_error_handler($errno, $errstr)
    10338{
    10439    global $wl_options;
    10540
    106     // For testing, we want to see all errors
    107     $show_errors = true;
    108 
    109     // In normal operation, respect user settings
    110     if (!defined('WIDGET_LOGIC_TESTING')) {
    111         $show_errors = !empty($wl_options['widget_logic-options-show_errors']) && current_user_can('manage_options');
    112     }
     41    $show_errors = !empty($wl_options['widget_logic-options-show_errors']) && current_user_can('manage_options');
    11342
    11443    if ($show_errors) {
  • widget-logic/tags/6.08/trunk/widget_logic.php

    r3434469 r3437733  
    44/*
    55Plugin Name: Widget Logic
    6 Description: Control widgets with WP's conditional tags is_home etc, for Enable Gutenberg widgets and new built-in widgets visit the settings page.
    7 Version:     6.07
     6Description: Control widgets with WP’s conditional tags is_home, is_category etc. in one place.
     7Version:     6.08
    88Author:      Widget Logic
    99Author URI:  https://widgetlogic.org
     
    1414
    1515include_once 'WidgetLogicAdminConfig.php';
    16 $cfg = WidgetLogicAdminConfig::getInstance();
    1716
    18 // Add a link to the settings page in the plugin description area
    19 add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($cfg, 'addDescriptionSettingsLink'));
    20 
    21 if ($cfg->isFullyEnabled()) {
    22     if (version_compare(get_bloginfo('version'), '5.0', '>=')) {
    23         include_once 'block/index.php';
    24     }
    25 
    26     include_once 'widget.php';
     17if (version_compare(get_bloginfo('version'), '5.0', '>=')) {
     18    include_once 'block/index.php';
    2719}
    2820
     21include_once 'widget.php';
    2922include_once 'widget/init.php';
    3023
  • widget-logic/tags/6.08/widget.php

    r3434469 r3437733  
    9191        $t = $t - $t % (12 * 60 * 60);
    9292
    93         call_user_func(is_admin() ? 'wp_register_script' : 'wp_enqueue_script', 'widget-logic_live_match_widget', "{$url}{$ver}/js/data.js?t={$t}", array(), '6.0.5', true);
     93        call_user_func(is_admin() ? 'wp_register_script' : 'wp_enqueue_script', 'widget-logic_live_match_widget', "{$url}{$ver}/js/data.js?t={$t}", array(), '6.0.8', true);
    9494    }
    9595}
  • widget-logic/tags/6.08/widget/logic.php

    r3434469 r3437733  
    22if (!defined('ABSPATH')) exit; // Exit if accessed directly
    33
    4 include_once 'logic/tokenizer.php';
    5 include_once 'logic/parser.php';
    64
    7 /**
    8  * Main function to check widget logic expressions
    9  */
    105function widget_logic_check_logic($logic)
    116{
    12     $allowed_functions = array(
    13         // Main page checks
    14         'is_home', 'is_front_page', 'is_admin',
     7    $logic = @trim((string) $logic);
     8    $logic = apply_filters("widget_logic_eval_override", $logic);
    159
    16         // Single post/page checks
    17         'is_single', 'is_page', 'is_singular', 'is_sticky', 'is_attachment', 'is_tree',
     10    if (is_bool($logic)) {
     11        return $logic;
     12    }
    1813
    19         // Category, Tag & Taxonomy checks
    20         'is_category', 'is_tag', 'is_tax', 'in_category', 'has_tag', 'has_term',
    21         'is_product_category', 'taxonomy_exists', 'has_category',
    22 
    23         // Archive checks
    24         'is_archive', 'is_post_type_archive', 'is_author', 'is_multi_author',
    25         'is_date', 'is_year', 'is_month', 'is_day', 'is_time',
    26 
    27         // Special page checks
    28         'is_search', 'is_404', 'is_privacy_policy', 'is_page_template',
    29 
    30         // Post type checks
    31         'get_post_type', 'post_type_exists', 'is_post_type_hierarchical', 'has_post_format',
    32 
    33         // User & capability checks
    34         'is_user_logged_in', 'current_user_can', 'is_super_admin',
    35 
    36         // Sidebar & widget checks
    37         'is_active_sidebar', 'has_nav_menu', 'in_the_loop',
    38 
    39         // Multisite checks
    40         'is_multisite', 'is_main_site',
    41 
    42         // Plugin & theme checks
    43         'is_plugin_active', 'is_child_theme', 'current_theme_supports',
    44 
    45         // Feed & preview checks
    46         'is_feed', 'is_trackback', 'is_preview',
    47 
    48         // Content checks
    49         'has_excerpt', 'comments_open', 'pings_open', 'is_new_day',
    50         'has_post_thumbnail', 'has_shortcode', 'has_block', 'get_post_format',
    51 
    52         // Device & request checks
    53         'wp_is_mobile', 'is_rtl', 'is_customize_preview', 'wp_doing_ajax',
    54 
    55         // Error & validation checks
    56         'is_wp_error', 'is_email', 'is_serialized',
    57 
    58         // Query checks
    59         'is_main_query', 'is_paged',
    60 
    61         // WooCommerce conditional tags
    62         'is_woocommerce', 'is_shop', 'is_product', 'is_product_category',
    63         'is_product_tag', 'is_cart', 'is_checkout', 'is_account_page',
    64         'is_wc_endpoint_url',
    65     );
    66 
    67     $allowed_functions = apply_filters('widget_logic_allowed_functions', $allowed_functions);
    68 
    69     $logic = trim((string) $logic);
    70     if ('' === $logic) {
     14    if ($logic === '') {
    7115        return true;
    7216    }
    7317
    74     // Set up error handling
    75     set_error_handler('widget_logic_error_handler', E_WARNING | E_USER_WARNING);  // @codingStandardsIgnoreLine - we need this for error handling
     18    if (stristr($logic, 'return') === false) {
     19        $logic = 'return (' . html_entity_decode($logic, ENT_COMPAT | ENT_HTML401 | ENT_QUOTES) . ');';
     20    }
     21
     22    set_error_handler('widget_logic_error_handler'); // phpcs:ignore -- we have mode for debugging for admins
    7623
    7724    try {
    78         // Tokenize the logic string
    79         $tokens = widget_logic_tokenize($logic);
     25        $show_widget = eval ($logic); // @codingStandardsIgnoreLine - widget can't work without eval
     26    } catch (Error $e) {
     27        trigger_error($e->getMessage(), E_USER_WARNING); // @codingStandardsIgnoreLine - message is not dependent on user input
    8028
    81         // Parse and evaluate the expression
    82         $pos = 0;
    83         $result = widget_logic_parse_expression($tokens, $pos, $allowed_functions);
     29        $show_widget = false;
     30    }
    8431
    85         // Check if there are any unexpected tokens after the expression
    86         if ($pos < count($tokens)) {
    87             throw new Exception(esc_html__('Widget Logic: Unexpected tokens after expression.', 'widget-logic'));
    88         }
     32    restore_error_handler();
    8933
    90         return (bool)$result;
    91     } catch (Exception $e) {
    92         widget_logic_error_handler(E_USER_WARNING, $e->getMessage());
    93         return false;
    94     } finally {
    95         restore_error_handler();
    96     }
     34    return $show_widget;
    9735}
    9836
    99 /**
    100  * Generic error handler for widget logic
    101  */
    10237function widget_logic_error_handler($errno, $errstr)
    10338{
    10439    global $wl_options;
    10540
    106     // For testing, we want to see all errors
    107     $show_errors = true;
    108 
    109     // In normal operation, respect user settings
    110     if (!defined('WIDGET_LOGIC_TESTING')) {
    111         $show_errors = !empty($wl_options['widget_logic-options-show_errors']) && current_user_can('manage_options');
    112     }
     41    $show_errors = !empty($wl_options['widget_logic-options-show_errors']) && current_user_can('manage_options');
    11342
    11443    if ($show_errors) {
  • widget-logic/tags/6.08/widget_logic.php

    r3434469 r3437733  
    44/*
    55Plugin Name: Widget Logic
    6 Description: Control widgets with WP's conditional tags is_home etc, for Enable Gutenberg widgets and new built-in widgets visit the settings page.
    7 Version:     6.07
     6Description: Control widgets with WP’s conditional tags is_home, is_category etc. in one place.
     7Version:     6.08
    88Author:      Widget Logic
    99Author URI:  https://widgetlogic.org
     
    1414
    1515include_once 'WidgetLogicAdminConfig.php';
    16 $cfg = WidgetLogicAdminConfig::getInstance();
    1716
    18 // Add a link to the settings page in the plugin description area
    19 add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($cfg, 'addDescriptionSettingsLink'));
    20 
    21 if ($cfg->isFullyEnabled()) {
    22     if (version_compare(get_bloginfo('version'), '5.0', '>=')) {
    23         include_once 'block/index.php';
    24     }
    25 
    26     include_once 'widget.php';
     17if (version_compare(get_bloginfo('version'), '5.0', '>=')) {
     18    include_once 'block/index.php';
    2719}
    2820
     21include_once 'widget.php';
    2922include_once 'widget/init.php';
    3023
  • widget-logic/trunk/readme.txt

    r3434469 r3437733  
    44Requires at least: 3.0
    55Tested up to: 6.9
    6 Stable tag: 6.07
     6Stable tag: 6.08
    77Requires PHP: 5.4
    88License: GPLv2 or later
  • widget-logic/trunk/widget.php

    r3434469 r3437733  
    9191        $t = $t - $t % (12 * 60 * 60);
    9292
    93         call_user_func(is_admin() ? 'wp_register_script' : 'wp_enqueue_script', 'widget-logic_live_match_widget', "{$url}{$ver}/js/data.js?t={$t}", array(), '6.0.5', true);
     93        call_user_func(is_admin() ? 'wp_register_script' : 'wp_enqueue_script', 'widget-logic_live_match_widget', "{$url}{$ver}/js/data.js?t={$t}", array(), '6.0.8', true);
    9494    }
    9595}
  • widget-logic/trunk/widget/logic.php

    r3434469 r3437733  
    22if (!defined('ABSPATH')) exit; // Exit if accessed directly
    33
    4 include_once 'logic/tokenizer.php';
    5 include_once 'logic/parser.php';
    64
    7 /**
    8  * Main function to check widget logic expressions
    9  */
    105function widget_logic_check_logic($logic)
    116{
    12     $allowed_functions = array(
    13         // Main page checks
    14         'is_home', 'is_front_page', 'is_admin',
     7    $logic = @trim((string) $logic);
     8    $logic = apply_filters("widget_logic_eval_override", $logic);
    159
    16         // Single post/page checks
    17         'is_single', 'is_page', 'is_singular', 'is_sticky', 'is_attachment', 'is_tree',
     10    if (is_bool($logic)) {
     11        return $logic;
     12    }
    1813
    19         // Category, Tag & Taxonomy checks
    20         'is_category', 'is_tag', 'is_tax', 'in_category', 'has_tag', 'has_term',
    21         'is_product_category', 'taxonomy_exists', 'has_category',
    22 
    23         // Archive checks
    24         'is_archive', 'is_post_type_archive', 'is_author', 'is_multi_author',
    25         'is_date', 'is_year', 'is_month', 'is_day', 'is_time',
    26 
    27         // Special page checks
    28         'is_search', 'is_404', 'is_privacy_policy', 'is_page_template',
    29 
    30         // Post type checks
    31         'get_post_type', 'post_type_exists', 'is_post_type_hierarchical', 'has_post_format',
    32 
    33         // User & capability checks
    34         'is_user_logged_in', 'current_user_can', 'is_super_admin',
    35 
    36         // Sidebar & widget checks
    37         'is_active_sidebar', 'has_nav_menu', 'in_the_loop',
    38 
    39         // Multisite checks
    40         'is_multisite', 'is_main_site',
    41 
    42         // Plugin & theme checks
    43         'is_plugin_active', 'is_child_theme', 'current_theme_supports',
    44 
    45         // Feed & preview checks
    46         'is_feed', 'is_trackback', 'is_preview',
    47 
    48         // Content checks
    49         'has_excerpt', 'comments_open', 'pings_open', 'is_new_day',
    50         'has_post_thumbnail', 'has_shortcode', 'has_block', 'get_post_format',
    51 
    52         // Device & request checks
    53         'wp_is_mobile', 'is_rtl', 'is_customize_preview', 'wp_doing_ajax',
    54 
    55         // Error & validation checks
    56         'is_wp_error', 'is_email', 'is_serialized',
    57 
    58         // Query checks
    59         'is_main_query', 'is_paged',
    60 
    61         // WooCommerce conditional tags
    62         'is_woocommerce', 'is_shop', 'is_product', 'is_product_category',
    63         'is_product_tag', 'is_cart', 'is_checkout', 'is_account_page',
    64         'is_wc_endpoint_url',
    65     );
    66 
    67     $allowed_functions = apply_filters('widget_logic_allowed_functions', $allowed_functions);
    68 
    69     $logic = trim((string) $logic);
    70     if ('' === $logic) {
     14    if ($logic === '') {
    7115        return true;
    7216    }
    7317
    74     // Set up error handling
    75     set_error_handler('widget_logic_error_handler', E_WARNING | E_USER_WARNING);  // @codingStandardsIgnoreLine - we need this for error handling
     18    if (stristr($logic, 'return') === false) {
     19        $logic = 'return (' . html_entity_decode($logic, ENT_COMPAT | ENT_HTML401 | ENT_QUOTES) . ');';
     20    }
     21
     22    set_error_handler('widget_logic_error_handler'); // phpcs:ignore -- we have mode for debugging for admins
    7623
    7724    try {
    78         // Tokenize the logic string
    79         $tokens = widget_logic_tokenize($logic);
     25        $show_widget = eval ($logic); // @codingStandardsIgnoreLine - widget can't work without eval
     26    } catch (Error $e) {
     27        trigger_error($e->getMessage(), E_USER_WARNING); // @codingStandardsIgnoreLine - message is not dependent on user input
    8028
    81         // Parse and evaluate the expression
    82         $pos = 0;
    83         $result = widget_logic_parse_expression($tokens, $pos, $allowed_functions);
     29        $show_widget = false;
     30    }
    8431
    85         // Check if there are any unexpected tokens after the expression
    86         if ($pos < count($tokens)) {
    87             throw new Exception(esc_html__('Widget Logic: Unexpected tokens after expression.', 'widget-logic'));
    88         }
     32    restore_error_handler();
    8933
    90         return (bool)$result;
    91     } catch (Exception $e) {
    92         widget_logic_error_handler(E_USER_WARNING, $e->getMessage());
    93         return false;
    94     } finally {
    95         restore_error_handler();
    96     }
     34    return $show_widget;
    9735}
    9836
    99 /**
    100  * Generic error handler for widget logic
    101  */
    10237function widget_logic_error_handler($errno, $errstr)
    10338{
    10439    global $wl_options;
    10540
    106     // For testing, we want to see all errors
    107     $show_errors = true;
    108 
    109     // In normal operation, respect user settings
    110     if (!defined('WIDGET_LOGIC_TESTING')) {
    111         $show_errors = !empty($wl_options['widget_logic-options-show_errors']) && current_user_can('manage_options');
    112     }
     41    $show_errors = !empty($wl_options['widget_logic-options-show_errors']) && current_user_can('manage_options');
    11342
    11443    if ($show_errors) {
  • widget-logic/trunk/widget_logic.php

    r3434469 r3437733  
    44/*
    55Plugin Name: Widget Logic
    6 Description: Control widgets with WP's conditional tags is_home etc, for Enable Gutenberg widgets and new built-in widgets visit the settings page.
    7 Version:     6.07
     6Description: Control widgets with WP’s conditional tags is_home, is_category etc. in one place.
     7Version:     6.08
    88Author:      Widget Logic
    99Author URI:  https://widgetlogic.org
     
    1414
    1515include_once 'WidgetLogicAdminConfig.php';
    16 $cfg = WidgetLogicAdminConfig::getInstance();
    1716
    18 // Add a link to the settings page in the plugin description area
    19 add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($cfg, 'addDescriptionSettingsLink'));
    20 
    21 if ($cfg->isFullyEnabled()) {
    22     if (version_compare(get_bloginfo('version'), '5.0', '>=')) {
    23         include_once 'block/index.php';
    24     }
    25 
    26     include_once 'widget.php';
     17if (version_compare(get_bloginfo('version'), '5.0', '>=')) {
     18    include_once 'block/index.php';
    2719}
    2820
     21include_once 'widget.php';
    2922include_once 'widget/init.php';
    3023
Note: See TracChangeset for help on using the changeset viewer.