/** * Apply the filter. * * @param mixed input * @param mixed optional arguments * @return mixed */ public function filter($input, $options = null) { $output = ' <style> div.cctm_code { border: solid 1px blue; font-size: 1.3 em; color: blue; margin: 10px; padding:10px; background: #FFFFB3 } #cctm_help { border:1px solid black; background-color: lightyellow; width: 90%; margin: 10px; padding: 10px; } h2.cctm_h2 { font-size:25px; line-height:32px; margin-bottom: 10px; } h3.cctm_h3 { font-size:18px; line-height:25px; margin-top: 20px; } </style> <div id="cctm_help"> <h2 class="cctm_h2">' . __('Output Filter Help', CCTM_TXTDOMAIN) . '</h2> <p>' . __('This help page was generated by <a href="http://code.google.com/p/wordpress-custom-content-type-manager/wiki/OutputFilters">Custom Content Type Manager</a> to demonstrate the use of the available Output Filters. For samples of template files, see the CCTM menus in the WordPress manager.', CCTM_TXTDOMAIN) . '</p>'; $filters = CCTM::get_available_helper_classes('filters', true); // print_r($filters); exit; foreach ($filters as $filter => $file) { //if( CCTM::include_output_filter_class($filter) ) { if ($Obj = CCTM::load_object($filter, 'filters')) { /* $filter_name = CCTM::filter_prefix . $filter; $Obj = new $filter_name(); */ $output .= sprintf('<h3 class="cctm_h3">%s (%s)</h3> <p>%s -- [<a href="%s" target="_new">%s</a>]</p> <strong>%s</strong>:<br/> <div class="cctm_code"> %s </div> ', $Obj->get_name(), $filter, $Obj->get_description(), $Obj->get_url(), __('More info', CCTM_TXTDOMAIN), __('Example', CCTM_TXTDOMAIN), highlight_string($Obj->get_example('myfield', $filter), true)); } else { $output .= sprintf(__('File not found for %s output filter: %s', CCTM_TXTDOMAIN), '<strong>' . $filter . '</strong>', $file) . '<br/>'; } } return $output . '</div>'; }
* */ //print '<pre>'; print_r(CCTM::$data['cache']); print '</pre>'; $data = array(); $data['page_title'] = __('Add Field: Choose Type of Custom Field', CCTM_TXTDOMAIN); $data['help'] = 'http://code.google.com/p/wordpress-custom-content-type-manager/wiki/SupportedCustomFields'; $data['msg'] = self::get_flash(); $data['menu'] = sprintf('<a href="' . get_admin_url(false, 'admin.php') . '?page=cctm_fields&a=list_custom_fields" class="button">%s</a>', __('Back', CCTM_TXTDOMAIN)); $data['fields'] = ''; $data['content'] = ''; // You can optionally create the field for a given post_type if (!empty($post_type)) { $data['menu'] = sprintf('<a href="' . get_admin_url(false, 'admin.php') . '?page=cctm_fields&a=list_post_types" class="button">%s</a>', __('Back', CCTM_TXTDOMAIN)); $data['content'] .= '<p>' . sprintf(__('Create a custom field for the %s post_type', CCTM_TXTDOMAIN), "<em>{$post_type}</em>") . '</p>'; } $elements = CCTM::get_available_helper_classes('fields'); //print_r($elements); exit; // EHG foreach ($elements as $field_type => $file) { if ($FieldObj = CCTM::load_object($field_type, 'fields')) { $d = array(); $d['name'] = $FieldObj->get_name(); $d['icon'] = $FieldObj->get_icon(); $d['description'] = $FieldObj->get_description(); $d['url'] = $FieldObj->get_url(); $d['type'] = $field_type; $d['post_type'] = $post_type; $data['fields'] .= CCTM::load_view('tr_custom_field_type.php', $d); } else { $data['fields'] .= sprintf(__('Form element not found: %s', CCTM_TXTDOMAIN), "<code>{$field_type}</code>"); } }
function testCustomFields() { $classes = CCTM::get_available_helper_classes('fields'); $this->assertTrue(isset($classes['checkbox'])); $this->assertTrue(isset($classes['colorselector'])); $this->assertTrue(isset($classes['date'])); $this->assertTrue(isset($classes['dropdown'])); $this->assertTrue(isset($classes['image'])); $this->assertTrue(isset($classes['media'])); $this->assertTrue(isset($classes['multiselect'])); $this->assertTrue(isset($classes['relation'])); $this->assertTrue(isset($classes['text'])); $this->assertTrue(isset($classes['textarea'])); $this->assertTrue(isset($classes['user'])); $this->assertTrue(isset($classes['wysiwyg'])); // 3rd Party stuff $this->assertTrue(isset($classes['exercises'])); }
<?php /*------------------------------------------------------------------------------ This is run only when this plugin is uninstalled. All cleanup code goes here. WARNING: uninstalling a plugin fails when developing locally via MAMP et al. Perhaps related to how WP attempts (and fails) to connect to the local site. ------------------------------------------------------------------------------*/ if (defined('WP_UNINSTALL_PLUGIN')) { require_once 'includes/constants.php'; require_once 'includes/CCTM.php'; require_once 'includes/CCTM_FormElement.php'; // If the custom fields modified anything, we need to give them this // opportunity to clean it up. $available_custom_field_files = CCTM::get_available_helper_classes('fields'); foreach ($available_custom_field_files as $shortname => $file) { include_once $file; if (class_exists(CCTM::filter_prefix . $shortname)) { $field_type_name = CCTM::filter_prefix . $shortname; $FieldObj = new $field_type_name(); $FieldObj->uninstall(); } } delete_option(CCTM::db_key); delete_option('custom_content_types_mgr_data'); // legacy pre 0.9.4 delete_option('custom_content_types_mgr_settings'); // legacy pre 0.9.4 global $wp_rewrite; $wp_rewrite->flush_rules(); }
/** * Get the list of available validators. * * @param array current def * @return strin HTML */ public function format_validators($def, $show_validators = true) { $req_is_checked = ''; if (isset($def['required']) && $def['required'] == 1) { $req_is_checked = 'checked="checked"'; } // Is Required? // Get available Validators $select_options = ''; $validation_select = ''; // containing select element $validator_options = ''; // options for the active validator (if any) if ($show_validators) { $validators = CCTM::get_available_helper_classes('validators'); foreach ($validators as $shortname => $path) { $Vobj = CCTM::load_object($shortname, 'validators'); if (!$Vobj) { continue; // skip bogus validators } $is_selected = ''; if ($this->validator == $shortname) { $is_selected = ' selected="selected"'; $Vobj->set_options($this->validator_options); $validator_options = $Vobj->draw_options(); } $select_options .= sprintf('<option value="%s"%s>%s</option>', $shortname, $is_selected, $Vobj->get_name()); $validation_select = ' <div class="' . self::wrapper_css_class . '" id="validator_wrapper"> <label for="validator" class="cctm_label cctm_dropdown_label" id="validator_label">' . __('Validation Rule', CCTM_TXTDOMAIN) . '</label> <span class="cctm_description">' . __('A validation rule can ensure that any data entered into this field meets a specific criteria.', CCTM_TXTDOMAIN) . '</span> <br /> <select id="validator" name="validator" onchange="javascript:get_validator_options();"> <option value="">-- ' . __('None', CCTM_TXTDOMAIN) . '--</option> ' . $select_options . ' </select> </div>'; } } $out = ' <div class="postbox"> <div class="handlediv" title="Click to toggle"><br /></div> <h3 class="hndle"><span>' . __('Validation', CCTM_TXTDOMAIN) . '</span></h3> <div class="inside"> <table> <tr> <td style="vertical-align:top"> <div class="' . self::wrapper_css_class . '" id="required_wrapper"> <label for="required" class="cctm_label" id="required_label">' . __('Required?', CCTM_TXTDOMAIN) . '</label> <br /> <input type="checkbox" name="required" class="cctm_checkbox" id="required" value="1" ' . $req_is_checked . '/> <span class="cctm_checkbox_label">' . $this->descriptions['required'] . '</span> </div>' . $validation_select . ' </td> <td width="100"></td> <td style="vertical-align:top"> <div id="validator_options"> ' . $validator_options . ' </div> </td> </tr> </table> </div><!-- /inside --> </div><!-- /postbox --> '; return $out; }