Gutenberg Color Pallette

I know that the rather lovely Gutenberg isn’t supposed to be used on production sites yet but I figure this blog doesn’t really count so I’m using this as my playground. I am also very aware that Gutenberg has split opinion in the WordPress community and there are a lot of issues to work through but, as I mentioned very briefly before, I am enjoying Gutenberg and like the direction it is taking WordPress as a content editor.

There will be a lot of head scratching and working out to be done to make sure sites I’ve made work with it, and to work out how Gutenberg sits alongside all the WordPress site builders that I’ve inherited over the last few years, but I’ve added it in to my work flow for site development now, taking me away from encouraging people to use something such as Divi or similar. They are great, but, when simplicity is desired, Gutenberg works for me.

add_theme_support('editor-color-palette',
'#ba1200',
'#031927',
'#9dd1f1',
'#508aa8',
'#c8e0f4'
);

Anyway – enough of that – the above code snippet is one of my new favourite things. It is, I think, pretty obvious what it does – as the code suggests it edits the colour palette options that are available in the Gutenberg editor (for those of you who don’t know Gutenberg – see the image, it’s a handy little Background / Text Colour editor). Drop the snippet in to your theme’s functions file and you’re away.

Simply put, this snippet lets you, the designer / developer behind the website, encourage the content creator for the site to use specific colours within their content. Very handy! The colour picker remains in place so people can go off-piste if they are that way inclined although even that functionality can be removed with the addition of add_theme_support('disable-custom-colors') if you need such restrictions.

Nice.

NB Thanks to Coolers.co for the colour scheme in this example.

ftp_connect

$ftp_conn = ftp_connect($host) or die("Could not connect to server");
$login = ftp_login ($ftp_conn, $user, $password);

I am pretty sure that ftp_connect isn’t recommended from a security point of view, and probably hasn’t been for a couple of hundred years.

Having said that, it turns out that when a third party says ‘to hell with the security concerns’, and only gives you access to FTP for an order process it’s pretty straight forward to connect with the PHP I’m putting together.

Fun.

Welcome Prefix

function replace_prefix( $wp_admin_bar ) {
 $my_account=$wp_admin_bar->get_node('my-account');
 $newtitle = str_replace( 'Hi,', 'Logged in as', $my_account->title );
 $wp_admin_bar->add_node( array(
 'id' => 'my-account',
 'title' => $newtitle,
 ) );
 }
 add_filter( 'admin_bar_menu', 'replace_prefix',25 );

It’s the little things that make me happy. Like controlling the WordPress prefix to the username in the admin bar. Here from a simple “Hi” to a “Logged in as” notification.