Archive for the Programming Category

Rapid Development

Posted in Programming, Software with tags , , , on November 10, 2009 by sinsearch

I think I must be mentally ill as I started wanting a Mac having I saw the product “Model Baker” advertised on Mac World. I wasn’t looking for anything Mac related but instead I was looking for a rapid development platform to handle user management type tasks.

Model Baker is a nifty like product that allows you to build simple database driven applications without any coding. Instead you create models, views, set relationships between them and also assign attributes. As apart of the process you can assign a theme to it and just click a button to build the entire application; add, edit, delete, view records.

Then from this you can add your own custom code to further develop the application. Having the advantage of being able to utilize a rapid development application such as Model Bakers turns a 1 week job into 20 minutes. Excellent stuff.

Model Baker like with all Mac based applications is really expensive. A single user license is $399 which is rather excessive in my opinion and of course you have to have a Mac with an intel processor. Anyone care to give me a Mac?

Drop Down Menu Tweak

Posted in Programming, Wordpress with tags , , , on November 8, 2009 by sinsearch

I just noticed that there is yet another location in the Buddy Press core where blogging functions are used and that is in the search bar type box:

dropdown01

Since on this platform there is only going to be the 1 blog which controlled entirely by admin then there’s no need to offer the function of searching for all blogs on the platform. To remove this code then we need to open the file; “wp-content/plugins/buddypress/bp-core/bp-core-templatetags.php” and remove the following block of code:

dropdown02

This bit of code simply adds the “Blogs” option to the drop down menu if the BB Blogs is installed. So deleting this code removes the option from the menu. If you prefer you can put a ‘#’ symbol to the left of “$Selection_box” which will comment this line out so its not executed but it still remains in the source code for any future use or just for reference purposes. Many programmers like to leave original code in place, which is fine. Whatever!

Buddypress, Template Tweaks

Posted in Programming, Tutorials, Wordpress with tags , , , on November 7, 2009 by sinsearch

This social networking software sits on a wordpress platform then it inherits all its blogging functionality. For me personally I don’t want people to have their own blogs as it makes it too difficult to monitor content and to ensure the audience is looking at the advertising spots. With the blogging functions enabled then users can use their own templetes and widgets which could be used to block content that we want people to see.

I wanted a platform that has one central blog that is controlled by admin (me) that can be used to public content with the extra benefits a social networking activities around it, thus; groups, internal messages, friend lists, activity streams and detailed user profiles. I don’t particularly want users to have their own blogs. Additionally, after further testing I found BBPress integration doesn’t actually work that well; it doesn’t actually display posts which is a bit of a fundamental issue!

Unfortunately to make this happen then some low level code edits to remove “forum” and “blogs” items from pages as well as menus. Firstly, to get rid of the two tabs for forum and blogs then we need to edit the theme file; wp-content/themes/bp-sn-parent/header.php and remove the following block of code:

tweaks01

And also the following block needs to be removed:

tweaks02

(If you don’t want to delete the bits of code, comment them out instead)

The next few steps involves actually editing some files. within the wordpress admin screen under the Buddypress menu select the component set-up option. From here turn off the Forum component and save the settings. You can also now delete the BBPress folder from your ‘wp/’ directory as well as the ‘BBPress Integration’ Plugin as its pointless.

Next we need to remove the ‘Random blogs’ element from the menu at the top of the page. We need to open the file called ‘/wp/wp-content/plugins/buddypress/bp-core/bp-core-adminbar.php’ and remove the following bits of code:

tweaks03

Within the same file we want to change the name of the “My Blogs” menu item to “News” too. So to do this look for this piece of code:

tweaks04

Just change ‘My Blogs’ to ‘News’ and that should do it. You might notice the code below it refers to creating and editing an existing blog. We can leave this code since we are going to switch off new blog registrations within wordpress itself. Thus this code will never be executed any way.

Next remove the Blog items off the profile page users see on logging in and the My account menu at the top of the screen, which can be done with a single edit. Open the file ‘/wp/wp-content/plugins/buddypress/bp-blogs.php’

Remove the following bit of code:

tweaks05

What the code above does is to add an item to an array which is later used for Buddypress in several places. So, obviously removing the code means that the Blog items won’t be used any where.

Finally, log into WordPress MU as admin and from the menu on the left select “Site Admin > Options” and set “Allow new Registrations” to “Only user account can be created” – This should stop new blogs being created when new users register on the site. When users do sign up though, they will automatically become subscribers of the main sites (ie admin) blog and be subscribed to that content.

In the following posts I will be discussing future tweaks plus also looking at changing colours, font and other styling issues.

Enabling the Theme Editor

Posted in Programming, Tutorials, Wordpress with tags , , on November 6, 2009 by sinsearch

In wordpress MU the theme editor is switched off since there’s a security flaw in its design whereby any user is able to change the current theme/template with it. This is a bit of a pain when building a new site as during testing I often want to change a tiny thing or to try something out. Having to log in via FTP, download the file, change it and re-loading it back again is rather inconvenient, making a simple 1 minute job into 5 minutes. So I looked around for a solution to get the theme-editor.php back onto the admin menu.

I discovered that what I had to do was to create a new PHP file inside the mu-plugin folder called "theme-opts.php" (for example) and fill it with the code below:

<?
add_action( ‘admin_init’, create_function(‘$pages’, ‘if(is_site_admin()) return remove_action("admin_init","disable_some_pages");’),1);
add_action( ‘_admin_menu’, create_function(‘$theme_menu’, ‘return add_theme_page( "Editor", "Editor", "edit_themes", "theme-editor.php");’ ));
add_action( ‘_admin_menu’, create_function(‘$plugin_menu’, ‘return add_submenu_page( "plugins.php", "Editor", "Editor", "edit_plugins", "plugin-editor.php");’ ));
?>

This code re-adds some of the options that are available in the single user wordpress software but is missing from the multi-user platform. It’s not really a good idea to leave these options online when the site is open to the public, but for testing/development purposes it is completely fine.

Social Network : Clean up

Posted in Programming, Tutorials, Wordpress with tags , , on November 5, 2009 by sinsearch

To complete the installation process we need to unset some permissions from 777 back to 755 on 3 folders for security reasons.

  1. Login to your Cpanel and start the File Manager.
  2. Locate the folder “wp” and tick the box to the left.
  3. Click the “Change Permissions” icon at the top of the page.
  4. Change the files permissions to 755 and click the “Change Permissions” button.
  5. Double click on the “wp” folder and select both the “bbpress” and “wp-content” folders by ticking their related boxes.
  6. Click the “Change Permissions” icon at the top of the page.
  7. Change the files permissions to 755 and click the “Change Permissions” button.
  8. That’s it!

These simple changes just puts the server permission back to how they were before we went through this installation process.

This is a test site used purely for demonstrating the process of getting WordPress MU, BuddyPress and BBPress to work together. Obviously, the theme does need to be completely re-done as its horrible, but I would need a graphic designer to do that and so I’m not obviously bothering to do that for a demo!

You are welcome to try the installation at: http://www.sinsearch.co.uk/wp/

BBPress Integration

Posted in Programming, Tutorials, Wordpress with tags , , on November 4, 2009 by sinsearch

Integrating BBPress is quite easy thanks largely to the “BBPress Plug-in” we uploaded several days ago. Even so, to complete the installation we also have to add a bit of code that it generates to a configuration file. Its a simple case of yet more copy and pasting, so not that hard!

Lets get started..

  1. Login as Admin into your wordpress; thus http://www.sinsearch.co.uk/wp/wp-login.php
  2. Click on the Plugins menu option (on the left hand side).
  3. Click on the Activate link next to the “BBPress Integration” plugin.
  4. Under the “Settings” menu on the left, click the “bbpress Integration” option.

This give’s you some more options to fill in. For my installation these are the values I have used:

bbinteg01

Another words, I’ve given the URL of the forum and just told the software that I am running WordPress MU rather than the single user edition. This produces the following page with some PHP code that needs to be added into a WordPress configuration file; “wp-config.php”. Copy this code into your notepad file for the next bit.

bbinteg02

Adding the Code to wp-config.php

  1. Login your cpanel and start the File Manager.
  2. Navigate to the folder that you installed WordPress into; the “wp” folder.
  3. Inside the “wp” folder, highlight the “wp-config.php” file (tick the box)
  4. From the top of the page click the “Editor” icon.
  5. Location the section just above “/**#@+ * Authentication Unique Keys.”
  6. Just above this line copy the PHP code from your notepad into the line above.
  7. Click “Save Changes” and your done.

The final step in the integration is to tell Buddypress to use the BBPress forum software. To do this:

  1. Login as “admin” on to your wordpress installation.
  2. From the menu on the left click the BuddyPress section.
  3. From the Buddypress drop down menu select “Forum Setup”.
  4. Click the “Use Existing Installation” button.

On this page Buddypress is asking for the path to the “bb-config.php” which if you remember sits inside the “bbpress” folder that in itself is inside the “wp” folder. In my case all I’ve have got to do is append the string “/wp/bbpress/” to the end of the line (do not include the double quotes) and press the “Complete Installation” button.

That’s the installation process complete only leaving a little bit of tidying up to do which I will address in my next post. You can view the installation so far by going to http://www.sinsearch.co.uk/wp/

Installing BBPress

Posted in Programming, Tutorials, Wordpress with tags , , , on November 3, 2009 by sinsearch

Unlike Buddypress, BBPress is not a plug in. Its a separate application that can be integrated into WordPress by using the “BBPress Integration” plug-in that you probably noticed we left de-activated when we installed BuddyPress. So to run the BBPress install, you’d go to your equivalent of http://www.sinsearch.co.uk/wp/bbpress/

installpp01

As you can see the script is intelligent enough to work out that we are trying to install it for the first time, which is nice. Click on the “Go To Step 1” button:

installpp02

At this point, open the notepad file containing your DB Name, DB User and DB Pass details and copy them into the fields above. Click the “Save Database Configuration” to save those settings. At this point you’ll get a page saying:

“Your settings have been saved to the file bb-config.php
You can now continue to the next step.”

Click on the “Go To Step 2” Button.

Step 2, is optional and we actually want to skip it since the BBPress Integration plug-in does a much better job of integrated the message board then this installation wizard. So, at this point click the “Skip WordPress Integration” button and you’ll get a page saying:

“You have chosen to skip the WordPress integration step. You can always integrate WordPress later from within the admin area of bbPress.”

There’s also two options; “Go Back” or “Go To Step 3”. Click on the “Go To Step 3” button.

installpp03

Step 3 is concerned with setting up the Message Board Name and the Key Masters details. The Key Master is really just another name for the Boss or Administrator for the board. As you can see from the screen shot above I’ve just used the username of “admin” and the same email address as before. I’ve also given the board a name and it will create the first message board called “Wicked Talk” ;-)

Click the “Save Site Settings” button. This is all the data the site installation wizard needs:

installpp04

To finish the installation of BBPress click on “Complete the Installation” button. This should return your admin user name and a generated password. Copy and Paste this information into your notepad file with all your other details. Now BBPress has been installed.

In the next instalment we’ll discuss how to actually integrate BBPress into WordPress as we haven’t actually done that yet!

Installing BuddyPress

Posted in Programming, Tutorials, Wordpress with tags , , , , on November 2, 2009 by sinsearch

To login for the first time I would go http://www.sinsearch.co.uk/wp/wp-login.php and typing my username of ‘admin’ and the generated password. You can change the password once you have logged in if you like, but I’ll leave that part to you.

installbb01

Once logged in you should see a screen similar to the one above. You need to look for the “Site Admin” menu and click on the arrow next to it to show its associated drop down menu of options. Click on the “Themes” menu item:

installbb02

In the above screen shot, you see there are two buddypress themes that are currently set to “No”, meaning they are invisible to the system. So what you need to do is select these both to ‘yes’ by clicking the appropriate ratio button and clicking the “Update Themes” button.

Next you need to click on the “options” menu link, which will load of different settings. There are a couple of things we need to set in this screen.

installbb03

  1. Firstly set “Allow new registrations” to “Enabled”.
  2. Scroll to the bottom of the page and tick the box next to “Plugins”.
  3. Click the “Update Options” button.

Next click on the “Plugins” menu option, which gives this screen:

installbb04

This shows the two plug-ins that we uploaded as apart of the package. At this point we need to activate just the “BuddyPress” plug-in. So, click on the “Activate” link next to the Buddypress plug-in. So, now you have once active and another inactive plug-in.

installbb05

You’ll notice on the left hand side on the menu a new item has appeared called “BuddyPress” with all sorts of options that you can play with. But first you need to change the current theme to a BuddyPress enabled one. To do this, click on the “Themes” option under the “Appearance” section on the menu.

installbb06

Currently a old style wordpress theme is selected. Instead activate one of the two available “Buddypress” themes. I’m going to activate the first one by clicking the “Activate” link next to the associated theme. At this point, Buddypress is installed and you can see the active theme visiting your site. In my case that is http://www.sinsearch.co.uk/wp/

In the next post I am going to install the Message board, BBPress and integrating it into the rest of the system.

Installing WordPress MU

Posted in Programming, Tutorials, Wordpress with tags , on November 1, 2009 by sinsearch

At bleeding last we can run the install script. The script is intelligent enough to figure out its being run for the first time and runs the installer, so all you need to do is go to the URL where you installed the software; http://www.sinsearch.co.uk/wp/

installwp01

If you scroll down past all this crap, it will get to all the various options.

installwp02

This installation has only been tested when placed in a sub-directory, rather than in a sub-domain. Besides there is allot of discussion on the internet about sub-domains not being as valuable in terms as search engine ranking as they used to be. In my opinion having a sub-domain name or not makes little difference overall.

Open up the notepad file that contains your Database access details. For the Database Name field copy the value labelled as “DB Name”. Likewise for User name copy the value associated with “DB User” and finally copy over the password. You can safely leave the database host to its default which probably is “localhost’.

The next section refers to the Sever address. I personally just left it to its default which for me was “sinsearch.co.uk” and then we come to the “Site Details” section:

installwp03

You just need to enter a site title and an email address. Ensure your email address has been setup and is working before using it as the system will use it to email your administration password to you.

Once you are satisfied that you have entered all the information correctly then click on the “Submit” button. The server setup will then go and do its thing, displaying a screen like this (but without the blacked out bits):

installwp04

The bottom bit where it refers to fixing permissions we want to ignore for the moment as we need to keep the permissions as they are in order to install the other scripts properly. In the next article I’ll deal with installing “BuddyPress” and loading the relevant theme.

Set Up File Permissions for a new Installation

Posted in Programming, Tutorials, Wordpress with tags , on October 31, 2009 by sinsearch

Before we can continue to the install, we need to change some permissions on certain folders to allow the install process to create the various files needed.

1. Tick the box next to the new folder “wp” and click the “Change Permissions” button. This loads a little popup box (below). You need to tick the two remaining empty boxes. You’ll notice that ticking these boxes changes the numbers shown to “777”. To save these changes, press the “Change Permissions” button.

perms01
2. Next double click on the “wp” folder from within the File Manager. From within this folder scroll to the “wp-content” and "bbpress" folders, changing their permissions to 777 too. You can do this by either ticking all its empty boxes or just typing in 777 into the permissions boxes. Then click the “Change Permissions” button.

perms02

Amazingly we are actually ready to install this bloody thing!