1082array_merge behaves differently in PHP 7 and PHP 8

The array_merge function produces unexpected results on a PHP 8 server, as compared to a PHP 7 server.

$output = array_merge($array1, $array2);

In PHP 8, if array2 is empty, the $output array is also empty.

In PHP 7, if array2 is empty, the $output array is $array1.

TODO

  • [ ] Make test page.

1080Running Different Versions of XAMPP on OSX

XAMPP is an open-source bundle of Apache + MariaDB + PHP + Perl and most popular PHP development environment. It bundles different versions of PHP and allows for local development of Apache/PHP server setups.

After installing a PHP 8 version of XAMPP - and renaming the XAMPP folders - I got the following error message:

Apparently, XAMPP does not like being renamed.

Workaround: Rename the version you want to work with to XAMPP, then the manager-osx will start.

1077GitHub Desktop not pushing to server?

Increase the http.postBuffer:

git config http.postBuffer 524288000

1075Generating a Random Password with pseudo-random bytes

openssl rand -base64 12

rand
Generate pseudo-random bytes.

base64
Base64 Encoding

1073Javascript Images Sliders and Lightboxes

An evolving list of JS Image Sliders and Lightboxes.

Image Sliders

Slick - "the last carousel you'll ever need"

Swiper - "The Most Modern Mobile Touch Slider"

  • v11.1.12, September 1, 2024
  • 39.5k Github stars

Lightbox

Slick + Lightbox

  • Building upong Slick
  • no longer in development

Gallery/Slider AND Lightbox

PhotoSwipe

  • v5.4.4
  • 23.9k Github stars

TODO:

  • make examples and test

1072WordPress Multisite and Switching Subdirectories

Notes for changing Wordpress Multisite Subdirectories:

Step 1

Update siteurl & home in wp_X_options Don’t forget the trailing slash

Step 2

Change corresponding paths in wp_blogs

Step 3 (Optional)

Clear Caches

Step 4

Check Image upload folders

Step 5

define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

1068NVM – Node Version Manager

The Node Version Manager allows for the installation and use of different versions of node and npm.

nvm install v18.20.4
Downloading and installing node v18.20.4...
Downloading https://nodejs.org/dist/v18.20.4/node-v18.20.4-darwin-x64.tar.xz...
######################################################################### 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v18.20.4 (npm v10.7.0)
nvm use v18.20.4
Now using node v18.20.4 (npm v10.7.0)
npm -v
10.7.0
node -v # v18.20.4

1065Not-so-advanced Custom Fields

The traditional Custom Fields in Wordpress have been around since the beginning, gives some degree of customability to the posts. They are very basic, but the work.

Soon after, the Advanced Custom Fields become the norm, adding a nice UI on top of the custom fields, and enabling things like checkboxes, time/date, repeater, etc.

All was great in Wordpressland, but the ACF were sold to WP Enginge who are now trying hard to monetize the ACFs. Instead of payment per installation, they now moved ACFs to a monthly/yearly subscription model.

I still keep using ACFs for client work, but try to remove it from my personal sites - like this one. All it did was to have a checkbox to enable/disable Markdown on the posts.

Markdown is now by default on, ACF no longer needed.

Also, I was stuggling to show the original Custom Fields:

Only AFTER I uninstalled ACF, the option showed up again!

1063Selector Magic in ProcessWire

ProcessWire's way of selecting ("getting") child pages is usually like this:
Get all children

$events = $page->children();

This can be fine-tuned with the Selector string.
Get all children, where the date or end_date is later than today, sort the results by date.

$events = $page->children("date|end_date>today,sort=date");

This works great, by we recently had a case, where a schedule talk had to be postponed to an unknown date in the future. I left the date field in the Backend empty, we need to modify the selection string:
Get all children, where the date or end_date is later than today OR where date is empty, sort the results by date.

$events = $page->children("(date|end_date >today), (date=), sort=date");

It's beautiful, that it's just a small change in the selection string:

  • The additional parenthesis () around (date|end_date >today) and (date=) specify an OR relation. Default is AND, here it means: select children with either (date|end_date >today) OR (date=) - no date.
  • date= means that the date field is empty

Resources

1062Resetting a User Password in ProcessWire

It happens to best of us: You have an local installation of your favourite CMS - and then you can't remember the password! Login throtteling kicks in, you still can't remember it. And this being a local XAMPP installation, you can't send an email to recover the password.

Here is Ryan1 to the resuce:

You can always reset your password just by pasting this temporarily into any one of your templates, and then viewing a page that uses the template:

$u = $users->get('admin'); // or whatever your username is
$u->of(false); 
$u->pass = 'your-new-password';
$u->save();

1 Who is Ryan? Ryan Cramer is the founder and lead developer of ProcessWire.