public static function options_form( $options ) { $html = ""; $limit = self::get_filesize_limit(); $limit_mb = WOOF_File::format_filesize($limit, "MB", false); $defaults = array( "filename_case" => "lowercase", "filename_sanitize" => "dashes", "allowed_types" => array("csv","doc","docx","gz","m4a", "md", "pdf","pps","ppt","pptx","psd","rar","rtf","swf","txt","vcf","xls","xlsx","xml","zip") ); $options = wp_parse_args( $options, $defaults ); $p = self::type_prefix(__CLASS__); $allowed_maxsize = self::option_value($options, "allowed_maxsize"); $allowed_types = self::option_value($options, "allowed_types"); $allowed_field = implode(",", $allowed_types); $allowed_types_label = __("Allowed File Types:", MASTERPRESS_DOMAIN); $allowed_maxsize_label = __("Maximum Size:", MASTERPRESS_DOMAIN); $allowed_field_label = __("More Allowed Types:", MASTERPRESS_DOMAIN); $allowed_field_note = __("Separate file extensions that you would like to allow with commas.<br /><strong>Important:</strong> in the interests of security, take care to avoid file types that are executable on your server that may be exploitable by malicious users.<br /><br />Alternatively, you can populate the list by selecting from the list of typical field types below:", MASTERPRESS_DOMAIN); $filename_label = __("File Name Handling", MASTERPRESS_DOMAIN); $filename_label_note = __("specify how file names should be sanitized on upload", MASTERPRESS_DOMAIN); $filename_sanitize_label = __("Sanitize file name:", MASTERPRESS_DOMAIN); $filename_sanitize_note = __("Sanitization removes special characters and replaces word boundaries with the specified character", MASTERPRESS_DOMAIN); $filename_case_label = __("Change case to:", MASTERPRESS_DOMAIN); $filename_case_select = WOOF_HTML::select( array("id" => $p."filename_case", "name" => "type_options[filename_case]"), array( "lower-case" => "lowercase", "Title-Case" => "titlecase", "UPPER-CASE" => "uppercase", "Preserve (No Change)" => "none" ), $options["filename_case"] ); $filename_sanitize_select = WOOF_HTML::select( array("id" => $p."filename_sanitize", "name" => "type_options[filename_sanitize]"), array( __("With Dashes ( - )", MASTERPRESS_DOMAIN) => "dashes", __("With Underscores ( _ )", MASTERPRESS_DOMAIN) => "underscores", __("None (Don't Sanitize)", MASTERPRESS_DOMAIN) => "none" ), $options["filename_sanitize"] ); $allowed_maxsize_note = __("( MB )", MASTERPRESS_DOMAIN); $allowed_maxsize_blank_note = sprintf(__("This value <strong>cannot exceed</strong> the maximum upload size<br />for your server, which is currently set to <strong>%s</strong>.", MASTERPRESS_DOMAIN), WOOF_File::format_filesize($limit, "MB", true, " ")); $allowed_label = __("File Restrictions", MASTERPRESS_DOMAIN); $allowed_label_note = __("restrict allowable files by type and file size", MASTERPRESS_DOMAIN); // setup variables to insert into the heredoc string // (this is required where we cannot call functions within heredoc strings) $html .= <<<HTML <div class="filename-handling-wrap"> <h4><i class="highlighter"></i>{$filename_label}<span> - {$filename_label_note}</span></h4> <div class="f"> <label for="{$p}filename_sanitize">{$filename_sanitize_label}</label> <div id="fw-{$p}filename_sanitize" class="fw"> {$filename_sanitize_select} <p class="note">{$filename_sanitize_note}</p> </div> </div> <!-- /.f --> <div class="f"> <label for="{$p}filename_case">{$filename_case_label}</label> <div id="fw-{$p}filename_case" class="fw"> {$filename_case_select} </div> </div> <!-- /.f --> </div> <div class="allowed-wrap divider"> <h4><i class="warning-shield"></i>{$allowed_label}<span> - {$allowed_label_note}</span></h4> <div class="f"> <label for="{$p}allowed_maxsize">{$allowed_maxsize_label}</label> <div id="fw-{$p}allowed_maxsize" class="fw"> <input id="{$p}allowed_maxsize" name="type_options[allowed_maxsize]" type="text" maxlength="4" value="{$allowed_maxsize}" class="text" /><span class="note">{$allowed_maxsize_note}</span> <p class="note">{$allowed_maxsize_blank_note}</p> </div> </div> <!-- /.f --> <div class="f f-allowed-types"> <p class="label">{$allowed_types_label}</p> <div class="fw"> <div class="clearfix"> <textarea id="{$p}allowed_field" class="mono" name="allowed_field">{$allowed_field}</textarea> <p id="allowed-field-note" class="note">{$allowed_field_note}</p> </div> <div id="{$p}allowed-types-wrap"> HTML; foreach (WOOF_File::file_type_categories() as $header => $exts) { $html .= '<div class="file-category">'; $html .= "<h5>".$header."</h5>"; $file_types_items = array(); $proxy = ""; if ($header == "Camera RAW Files") { $proxy = "file-type-raw"; } foreach ($exts as $ext) { $file_types_items[ self::file_type_label($ext, $proxy) ] = $ext; } $html .= WOOF_HTML::input_checkbox_group( "type_options[allowed_types][]", $p."allowed-types-", $file_types_items, $allowed_types, WOOF_HTML::open("div", "class=fwi"), WOOF_HTML::close("div")); $html .= '<div 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>'; $html .= '</div>'; } $html .= <<<HTML </div> <div id="{$p}allowed-types-custom"> </div> </div> </div> <!-- /.f --> </div> HTML; return $html; }
public static function options_form( $options ) { $mfs = WOOF_File::to_bytes(ini_get('upload_max_filesize')); $mps = WOOF_File::to_bytes(ini_get('post_max_size')); $html = ""; $limit = self::get_filesize_limit(); $limit_mb = WOOF_File::format_filesize($limit, "MB", false); $defaults = array( "filename_case" => "lowercase", "filename_sanitize" => "dashes", "filename_dashes_underscores" => "dashes", "allowed_maxsize" => $limit_mb, "allowed_types" => array("jpg","jpeg","png","gif") ); $options = wp_parse_args( $options, $defaults ); $p = self::type_prefix(__CLASS__); $allowed_types_label = __("Allowed File Types:", MASTERPRESS_DOMAIN); $allowed_maxsize_label = __("Maximum Size:", MASTERPRESS_DOMAIN); $filename_label = __("File Name Handling", MASTERPRESS_DOMAIN); $filename_label_note = __("specify how file names should be sanitized on upload", MASTERPRESS_DOMAIN); $filename_sanitize_label = __("Sanitize file name:", MASTERPRESS_DOMAIN); $filename_sanitize_note = __("Sanitization removes special characters and replaces word boundaries with the specified character", MASTERPRESS_DOMAIN); $filename_case_label = __("Change case to:", MASTERPRESS_DOMAIN); $filename_case_select = WOOF_HTML::select( array("id" => $p."filename_case", "name" => "type_options[filename_case]"), array( "lower-case" => "lowercase", "Title-Case" => "titlecase", "UPPER-CASE" => "uppercase", "Preserve (No Change)" => "none" ), $options["filename_case"] ); $filename_sanitize_select = WOOF_HTML::select( array("id" => $p."filename_sanitize", "name" => "type_options[filename_sanitize]"), array( __("With Dashes ( - )", MASTERPRESS_DOMAIN) => "dashes", __("With Underscores ( _ )", MASTERPRESS_DOMAIN) => "underscores", __("None (Don't Sanitize)", MASTERPRESS_DOMAIN) => "none" ), $options["filename_sanitize"] ); $allowed_maxsize_note = __("( MB )", MASTERPRESS_DOMAIN); $allowed_maxsize_blank_note = sprintf(__("This value <strong>cannot exceed</strong> the maximum upload size<br />for your server, which is currently set to <strong>%s</strong>.", MASTERPRESS_DOMAIN), WOOF_File::format_filesize($limit, "MB", true, " ")); $allowed_label = __("File Restrictions", MASTERPRESS_DOMAIN); $allowed_label_note = __("restrict allowable files by type and file size", MASTERPRESS_DOMAIN); $allowed_types_note = __("The image field type is intended only for images that are displayable on a website.<br />For other image types, use the <em>file</em> field type instead", MASTERPRESS_DOMAIN); MPFT::incl("file"); foreach (array("jpg","jpeg","png","gif") as $ext) { $file_types_items[ MPFT_File::file_type_label($ext) ] = $ext; } $allowed_types_checkboxes = WOOF_HTML::input_checkbox_group( "type_options[allowed_types][]", $p."allowed-types-", $file_types_items, $options["allowed_types"], WOOF_HTML::open("div", "class=fwi"), WOOF_HTML::close("div")); // setup variables to insert into the heredoc string // (this is required where we cannot call functions within heredoc strings) $html .= <<<HTML <div class="filename-handling-wrap"> <h4><i class="highlighter"></i>{$filename_label}<span> - {$filename_label_note}</span></h4> <div class="f"> <label for="{$p}filename_sanitize">{$filename_sanitize_label}</label> <div id="fw-{$p}filename_sanitize" class="fw"> {$filename_sanitize_select} <p class="note">{$filename_sanitize_note}</p> </div> </div> <!-- /.f --> <div class="f"> <label for="{$p}filename_case">{$filename_case_label}</label> <div id="fw-{$p}filename_case" class="fw"> {$filename_case_select} </div> </div> <!-- /.f --> </div> <div class="allowed-wrap divider"> <h4><i class="warning-shield"></i>{$allowed_label}<span> - {$allowed_label_note}</span></h4> <div class="f"> <label for="{$p}allowed_maxsize">{$allowed_maxsize_label}</label> <div id="fw-{$p}allowed_maxsize" class="fw"> <input id="{$p}allowed_maxsize" name="type_options[allowed_maxsize]" type="text" maxlength="4" value="{$options['allowed_maxsize']}" class="text" /><span class="note">{$allowed_maxsize_note}</span> <p class="note">{$allowed_maxsize_blank_note}</p> </div> </div> <!-- /.f --> <div class="f f-allowed-types"> <p class="label">{$allowed_types_label}</p> <div class="fw"> {$allowed_types_checkboxes} <div 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> <p class="note">{$allowed_types_note}</p> </div> </div> <!-- /.f --> </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) $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 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; $select_none_label = __("Select None", MASTERPRESS_DOMAIN); $select_all_label = __("Select All", MASTERPRESS_DOMAIN); $disabled = WOOF_HTML::disabled_attr(!$field->is_editable()); $field_value = $field->value(); if (!is_array($field_value)) { $field_value = array(); } $selected_values = $field_value; $values = WOOF_HTML::option_values($options["values"]); self::$values_keys = array(); if (!$field->blank()) { // populate the values $selected_values = array(); foreach ($values as $key => $value) { if (in_array($value, $field_value)) { self::$values_keys[] = $key; // cache the keys for the summary, so we don't have to look them up again! $selected_values[] = $value; } } } $hidden = ""; $buttons = ""; $checkbox_name = "{{name}}[]"; $checkbox_id = "{{id}}"; if (!$field->is_editable()) { $hidden_name = $checkbox_name; $hidden_id = $checkbox_id; $checkbox_name = "display_".$checkbox_name; $checkbox_id = "display_".$checkbox_id; foreach ($selected_values as $value) { $hidden .= '<input id="'.$hidden_id.'" name="'.$hidden_name.'" value="'.$value.'" type="hidden" />'; } } else { $buttons = <<<HTML <div class="buttons"> <button type="button" class="button button-small check-all">{$select_all_label}</button> <button type="button" class="button button-small uncheck-all">{$select_none_label}</button> </div> HTML; } $checkboxes = WOOF_HTML::input_checkbox_group( "{{name}}[]", "{{id}}", $values, $selected_values, WOOF_HTML::open("div", "class=fwi"), WOOF_HTML::close("div"), !$field->is_editable()); $html = <<<HTML <div class="f"> <div class="fw"> {$checkboxes} {$hidden} </div> {$buttons} </div> HTML; return $html; }
public static function options_form( $options ) { global $wf; global $meow_provider; $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 roles that users must have to be available for selection in the field control", MASTERPRESS_DOMAIN); $user_roles_items = array(); $user_roles = $wf->roles(); $user_roles_selected = array(); foreach ($user_roles as $role) { $user_roles_selected[] = $role->id(); $user_roles_items[$role->name()] = $role->id(); } if (!MPC::is_create()) { $user_roles_selected = self::option_value($options, "user_roles"); } $user_roles_checkboxes = WOOF_HTML::input_checkbox_group( "type_options[user_roles][]", $p."user-roles-", $user_roles_items, $user_roles_selected, WOOF_HTML::open("div", "class=fwi"), WOOF_HTML::close("div")); $ex_label = __("Details", 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 ) ); $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 ); $grouping = MPFT::options_select_grouping( $p, $options, __("Role", 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)); $control_options_label = __("Control Options", MASTERPRESS_DOMAIN); $control_results_label = __("Results Display - <span>settings for the display of the available users</span>", MASTERPRESS_DOMAIN); $control_selections_label = __("Selection Display - <span>settings for the display of the selected users</span>", MASTERPRESS_DOMAIN); $placeholder = MPFT::options_placeholder($p, $options); // build a taxonomies grid $results_row_item_prop_label = __("Row Item Properties:", MASTERPRESS_DOMAIN); $results_row_item_prop_note = __("Defines the user properties used to derive the info shown in result rows.<br /><b>Note: </b>Details 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 user-role", WOOF_HTML::tag("i", "class=user-role", "") . WOOF_HTML::tag("span", null, __("User Role", 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 ($user_roles as $user_role) { $classes = array("user-role-".$user_role->id); if ($count == 1) { $classes[] = "first"; } $attr = array("class" => implode(" ", $classes)); if (!in_array($user_role->id, $user_roles_selected)) { $attr["style"] = "display: none;"; } $grid .= WOOF_HTML::open("tr", $attr); $count++; $span = WOOF_HTML::tag("span", array(), $user_role->name()); $grid .= WOOF_HTML::tag("td", "class=first user-role", $span); $grid .= WOOF_HTML::open("td", "class=title"); $default = "full_name"; $value = isset($options["result_row_prop"][$user_role->id]["title"]) ? $options["result_row_prop"][$user_role->id]["title"] : $default; if ($value == "") { $value = $default; } $input_attr = array( "type" => "text", "name" => "type_options[result_row_prop][".$user_role->id."][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-user-role-".$user_role->id, "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 = "role_name"; $value = isset($options["result_row_prop"][$user_role->id]["excerpt"]) ? $options["result_row_prop"][$user_role->id]["excerpt"] : $default; if ($value == "") { $value = $default; } $input_attr = array( "type" => "text", "name" => "type_options[result_row_prop][".$user_role->id."][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-user-role-".$user_role->id, "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 = "avatar"; $value = isset($options["result_row_prop"][$user_role->id]["image"]) ? $options["result_row_prop"][$user_role->id]["image"] : $default; if ($value == "") { $value = $default; } $input_attr = array( "type" => "text", "name" => "type_options[result_row_prop][".$user_role->id."][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-user-role-".$user_role->id, "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 ($user_roles as $user_role) { $dialogs .= WOOF_HTML::open( "div", array( "class" => "wp-dialog dialog dialog-fields", "id" => "dialog-user-role-".$user_role->id, "data-title" => __("Select a Field", MASTERPRESS_DOMAIN) ) ); $fs = $meow_provider->user_role_field_sets($user_role->id); $field_options = array(); $field_options[""] = ""; $field_options_attr = array(""); $field_options[__("( Built-in Fields )", MASTERPRESS_DOMAIN)] = array( "options" => array( __("Full Name", MASTERPRESS_DOMAIN) => "full_name", __("Role Name", MASTERPRESS_DOMAIN) => "role_name", __("Login", MASTERPRESS_DOMAIN) => "login", __("Email", MASTERPRESS_DOMAIN) => "email", __("Avatar", MASTERPRESS_DOMAIN) => "feature_image" ), "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", "class" => "text"), array("data-icon" => "mp-icon mp-icon-field-type-text-box", "class" => "text"), array("data-icon" => "mp-icon mp-icon-field-type-text-box", "class" => "text"), array("data-icon" => "mp-icon mp-icon-field-type-image", "class" => "image") ) ); 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-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 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 ) { $defaults = array(); if (MPC::is_create()) { $defaults = array( "buttons" => "select_all,select_none", "width" => 400, "height" => 160, "allow_multiple" => "yes" ); } $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) $maxwidth_label = __("Maximum Width:", MASTERPRESS_DOMAIN); $height_label = __("Height:", MASTERPRESS_DOMAIN); $height_note = __("(pixels)", MASTERPRESS_DOMAIN); $maxwidth_note = __("(pixels)", MASTERPRESS_DOMAIN); $maxwidth = self::option_value($options, "maxwidth"); $values = self::option_value($options, "values"); $default_value = self::option_value($options, "default_value"); $buttons = self::option_value($options, "buttons"); $height = self::option_value($options, "height"); $allow_multiple_label = __("Multiple Selections?:", MASTERPRESS_DOMAIN); $allow_multiple_checked_attr = WOOF_HTML::checked_attr( $options["allow_multiple"] == "yes" ); $values_label = __("Choices:", MASTERPRESS_DOMAIN); $values_note = __('Specify the labels for each choice on separate lines. To use a different underlying <span class="tt">value</span> for any of the choices,<br /> use the form <strong><span class="tt">label = value</span></strong>. To create a group of choices, prefix the line you wish to use as a group label with <span class="tt">--</span> (group labels are not selectable)', MASTERPRESS_DOMAIN); $default_value_label = __("Default State:", MASTERPRESS_DOMAIN); $default_value_note = __("Use the preview of your control above to setup the default state", MASTERPRESS_DOMAIN); $buttons_label = __("Selection Buttons:", MASTERPRESS_DOMAIN); $buttons_checkboxes = WOOF_HTML::input_checkbox_group( "type_options[buttons][]", $p."buttons-", array("Select All" => "select_all", "Select None" => "select_none"), $buttons, WOOF_HTML::open("div", "class=fwi"), WOOF_HTML::close("div")); $default_value_attr = array( "id" => $p."default-value", "name" => "type_options[default_value][]" ); if ($options["allow_multiple"] == "yes") { $default_value_attr["multiple"] = "multiple"; } else { $default_value_attr["size"] = 2; } $default_value_select = WOOF_HTML::select( $default_value_attr, WOOF_HTML::option_values($values, "", true), $default_value ); $html = <<<HTML <div class="f"> <label for="{$p}values">{$values_label}</label> <div id="fw-{$p}values" class="fw"> <textarea id="{$p}values" class="mono" name="type_options[values]">{$values}</textarea> <p class="note">{$values_note}</p> </div> </div> <!-- /.f --> <div class="f"> <label for="{$p}maxwidth">{$maxwidth_label}</label> <div id="fw-{$p}maxwidth" class="fw"> <input id="{$p}maxwidth" type="text" name="type_options[maxwidth]" maxlength="4" value="{$maxwidth}" class="text" /><span class="note">{$maxwidth_note}</span> </div> </div> <!-- /.f --> <div class="f"> <label for="{$p}height">{$height_label}</label> <div id="fw-{$p}height" class="fw"> <input id="{$p}height" type="text" name="type_options[height]" value="{$height}" class="text" /><span class="note">{$height_note}</span> </div> </div> <!-- /.f --> <div class="f"> <label for="{$p}allow-multiple">{$allow_multiple_label}</label> <div id="fw-{$p}allow-multiple" class="fw"> <input id="{$p}allow-multiple" name="type_options[allow_multiple]" type="checkbox" {$allow_multiple_checked_attr} value="yes" class="checkbox" /> </div> </div> <!-- /.f --> <div id="{$p}default-value-f" class="f"> <label for="{$p}default-value">{$default_value_label}</label> <div id="fw-{$p}default-value" class="fw"> <div class="preview"> {$default_value_select} <div id="{$p}default-value-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 --> </div> <p class="note">{$default_value_note}</p> </div> </div> <!-- /.f --> HTML; return $html; }