ID.'">'; if($custom_page->preview_image!='none'){ $html.= ''; } $html.='
'; foreach($custom_page->fields as $field){ $required=isset($field['required'])?'required':'notrequired'; $html.='
'; switch($field['id']){ case 'title': $html.=$post->post_title; break; case 'content': $html.=$post->post_content; break; default: $html.=get_post_meta($post->ID, $prefix.$field['id'], true); break; } $html.='
'; } $html.='
'; return $html; } /** * Returns the HTML that is before each item custom section. * @param $title the title of the item */ public function get_before_custom_section($title){ $html= '

'.$title.'

'; if($title!=PEXETO_DEFAULT_TERM){ $html.='
'; } $html.='
'; return $html; } /** * Returns the HTML that is after each item custom section. */ public function get_after_custom_section(){ return '
'; } /** * Builds the template for a custom page form with all the input fields needed. * @param $title the title of the form * @param $category the category that corresponds to the current instance (each instance represents a different category) * @param $custom_page a custom page object that represents the custom page * @param $prefix the prefix of the fields in the form */ public function get_custom_page_form_template($title, $category, $custom_page, $prefix){ $html='
'; foreach($custom_page->fields as $field){ $html.= ''; } $html.='
'.$field['name'].''; switch($field['type']){ case 'text': //print a standart text field $class=isset($field['required'])?'required':''; $html.= ''; break; case 'upload': $class=$field['required']?'required':''; $button_id='upload_button'.$category; $field_id=$field['id']; //print a field with an upload button $html.= ''; $html.= '
Upload

'; //TODO maybe export the uploader functionality to a common JS file break; case 'textarea': //print a textarea $class=isset($field['required'])?'required':''; $html.= ''; break; } $html.='
'; //display some hidden inputs with the main item data that may be used in AJAX requests later $html.=''; $html.=''; $html.=''; $html.='
'; //print the add button $html.= 'ADD'; $html.='
'; $html.='
'; return $html; } }