示例#1
0
    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>&nbsp;&nbsp;<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 &ldquo;<?php 
                    echo $row['field_name'];
                    ?>
&rdquo;" 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 
        }
    }
示例#2
0
    function xydac_cpt_home()
    {
        ?>
	<div class="wrap" ><?php 
        xydac_cpt_heading();
        ?>
        <div id="poststuff" class="ui-sortable">
		<div class="postbox-container" style="width:100%">
				<?php 
        xydac_cpt_aboutus();
        ?>
			</div>
			<div id="normal-sortables" style="width:69%;float:left;">
			
			<div class="postbox-container" >
                <div class="postbox opened">
                    <h3><?php 
        _e('Custom Post Type', 'xydac_cpt');
        ?>
</h3>
                    <div class="inside">
                       
                            <p style="text-align:justify"><?php 
        _e('<strong>Custom Post type</strong> is a way of storing different types of content under different names, and you can call these names as a Custom Post Type.WordPress supports Creating Custom Post types since ver 3.1, and you can use the above link to create unlimited number of custom post types.<br/>', 'xydac_cpt');
        ?>
                            </p><h4><?php 
        _e('Deleting Custom Post type', 'xydac_cpt');
        ?>
</h4><p style="text-align:justify">
							<?php 
        _e('When you delete a Post Type then the data Post Type has saved does not get removed, So if you want to use the same Post Type again just recreate it again with same name.<br/>', 'xydac_cpt');
        ?>
                            </p><h4><?php 
        _e('Transferring from other Custom Post type plugins', 'xydac_cpt');
        ?>
</h4><p style="text-align:justify">
							<?php 
        _e('If you have created Post types already with some other Plugin and want to move to this Plugin then just create the Post type with same name and configure it.Do deactivate the other plugin or remove the same post type from it. Also you need to deactivate and reactivate this plugin again.', 'xydac_cpt');
        ?>
                            </p><h4><?php 
        _e('Some important links relating to Custom Post Types', 'xydac_cpt');
        ?>
</h4>
							<p style="text-align:justify">
							<?php 
        _e('
							<ul>
								<li><a href="http://codex.wordpress.org/Post_Types">WordPress Codex : Post Type </a></li>
								<li><a href="http://codex.wordpress.org/Function_Reference/register_post_type">WordPress Codex : register post type info </a></li>
								<li><a href="http://posttypemanager.wordpress.com/">Plugin Website </a></li>
							</ul>
							', 'xydac_cpt');
        ?>
							</p>
                        
                    </div>
                </div>
			</div>
			<div class="postbox-container" >
                <div class="postbox opened">
                    <h3><?php 
        _e('Custom Fields', 'xydac_cpt');
        ?>
</h3>
                    <div class="inside">
                            <p style="text-align:justify"><?php 
        _e('Custom Fields are custom data associated with any post type.They are usually a key value pair but can provide a great aid to help you design you post page. With the help of the plugin you can create various types of custom fields for any Post Type including Post and Pages.<br/>
                            
                            ', 'xydac_cpt');
        ?>
							</p style="text-align:justify"><h4><?php 
        _e('Using Custom Field in between Post', 'xydac_cpt');
        ?>
</h4><p>
							<?php 
        _e('To display Custom Fields in the posts you can use shortcode <strong>[xydac_field]<em>{name of field}</em>[/xydac_field]</strong> where {name of field} is the Name of Custom Field.', 'xydac_cpt');
        ?>
<br/>
                            </p><h4><?php 
        _e('Availaible Field Types', 'xydac_cpt');
        ?>
</h4>
							<p style="text-align:justify">
							<?php 
        _e('
							<ul>
								<li>Text Box</li>
								<li>Text area</li>
								<li>Rich Text Area</li>
								<li>Checkbox</li>
								<li>Radio Button</li>
								<li>Combobox</li>
								<li>Link</li>
								<li>Gallery</li>
								<li>Image</li>							
							</ul>
							', 'xydac_cpt');
        ?>
<br/>
                            </p>
                    </div>
                </div>
			</div>
			</div>
			<div id="side-sortables" style="width:29%;float:left;padding-left:15px;">
			<div class="postbox-container" >
                <div class="postbox opened">
                    <h3><?php 
        _e('Information', 'xydac_cpt');
        ?>
</h3>
                    <div class="inside">
                       <p><?php 
        _e('This plugin is an Easy to use Custom Post Type Manager to Customize Post Types, and Custom Fields for all post types with great UI.', 'xydac_cpt');
        ?>
</p>
                        <p><?php 
        _e('You can use the above menus to create <strong>Custom Post Type</strong> as well as Create <strong>Custom Fields</strong> to store more information
                           in each Post.These Custom Field Create a new Form for inserting these values.Just Check it out.', 'xydac_cpt');
        ?>
</p>
                        
                    </div>
                </div>
			</div>
			<div class="postbox-container">
                <div class="postbox opened">
                    <h3><?php 
        _e('Want More...', 'xydac_cpt');
        ?>
</h3>
                    <div class="inside">
                       <?php 
        if (!defined('XYDAC_VER')) {
            ?>
					   <?php 
            _e('So, You want more..!!!<br/>
					   Check out the plugin to create Custom Taxonomies<br/><br/>
					   Taxonomies are simply different ways of classifying and organising different areas of your website,In fact there are two predefined taxonomies which are Tags and Category.', 'xydac_cpt');
            ?>
<br/>
                        <h4><a href="http://wordpress.org/extend/plugins/ultimate-taxonomy-manager/" >Ultimate Taxonomy Manager</a><br/></h4>
                        <a href="http://taxonomymanager.wordpress.com/" >-<?php 
            _e('Plugin Home Page', 'xydac_cpt');
            ?>
</a><br/>
                        <a href="http://downloads.wordpress.org/plugin/ultimate-taxonomy-manager.zip">-<?php 
            _e('', 'xydac_cpt');
            _e('Download Latest Version Now', 'xydac_cpt');
            ?>
</a>
                        <br/><br/> <?php 
            _e('Hope You like that Plugin Also.', 'xydac_cpt');
            ?>
                    <?php 
        } else {
            ?>
                        <h4><?php 
            _e('Thank You', 'xydac_cpt');
            ?>
</h4> <?php 
            _e('For Installing Ultimate Post Type Manager and Ultimate Taxonomy Manager.', 'xydac_cpt');
            ?>
<br/><br/> <?php 
            _e('As you know creating good plugins require lot of time so, Support Further Development with you Esteemed Donation', 'xydac_cpt');
            ?>
<br/><br/>
                        <span style="color:red;background:yellow;padding:4px;font-weight:bold;"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=nikhilseth1989%40gmail%2ecom&item_name=WordPress%20Plugin%20(Ultimate%20Post%20Type%20Manager)&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8">>>&nbsp;<?php 
            _e('Click Here To Donate', 'xydac_cpt');
            ?>
&nbsp;<<</a></span>
						<br/><br/>
					<?php 
        }
        ?>
					   
                    </div>
                </div>
			</div>
			</div>
			<div class="clear"></div>
			
		</div>
	</div>
	<?php 
    }
示例#3
0
    function xydac_cpt_loader()
    {
        $xydac_edit = array();
        $editmode = false;
        //handles create Custom Post Types
        if (isset($_POST['xydac_create_cpt'])) {
            if (isset($_POST["xy_post"]['name']) && empty($_POST["xy_post"]['name'])) {
                $xydac_error = new WP_Error('err', __("Custom Post Type Name is required to create New Custom Post Type", "xydac_cpt"));
            } elseif (in_array($_POST["xy_post"]['name'], get_reg_cptName())) {
                $xydac_error = new WP_Error('err', __("Custom Post Type already registered !!!", "xydac_cpt"));
            } else {
                if (isset($_POST["xy_post"]['name'])) {
                    $_POST["xy_post"]['name'] = sanitize_title_with_dashes($_POST["xy_post"]['name']);
                }
                $xydac_cpts = get_option("xydac_cpt");
                if (!$xydac_cpts) {
                    $temp = array();
                    array_push($temp, $_POST["xy_post"]);
                    update_option('xydac_cpt', $temp);
                }
                if (is_array($xydac_cpts)) {
                    array_push($xydac_cpts, $_POST["xy_post"]);
                    update_option('xydac_cpt', $xydac_cpts);
                }
                $message = __('Custom Post Type Added.', "xydac_cpt");
                $editmode = true;
            }
        }
        //handles update CPT
        if (isset($_POST['xydac_update_cpt']) && $_POST['cpt_name']) {
            $editmode = false;
            if (empty($_POST["xy_post"]['name'])) {
                $xydac_error = new WP_Error('err', __("Custom Post Type Name is required to create New Custom Post Type", "xydac_cpt"));
            } elseif ($_POST["xy_post"]['name'] != $_POST['cpt_name']) {
                $xydac_error = new WP_Error('err', __("Changing Name is not allowed !!!", "xydac_cpt"));
            } else {
                $_POST["xy_post"]['name'] = sanitize_title_with_dashes($_POST["xy_post"]['name']);
                $xydac_cpts = get_option("xydac_cpt");
                if (is_array($xydac_cpts)) {
                    foreach ($xydac_cpts as $k => $xydac_cpt) {
                        if ($xydac_cpt['name'] == $_POST['cpt_name']) {
                            unset($xydac_cpts[$k]);
                            break;
                        }
                    }
                    array_push($xydac_cpts, $_POST["xy_post"]);
                    update_option('xydac_cpt', $xydac_cpts);
                    $message = __('Custom Post Type Updated.', "xydac_cpt");
                }
                $editmode = true;
            }
        }
        //handles delete CPT
        if (isset($_POST['xydac_cpt_doaction_submit']) && isset($_POST['action']) || isset($_GET['delete-single']) && isset($_GET['d_name'])) {
            $i = 0;
            if (isset($_POST['action']) && $_POST['action'] == 'delete' || isset($_GET['delete-single']) && $_GET['delete-single'] == 'delete') {
                $xydac_cpts = get_option("xydac_cpt");
                if (isset($_POST['delete_cpt'])) {
                    foreach ($_POST['delete_cpt'] as $k => $v) {
                        if (is_array($xydac_cpts)) {
                            foreach ($xydac_cpts as $k => $xydac_cpt) {
                                if ($xydac_cpt['name'] == $v) {
                                    unset($xydac_cpts[$k]);
                                    $i = 1;
                                }
                            }
                        }
                    }
                } elseif (isset($_GET['d_name']) && !empty($_GET['d_name'])) {
                    foreach ($xydac_cpts as $k => $xydac_cpt) {
                        if ($xydac_cpt['name'] == $_GET['d_name']) {
                            unset($xydac_cpts[$k]);
                            $i = 1;
                        }
                    }
                }
                if ($i) {
                    update_option('xydac_cpt', $xydac_cpts);
                    $message = __('Custom Post Type Deleted.', "xydac_cpt");
                } else {
                    $message = __('Custom Post Type Not Deleted.', "xydac_cpt");
                }
            }
            $editmode = true;
        }
        if (isset($editmode) && !$editmode) {
            if (isset($_POST["xy_post"])) {
                $xydac_edit = $_POST["xy_post"];
            }
        }
        if (isset($_GET['edit-cpt']) && isset($_GET['cptname']) && !isset($_POST["xy_post"])) {
            $xydac_cpts = get_option("xydac_cpt");
            if (is_array($xydac_cpts)) {
                foreach ($xydac_cpts as $xydac_cpt) {
                    if (isset($_GET['cptname'])) {
                        if ($xydac_cpt['name'] == $_GET['cptname']) {
                            $xydac_edit = $xydac_cpt;
                            break;
                        }
                    }
                }
            }
        }
        if (isset($_POST['xydac_cpt_import_submit']) && isset($_POST['xydac_cpt_import'])) {
            $m = xydac_import_cpt(stripslashes_deep($_POST['xydac_cpt_import']));
            if (is_wp_error($m)) {
                $xydac_error = $m;
            } else {
                $message = $m;
            }
        }
        ?>
<div class="wrap" id="page_content">

 <?php 
        xydac_cpt_heading("cpt_post");
        if (isset($xydac_error) && is_wp_error($xydac_error)) {
            echo "<div class='error below-h2'><p>" . $xydac_error->get_error_message() . "</p></div>";
        }
        //updated
        ?>
    <?php 
        if (isset($message)) {
            ?>
    <div id="message" class="updated below-h2"><p><?php 
            echo $message;
            ?>
</p></div>
    <?php 
        }
        ?>
  <br class="clear" />
  <div id="col-container">
  <?php 
        cpt_col_right();
        if (isset($_GET['edit-cpt']) && isset($_GET['cptname']) && !$editmode) {
            cpt_col_left($xydac_edit);
        } else {
            cpt_col_left();
        }
        echo '</div></div>';
    }