Month: March 2018

  • Adding WP Action & Filter Hooks

    Adding WP Action & Filter Hooks

    There are two types of WP hooks that can be used to extend the abilities of WP functions.

    Filter Hooks

    The following will output “Hooked: Home” to the “the_title” WordPress function on every call to the function.

    add_filter("the_title", "dl_title");
    function dl_title($title) {
      return "Hooked: " . $title;
    }

    Important: This will always return something.

    Action Hooks

    After the exection of the wp_footer, the following verbiage will output AFTER: Shoutout to all the WordPress devs!

    add_action("wp_footer", "dl_footer_shoutout");
    function dl_footer_shoutout() {
      echo "Shoutout to all the WordPress devs!";
    }

    Prioritization

    Specific functions can be called at different times using prioritization.

  • Insert WorkCast to WordPress

    Insert WorkCast to WordPress

    One of my clients tasked me to implement WorkCast as one of their WordPress pages.  The issue I ran into with their Product Owner was that:

    • Not all WordPress pages should have the CSS/JS code.  This will conflict with WordPress' jQuery.
    • "Copy/Pasting" WorkCast into a WordPress editor page didn't work.  The page came up blank.  I'm suspecting this is because of JS conflicts with the WP theme.

    Solution

    I wrote a plugin that injects a "Theme Template" into any of WordPress Pages.  The user simply chooses "WorkCast" as the page template to utilize WorkCast.

    This solution is currently configured to work for Swords-To-Plowshares.org.  If you're interested on how it was done, head on over here.