Xcode for WordPress Plug-in Developers

This post is an extension to this excellent article except with a subtle difference, I’m not interested in hacking the WP core, I’m writing a plug-in :)

I’m going to assume that you’ve requested access to WordPress.org’s SVN repository, and you’ve found the admin panel and want to get your Xcode goodness hooked up to the WP SVN.

To get started create a new Empty Xcode project.

Screenshot of Xcode project chooser Empty XCode waiting for LINICKX LifeStream
Xcode project chooser Empty Project

From the menu bar select SCM then Configure Repositories, the window select the + to add a new repo, the username & password pair are your wordpress.org credentials, you can find the URL to your SVN repo on the wordpress.org site.

WordPress dot org Admin Interface
The WP.org admin interface

Next from the menu bar select SCM then Repositories, highlight the repo you’ve just created and choose checkout; you’re going to be asked for a folder to “save” the contents of the repo to, I chose inside my Xcode project folder.

Checking out with Xcode
Repo’ Config Code Checkout

You now need to add those “checked out” files to you project, in the tree on the left, right/control click the blue project icon at the top and select add existing files, accept the defaults and the repo should be imported.

Code imported
Imported Code

These files now in the project need to be associated with the repo, this is done by highlighting the blue project icon and clicking the “Info” button, then click “Configure Roots & SCM”; click the + button and choose your repo folder (again)… the dropdown on the right should automatically select the correct SCM.

Project LINICKX LifeStream Info WP Xcode Edit Project Root
Project Properties Project Roots

If you now change a file / add / delete / etc it will appear under the SCM tree, you can right/control click and commit to the repo…. job done :)

WP Xcode readme txt changed
Yay it works!

Very quickly you’re going to find out that you want to test your changes prior to commiting them, to do this you may want to copy your files upto a webserver…. I get Xcode to do that for me, using macfuse to mount my webroot via ssh but for this example I’ll create a directory on the desktop … you also need to create any subdirectories you may need.. I have to create “admin”.

To copy the files we’re use an Xcode target, from the menu bar choose Project then New Target then Copy Files Target, I called my new target CopyFile. Using the info button change the absolute path of the copy – e.g. /Users/Nick/Desktop/LL … now here I ran into a problem (suggestions welcome)… next I created extra copy build phases for each subdirectory. Control/right click your Target ( i.e CopyFiles) then choose Add, New Build Phase, New Copy Files Build Phase… I then set the absolute path of this “sub target” to /Users/nick/Desktop/LL/admin/ to represent my admin subdirectory.

Finally DRAG down the files into their correct target, all being well and a fair wind clicking “BUILD” will cause your files to be copied into your directory. You can now make changes, click build to test, and then commit them to subversion when you’re happy :)

WP Xcode - Finished
Finished!

The red sweater post that inspires this now talks about creating a RUN shortcut to automatically open a web browser for testing, however mine didn’t work… I got this error “The program being debugged is not being run“… suggestions to fix welcome!

phpbb_recent_topics version 0.6

UPDATE: This Plugin has been updated, the below links to the new file, but please comment on the new post, thanks.

Screenshot phpbb_recent_topics admin page

Screenshot phpbb_recent_topics admin page

Admin GUI

It’s that time again, enough things have happened in the support forum to warrant another version.

phpbb_recent_topics 0.6 owes a debt of gratitude to number3nl he has worked very hard to push in two main new features and his work was so good it only needed a couple of minor tweaks from myself.

New Features!

  • The loooong awaited phpBB recent posts feature has been enabled, simply tick the box that says “Sort results by post date” and you’re away!
  • Tooltips are here! Yup if you’re into that kind of thing enabling tool tips will show a snippet of the post content to your visitors prior to them clicking on any links.
  • Admin UI Error Messages are here; the GUI will now inform you if you’re connected to phpBB.

Bug Fixes.

  • The variables in display.php now match those of admin-display.php; hopefully this will make community contribution simpler.
  • Uninstall.php has been added so removal of the plugin is more comprehensive.

A note to upgrader’s.

  • If you’re using secure database connectivity you’ll need to GRANT access to the posts table….
    GRANT SELECT ON phpbb_database.phpbb_posts TO wp_user@localhost;

Download phpBB_Recent_Topics_0.6 from wordpress.org

The usual stuff now follows….


The Installation

Before starting you need to get your database configuration sorted. So, are you going to connect to the PHPBB Database securely or Insecurely?

To connect Securely you need to GRANT access TO WordPress FROM phpbb.

How to GRANT wordpress read only access to phpBB ?
If you don’t know it already you need to find your wordpress mysql user id, it’ll be in wp-config.php

define('DB_USER', 'wp_user');     // Your MySQL username

and you should have already found your phpbb database & table for the above.
You need to type the following syntax into your mysql database

GRANT SELECT ON phpbb_database.phpbb_topics TO wp_user@localhost;

AND

GRANT SELECT ON phpbb_database.phpbb_forums TO wp_user@localhost;

AND

GRANT SELECT ON phpbb_database.phpbb_posts TO wp_user@localhost;

this can be achieved by logging into phpmyadmin as your phpbb user, selecting SQL and pasting the correct GRANT into the text box.

WordPress Installation

  • Unzip phpbb_recent_topics.tgz in your `/wp-content/plugins/` directory. (You’ll have a new directory, with this plugin in /wp-content/plugins/phpbb_recent_topics)
  • Activate the plugin through the ‘Plugins’ menu in WordPress
  • Configure the plugin, you need to tell wordpress about phpbb, this is done in the wordpress menu ‘Settings’ -> ‘phpBB Recent Topics’
    The following Settings are required:

    • * The name of your phpBB database (e.g phpbb)
    • * The name of the table where topics are held (the default is phpbb_topics )
    • * The full url of your forum for links (e.g. http://www.mydomain.com/forum)
    • * The number of topics to show. (If left blank you get 5)
    • * The Date Formatting, i.e. “d/M/y – g:i a” similar to the WordPress “General Settings”
  • The use of Insecure connectivity is optional – See Below
  • Tick the boxes of any Forums you don’t want this plugin to show posts from
  • Hit ‘Update Options”
  • To output the list of topics in a page or post…
    • * create a new page/post, type {phpbb_recent_topics} , hit ‘Publish’ or ‘Create new page’

    To output the list of topics in your theme sidebar using the widget…

    • * click “design” in the dashboard
    • * click “widgets”
    • * next to phpBB Recent Topics click “add”
    • * click “save changes”

    To output the list of topics in your theme sidebar using a template tag…

    • * edit sidebar.php and inside <div id=”sidebar”> type…
      <?php
      if (function_exists('phpbb_topics')) {
      phpbb_topics();
      }
      ?>

What is Insecure MySQL Connectivity & How do I use it?
If you need to you can connect in a less secure manner, the connection details held in your PHPBB config.php can be loaded into WordPress. This is insecure becuase the phpbb3 credentials are store in clear text, this is bad cuase if someone somehow comprised WordPress they’d have full access to PHPBB.

To use, tick the “Enable Insecure Database Connection” box, and submit, when the page re-freshes you’ll have some more boxes to populate, from your phpbb config.php fill in


$dbuser = phpbb MySQL Database UserName
$dbpasswd = phpbb MySQL Database Password
$dbhost = phpbb MySQL Server

Click update, and you should be connected!

Support
I’ve always been honest about support, there isn’t any. Basically I write this for my own needs and then publish it for you to use for free. You’re more than welcome to post comments here and if you need support the community phpbb-recent-topics forum is available, I do read every post there but we all have busy lives and I make no promises on how quickly I’ll reply to you.

Finally Subversion
The source for this plugin is in the wordpress subversion, you can checkout the trunk directly from here, if you weren’t aware wp.org also auto-magically creates a nightly build of any developments here.

I hope you enjoy my plug-in!