background preloader

WordPress

Facebook Twitter

Developer Docs - GravityForms. Introduction We believe in keeping Gravity Forms simple and easy to use, and a lot of thought goes into adding new functionality. Still, users often find the need to add/modify functionality to meet their needs. This section of the documentation offers guidelines and references for anyone wishing to modify or extend Gravity Forms. Add-on Developer Docs Hooks and Filters Following is a list of available hooks and filters. Form Loading The following filters can be used to manipulate the form data before the form gets displayed to the screen.

Gform_column_input (new in v. 1.6) This filter can be used to specify a different input type for a column in a list field. Sublabels In cases where translating Gravity Forms is not an option, the following filters can be used to change the sublabels of multi-input fields (i.e Name and Address). Form Submission The following filters can be used to manipulate the entry data when the user submits the form. Administration. Using Dynamic Population - GravityForms.

Using dynamic population in Gravity Forms allows you to dynamically populate a field with a value (or values depending on the field type). This value can be passed via Query Strings, Shortcode and/or Hooks. This walk-through will give you and example of how to use each method of dynamic population to dynamically populate a field on your form! Getting Started There are three steps to configuring dynamic population: specify which field should be populated configure how the field should be populated determine what value the field should be populated with To get started, let's talk about specifying which field should be populated. Please note: avoid using a parameter name from this list of reserved WordPress terms. Once you've entered your parameter name, you're ready to decide how you want to populate the field. Query String Assuming that a Gravity Form is on the page at this URL, any field with the dynamic population parameter name your_parameter would be populated with the value value.

Hooks. Command line interface for WordPress | wp-cli. Japh/Safe-Search-Replace. Php - Wordpress function when file is uploaded, deleted or edited. Generating Specific Image Sizes with the Custom Image Sizes Plugin. Working with WordPress’ media library and images can be at once and pleasure and a pain. I tend to like the manner in which images are managed in the admin; however, I have been left wanting when it comes to using images in the frontend of site.

In particular, I have experienced difficulties displaying images at a specific size in posts or pages. While one can use CSS or the img tag attributes height and width to display the precise image size, it is far more efficient to create an image of the exact size to display. Austin Matzko’s excellent Custom Image Sizes plugin helps ease this process by extending the functionality of the some of the main image display functions in WordPress. By default, WordPress creates up to four images when an image is uploaded, which include: thumbnail (150 x 150) medium (proportionally sized; 300 x 300 max) large (proportionally sized; 640 x 640 max) full (original image size) Or, perhaps, you can display the large size using the following: Create Native Admin Tables In WordPress The Right Way. Media upload finished hook. Add Custom Meta Fields to Media Attachments in WordPress. WordPress allows you to add a description, caption, title and link onto any media attachment.

But what if you want to add custom fields to your images, video or audio files? This can be done by manipulating data with the attachment_fields_to_edit and attachment_fields_to_save filters. Adding Additional Fields This function will remove, edit the order and add additional custom fields to the Media attachment edit and add view in WordPress for both Posts and the Media Library. function add_image_attachment_fields_to_edit( $form_fields, $post ) { unset( $form_fields['post_content'] ); $form_fields['post_title']['helps'] = 'Use a descriptive title for the image. This will make it easy to find the image in the future and will improve SEO Save The Data as Custom Fields This function will validate and save the data as custom fields associated with the attachment.

How to Display Attachment Custom Fields Now that we have 2 new fields created we need to display the data in a plugin or theme. Passing arguments with WordPress add_action | Michelle Dancer. Most WordPress developers are familiar with using add_action, but as you may have discovered the information on passing arguments to your callback function is hard to find. After a couple of hours of Googling, throwing a hissy fit, and good old trial and error I found a working solution, so I thought I’d share. The problem I wanted to run a function on admin_init, which would need arguments passed as an array. Running the function is easy enough: Add_action does accept a third parameter, but it’s not what I hoped it was. My solution The answer appears to be using do_action, which is something I’d never personally worked with before, and using two functions.

Since I want to run my main function on admin_init, this is essentially a chain reaction. The second add_action defines a custom hook, rather than one of the built-in WordPress ones, which I’m calling my_hook. If that last paragraph didn’t make your head explode, there’s one more thing to bear in mind. How To Create Custom Post Meta Boxes In WordPress. Sharing media libraries across network sites in WordPress - ChannelEaton. This is part of a larger project I’m developing at work. The ultimate goal is to have a central blog where the department can serve up sanctioned images, video, and audio for students to use on their portfolios – also hosted in the same WordPress multisite network.

After realizing that a (good) solution does not yet exist, I set out to create my own. The first hurdle was to create a new tab in the Upload/Insert media page. This task was made easy by a great tutorial here . The second and most difficult hurdle was solved by looking through the core code. Now for the last step. I haven’t yet had a chance to thoroughly test this code. Take a look at the follow-up post . Export csv functionality into my plugin. Function Reference/wp upload dir. Function Reference/wp upload dir Description Returns an array of key => value pairs containing path information on the currently configured uploads directory.

Checks the 'upload_path' option, which should be from the web root folder, and if it isn't empty it will be used. If it is empty, then the path will be 'WP_CONTENT_DIR/uploads'. The upload URL path is set either by the 'upload_url_path' option or by using the 'WP_CONTENT_URL' constant and appending '/uploads' to the path.

If the 'uploads_use_yearmonth_folders' is set to true (checkbox if checked in the administration settings panel), then the time will be used. If the path couldn't be created, then an error will be returned with the key 'error' containing the error message. On success, the returned array will have many indices: Usage Parameters $time (string) (optional) Time formatted in 'yyyy/mm'. Default: null Example Basic example to produce the upload directory URL. More in-depth break down of the data returned. <? Important Note Change Log. Support » Change file upload folders on WordPress 3.0 multi-site. 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.

It's this hooks architecture that makes WordPress the best blogging solution. If you don't know what WordPress hooks are for, read the Plugin API or this tutorial. If you're new to web design, you might also enjoy my easy PHP 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. Administration Menus. Administration Menus Languages: English • 中文(简体) • 日本語 • Русский • (Add your language) Introduction Usually, plugin and theme authors need to provide access to a settings (options) screen so users can customize how the plugin or theme is used.

The best way to present the user with such a screen is to create an administration menu item that allows the user to access that settings screen from all the Administration Screens. Function Reference Every Plot Needs a Hook To add an administration menu, you must do three things: Create a function that contains the menu-building code Register the above function using the admin_menu action hook. It is that second step that is often overlooked by new developers. Here is a very simple example of the three steps just described. <? In this example, the function my_plugin_menu() adds a new item to the Settings administration menu via the add_options_page() function. These processes are described in more detail in the sections below.

Dashboard Posts Media Links. 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. This article is specifically about the API of "Hooks", also known as "Filters" and "Actions", that WordPress uses to set your plugin in motion. 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. Function Reference Actions Modify database data. Create an Action Function Hook to WordPress. Uploads - Saving Media - Which Hook is Fired. Ten Things Every WordPress Plugin Developer Should Know. 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 (!

A Crash-Course in WordPress Plugin Development. Despite an extensive codex, many WordPress users remain unfamiliar with how to create their own custom plugins. In today's screencast, we'll start from scratch and build our first usable plugin. For this example, we'll write a simple "tuts formatting" function that allows a blog editor to more easily format articles. When creating a WordPress plugin, the first step is obviously to make sure that you have access to a WordPress installation. If you don't currently have a copy: Visit WordPress.org and download the most recent version to your harddrive. . * Note - this isn't a "getting started with WordPress" tutorial. Once WordPress is running, browse to wp-content -> plugins. Within the plugins folder, right-click and create a new folder - call it "Tuts_Formatting". WordPress recognizes these comments and then creates an option within your admin panel.

Note that if these comments are not included, WordPress will NOT recognize your plugin. Place all headings within H3 tags. We use ! Richmond Virginia Web Developer · Francis Yaconiello. I’ve noticed that a bunch of the how-to-write-a-plugin articles out there focus on demonstrating the minimum amount of code needed to get a plugin going. Not many focus on good plugin structure or convention. This tutorial explains how to create a class based WordPress plugin that makes sense. Start with a Directory WordPress plugins can be defined in a single file or a directory of files. Starting with a directory gives you more flexibility and allows you to use common structures and folder layouts between projects and will add a level of maintainability. Generally, I use the following folder tree: wp-plugin-name.php Every plugin begins with a docblock PHP comment describing the plugin.

<? After the plugin definition comment, you need to define your main plugin logic. If(! At the bottom of the plugin class register the activation/deactivation hooks and instantiate the plugin class by calling the constructor. ###Add a settings page Add your menu with a callback to a class function. If(!