Tag Archives: wp

wordpress: WP-Testimonials

18 Jul

came across this yesterday.

WP-Testimonials is a plugin for WordPress that lets you display your customer/client/product testimonials on your blog.

You may add, edit or remove testimonials through the “Manage” navigation tab in the admin area. The plugin includes the option to display a random testimonial in your sidebar using PHP code for older templates or using a widget for newer themes. The widget is built-in with the plugin, so you have no additional files to worry about.

Testimonials can also be displayed all on one page. A template file is included that will need to be uploaded to your theme directory. Once in place, simply create a new page and select that template from the drop-down.

check it out :
http://www.sunfrogservices.com/free-php-script-downloads/wp-testimonials/

reference: ultimate tag warrior tag clouds

18 Jul

just a reference point for myself

http://www.neato.co.nz/wp-content/plugins/UltimateTagWarrior/ultimate-tag-warrior-help-themes.html#tagcloud

wordpress hooks database

15 Dec

Sadly wordpress doesn’t maintain a complete list of all action and filter hooks. Lucky for us adam brown does

From: http://adambrown.info/p/wp_hooks

If you’re a plugin developer, you know how difficult it can be to figure out which hooks are available. This WordPress hooks database automatically scans each WP build for apply_filters() and do_action() to figure out exactly which hooks are available in each version and where the hooks occur.

If you don’t know what WordPress hooks are for, read the Plugin API .

Check It Out:
WordPress hooks database – action hooks and filters for all wp versions || Adam Brown, BYU Political Science

project: benchsid – automate benchmarks with siege, ab, and httperf using shell scripts

7 Dec

While benchmarking performance for deathy death match I realized something: Benchmarking sucks!

That said, and me being the lazy person I am, I asked myself how can I make this easier? My answer: benchsid, two shell scripts that make benchmarking easier.

disclaimer

This is a 1,2,3 trick pony – use it as such

These scripts are offered as is and I am not responsible for anything you do, create, break, etc.

Both scripts are released under the do whatever the hell you want, but don’t blame me license. This of course isn’t a real license, but you get the point.

Make benchmarks easier, if only a bit

I’ve tried as much as possible to keep your commands to a minimum. If running as root you can run a complete benchmark, save both the results and you benchmark servers top + free output, and reboot with 3 commands. See lazy right? :)

monitor.sh – run this script on the machine your benchmarking
bench.sh – run this script on the machine your benchmarking from

you do not need to run these on separate machines, but I recommend it

How do I use…

monitor:

 ./monitor.sh
 ./monitor.sh help

bench:

 ./bench.sh
 ./bench.sh help

If your still having issues post a comment

monitor.sh

Monitor should be ran on the machine your benchmarking. It automates the process of recording free (free -m) and top, and if running as root will reboot the server when you tell it to stop monitoring a benchmark

Sounds good so far right?

monitor.sh process overview

start process

clear out any benchmarks that will be overwritten
save output from free to a file (free -m)
save output from top to a file
start a top process to monitor to a file while we benchmark
confirm that we are up and running

stop process

stop top
save output of free to file
save output of top to file
reboot server

monitor.sh: umm why?

monitor.sh saves the information about the server before, during and after your benchmark has been run. By running top during the benchmark process (10 second intervals), we can get a real time overview of both server load and the loads created by applications

bench.sh

bench.sh is the benchmarking portion. bench.sh can benchmark your server using one of three programs: ab, siege, or httpref. I considered adding an option to do all three, but honestly that more poor mans dos than benchmark.

bench.sh first will perform a warm-up cycle of 2000 requests to your server using your desired (or default) concurrency. After that it will perform 3 benchmark cycles of your desired number of requests and concurrency.

All cycle results (including warm up) are saved to the filesystem.

download

download benchsid: http://gregsidberry.com/httpdocs/wp-content/uploads/2008/12/benchsid.tar.gz

known issues

siege output – siege outputs a couple of variables to screen that aren’t included, or properly recorded, in the created file. I’ve tried output redirection, script, etc, but haven’t been able to find a fix that keeps everything in one script

input validation – there is no input validation, so please don’t put these files in a web public location.

funyuns – I’m out of funyuns, please send more

enjoy
Sid

weird wordpress 2.6.5 bug

1 Dec

I’m now officially up and running with wordpress 2.6.5, only I’m nolonger able to edit posts in wordpress. After a bit of snooping the issue appears to be a new flag that is added to the db whenever I open a post to edit it: _edit_lock

To clear _edit_lock run:

delete from wp_postmeta where meta_key='_edit_lock'

. You’ll need to replace wp_ with whatever your table prefix is. This isn’t even a real solution as the lock will be put back in place the moment a post auto saves. Anyone else running into this?

Lucky for me I normally use scribefire

how to: fix wordpress admin blank page after 2.6 upgrade

1 Dec

I upgraded wordpress from 2.5* to the lasted 2.6 release. After the update my blog worked perfectly, but admin was nothing but a blank page.

First go to yourdomain.com/wp-admin/upgrade.php
next clear all your cookies
then download your /wp-config.php file and copy and paste everything below:

define('DB_COLLATE', '');

from the wp-config-sample.php file into your wp-config file. Be sure there isn’t any whitespace at the end of the file.

update, login, enjoy

Sid

using wordpress from multiple locations

21 May

Wordpress checks to make sure your running on from the proper site location. Problem is sometimes you just need it to run.

ex: wordpress runs at elsid.net, admin runs at admin.iamsid.net

Or you run both your development and production version of wordpress from the same db

edit the get_option function in the functions.php file in the wordpress includes folder

replace :

function get_option($setting){
global $wpdb;

with

function get_option($setting){
global $wpdb,$_SERVER;
if(strpos(“siteurl|home”,$setting)!==false){
return “http://”.$_SERVER['HTTP_HOST'];
}

you could use the update option function, but it adds unneeded overhead

configuring wp-cache to work with apc

23 Apr

Having issues getting wp-cache and apc to play nice? So was mark, luckily he found the answer so I can link to him

APC (Alternative PHP Cache) is great for WordPress. It caches the
compiled WordPress PHP files and greatly speeds up subsequent loads. I
even wrote a WordPress plugin to make WordPress store its objects in
APC instead of in the default file-based object cache.

WP-Cache2 is also great for WordPress, because it caches the HTML output of WordPress for a specified period.

So if both are good, together they should be awesome, right? Well…
in theory, yes. Unfortunately, I’ve been having a heck of a time
getting them to play together. What would happen was that pages would
start showing up blank. Just a white page. Real helpful. The same thing
happened when you tried to access

/wp-admin/

The only way to fix it was to delete WP-Cache2. In desperation, I removed all the error-silencing

@

from WP-Cache2. Ah. It was some problem with

class_exists()

and APC. Apparently, APC doesn’t play well with

class_exists()

.

Adventures with WP-Cache2 & APC « Mark on WordPress

Wordpress: modifying uploads

16 Apr

I’ve been working for a while to figure out how to modifiy the way wordpress handles uploads.  If your trying to make changes in the actual upload process open file.php in the wordpress wp-includes folder.

the function you’ll need to make changes to is wp_handle_upload

for anyone wondering why you would ever want to modify uploads heres a few examples of why I do.

Ex 1: wordpress admin runs on a different server than wordpress, whenever an upload is made it should also be sent to the live server ( yes there are other hacks involved)

ex 2: wordpress is a subsystem of a larger system, so at upload you need to make sure the ain system tracks those changes.

hapy hacking – Sid

integrating wordpress into existing site – part 2

11 Mar

I realized I left out alot while reading part1, so i’m covering more here, an possibly in additional posts

disable plugins if not in wordpress 

You’ll need to use wordpress on the backend from time to time, mostly for login / logout functionality. You should build a connector class to handle this. When using wordpress via your class outside of your actual wordpress install you should disable you wordpress plugins. why? less to load, and i’ve found some plugins have issues when loaded by wordpress outside of the actual wordpress installation.

 in wp-settings.php near line 231 replace

if ( get_option(‘active_plugins’) ) {
$current_plugins = get_option(‘active_plugins’);
if ( is_array($current_plugins) ) {
foreach ($current_plugins as $plugin) {
if (” != $plugin && file_exists(ABSPATH . PLUGINDIR . ‘/’ . $plugin))
include_once(ABSPATH . PLUGINDIR . ‘/’ . $plugin);
}
}
}

with

if(!defined(‘NO_PLUGINS’)){

if ( get_option(‘active_plugins’) ) {
$current_plugins = get_option(‘active_plugins’);
if ( is_array($current_plugins) ) {
foreach ($current_plugins as $plugin) {
if (” != $plugin && file_exists(ABSPATH . PLUGINDIR . ‘/’ . $plugin))
include_once(ABSPATH . PLUGINDIR . ‘/’ . $plugin);
}
}
}
}

What we just did was change the plugin loading portion of wordpress to not load plugins if we define the NO_PLUGINS flag.

Loading wordpress for your connector class 
In your class file you should load the required wordpress files before your class. Something like:

if(!defined(‘DB_NAME’)) {
define(‘NO_PLUGINS’,true);
require_once(FS_WORDPRESS.’/wp-config.php’);

}

 I’m checking for wordpress by looking to see if the DB_NAME is defined. This check will tell if we’re already in wordpress, its not rocket scienece just a check for a wordpress only varibale. If it’s not defined then plugins are disabled. simple right?

 login user to wordpress at site login.

When a user logs into your site, they should automaticly be logged into wordpress. this is of course assuming that your not trying to actually keep wordpress seprated, but then again that defeats the purpose of this thing that somehow turned into a tut (pardon me i seriously need some sleep)

 wordpress was loaded via the previous code, now we’ll still need to load the specific files that contain our required wordpress functions.

require_once( ABSPATH . WPINC . ‘/registration.php’);
require_once(FS_LIBRARY.’/User.inc’);

By loading the registration.php file we’ll now have all the functions needed for handling wordpress login, logout, and registration functions. Why do we want to register a user? simple new users (or old users if you don’t want to write an import script.

the following is of course assuming that your site is setup correctly.  when a new or current user attempts to login we’ll check to see if that user can in fact login or exists. if the user exists its safe to assume that they have updated their password on the main site, so we’ll update their password, and attempt to login again. for users who aren’t already in the wordpress db, we’ll run the wordpress registration functions ( removing their validation requirement of course ). because wordpress is running as an addon to your current saite, your actual site should be handling user checking etc, and only allow valid users access to this area, and only if their username matches the user session ( sorry not covering all that right now).

heres some sample code, please note your passwords shouldn’t be in plain text format, but this sampleuses plain text passcodes to show how. you can remove the md5 functions and do your own thing from there

    /*this function adds a user to wordpress, their is no error checking as users are checked, updated, created at login*/
function register($username, $password, $email){
global $wpdb;
//make sure we have a user

if(!empty($username) && !username_exists( $username )){
/*create user and update their wordpress account to not require activation*/
@create_user($username, $password, $email);
$wpdb->query(“UPDATE $wpdb->users SET user_pass = MD5(‘$password’), user_activation_key = ” WHERE user_login = ‘$username’”);
}
}

/*this function is only called from the login function in your  site user class
at the point its called we have a valid user, so we need to make sure the user can access wordpress*/
function login($user_login, $user_pass){
global $wpdb, $_SERVER;

//attempt login
$logged_in=@wp_login($user_login, $user_pass);
/*if login fails but user name exist
then user was created by an admin
so we’ll reset their wordpress password and update their email address, just in case they changed it*/
if(!$logged_in && username_exists( $user_login )){
$user    =&new YourUserClass($user_login);

$wpdb->query(“UPDATE $wpdb->users SET user_pass = MD5(‘$user_pass’), user_email=’”.$user->emailAddress().”‘ WHERE user_login = ‘$user_login’”);
}else{
/*the user hasn’t been added to wordpress, add them */
$user    =&new YourUserClass($user_login);

WordPressConnector::register($user->userName(), $user->password(), $user->emailAddress());

}
do_action_ref_array(‘wp_authenticate’, array(&$user_login, &$user_pass));

//ok we now have a valid wordpress user
//if not logged in then login user
$logged_in=(!$logged_in) ? @wp_login($user_login, $user_pass) : $logged_in;

if($logged_in){
wp_setcookie($user_login, $user_pass, false, ”, ”, true);
do_action(‘wp_login’, $user_login);


}

return $logged_in;
}

function logout(){
global $_SERVER;
wp_clearcookie();
do_action(‘wp_logout’);  


your_site_redirect_function();
}

 

If you have any questions, leave a comment, or just leave a comment if this was helpful.

 

Sid