/** * Mark the field as editable * * @param string $content Filtered content * @param mixed $data Additional data like an object id etc. * * @return string Wrapped content */ public function wrap($content, $data) { if (!$this->allow($data)) { return $content; } $data = wp_parse_args($data, array('type' => $this->input_type)); if ('rich' == $data['type'] && !FEE_Core::$options->rich) { $data['type'] = 'textarea'; } self::$wrapped[$data['type']] = true; if (is_null($content)) { $content = ''; } if (!is_scalar($content)) { trigger_error("scalar expected. " . gettype($content) . " given", E_USER_WARNING); } $data = apply_filters('front_end_editor_wrap', $data, $this->filter); $data['filter'] = $this->filter; $data_attr = array(); foreach ($data as $key => $value) { if (!is_scalar($value)) { $value = json_encode($value); } $data_attr["data-{$key}"] = $value; } $data_attr['class'] = 'fee-field'; if ($this->was_placeholded) { $data_attr['title'] = FEE_Core::get_title($this->filter); } $wrap_tag = in_array($data['type'], array('textarea', 'rich', 'widget')) ? 'div' : 'span'; if ('div' == $wrap_tag) { $data_attr['class'] .= ' fee-clearfix'; } return html($wrap_tag, $data_attr, $content); }
static function init($options) { self::$options = $options; add_action('wp_ajax_front-end-editor', array(__CLASS__, 'ajax_response')); add_action('template_redirect', array(__CLASS__, '_init')); // TODO: Add equivalent hook for BuddyPress }
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 = $this->fields_table(__('Post fields', $this->textdomain), $post_fields); $tables .= $this->fields_table(__('Other fields', $this->textdomain), $other_fields); echo $this->form_wrap($tables, '', 'manage_fields'); }
function _fee_init() { load_plugin_textdomain('front-end-editor', '', basename(dirname(__FILE__)) . '/lang'); $dir = dirname(__FILE__) . '/php'; require_once $dir . '/template-tags.php'; require_once $dir . '/core.php'; foreach (array('base', 'post', 'widget', 'other') as $name) { require_once "{$dir}/fields/{$name}.php"; } $options = new scbOptions('front-end-editor', __FILE__, array('disabled' => array('bloginfo'), 'rich' => true, 'group_post' => false, 'taxonomy_ui' => 'termselect')); FEE_Core::init($options); FEE_Field_Option::init(__FILE__); FEE_Field_Image::init(__FILE__); if (is_admin()) { require_once dirname(__FILE__) . '/admin/admin.php'; scbAdminPage::register('FEE_Admin', __FILE__, $options); } add_action('front_end_editor_fields', 'fee_register_defaults', 0); }
static function make_instances() { $disabled = (array) self::$options->disabled; self::$active_fields = array(); foreach (self::get_fields() as $key => $data) { if (!in_array($key, $disabled)) { self::$active_fields[$key] = $data; } } foreach (self::$active_fields as $filter => $args) { extract($args); self::$instances[$filter] = new $class($filter, $type); } }
private static function make_instances() { $disabled = (array) self::$options->disabled; self::$active_fields = array(); foreach (self::get_fields() as $filter => $args) { if (in_array($filter, $disabled)) { continue; } self::$active_fields[$filter] = $args; extract($args); self::$instances[$filter] = new $class($filter, $type); } }