Building a “Scotch Tape” Image Block Style

In today’s post, Tavern readers are in for something a little different than our regular stream of news and opinion. Welcome to the Building with Blocks series. It is a new type of post we are trying out to show people some of the fun, unique, or creative things they can do with WordPress blocks.

Our team decided to split the series into both developer and user-centric tracks. Posts may cover creating an “about me” page, coding custom block styles, piecing together a pattern, or something else entirely.

Since I am kicking off this series, I wanted to answer a question we already received from one of our readers. I had previously shared a custom block style with a “Scotch tape” look in my coverage of the FSE Outreach Program’s call for media testing:

Photo of a giraffe in the WordPress editor with a Polaroid-style frame and piece of tape holding it.
Original block style.

Devendra Meena asked in the comments:

Hey man, how to get the “tape” custom block image?

This felt like a natural starting point with my first post in the series.

The design shows a piece of tape holding a Polaroid-style, framed image. Technically, I also had an alternate style with two pieces of tape at the corners. However, this tutorial will focus on the former. The two-corner design requires overwriting some editor-specific CSS, technically breaking functionality, and is not something I should encourage.

I also wanted to begin with block styles because they are underutilized. Most variations I have seen have been simple changes like adding borders and removing margins. These are often best left to block design tools. Of course, themers are adding these styles because WordPress currently lacks or has previously lacked the UI controls for handling them. It is also one of the reasons so many have asked to mix and match multiple block styles — themes are doing the work that core should be doing. More tools are continually being added, but we still have a long way to go.

When I think of block styles, I want to create designs that are unlikely to be available via the standard design tools. I want to serve something unique to theme users. That is where we are starting today.

As a bonus, custom block styles work in classic and block themes.

Despite having written hundreds of tutorials in my life, this exercise turned out to be a little tougher than I had anticipated. It is easy to forget that everything I code starts with a base of “fixing” the things that I find odd about the default block library styles. This makes my life easier. However, many theme authors will lean on core’s defaults, so I needed to make this general enough to work for them.

Therefore, I opted to start from the default Twenty Twenty-Two theme. In testing, I suggest working with it. The CSS code in the following section may need slight alterations for others.

Creating the “Scotch Tape” Block Style

The first step is to register a custom block style via the theme. WordPress has both server-side and JavaScript APIs for this feature. Using PHP is easier to set up if you do not already have an editor script file to drop the code into.

To register the custom block style, add the following code to your theme’s functions.php file:

// Register block styles on the init hook.
add_action( 'init', 'tavern_register_block_styles' );

// Wrapper function for registering all block styles.
function tavern_register_block_styles() {

        register_block_style( 'core/image', [
        	'name' => 'scotch-tape',
        	'label' => __( 'Scotch Tape', 'tavern' )
        ] );
}

Doing so will register the style in the editor. You can test this by adding an Image block on the post-editing screen. “Scotch Tape” should be selectable under the styles tab.

WordPress editor with an Image block inserted into the content canvas.  On the right, there are three block styles, including a "Scotch Tape" variation.
Registered style correctly appears for the Image block.

Registering a style is the easy part. Writing the code is where things can get dicey. WordPress has so many methods of loading CSS styles that you might not know where to start.

The register_block_style() function used earlier allows developers to add a style_handle, a reference to a registered stylesheet. Themers can also add an inline style directly via the inline_style argument. For just a few lines of CSS, this works well.

In my own themes, I register block-specific stylesheets via the wp_enqueue_block_style() function — yes, the function names are terribly confusing. This was officially added in WordPress 5.9. It will only output the CSS when a block is used on the page. For example, I add a core-image.css file to house all Image block CSS. This is the method I recommend.

However, for the sake of simplicity, I added the following code to the end of Twenty Twenty-Two’s style.css file:

/* Design for the <figure> wrapper. */
.wp-block-image.is-style-scotch-tape {
	position:         relative;
	overflow:         visible;
	padding:          1rem;
	background-color: #fff;
	box-shadow:       0 4px 10px 0 rgba( 0, 0, 0, 0.3 ),
	                  0 0 4rem rgba( 255, 255, 235, 0.5 ) inset;
}

/* Design for the "tape". */
.wp-block-image.is-style-scotch-tape::before {
	content:    "";
	display:    block;
	position:   absolute;
	width:      7rem;
	height:     2rem;
	margin:     auto auto auto -3.5rem;
	z-index:    1;
	left:       50%;
	top:        -0.5rem;
	background: rgba( 255, 255, 235, 0.5 );
	box-shadow: 0 4px 10px 0 rgba( 0, 0, 0, 0.3 );
}

/* Remove TT2's image shadow. */
.wp-block-image.is-style-scotch-tape img {
	box-shadow: none;
}

/* Adjustments for the caption. */
.wp-block-image.is-style-scotch-tape figcaption {
	display:     block;
	margin:      1rem 0 0;
	line-height: 1;
	font-size:   1rem;
	font-family: 'Fuzzy Bubbles', sans-serif;
}

With the CSS in place, it is merely a matter of finding an image to test with. I chose Marcus Burnette’s whale shark from WordPress Photos.

WordPress post editor with an photo of a whale shark in the content canvas.  It has a Polaroid-style border with a piece of tape that appears to be holding it up.
Adding images in style!

If you want to add a bit of flair to your captions, load up Fuzzy Bubbles or another handwriting font from Google Fonts.

This style does not necessarily need to be tied to the Image block. There is no reason it could not apply to Paragraphs, Groups, and more with some adjustments.

For now, I hope you all have fun with it. Also, feel free to share in the comments where you would like to see the new “Building with Blocks” series head in the future.

Redshift vs. Snowflake: The Definitive Guide

What Is Snowflake?

At its core Snowflake is a data platform. It's not specifically based on any cloud service which means it can run any of the major cloud providers like Amazon Web Services (AWS), Microsoft Azure, Google Cloud Platform (GCP). As a SaaS (Software-as-a-Service) solution, it helps organizations consolidate data from different sources into a central repository for analytics purposes to help solve Business Intelligence use cases.

Once data is loaded into Snowflake, data scientists, engineers, and analysts can use business logic to transform and model that data in a way that makes sense for their company. With Snowflake users can easily query data using simple SQL. This information is then used to power reports and dashboards so business stakeholders can make key decisions based on relevant insights.

You’re Doing It Wrong — Recruiting a DevRel

The DevRel collective is a community where people in the developer relations field can chat and help each other out. But this post isn’t about that group… We’ll get to that. This is an article about you: the startup founder or manager who’s trying to hire your first developer relations person. This article is here to help you by example.

I’m not the first to write about this problem. Taylor Barnett wrote a great piece on this as well. Be sure to check it out!

Spring Boot Secured By Let’s Encrypt

In this article, we will learn how we can do the following:

  1. Generate a valid certificate for free
  2. Configure a Spring Boot app with it
  3. Renew it when it expires

In my previous blog post, we became familiar with the configuration of a Spring Boot Application with a self-signed certificate. Self-signed certificates are good for specific purposes such as test and development. But, if one needs to ship his application to production, certificates should be signed by known and legitimate Certificate Authorities (CA).

Using Machine Learning to Find Root Cause of App Failure Changes Everything

It is inevitable that a website or app will fail or encounter problems from time to time, ranging from broken functionality to performance issues or even complete outages. Development cycles are too fast, conditions too dynamic, and infrastructure and code too complex to expect flawless operations all the time. When a problem does occur, it creates a high-pressure urgency that sends teams scurrying to find a solution. The root cause of most problems can usually be found somewhere among millions (or even billions) of log events from a large number of different sources. The ensuing investigation is usually slow and painful and can take away valuable hours from already busy engineering teams. It also involves handoffs between experts in different aspects or components of the app, particularly with the use of interconnected microservices and third-party services which can cause a wide range of failure permutations. 

Finding the root cause and solution takes both time and experience. At the same time, development teams are usually quite short-staffed and overworked, so the urgent “fire drill” of dropping everything to find the cause of an app problem stalls other important development work. Using observability tools, such as APM, tracing, monitoring, and log management solutions, helps team productivity, but it's not enough. These tools still require knowing what to look for and significant time to interpret the results that are uncovered.

Getting Started With Apache Cassandra

Apache Cassandra® is a distributed NoSQL database that is used by the vast majority of Fortune 100 companies. By helping companies like Apple, Facebook, and Netflix process large volumes of fast-moving data in a reliable, scalable way, Cassandra has become essential for the mission-critical features we rely on today.

In this post, we will:

7 Strategies to Grow Affiliate Sales for WordPress Blogs

Strategies to Grow Affiliate Sales for WordPress BlogsYou may have started your blog with the sole intention of helping the community by providing much-needed information and answering questions around a given subject, but now you’re thinking you deserve to get some money out of it. Maybe you’re looking for new ways to make a little extra money on the side or you […]

The post 7 Strategies to Grow Affiliate Sales for WordPress Blogs appeared first on WPExplorer.

Polymorphism, Encapsulation, Data Abstraction and Inheritance in Object-Oriented Programming

Object-Oriented programming refers to the concept in high-level languages, such as Java and Python that uses Objects and classes in their implementations. OOP has four major building blocks which are, Polymorphism, Encapsulation, Abstraction, and Inheritance. There are other programming paradigms, such as Procedural programming in which code is written sequentially.

Python and Java are multi-paradigm high-level, programming languages. This means they support both OOP and procedural programming. A programmer decides on the paradigm to use based on their expertise and the problems they're trying to solve. However, there is no debate that OOP makes programming easier, faster, more dynamic, and secure. This is a major reason Java and Python are two fo the top most popular programming languages in the world today

Strict Validations in Mulesoft APIkit Router

This article will help you in your understanding of the functionality of Query Parameters and Headers Strict Validations in the MuleSoft APIkit Router.

What Are Strict Validations?

Strict Validations is an APIkit router configuration that restricts or limits API calls with unwanted Headers and/or Query Parameters which are not defined in the API Specification (RAML).

Completed Staff Work: Making Recommendations vs Asking for Approval

When I was introduced to the concept of Completed Staff Work, I felt like I had been handed a secret management technique. I had been a manager for several years and never heard of it, so it felt like a big secret when I did. And the idea simply exploded how I thought of my work as a leader.

So, let me share with you one of the most powerful management concepts I’ve encountered: Completed Staff Work. A standard for determining whether or not you’ve done enough work on a problem, the concept of Completed Staff Work involves useful techniques to

Using Travis CI for Deploying Mulesoft Applications to Cloudhub

What Is Travis CI?

  • Travis CI is a hosted continuous integration service used to build and test software projects hosted at GitHub and Bitbucket. Travis CI provides various paid plans for private projects and a free plan for open source. 
  • Travis CI is available at  https://travis-ci.org/.
  • https://travis-ci.org/ supports only public repositories. To support GitHub private repositories, you can use https://travis-ci.com/.

Prerequisites

To start using Travis CI, make sure you have:

To get started with Travis CI using GitHub, follow these steps:

Do AI Bots Need Some Regulations?

Look around and you will realize that artificial intelligence (AI) has found a place in almost every aspect of our daily functioning and is increasingly acquiring more space in our lives. Email spam filter, booking a cab, location-based services, using GPS while driving, voice commands on mobile — these are all examples of AI. As the customers and employees become smarter, there is a growing need for smart homes, and workplaces, and artificial intelligence (AI) can be seen acquiring more extensive responsibilities and coming up with an innovative offering.

In the series of AI innovations, there is another offering from AI, which is set to make our lives much easier and convenient, and it is chatbots. Today, organizations are actively using AI chatbots to promote their businesses, engage with customers better, and enhance their experience with a seamless personalized assistance. Growing competition, the need to keep up with ever-changing business landscapes, and the empowerment of consumers are making chatbots an essential presence. Not only are bots turning out to be instrumental in communication and engagement but also in cutting down costs and streamlining workflows. Moreover, chatbots are gradually finding the addresses of our homes. Machine learning capabilities and natural language processing have further opened gateways to the future, which was far from imagination once.

How to Save Money on your Microsoft Office 365 Subscription

Microsoft Office 365

The personal edition of Microsoft Office 365 is available for $6.99 per month on the official Microsoft website. This license includes all Microsoft Office apps. With the personal license, you’ll be able to install Microsoft Office on all your computers, phones and tablets through you can only be signed in to 5 device at the same time.

You may buy a license for Microsoft Office 365 through the Microsoft website, through in-app purchases inside the Apple App Store or Google Play store or through online stores like Amazon.

Office 365 Prices Comparison

I did a quick comparison of Office 365 prices across different regions and it is obvious that the most affordable option is Amazon. For instance, if you are looking to buy Microsoft 365 subscription in India, you’ll save around 20% when the purchase is made through Amazon vis-a-vis the Microsoft Store. The savings are even higher for UK customers.

Country / RegionPrice on Microsoft StorePrice on Amazon WebsiteSavings
United States$69.99$58.9916%
India₹4,899₹3,94920%
France€69,00€59,9913%
United Kingdom£59.99£42.9928%

Buying Office 365 through Amazon

When you buy a Microsoft 365 subscription through Amazon, Amazon will send a 16-digit license key to the email address associated with your Amazon account. It may take 15-30 minutes for the license key to arrive.

Once you have received the code, go to setup.office.com and sign-in with the Microsoft Office where you wish to use the Office 365 subscription. Enter the product key and click on the “Activate” button.

Activate Microsoft Office 365

Next, launch Word, Outlook or any other Microsoft Office app on the computer and sign-in with the same Microsoft account.

Also see: Buy Udemy Courses for Less

Things to note

The Office 365 subscription purchased on Amazon is exactly the same as the one offered on the Microsoft website but the price is cheaper. Once the license is activated, you’ll manage the subscription through your Office.com dashboard.

There are a few things to note when you buy an Office 365 license outside the Microsoft store.

  1. There could be geo restrictions in place. For instance, an Office license acquired from the Amazon US website may not be activated in India.
  2. If you wish to opt for monthly billing instead of paying for the full year, you’ll have to buy through the Microsoft website or make an in-app purchase on your Android or iPhone.
  3. This is important. If you have purchased Office 365 from Microsoft, you can request a return but licenses purchased through Amazon may not be returnable in every region.

5 Best MySQL Courses for Beginners and Experienced Programmers

Hello all! If you are interested in learning SQL with MySQL database and looking for some awesome resources such as books, tutorials, and online courses, then you have come to the right place. In the past, I have shared some useful books and tutorials. In this article, I am going to talk about some of the best MySQL online courses from Udemy and Pluralsight, which you can join to learn SQL and MySQL from the comfort of your office or home.

In the last couple of years, you might have heard the statement that "everybody should learn to code," which is great. Coding is now like reading, writing, and speaking skills, and in today's information technology-centric world, it is a must-have. There is no better way to start coding than learning SQL, the most popular programming language.

Win Your War Against Hackers and Secure Your Network

"Security is always going to be a cat and mouse game because there'll be people out there that are hunting for the zero day award, you have people that don't have configuration management, don't have vulnerability management, don't have patch management." - Kevin Mitnick (American Businessman)

Work culture has changed a lot recently. The ability to work from anywhere and at any time has become comfortable for employees, which in turn has brightened up things for hackers too. These days, sites are being bombarded by hack attacks from groups of hackers who later claim responsibility for the incident and make demands. There are a few pain points where hackers start their games.

Let's look into those vulnerable spots one by one.

What Is BizTalk Server?

If you wanted to explain BizTalk Server to a technology guy, the answer would be:

BizTalk Server is a middleware product from Microsoft that helps connect various systems together.