Corey Salzano

  • CONTACT
  • Hiding Specific Terms When Creating or Editing Posts

    The WordPress block editor uses the REST API to manipulate all information in the post object, so hiding terms from the category, tags, or a custom taxonomy meta box can be achieved by removing those terms from REST API responses.

    One hook that makes this easy is the rest_{taxonomy}_collection_params filter.

    Here is an example that shows how terms can be included in the editor only if they have a certain value for a term meta key. This isn’t the best code design because it uses a global variable to hold the taxonomy name, but that’s an artifact of my pulling this out of a larger class.

    For my application, the terms I’m excluding are outdated and won’t be added to any new content on the site. This method is effective and seems low risk. If you are aware of any risks associated with excluding terms from REST API responses, please comment below.

    August 12, 2019
  • WordPress Memes

    This is the collection of all the WordPress memes I’ve created.

    You Should Make Plugins

    The West Coast Choppers meme is one of the greatest of all time. I made this for a presentation at the WordPress Lancaster meetup called How to Make a WordPress Plugin to help people get over the two biggest mental roadblocks to making their first plugin: “I don’t know PHP,” and “I don’t want to break my site.”

    Is This a PHP File?

    I made this for the same How to Make a WordPress Plugin presentation to help people understand that PHP start and end tags are what makes parts of a PHP file special, and there might be HTML or something else inside otherwise. This is slight meme abuse because the typical use of this image portrays our hero as naive.

    But Her Editors

    I made this to mock a sentence in Matt Mullenweg’s “New 5.0 Target Date” blog post that turned out to be false. I feel bad because this is trolling and a joke at his expense, but I did it.
    July 19, 2019
  • Pressure Washing in Lancaster, PA

    Pressure Washing in Lancaster, PA

    Business cards for a local pressure washing business, Clean & Co. LLC

    June 27, 2019
  • Tasting Room & Bottle Shop

    Tasting Room & Bottle Shop

    I made this last year for the Stoll & Wolfe distillery in Lititz, PA.

    June 27, 2019
  • Why Elementor Disobeys is_admin()

    I was surprised to learn that when editing a page using Elementor‘s page builder, is_admin() returns false. The reason for this is that Elementor is loading the page in an <iframe> element as if it were being viewed on the front-end.

    Use code like this to detect when posts or pages are being edited in Elementor. Code like this is useful to me because sometimes I add a meta refresh element to automatically start a download, and I don’t want the redirect and download to happen while editing the page.

    //don't do anything if we're editing in Elementor
    if( \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
        return;
    }

    Here is other code that relies on a URL querystring parameter.

    //don't do anything if we're editing post 1112 in Elementor
    if( isset( $_GET['elementor-preview'] ) && '1112' == $_GET['elementor-preview'] ) {
        return;
    }
    March 11, 2019
  • Using register_setting() and the REST API

    Here is a comment I just requested be added to the bottom of the register_setting() page.

    If you plan to use your setting in the REST API, use both the rest_api_init and admin_init hooks when calling register_setting() instead of just admin_init. The show_in_rest argument is ineffective when hooked into admin_init alone.

    Corey Salzano

    Someday, when my comment is approved, you’ll be able to see it on this page and save an hour or two of debugging time. If you can see my comment on this page, please let me know.

    March 5, 2019
  • The Events Calendar List Widget Replacement

    I wrote a plugin to customize the Events List widget that ships with Modern Tribe’s The Events Calendar Pro plugin. The widget has an option to hide completely when there are no upcoming events. The alternative displays the dreaded “There are no upcoming events at this time” in an otherwise empty Events List widget. I love the idea of not including the widget at all if there are no events, but what if this is the only widget in a sidebar or widget area? Sometimes, I want to display something in place of the widget instead of leaving the space empty. Here’s a plugin that does exactly that.

    Download plugin

    https://github.com/csalzano/the-events-calendar-list-widget-replacement

    Where does the replacement content live?

    Create a file at wp-content/themes/your-theme/tribe-events/pro/widgets/list-widget-replacement.php that contains the content you wish to display in place of the Events List widget when there are no upcoming events.

    If you’re using the free version of The Events Calendar, create the file at wp-content/themes/your-theme/tribe-events/widgets/list-widget-replacement.php

    (This file sits right next to list-widget.php, the template you might create to modify the output of the Events List widget. I chose these locations in the spirit of The Events Calendar Themer’s Guide.)

    Here’s what my file looks like–I wrote some HTML that mimics a widget so I didn’t have to write any additional CSS styles for the replacement content. My client is a local municipality, so I put together some numbers that describe the size and age of a small Pennsylvania township.

    March 3, 2019
  • Editing Terms & Term Meta with the WordPress REST API

    Here are some JavaScript snippets to manipulate WP_Term objects in WordPress using the REST API and the Backbone JavaScript client library.

    Insert a term

    Delete a term

    This next example assumes you’ve used wp_localize_script() to make the REST API endpoint and a nonce available in an object myplugin. If you need help doing this, please leave a comment below and I’ll expand this example.

    Edit a term meta value

    Let’s add a term meta value to identify the number of speeds in this automatic transmission.

    Thanks for reading. If you know a better way to edit terms and term meta in JavaScript, please leave a comment below.

    February 27, 2019
  • WordCamp Lancaster 2019

    WordCamp Lancaster 2019

    I am the lead organizer for WordCamp Lancaster for the first time in 2019, and that means I was allowed to design this logo for the event. Thanks be to fellow organizer Dustin Leer for looking at draft versions of this and sharing insights.

    January 3, 2019
  • What is $posted_data passed to Contact Form 7’s wpcf7_posted_data hook

    For a ContactForm7 form that has this source:

    <div class="wpcf7-lead-widget">[text* contact-name maxlength:50 placeholder "Your Name (required)"]
    [email* email maxlength:50 placeholder "Email (required)"]
    [text phone maxlength:15 placeholder "Phone"]
    [vehicle_form_field]
    [textarea comments x3 placeholder "Questions and Comments"]
    [submit class:_button class:_button-small "Check Availability"]
    [hidden context id:context "contact"]
    [hidden do-not-send-mail]</div>

    The $posted_data that is passed via the wpcf7_posted_data hook looks like this:

    Array
    (
    [_wpcf7] => 10610
    [_wpcf7_version] => 5.1.1
    [_wpcf7_locale] => en_US
    [_wpcf7_unit_tag] => wpcf7-f10610-p7983-o1
    [_wpcf7_container_post] => 7983
    [g-recaptcha-response] =>
    [contact-name] => Corey
    [email] => [email protected]
    [phone] => 8005556666
    [inventory-post-id] => 7983
    [comments] => Super interested in this sandbox
    [context] => contact
    [do-not-send-mail] =>
    )

    The first item is the form ID, and all items after g-recaptcha-response are the values of the fields provided by the the user (or the source in the case of the hidden fields). inventory-post-id is the value of a drop down created by the shortcode in our form, [vehicle_form_field].

    December 28, 2018
  • Mudbugs Hockey Jersey Patches

    Mudbugs Hockey Jersey Patches

    New shoulder patches for my hockey team’s 2018 rebrand

    December 2, 2018
  • Convert alphabetical Google Sheet column names to numbers

    Lately, I’ve been working with large Google spreadsheets that have many columns. When you write QUERY statements to pull data from one sheet into another, you have to use Col1, Col2, Col3 column names instead of A, B, and C. It’s hard enough to remember the letter O is the 15th letter of the alphabet. There is no chance that I am going to memorize that column BH is the 60th. I made this calculator to solve this conversion:





    One of my favorite tricks when a team member needs some data is to create a new Sheet, query data from the primary sheet, and share that subset of the data while protecting the A1 cell so the formula doesn’t get mangled. This method lets our friend get only the columns she needs and live updates in the form of new rows just like the huge primary sheet. It works by passing an IMPORTRANGE call into the first parameter of QUERY.

    November 20, 2018
←Previous Page
1 2 3 4 5 … 9
Next Page→

Corey Salzano

Proudly powered by WordPress