public static function options_form( $options ) { $defaults = array(); if (MPC::is_create()) { $defaults = array(); } $options = wp_parse_args( $options, $defaults ); $p = self::type_prefix(__CLASS__); // setup variables to insert into the heredoc string // (this is required where we cannot call functions within heredoc strings) $maxlength_label = __("Maximum Length:", MASTERPRESS_DOMAIN); $maxlength_note = __("(characters)", MASTERPRESS_DOMAIN); $maxlength = self::option_value($options, "maxlength"); $status_checked_attr = WOOF_HTML::checked_attr(self::option_value($options, "status") == "yes"); $status_label = __("show a count of remaining characters", MASTERPRESS_DOMAIN); $default_value_label = __("Default Value:", MASTERPRESS_DOMAIN); $default_value_note = __("Use the preview of your control above to set a default value", MASTERPRESS_DOMAIN); $default_value = self::option_value($options, "default_value"); $maxwidth = MPFT::options_maxwidth( $p, $options ); $font = MPFT::options_font( $p, $options ); $html = <<<HTML <div class="f"> <label for="{$p}maxlength">{$maxlength_label}</label> <div id="fw-{$p}maxlength" class="fw"> <input id="{$p}maxlength" name="type_options[maxlength]" type="text" value="{$maxlength}" class="text" /><span class="note">{$maxlength_note}</span> <div id="{$p}status-wrap"> <input id="{$p}status" type="checkbox" name="type_options[status]" {$status_checked_attr} value="yes" class="checkbox" /> <label for="{$p}status" class="checkbox">{$status_label}</label> </div> </div> </div> <!-- /.f --> {$maxwidth} {$font} <div class="f"> <label for="{$p}default_value">{$default_value_label}</label> <div id="fw-{$p}default-value" class="fw"> <input id="{$p}default-value" name="type_options[default_value]" type="text" value="{$default_value}" class="text" /> <p class="note">{$default_value_note}</p> </div> </div> <!-- /.f --> HTML; return $html; }
public static function options_form( $options ) { global $meow_provider; global $wf; $p = self::type_prefix(__CLASS__); $defaults = array(); if (MPC::is_create()) { $defaults = array("maxwidth" => 580, "height" => 300, "control_style" => "drop_down_list"); } $options = wp_parse_args( $options, $defaults ); if (MPC::is_create()) { $options["post_types"] = array(); } // setup variables to insert into the heredoc string // (this is required where we cannot call functions within heredoc strings) $taxonomies_label = __("Available Taxonomies:", MASTERPRESS_DOMAIN); $taxonomies_note = __("Select the taxonomies of terms available for selection in the field control", MASTERPRESS_DOMAIN); $taxonomies_items = array(); MPM::incl("taxonomy"); $taxonomies = MPM_Taxonomy::find("orderby=disabled,name ASC"); $taxonomies_selected = array(); foreach ($taxonomies as $taxonomy) { if (!$taxonomy->disabled && $taxonomy->show_ui && $taxonomy->still_registered()) { $taxonomies_selected[] = $taxonomy->name; $taxonomies_items[$taxonomy->display_label()] = $taxonomy->name; } } if (!MPC::is_create()) { $taxonomies_selected = self::option_value($options, "taxonomies"); } if (!is_array($taxonomies_selected)) { $taxonomies_selected = explode(",", $taxonomies_selected); } $id = $p."taxonomies-"; $taxonomies_checkboxes = ""; foreach ($taxonomies as $taxonomy) { if (!$taxonomy->disabled && $taxonomy->show_ui && $taxonomy->still_registered()) { $value = $taxonomy->name; $label = $taxonomy->display_label(); $id_suffix = WOOF::sanitize($value); $attr = array( "id" => $id."_".$id_suffix, "class" => "checkbox", "type" => "checkbox", "name" => "type_options[taxonomies][]", "value" => $value ); if (in_array($value, $taxonomies_selected)) { $attr["checked"] = "checked"; } $taxonomies_checkboxes .= WOOF_HTML::open("div", "class=fwi"); $taxonomies_checkboxes .= WOOF_HTML::tag("input", $attr ); $taxonomies_checkboxes .= WOOF_HTML::tag("label", array( "for" => $id."_".$id_suffix, "class" => "checkbox mp-icon-taxonomy mp-icon-taxonomy-".$value ), $label ); $taxonomies_checkboxes .= WOOF_HTML::close("div"); } } $ex_label = __("Description", MASTERPRESS_DOMAIN); $title_label = __("Name", MASTERPRESS_DOMAIN); $results_row_style = MPFT::options_select_results_row_style( $p, $options, array("excerpt" => $ex_label, "title" => $title_label ) ); $placeholder = MPFT::options_placeholder($p, $options); $basic = MPFT::options_select_basic( $p, $options ); $multi_layout = MPFT::options_select_multi_layout( $p, $options ); $control_style = MPFT::options_select_control_style( $p, $options ); $maxwidth = MPFT::options_maxwidth( $p, $options ); $height = MPFT::options_height( $p, $options ); $grouping = MPFT::options_select_grouping( $p, $options, __("Taxonomy", MASTERPRESS_DOMAIN) ); $results_input_length = MPFT::options_input_text( $p, $options, "results_input_length", __("Minimum Input Length", MASTERPRESS_DOMAIN), __("Enter the number of characters required before any results are displayed.<br />This is useful for large numbers of posts, where performance may become poor.", MASTERPRESS_DOMAIN)); $data_source_label = __("Data Source - <span>specify the terms available for selection</span>", MASTERPRESS_DOMAIN); $control_options_label = __("Control Options", MASTERPRESS_DOMAIN); $control_results_label = __("Results Display - <span>settings for the display of the available terms</span>", MASTERPRESS_DOMAIN); $control_selections_label = __("Selection Display - <span>settings for the display of the selected terms</span>", MASTERPRESS_DOMAIN); // build a taxonomies grid $results_row_item_prop_label = __("Row Item Properties:", MASTERPRESS_DOMAIN); $results_row_item_prop_note = __("Defines the term properties used to derive the info shown in result rows.<br /><b>Note: </b>Descriptions and images will be truncated / resized automatically.", MASTERPRESS_DOMAIN); $row_style = self::option_value($options, "row_style", "icon_title"); $grid = WOOF_HTML::open("table", "class=grid mini not-selectable grid-row-item-prop&cellspacing=0"); $grid .= WOOF_HTML::open("thead"); $grid .= WOOF_HTML::tag("th", "class=icon taxonomy", WOOF_HTML::tag("i", "class=tags", "") . WOOF_HTML::tag("span", null, __("Taxonomy", MASTERPRESS_DOMAIN))); $grid .= WOOF_HTML::tag("th", "class=icon title", WOOF_HTML::tag("i", "class=title-bar", "") . WOOF_HTML::tag("span", null, $title_label)); $grid .= WOOF_HTML::tag("th", "class=".(($row_style == "icon_title" || $row_style == "image_title") ? "disabled " : "")."icon excerpt", WOOF_HTML::tag("i", "class=content-bar", "") . WOOF_HTML::tag("span", null, $ex_label)); $grid .= WOOF_HTML::tag("th", "class=".(($row_style == "icon_title" || $row_style == "icon_title_excerpt") ? "disabled " : "")."icon image", WOOF_HTML::tag("i", "class=image", "") . WOOF_HTML::tag("span", null, __("Image", MASTERPRESS_DOMAIN))); $grid .= WOOF_HTML::close("thead"); $grid .= WOOF_HTML::open("tbody"); $count = 1; foreach ($taxonomies as $taxonomy) { if (!$taxonomy->disabled && $taxonomy->show_ui) { $classes = array("taxonomy-".$taxonomy->name); if ($count == 1) { $classes[] = "first"; } $attr = array("class" => implode(" ", $classes)); if (!in_array($taxonomy->name, $taxonomies_selected)) { $attr["style"] = "display: none;"; } $grid .= WOOF_HTML::open("tr", $attr); $count++; $span = WOOF_HTML::tag("span", array("class" => "mp-icon-taxonomy mp-icon-taxonomy-".$taxonomy->name ), $taxonomy->display_label()); $grid .= WOOF_HTML::tag("td", "class=first taxonomy", $span); $grid .= WOOF_HTML::open("td", "class=title"); $default = "name"; $value = isset($options["result_row_prop"][$taxonomy->name]["title"]) ? $options["result_row_prop"][$taxonomy->name]["title"] : $default; if ($value == "") { $value = $default; } $input_attr = array( "type" => "text", "name" => "type_options[result_row_prop][".$taxonomy->name."][title]", "class" => "text", "value" => $value ); $grid .= WOOF_HTML::open("div"); $grid .= WOOF_HTML::tag("input", $input_attr); $grid .= WOOF_HTML::tag( "button", array( "type" => "button", "class" => "ir", "data-dialog" => "dialog-taxonomy-".$taxonomy->name, "data-filter" => "text", "title" => __("Select Field", MASTERPRESS_DOMAIN) ), "select" ); $grid .= WOOF_HTML::close("div"); $grid .= WOOF_HTML::close("td"); $grid .= WOOF_HTML::open("td", "class=excerpt".(($row_style == "icon_title" || $row_style == "image_title") ? " disabled" : "")); $default = "description"; $value = isset($options["result_row_prop"][$taxonomy->name]["excerpt"]) ? $options["result_row_prop"][$taxonomy->name]["excerpt"] : $default; if ($value == "") { $value = $default; } $input_attr = array( "type" => "text", "name" => "type_options[result_row_prop][".$taxonomy->name."][excerpt]", "class" => "text", "value" => $value ); $grid .= WOOF_HTML::open("div"); $grid .= WOOF_HTML::tag("input", $input_attr); $grid .= WOOF_HTML::tag( "button", array( "type" => "button", "class" => "ir", "data-dialog" => "dialog-taxonomy-".$taxonomy->name, "data-filter" => "text", "title" => __("Select Field", MASTERPRESS_DOMAIN) ), "select" ); $grid .= WOOF_HTML::close("div"); $grid .= WOOF_HTML::close("td"); $grid .= WOOF_HTML::open("td", "class=image".(($row_style == "icon_title" || $row_style == "icon_title_excerpt") ? " disabled" : "")); $default = ""; $value = isset($options["result_row_prop"][$taxonomy->name]["image"]) ? $options["result_row_prop"][$taxonomy->name]["image"] : $default; if ($value == "") { $value = $default; } $input_attr = array( "type" => "text", "name" => "type_options[result_row_prop][".$taxonomy->name."][image]", "class" => "text", "value" => $value ); $grid .= WOOF_HTML::open("div"); $grid .= WOOF_HTML::tag("input", $input_attr); $grid .= WOOF_HTML::tag( "button", array( "type" => "button", "class" => "ir", "data-dialog" => "dialog-taxonomy-".$taxonomy->name, "data-filter" => "image", "title" => __("Select Field", MASTERPRESS_DOMAIN) ), "select" ); $grid .= WOOF_HTML::close("div"); $grid .= WOOF_HTML::close("td"); $grid .= WOOF_HTML::close("tr"); } } $grid .= WOOF_HTML::close("tbody"); $grid .= WOOF_HTML::close("table"); // build dialogs for selecting row properties in the grid $dialogs = ""; foreach ($taxonomies as $taxonomy) { if (!$taxonomy->disabled && $taxonomy->show_ui) { $dialogs .= WOOF_HTML::open( "div", array( "class" => "dialog dialog-fields", "id" => "dialog-taxonomy-".$taxonomy->name, "data-title" => __("Select a Field", MASTERPRESS_DOMAIN) ) ); $fs = $meow_provider->taxonomy_field_sets($taxonomy->name); $field_options = array(); $field_options[""] = ""; $field_options_attr = array(""); $field_options[__("( Built-in Fields )", MASTERPRESS_DOMAIN)] = array( "options" => array( __("Name", MASTERPRESS_DOMAIN) => "name", __("Description", MASTERPRESS_DOMAIN) => "description" ), "options_attr" => array( array("data-icon" => "mp-icon mp-icon-field-type-text-box", "class" => "text"), array("data-icon" => "mp-icon mp-icon-field-type-text-box-multiline", "class" => "text") ) ); foreach ($fs as $set) { $fo = array(); $fo_attr = array(); foreach ($set->fields() as $field) { if ($type_class = MPFT::type_class($field->type)) { $image = call_user_func( array($type_class, "supports_image") ) ? " image" : ""; $text = call_user_func( array($type_class, "supports_text") ) ? " text" : ""; $fo[$field->display_label()] = $set->name.".".$field->name; $fo_attr[] = $field_options_attr[] = array("class" => $image.$text, "data-icon" => "mp-icon mp-icon-field-type-".$field->type); } $field_options[$set->display_label()] = array("options" => $fo, "options_attr" => $fo_attr); } } $dialogs .= WOOF_HTML::select(array("name" => "add-field-column-field-sets", "class" => "with-icons select2-source", "data-placeholder" => __("-- Select a Field --", MASTERPRESS_DOMAIN)), $field_options, "", $field_options_attr); $dialogs .= WOOF_HTML::close("div"); } } $html = <<<HTML {$dialogs} {$control_style} <div class="f f-taxonomies"> <p class="label">{$taxonomies_label}</p> <div class="fw"> <div id="{$p}taxonomies-wrap"> {$taxonomies_checkboxes} </div> <div id="{$p}taxonomies-controls" class="controls"> <button type="button" class="button button-small select-all">Select All</button> <button type="button" class="button button-small select-none">Select None</button> </div> <!-- /.controls --> <p class="note">{$taxonomies_note}</p> </div> </div> <!-- /.f --> {$placeholder} {$basic} {$maxwidth} <div class="divider"> <h4><i class="menu-gray"></i>{$control_results_label}</h4> {$grouping} {$results_input_length} {$results_row_style} <div id="{$p}results-row-item-prop-f" class="results-row-item-prop-f f"> <p class="label">{$results_row_item_prop_label}</p> <div class="fw"> {$grid} <p class="note">{$results_row_item_prop_note}</p> </div> </div> <!-- /.f --> </div> <div id="{$p}control-selections-wrap" class="divider"> <h4><i class="buttons"></i>{$control_selections_label}</h4> {$multi_layout} </div> HTML; return $html; }
public static function options_form( $options ) { global $wf; $defaults = array(); if (MPC::is_create()) { $defaults = array("maxwidth" => 580, "height" => 200); } $options = wp_parse_args( $options, $defaults ); $p = self::type_prefix(__CLASS__); // setup variables to insert into the heredoc string // (this is required since we cannot call functions within heredoc strings) $exclude_current = MPFT::options_exclude_current( $p, $options, __('Check to exclude the current site from this list', MASTERPRESS_DOMAIN) ); $basic = MPFT::options_select_basic( $p, $options ); $multi_layout = MPFT::options_select_multi_layout( $p, $options ); $control_style = MPFT::options_select_control_style( $p, $options ); $maxwidth = MPFT::options_maxwidth( $p, $options ); $height = MPFT::options_height( $p, $options ); $placeholder = MPFT::options_placeholder($p, $options); $control_selections_label = __("Selection Display - <span>settings for the display of the selected sites</span>", MASTERPRESS_DOMAIN); $html = <<<HTML {$control_style} {$basic} {$exclude_current} {$placeholder} {$maxwidth} <div id="{$p}control-selections-wrap" class="divider"> <h4><i class="buttons"></i>{$control_selections_label}</h4> {$multi_layout} </div> HTML; return $html; }
public static function options_form( $options ) { $p = self::type_prefix(__CLASS__); $defaults = array(); if (MPC::is_create()) { $defaults = array("step" => 1, "min" => 0, "format" => "0", "maxwidth" => 100, $negative_red = "yes"); } $options = wp_parse_args( $options, $defaults ); $negative_red_label = __("Show Negative in red?:", MASTERPRESS_DOMAIN); $min_label = __("Minimum Value:", MASTERPRESS_DOMAIN); $max_label = __("Maximum Value:", MASTERPRESS_DOMAIN); $default_label = __("Default Value:", MASTERPRESS_DOMAIN); $step_label = __("Step By:", MASTERPRESS_DOMAIN); $step_note = __("Enter a numeric step amount for the up / down buttons or arrow keys.", MASTERPRESS_DOMAIN); $format_label = __("Number Format:", MASTERPRESS_DOMAIN); $format_note = __("Enter a numeric format to use made up of zeros (0), hashes (#), commas (,) a decimal point, and other symbols.<br />0 represents a decimal that will always be present (generally only used on either side of a decimal point).<br /># is a decimal that is present if needed, and commas and other symbols are placed into the same position.<br />Example: $#,###,###,##0.00 is a currency amount with 2 decimal places always shown,<br />and a leading zero always in front of the decimal point.", MASTERPRESS_DOMAIN); $negative_red = self::option_value($options, "negative_red"); $negative_red_checked_attr = WOOF_HTML::checked_attr($negative_red == "yes"); $min = self::option_value($options, "min"); $default = self::option_value($options, "default"); $max = self::option_value($options, "max"); $step = self::option_value($options, "step"); $format = self::option_value($options, "format"); $maxwidth = MPFT::options_maxwidth( $p, $options ); $html = <<<HTML <div class="f"> <label for="{$p}min">{$min_label}</label> <div id="fw-{$p}min" class="fw"> <input id="{$p}min" name="type_options[min]" type="text" value="{$min}" class="text" /> </div> </div> <!-- /.f --> <div class="f"> <label for="{$p}max">{$max_label}</label> <div id="fw-{$p}max" class="fw"> <input id="{$p}max" name="type_options[max]" type="text" value="{$max}" class="text" /> </div> </div> <!-- /.f --> <div class="f"> <label for="{$p}default">{$default_label}</label> <div id="fw-{$p}default" class="fw"> <input id="{$p}default" name="type_options[default]" type="text" value="{$default}" class="text" /> </div> </div> <!-- /.f --> <div class="f"> <label for="{$p}step">{$step_label}</label> <div id="fw-{$p}step" class="fw"> <input id="{$p}step" name="type_options[step]" type="text" value="{$step}" class="text" /> </div> </div> <!-- /.f --> <div class="f"> <label for="{$p}format">{$format_label}</label> <div id="fw-{$p}format" class="fw"> <input id="{$p}format" name="type_options[format]" type="text" value="{$format}" class="text" /> <p class="note">{$format_note}</p> </div> </div> <!-- /.f --> {$maxwidth} <div class="f"> <label for="{$p}negative_red">{$negative_red_label}</label> <div id="fw-{$p}negative_red" class="fw"> <input id="{$p}negative_red" name="type_options[negative_red]" type="checkbox" {$negative_red_checked_attr} value="yes" class="checkbox" /> </div> </div> <!-- /.f --> HTML; return $html; }
public static function options_form( $options ) { global $wf; $defaults = array(); if (MPC::is_create()) { $defaults = array("maxwidth" => 580, "height" => 200); } $options = wp_parse_args( $options, $defaults ); $p = self::type_prefix(__CLASS__); // setup variables to insert into the heredoc string // (this is required since we cannot call functions within heredoc strings) $user_roles_label = __("Available User Roles:", MASTERPRESS_DOMAIN); $user_roles_note = __("Specify the user roles available for selection in the field control", MASTERPRESS_DOMAIN); $user_roles_items = array(); $user_roles = get_editable_roles(); foreach ($wf->roles() as $role) { $user_roles_items[$role->name()] = $role->id(); } $user_roles_checkboxes = WOOF_HTML::input_checkbox_group( "type_options[user_roles][]", $p."user-roles-", $user_roles_items, self::option_value($options, "user_roles"), WOOF_HTML::open("div", "class=fwi"), WOOF_HTML::close("div")); $basic = MPFT::options_select_basic( $p, $options ); $multi_layout = MPFT::options_select_multi_layout( $p, $options ); $control_style = MPFT::options_select_control_style( $p, $options ); $maxwidth = MPFT::options_maxwidth( $p, $options ); $height = MPFT::options_height( $p, $options ); $placeholder = MPFT::options_placeholder($p, $options); $control_selections_label = __("Selection Display - <span>settings for the display of the selected user roles</span>", MASTERPRESS_DOMAIN); $html = <<<HTML {$control_style} <div class="f f-user-roles"> <p class="label">{$user_roles_label}</p> <div class="fw"> <div id="{$p}user-roles-wrap"> {$user_roles_checkboxes} </div> <div id="{$p}user-roles-controls" class="controls"> <button type="button" class="button button-small select-all">Select All</button> <button type="button" class="button button-small select-none">Select None</button> </div> <!-- /.controls --> <p class="note">{$user_roles_note}</p> </div> </div> <!-- /.f --> {$basic} {$placeholder} {$maxwidth} <div id="{$p}control-selections-wrap" class="divider"> <h4><i class="buttons"></i>{$control_selections_label}</h4> {$multi_layout} </div> HTML; return $html; }
public static function options_form( $options ) { global $wf; $p = self::type_prefix(__CLASS__); $defaults = array(); if (MPC::is_create()) { $defaults = array("maxwidth" => 580, "height" => 300, "control_style" => "drop_down_list"); } $options = wp_parse_args( $options, $defaults ); if (MPC::is_create()) { $options["post_types"] = array(); } // setup variables to insert into the heredoc string // (this is required where we cannot call functions within heredoc strings) $taxonomies_label = __("Available Taxonomies:", MASTERPRESS_DOMAIN); $taxonomies_note = __("Select the taxonomies available for selection in the field control", MASTERPRESS_DOMAIN); $taxonomies_items = array(); MPM::incl("taxonomy"); $taxonomies = MPM_Taxonomy::find("orderby=disabled,name ASC"); $ts = array(); foreach ($taxonomies as $taxonomy) { if (MPC::is_create()) { $options["taxonomies"][] = $taxonomy->name; } if (!$taxonomy->disabled && $taxonomy->show_ui && $taxonomy->still_registered()) { $taxonomies_items[$taxonomy->display_label()] = $taxonomy->name; $ts[] = $taxonomy->name; } } if (!MPC::is_create()) { $ts = self::option_value($options, "taxonomies"); } $id = $p."taxonomies-"; $taxonomies_checkboxes = ""; foreach ($taxonomies as $taxonomy) { if (!$taxonomy->disabled && $taxonomy->show_ui && $taxonomy->still_registered()) { $value = $taxonomy->name; $label = $taxonomy->display_label(); $id_suffix = WOOF::sanitize($value); $attr = array( "id" => $id."_".$id_suffix, "class" => "checkbox", "type" => "checkbox", "name" => "type_options[taxonomies][]", "value" => $value ); if (in_array($value, $ts)) { $attr["checked"] = "checked"; } $taxonomies_checkboxes .= WOOF_HTML::open("div", "class=fwi"); $taxonomies_checkboxes .= WOOF_HTML::tag("input", $attr ); $taxonomies_checkboxes .= WOOF_HTML::tag("label", array( "for" => $id."_".$id_suffix, "class" => "checkbox mp-icon-taxonomy-".$value ), $label ); $taxonomies_checkboxes .= WOOF_HTML::close("div"); } } $basic = MPFT::options_select_basic( $p, $options ); $multi_layout = MPFT::options_select_multi_layout( $p, $options ); $control_style = MPFT::options_select_control_style( $p, $options ); $maxwidth = MPFT::options_maxwidth( $p, $options ); $height = MPFT::options_height( $p, $options ); $placeholder = MPFT::options_placeholder($p, $options); $control_selections_label = __("Selection Display - <span>settings for the display of the selected taxonomies</span>", MASTERPRESS_DOMAIN); $html = <<<HTML {$control_style} <div class="f f-taxonomies"> <p class="label">{$taxonomies_label}</p> <div class="fw"> <div id="{$p}taxonomies-wrap"> {$taxonomies_checkboxes} </div> <div id="{$p}taxonomies-controls" class="controls"> <button type="button" class="button button-small select-all">Select All</button> <button type="button" class="button button-small select-none">Select None</button> </div> <!-- /.controls --> <p class="note">{$taxonomies_note}</p> </div> </div> <!-- /.f --> {$basic} {$placeholder} {$maxwidth} <div id="{$p}control-selections-wrap" class="divider"> <h4><i class="buttons"></i>{$control_selections_label}</h4> {$multi_layout} </div> HTML; return $html; }