Hur utvecklar man då ett sånt plugin? Jo, det första man gör är att skapa ett bibliotek i sin wordpress-installation (givetvis utvecklingsvarianten) under wp-content/plugins med namnet johan_ripas.
I denna placerar vi två filer: readme.txt och johan_ripas.php.
I readme.txt skriver vi det vanliga:
=== Johan Ripås === Contributors: Aspelund Tags: Johan Ripås Requires at least: 3 Tested up to: 3 Stable tag: 3 This plugin adds links to support the cause of Johan Ripås. Nothing more, nothing less. == Description == This is a simple plugin that adds two links to your blogs footer. One link to [Johan Ripås](http://www.lindqvist.com/tag/johan-ripas/) and on link to [Johan Ripås](http://johanripas.wordpress.com/). It is not likely that this plugin will ever be updated. == Installation == Use Wordpress' own installation process in the admin guide. == Changelog ==
I filen johan_ripas.php skapar vi sedan koden som lägger till länkarna till Johan Ripås och Johan Ripås. Vi hookar upp dem mot actionen wp_footer.
class johanripas { function add_johan_ripas_link() { echo 'Jag länkar glatt till Johan Ripås och Johan Ripås. '; } } add_action('wp_footer',array('johanripas','add_johan_ripas_link')); ?>
Notera att vi lägger koden inuti klassen johanripas. Det innebär att vi undviker namnkonflikter. :)
När detta är gjort har vi vår plugin, och det är bara att aktivera den från admin-sidan.
För att göra det lite lättare så har jag sparat det hela som en färdig fil: Johan Ripås - The plugin.
No comments:
Post a Comment