| 1 |
<?php |
| 2 |
/* |
| 3 |
* Page Name: Add New |
| 4 |
*/ |
| 5 |
|
| 6 |
use WPCoder\Dashboard\DashboardInitializer; |
| 7 |
use WPCoder\Dashboard\Field; |
| 8 |
use WPCoder\Dashboard\Link; |
| 9 |
use WPCoder\Dashboard\Settings; |
| 10 |
use WPCoder\WPCoder; |
| 11 |
|
| 12 |
defined( 'ABSPATH' ) || exit; |
| 13 |
|
| 14 |
$default = Field::getDefault(); |
| 15 |
|
| 16 |
$action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ''; |
| 17 |
$item_id = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : ''; |
| 18 |
$item_title = __( 'Add new code', 'wpcoder' ); |
| 19 |
if ( $action === 'update' && ! empty( $item_id ) ) { |
| 20 |
$item_title = __( 'Update code', 'wpcoder' ) . ' ID: ' . $item_id; |
| 21 |
} elseif ( $action === 'duplicate' && ! empty( $item_id ) ) { |
| 22 |
$item_title = __( 'Duplicate the code from', 'wpcoder' ) . ' ID: ' . $item_id; |
| 23 |
} |
| 24 |
$license_page = add_query_arg( ['page' => WPCoder::SLUG . '-license' ], admin_url( 'admin.php' ) ); |
| 25 |
$add_url = add_query_arg( [ |
| 26 |
'page' => WPCoder::SLUG . '-settings', |
| 27 |
'action' => 'new' |
| 28 |
], admin_url( 'admin.php' ) ); |
| 29 |
|
| 30 |
|
| 31 |
?> |
| 32 |
|
| 33 |
<div class="wowp-header-wrapper"> |
| 34 |
<?php DashboardInitializer::header(); ?> |
| 35 |
|
| 36 |
<div class="wowp-header-title"> |
| 37 |
<h2><?php echo esc_html( $item_title ); ?></h2> |
| 38 |
<a href="<?php echo esc_url( $add_url ); ?>" class="button button-primary button-large"> |
| 39 |
+ <?php esc_html_e( 'Add New', 'wpcoder' ); ?> |
| 40 |
</a> |
| 41 |
|
| 42 |
<a href="<?php echo esc_url( Link::all_codes() ); ?>" class="button button-secondary button-large"> |
| 43 |
⇐ <?php esc_html_e( 'Back to Codes', 'wpcoder' ); ?> |
| 44 |
</a> |
| 45 |
|
| 46 |
</div> |
| 47 |
</div> |
| 48 |
|
| 49 |
|
| 50 |
<form action="" id="wowp-settings" class="wowp-settings wowp-wrap" method="post"> |
| 51 |
|
| 52 |
<div id="poststuff"> |
| 53 |
<div id="post-body" class="metabox-holder columns-2"> |
| 54 |
<div id="post-body-content"> |
| 55 |
|
| 56 |
<div id="titlediv"> |
| 57 |
|
| 58 |
<div id="titlewrap"> |
| 59 |
<label class="screen-reader-text" id="title-prompt-text" |
| 60 |
for="title"><?php esc_html_e( 'Enter title here', 'wpcoder' ); ?> |
| 61 |
</label> |
| 62 |
<?php Field::text( 'title' ); ?> |
| 63 |
</div> |
| 64 |
|
| 65 |
</div> |
| 66 |
</div> |
| 67 |
|
| 68 |
<!-- Sidebar with the setting--> |
| 69 |
<div id="postbox-container-1" class="postbox-container"> |
| 70 |
<?php require_once plugin_dir_path( __FILE__ ) . 'sidebar.php'; ?> |
| 71 |
</div> |
| 72 |
|
| 73 |
<div id="postoptions"> |
| 74 |
<div id="postbox-container-2" class="postbox-container wowp-settings-wrapper"> |
| 75 |
<?php Settings::init(); ?> |
| 76 |
</div> |
| 77 |
</div> |
| 78 |
</div> |
| 79 |
|
| 80 |
</div> |
| 81 |
|
| 82 |
<input type="hidden" name="tool_id" value="<?php echo absint( $default['id'] ); ?>" id="tool_id"/> |
| 83 |
<input type="hidden" name="param[time]" value="<?php echo esc_attr( time() ); ?>"/> |
| 84 |
<?php wp_nonce_field( WPCoder::PREFIX . '_nonce', WPCoder::PREFIX . '_settings' ); ?> |
| 85 |
|
| 86 |
</form> |
| 87 |
|
| 88 |
|
| 89 |
<?php |
| 90 |
|