MT with git part two …

This topic contains 18 replies, has 2 voices, and was last updated by  Sebastian 4 weeks, 1 day ago.

Author Posts

olleka

Hi. Sorry to bring this up again. But we can not get it to work. Somehow it seems that the active.styles.css can be overwritten with the cached old copy.
Here is what I did.
I changed a simple rule in the dev site to “letter-spacing: 0.1px” instead of “letter-spacing: 0”

h2 a {
color: rgb(48, 49, 48);
word-spacing: 1px;
letter-spacing: 0.1px;
}

1. I verified that the file was pushed to GitHub. Check!
2. I waited 20 minutes and had a look at the webpage in not logged in mode “letter-spacing: 0”
3. I loaded the same page without servercache via a script I have. “letter-spacing:0.1px”. Right!
4. I went direct to the https://www.hamnen.se/wp-content/micro-themes/active-styles.css “letter-spacing:0.1px” Right file is in the right place on the live site.
5. logged in and checked css with inspector tool. “letter-spacing:0.1px”. Right
6. Opened Microthemer to check the CSS rule there. “letter-spacing: 0”. Wrong.
7. I opened MTs ”Show generated CSS” ” letter-spacing: 0”. Wrong.
8. Opened the link active-styles.css (not editable here) in ”Show generated CSS” page “letter-spacing:0.1px” Right!?.
9. Closed down MT and checked CSS with inspector in logged in mode. “letter-spacing: 0”. Wrong!
10. Logged out and checked point 3 and 4 again. “letter-spacing: 0” Wrong.
11. So now active-styles.css contains the old CSS from before. Gah!

So it seems to me a bug somewhere either the cache or MT. Can MT active-styles.css be owerwritten just by open it and close it without doing any changes?
Furthermore when I open MT in the live site why is it showing the wrong style. It should show the active-styles.css? Unless it shows a cached version from before and then saves the wrong styles when MT is closed down.

Regards
Olle


Sebastian

Hey Olle,

MT displays settings stored in the database. It doesn’t read from active-styles.css as some of the UI data isn’t in the form of pure CSS. Also, when you use the Show generated CSS feature within Microthemer, it re-saves the settings to ensure the stylesheet reflects the latest MT changes (not useful in your special case of course). Because you did this action on the live site, it updated the stylesheet using the out of date style settings in the live database.

So with your system, you probably needed to wait longer than 20 mins for the cache to clear, as well as keep out of the MT interface on the live site. Or sync the database values, but that can be fiddly with the wp_options table, as I mentioned in our previous thread.

Cheers,
Sebastian


olleka

I thought you said before that it would be enough to move just the active-styles.css to the live site.
And now you are saying I need the database also. I’m a little confused.

So with my git setup dev->live how would I move safely the new CSS from dev to live?
Would that be a export -> import of a design pack?

If I sync the wp_options and just sync
preferences_themer_loader
and
microthemer_ui_settings
Would that solve my problems?

In my other sites I have moved the whole site. Therefore I have never had this problem.
But surely it would be a good idea to have MT to Work with git?

Regards
olle


Sebastian

Hey Olle,

I was saying you can just Git sync the stylesheet if you want to keep your Git setup simple. But that means you can’t use MT on the live site. If that is a downside for you, then I recommend also syncing the database as a solution.

So yes, syncing those two options will do the trick:

preferences_themer_loader
microthemer_ui_settings

And if you’re taking the time to sync databases, you should also sync the wp_micro_revisions table, so the history is synced too.

Cheers,
Sebastian


olleka

Ok thanks for the clarification.

Since I can’t use MT in the live site. What do you think about deactivating MT in the live site and have MTs CSS code load from the functions.php “inactive” settings?

With that I don’t need the database right?

Regards
Olle


Sebastian

Yes absolutely. That will save you from accidentally using MT on the live site 🙂


olleka

So I deactivated MT. But it still shows the wrong CSS file.
https://www.hamnen.se/wp-content/micro-themes/active-styles.css?mts=8916&ver=c21fc1363f4681f0ab36881a5360bf16
Not the https://www.hamnen.se/wp-content/micro-themes/active-styles.css

Do I need to remove MT compleatly? And remove the MT fields from the wp_options table also?

Regards
Notify me of follow-up replies via email
Submit
Olle


olleka

So that is because the database tables are still there in the live site right?

Gah. This turned out to be a nightmare. MT is not really designed for this kind of scenario.

Consider this. If I remove the fields in the database (by deleting MT and the settings) Probably It will serve the right CSS file. Just guessing.

But If I then synk the live-> dev database befor the next development cycle. What will be shown in the dev site? Because the MT settings is not in the database thet I pull from live site.

Sort of impossible to get this right. I surprised you have not any fix for this scenario. Or am I the first person working like this? How does other people using MT in a dev-live stup normally do?

Regards
Olle


Sebastian

Hey Olle,

You don’t need to delete any database content. Just deactivate Microthemer (or optionally uninstall). Did you remember to push the local version of active styles again and wait the the cache to clear?

If you pull the database from the live site in future that will overwrite your (most up to date) local MT settings though. So really, I think your only option is to sync the local DB settings for MT with the live site. That way everything is equivalent. And you can pull data from the live DB in future without losing anything.

Cheers,
Sebastian

P.S. The normal way to work locally is to export your local settings to a zip file which you install on the live site. You are indeed the first person to ask about GIT integration methods.


olleka

Well yes. If you go to
ttps://www.hamnen.se/wp-content/micro-themes/active-styles.css
And search for
.hamnenplay div h3, .hamnen-play-modul .category-hamnen-play div h3

You can se the CSS i pushed to live. So its the right file.

However If I go to the page and inspect the element it shows the wrong CSS and that CSS is still rendered from the link
https://www.hamnen.se/wp-content/micro-themes/active-styles.css?mts=8916&ver=c21fc1363f4681f0ab36881a5360bf16

I did empty the cache several times.

If I read the php code in functions php mts=1 when MT is off? and if I go to
https://www.hamnen.se/wp-content/micro-themes/active-styles.css?mts=1&ver=c21fc1363f4681f0ab36881a5360bf16 The CSS is right.

Very strange.

Regards
Olle


olleka

Sorry mts=0 I can by anything but 8916. I cannot see why that is still there.

If I remove MT will it also remove the database fields?

If I then reinstall MT will the “inactive” setting pick up the “old” CSS file and start the count from 0

Thanks


Sebastian

Hey Olle,

If you install MT it won’t delete the DB fields unless you choose the “Upon Uninstall, Delete ALL Microthemer Data” option on the MT Preferences > Inactive tab. That will also delete everything in the /wp-content/micro-themes/ folder, including the active-styles.css stylesheet. So you would need push the file again.

Your make an interesting point I hadn’t considered re the mts=1 piece of “inactive” code you pasted to your theme’s functions.php file. You can manually change that number to anything you want. So, set a unique number just before pushing code to git, and then the stylesheet will have a unique URL on the live site, which will refresh your server’s cache of that file.

Cheers,
Sebastian


olleka

Aha so you mean I can put something like
$mts = ‘?mts=’ . (!empty($p[‘num_saves’]) ? $p[‘num_saves’] : 1234);
In the functions php? Before I push to live?

Regards
olle


Sebastian

Or rather simply:

$mts = 1234;

Because $p[‘num_saves’] pulls from the database, which you don’t want.

Cheers,
Sebastian


olleka

Ok 🙂
Il” have a go at it.

Regards
olle


olleka

Hm i got a ” Failed to load resource: the server responded with a status of 404 () active-styles.css1234:1″


olleka

Ok, got it. The code should probably be
$mts = ‘?mts=’ . (1234);

Regards
olle


olleka

It works!

I’m a happy man now 🙂

Regards
Olle


Sebastian

Ah wonderful, I’m really glad we got there in the end 🙂

Sorry about the incorrect $mts example.

You must login or register to reply to this topic.