Plugins
By Paul
0/5 based on 0 votes. The median rating is 0.
By Paul
Plugins allow you to override WSN functions with customized versions. Any file uploaded to the /plugins/ subdirectory will be able to override these functions with a custom version you write. The following functions can be replaced by plugins:
beforeaddition (includes/commonfuncs.php) - Perform any desired changes to any sort of object just before it gets added to the database.
afteraddition (includes/commonfuncs.php) - Do something after submission is added to the database.
afterapplyedits (includes/commonfuncs.php) - Do something after edits have been applied to the object (but not the database).
checkincompletes (includes/commonfuncs.php) - Trigger an incomplete prompt when the submitted data isn't valid.
afterpayment (includes/commonfuncs.php) - Do whatever you want after the successful processing of a sponsorship payment.
onunpaidsubmit (includes/addlink.php) - What to do when submitting to a paid type and we haven't paid in advance.
aftersetup (includes/commonfuncs.php) - Do whatever you want after installation is completed.
afterhitout (includes/commonfuncs.php) - Do whatever you like after a hit out is counted.
regenerateplugin (includes/commonfuncs.php) - Do something when the article is regenerated.
securityimagevalue (includes/commonfuncs.php) - Returns characters for security image.
realip (includes/commonfuncs.php) - Determines the visitor's IP address.
catselector (includes/commonfuncs.php) - Gives category selector dropdown.
redirect (includes/commonfuncs.php) - Redirects from one page to another.
markrequired (includes/addeditfuncs.php) - Marks required fields in red outline.
reciprocates (includes/addeditfuncs.php) - Determines whether a link is considered reciprocated.
typeselector (includes/addeditfuncs.php) - Gives article type selector options.
makehtaccess (includes/commonfuncs.php) - Writes the .htaccess for URL rewriting.
alterhtaccess - Changes the .htaccess content before writing (added in 6.1.0).
googlemap (includes/googlemapfunc.php) - Generates google or sitemaps.org sitemap.
latextohtml (includes/commonfuncs.php) - Renders latex codes.
protecttext (includes/commonfuncs.php) - Disguises email addresses.
addtag (includes/tagfunctions.php) - Adds a new tag.
showfeeds (includes/objectfunctions.php) - Shows RSS feed data associated with item.
pluralize (includes/pluralize.php) - Attempts to pluralize/singularize words appropriately.
geofromaddr (includes/commonfuncs.php) - Finds latitude and longitude for an address.
geofromip (includes/commonfuncs.php) - Finds latitude and longitude from an IP.
urlchanger (includes/commonfuncs.php) - Manipulates URLs for rewriting.
changeoutgoingurl (includes/commonfuncs.php) - Changes the outgoing link URL for rewriting.
adjustpreviews (includes/commonfuncs.php) - Adjusts the preview page content.
adjustpagination (includes/commonfuncs.php) - Adjusts the pagination HTML, useful for new forms of URL rewriting.
extrareadyfunctioncontent (includes/commonfuncs.php) - Place extra javascript in jquery's document ready function.
extrajsheadercontent (includes/commonfuncs.php) - Place extra javascript in the header after the jquery stuff runs.
afterusergroupchange (includes/commonfuncs.php) - Do stuff when a member's usergroup is manually altered on the edit member page, like maybe send them an email.
mlstransformations (includes/commonfuncs.php) - Does manipulations before processing MLS real estate import listings.
The file listed inside the parenthetical has the original version of each function. Don't edit those files -- copy and paste the function out of that file into a new .php file in your /plugins/ subdirectory. Any of these functions placed in files in the /plugins/ directory will automatically override the shipped versions.
If you'd like another function to become pluggable, just ask and your wish will almost certainly be granted.
The most useful pluggable function will probably be beforeaddition. Use it to perform any desired changes to any sort of object just before it gets added to the database. For example:
Note how the objecttype property of $object allows you to determine what sort of object you're dealing with. Don't hesitate to ask support if you need help understanding how the WSN objects work.
The afteraddition() function is the same as beforeddition() except it executes after the item has been added to the database (though it hasn't necessarily been validated). afterapplyedits() allows you to manipulate edits before they're saved.
The function afterpayment() is similar, but it allows you to do whatever you want after the sucessful processing of a sponsorship payment. See the dummy in commonfuncs.php for a short list of useful inputs.
The checkincompletes() function, added in 5.0, allows you to trigger an incomplete prompt when the submitted data isn't valid. For example, I use this on the WSN suppport forums to make sure the version field is filled with a valid number:
The aftersetup() function lets you run code after a successful new installation completes. This may help simplify the task of a large-scale deployment where alterations need to be performed or default data needs to be inserted after installation.
Note that if you want to create new functions or do processing which may benefit from things having been initialized already you may find the modifications directory more useful, and for login-related matters see member system integration.
beforeaddition (includes/commonfuncs.php) - Perform any desired changes to any sort of object just before it gets added to the database.
afteraddition (includes/commonfuncs.php) - Do something after submission is added to the database.
afterapplyedits (includes/commonfuncs.php) - Do something after edits have been applied to the object (but not the database).
checkincompletes (includes/commonfuncs.php) - Trigger an incomplete prompt when the submitted data isn't valid.
afterpayment (includes/commonfuncs.php) - Do whatever you want after the successful processing of a sponsorship payment.
onunpaidsubmit (includes/addlink.php) - What to do when submitting to a paid type and we haven't paid in advance.
aftersetup (includes/commonfuncs.php) - Do whatever you want after installation is completed.
afterhitout (includes/commonfuncs.php) - Do whatever you like after a hit out is counted.
regenerateplugin (includes/commonfuncs.php) - Do something when the article is regenerated.
securityimagevalue (includes/commonfuncs.php) - Returns characters for security image.
realip (includes/commonfuncs.php) - Determines the visitor's IP address.
catselector (includes/commonfuncs.php) - Gives category selector dropdown.
redirect (includes/commonfuncs.php) - Redirects from one page to another.
markrequired (includes/addeditfuncs.php) - Marks required fields in red outline.
reciprocates (includes/addeditfuncs.php) - Determines whether a link is considered reciprocated.
typeselector (includes/addeditfuncs.php) - Gives article type selector options.
makehtaccess (includes/commonfuncs.php) - Writes the .htaccess for URL rewriting.
alterhtaccess - Changes the .htaccess content before writing (added in 6.1.0).
googlemap (includes/googlemapfunc.php) - Generates google or sitemaps.org sitemap.
latextohtml (includes/commonfuncs.php) - Renders latex codes.
protecttext (includes/commonfuncs.php) - Disguises email addresses.
addtag (includes/tagfunctions.php) - Adds a new tag.
showfeeds (includes/objectfunctions.php) - Shows RSS feed data associated with item.
pluralize (includes/pluralize.php) - Attempts to pluralize/singularize words appropriately.
geofromaddr (includes/commonfuncs.php) - Finds latitude and longitude for an address.
geofromip (includes/commonfuncs.php) - Finds latitude and longitude from an IP.
urlchanger (includes/commonfuncs.php) - Manipulates URLs for rewriting.
changeoutgoingurl (includes/commonfuncs.php) - Changes the outgoing link URL for rewriting.
adjustpreviews (includes/commonfuncs.php) - Adjusts the preview page content.
adjustpagination (includes/commonfuncs.php) - Adjusts the pagination HTML, useful for new forms of URL rewriting.
extrareadyfunctioncontent (includes/commonfuncs.php) - Place extra javascript in jquery's document ready function.
extrajsheadercontent (includes/commonfuncs.php) - Place extra javascript in the header after the jquery stuff runs.
afterusergroupchange (includes/commonfuncs.php) - Do stuff when a member's usergroup is manually altered on the edit member page, like maybe send them an email.
mlstransformations (includes/commonfuncs.php) - Does manipulations before processing MLS real estate import listings.
The file listed inside the parenthetical has the original version of each function. Don't edit those files -- copy and paste the function out of that file into a new .php file in your /plugins/ subdirectory. Any of these functions placed in files in the /plugins/ directory will automatically override the shipped versions.
If you'd like another function to become pluggable, just ask and your wish will almost certainly be granted.
The most useful pluggable function will probably be beforeaddition. Use it to perform any desired changes to any sort of object just before it gets added to the database. For example:
<?php
function beforeaddition(&$object)
{
if ($object->objecttype == 'link') $object->title = ucwords($object->title); // capitalize first letter of each word in link titles
}
?>
function beforeaddition(&$object)
{
if ($object->objecttype == 'link') $object->title = ucwords($object->title); // capitalize first letter of each word in link titles
}
?>
Note how the objecttype property of $object allows you to determine what sort of object you're dealing with. Don't hesitate to ask support if you need help understanding how the WSN objects work.
The afteraddition() function is the same as beforeddition() except it executes after the item has been added to the database (though it hasn't necessarily been validated). afterapplyedits() allows you to manipulate edits before they're saved.
The function afterpayment() is similar, but it allows you to do whatever you want after the sucessful processing of a sponsorship payment. See the dummy in commonfuncs.php for a short list of useful inputs.
The checkincompletes() function, added in 5.0, allows you to trigger an incomplete prompt when the submitted data isn't valid. For example, I use this on the WSN suppport forums to make sure the version field is filled with a valid number:
function checkincompletes($object)
{
global $incomplete, $incompletemessage;
// $incomplete should be set as true when it's incomplete. $incompletemessage is an array containing a list of prompts for the user.
if ($object->objecttype == 'link')
{
$pattern = "/(WSN (Links|Gallery|KB|Forum|Classifieds|Guest|FormEmail)?)?( )?[0-9]+\.[0-9]+\.[0-9]+( (Alpha|Beta|RC) [0-9]+)?/i";
$check = preg_match($pattern, $object->sversion);
if (!$check)
{
$incomplete = true;
$incompletemessage[] = "A valid version number would be, for example, 5.0.1. ".$object->sversion." is not valid.";
}
}
return true;
}
{
global $incomplete, $incompletemessage;
// $incomplete should be set as true when it's incomplete. $incompletemessage is an array containing a list of prompts for the user.
if ($object->objecttype == 'link')
{
$pattern = "/(WSN (Links|Gallery|KB|Forum|Classifieds|Guest|FormEmail)?)?( )?[0-9]+\.[0-9]+\.[0-9]+( (Alpha|Beta|RC) [0-9]+)?/i";
$check = preg_match($pattern, $object->sversion);
if (!$check)
{
$incomplete = true;
$incompletemessage[] = "A valid version number would be, for example, 5.0.1. ".$object->sversion." is not valid.";
}
}
return true;
}
The aftersetup() function lets you run code after a successful new installation completes. This may help simplify the task of a large-scale deployment where alterations need to be performed or default data needs to be inserted after installation.
Note that if you want to create new functions or do processing which may benefit from things having been initialized already you may find the modifications directory more useful, and for login-related matters see member system integration.
Rating:
0/5 based on 0 votes. The median rating is 0.
Submitted: 05/18/07 (Edited 10/17/11)
Description: Changing the functionality of WSN Links with PHP plugin files.
Views:
1117 views. Averaging 1 views per day.
In the most recent 30 day period, there've been 11 views.

Print
E-Mail