darrenjacoby / intervention

WordPress plugin to configure wp-admin and application state using a single config file.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting timezone through intervention without setting it in the DB: new posts are scheduled

tombroucke opened this issue · comments

Hi,

I just got to know Intervention, and have implemented it in a first project, but encountered a problem.
In a fresh install, the value for the timezone_string option is EMPTY, so WordPress assumes UTC +0. In my config/intervention.php, I set the timezone to Europe/Brussels, this is correctly reflected wp-admin/options-general.php. The DB value for timezone_string remains EMPTY.

When I create a new post or page, the "publish" button has been renamed to "schedule".

If I disable intervention, update the timezone_string to Europe/Brussels, and re-enable intervention (or just set timezone_string to Europe/Brussels in the DB), the issue is solved.

Is there a fix for this?

I'm having a similar issue with translations. In the plugins_loaded hook, get_locale() returns en_US, while the language is set to nl_NL in my config/intervention.php file. Database value is EMPTY. I need to update the database value in order to get the correct translation.

Am I missing the point? Is intervention only disabling the options, but not settings their values?

Hey @tombroucke,

I will check on the first issue regarding the timezone.

I'm using the WordPress switch_to_locale function for languages, with the init hook. https://github.com/soberwp/intervention/blob/main/src/Application/General.php#L125-L134

The plugins_loaded hook fires before and therefore Intervention has not yet applied the function.

Regarding database values, Intervention uses pre_option when available, and therefore does not update the DB. Here's the thread on the reasoning behind that. #64

You can import values under Tools > Intervention > Application which will run update_option and update the database values according to the Intervention config file. (please do a database backup prior!). This should solve your issue with the plugins_loaded hook firing first.

@tombroucke I seem unable to reproduce the timezone issue with a post changing from publish to schedule. Do you have any other plugins installed which may affect this?

Hi,

Please see the screen recording below. Fresh install, twentytwentyone & intervention as the only active plugin. When I deactivate intervention, I can correctly publish new posts.

<?php
return [
    'wp-admin' => [
        'editor|shop_manager' => [
            'common' => [
                'adminbar' => [
                    'comments' => false,
                    'search' => false,
                    'updates' => false,
                    'site' => [
                        'themes' => false
                    ]
                ],
                'updates' => false,
            ],
            'comments' => true,
            'dashboard' => 'pages',
            'tools' => true,
        ]
    ],
    'application' => [
        'theme' => 'twentytwentyone',
        'general' => [
            'membership' => false,
            'default-role' => 'subscriber',
            'timezone' => 'Europe/Brussels',
            'date-format' => 'j F Y',
            'time-format' => 'H:i',
            'week-starts' => 'Mon',
        ],
        'writing' => [
            'emoji' => 'false',
        ],
        'reading' => [
            'posts-per-page' => 10,
            'posts-per-rss' => 10,
            'rss-excerpt' => 'full',
        ],
        'media' => [
            'sizes' => [
                'thumbnail' => [
                    'width' => 300,
                    'height' => 200,
                    'crop' => true,
                ],
                'medium' => [
                    'width' => 800,
                    'height' => 800,
                    'crop' => false,
                ],
                'large' => [
                    'width' => 1920,
                    'height' => 1920,
                    'crop' => true,
                ],
            ],
            'uploads.organize' => true,
        ],
        'permalinks' => [
            'structure' => '/%postname%/',
            'category-base' => 'category',
            'tag-base' => 'tag',
            'search-base' => 'search',
        ],
    ],
];
Screen.Recording.2021-12-20.at.09.14.23.mov