Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tareq1988 committed Oct 10, 2015
1 parent 4774068 commit caf02b2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions form.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,18 @@ function build_rows( $edit = false ) {
);

$new_code = $edit_code = str_replace( $search_array, $replace_array, $form_code );
$new_code = str_replace( array( '%rows%', '%submit_new_text%', '%retrieve_row%' ), array( $new_rows, $_POST['submit_new_text'], '' ), $new_code );
$edit_code = str_replace( array( '%rows%', '%submit_new_text%', '%retrieve_row%' ), array( $edit_rows, $_POST['submit_edit_text'], $retrieve_row ), $edit_code );
$new_code = str_replace( array( '%rows%', '%submit_new_text%', '%retrieve_row%', '%field_id%' ), array( $new_rows, $_POST['submit_new_text'], '', '0' ), $new_code );
$edit_code = str_replace( array( '%rows%', '%submit_new_text%', '%retrieve_row%', '%field_id%' ), array( $edit_rows, $_POST['submit_edit_text'], $retrieve_row, '<?php echo $item->id; ?>' ), $edit_code );

$form_handler = str_replace( $search_array, $replace_array, $form_handler );
$form_handler = str_replace( array( '%form_fields%', '%required_form_fields%', '%form_fields_array%' ), array( $form_fields, $required_form_fields, $form_fields_array ), $form_handler );

$form_functions = str_replace( $search_array, $replace_array, $form_functions );
?>
<p><strong>add-item.php</strong></p>
<p><strong><?php echo $_POST['singular_name']; ?>-new.php</strong></p>
<pre class="prettyprint"><?php echo htmlentities( $new_code ); ?></pre>

<p><strong>edit-item.php</strong></p>
<p><strong><?php echo $_POST['singular_name']; ?>-edit.php</strong></p>
<pre class="prettyprint"><?php echo htmlentities( $edit_code ); ?></pre>

<p><strong>class-form-handler.php</strong></p>
Expand Down
2 changes: 1 addition & 1 deletion templates/form-functions.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Insert a new leave policy
* Insert a new %singular_name%
*
* @param array $args
*/
Expand Down
6 changes: 3 additions & 3 deletions templates/form-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct() {
}

/**
* Add entitlement with leave policies to employees
* Handle the %singular_name% new and edit form
*
* @return void
*/
Expand Down Expand Up @@ -52,13 +52,13 @@ public function handle_form() {
// New or edit?
if ( ! $field_id ) {

prefix_insert_%singular_name%( $fields );
%prefix%_insert_%singular_name%( $fields );

} else {

$fields['id'] = $field_id;

prefix_insert_%singular_name%( $fields );
%prefix%_insert_%singular_name%( $fields );
}

$redirect_to = add_query_arg( array( 'affected' => $affected ), $page_url );
Expand Down
2 changes: 1 addition & 1 deletion templates/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<tbody>%rows%</tbody>
</table>

<input type="hidden" name="field_id" value="0">
<input type="hidden" name="field_id" value="%field_id%">

<?php wp_nonce_field( '%nonce%' ); ?>
<?php submit_button( __( '%submit_new_text%', '%textdomain%' ), 'primary', '%submit_name%' ); ?>
Expand Down

0 comments on commit caf02b2

Please sign in to comment.