Skip to content

Actions and filters

bookchiq edited this page Nov 30, 2012 · 2 revisions

Front-end Editor comes with several hooks for fine-tuning its behaviour.

'front_end_editor_disable'

Use this filter if you want to completely disable the plugin for certain URLs.

Callback arguments:

  • bool $disable The current state. Default: false

You can use conditional tags:

Disable FEE on author archive pages

<?php
function fee_disable_on_author_pages( $disable ) {
    return is_author();
}
add_filter( 'front_end_editor_disable', 'fee_disable_on_author_pages' );

'front_end_editor_allow_{$type}'

Use this filter if you want more fine-grained control over which fields are editable by which users.

$type is the type of object being edited. It can be: post, comment, term, option, widget, user

Callback arguments:

  • bool $allow The current state. Default: true
  • array $data Various information about the current object, like post_id etc.
  • string $filter The current filter name, such as 'the_content'
  • string $input_type The current input type: input, textarea, rich, checkbox, radio or select

Usually, you'll only need $allow and $data.

Allow editing only posts belonging to a certain category

<?php
function fee_specific_category( $allow, $data ) {
	return $allow && in_category( 'wiki', $data['post_id'] );
}
add_filter( 'front_end_editor_allow_post', 'fee_specific_category', 10, 2 );

'front_end_editor_fields'

This action is fired exactly after all the default field types have been registered.

It's intended use is registering new field types or manipulating default ones. This is done using fee_register_field().

'front_end_editor_loaded'

This is an action fired right after FEE has finished loading all the JS and CSS.

It's a good place to add additional JavaScript.

Callback arguments:

  • array $wrapped List of filters found at the current URL

'front_end_editor_wrap'

This filter allows you to change the data-* attributes of the tag that wraps editable fields.

An example can be found in Editing taxonomies.

Callback arguments:

  • array $data An associative array containing all the available data about that particular field, like the post id, the input type, etc.
  • string $filter The current filter, i.e. the_content, the_title etc.