Skip to content
This repository was archived by the owner on Nov 4, 2019. It is now read-only.
Jesper Bjerke edited this page Oct 1, 2015 · 5 revisions

Configuration

The idea with Fronted is that theme and plugin developers incorporate their configuration filter and add-on for their plugin or theme, without requiring the end user to use Fronted necessarily. This way, multiple configurations and add-ons can be hooked onto a single Fronted instance.

Here's the basics:

To enable an editable area, simply add a filter function to wa_fronted_options that passes and returns a multidimensional array. Note that both themes and plugins can call this filter before or after eachother and build upon or replace options.

The first level of the array consists of the key defaults (optional) and post_types. In defaults, specify whatever you want to be set as default when you have not set anything else in that specific area. In post_types you create an array for each post type you want to enable frontend editing for (you can also use front_page if you just want to target your static front page). Inside, you set editable_areas with an array with options for each editable area on this post type.

The following example will enable the regular post content on front page to be editable from frontend if logged in user has role administrator, with a toolbar consisting of only bold and italic buttons, but on posts we allow a full toolbar and leaving permission to the default (current_user_can('edit_posts')). See options for all available parameters.

<?php 
function my_editor_options($exisiting_options){
	//It is recommended to do an array_merge with the exisiting options to not break other settings
	return array_merge($exisiting_options, array(
		"defaults" => array(
			"permission"   => "default",
			"toolbar"      => "full",
			"media_upload" => true
		),
		"post_types" => array(
			"front_page" => array(
				"editable_areas" => array(
					array(
						"container"  => ".entry-content",
						"field_type" => "post_content",
						"toolbar"    => "bold, italic",
						"permission" => "administrator"
					)
				)
			),
			"post" => array(
				"editable_areas" => array(
					array(
						"container"  => ".entry-content",
						"field_type" => "post_content",
						"toolbar"    => "full"
					)
				)
			)
		)
	)); 
}
add_filter('wa_fronted_options', 'my_editor_options');
?>
Clone this wiki locally