function xydac_cpt() { global $xydac_fieldtypes; if ((isset($_GET['manage_cpt_fields_submit']) || isset($_POST['add_cpt_field_submit']) || isset($_GET['cpt_field']) || isset($_POST['cpt_doaction_submit'])) && (isset($_GET['manage_cpt_fields_select']) || isset($_POST['cpt_name']))) { $not_inserted = false; if (isset($_GET['manage_cpt_fields_select'])) { $t_name = $_GET['manage_cpt_fields_select']; } elseif (isset($_POST['cpt_name'])) { $t_name = $_POST['cpt_name']; } $p_tname = ""; $p_fname = ""; $p_flabel = ""; $p_ftype = ""; $p_fdesc = ""; //deletion if (isset($_POST['cpt_doaction_submit'])) { if (isset($_POST['action']) && $_POST['action'] == 'delete') { if (isset($_POST['delete_content_type'])) { foreach ($_POST['delete_content_type'] as $k => $v) { deleteCptField($v, $_POST['cpt_name']); $cpt_message = __('Item Deleted.', 'xydac_cpt'); } } } } if (isset($_GET['field']) || isset($_POST['field_name'])) { if (isset($_GET['field'])) { $frow = getCptFieldrow($_GET['field'], $t_name); } else { $frow = getCptFieldrow($_POST['field_name'], $t_name); } if ($frow) { $t_name = $frow['cpt_name']; $p_tname = $frow['cpt_name']; $p_fname = $frow['field_name']; $p_flabel = $frow['field_label']; $p_ftype = $frow['field_type']; $p_fdesc = $frow['field_desc']; $p_fval = $frow['field_val']; $p_forder = $frow['field_order']; $not_inserted = true; } } if (isset($_POST['edit_cpt_field_submit'])) { if (isset($_POST["field_name"]) && empty($_POST["field_name"])) { $xydac_cpt_error = new WP_Error('err', __("You need to give field name", 'xydac_cpt')); } elseif (isset($_POST['field_name']) && $_POST['field_name'] != $p_fname) { $xydac_cpt_error = new WP_Error('err', __("Changing Field Name is not allowed !!!", 'xydac_cpt')); } else { $p_tname = $_POST['cpt_name']; $p_fname = sanitize_title_with_dashes($_POST['field_name']); $p_flabel = !empty($_POST['field_label']) ? $_POST['field_label'] : $_POST['field_name']; $p_ftype = $_POST['field_type']; $p_fdesc = $_POST['field_desc']; $p_fval = $_POST['field_val']; $p_forder = $_POST['field_order']; if ($p_tname != '' && $p_fname != '' && $p_flabel != '' && $p_ftype != '') { if (!updateCptField($p_tname, $p_fname, $p_flabel, $p_ftype, $p_fdesc, $p_fval, $p_forder)) { $not_inserted = true; } else { $cpt_message = __('Item Updated.', 'xydac_cpt'); $not_inserted = false; } } else { $not_inserted = true; } } } if (isset($_POST['add_cpt_field_submit'])) { if (isset($_POST["field_name"]) && empty($_POST["field_name"])) { $xydac_cpt_error = new WP_Error('err', __("You need to give field name", 'xydac_cpt')); } elseif (!xydac_Cpt_field_avail(sanitize_title_with_dashes($_POST['field_name']), $t_name)) { $xydac_cpt_error = new WP_Error('err', __("Field name not available", 'xydac_cpt')); } else { $t_name = $_POST['cpt_name']; //@TODO: check empty post $p_tname = $_POST['cpt_name']; $p_fname = sanitize_title_with_dashes($_POST['field_name']); $p_flabel = !empty($_POST['field_label']) ? $_POST['field_label'] : $_POST['field_name']; $p_ftype = $_POST['field_type']; $p_fdesc = $_POST['field_desc']; $p_fval = $_POST['field_val']; $p_forder = $_POST['field_order']; if ($p_tname != '' && $p_fname != '' && $p_flabel != '' && $p_ftype != '') { if (!insertCptField($p_tname, $p_fname, $p_flabel, $p_ftype, $p_fdesc, $p_fval, $p_forder)) { $not_inserted = true; } else { $cpt_message = __('Item Added.', 'xydac_cpt'); $not_inserted = false; } } else { $not_inserted = true; } } } $rows = getCptFields($t_name); ?> <div class="wrap" id="page_content"> <?php xydac_cpt_heading("cpt_fields"); ?> <?php if (isset($xydac_cpt_error) && is_wp_error($xydac_cpt_error)) { ?> <div id="message" class="error below-h2"><p><?php echo $xydac_cpt_error->get_error_message(); ?> </p></div> <?php } ?> <?php if (isset($cpt_message)) { ?> <div id="message" class="updated below-h2"><p><?php echo $cpt_message; ?> </p></div> <?php } ?> <br class="clear" /> <div id="col-container"> <div id="col-right"> <p><?php _e('Custom Post Type Name', 'xydac_cpt'); ?> <span style="color:red;"><strong><?php echo $t_name; ?> </strong></span> <a href="<?php echo XYDAC_CPT_FIELDS_PATH; ?> "><?php _e('[Select Another cpt]', 'xydac_cpt'); ?> </a></p> <div class="form-wrap"> <form id="form_field_edit" action="<?php echo XYDAC_CPT_FIELDS_PATH; ?> &manage_cpt_fields_submit=true&manage_cpt_fields_select=<?php echo $t_name; ?> " method="post" > <input type="hidden" name="page" value="ultimate-post-type-manager"/> <input type="hidden" name="sub" value="custom-cpt-fields"/> <input type="hidden" value="<?php echo $t_name; ?> " name="cpt_name" /> <div class="tablenav"> <select name="action"> <option value=""><?php _e('Bulk Actions', 'xydac_cpt'); ?> </option> <option value="delete"><?php _e('Delete', 'xydac_cpt'); ?> </option> </select> <input type="submit" class="button-secondary action" id="cpt_doaction_submit" name="cpt_doaction_submit" value="Apply"/> </div><br class="clear"> <table class="widefat tag fixed" cellspacing="0"> <thead class="content-types-list"> <tr> <th class="manage-column column-cb check-column" id="cb" scope="col"><input type="checkbox"></th> <th class="manage-column column-name" id="name" scope="col"><?php _e('Name', 'xydac_cpt'); ?> </th> <th class="manage-column column-fields" id="fields" scope="col"><?php _e('Label', 'xydac_cpt'); ?> </th> <th class="manage-column column-categories" id="categories" scope="col"><?php _e('Type', 'xydac_cpt'); ?> </th> <th class="manage-column column-field-order" id="field-order" scope="col" width="50px"><?php _e('Order', 'xydac_cpt'); ?> </th> </tr> </thead> <tbody id="the-list"> <?php //field_id,field_name,field_label,field_type if ($rows) { foreach ($rows as $row) { ?> <tr id="content-type-<?php echo $row['field_name']; ?> " class=""> <th class="check-column" scope="row"> <input type="checkbox" value="<?php echo $row['field_name']; ?> " name="delete_content_type[]"/> </th> <td class="name column-name"> <strong> <a class="row-title" title="Edit “<?php echo $row['field_name']; ?> ”" href="<?php echo XYDAC_CPT_FIELDS_PATH; ?> &manage_cpt_fields_submit=true&manage_cpt_fields_select=<?php echo $t_name; ?> &field=<?php echo $row['field_name']; ?> "><?php echo $row['field_name']; ?> </a></strong><br /> </td> <td class="fields column-fields"> <?php echo $row['field_label']; ?> </td> <td class="categories column-categories"> <?php echo $row['field_type']; ?> </td> <td class="categories column-categories" > <?php if (!empty($row['field_order'])) { echo $row['field_order']; } else { echo '0'; } ?> </td> </tr> <?php //echo $row->field_name; } } ?> </tbody> <tfoot> <tr> <th class="manage-column column-cb check-column" scope="col"><input type="checkbox"></th> <th class="manage-column column-name" scope="col"><?php _e('Name', 'xydac_cpt'); ?> </th> <th class="manage-column column-fields" scope="col"><?php _e('Label', 'xydac_cpt'); ?> </th> <th class="manage-column column-categories" scope="col"><?php _e('Type', 'xydac_cpt'); ?> </th> <th class="manage-column column-field-order" id="field-order" scope="col"><?php _e('Order', 'xydac_cpt'); ?> </th> </tr> </tfoot> </table> </form> <br class="clear"> <br class="clear"> <div class="form-wrap"> <p><?php _e('<strong>Note:</strong><br>Deleting a field does not deletes the value in database', 'xydac'); ?> </p><br/> <p><?php _e('For those who had been using other plugin to create or use custom field for post types can switch to this plugin by using the same custom field names. The values remain the same if using the Text Input type.', 'xydac'); ?> </p><br/> </div> </div> </div> <div id="col-left"><div class="col-wrap"> <div class="form-wrap"> <h3><?php if ($not_inserted) { _e('Edit Custom Field', 'xydac_cpt'); } else { _e('Add a New Custom Field', 'xydac_cpt'); } ?> </h3> <form id="form_create_field" action="<?php echo XYDAC_CPT_FIELDS_PATH . "&manage_cpt_fields_submit=true&manage_cpt_fields_select=" . $t_name; ?> " method="post"> <div class="form-field form-required"> <label for="field_name"><?php _e('Field Name', 'xydac_cpt'); ?> </label> <input type="text" name="field_name" <?php if ($not_inserted) { echo "readonly"; } ?> class="name" id="field_name" value="<?php if ($not_inserted) { if (isset($_POST['field_name'])) { echo $p_fname; } else { if (isset($_GET['field'])) { echo $p_fname; } } } ?> "> <p><?php _e('The name of the Field.', 'xydac_cpt'); ?> </p> </div> <div class="form-field form-required"> <label for="field_label"><?php _e('Field Label', 'xydac_cpt'); ?> </label> <input type="text" name="field_label" class="name" id="field_label" value="<?php if ($not_inserted) { if (isset($_POST['field_label'])) { echo $p_flabel; } else { if (isset($_GET['field'])) { echo $p_flabel; } } } ?> "> <p><?php _e('The Label of the Field.', 'xydac_cpt'); ?> </p> </div> <div class="form-field"> <label for="field_type"><?php _e('Field Type', 'xydac_cpt'); ?> </label> <select id="field_type" name="field_type" class="postform"> <?php global $xydac_fields; foreach ($xydac_fields['fieldtypes'] as $type => $label) { $temp = new $type('t1'); echo $temp->option($p_ftype); } ?> </select> <p><?php _e('Input type of the field.', 'xydac_cpt'); ?> </p> </div> <div class="form-field"> <label for="field_desc"><?php _e('Field Description', 'xydac_cpt'); ?> </label> <input type="text" name="field_desc" id="field_desc" class="name" value="<?php if ($not_inserted) { if (isset($_POST['field_desc'])) { echo $p_fdesc; } else { if (isset($_GET['field'])) { echo $p_fdesc; } } } ?> "> <p><?php _e('Description for The Field', 'xydac_cpt'); ?> </p> </div> <div class="form-field"><?php //@TODO:make values disabled when text is selected ?> <label for="field_val"><?php _e('Field Value', 'xydac_cpt'); ?> </label> <input type="text" name="field_val" id="field_val" class="name" value="<?php if ($not_inserted) { if (isset($_POST['field_val'])) { echo $p_fval; } else { if (isset($_GET['field'])) { echo $p_fval; } } } ?> "> <p><?php _e('Enter a comma seperated values to be used for Combo-box, Checkbox, Radio Buttons.For Gallery Enter Width,height as 300px,400px', 'xydac_cpt'); ?> </p> </div> <div class="form-field"> <label for="field_order"><?php _e('Field Order', 'xydac_cpt'); ?> </label> <input type="text" name="field_order" id="field_order" class="name" value="<?php if ($not_inserted) { if (isset($_POST['field_order'])) { echo $p_fval; } else { if (isset($_GET['field'])) { echo $p_forder; } } } ?> "> <p><?php _e('Enter 1,2,3.. order in which you want the Custom Field to appear.', 'xydac_cpt'); ?> </p> </div> <input type="hidden" name="cpt_name" value="<?php echo $t_name; ?> "/> <?php if (isset($_GET['cpt_field'])) { ?> <input type="hidden" name="field_name" value="<?php echo $_GET['cpt_field']; ?> "/><?php } ?> <p class="submit"> <input type="submit" name="<?php if (isset($_GET['field'])) { echo 'edit_cpt_field_submit'; } else { echo 'add_cpt_field_submit'; } ?> " id="<?php if (isset($_GET['field'])) { echo 'edit_cpt_field_submit'; } else { echo 'add_cpt_field_submit'; } ?> " class="button-primary" value="<?php if (isset($_GET['field'])) { _e('Update Custom Field', 'xydac_cpt'); } else { _e('Add Custom Field', 'xydac_cpt'); } ?> "> </p> </form> </div> </div> </div> </div> </div> <?php } else { xydac_cpt_heading("cpt_fields"); $output = 'objects'; // or objects $cpts = get_post_types('', $output); ?> <div class="wrap"> <form name='manage_cpt_fields' action='<?php echo XYDAC_CPT_FIELDS_PATH; ?> ' method='get' > <h3><?php _e('Select the Custom Post Type To manage ', 'xydac_cpt'); ?> </h3> <select name='manage_cpt_fields_select' id='manage_cpt_fields_select' style="margin:20px;"> <?php foreach ($cpts as $cpt => $e) { if ($e->name != 'attachment' && $e->name != 'revision' && $e->name != 'nav_menu_item') { ?> <option value="<?php echo $e->name; ?> "><?php echo !empty($e->label) ? $e->label : $e->name; ?> </option> <?php } } ?> </select> <input type="hidden" name="page" value="ultimate-post-type-manager"/> <input type="hidden" name="sub" value="custom-cpt-fields"/> <input type="submit" name="manage_cpt_fields_submit" id="manage_cpt_fields_submit" class="button" value="Manage"> </form> <br class="clear" /> <p><?php _e('The fields that you create here will be visible on the Custom Post Type Page.', 'xydac_cpt'); ?> </p><br class="clear" /><br class="clear" /> <div id="poststuff" class="ui-sortable"> <?php xydac_cpt_aboutus(); ?> </div> </div> <?php } }
function xydac_cpt_update1() { global $wpdb; $xydac_active_field_types = get_option("xydac_active_field_types"); if (!is_array($xydac_active_field_types)) { $xydac_active_field_types = array(); } $check = 0; $cpts = get_option("xydac_cpt"); if (is_array($cpts)) { foreach ($cpts as $cpt) { $fields = getCptFields($cpt['name']); if (is_array($fields)) { foreach ($fields as $field) { $metas = $wpdb->get_results("SELECT meta_id, meta_value FROM " . $wpdb->postmeta . " WHERE meta_key ='" . $field['field_name'] . "'"); foreach ($metas as $meta) { $meta->meta_value = maybe_unserialize($meta->meta_value); $r = false; if (is_array($meta->meta_value)) { foreach ($meta->meta_value as $k => $v) { if ($k != $field['field_type']) { $r = true; } } } else { $r = true; } if ($r) { $meta->meta_value = array($field['field_type'] => $meta->meta_value); } $meta->meta_value = maybe_serialize($meta->meta_value); $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_value='" . $meta->meta_value . "' WHERE meta_id = " . $meta->meta_id); } if (!in_array($field['field_type'], $xydac_active_field_types)) { array_push($xydac_active_field_types, $field['field_type']); } } } } } if (is_array($xydac_active_field_types)) { update_option('xydac_active_field_types', $xydac_active_field_types); } }
function cpt_col_left($xydac_edit = false) { $avl_types = __(":- NONE -:", "xydac_cpt"); if (is_array($xydac_edit)) { $c_fields = getCptFields($xydac_edit['name']); if (is_array($c_fields)) { $avl_types = ""; $avl_types .= "<ul>"; foreach ($c_fields as $field) { $avl_types .= "<li><b>[xydac_field]" . $field['field_name'] . "[/xydac_field]</b></li>"; } $avl_types .= "</ul>"; } } $xy_arrs = array('heading-1' => array('arr_label' => __('Labels', 'xydac_cpt'), 'name' => 'xydac_acc_label', 'type' => 'heading', 'initialclose' => false), 'label' => array('arr_label' => __('Label for Post Type ', 'xydac_cpt'), 'name' => 'xy_post[args][label]', 'type' => 'string', 'desc' => __('A plural descriptive name for the post type marked for translation.', 'xydac_cpt'), 'default' => ' '), 'name' => array('arr_label' => __('Name of Post Type', 'xydac_cpt'), 'name' => 'xy_post[args][labels][name]', 'type' => 'string', 'desc' => __('general name for the post type, usually plural. The same as, and overridden by Label ', 'xydac_cpt'), 'default' => ' '), 'singular_name' => array('arr_label' => __('Singular Name of Post Type', 'xydac_cpt'), 'name' => 'xy_post[args][labels][singular_name]', 'type' => 'string', 'desc' => __('name for one object of this post type. Defaults to value of name ', 'xydac_cpt'), 'default' => ' '), 'add_new' => array('arr_label' => __('Add New Label of Post Type', 'xydac_cpt'), 'name' => 'xy_post[args][labels][add_new]', 'type' => 'string', 'desc' => __('the add new text. The default is Add New for both hierarchical and non-hierarchical types.', 'xydac_cpt'), 'default' => ' '), 'add_new_item' => array('arr_label' => __('Add New Item Label of Post Type', 'xydac_cpt'), 'name' => 'xy_post[args][labels][add_new_item]', 'type' => 'string', 'desc' => __('the add new item text. Default is Add New Post/Add New Page', 'xydac_cpt'), 'default' => ' '), 'edit_item' => array('arr_label' => __('Edit Item Label of Post Type', 'xydac_cpt'), 'name' => 'xy_post[args][labels][edit_item]', 'type' => 'string', 'desc' => __('the edit item text. Default is Edit Post/Edit Page', 'xydac_cpt'), 'default' => ' '), 'new_item' => array('arr_label' => __('New Item Label of Post Type', 'xydac_cpt'), 'name' => 'xy_post[args][labels][new_item]', 'type' => 'string', 'desc' => __('the new item text. Default is New Post/New Page', 'xydac_cpt'), 'default' => ' '), 'view_item' => array('arr_label' => __('View Item Label of Post Type', 'xydac_cpt'), 'name' => 'xy_post[args][labels][view_item]', 'type' => 'string', 'desc' => __('the view item text. Default is View Post/View Page', 'xydac_cpt'), 'default' => ' '), 'search_items' => array('arr_label' => __('Search Item Label of Post Type', 'xydac_cpt'), 'name' => 'xy_post[args][labels][search_item]', 'type' => 'string', 'desc' => __('the search items text. Default is Search Posts/Search Pages', 'xydac_cpt'), 'default' => ' '), 'not_found' => array('arr_label' => __('Not Found Item Label of Post Type', 'xydac_cpt'), 'name' => 'xy_post[args][labels][not_found]', 'type' => 'string', 'desc' => __('the not found text. Default is No posts found/No pages found', 'xydac_cpt'), 'default' => ' '), 'not_found_in_trash' => array('arr_label' => __('Not Found in Thrash Label of Post Type', 'xydac_cpt'), 'name' => 'xy_post[args][labels][not_found_in_trash]', 'type' => 'string', 'desc' => __('the not found in trash text. Default is No posts found in Trash/No pages found in Trash', 'xydac_cpt'), 'default' => ' '), 'parent_item_colon' => array('arr_label' => __('Parent Item with Colon Label of Post Type', 'xydac_cpt'), 'name' => 'xy_post[args][labels][parent_item_colon]', 'type' => 'string', 'desc' => __('the parent text. This string isn\'t used on non-hierarchical types. In hierarchical ones the default is Parent Page:', 'xydac_cpt'), 'default' => ' '), 'menu_name' => array('arr_label' => __('Menu Name', 'xydac_cpt'), 'name' => 'xy_post[args][labels][menu_name]', 'type' => 'string', 'desc' => __('The menu name text. This string is the name to give menu items.', 'xydac_cpt'), 'default' => ' '), 'enter_text_here' => array('arr_label' => __('Enter Text Here Label', 'xydac_cpt'), 'name' => 'xy_post[args][labels][enter_text_here]', 'type' => 'string', 'desc' => __('The Enter Text Here title label for post type.', 'xydac_cpt'), 'default' => ' '), 'heading-2' => array('arr_label' => __('Options', 'xydac_cpt'), 'name' => 'xydac_acc_options', 'type' => 'heading', 'initialclose' => true), 'public' => array('arr_label' => __('Public', 'xydac_cpt'), 'name' => 'xy_post[args][public]', 'type' => 'boolean', 'desc' => __('This field is used to define default values for publicly_queriable, show_ui, show_in_nav_menus and exclude_from_search, But since the values for these fields is already present so I think this won\'t be used, Better leave this as it is.', 'xydac_cpt'), 'default' => 'true'), 'publicly_queryable' => array('arr_label' => __('Publicly Queryable', 'xydac_cpt'), 'name' => 'xy_post[args][publicly_queryable]', 'type' => 'boolean', 'desc' => __('Allows advanced query based operations from themes based on variable post_type.', 'xydac_cpt'), 'default' => 'true'), 'exclude_from_search' => array('arr_label' => __('Exclude from search ', 'xydac_cpt'), 'name' => 'xy_post[args][exclude_from_search]', 'type' => 'boolean', 'desc' => __('Whether to exclude posts with this post type from search results.', 'xydac_cpt'), 'default' => 'false'), 'show_ui' => array('arr_label' => __('Show UI', 'xydac_cpt'), 'name' => 'xy_post[args][show_ui]', 'type' => 'boolean', 'desc' => __('Whether use the default User Interface for the this Post Type.', 'xydac_cpt'), 'default' => 'true'), 'query_var' => array('arr_label' => __('Query Var', 'xydac_cpt'), 'name' => 'xy_post[args][query_var]', 'type' => 'boolean', 'desc' => __('Use False to disable Querying, True sets the query_var to the name of Post Type.', 'xydac_cpt'), 'default' => 'true'), 'can_export' => array('arr_label' => __('Can Export', 'xydac_cpt'), 'name' => 'xy_post[args][can_export]', 'type' => 'boolean', 'desc' => __('Allow Exporting of Post Types\'s Content from EXPORT option of WordPress.', 'xydac_cpt'), 'default' => 'true'), 'show_in_nav_menus' => array('arr_label' => __('Show in Navigation Menu', 'xydac_cpt'), 'name' => 'xy_post[args][show_in_nav_menus]', 'type' => 'boolean', 'desc' => __('Whether post_type is available for selection in navigation menus.', 'xydac_cpt'), 'default' => 'true'), 'show_in_menu' => array('arr_label' => __('Show in Menu', 'xydac_cpt'), 'name' => 'xy_post[args][show_in_menu]', 'type' => 'boolean', 'desc' => __('Whether to show the post type in the admin menu and where to show that menu. Note that show_ui must be true. ', 'xydac_cpt'), 'default' => 'true'), 'has_archive' => array('arr_label' => __('Has Archive', 'xydac_cpt'), 'name' => 'xy_post[args][has_archive]', 'type' => 'boolean', 'desc' => __('Enables post type archives. Will generate the proper rewrite rules if rewrite is enabled. ', 'xydac_cpt'), 'default' => 'true'), 'map_meta_cap' => array('arr_label' => __('Map Meta Capabilities', 'xydac_cpt'), 'name' => 'xy_post[args][map_meta_cap]', 'type' => 'boolean', 'desc' => __('Whether to use the internal default meta capability handling.This is used for default handling of Capabilities and should be set to TRUE for proper use ', 'xydac_cpt'), 'default' => 'true'), 'hierarchical' => array('arr_label' => __('Hierarchical ', 'xydac_cpt'), 'name' => 'xy_post[args][hierarchical]', 'type' => 'boolean', 'desc' => __('Whether the post type is hierarchical. Allows Parent to be specified.', 'xydac_cpt'), 'default' => 'false'), 'menu_position' => array('arr_label' => __('Menu Position', 'xydac_cpt'), 'name' => 'xy_post[args][menu_position]', 'type' => 'array', 'desc' => __('The position in the menu order the post type should appear.', 'xydac_cpt'), 'default' => '5', 'values' => array('null' => 'Below Comments', '5' => 'Below Post', '10' => 'Below Media', '20' => 'Below Pages', '60' => 'Below First Seperator', '100' => 'Below Second Seperator')), 'heading-3' => array('arr_label' => __('Features', 'xydac_cpt'), 'name' => 'xydac_acc_features', 'type' => 'heading', 'initialclose' => true), 'title' => array('arr_label' => __('Support for Title', 'xydac_cpt'), 'name' => 'xy_post[args][supports][title]', 'type' => 'boolean', 'desc' => __(' ', 'xydac_cpt'), 'default' => 'true'), 'editor' => array('arr_label' => __('Support for Editor', 'xydac_cpt'), 'name' => 'xy_post[args][supports][editor]', 'type' => 'boolean', 'desc' => __(' ', 'xydac_cpt'), 'default' => 'true'), 'author' => array('arr_label' => __('Support for Author', 'xydac_cpt'), 'name' => 'xy_post[args][supports][author]', 'type' => 'boolean', 'desc' => __(' ', 'xydac_cpt'), 'default' => 'false'), 'thumbnail' => array('arr_label' => __('Support for Thumbnail', 'xydac_cpt'), 'name' => 'xy_post[args][supports][thumbnail]', 'type' => 'boolean', 'desc' => __(' ', 'xydac_cpt'), 'default' => 'false'), 'excerpt' => array('arr_label' => __('Support for Excerpt', 'xydac_cpt'), 'name' => 'xy_post[args][supports][excerpt]', 'type' => 'boolean', 'desc' => __(' ', 'xydac_cpt'), 'default' => 'false'), 'trackbacks' => array('arr_label' => __('Support for Trackbacks', 'xydac_cpt'), 'name' => 'xy_post[args][supports][trackbacks]', 'type' => 'boolean', 'desc' => __(' ', 'xydac_cpt'), 'default' => 'false'), 'custom-fields' => array('arr_label' => __('Support for Custom Fields', 'xydac_cpt'), 'name' => 'xy_post[args][supports][custom-fields]', 'type' => 'boolean', 'desc' => __(' ', 'xydac_cpt'), 'default' => 'false'), 'comments' => array('arr_label' => __('Support for Comments', 'xydac_cpt'), 'name' => 'xy_post[args][supports][comments]', 'type' => 'boolean', 'desc' => __(' ', 'xydac_cpt'), 'default' => 'false'), 'revisions' => array('arr_label' => __('Support for Revisions', 'xydac_cpt'), 'name' => 'xy_post[args][supports][revisions]', 'type' => 'boolean', 'desc' => __(' ', 'xydac_cpt'), 'default' => 'false'), 'page-attributes' => array('arr_label' => __('Support for Page attributes', 'xydac_cpt'), 'name' => 'xy_post[args][supports][page-attributes]', 'type' => 'boolean', 'desc' => __(' ', 'xydac_cpt'), 'default' => 'false'), 'def-cats' => array('arr_label' => __('Show Default Category', 'xydac_cpt'), 'name' => 'xy_post[def][cat]', 'type' => 'boolean', 'desc' => __('Show the Default Categories for this Custom Post Type ', 'xydac_cpt'), 'default' => 'false'), 'def-tag' => array('arr_label' => __('Show Default Tags', 'xydac_cpt'), 'name' => 'xy_post[def][tag]', 'type' => 'boolean', 'desc' => __('Show the Default Tags for this Custom Post Type ', 'xydac_cpt'), 'default' => 'false'), 'heading-4' => array('arr_label' => __('Advanced Options', 'xydac_cpt'), 'name' => 'xydac_acc_ad_options', 'type' => 'heading', 'initialclose' => true), 'description' => array('arr_label' => __('Description', 'xydac_cpt'), 'name' => 'xy_post[args][description]', 'type' => 'string', 'desc' => __('A short descriptive summary of what the post type is.', 'xydac_cpt'), 'default' => ' '), 'capability_type' => array('arr_label' => __('Capability Type', 'xydac_cpt'), 'name' => 'xy_post[args][capability_type]', 'type' => 'string', 'desc' => __('The post type to use for checking read, edit, and delete capabilities.The Capabilities will be automatically created.', 'xydac_cpt'), 'default' => ''), 'register_meta_box_cb' => array('arr_label' => __('Register Meta Box CB', 'xydac_cpt'), 'name' => 'xy_post[args][register_meta_box_cb]', 'type' => 'string', 'desc' => __('Provide a callback function that will be called when setting up the meta boxes for the edit form. Do remove_meta_box() and add_meta_box() calls in the callback.', 'xydac_cpt'), 'default' => ' '), 'menu_icon' => array('arr_label' => __('Menu Icon', 'xydac_cpt'), 'name' => 'xy_post[args][menu_icon]', 'type' => 'string', 'desc' => __('The url to the icon to be used for this menu.', 'xydac_cpt'), 'default' => ' '), 'heading-41' => array('arr_label' => __('Rewrite Options', 'xydac_cpt'), 'name' => 'xydac_acc_rw_options', 'type' => 'heading', 'initialclose' => true), 'rewrite' => array('arr_label' => __('Rewrite', 'xydac_cpt'), 'name' => 'xy_post[args][rewrite][val]', 'type' => 'boolean', 'desc' => __('Do you Want the Permalinks ceated for this post-type to be Rewritten.', 'xydac_cpt'), 'default' => 'true'), 'slug' => array('arr_label' => __('Slug', 'xydac_cpt'), 'name' => 'xy_post[args][rewrite][slug]', 'type' => 'string', 'desc' => __('Prepend posts with this slug. Uses Post-Type name if left blank.', 'xydac_cpt'), 'default' => ' '), 'permalink_epmask' => array('arr_label' => __('Permalink_EPMASK', 'xydac_cpt'), 'name' => 'xy_post[args][permalink_epmask]', 'type' => 'string', 'desc' => __('The default rewrite endpoint bitmasks.', 'xydac_cpt'), 'default' => ' '), 'with_front' => array('arr_label' => __('With Front', 'xydac_cpt'), 'name' => 'xy_post[args][rewrite][with_front]', 'type' => 'boolean', 'desc' => __('allowing permalinks to be prepended with front base', 'xydac_cpt'), 'default' => 'true'), 'feeds' => array('arr_label' => __('Feeds', 'xydac_cpt'), 'name' => 'xy_post[args][rewrite][feeds]', 'type' => 'boolean', 'desc' => __('', 'xydac_cpt'), 'default' => 'false'), 'pages' => array('arr_label' => __('Pages', 'xydac_cpt'), 'name' => 'xy_post[args][rewrite][pages]', 'type' => 'boolean', 'desc' => __('', 'xydac_cpt'), 'default' => 'true'), 'heading-42' => array('arr_label' => __('Content Details', 'xydac_cpt'), 'name' => 'xydac_acc_con_details', 'type' => 'heading', 'initialclose' => true), 'content_html' => array('arr_label' => __('Content HTML', 'xydac_cpt'), 'name' => 'xy_post[content_html]', 'type' => 'textarea', 'desc' => __('Please Enter the default template for the content.Use the litrel [CONTENT] wherever you want to show the default content.Else use the Shortcodes for display of other fields.<br/><b>Availaible Field Types :</b> <br/>' . $avl_types . ' ', 'xydac_cpt'), 'default' => ''), 'heading-5' => array('name' => 'finalheading', 'type' => 'heading', 'initialclose' => true, 'finalclose' => true)); ?> <div id='col-left'><div class='col-wrap'> <div class='form-wrap'> <h3><?php if (is_array($xydac_edit)) { _e('Edit Custom Post Type', 'xydac_cpt'); } else { _e('Add a New Custom Post Type', 'xydac_cpt'); } ?> </h3> <form <?php if (is_array($xydac_edit)) { echo "id='form_edit_cpt'"; } else { echo "id='form_create_cpt'"; } ?> action='<?php echo XYDAC_CPT_POST_PATH; ?> ' method='post'> <div class="form-field form-required <?php if (isset($_POST['xydac_create_cpt']) || isset($_POST['xydac_edit_cpt'])) { if (isset($_POST["xy_post"]['name']) && empty($_POST["xy_post"]['name'])) { echo 'form-invalid'; } } ?> " > <label for='xy_post[name]' style="font-weight:bold;"><?php _e('The Name of the Custom Post Type', 'xydac_cpt'); ?> </label> <input type='text' name='xy_post[name]' class='name' <?php if (is_array($xydac_edit)) { echo "readonly"; } ?> id='xy_post[name]' value="<?php if (is_array($xydac_edit)) { _e($xydac_edit['name'], 'xydac'); } ?> " /> <p><?php _e('Custom Post Type Name identifies your Custom Post among others. It is usually all lowercase and contains only letters, numbers, and hyphens.', 'xydac_cpt'); ?> </p><br/> </div> <?php if (is_array($xydac_edit)) { ?> <div id="accordion" > <?php foreach ($xy_arrs as $k => $xy_arr) { $atemp = explode('[', substr($xy_arr['name'], 6)); if ($xy_arr['type'] == 'heading') { if ($xy_arr['initialclose']) { echo "</div>"; } if (!isset($xy_arr['finalclose'])) { ?> <h3><?php echo $xy_arr['arr_label']; ?> </h3><div> <?php } } else { ?> <div class='form-field' id="xydac_panel_<?php echo $xy_arr['name']; ?> " > <?php if ($xy_arr['type'] == 'boolean') { ?> <label for='<?php echo $xy_arr['name']; ?> ' style="display:inline;font-weight:bold;"><?php echo $xy_arr['arr_label']; ?> </label> <select id='<?php echo $xy_arr['name']; ?> ' name='<?php echo $xy_arr['name']; ?> ' class='postform' style="float:right;width:100px;margin-right:5%"> <option value='true' <?php if ($xy_arr['default'] == 'true' && !is_array($xydac_edit)) { echo 'selected'; } elseif (is_array($xydac_edit)) { if (count($atemp) == 2) { if ($xydac_edit[substr($atemp[1], 0, -1)] == 'true') { echo ' Selected'; } } elseif (count($atemp) == 3) { if ($xydac_edit[substr($atemp[1], 0, -1)][substr($atemp[2], 0, -1)] == 'true') { echo ' Selected'; } } elseif (count($atemp) == 4) { if ($xydac_edit[substr($atemp[1], 0, -1)][substr($atemp[2], 0, -1)][substr($atemp[3], 0, -1)] == 'true') { echo 'selected'; } } } ?> ><?php _e('True', 'xydac_cpt'); ?> </option> <option value='false' <?php if ($xy_arr['default'] == 'false' && !is_array($xydac_edit)) { echo 'selected'; } elseif (is_array($xydac_edit)) { if (count($atemp) == 2) { if ($xydac_edit[substr($atemp[1], 0, -1)] == 'false') { echo ' Selected'; } } elseif (count($atemp) == 3) { if ($xydac_edit[substr($atemp[1], 0, -1)][substr($atemp[2], 0, -1)] == 'false') { echo ' Selected'; } } elseif (count($atemp) == 4) { if ($xydac_edit[substr($atemp[1], 0, -1)][substr($atemp[2], 0, -1)][substr($atemp[3], 0, -1)] == 'false') { echo 'selected'; } } } ?> ><?php _e('False', 'xydac_cpt'); ?> </option> </select> <?php } elseif ($xy_arr['type'] == 'array') { ?> <label for='<?php echo $xy_arr['name']; ?> ' style="display:inline;font-weight:bold;"><?php echo $xy_arr['arr_label']; ?> </label> <select id='<?php echo $xy_arr['name']; ?> ' name='<?php echo $xy_arr['name']; ?> ' class='postform' style="float:right;width:150px;margin-right:5%"> <?php foreach ($xy_arr['values'] as $n => $c) { ?> <option value='<?php echo $n; ?> ' <?php if ($xy_arr['default'] == $n && !is_array($xydac_edit)) { echo 'selected'; } elseif (is_array($xydac_edit)) { if (count($atemp) == 2) { if ($xydac_edit[substr($atemp[1], 0, -1)] == $n) { echo ' Selected'; } } elseif (count($atemp) == 3) { if ($xydac_edit[substr($atemp[1], 0, -1)][substr($atemp[2], 0, -1)] == $n) { echo ' Selected'; } } elseif (count($atemp) == 4) { if ($xydac_edit[substr($atemp[1], 0, -1)][substr($atemp[2], 0, -1)][substr($atemp[3], 0, -1)] == $n) { echo 'selected'; } } } ?> ><?php echo $c; ?> </option> <?php } ?> </select> <?php } elseif ($xy_arr['type'] == 'string') { ?> <label for='<?php echo $xy_arr['name']; ?> ' style="font-weight:bold;"><?php echo $xy_arr['arr_label']; ?> </label> <input type='text' name='<?php echo $xy_arr['name']; ?> ' class='name' id='<?php echo $xy_arr['name']; ?> ' value="<?php if (is_array($xydac_edit)) { if (count($atemp) == 3) { echo $xydac_edit[substr($atemp[1], 0, -1)][substr($atemp[2], 0, -1)]; } elseif (count($atemp) == 4) { echo $xydac_edit[substr($atemp[1], 0, -1)][substr($atemp[2], 0, -1)][substr($atemp[3], 0, -1)]; } } ?> "/> <?php } elseif ($xy_arr['type'] == 'textarea') { ?> <label for='<?php echo $xy_arr['name']; ?> ' style="font-weight:bold;"><?php echo $xy_arr['arr_label']; ?> </label> <textarea style="height:300px" name='<?php echo $xy_arr['name']; ?> ' class='name' id='<?php echo $xy_arr['name']; ?> '> <?php if (is_array($xydac_edit)) { echo $xydac_edit['content_html']; } ?> </textarea> <?php } ?> <p><?php echo $xy_arr['desc']; ?> </p> </div> <?php } } if (is_array($xydac_edit)) { ?> <input type="hidden" name="cpt_name" value="<?php if (isset($_GET['cptname'])) { echo $_GET['cptname']; } ?> "> <?php } ?> </div> </div> <?php } ?> <p class='submit'> <input type="submit" name="<?php if (!is_array($xydac_edit)) { echo 'xydac_create_cpt'; } else { echo 'xydac_update_cpt'; } ?> " class="button-primary" value="<?php if (!is_array($xydac_edit)) { _e('Add Custom Post Type', 'xydac_cpt'); } else { _e('Update Custom Post Type', 'xydac_cpt'); } ?> "></p> </form> </div> </div> <?php }