Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a new plugin template structure. #37

Merged
merged 1 commit into from Jun 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -18,4 +18,4 @@
</form>
</div>
<?php endif; ?>
</div>
</div>
Expand Up @@ -18,4 +18,4 @@
</form>
</div>
<?php endif; ?>
</div>
</div>
2 changes: 1 addition & 1 deletion includes/gateway/class-omise-payment-creditcard.php
Expand Up @@ -168,7 +168,7 @@ function payment_fields() {
$viewData['user_logged_in'] = false;
}

Omise_Util::render_view( 'includes/templates/omise-payment-form.php', $viewData );
Omise_Util::render_view( 'templates/payment/form.php', $viewData );
}

/**
Expand Down
2 changes: 0 additions & 2 deletions includes/templates/index.php

This file was deleted.

37 changes: 0 additions & 37 deletions includes/templates/omise-myaccount-panel.php

This file was deleted.

3 changes: 2 additions & 1 deletion omise-util.php
Expand Up @@ -50,7 +50,8 @@ public static function render_json_error( $message ) {
* @return void
*/
public static function render_partial( $partial_name, $partial_data = null ) {
require_once( plugin_dir_path( __FILE__ ) . 'includes/templates/partials/' . $partial_name . '-template.php' );
// TODO: Make it to not relate with `admin` directory.
require_once( plugin_dir_path( __FILE__ ) . 'includes/admin/views/partials/' . $partial_name . '-template.php' );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion omise-wc-myaccount.php
Expand Up @@ -62,7 +62,7 @@ public function init_panel(){
$cards = Omise::get_customer_cards ( $this->private_key, $this->omise_customer_id );
$viewData ["existingCards"] = $cards;

Omise_Util::render_view ( 'includes/templates/omise-myaccount-panel.php', $viewData );
Omise_Util::render_view ( 'templates/myaccount/my-card.php', $viewData );
$this->register_omise_my_account_scripts ();
}
}
Expand Down
4 changes: 2 additions & 2 deletions omise-wp-admin.php
Expand Up @@ -189,7 +189,7 @@ public function render_dashboard_page() {

try {
$viewData['charges'] = Omise_Charge::list_charges( $this->private_key );
$this->render_view( 'includes/templates/omise-wp-admin-page.php', $viewData );
$this->render_view( 'includes/admin/views/page-dashboard.php', $viewData );
} catch( Exception $e ) {
echo "<div class='wrap'><div class='error'>" . esc_html( $e->getMessage () ) . "</div></div>";
}
Expand All @@ -204,7 +204,7 @@ public function render_transfers_page() {

try {
$viewData['transfers'] = Omise_Transfer::list_transfers( $this->private_key );
$this->render_view( 'includes/templates/omise-wp-admin-transfer-page.php', $viewData );
$this->render_view( 'includes/admin/views/page-transfer.php', $viewData );
} catch ( Exception $e ) {
echo "<div class='wrap'><div class='error'>" . esc_html( $e->getMessage() ) . "</div></div>";
}
Expand Down
35 changes: 35 additions & 0 deletions templates/myaccount/my-card.php
@@ -0,0 +1,35 @@
<h2>Omise settings</h2>
<h3>Cards</h3>
<div id="omise_card_panel">
<table>
<tr>
<th>Name</th>
<th>Number</th>
<th>Created date</th>
<th>Action</th>
</tr>
<tbody>
<?php if ( isset( $viewData['existingCards']->data ) ): ?>
<?php foreach( $viewData['existingCards']->data as $card ): ?>
<?php
$nonce = wp_create_nonce( 'omise_delete_card_' . $card->id );
echo "<tr><td>{$card->name}</td><td>XXXX XXXX XXXX {$card->last_digits}</td>";
$created_date = date_i18n( get_option( 'date_format' ), strtotime($card->created));
echo "<td>{$created_date}</td>";
echo "<td><button class='button delete_card' data-card-id='{$card->id}' data-delete-card-nonce='{$nonce}'>Delete</button></td></tr>";
?>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>

<h4>Add new card</h4>
<form name="omise_cc_form" id="omise_cc_form">
<?php wp_nonce_field('omise_add_card','omise_add_card_nonce'); ?>
<fieldset>
<?php require_once( '../payment/form-creditcard.php' ); ?>
<div class="clear"></div>
</fieldset>
</form>
<button id="omise_add_new_card" class="button">Save card</button>
</div>
Expand Up @@ -26,4 +26,4 @@
<input id="omise_card_security_code"
class="input-text" type="password" autocomplete="off"
placeholder="<?php echo _x( 'Security Code', 'Placeholder for security Code', 'omise' ); ?>" name="omise_card_security_code">
</p>
</p>
Expand Up @@ -14,7 +14,7 @@

<fieldset id="new_card_form" class="<?php echo $showExistingCards ? 'omise-hidden' : ''; ?>">

<?php require_once('omise-cc-form.php'); ?>
<?php require_once('form-creditcard.php'); ?>

<?php if ( $viewData['user_logged_in'] ) : ?>
<p class="form-row form-row-wide">
Expand All @@ -25,4 +25,4 @@

<div class="clear"></div>
</fieldset>
</div>
</div>