public static function summary( MEOW_Field $field ) { if (!$field->blank()) { $summary = preg_replace("/\[[^\]]*\]/", '', $field->raw()); $summary = preg_replace("/<[^>]*>/", " ", $summary); $summary = preg_replace("/( ){2,}/", " ", $summary); $summary = preg_replace("/^(\s|( ))+/", "", $summary); $summary_content = self::truncate_for_summary(self::summary_width(), $summary); if ($summary_content == "") { $summary_content = $field->raw(); // if there's nothing, bring back some of the content (shortcodes in particular) } return $summary_content; } }
public static function ui( MEOW_Field $field ) { // $field here is a MEOW_Field, which is a class that encapsulates the value of a field AND the info associated with it $options = $field->info->type_options; $readonly = WOOF_HTML::readonly_attr( !$field->is_editable() ); $value = ""; if (!$field->blank()) { $value = htmlspecialchars($field->raw()); $hiddenmode = $field->prop("mode"); } else { $hiddenmode = self::option_value($options, "mode"); } $class = ""; $mode_select = ''; if (isset($options["modeselect"]) && $options["modeselect"] == "yes") { $mode_select = WOOF_HTML::open("div", array("class" => "modeselect-wrap")); $mode_select .= WOOF_HTML::tag("label", array(), __("Syntax Mode: ", MASTERPRESS_DOMAIN)); $class = " editor-ui-with-modeselect"; $attr = array("id" => "{{prop_id}}-mode", "name" => "{{prop_name}}[mode]", "class" => "modeselect"); if ($readonly) { $attr["readonly"] = "readonly"; } $mode_select .= WOOF_HTML::select( $attr, self::modes(), $hiddenmode ); $mode_select .= WOOF_HTML::close("div"); } $html = <<<HTML <div class="editor-ui{$class}"> <textarea id="{{id}}" $readonly name="{{name}}">{$value}</textarea> <input type="hidden" name="hiddenmode" id="{{id}}-hiddenmode" class="hiddenmode" value="{$hiddenmode}" /> {$mode_select} </div> HTML; return $html; }