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 $controls = ""; $options = $field->info->type_options; $allow_uncheck = self::option_value($options, "allow_uncheck"); $select_none_label = __("Select None", MASTERPRESS_DOMAIN); $value = $field->value(); $option_values = WOOF_HTML::option_values($options["values"]); $hidden = ""; $name = "{{name}}"; $id = "{{id}}"; $buttons = ""; if (!$field->is_editable()) { $hidden_name = $name; $hidden_id = $id; $name = "display_".$name; $id = "display_".$id; $hidden = '<input id="'.$hidden_id.'" name="'.$hidden_name.'" value="'.$value.'" type="hidden" />'; } else { if (isset($options["allow_uncheck"]) && $allow_uncheck == "yes") { $controls = <<<HTML <div class="buttons"> <button type="button" class="button button-small uncheck-all">{$select_none_label}</button> </div> HTML; } } $radio_buttons = WOOF_HTML::input_radio_group( $name, $id, $option_values, $value, WOOF_HTML::open("div", "class=fwi"), WOOF_HTML::close("div"), !$field->is_editable()); $html = <<<HTML <div class="f"> <div class="fw"> {$radio_buttons} {$hidden} </div> {$controls} </div> 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 function init() { global $wf; // check if we're in a child theme $template_dir = get_template_directory(); $stylesheet_dir = get_stylesheet_directory(); // check if there are any templates that have the same name, which can cause confusion $names = array(); $dupes = array(); self::get_names($template_dir, $names, $dupes); if ($stylesheet_dir != $template_dir) { self::get_names($stylesheet_dir, $names, $dupes); } if (count($dupes)) { $msg = WOOF_HTML::tag("p", array(), __("<strong>Warning:</strong> your theme appears to contain multiple template files with the same <b>Template Name</b>.<br />This may cause some templates to become invisible to both WordPress and MasterPress.<br />Please verify the following, and make changes to your template files as necessary:", MASTERPRESS_DOMAIN)); $msg .= WOOF_HTML::open("ul"); foreach ($dupes as $template_name => $file_name) { $msg .= WOOF_HTML::tag("li", array(), sprintf( __('<span class="tt">%s</span> is called <b>%s</b>, which is already used by <span class="tt">%s</span>', MASTEPRESS_DOMAIN), $file_name, $template_name, $names[$template_name]) ); } $msg .= WOOF_HTML::close("ul"); MPV::warn($msg); } $action = MasterPress::$action; // inform the view what to render in the info panel MasterPress::$view->is_template_set = true; if ($action == "edit-field" || $action == "create-field") { // inform the view what to render in the info panel MasterPress::$view->parent = MPM_FieldSet::find_by_id(MasterPress::$parent); // enqueue the field type CSS $type = MasterPress::$model->type; MPFT::options_admin_head($type); // enqueue dependent scripts for all field types (could improve this in the future) foreach (MPFT::type_keys() as $type) { if ($ftc = MPFT::type_class($type)) { call_user_func( array($ftc, "enqueue") ); } } } if ($action == "create-field") { MasterPress::$model->field_set_id = MasterPress::$parent; MasterPress::$model->infer_position(); } }
public static function options_form( $options ) { $defaults = array(); if (MPC::is_create()) { $defaults = array("default_tab" => "visual", "height" => 250, "html_editor" => "cm", "cm_theme" => "sunburst"); } $options = wp_parse_args( $options, $defaults ); $p = self::type_prefix(__CLASS__); $height = self::option_value($options, "height"); $mce_blockformats = self::option_value($options, "mce_blockformats"); $mce_styles = self::option_value($options, "mce_styles"); $default_tab = self::option_value($options, "default_tab"); $cm_theme = self::option_value($options, "cm_theme"); $height_label = __("Editor Height:", MASTERPRESS_DOMAIN); $height_note = __("(pixels)", MASTERPRESS_DOMAIN); $html_editor_label = __("HTML Editor:", MASTERPRESS_DOMAIN); $html_editor_note = __('<a href="http://codemirror.net" target="_blank">CodeMirror 2</a> is a wonderful JavaScript text editor that support live syntax-coloring, among other features.', MASTERPRESS_DOMAIN); $html_editor_select = WOOF_HTML::select( array("id" => $p."html-editor", "name" => "type_options[html_editor]"), array( "CodeMirror 2" => "cm", "Standard Textarea" => "textarea" ), self::option_value($options, "html_editor") ); $cm_theme_label = __("CodeMirror Theme:", MASTERPRESS_DOMAIN); $cm_theme_select = WOOF_HTML::select( array("id" => $p."cm-theme", "name" => "type_options[cm_theme]"), array( "Default" => "default", "Cobalt" => "cobalt", "Elegant" => "elegant", "Neat" => "neat", "Night" => "night", "Sunburst" => "sunburst" ), $cm_theme ); $mce_blockformats_label = __("Block Formats:", MASTERPRESS_DOMAIN); $mce_blockformats_note = __('Specify the block-level tags which appear in the <em>Format</em> dropdown list in TinyMCE.<br />Leave this value empty to use the same formats as the WordPress content editor. <a target="_blank" href="http://www.tinymce.com/wiki.php/Configuration:theme_advanced_blockformats">More Info</a>', MASTERPRESS_DOMAIN); $mce_styles_label = __("Styles:", MASTERPRESS_DOMAIN); $mce_styles_note = __('Specify the style names and the underlying CSS classes for these styles, in the form <span class="tt">label = css_class</span> separated by semi-colons (;). Leave this value empty to use the same formats as the WordPress content editor. <a target="_blank" href="http://www.tinymce.com/wiki.php/Configuration:theme_advanced_styles">More Info</a>', MASTERPRESS_DOMAIN); // setup variables to insert into the heredoc string // (this is required where we cannot call functions within heredoc strings) $default_tab_label = __("Default Tab:", MASTERPRESS_DOMAIN); $default_tab_select = WOOF_HTML::input_radio_group( "type_options[default_tab]", $p."default-tab-", array( __("Visual <span>( TinyMCE )</span>", MASTERPRESS_DOMAIN) => "visual", __("HTML", MASTERPRESS_DOMAIN) => "html" ), $default_tab, WOOF_HTML::open("div", "class=fwi"), WOOF_HTML::close("div") ); $html = <<<HTML <div class="f"> <label for="{$p}default_tab">{$default_tab_label}</label> <div id="fw-{$p}default_tab" class="fw"> {$default_tab_select} </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> <div class="f"> <label for="{$p}html_editor">{$html_editor_label}</label> <div id="fw-{$p}html_editor" class="fw"> {$html_editor_select} <p class="note">{$html_editor_note}</p> </div> </div> <!-- /.f --> <div id="{$p}cm-theme-f" class="f"> <label for="{$p}cm_theme">{$cm_theme_label}</label> <div id="fw-{$p}cm_theme" class="fw"> {$cm_theme_select} </div> </div> <!-- /.f --> <div class="f"> <label for="{$p}mce_blockformats">{$mce_blockformats_label}</label> <div id="fw-{$p}mce_blockformats" class="fw"> <input id="{$p}mce_blockformats" type="text" name="type_options[mce_blockformats]" value="{$mce_blockformats}" class="text" /> <p class="note">{$mce_blockformats_note}</p> </div> </div> <!-- /.f --> <div class="f"> <label for="{$p}mce_styles">{$mce_styles_label}</label> <div id="fw-{$p}mce_styles" class="fw"> <textarea id="{$p}mce_styles" name="type_options[mce_styles]" class="mono">{$mce_styles}</textarea> <p class="note">{$mce_styles_note}</p> </div> </div> <!-- /.f --> HTML; return $html; }
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 function manage() { global $wf, $blog_id; $this->setup_view( array( "title_args" => array( "text" => sprintf( __("Masterplan - <small>Powered by %s</small>", MASTERPRESS_DOMAIN), '<a href="http://masterpressplugin.com" target="_blank">MasterPress</a>' ) ) ) ); if (defined("MASTERPRESS_LEGACY_DIR_MIGRATE")) { if (defined("MASTERPRESS_LEGACY_DIR") && MasterPress::$action != "legacy_dir_migrate") { update_option("mp_legacy_dir", "1"); $ud = wp_upload_dir(); $steps = WOOF_HTML::open("ul"); $new_ul_base = str_replace($wf->site->url, "", $ud["baseurl"]) . "/mp/files/$1"; $rules = <<<HTML <IfModule mod_rewrite.c><br> RewriteEngine On<br> RewriteBase /<br> <br> RewriteCond %{REQUEST_FILENAME} !-f<br> RewriteRule ^wp-content/mp/uploads/(.+) $new_ul_base [PT]<br> <br> RewriteCond %{REQUEST_FILENAME} !-f<br> RewriteRule ^wp-content/blogs.dir/([0-9]+)/mp/uploads/(.+) wp-content/blogs.dir/$1/mp/files/$2 [PT]<br> <br> RewriteCond %{REQUEST_FILENAME} !-f<br> RewriteRule ^wp-content/mp/(.+) wp-content/uploads/mp/$1 [PT,L]<br> </IfModule> HTML; $step = 1; $steps .= WOOF_HTML::tag("li", "", __("<b>".$step++.".</b> Backup your WordPress database."), MASTERPRESS_DOMAIN ); $steps .= WOOF_HTML::tag("li", "", sprintf( __("<b>(Optional)</b>. To avoid 404s from existing links to your files, you may wish to place the following lines just above in your .htaccess file (at the root of your site).<code>%s</code><br><b>IMPORTANT:</b> These rules should be <b>placed just above the line # BEGIN WordPress </b> in your .htaccess file, as placing it above rules from caching plugins may cause issues.", MASTERPRESS_DOMAIN ), $rules ) ); if (MASTERPRESS_MULTI) { if (WOOF_MS_FILES) { if (is_main_site()) { $steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Move the masterpress content folder currently at:<br> <span class="tt">%s/mp</span><br>to:<br> <span class="tt">%s/mp</span>', MASTERPRESS_DOMAIN ), $step++, WP_CONTENT_DIR, $ud["basedir"] ) ); $steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Rename the folder:<br> <span class="tt">%s/mp/uploads</span><br>to:<br> <span class="tt">%s/mp/files</span>', MASTERPRESS_DOMAIN ), $step++, WP_CONTENT_DIR, WP_CONTENT_DIR ) ); } $base = WP_CONTENT_DIR . WOOF_DIR_SEP . "blogs.dir" . WOOF_DIR_SEP . $blog_id; $steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d</b> Rename the folder:<br> <span class="tt">%s/mp/uploads</span><br>to:<br> <span class="tt">%s/mp/files</span>', MASTERPRESS_DOMAIN ), $step++, $base , $base ) ); $steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d</b> Click the migrate links button below to update your custom field database entries to point to the new location:<br>%s', MASTERPRESS_DOMAIN ), $step++, WOOF_HTML::tag("a", array("href" => MasterPress::admin_url( "masterplan", "legacy_dir_migrate", "", false ), "class" => "button button-small" ), "Migrate Links" ) ) ); } else { if (is_main_site()) { $steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Move the masterpress content folder currently at:<br> <span class="tt">%s/mp</span><br>to:<br> <span class="tt">%s/mp</span>', MASTERPRESS_DOMAIN ), $step++, WP_CONTENT_DIR, $ud["basedir"] ) ); $steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Rename the folder:<br> <span class="tt">%s/mp/uploads</span><br>to:<br> <span class="tt">%s/mp/files</span>', MASTERPRESS_DOMAIN ), $step++, $ud["basedir"], $ud["basedir"] ) ); $steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Click the migrate links button below to update your custom field database entries to point to the new location:<br>%s', MASTERPRESS_DOMAIN ), $step++, WOOF_HTML::tag("a", array("href" => MasterPress::admin_url( "masterplan", "legacy_dir_migrate", "", false ), "class" => "button button-small" ), "Migrate Links" ) ) ); } else { $steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Rename the folder:<br> <span class="tt">%s/mp/uploads</span><br>to:<br> <span class="tt">%s/mp/files</span>', MASTERPRESS_DOMAIN ), $step++, $ud["basedir"], $ud["basedir"] ) ); $steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Click the migrate links button below to update your custom field database entries to point to the new location:<br>%s', MASTERPRESS_DOMAIN ), $step++, WOOF_HTML::tag("a", array("href" => MasterPress::admin_url( "masterplan", "legacy_dir_migrate", "", false ), "class" => "button button-small" ), "Migrate Links" ) ) ); } } } else { $steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Move the masterpress content folder currently at:<br> <span class="tt">%s/mp</span><br>to:<br> <span class="tt">%s/mp</span>', MASTERPRESS_DOMAIN ), $step++, WP_CONTENT_DIR, $ud["basedir"] ) ); $steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Rename the folder:<br> <span class="tt">%s/mp/uploads</span><br>to:<br> <span class="tt">%s/mp/files</span>', MASTERPRESS_DOMAIN ), $step++, $ud["basedir"], $ud["basedir"] ) ); $steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Click the migrate links button below to update your custom field database entries to point to the new location:<br>%s', MASTERPRESS_DOMAIN ), $step++, WOOF_HTML::tag("a", array("href" => MasterPress::admin_url( "masterplan", "legacy_dir_migrate", "", false ), "class" => "button button-small" ), "Migrate Links" ) ) ); } $steps .= WOOF_HTML::close("ul"); MPV::warn( sprintf( __('Your MasterPress installation is storing certain content in folders which are <a href="%s">no longer the default locations in version 1.0.1.</a><br><br>To migrate to the new location: %s', MASTERPRESS_DOMAIN ), "http://masterpressplugin.com/blog/content-in-101/", $steps ) ); } else if (get_option("mp_legacy_dir")) { $migrate = sprintf( __('Click the migrate links button below to update your custom field database entries to point to the new location:<br>%s', MASTERPRESS_DOMAIN ), WOOF_HTML::tag("a", array("href" => MasterPress::admin_url( "masterplan", "legacy_dir_migrate", "", false ), "class" => "button button-small" ), "Migrate Links" ) ); MPV::warn( sprintf( __('It appears you\'ve moved your MasterPress content folder from the old <span class="tt">wp-content/mp</span> location without running the necessary database migration.<br><br>%s', MASTERPRESS_DOMAIN ), $migrate ) ); } } if (isset($_POST["import_masterplan"]) || isset($_POST["restore_masterplan"])) { self::import(); } }
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 function dump_item($key, $value) { $html = ''; $html .= WOOF_HTML::open("tr"); $html .= WOOF_HTML::tag("th", array("scope" => "row"), $key); if (is_array($value)) { $html .= WOOF_HTML::open("td"); $html .= WOOF_HTML::open("table"); foreach ($value as $sub_key => $sub_value) { $html .= $this->dump_item($sub_key, $sub_value); } $html .= WOOF_HTML::close("table"); $html .= WOOF_HTML::close("td"); } else { $html .= WOOF_HTML::tag("td", array(), $value); } $html .= WOOF_HTML::close("tr"); 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 create_directories() { MPU::incl("view/mpv.php"); global $wf; global $blog_id; $main_exists = true; $global_exists = true; $try_content = true; self::$is_masterplan = ( isset($_GET["page"] ) && $_GET["page"] == "masterpress" ); if (!file_exists(MASTERPRESS_CONTENT_DIR)) { if ($try_content) { // if the base uploads directory doesn't exist, try to create it if (!wp_mkdir_p(MASTERPRESS_CONTENT_DIR)) { $main_exists = FALSE; // check that the base blogs.dir actually exists! $bd_base_dir = WP_CONTENT_DIR.WOOF_DIR_SEP."blogs.dir"; if (is_multisite()) { MPV::warn(sprintf(__('<strong>Note: the MasterPress content folder %s for this site does not yet exist and cannot be automatically created</strong>, which will cause problems when using MasterPress.<br /><br />Using your FTP client, server admin panel, or operating system (for local installations), please give the %s folder permission <strong>777</strong> so that MasterPress can create the necessary folders.<br /><br />Alternatively, use the following command if you have shell or terminal access: %s<br /><a href=%s>Click here</a> once this is complete, to verify this problem has been solved.', MASTERPRESS_DOMAIN), '<span class="tt">'.MASTERPRESS_CONTENT_DIR.'</span>', '<span class="tt">wp-content/blogs.dir/'.$blog_id.'/</span>', self::dir_cmd(WP_CONTENT_DIR.WOOF_DIR_SEP."blogs.dir".WOOF_DIR_SEP.$blog_id.WOOF_DIR_SEP), '"'.MPU::current_url().'"')); } else { MPV::warn(sprintf(__('<strong>Note: the MasterPress content folder %s does not yet exist and cannot be automatically created</strong>, which will cause problems when using MasterPress.<br /><br />Using your FTP client, server admin panel, or operating system (for local installations), please give the %s folder the permission <strong>777</strong> so that MasterPress can create the necessary folders.<br /><br />Alternatively, use the following command if you have shell or terminal access: %s<br /><a href=%s>Click here</a> once this is complete, to verify this problem has been solved.', MASTERPRESS_DOMAIN), '<span class="tt">'.MASTERPRESS_CONTENT_DIR.'</span>', '<span class="tt">wp-content</span>', self::dir_cmd(WP_CONTENT_DIR), '"'.MPU::current_url().'"')); } update_site_option("mp_dir_problem", true); } else { chmod(MASTERPRESS_CONTENT_DIR, 0755); } } } if (!file_exists(MASTERPRESS_GLOBAL_CONTENT_DIR)) { // if the global content directory doesn't exist, try to create it if (MASTERPRESS_GLOBAL_CONTENT_DIR != MASTERPRESS_CONTENT_DIR) { if (!wp_mkdir_p(MASTERPRESS_GLOBAL_CONTENT_DIR)) { $global_exists = FALSE; MPV::warn(sprintf(__('<strong>Note: the MasterPress shared content folder %s for your multi-site network does not yet exist and cannot be automatically created</strong>, which will cause problems when using MasterPress.<br /><br />Using your FTP client, server admin panel, or operating system (for local installations), please give the %s folder the permission <strong>777</strong> so that MasterPress can create the necessary folders.<br /><br />Alternatively, use the following command if you have shell or terminal access: %s<br /><a href=%s>Click here</a> once this is complete, to verify this problem has been solved', MASTERPRESS_DOMAIN), '<span class="tt">'.MASTERPRESS_GLOBAL_CONTENT_DIR.'</span>', '<span class="tt">wp-content</span>', self::dir_cmd(WP_CONTENT_DIR), '"'.MPU::current_url().'"')); update_site_option("mp_dir_problem", true); } else { chmod(MASTERPRESS_GLOBAL_CONTENT_DIR, 0755); } } } $warning_777 = __('Please change the permissions of your <span class="tt">wp-content</span> directory to <span class="tt">755</span>. <br />'); $stop_trying_global = false; $stop_trying = false; if ($main_exists && $global_exists) { $stop_trying = false; $stop_trying_global = false; // test if the standard sub-directories exist $not_writable_warning = sprintf(__('<strong>Note: the MasterPress folder %s does not seem to be writable</strong>, which will cause problems when using MasterPress.<br /><br />Using your FTP client, server admin panel, or operating system (for local installations), please give this folder the permission 777.<br /><br />Alternatively, use the following command if you have shell or terminal access: %s<br /><a href=%s>Click here</a> once this is complete, to verify this problem has been solved', MASTERPRESS_DOMAIN), '<span class="tt">'.MASTERPRESS_CONTENT_DIR.'.</span>', self::chmod_cmd(MASTERPRESS_CONTENT_DIR), '"'.MPU::current_url().'"'); if (is_multisite()) { $not_writable_global_warning = sprintf(__('<strong>Note: the MasterPress shared folder %s for your multi-site network does not seem to be writable</strong>, which will cause problems when using MasterPress.<br /><br />Using your FTP client, server admin panel, or operating system (for local installations), please give this folder the permission 777.<br /><br />Alternatively, use the following command if you have shell or terminal access: %s<br /><a href=%s>Click here</a> once this is complete, to verify this problem has been solved', MASTERPRESS_DOMAIN), '<span class="tt">'.MASTERPRESS_GLOBAL_CONTENT_DIR.'</span>', self::chmod_cmd(MASTERPRESS_GLOBAL_CONTENT_DIR), '"'.MPU::current_url().'"'); } else { $not_writable_global_warning = $not_writable_warning; } if (!$stop_trying) { if (!file_exists(MASTERPRESS_CONTENT_IMAGE_CACHE_DIR)) { if (!wp_mkdir_p(MASTERPRESS_CONTENT_IMAGE_CACHE_DIR)) { $stop_trying = TRUE; MPV::warn($not_writable_warning); } } } if (!$stop_trying) { if (!file_exists(MASTERPRESS_CONTENT_IMAGE_FROM_URL_DIR)) { if (!wp_mkdir_p(MASTERPRESS_CONTENT_IMAGE_FROM_URL_DIR)) { $stop_trying = TRUE; MPV::warn($not_writable_warning); } } } if (!$stop_trying) { if (!file_exists(MASTERPRESS_CONTENT_FILE_FROM_URL_DIR)) { if (!wp_mkdir_p(MASTERPRESS_CONTENT_FILE_FROM_URL_DIR)) { $stop_trying = TRUE; MPV::warn($not_writable_warning); } } } if (!$stop_trying) { if (!file_exists(MASTERPRESS_CONTENT_UPLOADS_DIR)) { if (!wp_mkdir_p(MASTERPRESS_CONTENT_UPLOADS_DIR)) { $stop_trying = TRUE; MPV::warn($not_writable_warning); } } } if (!is_multisite() && $stop_trying) { // global and site are the same path $stop_trying_global = true; } if (!$stop_trying_global) { if (!file_exists(MASTERPRESS_CONTENT_MENU_ICONS_DIR)) { if (!wp_mkdir_p(MASTERPRESS_CONTENT_MENU_ICONS_DIR)) { $stop_trying_global = true; MPV::warn($not_writable_global_warning); } } } if (!$stop_trying_global) { if (!file_exists(MASTERPRESS_CONTENT_MASTERPLANS_DIR)) { if (!wp_mkdir_p(MASTERPRESS_CONTENT_MASTERPLANS_DIR)) { $stop_trying_global = TRUE; MPV::warn($not_writable_global_warning); } } } if (!$stop_trying_global) { if (!file_exists(MASTERPRESS_CONTENT_MPFT_CACHE_DIR)) { if (!wp_mkdir_p(MASTERPRESS_CONTENT_MPFT_CACHE_DIR)) { $stop_trying_global = TRUE; MPV::warn($not_writable_global_warning); } } } if (!$stop_trying_global) { if (!file_exists(MASTERPRESS_TMP_DIR)) { if (!wp_mkdir_p(MASTERPRESS_TMP_DIR)) { $stop_trying_global = TRUE; MPV::warn($not_writable_warning); } } } if (!$stop_trying_global) { if (!file_exists(MASTERPRESS_EXTENSIONS_DIR)) { if (!wp_mkdir_p(MASTERPRESS_EXTENSIONS_DIR)) { $stop_trying_global = TRUE; MPV::warn($not_writable_global_warning); } } } if (!$stop_trying_global) { if (!file_exists(MASTERPRESS_EXTENSIONS_FIELD_TYPES_DIR)) { if (!wp_mkdir_p(MASTERPRESS_EXTENSIONS_FIELD_TYPES_DIR)) { $stop_trying_global = TRUE; MPV::warn($not_writable_extensions_warning); } } } if (!$stop_trying_global) { if (!file_exists(MASTERPRESS_EXTENSIONS_ICONS_DIR)) { if (!wp_mkdir_p(MASTERPRESS_EXTENSIONS_ICONS_DIR)) { $stop_trying_global = TRUE; MPV::warn($not_writable_extensions_warning); } } } if (!$stop_trying) { // check the writable status of MasterPress directories $not_writables = self::check_writable( array( MASTERPRESS_CONTENT_MENU_ICONS_DIR, MASTERPRESS_CONTENT_IMAGE_CACHE_DIR, MASTERPRESS_CONTENT_IMAGE_FROM_URL_DIR, MASTERPRESS_CONTENT_FILE_FROM_URL_DIR, MASTERPRESS_CONTENT_MPFT_CACHE_DIR, MASTERPRESS_TMP_DIR, MASTERPRESS_CONTENT_MASTERPLANS_DIR, MASTERPRESS_EXTENSIONS_DIR, MASTERPRESS_EXTENSIONS_FIELD_TYPES_DIR, MASTERPRESS_EXTENSIONS_ICONS_DIR, MASTERPRESS_CONTENT_UPLOADS_DIR )); if (count($not_writables)) { $content_paths = WOOF_HTML::open("p"); $chmods = WOOF_HTML::open("code"); foreach ($not_writables as $nw) { $content_paths .= WOOF_HTML::tag("span", "class=tt", $nw["content_path"]."<br />"); $chmods .= $nw["chmod"]; } $content_paths .= WOOF_HTML::close("p"); $chmods .= WOOF_HTML::close("code"); MPV::warn(sprintf(__('<p><strong>Note:</strong> these MasterPress folders in <span class="tt">wp-content</span> are not writable which will cause problems using WordPress:%s<br /></p><p>Using your FTP client, server admin panel, or operating system (for local installations), please give these folders permission 777.<br /><br />Alternatively, use the following commands if you have shell or terminal access:<br />%s', MASTERPRESS_DOMAIN), $content_paths, $chmods)); } } } }
function pagination($args = array()) { /* Based on code from Sparklette studios http://design.sparklette.net/teaches/how-to-add-wordpress-pagination-without-a-plugin/# */ $html = ""; global $wp_query; $r = wp_parse_args( $args, array( "pages" => '', "page_var" => "paged", "range" => 5, "link_callback" => "get_pagenum_link", "class_page" => "page", "class_current" => "current", "class_inactive" => "inactive", "class_wrap" => "pagination", "tag_wrap" => "nav", "tag_wrap_pages" => "div", "class_pages" => "pages", "show_page_count" => true, "tag_page_count" => "span", "class_page_count" => "page-count", "t_page_count" => __("Page %d of %d", WOOF_DOMAIN), "show_first" => true, "class_first" => "first", "title_first" => __("First Page", WOOF_DOMAIN), "t_first" => __("« First", WOOF_DOMAIN), "show_previous" => true, "class_previous" => "previous", "title_previous" => __("Previous Page", WOOF_DOMAIN), "t_previous" => __("‹ Previous", WOOF_DOMAIN), "show_next" => true, "class_next" => "next", "title_next" => __("Next Page", WOOF_DOMAIN), "t_next" => __("Next ›", WOOF_DOMAIN), "show_last" => true, "class_last" => "last", "title_last" => __("Last Page", WOOF_DOMAIN), "t_last" => __("Last »", WOOF_DOMAIN) ) ); extract($r); $showitems = ($range * 2) + 1; $paged = get_query_var($r["page_var"]); if (!$paged) $paged = 1; if ($pages == '') { $pages = $wp_query->max_num_pages; if (!$pages) { $pages = 1; } } if (1 != $pages) { if ($show_page_count) { $html .= WOOF_HTML::tag($tag_page_count, array("class" => $class_page_count), sprintf($t_page_count, $paged, $pages)); } $limit = !($paged > 2 && $paged > $range + 1 && $showitems < $pages); if ($show_first && ($show_first == "always" || !$limit)) { if ($paged == 1) { $html .= WOOF_HTML::tag("span", array("class" => $class_first), $t_first); } else { $href = call_user_func( $r["link_callback"], 1 ); $html .= WOOF_HTML::tag("a", array("href" => $href, "title" => $title_first, "class" => $class_first), $t_first); } } $limit = !($paged > 1 && $showitems < $pages); if ($show_previous && ($show_previous == "always" || !$limit)) { if ($paged == 1) { $html .= WOOF_HTML::tag("span", array("class" => $class_previous), $t_previous); } else { $href = call_user_func( $r["link_callback"], $paged - 1 ); $html .= WOOF_HTML::tag("a", array("href" => $href, "title" => $title_previous, "class" => $class_previous), $t_previous); } } $html .= WOOF_HTML::open($tag_wrap_pages, array("class" => $class_pages)); $pc = 0; for ($i=1; $i <= $pages; $i++) { if (1 != $pages && ( !($i >= $paged + $range + 1 || $i <= $paged - $range - 1) || $pages <= $showitems )) { $pc++; $class = array($class_page); if ($paged == $i) { $class[] = $class_current; $html .= WOOF_HTML::tag("span", array("class" => implode(" ", $class)), $i); } else { $class[] = $class_inactive; $href = call_user_func( $r["link_callback"], $i ); $html .= WOOF_HTML::tag("a", array("href" => $href, "class" => implode(" ", $class)), $i); } } } $html = WOOF_HTML::open($tag_wrap, array("class" => $class_wrap." with-$pc-pages $class_wrap-with-$pc-pages")).$html; $html .= WOOF_HTML::close($tag_wrap_pages); $limit = !( $paged < $pages && $showitems < $pages ); if ($show_next && ($show_next == "always" || !$limit)) { if ($pages == $paged) { $html .= WOOF_HTML::tag("span", array("class" => $class_next), $t_next); } else { $href = call_user_func( $r["link_callback"], $paged + 1 ); $html .= WOOF_HTML::tag("a", array("href" => $href, "title" => $title_next, "class" => $class_next), $t_next); } } $limit = !($pages - 1 && $paged + $range - 1 < $pages && $showitems < $pages); if ($show_last && ($show_last == "always" || !$limit)) { if ($pages == $paged) { $html .= WOOF_HTML::tag("span", array("class" => $class_last), $t_last); } else { $href = call_user_func( $r["link_callback"], $pages ); $html .= WOOF_HTML::tag("a", array("href" => $href, "title" => $title_last, "class" => $class_last), $t_last); } } $html .= WOOF_HTML::close($tag_wrap); } 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; $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; }
public static function options_form( $options ) { $defaults = array(); if (MPC::is_create()) { $defaults = array("mode" => "single"); } $options = wp_parse_args( $options, $defaults ); $mode = self::option_value($options, "mode"); if ($mode == "") { $mode = "single"; } $p = self::type_prefix(__CLASS__); // setup variables to insert into the heredoc string // (this is required where we cannot call functions within heredoc strings) $mode_label = __("Selection Mode:", MASTERPRESS_DOMAIN); $mode_select = WOOF_HTML::input_radio_group( "type_options[mode]", $p."mode-", array(__("Single Date", MASTERPRESS_DOMAIN) => "single", __("Start / End Date", MASTERPRESS_DOMAIN) => "start_end" ), self::option_value($options, "mode"), WOOF_HTML::open("div", "class=fwi"), WOOF_HTML::close("div") ); $mindate_label = __("Minimum Date:", MASTERPRESS_DOMAIN); $maxdate_label = __("Maximum Date:", MASTERPRESS_DOMAIN); $default_value_label = __("Default Date:", MASTERPRESS_DOMAIN); $time_select_label = __("Allow Time Selection?", MASTERPRESS_DOMAIN); $time_select_checked_attr = WOOF_HTML::checked_attr(self::option_value($options, "timeselect") == "yes"); $date_format_note = __("Note: for minumum, maximum, and default dates, you may also enter a number of days from today (e.g. +7) or a string of values and periods ('y' for years, 'm' for months, 'w' for weeks, 'd' for days, e.g. '-1y -1m').", MASTERPRESS_DOMAIN); $button_text = esc_js(__("choose…", MASTERPRESS_DOMAIN)); $font_select = WOOF_HTML::select( array("id" => $p."font", "name" => "type_options[font]"), array( "Sans-Serif - Helvetica, Arial, sans-serif" => "helvetica, arial, sans-serif", "Serif - Georgia, Times New Roman, serif" => "georgia, 'times new roman', serif", "Fixed Width - Consolas, Menlo, Andale Mono, Lucida Console, monospace" => "consolas, menlo, 'andale mono', 'lucida console', monospace" ), self::option_value($options, "font") ); $mindate = esc_attr(self::option_value($options, "mindate")); $maxdate = esc_attr(self::option_value($options, "maxdate")); $default_value = esc_attr(self::option_value($options, "default_value")); $html = <<<HTML <!-- TODO - re-enable dual date support (not important right now) <div class="f"> <label for="{$p}mode_select">{$mode_label}</label> <div id="fw-{$p}mode_select" class="fw"> {$mode_select} </div> </div> --> <!-- /.f --> <div class="f"> <label for="{$p}timeselect">{$time_select_label}</label> <div id="fw-{$p}timeselect" class="fw"> <input id="{$p}timeselect" type="checkbox" name="type_options[timeselect]" {$time_select_checked_attr} value="yes" class="checkbox" /> </div> </div> <!-- /.f --> <div class="f"> <label for="{$p}mindate">{$mindate_label}</label> <div id="fw-{$p}mindate" class="fw"> <input id="{$p}mindate" name="type_options[mindate]" type="text" maxlength="4" value="{$mindate}" class="text date { buttonText: '{$button_text}' }" /> </div> </div> <!-- /.f --> <div class="f"> <label for="{$p}maxdate">{$maxdate_label}</label> <div id="fw-{$p}maxdate" class="fw"> <input id="{$p}maxdate" name="type_options[maxdate]" type="text" maxlength="4" value="{$maxdate}" class="text date { buttonText: '{$button_text}' }" /> </div> </div> <!-- /.f --> <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" defaultlength="4" value="{$default_value}" class="text date { buttonText: '{$button_text}' }" /> </div> </div> <!-- /.f --> <p class="note format-note"> {$date_format_note} </p> 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; $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; }
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; }