• Resolved evergf88

    (@evergf88)


    Hello! i have a problem with the latest version of AREOI.

    The website ignores the values loaded in “padding” and “margin” fields and always the divs have zero padding/margin.

    I use a custom theme developed by myself and it worked well with the version 1.3.3 of the plugin. But in the newer versions it fails.

    With another theme, like twenty-twentythree, works well.

    Are there any function to enqueue in my functions.php to fix this problem?

    Thanks for your assistance.

    The page I need help with: [log in to see the link]

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Miles

    (@areoimiles)

    Hi @evergf88

    Thank you for flagging this issue. I’m not sure what could be causing this, however if you could send me the code for a page that you have applied margin / padding to, I can set it up locally and hopefully find the issue for you. You can get the relevant code by editing a page, then clicking the three dots in the top right and then select Code Editor.

    Also, if the issue is only happening on your custom theme, it may be worth clearing out your functions.php file just to see if that resolves the issue. If it does then you can add your functions back in one at a time to identify the cause.

    If you could send me the above I can look into this further for you.

    Thanks
    Miles

    Thread Starter evergf88

    (@evergf88)

    Ok, i send you the code of the index of my web and the functions.php where i can’t find anything weird.

    And i try to comment the most of lines in functions.php but it keeps failing.

    You can view the actual result in the actual web url.

    Another weird thing is that actually another values like ‘row-cols’ or aligns works well. The only fail point are the margins and paddins

    Thanks for your help

    https://drive.google.com/file/d/1m6YKim9WKTtr7pp_fKAjX6yaYjd1tK1i/view?usp=drive_link

    • This reply was modified 1 year, 6 months ago by evergf88. Reason: forgot include the file
    Plugin Author Miles

    (@areoimiles)

    Hi @evergf88

    Thank you for the additional details. I have tried your index-page-code and it works as it should do when I use it in my theme.

    For margin and padding these additional styles get added to the head of your page and looking at the URL you provided I can see no styles have been added. So, I think the best thing to try next is to see what is being outputted from the style function within the plugin. If you open this file: plugins/all-bootstrap-blocks/class.areoi.styles.php and add the following code at line 244:

    echo '<pre>'; print_r($blocks); echo '</pre>';
    echo $styles; die;

    This should output an array of all of the blocks the plugin is able to find on the page and then the generated CSS. Please could you try this and send me the output, if there is any?

    Apologies in advance, because I can’t replicate the issue it may take us a bit of back and forth to get this sorted for you.

    Thanks
    Miles

    Thread Starter evergf88

    (@evergf88)

    Effectively, $blocks returns a empty array: Array()

    And $styles returns a empty string: “”

    Somewhere, fails generating this vars

    Thread Starter evergf88

    (@evergf88)

    Miles, thanks for your help to reach this point.

    The key of my problem is there, in class.areoi.styles.php file. This class, in order to make the final recap to add the required inline styles, in the add_block_styles method merges 4 arrays previosly processed and then merges then (line 228):

    $blocks = array_merge( $standard_blocks, $page_reuseable_blocks, $reuseable_blocks, $template_blocks, $widget_blocks );

    I dump the values of each one and only $widget_blocks have an array with values inside. The others are all empty. That is the problem.

    $template_blocks doesn’t apply to my theme because there is not a modern block theme (like the anothers themes tried for myself to report this issue, e.g. twenty-twentythree).

    I think that the necessary variable to generate the inline styles is $standard_blocks. The key to generate this var are in the lines 179-180:

    global $page;
    $standard_blocks = ( $page === null ? array() : parse_blocks( get_the_content() ) );

    When i dump the value of $standard_blocks, it’s a empty array. That’s mean that the $page global variable are null (checked by var_dump()). If i replace the conditional with:

    $standard_blocks = parse_blocks( get_the_content() );

    Ualá, the styles are loaded correctly.

    Then… Why the $page variable returns null here? Is only a problem of my theme or happens to another classic themes?

    Regards

    Plugin Author Miles

    (@areoimiles)

    Hi @evergf88

    Massive thank you for all of your work debugging the problem! I’m not sure why the global $page is null for you, however I will be releasing an update next week and now that you’ve found the issue I will be able to put a fix in place that should resolve this for you.

    For the time being if you just make the change you suggested directly in the plugin then I will send you an update when the new version has been released with a fix.

    Thank you for your help and patience!

    Miles

    Thread Starter evergf88

    (@evergf88)

    Thanks for all Miles. Regards

    Plugin Author Miles

    (@areoimiles)

    Hi @evergf88

    I’m just trying to find a resolution for your issue and hoped you would be able to test something for me?

    Would you be able to change this:

    $standard_blocks = parse_blocks( get_the_content() );

    to this:

    global $pages;
    		
    $standard_blocks = ( $pages === null ? array() : parse_blocks( get_the_content() ) );

    If you make this change do the styles get applied as they should do?

    Thanks

    Miles

    Thread Starter evergf88

    (@evergf88)

    Hi Miles.

    Unfortunately, both the $page and $pages variables I receive with null value and the styles are not applied.

    Possible solution?

    ?Maybe replacing the use of the global $page with…

    $page = get_the_ID();

    And the conditional with…

    $standard_blocks = ( $page === false ? array() : parse_blocks( get_the_content() ) );

    In my reduced understanding of the WP Core, the $page variable is equivalent with the return value of “get_the_ID()” with the difference that when is not value, it returns “false” instead “null”.

    I tried this code and it works ok. I hope it can help

    Regards

    • This reply was modified 1 year, 5 months ago by evergf88.
    • This reply was modified 1 year, 5 months ago by evergf88. Reason: added possible solution
    Thread Starter evergf88

    (@evergf88)

    @areoimiles thanks for all your help, but I must remind you that the problem persists in the latest versions (1.3.7 and 1.3.8) and that the statement that causes me the problem remains unchanged in the AREOI code.

    Currently, I apply this patch in class.areoi.styles.php, lines 185, 186 to make the plugin working ok in my sites:

    $page = get_the_ID();
    $standard_blocks = ( $page === false ? array() : parse_blocks( get_the_content() ) );

    Regards best

    Plugin Author Miles

    (@areoimiles)

    Hi @evergf88

    I’m just waiting for a response from another user, I want to make sure that your suggested fix doesn’t cause issues for them. If I don’t hear back from them in a couple of days I will implement your solution in the next release.

    Thank you for your patience!

    Miles

    Plugin Author Miles

    (@areoimiles)

    Hi @evergf88

    I never got a response from the other user so I have gone ahead and implemented your suggested fix. Hopefully, this resolves your issue going forward. Thank you for your patience on this and if you have any issues in the future please don’t hesitate to get back in touch.

    Thanks
    Miles

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Fail to apply paddings and/or margins in the latests version with custom theme’ is closed to new replies.