Categories
Uncategorized

How to reinstall Local by Flywheel on MacOS

As you may know, Local by Flywheel is a very useful tool for the ones that want to create WordPress websites on their local computers (at least, this is its first purpose).

The idea for this article appeared when I got stuck with the same problem for the second time while trying to remove this program from my laptop and install it from scratch. This is the second time I had this little issue and I don’t want to be any third time. And that’s the reason why I’m writing this article and maybe it will help some other users too.

VirtualBox gets installed too when using Local by Flywheel. Basically, a virtual machine is created to host all the WordPress websites. Now, when you want to remove everything for good, there are two steps that need to be taken:

  1. open VirtualBox and remove the machine;
  2. download the VirtualBox package as you would install it and run the VirtualBox_Uninstall.tool script;
  3. move Local by Flywheel to the trash.

This second step is the one that needs to be done instead of just moving VirtualBox to the trash. If you don’t do this when trying to install back the Local by Flywheel, it will get stuck and you won’t know why is this happening. Well, it seems that if that script isn’t used, VirtualBox is not actually removed. I won’t go into more details.

Long story short, this is the right way to uninstall Local by Flywheel and make sure that you’ll be able to install it back at some point.

Categories
Uncategorized

How to use a different logo for each language with Polylang

Every now and then I have some period of times when I feel an urge of giving back to the community and keep an eye on the public forums of wordpress.org. The good part is that this synchronizes with the moments when I’m not that busy with my day-to-day job.

This time I found a pretty interesting question related to the Polylang plugin. I usually recommend using the WPML plugin since it’s a pretty great tool (even if it is not easy to be used by a new WordPress user) but this time the question was about a different multi-language plugin. Don’t get me wrong: I like that Polylang is a free plugin that can be used for simple websites.

Let’s get to the point: the question raised by a user on the public forums was about how to have a different logo for each language. I checked a couple articles and topics but I couldn’t find an article to present a solution. I always look for new challenged and that’s why I started working on a custom code to do the job. And here’s the solution that came out.

The code

Here’s the code that need to be added to your website for using different logos when having the English and French languages:

function custom_polylang_multilang_logo( $value ) {
	if ( function_exists( 'pll_current_language' ) ) {
		$logos = array(
			'en' => wp_get_attachment_image('1555', 'full'),
			'fr' => wp_get_attachment_image('1556', 'full'),
		);
		$default_logo = $logos['en'];
		$current_lang = pll_current_language();
		if ( isset( $logos[ $current_lang ] ) )
			$value = $logos[ $current_lang ];
		else
			$value = $default_logo;
	}
	$html = sprintf( '<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>',
            esc_url( home_url( '/' ) ),
            $value
        );
	return $html;
}
add_filter( 'get_custom_logo', 'custom_polylang_multilang_logo' );

The logos

Now we have the code, but it cannot know what images to use from the media gallery. Once you uploaded the logos, simply get the ID for each one and replace the 1555 and 1556 in the code above with your values.

How to get the image ID? When opening a logo image in the media library, the link looks something like this:

https://www.example.com/wp-admin/upload.php?item=205

The 205 value is the one that’s needed here. 

Where to add the code?

There are two ways to add the code to the website:

  1. Copy the code that resulted (with the two IDs changed) to the functions.php file of the current theme;
  2. Use a plugin like My Custom Functions. This way, the code will stay there even when changing the theme.

Adding one more logo

If there are more than two languages used, the change is pretty simple. Just simply copy this line of code:

'en' => wp_get_attachment_image('1555', 'full'),

, replace the en part with a new locales (the full list of locales can be found here), and add it right after this line:

'fr' => wp_get_attachment_image('1556', 'full'),

Don’t forget about the logo ID and that’s all. This part of code should look like this:

'en' => wp_get_attachment_image('1555', 'full'),
'fr' => wp_get_attachment_image('1556', 'full'),
'ro' => wp_get_attachment_image('1557', 'full'),

I guess that this solution is needed when a website has some sort of text inside the logo, and it needs to be different in each language. I cannot imagine another situation when someone would have a different logo for different countries 😅

Let me know in the comments area if this did the trick for you or you need a little help with it.

Categories
Uncategorized

What did I learn about WordPress Starter Content?

I spend the last two days playing with Starter Content option that was introduced in WordPress 4.7. I’ve heard about this a long time ago but I never took the time to step back and give it a try. Since I’m working on a new theme for WordPress.org, I was thinking that it’s time to see how this feature can help me.

Why do you need this starter content and, most important, why a new article when there are already some very helpful resources out there?

Well, first of all, I think that I learned a lot of things in these two days. And, second of all, I really have to share this. Other users that might wanna use this on their theme really need to know a few things. Are you ready?

There’s an article that can be used as a starting point

There’s this article that you can use to learn some basic things like when was this option added to WordPress or how should the config look like. However, there are just some small pieces of code that you can copy and hope for the best. I’m saying this because some parts are not actually working but we’ll talk about that a bit later.

There are already a few elements included by default

Here’s the default config that’s merged with the one that you’re adding to the theme (or to a plugin if going this way): https://github.com/WordPress/WordPress/blob/master/wp-includes/theme.php#L2002

Basically, you have a few widgets, menus, and pages that you can already use without being needed to create them from scratch. Basically, you’ll be able to set the homepage and the posts page very easily with just a few lines of code. However, there’s no post included in this core content which looked a bit odd to me. I mean, WordPress main element is… the post. Why are only pages the only type of posts included by default? Well, the answer to this question leads me to the next point of my post.

The posts cannot be used with starter content

This is the main part that almost made me give up and delete everything I’ve done. However, I tend to at least understand why is a thing happening and that’s what I was gonna do this time too. So, after a couple hours, I made the connection that the posts created by starter content were saved with the status of auto-draft and that’s why nothing was showing on the blog archive. Basically, what I was looking to add some posts (11 to be more precise) and show all of them on a page through some custom widgets. Everything worked fine but the posts part was a dead-end. However, the solution that I used, even though it’s not a fancy one, was this code:

function post_status_customizer_change( $query ) {
	if ( ( 1 == get_option( 'fresh_site' ) ) && is_customize_preview() )
      $query->set('post_status', 'auto-draft');
}

add_action('pre_get_posts','post_status_customizer_change');

Using this code I was able to include the posts in the main loop and get them displayed as needed.

All in all, these were the main things that I learned from playing with the starter content. It’s a nice feature so big shout-out for everybody that worked implementing it. Since the WordPress.org system is still relying on the same default preview content for all the themes, I think that starter content is a breath of fresh air for everybody who wants to stand-out and show what his theme can do.

P.S. This is an article that I wrote at the end of the day, right after I closed PhpStorm. If you see any bad grammar or something wrong, please have mercy. I’m doing my best and still learning 😁

Categories
Uncategorized

There’s a new Hackathon in town

Pixelgrade’s first Hackathon was quite a strike from many points of view. I’m happy I had this experience with the team I’m working next on a daily basis. In this article, I want to share with you my thoughts on how things worked out from my perspective.


The place

Which could be the best and most productive place to play with ideas and make them happen? Not an office, that’s for sure. We went to our favorite cabin in the mountains, a very beautiful and cozy place where we feel welcomed every single time. In the end, we wanted some time for ourselves for running this event, but also for socializing and sharing stories.

We kicked-off the day with a relaxed pitching session where each of us tried to convince at least one-two other folks to work for particular ideas (we were nine, so not too many options). After a round-up of presenting ideas, debating which one makes more sense to invest in, and coming to a conclusion (thanks to Răzvan, the coordinator of this entire experience), we started working. We had 36 hours to play around and make things come true.

The projects

It’s funny that, in the end, all of us pushed the boundaries a little bit and got out of the comfort zone. Some of us needed more brainstorming sessions while others were quite confident about the technology they will use to make their idea happen. However, the nicest thing was that each of us learned something new in different areas: some extended their technical skills while others boosted their soft abilities.

Let me briefly introduce you each project, and hopefully, I will come back with updates once we have them.

#1—Mirroring

Mirroring

A web app that gives you the chance to use your smartphone to something else, other than scrolling the news feed on Facebook. It should be a game for at least two players, and the rules are pretty straightforward: each player is the host at some point, and the other ones are simply competitors. The hosting puts his phone in a certain position, and the opponents need to simulate it. The player that has the most accurate reply wins the game.

After 36 hours of hard work (from research to coding) this team achieved at least two small wins: they finished almost the entire look-and-feel regarding design and founded the algorithm to create an animation depending on the moves of the phone. I must confess I was really worried about the complexity and difficulty of this project, but I was impressed with the huge progress they did.


#2—Tonus

We already know that music makes everything easier (and better). Since sharing is caring and good music can drive a positive impact, why not sharing what you’re listening to the folks next to you? Here’s where Tonus (yes, they already have a name, beat this) shows up and saves the day. Things are simple: use your phone and the geolocation service and get a sneak peek inside the playlists of those traveling with you in tram, metro or bus.

Ilinca, my teammate, spend quite a lot of time on her way to the office, so no wonder why she struggled to make Tonus up and kicking. They still have a lot of tweaks to handle, but all in all, they have some early adopters ready to try it out and provide feedback.

Tonus

#3—Scores

Scores

We have some huge Fifa fans inside our team, and we too often debate who won which game. On top of that, we also have other sports lovers around us (especially tennis), so my team and I created a simple app that helps you note down the score. At this particular moment, you can create a new account, add the score for a match between two players, gain XP, win badges and check some leaderboards. I have to be honest and tell you that there are a few things that are still not working well, but we are proud of our work.


#4—Apply. Now.

We’re always looking for meeting interesting people from the local community, both for socializing, but also for recruitment purposes. The main idea of this project was tailored to our unique needs regarding bringing new people aboard. My teammates managed to create some short video stories which highlight the huge gap between the corporate approach and our vision about how things should work out. The results were… really game-changer.

Even it wasn’t an app like the other projects, the level of finding practical solutions was a bit higher. Long-story-short: the sky’s the limit. One thing’s for sure: you shouldn’t miss the opportunity to join our crew. So Apply. Now.

Final thoughts

There were 36 hours with a lot of laptop chargers connected to the wall, coffee, fruits and some tasty traditional food. Do we have any financial benefit out of this? Not really. Is there any accomplishment for the fact that we took some days off to run this internal Hackathon? You can be damn sure. Not only that we collaborated in different ways and pushed our boundaries, but we had the chance to invest our know-how, energy, and time in something else than business as usual. This is the break that we all need to take from time to time to see what’s behind the walls.

My main takeaway is related to the fact that we can do so much more if we truly are in this together. There are almost no limits.