Blog

How to declare a class in PHP

Posted by on 1:26 pm in Knowledge Base | Comments Off on How to declare a class in PHP

Since PHP 5 we can use object oriented features in PHP. This allows us to not only use functions and variables, but also write classes and create instances of them in our code. Here’s quick rundown on how to do it. Writing and instantiating a Class Creating classes is very similar to writing functions. Here’s an example of a class with one method and one variable: // creating a basic class with one method class Test { var $testValue = 47; function sampleFunction() { echo "Hello from the Sample Function!\n"; } } Once declared, we can...

read more

How to switch off emails from Anacron in Plesk Onyx

Posted by on 1:24 pm in Knowledge Base | Comments Off on How to switch off emails from Anacron in Plesk Onyx

In 2011 I wrote an article about how to avoid emails from Dr. Web. In it I was discussing how to switch off these notifications, which are generated when the Dr. Web service updates itself. Here’s an example: /etc/cron.daily/drweb-update: Dr.Web update details: Update server: http://update.msk5.drweb.com/plesk/700/unix Update has begun at Fri May 18 03:53:47 2018 Update has finished at Fri May 18 03:53:54 2018 Following files have been updated: /var/drweb/bases/drwdaily.vdb /var/drweb/bases/drwtoday.vdb /var/drweb/bases/dwmtoday.vdb...

read more

Fan Maintenance on my Samsung NC10

Posted by on 1:46 pm in Knowledge Base | Comments Off on Fan Maintenance on my Samsung NC10

My Samsung NC10 Netbook has been in constant operation since 2013, for 24 hours a day, 7 days a week. It’s doing a great job as our internal office server, purring along quietly running CentOS 6. When I put it in operation 5 years ago, I made sure no mechanical parts we being used anymore to avoid wear and tear: I’ve added an SSD, and once a day valuable data is backed up on a permanently mounted SD card. The only mechanical thing still in use is the internal fan. I knew the day would come on which the poor thing would either give up and need...

read more

How to host multiple websites with Apache

Posted by on 1:45 pm in Knowledge Base | Comments Off on How to host multiple websites with Apache

The Apache web server has a convenient feature called Name-based Virtual Hosting. This function allows us to have a single LAMP Stack server configured on one IP address, but serve a different set of files depending on which domain is being requested. This sounds more complicated than it is. Say we had example1.com and example2.com, both of which are to be separate websites, but both domains point to the same IP address. Apache’s Name-based Virtual hosting makes this possible. In fact, this feature forms the basis of 90% of this planet’s...

read more

How to increase the font size in Automattic’s P2 Post Box

Posted by on 12:51 pm in Knowledge Base, Themes | Comments Off on How to increase the font size in Automattic’s P2 Post Box

Front page posting is what the P2 theme is all about – but I personally find the default font size on the front page a bit too small. Perhaps it’s my raging tired eyes. In every child theme I write for P2, I usually increase this – both for immediate posting, as well as for text editing (which also happens inline on the front page). To do that, add the following to your style.css file: /* larger text for post box and editing */   #postbox textarea #posttext, textarea.posttext {   font-size: 1.3em !important; } This will address the font size...

read more

How to update legacy constructor methods in PHP 7

Posted by on 1:44 pm in Knowledge Base | Comments Off on How to update legacy constructor methods in PHP 7

When I was fiddling with my P2 Categories theme last week, debug mode generated several warnings when run in PHP 7.2.1. That’s because class methods are no longer allowed to have the same name as the class itself. This was allowed in PHP 5 and earlier, but from what I gather it’s no longer the way to do things. Back then such methods were used as constructors, or in other words, methods that would be run automatically when the class is instantiated. Let’s take an example from the P2 theme. Here’s the beginning of the P2 class as of version...

read more

P2 Categories – Version 1.6 released

Posted by on 1:52 pm in Knowledge Base, Themes | Comments Off on P2 Categories – Version 1.6 released

  Last week I found some time to update my fork of Automattic’s P2 theme, aptly titled P2 Categories. In addition to all the greatness of P2, it’s been adding front-page category posting since 2013 (and hasn’t seen an update since then either). Here’s what’s new in the latest version: fixed the drop down menu, which was no longer working since Safari 10 rewrote the whole theme from scratch, based on P2 v1.5.8 (2016) fixed a bug that would not show the correct number of posts in a category added new p2-categories-functions.php file updated a...

read more

How to display categories in Automattic’s P2 Theme

Posted by on 2:04 pm in Knowledge Base, Themes | Comments Off on How to display categories in Automattic’s P2 Theme

By default, Automattic’s phenomenal P2 theme does not support posting into categories from the front page, it only supports tags. My fork of the theme called P2 Categories does that though and lets you conveniently select a category from a drop down menu right there on the front page. I wrote an update to it last week, and in so doing my article from 2013 came in handy that explains how to add this functionality to P2. Nothing much has changed in the source code, so it’s still relevant and accurate. What the above article did not explain...

read more

How to hide the Promo Box in Plesk Customer View

Posted by on 1:56 pm in Knowledge Base | Comments Off on How to hide the Promo Box in Plesk Customer View

There’s a small Promo Box on the right hand side in Plesk’s Customer View. This box can be a little confusion for users – especially when it shows products and extensions with highly cryptic names. Here’s an example: Lucky for us, there’s an easy way to remove it. All we need to do is create a vile called /usr/local/psa/admin/conf/panel.ini and add the following content to it: [promos] ; Disable other products promotions enabled = off   This file is read by Plesk every time the panel loads, telling Plesk what to display in the admin...

read more

How to install PHP 7.x on a CentOS LAMP Stack

Posted by on 1:24 pm in Knowledge Base | Comments Off on How to install PHP 7.x on a CentOS LAMP Stack

By default, CentOS 7 comes with support for PHP 5.4. Sadly that version has reached the end of its life in 2015and is no longer updated by the developers. If we want to stay up to date with the latest software, we may want to upgrade (if our applications are working with newer versions of PHP). For CentOS users this either means to compile cutting edge versions from source and tweaking lots of scary system configurations – or dipping into the power of Software Collections. These are official pre-compiled packages by the software vendor,...

read more