コード例 #1
0
ファイル: metaboxes.php プロジェクト: KB-Support/kb-support
/**
 * Render the form field row.
 *
 * @since	0.1
 * @param	obj		$field	The WP_Post object for the field.
 * @param	obj		$form	The WP_Post object for the form.
 * return	void
 */
function kbs_render_form_field_row($field, $form)
{
    $settings = $form->get_field_settings($field->ID);
    $url = remove_query_arg(array('edit_field', 'delete_field', 'kbs-message', 'kbs-action-nonce'));
    $edit = wp_nonce_url(add_query_arg(array('kbs-action' => 'edit_form_field', 'field_id' => $field->ID, 'kbs-message' => 'editing_field'), $url), 'edit_form_field', 'kbs-action-nonce');
    $delete = wp_nonce_url(add_query_arg(array('kbs-action' => 'delete_form_field', 'field_id' => $field->ID), $url), 'delete_form_field', 'kbs-action-nonce');
    ?>
    <td><span class="kbs_draghandle"></span></td>
	<?php 
    echo KBS()->html->hidden(array('name' => 'kbs_form_field[' . $field->ID . '][index]', 'value' => $field->menu_order, 'class' => 'kbs_sortable_index'));
    ?>
    
    <td><?php 
    echo $field->post_title;
    ?>
		<?php 
    if (!empty($settings['description'])) {
        ?>
        	<br />
            <span class="description"><?php 
        echo esc_html($settings['description']);
        ?>
</span>
        <?php 
    }
    ?>
    </td>
    
    <td><?php 
    echo kbs_get_field_type($settings['type']);
    ?>
</td>
    
    <td><?php 
    echo kbs_display_field_setting_icons($field->ID);
    ?>
</td>
    
    <td>
    	<a href="<?php 
    echo $edit;
    ?>
" class="button button-primary button-small"><?php 
    _e('Edit', 'kb-support');
    ?>
</a>

        <?php 
    if (kbs_can_delete_field($field->ID)) {
        ?>
	        <a href="<?php 
        echo $delete;
        ?>
" class="button button-secondary button-small"><?php 
        _e('Delete', 'kb-support');
        ?>
</a>
        <?php 
    }
    ?>
    </td>
    
    <?php 
}
コード例 #2
0
 /**
  * Deletes a field.
  *
  * @since	1.0
  * @param	int		$field_id	The field post ID.
  * @param	bool	$force		Whether or not to force deletion of a default field.
  * @return	mixed	Field post object if successful, otherwise false.
  */
 public function delete_field($field_id, $force = false)
 {
     if ('kbs_form_field' != get_post_type($field_id)) {
         return false;
     }
     if (!$force && !kbs_can_delete_field($field_id)) {
         return false;
     }
     do_action('kbs_pre_delete_field', $field_id);
     $result = wp_delete_post($form_id, true);
     do_action('kbs_post_delete_field', $field_id);
     return $result;
 }
コード例 #3
0
/**
 * Delete a form field.
 *
 * @since	1.0
 * @param	int		$field_id	Post ID.
 * @param	bool	$force		Whether or not to force deletion of a default field.
 * @return	obj		WP_Query Object.
 */
function kbs_delete_field($field_id, $force = false)
{
    if (!$force && !kbs_can_delete_field($field_id)) {
        return false;
    }
    do_action('kbs_pre_delete_field', $field_id);
    $result = wp_delete_post($field_id);
    do_action('kbs_post_delete_field', $field_id, $result);
    return $result;
}