Category Archives: Development

A new and easy to use WordPress plugin to show or hide content in your blog

I just created a new WordPress plugin that you can use when you have to compress the content in a FAQ or similar. Eg. when the information of your page is to long, you can initially hide content and show it when clicking on a given element.

googley-eye-bird-blue
This bird has nothing to do with the plugin ūüôā Image source

As said above a common use case is a FAQ where the questions are visible and the answers are initially hidden. Have a look at this example:
Use case:

Q1. This is the first faq question
A1. This is the answer for the first faq question.
Q2. This is the second faq question
A2. This is the answer for the second faq question.
Q3. This is the third faq question
A3. This is the answer for the third faq question.


Code for previous example:
<div class="ssh-question">Q1. This is the first faq question</div>
<div class="ssh-answer ssh-hide">A1. This is the answer for the first faq question.</div>

Get the Simple Show Hide for WordPress plugin from any of these locations: WordPress Download or GitHub

Tampermonkey and Greasemonkey to your help when you are not satisfied

greasemonkeyWhen you use a web site or a web based system more or less everyday you find things that you would like to change in the design or some of the functionality. In that case Tampermonkey / Greasemonkey could be your friend if you also have some basic knowledge in javascript.

 

I recently started to play an old computer game called Planetarion. The last time I played was back in the late 90th/early 2000¬†and it still has the same look and feel. Of course it’s some of its charm but I could not resist to fix the most obvious flaws.

tampermonkeyTo make use of Tampermonkey/Greasemonkey you create a javascript file. Then you add the following code to¬†configure the script to be activated only on the site game.planetarion.com and set up some basic includes like JQuery. This code begins the so called “user script”:

// ==UserScript==
// @name Planetarion style script
// @namespace https://www.hoyce.com/
// @version 1.1
// @description A user script that styles Planetarion
// @match http://game.planetarion.com/*
// @author Hoyce
// @require http://code.jquery.com/jquery-latest.js
// @grant none
// ==/UserScript==

In my case I wanted to fix the menu in the game and titles in the browser tabs. One of the things that irritated me the most was that you couldn’t¬†see which page/section you were in based on the menu links. An easy fix for this is to highlight the active link with a distinct color and bold text. (see some javascript code below)

Another improvement was to shorten the title text which is shown in the browser tabs to get a good overview on which tab contains which page when you have several tabs open in your browser.

 

function setActiveLink(element) {
  var menuItem = $(element);
  menuItem.css('font-weight', 'bold').css('color', '#47b4fa');
}
 
function setTitle(title) {
  $('title').text('PA ' + title);
}

if(window.location.href.indexOf('fleets.pl') > 0) {
  setActiveLink('li#menu_fleets a');
  setTitle('Fleets');
}

Activate your script in your browser

To make use of your script you have to install the browser plugin which depends on the browser you use. Use Tampermonkey for Chrome/Opera/Safari and Greasemonkey for Firefox.

Then activate the the script you just created and make use of its extra functionality!

Get the code form GitHub: https://github.com/hoyce/planetarion-scripts     GitHub-Mark-120px-plus

UStream for WordPress and the power of the community

Ustream_Logo_2013 I recently got a support question on my plugin called UStream for WordPress which is a plugin for embedding UStream videos on you blog. The plugin did not seem to work after the WordPress 4.0 update and the user seemed to have at least one client who really needed it.

The reason behind the failure of the plugin was that UStream had changed the way you embed the video from object tags to iframe tags and the fix was easy. I updated my plugin, answered the user and she was happy. And if she was happy, I’m happy!

The WordPress community for the win!

wordpress-logo-notext-rgbWhat I want to say with this is not that I fixed this bug and “Hey, I’m so good”. No, I really want to give thumbs up for the community thing where you can get a lot, and I mean really a lot of functionality for free but also¬†the possibility to give some back witch other can utilize on their WordPress driven sites.

I both use other plugins and on some of them I have reported bugs to the authors. I have in all cases gotten help pretty quickly and been able to continue to use their plugins and have not been forced to do the hard work of building these plugins my self.

There is one thing I want to encourage people to do when they use plugins they get for free and that is to give back a review of the plugin. Either by just mark the grade of the plugin or write a word or two what you think of it. This will help contributors to get their work used by even more people and probably make them put more effort in creating awesome stuff.

The WordPress community for the win!