PageRenderTime 54ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/wp-e-commerce/wpsc-admin/display-options-settings.page.php

https://github.com/AaronFernandes/aquestionof
PHP | 312 lines | 232 code | 64 blank | 16 comment | 42 complexity | 4de308fde9134c913eb0d66576d037bb MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0
  1. <?php
  2. /*
  3. * Display Settings page
  4. */
  5. // Clear the previously selected shipping form session variable if you are not on the shipping page
  6. if ( isset( $_GET['tab'] ) )
  7. if( $_GET['tab'] == 'shipping' )
  8. if( isset( $_GET['shipping_module'] ) )
  9. $_SESSION['previous_shipping_name'] = $_GET['shipping_module'];
  10. function wpsc_display_settings_page() { ?>
  11. <div id="wpsc_options" class="wrap">
  12. <div id="icon_card"><br /></div>
  13. <h2><?php _e( 'Store Settings', 'wpsc' ); ?></h2>
  14. <?php
  15. wpsc_the_settings_tabs();
  16. if ( isset( $_GET['tab'] ) )
  17. $page = $_GET['tab'];
  18. else
  19. $page = 'general';
  20. if ( !isset( $_GET['isocode'] ) )
  21. $_GET['isocode'] = '';
  22. if ( preg_match( "/[a-zA-Z]{2,4}/", $_GET['isocode'] ) ) {
  23. include(WPSC_FILE_PATH . '/wpsc-admin/includes/tax_and_shipping.php');
  24. return;
  25. }
  26. if ( isset( $_GET['googlecheckoutshipping'] ) ) {
  27. include(WPSC_FILE_PATH . '/wpsc-merchants/library/google_shipping_country.php');
  28. return;
  29. exit();
  30. }
  31. if ( isset( $_GET['selected_all'] ) )
  32. wpsc_submit_options( $_GET['selected_all'] );
  33. ?>
  34. <div id='wpsc_options_page'>
  35. <?php
  36. switch ( $page ) {
  37. case 'checkout' :
  38. require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/checkout.php' );
  39. wpsc_options_checkout();
  40. break;
  41. case 'gateway' :
  42. require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/gateway.php' );
  43. wpsc_options_gateway();
  44. break;
  45. case 'shipping' :
  46. require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/shipping.php' );
  47. wpsc_options_shipping();
  48. break;
  49. case 'admin' :
  50. require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/admin.php' );
  51. wpsc_options_admin();
  52. break;
  53. case 'presentation' :
  54. require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/presentation.php' );
  55. wpsc_options_presentation();
  56. break;
  57. case 'taxes' :
  58. wpec_taxes_settings_page();
  59. break;
  60. case 'marketing' :
  61. require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/marketing.php' );
  62. wpsc_options_marketing();
  63. break;
  64. case 'import' :
  65. require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/import.php' );
  66. wpsc_options_import();
  67. break;
  68. case 'general' :
  69. default :
  70. require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/general.php' );
  71. wpsc_options_general();
  72. break;
  73. }
  74. $_SESSION['wpsc_settings_curr_page'] = $page; ?>
  75. </div>
  76. </div>
  77. <?php
  78. }
  79. /*
  80. * Create settings page tabs
  81. */
  82. function wpsc_settings_tabs() {
  83. $_default_tabs = array(
  84. 'general' => _x( 'General', 'General settings tab in Settings->Store page', 'wpsc' ),
  85. 'presentation' => _x( 'Presentation', 'Presentation settings tab in Settings->Store page', 'wpsc' ),
  86. 'admin' => _x( 'Admin', 'Admin settings tab in Settings->Store page', 'wpsc' ),
  87. 'taxes' => _x( 'Taxes', 'Taxes settings tab in Settings->Store page', 'wpsc' ),
  88. 'shipping' => _x( 'Shipping', 'Shipping settings tab in Settings->Store page', 'wpsc' ),
  89. 'gateway' => _x( 'Payments', 'Payments settings tab in Settings->Store page', 'wpsc' ),
  90. 'checkout' => _x( 'Checkout', 'Checkout settings tab in Settings->Store page', 'wpsc' ),
  91. 'marketing' => _x( 'Marketing', 'Marketing settings tab in Settings->Store page', 'wpsc' ),
  92. 'import' => _x( 'Import', 'Import settings tab in Settings->Store page', 'wpsc' )
  93. );
  94. return apply_filters( 'wpsc_settings_tabs', $_default_tabs );
  95. }
  96. /*
  97. * Display settings tabs
  98. */
  99. function wpsc_the_settings_tabs() {
  100. global $redir_tab;
  101. $tabs = wpsc_settings_tabs();
  102. if ( !empty( $tabs ) ) {
  103. echo '<div id="wpsc_settings_nav_bar" style="width:100%;">';
  104. echo "<ul id='sidemenu' >\n";
  105. if ( isset( $redir_tab ) && array_key_exists( $redir_tab, $tabs ) ) {
  106. $current = $redir_tab;
  107. } elseif ( isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $tabs ) ) {
  108. $current = $_GET['tab'];
  109. } else {
  110. $keys = array_keys( $tabs );
  111. $current = array_shift( $keys );
  112. }
  113. foreach ( $tabs as $callback => $text ) {
  114. $class = '';
  115. if ( $current == $callback )
  116. $class = " class='current'";
  117. $href = add_query_arg( array( 'tab' => $callback, 's' => false, 'paged' => false, 'post_mime_type' => false, 'm' => false ) );
  118. $href = remove_query_arg( 'isocode', $href );
  119. $href = wp_nonce_url( $href, "tab-$callback" );
  120. $link = "<a href='" . esc_url( $href ) . "'$class>$text</a>";
  121. echo "\t<li id='" . esc_attr( "tab-$callback" ) . "'>$link</li>\n";
  122. }
  123. echo "</ul>\n";
  124. echo '</div>';
  125. echo "<div style='clear:both;'></div>";
  126. }
  127. }
  128. function country_list( $selected_country = null ) {
  129. global $wpdb;
  130. $output = '';
  131. $output .= "<option value=''></option>";
  132. $country_data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY `country` ASC", ARRAY_A );
  133. foreach ( (array)$country_data as $country ) {
  134. $selected = '';
  135. if ( $selected_country == $country['isocode'] )
  136. $selected = "selected='selected'";
  137. $output .= "<option value='" . $country['isocode'] . "' $selected>" . htmlspecialchars( $country['country'] ) . "</option>";
  138. }
  139. return $output;
  140. }
  141. /*
  142. * Get Shipping Form for wp-admin
  143. */
  144. function wpsc_get_shipping_form( $shippingname ) {
  145. global $wpsc_shipping_modules;
  146. if ( array_key_exists( $shippingname, $wpsc_shipping_modules ) ) {
  147. $shipping_forms = $wpsc_shipping_modules[$shippingname]->getForm();
  148. $shipping_module_name = $wpsc_shipping_modules[$shippingname]->name;
  149. $output = array( 'name' => $shipping_module_name, 'form_fields' => $shipping_forms, 'has_submit_button' => 1 );
  150. } else {
  151. $output = array( 'name' => '&nbsp;', 'form_fields' => __( 'To configure a shipping module select one on the left.', 'wpsc' ), 'has_submit_button' => 0 );
  152. }
  153. return $output;
  154. }
  155. /***
  156. * Get Payment Form for wp-admin
  157. */
  158. function wpsc_get_payment_form( $paymentname ,$selected_gateway_data='') {
  159. global $nzshpcrt_gateways;
  160. $payment_gateway_names = get_option('payment_gateway_names');
  161. $form = array();
  162. $output = array( 'name' => '&nbsp;', 'form_fields' => __( 'To configure a payment module select one on the left.', 'wpsc' ), 'has_submit_button' => 0 );
  163. foreach ( $nzshpcrt_gateways as $gateway ) {
  164. if ( $gateway["internalname"] != $paymentname ) {
  165. continue;
  166. } else {
  167. $selected_gateway_data = $gateway;
  168. $form = $gateway;
  169. }
  170. }
  171. if ( $form ) {
  172. $output ='';
  173. $output .="<tr>
  174. <td style='border-top: none;'>
  175. ".__("Display Name", 'wpsc')."
  176. </td>
  177. <td style='border-top: none;'>";
  178. if (isset($payment_gateway_names[$paymentname]) ) {
  179. $display_name = $payment_gateway_names[$paymentname];
  180. } elseif(!empty($selected_gateway_data['display_name'])){
  181. $display_name =$selected_gateway_data['display_name'];
  182. }else{
  183. switch($selected_gateway_data['payment_type']) {
  184. case "paypal";
  185. $display_name = "PayPal";
  186. break;
  187. case "manual_payment":
  188. $display_name = "Manual Payment";
  189. break;
  190. case "google_checkout":
  191. $display_name = "Google Checkout";
  192. break;
  193. case "credit_card":
  194. default:
  195. $display_name = "Credit Card";
  196. break;
  197. }
  198. }
  199. $output .="<input type='text' name='user_defined_name[".$paymentname."]' value='". $display_name ."' /><br />
  200. <span class='small description'>".__('The text that people see when making a purchase', 'wpsc')."</span>
  201. </td>
  202. </tr>";
  203. $payment_forms = $form["form"]();
  204. $payment_module_name = $form["name"];
  205. $output = array( 'name' => $payment_module_name, 'form_fields' => $output.$payment_forms, 'has_submit_button' => 1 );
  206. } else {
  207. $output = array( 'name' => '&nbsp;', 'form_fields' => __( 'To configure a payment module select one on the left.', 'wpsc' ), 'has_submit_button' => 0 );
  208. }
  209. return $output;
  210. }
  211. function wpsc_settings_page_update_notification() {
  212. if ( isset( $_GET['skipped'] ) || isset( $_GET['updated'] ) || isset( $_GET['regenerate'] ) || isset( $_GET['deleted'] ) || isset( $_GET['shipadd'] ) ) { ?>
  213. <div id="message" class="updated fade"><p>
  214. <?php
  215. if ( isset( $_GET['updated'] ) && (int)$_GET['updated'] ) {
  216. printf( _n( '%s Setting options updated.', ' %s Settings options updated.', $_GET['updated'] ), absint( $_GET['updated'] ) );
  217. unset( $_GET['updated'] );
  218. $message = true;
  219. }
  220. if ( isset( $_GET['deleted'] ) && (int)$_GET['deleted'] ) {
  221. printf( _n( '%s Setting option deleted.', '%s Setting option deleted.', $_GET['deleted'] ), absint( $_GET['deleted'] ) );
  222. unset( $_GET['deleted'] );
  223. $message = true;
  224. }
  225. if ( isset( $_GET['shipadd'] ) && (int)$_GET['shipadd'] ) {
  226. printf( _n( '%s Shipping option updated.', '%s Shipping option updated.', $_GET['shipadd'] ), absint( $_GET['shipadd'] ) );
  227. unset( $_GET['shipadd'] );
  228. $message = true;
  229. }
  230. if ( isset( $_GET['added'] ) && (int)$_GET['added'] ) {
  231. printf( _n( '%s Checkout field added.', '%s Checkout fields added.', $_GET['added'] ), absint( $_GET['added'] ) );
  232. unset( $_GET['added'] );
  233. $message = true;
  234. }
  235. if ( isset( $_GET['regenerate'] ) ) {
  236. _e('Thumbnails regenerated.', 'wpsc');
  237. unset( $_GET['regenerate'] );
  238. $message = true;
  239. wpsc_regenerate_thumbnails();
  240. }
  241. if ( !isset( $message ) )
  242. _e( 'Settings successfully updated.', 'wpsc' );
  243. $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'regenerate', 'skipped', 'updated', 'deleted', 'wpsc_downloadcsv', 'rss_key', 'start_timestamp', 'end_timestamp', 'email_buyer_id' ), $_SERVER['REQUEST_URI'] ); ?>
  244. </p></div>
  245. <?php
  246. }
  247. }
  248. ?>