textdomain = 'front-end-editor';
$this->args = array('page_title' => __('Front-end Editor', $this->textdomain));
$this->boxes = array(
array('fields', __('Fields', $this->textdomain), 'normal'),
array('settings', __('Settings', $this->textdomain), 'side'),
);
}
function page_head() {
?>
options->disabled = $disabled;
$this->admin_msg();
}
function fields_box() {
// Separate fields
$post_fields = $other_fields = array();
foreach ( FEE_Core::get_fields() as $field => $args )
if ( 'post' == call_user_func(array($args['class'], 'get_object_type') ) )
$post_fields[$field] = $args;
else
$other_fields[$field] = $args;
echo html('p', __('Enable or disable editable fields', $this->textdomain));
$tables = self::fields_table(__('Post fields', $this->textdomain), $post_fields);
$tables .= self::fields_table(__('Other fields', $this->textdomain), $other_fields);
echo $this->form_wrap($tables, '', 'manage_fields');
}
private function fields_table($title, $fields) {
$thead =
html('thead',
html('tr',
html('th scope="col" class="check-column"', '')
.html('th scope="col"', $title)
)
);
$tbody = '';
foreach ( $fields as $field => $args )
$tbody .=
html('tr',
html('th scope="row" class="check-column"',
$this->input(array(
'type' => 'checkbox',
'name' => $field,
'checked' => ! @in_array($field, $this->options->disabled)
))
)
.html('td', $args['title'])
);
return html('table class="widefat"', $thead . $tbody);
}
function settings_handler() {
if ( !isset($_POST['save_settings']) )
return;
foreach ( array('rich', 'chunks', 'reset_date', 'highlight', 'tooltip') as $key )
$this->options->$key = (bool) @$_POST[$key];
$this->admin_msg();
}
function settings_box() {
$rows = array(
array(
'desc' => __('Enable the WYSIWYG editor', $this->textdomain),
'type' => 'checkbox',
'name' => 'rich',
),
array(
'desc' => __('Edit one paragraph at a time, instead of an entire post', $this->textdomain),
'type' => 'checkbox',
'name' => 'chunks',
),
array(
'desc' => __('Reset the post date on each edit', $this->textdomain),
'type' => 'checkbox',
'name' => 'reset_date',
),
array(
'desc' => __('Highlight editable elements', $this->textdomain),
'type' => 'checkbox',
'name' => 'highlight',
),
array(
'desc' => __('Display a tooltip above editable elements', $this->textdomain),
'type' => 'checkbox',
'name' => 'tooltip',
),
);
$out = '';
foreach ( $rows as $row )
$out .= html('p', $this->input($row));
echo $this->form_wrap($out, '', 'save_settings');
}
}