Using the Specificity of :where() as a CSS Reset

Category Image 091

I don’t know about you, but I write these three declarations many times in my CSS:

ul {
  padding: 0;
  margin: 0;
  list-style-type: none;
}

You might yell at me and say I can just put those in my CSS resets. I wish I could, but I don‘t want to and I’ll tell you why in a second.

User agents set values to those properties in a list for a purpose, and that is to make lists more readable. These are the default styles in chromium browsers for a <ul> element:

ul {
  list-style-type: disc;
  margin-block-start: 1em;
  margin-block-end: 1em;
  margin-inline-start: 0px;
  margin-inline-end: 0px;
  padding-inline-start: 40px;
}

So, without adding any class in HTML or style in CSS, we get those for free. That‘s a nice thing and I don‘t want to lose it. But I would appreciate it if I could make the browser understand that there is very high chance I don’t want that default feature in cases where I add a class to the element.

So here is a quick solution to reset a <ul> element that has a class:

ul[class] {
  padding: 0;
  margin: 0;
  list-style-type: none;
}

Now I don’t lose the default style except when I add a class to my <ul> element.

The problem

There is a problem with this solution. Imagine there is a list that we want to have a different list-style-type for it, like the following:

ul[class] {
  padding: 0;
  margin: 0;
  list-style-type: none;
}

.list {
  list-style-type: square;
}

This doesn’t work since ul[class] has higher specificity. That’s where our solution breaks down.

We could add more weight to the selector’s specificity:

ul.list {
  list-style-type: square; /* Specificity: 0, 1, 1 */
}

/* or */

.sidebar .list {
  list-style-type: square; /* Specificity: 0, 2, 0 */
}

If you are OK adding more weight to the selector, you are good to go. But I’m not OK with it, personally. For example, I don’t want to put the element’s name in my CSS most of the times due to a separation of concerns principle. Or, if you are following BEM methodology, problems will most certainly arise as this conflicts with it.

So what can we do?

The solution

A few months ago, I learned about some hot selectors, including :is() and :where(). One thing about these two functional pseudo selectors, is that they can change specificity, giving us the power to nullify or increase that specificity.

The key about :where() is that it always has 0 specificity. So we can get rid of our problem very easily like this:

:where(ul[class]) {
  list-style: none;
}

.list {
  list-style: square; /* Now this works like a charm! */
}

With the power of this selector, libraries can give us style with no specificity. So there would be no specificity to compete with when we as authors write CSS.

Demo

In the following demo, you can remove :where() to see what we talked about in action:


The post Using the Specificity of :where() as a CSS Reset appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.

Lead Generation Strategies for SaaS

Category Image 060

Introduction

Think of your SaaS business as an orchard. If you don’t tend the trees, they won’t bear fruit. Similarly, if you don’t maintain your services, you won’t make a profit. Generating leads for your business is an essential step in maintaining your business’s health and growth. We’re here to show you why and how lead generation can work for you! 

What Is Lead Generation?

A lead is someone who has shown an interest in your product, to the point where they’ve given you their information. You’ll need to nurture this interest to turn it into customer action, as well as generating more leads for your business. 

How do I convert a SQLITE day number to a date string

Category Image 101

I have a SQLite database that for some insane reason stores dates as the number of days since 1899-12-31. I want to create a view that will display the date as an actual date. I can calculate a specific date from a specific day number as

select date('1899-12-31','Localtime','+44386 day') as dddd

which returns the single value '2021-07-09'. Unfortunately there seems to be no way to replace the hard coded number with the 'day' column. The original table also has the data broken down by hour (thus the GROUP BY clause), and by data_out and data_in (thus the SUM) So far I have

CREATE VIEW UsageByDay AS
SELECT day, SUM(data_in+data_out)/1024.0/1024.0 AS total 
  FROM usage GROUP BY day 
ORDER BY day DESC;

Which gives me on select

DAY     total
44386   45.2344284057617
44385   35.1123762130737
44381   26.000226020813
.
.
.

I want to replace the numerical values for day with the calculated date to give

DAY          total
2021-07-09   45.2344284057617
2021-07-08   35.1123762130737
2021-07-07   26.000226020813
.
.
.

Any suggestions on how to modify my CREATE VIEW query?

Awesome Motive Acquires SearchWP

Wp Plugins

Awesome Motive, the company behind MonsterInsights, OptinMonster, WPForms, and several other popular products, has acquired SearchWP, a commercial plugin that enhances WordPress’ search functionality. No changes have been announced for the plugin and Awesome Motive CEO Syed Balkhi says it will be “business as usual” for current customers.

“We have built a lot of internal tools to improve our website search that I’m really looking forward to sharing with the WordPress community,” Balkhi said.

“We will be combining Jon’s vision with our own experience, so you can literally have the best search plugin in the industry without the high costs.”

In 2013, when Jon Christopher launched SearchWP, he quickly carved out a slice of the WordPress search market among early competitors. The freemium model was already popular in those days with plugins like Relevanssi, but Christopher chose to launch SearchWP as a commercial-only product.

“There was already freemium competition, and I felt that the pricing model (which is the same today) was stronger given the product itself,” Christopher said. “I saw the pricing model as something that would help SearchWP stand out, and I also wanted to avoid opening the doors to overwhelming amounts of support requests right from the start.

“I had no idea if SearchWP would be successful given the landscape, I built it first to scratch my own itch while knowing that even if no one bought it, I would 100% use it in my own work, and use it a lot.”

His gamble paid off and the plugin has been used on more than 30,000 WordPress sites. Christopher had one support contractor but otherwise had been running the business alone for the past eight years. WordPress’ growing market share has made one-person plugin businesses difficult to maintain once they become very popular, as seen in the recent sale of ACF to Delicious Brains.

“I was looking ahead and considering what would be best for SearchWP’s customers,” Christopher said. “I want SearchWP to live as long as it possibly can. If I’m by myself it’s a bit of a risk to continue that way as the business continues to grow. I know that I prefer to build things from the ground up, and I also know that I’m not the guy to build (or manage) a team, it’s not my strong suit. Given all of those pieces it was clear to me that it was a good time to consider selling.”

Christopher described the 2013 WordPress ecosystem as more “scrappy,” as developers launched product businesses and worked to figure it out along the way.

“There are pros and cons to an environment like that, but it was fantastic from my perspective,” he said. “Over time that feeling went away as companies grew, matured, and playbooks began to take shape. That cycle has continued over time and especially in the last 18 months we’re getting a look at where WordPress is headed – lots of big players in a really big space.”

For those who are jumping into the waters with a new product business, Christopher underscored the need for strong marketing.

“I think that a lack of serious marketing will in fact be a limiter in today’s WordPress economy,” he said. “Products that have been around a long time have a natural momentum that’s really tough to beat, but that momentum doesn’t come without friction. In order to keep up with where WordPress is going, I do feel like you need assets (and capital) aimed directly and solely at marketing for the long haul.”

Balkhi did not elaborate on Awesome Motive’s immediate plans for the search plugin but said the company will be executing on a 12-month plan to make it easier for beginners and non-technical business owners to set up in less than 10 minutes.

The Right Way to Remove WordPress Version Number

Category Image 091

Do you want to remove the WordPress version number from your website?

Many believe that removing the WordPress version number from your website’s source code can prevent some common online attacks.

In this article, we’ll show you how to easily remove WordPress version number the right way.

Hiding WordPress version number from your website

Why Remove WordPress Version Number?

By default, WordPress leaves its footprints on your site for the sake of tracking. That is how we know that WordPress is the top website builder in the world.

WordPress version shown in source code by default

However, sometimes this footprint might be a security leak on your site if you are not running the most updated version of WordPress. It provides the hacker with useful information by telling them which version you are running.

We recommend using the latest version of WordPress on all your websites so you don’t have to worry about this. However, if for some reason you are running an older version of WordPress, then you should definitely follow this tutorial.

It is quite difficult to remove all traces of which WordPress version you are using on your website. A sophisticated attack may still be able to find that information.

However, it will prevent automatic scanners and other less sophisticated attempts from guessing your WordPress version.

That being said, let’s take a look at some ways to easily remove version number from your WordPress website.

Method 1. Remove WordPress Version Number using Sucuri

This method is easier and recommended for all users.

All top WordPress security plugins offer an option in the settings to hide your WordPress version number.

However, we recommend using Sucuri because it automatically hides WordPress version information and offers other more advanced security features.

Simply install and activate the Sucuri plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, the plugin will automatically hide WordPress version information. You can verify it by visiting Sucuri Security » Settings and switching to the Hardening tab.

Sucuri WordPress version hardening

Method 2. Manually Remove WordPress Version Information

This method requires you to add code to your WordPress website. If you haven’t done this before, then see our guide on how to copy and paste code snippets in WordPress.

Now, many websites will recommend you to edit your theme’s header.php file and get rid of the following line of code:

<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" />

This method doesn’t work as a new theme update will automatically replace the old template with the new file.

Another commonly recommended, but inefficient method is to put this code in your theme’s functions.php or site-specific plugin:

remove_action('wp_head', 'wp_generator');

This will only remove the information from the WordPress header. The version number will still be visible in your website’s RSS feeds.

The right way to remove WordPress version information is by disabling the function responsible for displaying it.

In order for you to completely remove your WordPress version number from both your head file and RSS feeds, you will need to add the following code to a site-specific plugin or code snippets plugin.

function wpbeginner_remove_version() {
return '';
}
add_filter('the_generator', 'wpbeginner_remove_version');

By adding this code, you will remove the WordPress version number from WordPress RSS feeds and your website’s head section.

Can You Completely Hide WordPress Version?

WordPress may still add the version information in various other places throughout your website. For instance, it is included as the query string in source code for CSS and JS files.

WordPress version shown with CSS and JS files

Removing all instances of WordPress version information can be time-consuming, complicated, and may not always work.

From a security perspective, removing the obvious generator tags can protect you from some very common attacks.

However, if someone is determined to break into your website, then hiding your WordPress version number does little to stop this.

You need to implement a proper WordPress security setup in place to make your website more secure. This adds layers of security around your website making it harder to hack into.

We hope this article helped you learn how to easily hide WordPress version number from your website. You may also want to see our guide on how to get a free SSL certificate for your website, or our list of must-have WordPress plugins for small business.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post The Right Way to Remove WordPress Version Number appeared first on WPBeginner.

Does Anyone Know of a PHP Content Locker Script?

558fe5180e0e8fc922d31c23ef84d240

Trying to have a script built that locks the content until user refers a friend to signup, then they are granted access. They have a set amount of time, as a timer counts down or their account is deactivated. Its for a game we are creating and want to use this type system. Is there anyone who has done this?

I have hired someone to build it but i see lol he doesnt know what he is doing......help please.

Collaborative Editing Solutions for WordPress

Featured Imgs 26

Collaborative Editing Solutions for WordPressAs a website grows, more content creators are required. With this, there are more iterations of editing in content pieces. This leads to increased complications in collaborative or synchronized working. Now, while there still are efficient tools like Google Docs and grammar checkers for this, publishing the content on websites remains super-taxing. In the coming […]

The post Collaborative Editing Solutions for WordPress appeared first on WPExplorer.

postcss-px-to-viewport

Category Image 091

A user wrote in the other day asking us to add this PostCSS plugin: postcss-px-to-viewport. We’re always happy to consider them as needed, and this one looks pretty neat and pretty popular.

It also blows my mind a little bit. All you do is size things in traditional units like px and it turns them into viewport units instead, making the entire UI scale together. You could just use viewport units yourself, but I guess this means you get to keep using units you have more muscle memory and a mental model for, yet get this result.

Above is me in Debug Mode checking out the weird result!

One reason I bring it up is to note the special way that options are passed to the PostCSS plugin:

@use postcss-px-to-viewport(
  viewportUnit: vw,
  viewportWidth: 1200
);

That’s just passing two of the many options this plugin supports. Any PostCSS plugin we offer that supports options works in this same format. For example, if you want to customize Autoprefixer, you can do that the same way.

The post postcss-px-to-viewport appeared first on CodePen Blog.

What’s New In The Digital Marketing Space for 2021

Featured Imgs 23

Digital marketing is kind of like a moving machine made up of various gears and pieces that work in unison to get things rolling. For example, you can utilize SEO to get more visibility, and you can incorporate ads for traffic. Digital marketing is also at the forefront of some more modern technologies, making it an essential tool for your business now and in the future. If you want to stay ahead of the competition, you are going to need to focus on your digital marketing strategies and implement some of the digital marketing trends of 2021. 

So here’s what’s new in the digital marketing space every Ottawa website owner should know.

 

1. Artificial Intelligence (AI)

This is quickly becoming one of the biggest trends of 2021 and beyond. Smart machines that can carry out simple tasks increase productivity and make life a little easier. For the digital world, AI is popping up in the form of chatbots and analytics. For example, you might opt to have a chatbot on your site who can help new and existing customers with common problems on orders or with finding valuable information. Not only does this increase your site’s user experience, but it frees you up to manage your site and develop content. 

 

2. Social Messaging Apps

Did you know that Facebook Messenger has over 1.3 billion active users? WhatsApp has 1 billion active users, and over 55 billion messages are sent over the program daily. People want communication apps. Not only that, they want to know that the businesses and organizations they are backing are also reachable on these kinds of apps. Simply having accounts on Facebook Messenger, WhatsApp, or a similar messaging app will make 63% of online consumers more likely to return to your site. 

 

3. Video Marketing

Because smartphones are so commonplace these days, video marketing continues to dominate digital marketing. One of the reasons is the difficulty some people have with long form content, sales pages, and emails on their phones. Video is easier. It’s quick. And it plays into humanity’s short attention span. Having videos will improve retention, increase brand awareness, and even increase your conversion rate. Video continues to bring more and more to the world of digital marketing. 

 

4. Personalization

More and more, people want to feel valued by the businesses they support. That is why personalized content, such as emails, product suggestions, song recommendations, and more has become one of the top digital marketing trends of 2021. If you haven’t started putting customer’s names in your promotional content, you are missing out! After all, no one likes generic advertisements anymore. 

 

5. Interactive Content

Yes, this has been around for some time, but 2021 has refreshed and rejuvenated the idea of interactive content. Marketers have realized how valuable such content can be to a user. Things like contests, quizzes, giveaways, and videos can truly increase your following, brand loyalty, and gain you more traffic. A bunch of interactive content builders are available, including involve.me, Outgrow, ContentTools, and Zembula. 

 

6. Voice Search

2021 is all about innovating technologies that have existed for a few years, like smart speakers and voice search. Convenience is the name of the game with voice search, and it’s something you need to consider if you want to be successful at digital marketing in 2021 and beyond. Audio advertisements have become more prevalent as a result of voice search. For example, if someone asks Alexa to search for something, she might answer back in the form of your ad as a “word from a sponsor.”

 

7. Stories

Although stories didn’t emerge in 2021, they are more popular and influential than ever before. Snapchat started the idea of story clips back in 2013, and since then Facebook, Instagram, WhatsApp, and other social media platforms have implemented similar ideas. But why are stories such a beneficial feature? Because you can engage with your followers at the push of a button in a cost-effective way. Think of Stories or Reels or little clips as a simple advertisement that helps you interact with your audience. 

 

8. Featured Snippets

When someone has a question, they Google it. Google then crunches that data and provides an answer. Sometimes the results page is crowned with something known as the Featured Snippet or Position Zero, which is a distinguishing place of honor. Why? Because it provides the information you need without you having to select anything. You just get what you came for. 

Many businesses are vying for Position Zero, because it means maximum visibility. Readers are enticed by the information provided, and they often want more. In short, if you aren’t trying to get the Featured Snippet position, you could be missing out on traffic. 

 

9. Customer Segmentation

So, this might not be 100% new to the digital marketing space in 2021, but it is more necessary. The idea is simple—you target a very specific niche or audience with smaller campaigns rather than launch multiple campaigns for a larger group. 

With a number of ways to content with people these days, such as video, voice, interactive content, and more, customer segmentation can help you analyze precisely who you want to target and how. It will save you some money and time, too. 

 

10. User-Generated Content

For those who wish to target Gen Z and millennials, user-generated content is a valuable tool. It’s a simple tactic: simply encourage your users to share their content with you on their social media accounts. You can also provide an incentive, such as discounts to a product or a giveaway. Since there are a lot of visual platforms these days, user-generated content is a cost-effective way of getting people to advertise your product for you. In fact, 90% of online shoppers are influenced by user-generated content

 

Conclusion

Although there hasn’t been a lot of new trends popping up in the digital marketing world for 2021, there is a number of improvements on past trends. For example, video marketing, voice search, and web responsiveness keeps evolving to make smartphones more and more beneficial to advertising. Keep your eye on these trends to see how you can use them and guide yourself towards success.