Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update class-redux-page-render.php #4043

Closed
wants to merge 1 commit into from

Conversation

andrejarh
Copy link

@andrejarh andrejarh commented Nov 30, 2024

This resolves PHP warnings like:
Deprecated: Implicit conversion from float 0.2 to int loses precision

This resolves errors like:
Deprecated: Implicit conversion from float 0.2 to int loses precision
@andrejarh andrejarh closed this Nov 30, 2024
@andrejarh andrejarh reopened this Nov 30, 2024
@kprovance
Copy link
Member

I need you to explain in detail the advantages of this, including a use case that I can try on my end. Too often, people want to mess with the core, and it blows up down the line, which means I have to fix it. So, let's be sure.

@andrejarh
Copy link
Author

Sure @kprovance
image

PHP ver: 8.1.29
Please try the follow example:

Redux::setSection( $opt_name, array(
    'title'     => esc_html__('Colors', 'option-plugin'),
    'icon'      => 'fa fa-tint',
    'fields'    => array(
      
        array(
            'id'       => 'boxed_site_shadow_color',
            'type'     => 'color_rgba',
            'title'    => esc_html__('Shadow color', 'option-plugin'),
            'subtitle'  => esc_html__('Defines the page shadow. ', 'option-plugin'),
            'transparent' => false,
            'options'       => array(
                'clickout_fires_change' => true,
            ),
            'default'   => array(
                'color'     => $color_1,
                'alpha'     => 0.15
            ),
            'required' => array(
                    array('boxed_fullwidth','equals','0'), 
                    array('boxed_add_shadow','equals','1'),                   
            ),  
            'compiler' => true,
        ),
        array(
            'id'        => 'submenu_background_nav_dark',
            'type'      => 'color_rgba',
            'title'    => esc_html__('Submenu Background Color', 'option-plugin'),
            'subtitle' => esc_html__('Pick a background color for the submenu.', 'option-plugin'),
            'default'   => array(
                'color'     => '#fff',
                'alpha'     => 0.95
            ),
            'compiler' => true,
            'options'       => array(
                'clickout_fires_change'     => true,
            ),                    
        ),
        array(
            'id'        => 'submenu_border_nav_dark',
            'type'      => 'color_rgba',
            'title'    => esc_html__('Submenu links border color (desktop)', 'option-plugin'),
            'options'       => array(
                'clickout_fires_change'     => true,
            ),
            'default'   => array(
                'color'     => '#000',
                'alpha'     => 0.1
            ),            
            'compiler' => true,       
        ),        
    ),
));

Explanation:
Setting 'alpha' default value to 0.1 causes PHP warnings, because it is a numeric value.
Setting it to "0.1" is OK, because it is a string.
But alpha kind of is a numeric value and in my case it was written this way.

kprovance added a commit that referenced this pull request Dec 2, 2024
@kprovance
Copy link
Member

It took me a hot minute to figure out why I couldn't reproduce this. It only occurs when the show_default is set to true. Replicated and contributed fix applied (manually) and credited. Much obliged.

@kprovance kprovance closed this Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants