Wojtek Naruniec

Deploy Studio sites to WordPress.com

Recently, in WordPress.com, we launched a new local development environment tool called Studio. It allows creating local WordPress sites and sharing them with clients for review.

Sharing those demo sites is an excellent feature, but it can’t replace the ability to synchronize the local Studio site with a WordPress.com site. As such a feature is not available yet, I used GitHub deployments feature released earlier this year to hook Studio with WordPress.com. See how you can use both together.

Create a Studio site

First, download Studio, install it, and create a site. Install some plugins and a custom theme, and maybe use something you developed recently. See how my test site with a Kadence theme looks in Studio:

Create a GitHub repository

When your local Studio site is ready, create an empty GitHub repository. This can be either Public or Private and will be used to hook your local Studio site with WordPress.com.

Push the site to the repository

Now, push the Studio site code to the newly created repository. GitHub deployments allow setting up deployments granularly, separately for each plugin and theme, but to mimic the basic development project flow, let’s plan to keep the whole wp-content/ in the repository.

See the detailed steps below:

1. Open the Studio site in Terminal and init the Git repository

Initialize local Git repository inside wp-content/.

1. In the Studio site’s Overview tab, click Open in -> Terminal

2. Change the directory to wp-content and initialize Git repository:

cd wp-content
git init

4. Create a .gitignore file, and using your editor, add the following content:

.DS_Store
db.php
mu-plugins
database

5. Add and commit all changes:

git add .git commit -m "Initial commit"

6. Add a new repository as a remote:

git remote add origin git@github.com:USER/REPOSITORY.git

7. Push to the remote repository:

git push origin master

2. Create a site with a Creator plan

The GitHub deployments feature is available for WordPress.com Creator and Entrepreneur plans, so ensure you have a WordPress.com site with one of those plans before proceeding. Of course, you can use a staging site for such a site to avoid testing on production.

3. Set up GitHub deployments

  1. Navigate to your WordPress.com Site -> GitHub Deployments
  2. Connect your GitHub account if needed
  3. Select the repository
  4. Leave the default ‘Deployment branch’
  5. Leave the default value of ‘Destination directory’, which is /wp-content
  6. Enable ‘Automatic deployments’
  7. Save
  8. Use the three-dots menu and trigger an initial deployment

That’s it! Now, you can navigate to WP Admin and confirm that plugins and themes exist. Note that this only deploys the code, so you will need to manually activate plugins and themes and synchronize any changes made in WP Admin.

4. Continuous development

With Automatic deployments enabled, any subsequent commit pushed to the repository will be automatically deployed to the site. See how it looks after pushing another commit to the repository:

Further reading

This is just a basic flow, and the GitHub Deployments feature allows setting up much more complex flows, e.g., deploying each plugin and theme from its own GitHub repository or using Composer as one of the build steps.

Check the docs to learn more about GitHub Deployments and Studio, and share any questions or feedback you have.

Should I use book summarizing services?

I was recently recommended a book-summarizing subscription service called Blinkist. They advertise to have summarized versions of over 6,500 non-fiction books, each available to listen to or to read. They say the service is “Perfect for curious people who love to learn, busy people who don’t have time to read, and even people who aren’t into reading.”.

Honestly, I was feeling a bit skeptical. Pausing for a bit and thinking about my school years, I remember that I’ve never used book summarizing for school reading. I loved reading books and was reading a book once every one or two weeks. At that time, I was mainly reading fiction books, varying from fantasy and science-fiction to horror and thrillers. Another part was school reading books required as a part of classes. The latter was often considered boring, especially for teenagers, and some book-summarizing options were available. Still, I decided not to cheat and just read the books.

Now, I consider myself a “curious people who love to learn” and a little less a “busy person who doesn’t have time to read.”, so why not try? Lucky working for Automattic, I recently got access to a corporate subscription to Blinkist Business for the remainder of this year. This reduced the entry barrier and opened an opportunity to try the service.

I chose “Turn the Ship Around” by David Marquet as the first summarized book to try. I picked this one as I was planning to read this book after all. A few months ago, I watched the amazing video “What is leadership?” by the book’s author. It resonated with me, so the book has been on my list since then.

The summarized book, or a “blink,” which is the term used by Blinkist, gives a rough idea of what the book is about. However, I have a feeling that it only gives a superficial understanding. Relying on Blink, I would miss nuances, examples, or exciting anecdotes shared by the author in the book. I don’t like the voice of the narrator reading the book too much, too, as it feels a bit like Ivona. On top of that, my FoMo ghost makes me feel a bit uncomfortable if I read a summarized book and move on.

I think I won’t use Blinkist to “read books” as I still prefer reading the full version of the book. I may only try that to power the decision on which book to pick up next. Which one should I read after I’m done with The Great Mental Models: Turn the Ship Around!, The Five Dysfunctions of a Team, or The Making of a Manager? I will see if Blinkist helps me make this decision.

Bonus: What is leadership? video made by the book’s author, David Marquet, is 10x better than the Blink of that book. This looks like a way to go: before relying on Blink, check a TED-like book overview made by the author.

Top 10 Wolfram Alpha queries for a developer

Wolfram Alpha is a computational engine that can provide expert-level knowledge-based answers to questions. I use it to help with everyday work, mainly to perform simple calculations or conversions and for some analysis.

I compiled a list of my top 10 queries in random order:

Timestamp calculations
timestamp for June 1st, 2023, 13:34 UTC
I can quickly get a timestamp for a date in any format or perform other date conversions.

Average of a few numbers
average of {254ms, 419ms, 286ms, 295ms, 289ms} in seconds
It calculates an average of listed numbers and converts milliseconds to seconds. It’s usually quicker than opening a spreadsheet, adding numbers, and writing a formula.

Currency conversions
1700 USD to PLN
I can convert any currency using live rate data.

Basic IP details
check ip 79.110.202.123
I can see basic information for a given IP address.

Date difference calculations
weekdays until June 27th
Calculate how many work days are left before the given date (e.g., deadline).

Details about addresses
state for zipcode 60104
Get a state for a given zip code.

Weight conversions
convert 10lb to kg
I used it a lot when working on e-commerce.

Logical expressions
P && (Q || R)
I can analyze logical expressions and check if they can be simplified.

Colors conversions
rgb 79, 148, 212
It allows converting colors from RGB to hex and many different formats.

Calculate string length
string length “Lorem ipsum dolor sit amet, consectetur adipiscing elit.”
I can check string length.

Do you use Wolfram Alpha too? Do you know any other helpful queries?

Staging Sites on WordPress.com

WordPress.com users have been missing the staging sites feature for years. Here are some quotes I found on the forums:

Does the wp.com business plan offer a staging environment or a recommendation on how to make deployment go smoothly?

julescowan1

How do I set up a staging website?

morganelaine51

I want to work on another theme on a live site. Can I create a staging site to do that in a wordpress.com site?

dlshio

Do any of the WordPress.com plans have staging features? A client of mine has a Business hosting account and I’m trying to understand whether there’s something built in or not. If not, can you suggest options? Thanks in advance

antimofm

As a developer working on my site or a contractor working for a client, I agree, as I used a staging site for most projects I was involved with. The feature can also be helpful for non-developer users, e.g., bloggers or site owners, as they can create a staging site, play with some themes and plugins, experiment with content, and then apply those on the production site if they like the outcome.

I’m happy that it changed this month! Along with my team, we’ve added support for staging sites on WordPress.com, and I had a chance to lead the technical part of the project. Now users on Business and Commerce plans can add one staging site for their production site. The feature is powerful, creating an environment almost like the production environment. 

We still miss the feature allowing users to synchronize data from production to staging or vice versa. Still, at least for one direction, users can use the “cattle not pets” approach and delete the staging site to recreate it fresh based on the production site. 

If you want more details, check out the official staging sites announcement.

Crazy Magento 2 core patches

Last year I took over a maintenance of the Magento 2 Commerce site. One of first tasks was adjusting the site to meet industry standards as it was a bit messy. The whole content of vendor/ directory was kept in the repository and there were about 30 patch files placed in the site root, without any information which were applied and in which order. Most of them looked as provided by M2 support. I needed to clean this up – to figure out which patches are applied, in which order they are applied and finally find a way allowing me to remove vendor/ from the repository and to be able to apply patches dynamically, during the deployment.

This was a challenging task – I needed to keep comparing the vendor/ contents with the version of this directory coming from clean Magento 2 site, and then keep applying patches until directories were the same. I was able to do this, it proved that about 25 of these patches were really applied.

Recently I wrote a blog post explaining how to deal with the second part of this challenge – check Rocket Web blog to see how to apply Magento 2 core patches.

How I started career thanks to Ultima Online

About 13 years ago I was in college and used to play Ultima Online. It’s a fantasy role playing game, actually it’s the first game of massively multiplayer online role-playing game genre (MMORPG). I didn’t play too much on official servers and played mostly on server emulators. They were created by a community who reverse engineered the game and created its own servers.

While playing more I was curious how it all worked so I dug a bit into emulators. I was trying to set up a server using different emulation software, trying to build sceneries and buildings. It was challenging to find online resources which could help in working with emulators. It was a few years before StackExchange was released so I could only get help on bulletin boards or on IRC channels.

At some point I gathered a bunch of Ultima Online materials and spotted a web development tutorial in a computer magazine. As I already tried programming on Amiga a couple years earlier, web development looked encouraging. I tried and soaked into that completely. Soon I created my first website and started sharing my experience and materials with other people who played and mod Ultima Online. I used PHP to run the website and stored site data in text files. I may write more about this some day.

The site was working for the next few years and became popular in the Ultima Online community in Poland. In the meantime I started working on other websites. One of these sites became my first paid web development job, and after some time web development became my main source of income.

Currently the website is offline, but Ultima Online still has active servers which could be played on. In about two weeks, on September 24th it will turn 18 years old!

It looks like it’s worth it to play games, and in general, have a hobby. Gaming led me to a career in web development which actually also became one of my hobbies.