Skip to content

Instantly share code, notes, and snippets.

@ali-cedcoss
Last active October 1, 2021 04:42
Show Gist options
  • Save ali-cedcoss/257b4e4992646d4c2957eaf5ecf0cf7b to your computer and use it in GitHub Desktop.
Save ali-cedcoss/257b4e4992646d4c2957eaf5ecf0cf7b to your computer and use it in GitHub Desktop.
new accounts settings UI
<?php
// If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
die;
}
$file = CED_EBAY_DIRPATH . 'admin/partials/header.php';
if ( file_exists( $file ) ) {
require_once $file;
}
$shop_data = isset( $shopDetails ) ? $shopDetails : array();
$name = ! empty( $shop_data['store_name'] ) ? $shop_data['store_name'] : $shop_data['user_id'];
$user_id = isset( $_GET['user_id'] ) ? sanitize_text_field( $_GET['user_id'] ) : '';
$part = isset( $_GET['part'] ) ? sanitize_text_field( $_GET['part'] ) : '';
?>
<div class="ced-ebay-v2-header">
<div class="ced-ebay-v2-logo">
<img src="<?php echo esc_attr( CED_EBAY_URL ) . 'admin/images/icon-100X100.png'; ?>">
</div>
<div class="ced-ebay-v2-header-content">
<div class="ced-ebay-v2-title">
<h1>Account Settings</h1>
</div>
<div class="ced-ebay-v2-actions">
<a class="ced-ebay-v2-btn" href="https://docs.woocommerce.com/document/ebay-integration-for-woocommerce/#section-5" target="_blank">
Documentation </a>
</div>
</div>
</div>
<?php
$payment_select = '';
$shipping_select = '';
$return_select = '';
$description_template_select = '';
if ( 'payment' == $part || '' == $part ) {
$payment_select = 'active';
} elseif ( 'shipping' == $part ) {
$shipping_select = 'active';
} elseif ( 'return' == $part ) {
$return_select = 'active';
} elseif ( 'description_template' == $part ) {
$description_template_select = 'active';
}
?>
<div id="gf-admin-notices-wrapper">
<!-- WP appends notices to the first H tag, so this is here to capture admin notices. -->
<h2 class="gf-notice-container"></h2> </div>
<div class="gform-settings__wrapper">
<nav class="gform-settings__navigation">
<a href="<?php echo esc_attr_e( admin_url( 'admin.php?page=ced_ebay&section=accounts-view-new&part=payment&user_id=' . $user_id ) ); ?>" id="payment_details" class="<?php echo esc_attr_e( $payment_select ); ?>">
<span class="label">Payment Settings</span></a>
<a href="<?php echo esc_attr_e( admin_url( 'admin.php?page=ced_ebay&section=accounts-view&part=shipping&user_id=' . $user_id ) ); ?>" id="shipping_details" class="<?php echo esc_attr_e( $shipping_select ); ?>">
<span class="label">Shipping Settings</span></a>
<a href="<?php echo esc_attr_e( admin_url( 'admin.php?page=ced_ebay&section=accounts-view&part=return&user_id=' . $user_id ) ); ?>" id="return_details" class="<?php echo esc_attr_e( $return_select ); ?>">
<span class="label">Return Settings</span></a>
<a href="<?php echo esc_attr_e( admin_url( 'admin.php?page=ced_ebay&section=accounts-view&part=description_template&user_id=' . $user_id ) ); ?>" id="description_template_details" class="<?php echo esc_attr_e( $description_template_select ); ?>">
<span class="label">Return Settings</span></a>
</nav>
<div class="gform-settings__content" id="tab_export_form">
<div class="gform-settings__content">
<?php
if ( 'payment' == $part || '' == $part ) {
include_once CED_EBAY_DIRPATH . 'admin/partials/payment-new.php';
}?>
</div>
</div>
<!-- / gform-settings__content -->
</div>
<!-- / gform-settings__wrapper -->
<style>
/* @media all{
label{vertical-align:middle;}
.form-table{border-collapse:collapse;margin-top:.5em;width:100%;clear:both;}
.form-table,.form-table td,.form-table th{font-size:14px;}
.form-table td{margin-bottom:9px;padding:15px 10px;line-height:1.3;vertical-align:middle;}
.form-table th{color:#1d2327;font-weight:400;text-shadow:none;vertical-align:baseline;}
.form-table th{vertical-align:top;text-align:left;padding:20px 10px 20px 0;width:200px;line-height:1.3;font-weight:600;}
@media screen and (max-width:782px){
.form-table{box-sizing:border-box;}
.form-table td,.form-table th{display:block;width:auto;vertical-align:middle;}
.form-table th{padding:10px 0 0 0;border-bottom:0;}
.form-table td{margin-bottom:0;padding:4px 0 6px 0;}
.form-table label{font-size:14px;}
}
} */
@media all{
.gform-settings__wrapper{display:-ms-grid;display:grid;grid-column-gap:.875rem;-ms-grid-columns:12.875rem auto;grid-template-columns:12.875rem auto;margin-left:auto;margin-right:auto;max-width:69.5rem;padding:1.5rem;}
.gform-settings-header{background:#3e7da6;box-shadow:1px 1px 3px rgba(0,0,0,.0272345);}
.gform-settings-header .gform-settings__wrapper{align-items:center;background:url(https://dev.blackmountaincoins.com/wp-content/plugins/gravityforms/includes/settings/images/gravity-rocket.svg?2) no-repeat 252px bottom;background-size:164px;display:flex;flex-wrap:wrap;justify-content:space-between;padding-bottom:1.375rem;padding-top:1.375rem;transition:padding .3s ease;}
.gform-settings__navigation a{border:1px solid transparent;border-radius:3px;color:#5b5e80;display:block;font-size:.875rem;font-weight:400;line-height:normal;margin:0;padding:.6875rem .5rem .6875rem 1rem;text-decoration:none;}
.gform-settings__navigation .active,.gform-settings__navigation a:focus,.gform-settings__navigation a:hover{color:#242748;}
.gform-settings__navigation .active,.gform-settings__navigation a:focus{background:#fff;font-weight:500;}
.gform-settings__navigation .active{border:1px solid #e3e6ef;box-shadow:0 1px 4px rgba(18,25,97,.0779552);margin-top:.125rem;}
.gform-settings__navigation a:focus{border:1px solid #3985b7;box-shadow:0 .125rem .0675rem rgba(28,31,63,.0634624),0 0 0 2px #bed8ed;color:#242748;}
.gform-settings__navigation span{vertical-align:middle;}
.gform-settings__navigation .icon{align-items:center;display:inline-flex;height:1.25rem;justify-content:center;margin-right:.75rem;width:1.25rem;}
.gform-settings__navigation svg{height:auto;max-width:1.25rem;}
}
</style>
<?php
// If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
die;
}
// var_dump($shop_data);
$shop_data = isset( $shop_data['account_data'] ) ? json_decode( $shop_data['account_data'], true ) : array();
$siteID = isset( $shop_data['siteID'] ) ? $shop_data['siteID'] : '';
$token = isset( $shop_data['token']['eBayAuthToken'] ) ? $shop_data['token']['eBayAuthToken'] : '';
$shop_name = isset( $_GET['user_id'] ) ? sanitize_text_field( $_GET['user_id'] ) : '';
if ( isset( $_POST['ced_ebay_payment_nonce'] ) && wp_verify_nonce( sanitize_text_field( $_POST['ced_ebay_payment_nonce'] ), 'ced_ebay_payment_page_nonce' ) ) {
if ( isset( $_POST['ced_ebay_site_settings_save_payment_button'] ) ) {
$sanitized_array = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
$ced_ebay_site_selected_payment_options = isset( $sanitized_array['ced_ebay_site_selected_payment_options'] ) ? ( $sanitized_array['ced_ebay_site_selected_payment_options'] ) : array();
$email = isset( $sanitized_array['ced_ebay_site_email_address'] ) ? ( $sanitized_array['ced_ebay_site_email_address'] ) : '';
if ( ! empty( $ced_ebay_site_selected_payment_options ) ) {
update_option( 'ced_umb_ebay_site_selected_payment_methods_' . $shop_name, $ced_ebay_site_selected_payment_options );
}
}
}
$payment_methods = array();
$payment_methods = get_option( 'ced_umb_ebay_site_payment_methods_' . $shop_name, array() );
$selected_payment_methods = array();
$selected_payment_methods = get_option( 'ced_umb_ebay_site_selected_payment_methods_' . $shop_name, array() );
if ( ! is_array( $selected_payment_methods ) ) {
$selected_payment_methods = array();
}
$email = get_option( 'ced_ebay_site_email_address_' . $shop_name, '' );
if ( empty( $payment_methods ) ) {
if ( ! empty( $token ) ) {
require_once CED_EBAY_DIRPATH . 'admin/ebay/lib/ebayUpload.php';
$ebayUploadInstance = EbayUpload::get_instance( $siteID, $token );
$mainXml = '<?xml version="1.0" encoding="utf-8"?>
<GetCategoryFeaturesRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>' . $token . '</eBayAuthToken>
</RequesterCredentials>
<DetailLevel>ReturnAll</DetailLevel>
<AllFeaturesForCategory>true</AllFeaturesForCategory>
</GetCategoryFeaturesRequest>';
$site_specific_payment_methods = $ebayUploadInstance->get_sitespecific_payment_methods( $mainXml );
if ( is_array( $site_specific_payment_methods ) && ! empty( $site_specific_payment_methods ) ) {
if ( isset( $site_specific_payment_methods['SiteDefaults'] ) ) {
$payment_methods = $site_specific_payment_methods['SiteDefaults']['PaymentMethod'];
update_option( 'ced_umb_ebay_site_payment_methods_' . $shop_name, $payment_methods );
}
}
}
}
?>
<?php
if ( ! empty( $payment_methods ) ) {
require_once CED_EBAY_DIRPATH . 'admin/ebay/lib/eBayPaymentConfig.php';
$eBayConfigInstance = Ced_EBay_Config::get_instance();
$allEbayPaymentMethods = $eBayConfigInstance->getEbayPaymentMethods();
?>
<form method="post" class="ced_ebay_payment_preference_form">
<div class="gform-settings-panel gform-settings-panel--full">
<header class="gform-settings-panel__header">
<legend class="gform-settings-panel__title">Manage Payment Methods for your eBay Listings</legend>
</header>
<div class="gform-settings-panel__content">
<div class="gform-settings-description">
From the list below, select payment preference for your Products while uploading them to eBay. You can either set an existing Payment Policy or add new payment methods to your Listings.
<b>If you are using eBay Managed Payments you can skip this section.</b></div>
<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row">
<label for="export_fields">eBay Payment Policy</label>
</th>
<td>
<ul>
<li>
<input id="ced_ebay_use_eBay_shipping_policy_checkbox" type="checkbox" name="ced_ebay_use_eBay_shipping_policy_checkbox" value="" >
<label for="ced_ebay_use_eBay_shipping_policy_checkbox">Use your existing Payment Policy?</label>
</li>
</ul>
</td>
</tr>
<tr valign="top">
<th scope="row">
<label for="export_fields">Select Payment Methods</label>
</th>
<td>
<ul id="export_form_list">
<li>
<input type="checkbox" id="ced_ebay_select_all_payment_methods_checkbox">
<label for="ced_ebay_select_all_payment_methods_checkbox" data-deselect="Deselect All" data-select="Select All">Select All</label>
</li>
<?php
foreach ( $payment_methods as $key => $value ) {
$selected = '';
if ( in_array( $value, $selected_payment_methods ) ) {
$selected = 'checked';
}
?>
<li>
<input id="<?php echo esc_attr( $value ); ?>" type="checkbox" name="ced_ebay_site_selected_payment_options[]" value="<?php echo esc_attr( $value ); ?>" <?php echo esc_attr( $selected ); ?>>
<label for="<?php echo esc_attr( $value ); ?>"><?php echo esc_attr( $value ); ?></label>
</li>
<?php
}
?>
</ul>
</td>
</tr>
</tbody>
</table>
<br>
<br>
<?php wp_nonce_field( 'ced_ebay_payment_page_nonce', 'ced_ebay_payment_nonce' ); ?>
<input type="submit" value="Save Payment Preference" name="ced_ebay_site_settings_save_payment_button" id="ced_ebay_site_settings_save_payment_button" class="button large primary"> </div>
</div>
</form>
<?php
}
?>
<style>
@media all{
label{vertical-align:middle;}
.form-table{border-collapse:collapse;margin-top:.5em;width:100%;clear:both;}
.form-table,.form-table td,.form-table th{font-size:14px;}
.form-table td{margin-bottom:9px;padding:15px 10px;line-height:1.3;vertical-align:middle;}
.form-table th{color:#1d2327;font-weight:400;text-shadow:none;vertical-align:baseline;}
.form-table th{vertical-align:top;text-align:left;padding:20px 10px 20px 0;width:200px;line-height:1.3;font-weight:600;}
@media screen and (max-width:782px){
.form-table{box-sizing:border-box;}
.form-table td,.form-table th{display:block;width:auto;vertical-align:middle;}
.form-table th{padding:10px 0 0 0;border-bottom:0;}
.form-table td{margin-bottom:0;padding:4px 0 6px 0;}
.form-table label{font-size:14px;}
}
}
@media all{
.gform-icon{font-family:gform-icons-admin!important;speak:never;font-style:normal;font-weight:400;font-feature-settings:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;}
.gform-icon--question-mark:before{content:"\e97e";}
}
@media all{
table.form-table tr:last-child td,table.form-table tr:last-child th{border:none!important;}
.gforms_edit_form input:disabled{pointer-events:none;}
::-webkit-input-placeholder{color:#5b5e80;}
::-moz-placeholder{color:#5b5e80;}
:-ms-input-placeholder{color:#5b5e80;}
:-moz-placeholder{color:#5b5e80;}
.gf_browser_chrome input[type=checkbox]{margin-bottom:-4px;}
.gf-notice-container{display:none;}
.gform-settings-header .gform-settings__wrapper{clear:both;}
}
@media all{
.ced_ebay_payment_preference_form{display:-ms-grid;display:grid;grid-column-gap:.875rem;grid-row-gap:.875rem;-ms-grid-columns:1fr 1fr;grid-template-columns:1fr 1fr;}
.gform-settings-panel{background:#fff;border:1px solid #e3e6ef;border-radius:3px;box-shadow:0 1px 4px rgba(18,25,97,.0779552);box-sizing:border-box;display:flex;flex-direction:column;-ms-grid-column-span:2;grid-column:span 2;position:relative;}
.gform-settings-panel__header{align-items:center;display:flex;font-size:.875rem;justify-content:space-around;line-height:2.875rem;padding-left:1.0625rem;padding-right:.875rem;position:relative;}
.gform-settings-panel__title{flex-grow:1;font-weight:500;margin:0;}
.gform-settings-panel .gform-settings-panel__content{border-top:1px solid #ebebf2;padding:1rem 1rem 1.25rem;}
.gform-settings-description{display:block;font-size:.8125rem;line-height:1.384615385rem;margin-bottom:.5625rem;}
.gform-settings-panel__content input:-ms-input-placeholder{color:#9092b0;}
.gform-settings-panel__content input::-moz-placeholder,.gform-settings-panel__content input::-ms-input-placeholder,.gform-settings-panel__content input::placeholder{color:#9092b0;}
.gform-settings-panel__content input[type=checkbox]:disabled{opacity:.6;pointer-events:none;}
.gform-settings-panel__content input:disabled+label,.gform-settings-panel__content input:disabled+label::before{cursor:not-allowed;opacity:.6;pointer-events:none;}
.gform-settings-panel__content input[type=checkbox]{background:#fff;border:1px solid #9092b2;border-radius:3px;height:1.375rem;margin:0 .75rem 0 0;transition:box-shadow .15s ease,background-color .15s ease;width:1.375rem;}
.gform-settings-panel__content input[type=checkbox]:focus,.gform-settings-panel__content input[type=checkbox]:hover{border:1px solid #3985b7;box-shadow:0 .125rem .0675rem rgba(28,31,63,.0634624),0 0 0 2px #bed8ed;color:#242748;}
.gform-settings-panel__content input[type=checkbox]::before{background-position:center;background-repeat:no-repeat;background-size:.75rem;content:"";display:block;height:100%;margin:0;width:100%;}
.gform-settings-panel__content input[type=checkbox]:hover::before{background-image:url(data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjEwIiB2aWV3Qm94PSIwIDAgMTIgMTAiIHdpZHRoPSIxMiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJtNCA2LjU4NTc5IDYuMjkyOS02LjI5Mjg5N2MuMzkwNS0uMzkwNTI0MSAxLjAyMzctLjM5MDUyNDEgMS40MTQyIDAgLjM5MDUuMzkwNTI1LjM5MDUgMS4wMjM2ODcgMCAxLjQxNDIxN2wtNy43MDcxIDcuNzA3MS0zLjcwNzEwNy0zLjcwNzFjLS4zOTA1MjQxLS4zOTA1My0uMzkwNTI0MS0xLjAyMzY5IDAtMS40MTQyMi4zOTA1MjUtLjM5MDUyIDEuMDIzNjg3LS4zOTA1MiAxLjQxNDIxNyAweiIgZmlsbD0iI0VDRURGOCIvPjwvc3ZnPg==);}
.gform-settings-panel__content input[type=checkbox]:checked{background:#3e7da6;border-color:transparent;}
.gform-settings-panel__content input[type=checkbox]:checked::before{background-image:url(data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjEwIiB2aWV3Qm94PSIwIDAgMTIgMTAiIHdpZHRoPSIxMiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJtNCA2LjU4NTc5IDYuMjkyOS02LjI5Mjg5N2MuMzkwNS0uMzkwNTI0MSAxLjAyMzctLjM5MDUyNDEgMS40MTQyIDAgLjM5MDUuMzkwNTI1LjM5MDUgMS4wMjM2ODcgMCAxLjQxNDIxN2wtNy43MDcxIDcuNzA3MS0zLjcwNzEwNy0zLjcwNzFjLS4zOTA1MjQxLS4zOTA1My0uMzkwNTI0MS0xLjAyMzY5IDAtMS40MTQyMi4zOTA1MjUtLjM5MDUyIDEuMDIzNjg3LS4zOTA1MiAxLjQxNDIxNyAweiIgZmlsbD0iI2ZmZiIvPjwvc3ZnPg==);}
.gform-settings-panel__content input[type=checkbox]:focus{outline:0;}
.gform-settings__wrapper .button:disabled{opacity:.6;}
.gform-settings__wrapper .button{background:#fff;border:1px solid #3e7da6;border-radius:3px;box-shadow:0 2px 1px rgba(28,31,63,.0634624);font-size:.875rem;height:2.3125rem;line-height:.875rem;padding:.625rem 1.125rem;}
.gform-settings__wrapper .button:hover{box-shadow:0 4px 6px rgba(28,31,63,.0837013);}
.gform-settings__wrapper .button.primary{-webkit-backface-visibility:hidden;backface-visibility:hidden;background:#3e7da6;border:1px solid transparent;border-radius:3px;color:#fff;font-family:inherit;font-size:.875rem;font-weight:500;height:auto;height:initial;line-height:1;margin-left:0;padding:.625rem 1.125rem;transition:transform .3s ease,box-shadow .3s ease,background-color .3s ease;}
.gform-settings__wrapper .button.primary:hover{box-shadow:0 4px 6px rgba(28,31,63,.0837013);transform:translate(0,-2px);}
.gform-settings__wrapper .button.large{padding-bottom:.875rem;padding-top:.875rem;}
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment