Small Matters - February 6, 2024

Caring for your WordPress website

WordPress Education

Using code snippets with your WordPress website gives you the flexibility of extending website capabilities to suit your specific needs.

Code snippets? That sounds really techy, right?

Right. It is techy. But there are many developers out there who generously share their knowledge for free.

For example, here’s a code snippet that I often use to help reduce spam in online forms:

add_filter( ‘gform_field_validation’, function ( $result, $value, $form, $field ) {
    GFCommon::log_debug( __METHOD__ . ‘(): Running…’ );

    // Only for Single Line Text and Paragraph fields.
    if ( $field->type == ‘text’ || $field->type == ‘textarea’ ) {
        if ( $result[‘is_valid’] ) {
            $stop_words = array( // List of words to not allow in lowercase.
                ‘unwanted word’,

            // Stop Words Counter.
            $stop_words_detected = 0;
            // Check field value for Stop Words.
            foreach ( $stop_words as $stop_word ) {

                if ( strpos( strtolower( $value ), $stop_word ) !== false ) {
                    $stop_words_detected++;
                    GFCommon::log_debug( __METHOD__ . “(): Increased Stop Words counter for field id {$field->id}. Stop Word: {$stop_word}” );
                }
            }
            if ( $stop_words_detected > 0 ) {
                GFCommon::log_debug( __METHOD__ . “(): {$stop_words_detected} Stop words detected.” );
                $result[‘is_valid’] = false;
                $result[‘message’]  = ‘Sorry, you used a disallowed word.’;
            }
        }
    }
    return $result;
}, 10, 4 );

You don’t need to understand PHP programming language to use this code. WordPress makes it as easy as copy/paste.

Trouble is, sometimes you don’t know where to put these awesome custom code snippets. If you’re up to the task, this article is a great introduction to adding code snippets to your WordPress website, with or without a code snippet plugin.

Caring for Your Business

Marketing

If you’re brave enough to add code snippets to your website, you might also be doing other tasks yourself, like improving the look of your website.

Photos, videos, and other graphics usually stand out to most website visitors. What they don’t always notice is your choice of fonts.

At least, most people wouldn’t say they notice fonts…unless they don’t work well visually.

Font pairing is a subtle yet important tool for your marketing efforts. The better the match (with each other and with your brand), the better the user experience for your website readers.

Read more about these secrets to font pairing from Adobe:

  • Choose a suitable anchor font
  • Consider contrast & similarity
  • Balance the font’s purpose with its emotional impact

Caring for Yourself

Inspiration

There was a time when I really geeked out about fonts. I still have my moments.

That shouldn’t be so weird, though. I believe each day holds the possibility to stand (or sit) in wonder before something grand and extravagantly beautiful (like a sunrise or a photo of a sunrise) but also at something small and common (like frost on a window or two well-matched fonts).

After all…

Small matters.

More than the grand beauties of our lives, wonder is about having the presence to pay attention to the commonplace. It could be said that to find beauty in the ordinary is a deeper exercise than climbing to the mountaintop.


Cole Arthur Riley, This Here Flesh
AI generated image of frost on window at sunrise
AI-generated with Adobe Firefly (and some creative human text prompts)

Do you maintain a WordPress website?
Get hand-picked practical tips, valuable resources, and creative inspiration from the best online sources – delivered to your Inbox twice a month.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.