preload
May 04

I have not been active visiting my own blog lately and when I opened it today it did not look very good. Actually it was broken with an error message on the top of the page and no posts/articles showing.

Warning: Parameter 1 to fb_update_comment_type_cache() expected to be a reference, value given in /home/breathin/public_html/wp-includes/plugin.php on line 230

php_issue

breathingtech.com earlier today when I first noticed this issue

Since I had not attended the website for a while I hoped that just doing some updates of WordPress and plugins would fix the problem but it did not. It is the theme I am using that is causing this problem and I am not updating the theme since I have done a lot of changes to it.

Continue reading »

Tagged with:
Feb 04

I have developed a plugin for WordPress that is called DiveBook with the purpose of logging dives. I have now had it published at WordPress Plugin Directory for a while as a beta version. In this post I will talk about bugs and issues I experienced during the beta period and how I solved them.

Unexpected output during activation

The first issue I got was that when activating the plugin the following error message were displayed

The plugin generated 2 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin

Continue reading »

Tagged with:
Jan 13

My DiveBook plugin is completed and I want it to be listed in the WordPress Plugin Directory. This way it will be easier for others to install and read about the plugin. Before you get your plugin listed there is a few steps you must do and a few steps I think you should do. In this post I will talk about what I did to make my DiveBook plugin ready for the world.

First your plugin needs to follow a few restrictions set by WordPress. Then you need to sign up, send request for WordPress to host your plugin and add your plugin to the Subversion repository (you get access to the svn repository when WordPress have read and accepted your hosting request). You also need to create a readme.txt file for your plugin. You can read about the steps above at the WordPress Developer Central.

When it comes to writing the readme.txt file you should spend some effort to make this file detailed and good. All the information a potential user of your plugin will read is parsed from this file. Most important is to have a good description about the plugin, screenshots of the functionality and a good description on how to install and use your plugin.

This is all you need to do. WordPress will automatically publish your plugin from the subversion repository.

Continue reading »

Tagged with:
Jan 04

When developing a smooth plugin for WordPress you will quite often need to supplement php and html with some kind of scripting language. To make the floating input form for the DiveBook plugin I used jQuery and I used Javascript to validate user input and redirecting.

To include your script files to the plugin you need to add the following code in your main php file:

//Add script
add_action('wp_print_scripts', 'divebook_enqueue_js');

function divebook_enqueue_js () {
    wp_enqueue_script('divebookFunctions', WP_CONTENT_URL . '/plugins/divebook/functions.js', array('jquery'),'1.0.1');
    wp_enqueue_script('divebookPopup', WP_CONTENT_URL . '/plugins/divebook/divepopup.js', array('jquery'),'1.0.1');
}

Continue reading »

Tagged with:
Nov 11

I am writing a WordPress plugin called DiveBook that is a plugin for logging dives and view other logged dives. The main part of this plugin is the input form for logging dives and a view where users can search and view logged dives. I want the WordPress administrators using this plugin to be able to inject the plugin in posts or pages. This post describes how I achieved plugin injection to posts or pages.

I chose to enable injection of the plugin (and php in general) by adding a filter that is evaluating the content and looking for php executable code inside a defined bracket.

First I add the filter in top of my main php file (divebook.php). In the filter I hook the content to function filter_php_code

//Add filter to filter executable php code in content
add_filter('the_content', 'filter_php_code', 0);

Continue reading »

Tagged with:
Nov 07

In this post I will explain how I use the WordPress database (MySQL) for the DiveBook plugin I am currently developing. For my plugin I am using the options table in WordPress for storing options and settings for my plugin. The DiveBook plugin will be storing information about dives and for this I am creating new tables in the WordPress database.

In my previous post “Getting started with WordPress plugin development” I talked about how to create a widget for the plugin and how to save options for the widget in the control panel. In the widget.php file I used the option table to store and retrieve the data.

The following code will store data to the options table when the user submits the options.

        //Store title and numdives in options table
        if ($_POST['divebook-submit']) {
            $options['title'] = strip_tags(stripslashes($_POST['divebook-title']));
            $options['numdives'] = strip_tags(stripslashes($_POST['divebook-numdives']));
            update_option('divebook', $options);
        }

Continue reading »

Tagged with:
Nov 05

This post will describe what you need to do to get started with WordPress plugin development.

First you should install WordPress on your localhost to make it easy to test what you are developing. Good instructions about installing WordPress on your own computer can be found at wordpress.org Installing WordPress. I am using Windows 7 so I first installed Windows Web Platform Installer and then launched the WordPress installation from Web PI. I just used the default settings for ISS and selected to create a new database for this installation.  WordPress is now installed and I can access it at http://localhost/wordpress. I also find all the installed WordPress files in the inetpub directory on my drive.

After getting some tips on Twitter I downloaded and installed PhpStorm by JetBrains to use as my IDE for php development. There is a 45 days free trial license available.

To make live testing while developing I decided to work directly on the inetpub directory. I created a folder for my plugin called “divebook”. In PhpStorm open directory to work on. For my plugin the directory is: C:/inetpub/wwwroot/wordpress/wp-content/plugins/divebook/

Continue reading »

Tagged with:
Aug 12

I am responsible for the local scuba dive club, Ikornnes Dykkerklubb, back home in Sykkylven. To make it easier for club members and others to follow what is going on at the website I decided to integrate it with Facebook.

First I created a page for Ikornnes Dykkerklubb at Facebook and registered a developer account to my personal profile so I could add a application to connect with the fan box also added to the web page. Now I wanted to have information about new posts at the website published to the Facebook page and I also wanted comments on posts at the webpage to be published.

My first approach was to use Facebook Connect API and add the logic to the website. I have never used the Connect API before and I am not usually coding in php (the website is running WordPress) so I decided to try to find an easier way to achieve this. I also installed some WordPress plugins, some of these plugins did the job but I was not 100% satisfied.

Continue reading »

Tagged with:
Jul 07

I wanted to make it as easy as possible for my blog readers to directly retweet my posts. First I started to install and test several WordPress plugins for this but I just couldn’t seem to find one that I liked. Some of them are to massive and are showing information about how many and who has retweeted your post, I don’t need that. Other required the Twitter Anywhere connection and the user must accept that the retweet application on my blog can connect directly to their Twitter account, I don’t want to force my readers to do this. I decided to create the Retweet functionality by myself so I would have full control on the behavior. This post will tell you step by step how to achieve this.

First I wanted to shorten the post url by using Bit.ly, I am not a php expert or familiar with the Bit.ly API so I googled and found the php code needed for using Bit.ly to shorten my url. I found a great example at www.devmoose.com in a post called Automatically Create a Bit.ly URL for WordPress Posts. Just follow the steps in the referred post at devmoose.com to achieve this.  I did a minor modification to the code to make it work in my WordPress : I added “<? php” before the code and  “?>” after the code. I also added the “if function exists” check.

The complete code to add in your functions.php file:

<?php
//create bit.ly url
if ( !function_exists(‘bitly’) ) {
function bitly()
{
//login information
$url = get_permalink(); //generates wordpress’ permalink
$login = ‘yourbitlyusername’; //your bit.ly login
$apikey = ‘yourbitlyapikey’; //bit.ly apikey
$format = ‘json’; //choose between json or xml
$version = ‘2.0.1’;

Continue reading »

Tagged with:
Aug 27

Today I did some cleaning on my laptop; removing old unused programs and updating/installing new programs. When I installed the newest Windows Live package I got the Windows Live Writer and thought that I would give it a try.

It was very easy to get started, just run the program, type the url to your blog and provide your username and password. I needed to do one change in my blog settings and that was to enable XML-RPC for remote publishing. You find this option under Tools –> Writing

It is very easy to insert several different medias when using Windows Live Writer (link, image, album, table, codes, map, video).

I also like the feeling to write in a program and not directly from my browser. I will play around using this program for my next posts and then the time will show if this is my new preferred publishing tool.

Tagged with:
Subscribe to my feeds Follow me on Twitter
DZone MVB