background preloader

Writing a Plugin

Writing a Plugin
Languages: English • العربية • বাংলা • Español • Italiano • a Plugin 日本語 한국어 • Português do Brasil • Русский • ไทย • 中文(简体) • (Add your language) WordPress Plugins allow you to easily modify, customize, and enhance a WordPress site. Instead of changing the core program code of WordPress, you can add functionality with WordPress Plugins. Here is a basic definition. A WordPress Plugin is a program or a set of one or more functions written in the PHP scripting language, that adds a specific set of features or services to the WordPress site. Wish that WordPress had some new or modified functionality? This article assumes you are already familiar with the basic functionality of WordPress and with PHP programming. Resources To understand how WordPress Plugins work and how to install them on your WordPress blog, see Plugins. This section of the article goes through the steps you need to follow – and some things you need to to consider – when creating a well-structured WordPress Plugin. Plugin Name

PHP form tutorial - PHP form processing This article demonstrates how to use PHP forms. You will find detailed information from the form basics to advanced form processing. Tutorial info: Bookmark PHP form tutorial Step 2 - PHP form processing PHP form tutorial Now we have a HTML page with a form but if we press the submit button then we will get a Not Found message if the form.php file doesn't exists yet. First you should save the HTML site shown in the previous step as form.php. If a form was submitted and the script defined in the action parameter of the form tag is called then a so called super global array will be populated with the user entered information. Code: $_POST['name'] : "John"$_POST['email'] : ""$_POST['mesg'] : "Hello, my nam is John!" What does it mean? However it can happen that the visitor submitted an empty form by just clicking on the Send button. Ok, it's nice but what to do now. Previous Step of PHP form tutorialNext Step of PHP form tutorial

InformatiWeb v2 - Autoriser toutes les balises dans TinyMCE (TinyMCE est un Editeur WYSIWYG en javascript) 354 vues Publié le : 20 mars 2011 à 17:05 Si vous avez une fois testé "TinyMCE" dans votre site web, vous avez peut-être remarqué que certaines balises comme la balise "marquee" était automatiquement supprimée lorsqu'elle était insérée dans le code source. Ceci pour une raison de sécurité, car dans le cas où vous mettez cet éditeur disponible à tous les utilisateurs de votre forum, par exemple, elles sont considérées comme potentiellement dangereuses car elle peuvent modifier l'aspect de votre site web ou forum. Le problème, c'est que lorsque l'on veut l'utiliser dans l'administration de son site web, par exmple, ou dans une partie du site web ou forum réservée aux admins, on aimeraient bien des fois de mettre certaines balises qui ne sont pas habituellles. Remplacer : extended_valid_elements:"0" Par : extended_valid_elements:"*[*]" Ceci aura pour effet d'autoriser toutes les balises HTML existantes Note : Cette astuce peut ne pas fonctionner sur les versions récentes de TinyMCE

Managing Plugins Managing Plugins Languages: English • Français • 日本語 • Português do Brasil • 中文(简体) • (Add your language) WordPress Plugins are composed of php scripts that extend the functionality of WordPress. They offer new additions to your blog that either enhance features that were already available or add otherwise unavailable new features to your site. The majority of WordPress users don't require Plugins, or only require a few, such as Plugins dealing with comment spam or customized post listings. Other users enjoy the varied options Plugins provide such as frequently updated weather reports, post word counts, rating systems, and more. Plugins available via the WordPress Plugins Directory site are designed by volunteers and are usually free to the public. If you want to develop your own Plugins, there is a comprehensive list of resources at Plugin Resources. Finding Plugins Plugin Compatibility and Updates Installing Plugins Automatic Plugin Installation WordPress Plugins Panel Plugin Favorites <?

7 Simple Rules: WordPress Plugin Development Best Practices We've been talking a lot about "Best Practices" here on Wptuts lately. Today, we'll cover some important best practices for creating a WordPress plugin. From security tips to namespacing tricks, follow these rules and you'll do no wrong. Whether you're a budding new plugin developer or a time-tested veteran, these simple rules and suggestions will make you a better developer (and the community will thank you for it!) Rule 01: Have a Strategy Yes, a strategy. Is my plugin just for fun/demonstration purposes or for everyday use in the real world? These questions are important because they impact on how seriously you need to take issues such as coding standards, updates, security, support and documentation. Rule 02: Use Consistent and Clear Coding Standards Which do you prefer, this? Or this? Simple things like consistent spacing, indenting, informative variable naming and succinct comments are a good place to start. Use Namespacing Rule 03: Take Security Seriously Sanitize inputs, escape outputs

Plugin API Plugin API Languages: বাংলা • English • Español • Français • 日本語 • 한국어 • Português do Brasil • ไทย • 中文(简体) • Русский • (Add your language) Introduction This page documents the API (Application Programming Interface) hooks available to WordPress plugin developers, and how to use them. This article assumes you have already read Writing a Plugin, which gives an overview (and many details) of how to develop a plugin. These hooks may also be used in themes, as described here. Hooks, Actions and Filters Hooks are provided by WordPress to allow your plugin to 'hook into' the rest of WordPress; that is, to call functions in your plugin at specific times, and thereby set your plugin in motion. You can sometimes accomplish the same goal with either an action or a filter. For a thorough listing of all action and filter hooks in WP see Adam Brown's WordPress Hooks Database. Function Reference Actions Modify database data. The basic steps to make this happen (described in more detail below) are: where:

PHP form tutorial This tutorial takes you step by step through web form processing using PHP. You will learn how to collect input from a web form, validate and save it. This tutorial assumes that you are familiar with at least very basic PHP and HTML. Note: You can make web forms quickly with Simfatic Forms. Simfatic Forms helps you to make complete, feature rich forms and get it online quickly. Creating the HTML code for the form In HTML, a form is begins and ends with a <form> tag. The “action” specifies what page to submit the form to. Now let’s add some inputs to the form. Getting the form data The input of type “text” is just a single line field to type in some text. Congratulations! Let’s add some PHP to process this form: First, remember that this form “submits to itself”, meaning that the form variables will be sent to this page, and the page will load again from the top. So, the first thing we should do is to check and see if a form was submitted or not. Validating the input Saving the data to a file

[Wordpress] La vraie bonne manière de supprimer le numéro de version Dès qu’un blog commence à avoir un peu de succès, il devient la cible des spammers, puis plus tard des hackers. WordPress est l’une des plateforme de blogging les plus populaires. A ce titre, elle concentre bon nombre d’attaques. Par défaut, WordPress publie sur votre site la version du moteur (par exemple 2.9.1) qui le propulse. Ceci a pour but de compter le nombre de blog utilisant la plateforme et dans quelle version. Mais cette publication a un gros inconvénient : un hacker peut connaitre la version que vous utilisez et se servir de failles connues de la dite version pour prendre le contrôle de votre blog, surtout si elle n’est pas à jour. Il est donc recommandé de supprimer cette information. Suppression dans le header On voit parfois une technique simple qui permet, a priori, de supprimer la version dans le code HTML produit. Suppression de l’insertion dans le header D’autres recommandent de supprimer l’insertion de la ligne ci-dessus, en utilisant un hook. Limites de ces techniques

Creating Tables with Plugins Creating Tables with Plugins Languages: English • 日本語 • Русский • (Add your language) If you are writing a plugin for WordPress, you will almost certainly find that you need to store some information in the WordPress database. There are two types of information you could store: Setup information -- user choices that are entered when the user first sets up your plugin, and don't tend to grow much beyond that (for example, in a tag-related plugin, the user's choices regarding the format of the tag cloud in the sidebar).Setup information will generally be stored using the WordPress options mechanism. This article describes how to have your plugin automatically create a MySQL table to store its data. So, it is recommended that you follow the steps below to have your plugin automatically create its database tables: Write a PHP function that creates the table. Create Database Tables Database Table Prefix In the wp-config.php file, a WordPress site owner can define a database table prefix.

Advertisement Plugins are a major part of why WordPress powers millions of blogs and websites around the world. The ability to extend WordPress to meet just about any need is a powerful motivator for choosing WordPress over other alternatives. Having written several plugins myself, I’ve come to learn many (but certainly not all) of the ins-and-outs of WordPress plugin development, and this article is a culmination of the things I think every WordPress plugin developer should know. Oh, and keep in mind everything you see here is compatible with WordPress 3.0+. Don’t Develop Without Debugging The first thing you should do when developing a WordPress plugin is to enable debugging, and I suggest leaving it on the entire time you’re writing plugin code. Enabling debugging also turns on WordPress notices, which is important because that’s how you’ll know if you’re using any deprecated functions. How to Enable Debugging define('WP_DEBUG', false); Replace that line with the following: if (! if (!

WordPress hooks database - action and filter hooks for wp plugin developers -- Adam Brown, BYU Political Science What is a hook? In brief, WordPress hooks enable you to change how WordPress behaves without editing any core files. Because you leave the WordPress files untouched, you can painlessly upgrade your blog with each new version of WordPress. If you don't know what WordPress hooks are for, read the Plugin API or this tutorial. What is this directory? If you're a plugin or theme developer, you know how difficult it can be to figure out which hooks are available. What is this good for? See what new hooks are available with each new version of WordPress See which hooks have been deprecated or renamed (use the "view all hooks" option) Easily learn exactly which WP file(s) use each hook. How to help? Update and improve the official action and filter references.

15 very useful PHP code snippets for PHP developers | Following are list of 15 most useful PHP code snippets that a PHP developer will need at any point in his career. Few of the snippets are shared from my projects and few are taken from useful php websites from internet. You may also want to comment on any of the code or also you can share your code snippet through comment section if you think it may be useful for others. 1. 2. 3. The above code will not work in case your client is behind proxy server. 4. This function will return the duration of the given time period in days, hours, minutes and seconds. e.g. secsToStr(1234567) would return “14 days, 6 hours, 56 minutes, 7 seconds” 5. 6. Required Extension: SimpleXML 7. 8. Following is the PHP code to create the JSON data format of above example using array of PHP. Following code will parse the JSON data into PHP arrays. 9. 10. This basic snippet will create a random authentication code, or just a random string. 11. Validate a date in “YYYY-MM-DD” format. 12. 13. 14. 15.

[Wordpress] Login LockDown, protégez votre blog des hackers Lorsqu’on édite un blog et qu’on y met toute son énergie, l’une des choses les plus redoutées et de se faire hacker. L’attaque la plus commune consiste à usurper l’identité de l’administrateur en trouvant son mot de passe par « bruteforce ». Cette technique consiste, en gros, à essayer toutes les combinaisons de mots de passe possibles jusqu’à tomber sur le bon. Sur les blogs WordPress, il n’existe, par défaut, aucune méthode pour empêcher ce genre d’attaques. Il est possible de tenter de se loguer autant de fois qu’on le souhaite. Login LockDown est un plugin qui permet de définir un nombre maximum de tentatives de login avec une adresse IP donnée et dans un laps de temps donné. Une fois installé, il suffit de se rendre dans l’interface d’administration de votre blog et de cliquer que le menu Login Lockdown. Dans cet exemple, une même adresse IP pourra tenter de se loguer 3 fois dans une période de 60 minutes. Bien entendu, ce plugin ne vous protègera pas à 100%.

Function Reference/wpdb Class Languages: English • Italiano • 日本語 • Русский • 中文(简体) • 中文(繁體) • (Add your language) Talking to the Database: The wpdb Class WordPress defines a class called wpdb, which contains a set of functions used to interact with a database. Its primary purpose is to provide an interface with the WordPress database, but can be used to communicate with any other appropriate database. Using the $wpdb Object Warning: Methods in the wpdb() class should not be called directly. WordPress provides a global object variable, $wpdb, which is an instantiation of the wpdb class defined in /wp-includes/wp-db.php. // 1st Method - Declaring $wpdb as global and using it to execute an SQL query statement that returns a PHP object global $wpdb; $results = $wpdb->get_results( 'SELECT * FROM wp_options WHERE option_id = 1', OBJECT ); // 2nd Method - Utilizing the $GLOBALS superglobal. $myrows = $wpdb->get_results( "SELECT id, name FROM mytable" ); A Warning SELECT a Variable <? query (string) The query you wish to run. <?