Show only user’s own media files in WordPress

Show only user’s own media files in WordPress

The problem I recently did a site for a client in wordpress which required a custom user type. These users needed to be able to use the media library but only to see their own media files. One would have thought that this is actually quite a common scenario so I thought that implementing it would be simple enough… In my research I came across a wordpress plugin called “View own posts media only”. This apparently worked well for a…

Read More Read More

Creating a new laravel site

Creating a new laravel site

Having installed Laravel you’ll now want to create your first Laravel website. Creating the new Laravel site In the command line navigate to the parent directory which contains all your web projects. On my Ubuntu system my projects are all in /var/www/html, so on the command line: cd /var/www/html Decide on a name for your project. We’ll call ours my-cool-website. Now run the new command from the command line like this: laravel new my-cool-website            …

Read More Read More

Node / NPM to manage JS / CSS in Laravel

Node / NPM to manage JS / CSS in Laravel

To manage your js and css files in Laravel you could place your js and css files in the public directory, but using the /resources/assets folder you can add your js and css (sass or less, etc) in there. You then need to compile these with nodejs and NPM. To install nodejs / npm on Ubuntu you can use sudo apt-get install nodejs Once installed in a terminal window navigate to your Laravel project directory and type: node install Once…

Read More Read More

Installing Laravel

Installing Laravel

Laravel is a PHP framework so we need to start with a L(W)AMP server of some sort. We recommend PHP 7 but from PHP 5.6 will do. Laravel is easiest to install with Composer. Once Composer is installed according to their instructions, we can use it to install Laravel. There are different methods of installing Laravel but I prefer installing it as a global package on the system. To do this, on the command line type: composer global require “laravel/installer”…

Read More Read More

WordPress wp_remote_get

WordPress wp_remote_get

I was recently working on a project which involved using WordPress cron for some automated tasks. Although the function wrapping the call to the WordPress even scheduler reported being called, the ‘work’ was not being done (in this case retrieving data from a remote server). This was particularly strange because if I ran the functionality manually it worked. Note: I inherited this system from another developer so any references to code duplication are not of my doing! Upon closer investigation…

Read More Read More

Creating Separate Categories for Learndash

Creating Separate Categories for Learndash

I was recently tasked with assisting in setting up a website which needed, amongst other things a Learner Management System. One of the go to LMS for WordPress is the Learndash plugin. I installed Learndash and then proceeded to set up a test course. Now, the idea with this website (which I believe is common to many sites) is that there would be both a courses section as well as a blog. The blog would have categories like “Getting Started”,…

Read More Read More

Creating a Simple .htaccess redirect

Creating a Simple .htaccess redirect

RedirectMatch uses a regular expression that is matched against the URL path. And your regular expression /contact.php just means any URL path that contains /contact.php but not just any URL path that is exactly /contact.php. So use the anchors for the start and end of the string (^ and $): RedirectMatch 301 ^/contact\.php$ /contact-us.php redirect 301 /contact.php /contact-us.php

Spam Trap for Contact Form 7

Spam Trap for Contact Form 7

This plugin adds spam checks to catch contact form 7 spam. It does so in the background without annoying your legitimate users with captchas. It adds a hidden field to the your contact form 7 form and then checks when a contact form 7 is submitted for that field. If its not present, or its filled in, then we can be sure that it was a bot of some sort. It also adds the ability to check for links in…

Read More Read More

PHP Namespaces

PHP Namespaces

PHP namespaces allow you to namespace your functions! Ok, so I know that’s circular reasoning. Let’s see what that means. We’re all familiar with the way that files and folders work on our PCs. If you have two files with the same name, then they cannot exist in the same folder. So, if I have a file called notes.txt with all my work related notes, then I can’t also have a file called notes.txt with all my personal related notes…

Read More Read More

How to fix WordPress after changing table prefix

How to fix WordPress after changing table prefix

In this article find out how to fix WordPress after changing the table prefix. In your wordpress wp-config.php file you have a $table_prefix variable, which by default is set to “wp_”. If you need to change that on an existing wordpress site then you’re in for a bit of a battle. On a site I’m working with we needed to change the table prefix when moving the site to a new server. Changing the table prefix meant that we weren’t…

Read More Read More