Ben Rothman - WordPress Developer Blog - Page 3 of 6 - ©2023 Ben Rothman, Web Developer

Blog

My blog is dedicated to sharing my expertise, recommendations, and tutorials on WordPress. If you're interested in developing with WordPress, my blog is a valuable resource that you won't want to miss.

Categories
Plugin Web Development WordPress

Fixed ChatPress

I installed ChatPress on a website with a new theme today and it looked squished and strange. It was still legible and everything but the whole appearance just looked a little sloppy to me. I’m sure some people would have told me the plugin looked fine and that whether it works or not (which it always did) was more important.

Functionality alone is not enough for me, so I went to work diagnosing the problem and creating a fix. I found that the problems were CSS-related so I went to my scss files, made the changes and recompiled my scss into css so that I could use them for the plugin and voila, it was fixed!

Categories
Web Development

How to Control a Youtube Video with javascript

Last Tested: 11/21/2020

Sometimes a web developer needs to perform this very important control/monitoring functionality. Whether you need to play a video, see if a video has been watched in its entirety or just integrate the embedded youtube video’s functionality into your code for another reason, it can all be done using the youtube API.

The first important (albeit basic) part of using the Youtube API for these functions is that although the video on your page will look like an embed, you are actually putting an empty div on your page with HTML and the Javascript calls the API and replaces that div with the video you specify.

  1. Put the following in the code of your HTML page:
<div id="video-placeholder"></div>

2. Include a javascript file with the following content (but change videoId to the ID of your video):

var player;

function onYouTubeIframeAPIReady() {
    player = new YT.Player('video-placeholder', {
        width: 600,
        height: 400,
        videoId: 'Xa0Q0J5tOP0',
        playerVars: {
            color: 'white',
            playlist: 'taJ60kskkns,FG0fTKAqZ5g'
        },
        events: {
            onReady: initialize
        }
    });
}

function initialize(){

    // Update the controls on load
    updateTimerDisplay();
    updateProgressBar();

    // Clear any old interval.
    clearInterval(time_update_interval);

    // Start interval to update elapsed time display and
    // the elapsed part of the progress bar every second.
    time_update_interval = setInterval(function () {
        updateTimerDisplay();
        updateProgressBar();
    }, 1000)

}

3. Include this code in your html page to get the current duration of the video automatically updated:

// This function is called by initialize()
function updateTimerDisplay(){
    // Update current time text display.
    $('#current-time').text(formatTime( player.getCurrentTime() ));
    $('#duration').text(formatTime( player.getDuration() ));
}

function formatTime(time){
    time = Math.round(time);

    var minutes = Math.floor(time / 60),
    seconds = time - minutes * 60;

    seconds = seconds < 10 ? '0' + seconds : seconds;

    return minutes + ":" + seconds;
}

4. Include this code in your HTML page to add a play button for the video:

$('#play').on('click', function () {

    player.playVideo();

});

5. Include this code in your HTML page to add a pause button for the video:

$('#pause').on('click', function () {

    player.pauseVideo();

});

Disclaimer: I do not work for youtube and so had no involvement whatsoever in the creation of Youtube or it’s excellent API. For more information about using the youtube embed API visit the site listed in my sources for a more in-depth explanation.

Source(s):

  1. https://tutorialzine.com/2015/08/how-to-control-youtubes-video-player-with-javascript
Categories
Web Development

[HowTo] Install Atom, Brew and Node (npm and npx) on Mac

Ok, lets start by saying that I know the title is a lot. It is not just one or two tools that this guide helps you install, it’s all of those tools listed above, plus a few more that are required to run those tools.

But Ben, why not break this guide into several easier-to-manage guides that install one or two tools at a time? Well, I am writing this guide to help with all of those installations, BUT you can start this guide from anywhere and just pick and choose the tools you want.


First, Atom. The atom editor is the easiest of the bunch to install, just go to https://www.atom.io and download it. The website will automatically detect your OS (unless you are on a crazy one or have some kind of unusual configuration). Easy, one step


Next we will go on to installing Brew. At the time of writing this guide, the terminal command to execute is:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

but if that is not working for some reason or you want to troubleshoot, you can go to https://www.brew.sh . Wow, another one-stepper, I guess this guide is shorter than you thought.


Next we will install Node which as noted in the title will allow you to use both the npm and npx commands. For this installation I recommend using a package manager such as Brew and fortunately I just showed you how to install one above. All we have to do for this one is run the command:

brew install node

and you will now be able to use npm, npx and node packages in general. If you want to confirm that node is in fact installed on you computer you can run node -v.


We are just flying through this guide! Next, we will install composer. To be honest, you may not have to use this tool much after today, but let’s just install it anyway because it is a great tool and a requirement for the next step which is installing valet.

Categories
Project Web Development Website

Park Picker

This project is written with PHP, HTML/CSS and JQuery with some light javascript in there too.

I was given a list of parks, tags that relate to them (like dogpark, pond and bike path), the park’s website and a picture of that park; I made all of that information into a JSON file. All of the tags of every park are all listed all together each one time and the user chooses the tags for their ideal park, something that has all of or as many of the tags as possible.

The JQuery then immediately rebuilds the page (without a page refresh) and lists the parks in order of how many tags it has that match the tag criteria as well as gives a grade to each park that shows how many tags.

It’s not a terribly complex project, but it gets an important job done and solves a problem in away that is relatively easy to maintain.

This project can be found on my GitHub at: https://github.com/brothman01/park-picker

Categories
Plugin WordPress

WordPress: Formidable Forms

If you want a complex form with conditional logic, advanced scoring, user registrations and much more, Formidable Forms is the plugin for you. If you want a contact form this plugin works excellently for that too, it’s much more power than you need but it is a good solution.

Formidable forms has an easy-to-use graphical interface to build forms, and then can add conditional logic/assign scores or values to responses right there. If you need to refer to the value of a field in the value of another field, email it or otherwise use it elsewhere in the form, you can just refer to the index number associated with that field or use a url parameter right in the Formidable Forms interface.

If you need complicated and very powerful forms on your site and do not want to build them with code then this is the plugin for you.

There is even a very useful API add-on that I used at work to create API sends to specific endpoints and with specific data including but not limited to the data entered on the form.

Categories
WordPress

WordPress 5.5 “Eckstine”

Here it is! Named “Eckstine” in honor of Billy Eckstine.


Speed

Posts and pages feel faster, thanks to lazy-loaded images.

Images give your story a lot of impact, but they can sometimes make your site seem slow.

In WordPress 5.5, images wait to load until they’re just about to scroll into view. The technical term is ‘lazy loading.’

On mobile, lazy loading can also keep browsers from loading files meant for other devices. That can save your readers money on data — and help preserve battery life.

Say hello to your new sitemap.

WordPress sites work well with search engines.

Now, by default, WordPress 5.5 includes an XML sitemap that helps search engines discover your most important pages from the very minute you go live.

So more people will find your site sooner, giving you more time to engage, retain and convert them to subscribers, customers or whatever fits your definition of success.

Security

Now you can choose to update plugins and themes automatically–or pick just a few–from the screens you’ve always used.

Auto-updates for Plugins and Themes

Now you can set plugins and themes to update automatically — or not! — in the WordPress admin. So you always know your site is running the latest code available.

You can also turn auto-updates on or off for each plugin or theme you have installed — all on the same screens you’ve always used.

Update by uploading ZIP files

If updating plugins and themes manually is your thing, now that’s easier too — just upload a ZIP file.

Categories
Website WordPress

WordPress: WPOptimize

This life-saver plugin adds a button to the dashboard when installed that allows the administrator of the website to perform certain site optimization tasks such as removing old post revisions, minifying images, removing trashed comments and lots more from the comfort of their own dashboard.

Want to optimize the tables in your database? No problem, just install this handy plugin and with no configuration required you can do that with just the click of a button. If you have a WordPress site and want a boost in performance, as long as the issue(s) causing the slowness are not very uncommon and strange, this is the plugin for you.

Categories
WordPress

WordPress 5.4 “Adderly”

Categories
Travel WordCamp WordPress

WordCamp Montreal 2019

This was the last WordCamp I attended before COVID and little did I know but it was just under the wire. I went to this event with my friend Evan who goes with me to many of the fun WordCamp events.

This event was held right nearby where I was staying at the John Molson School of Business building at Concordia University. Aside from having a nice venue, there were interesting talks about the UX, generating revenue, the JAM Stack and much more.

It was cool to visit another country and then to also learn about WordPress, the thing I love. We had friends who lived in the area who knew of some great places to eat and visit. I had a great time, and I hope all of my future WordCamp experiences are that great.

Categories
Project WordPress

Hosted WordPress Site on raspberry pi

I know this is a deviation from my normal posts but I had to say something because I enjoyed this exciting project.

I used a raspberry pi to host a WordPress website on my local network. Granted, this would have been a better announcement if the website was available everywhere, but I just wanted to set up a headless installation of Ubuntu on Raspberry pi, SSH in from one of my other computers and host a website on the pi.

To be honest, technologically this was nothing special I suppose because it was not a complex website but the site I made was not a complex site, but this was an interesting project.