VTMIN_Setup_Plugin_Options

Based on code from the following: (example is a tabbed settings page) http://wp.tutsplus.com/series/the-complete-guide-to-the-wordpress-settings-api/ (code at https://github.com/tommcfarlin/WordPress-Settings-Sandbox) http://www.chipbennett.net/2011/02/17/incorporating-the-settings-api-in-wordpress-themes/?all=1 http://www.presscoders.com/2010/05/wordpress-settings-api-explained/.

Defined (1)

The class is defined in the following location(s).

/admin/vtmin-setup-options.php  
  1. class VTMIN_Setup_Plugin_Options {  
  2.  
  3. public function __construct() {  
  4.  
  5. add_action( 'admin_init', array( &$this, 'vtmin_initialize_options' ) ); 
  6. add_action( 'admin_menu', array( &$this, 'vtmin_add_admin_menu_setup_items' ) ); 
  7.  
  8. }  
  9.  
  10.  
  11. function vtmin_add_admin_menu_setup_items() { 
  12. // add items to the minimum purchase custom post type menu structure 
  13. add_submenu_page( 
  14. 'edit.php?post_type=vtmin-rule', // The ID of the top-level menu page to which this submenu item belongs 
  15. __( 'Rules Options Settings', 'vtmin' ), // The value used to populate the browser's title bar when the menu page is active  
  16. __( 'Rules Options Settings', 'vtmin' ), // The label of this submenu item displayed in the menu 
  17. 'administrator', // What roles are able to access this submenu item 
  18. 'vtmin_setup_options_page', // The slug used to represent this submenu item 
  19. array( &$this, 'vtmin_setup_options_cntl' ) // The callback function used to render the options for this submenu item 
  20. ); 
  21.  
  22. if(!defined('VTMIN_PRO_DIRNAME')) { //update to pro version... 
  23. add_submenu_page( 
  24. 'edit.php?post_type=vtmin-rule', // The ID of the top-level menu page to which this submenu item belongs 
  25. __( 'Upgrade to Minimum Purchase Pro', 'vtmin' ), // The value used to populate the browser's title bar when the menu page is active  
  26. __( 'Upgrade to Pro', 'vtmin' ), // The label of this submenu item displayed in the menu 
  27. 'administrator', // What roles are able to access this submenu item 
  28. 'vtmin_pro_upgrade', // The slug used to represent this submenu item 
  29. array( &$this, 'vtmin_pro_upgrade_cntl' ) // The callback function used to render the options for this submenu item 
  30. ); 
  31. }  
  32.  
  33. //v1.09.1 begin 
  34. //Add a DUPLICATE custom tax URL to be in the main Pricing Deals menu as well as in the PRODUCT menu 
  35. //post_type=product => PARENT plugin post_type 
  36. add_submenu_page( 
  37. 'edit.php?post_type=vtmin-rule', // The ID of the top-level menu page to which this submenu item belongs 
  38. __( 'Minimum Purchase Categories', 'vtmin' ), // The value used to populate the browser's title bar when the menu page is active  
  39. __( 'Minimum Purchase Categories', 'vtmin' ), // The label of this submenu item displayed in the menu 
  40. 'administrator', // What roles are able to access this submenu item 
  41. 'edit-tags.php?taxonomy=vtmin_rule_category&post_type=product', // The slug used to represent this submenu item 
  42. // PARENT PLUGIN POST TYPE  
  43. '' // NO CALLBACK FUNCTION REQUIRED 
  44. ); 
  45. //v1.09.1 end  
  46. }  
  47.  
  48. function vtmin_pro_upgrade_cntl() { 
  49.  
  50. //PRO UPGRADE PAGE 
  51. ?> 
  52. <style type="text/css"> 
  53. #upgrade-div { 
  54. float: left; 
  55. margin:40px 0 0 100px; 
  56. /* width: 2.5%; */ 
  57. border: 1px solid #CCCCCC; 
  58. border-radius: 5px 5px 5px 5px; 
  59. padding: 15px; 
  60. font-size:14px; 
  61. width:500px; 
  62. #upgrade-div h3, #upgrade-div h4 {margin-left:20px;} 
  63. #upgrade-div ul {list-style-type: square;margin-left:50px;} 
  64. #upgrade-div ul li {font-size:16px;} 
  65. #upgrade-div a {font-size:16px; margin-left:23%;font-weight: bold;}  
  66. </style> 
  67.  
  68. <div class="wrap"> 
  69. <div id="icon-themes" class="icon32"></div> 
  70.  
  71. <h2><?php esc_attr_e('Upgrade to Minimum Purchase Pro', 'vtmin'); ?></h2> 
  72.  
  73. <div id="upgrade-div"> 
  74. <h3><?php _e('Minimum Purchase Pro offers considerable versatility in creating minimum purchase rules.', 'vtmin') ?></h3> 
  75. <h4><?php _e('In Minimum Purchase Pro, you can choose to apply the rule to:', 'vtmin') ?></h4> 
  76. <ul> 
  77. <li><?php _e('the entire contents of the cart.', 'vtmin') ?></li> 
  78. <li><?php _e('an individual product.', 'vtmin') ?></li> 
  79. <li><?php _e('the variations for an individual product.', 'vtmin') ?></li> 
  80. <li><?php _e('those products in a particular Product category or group of categories.', 'vtmin') ?></li> 
  81. <li><?php _e('those products in a particular Minumum Purchase category or group of categories. (particularly useful if you need to define a group outside of existing Product Categories)', 'vtmin') ?></li> 
  82. <li><?php _e('Membership Status, inclusive or exclusive of category participation.', 'vtmin') ?></li> 
  83. <li><?php _e('<em>Set cumulative lifetime limits on rule purchases by customer.</em>', 'vtmin') ?></li> 
  84. </ul> 
  85. <a href=" <?php echo VTMIN_PURCHASE_PRO_VERSION_BY_PARENT ; ?> " title="Access Plugin Documentation"> Upgrade to Minimum Purchase Pro</a>  
  86. </div>  
  87. </div> 
  88.  
  89. <?php 
  90.  
  91. /** 
  92. * Renders a simple page to display for the menu item added above. 
  93. */ 
  94. function vtmin_setup_options_cntl() { 
  95. //add help tab to this screen... 
  96. //$vtmin_backbone->vtmin_add_help_tab (); 
  97. $content = '<br><a href="' . VTMIN_DOCUMENTATION_PATH . '" title="Access Plugin Documentation">Access Plugin Documentation</a>'; 
  98. $screen = get_current_screen(); 
  99. $screen->add_help_tab( array(  
  100. 'id' => 'vtmin-help-options', //unique id for the tab 
  101. 'title' => 'Minimum Purchase Options Help', //unique visible title for the tab 
  102. 'content' => $content //actual help text 
  103. ) ); 
  104.  
  105. //OPTIONS PAGE 
  106. ?> 
  107. <style type="text/css"> 
  108. .form-table th { 
  109. width: 350px; 
  110. .form-table td { 
  111. padding: 8px 30px; 
  112. #help-all {font-size: 12px; text-decoration:none; border: 1px solid #DFDFDF; padding:3px;} 
  113. #help-all span {font-style:normal; text-decoration:underline; font-weight:normal;} 
  114. .help-anchor {margin-left:30px;} 
  115. .help-text {display:none; font-style:italic; } 
  116. h3 {margin-top:40px;} 
  117. h4 {font-style:italic;} 
  118. .form-table, h4 {margin-left:30px;font-size:14px;} 
  119. .form-table td p {width: 95%;} 
  120. #nuke-rules-button, #nuke-cats-button, #nuke-hist-button, #repair-button {color:red; margin-left:30px} 
  121. #nuke-rules-button:hover, #nuke-cats-button:hover, #nuke-hist-button:hover, #repair-button:hover {cursor:hand; cursor:pointer; font-weight:bold;} 
  122.  
  123. #system-info-title {float:left; margin-top:70px;} 
  124. .system-info-subtitle {clear:left;float:left;} 
  125. .system-info {float:left;margin-bottom:15px; margin-left:30px;} 
  126. .system-info-line {width:95%; float:left; margin-bottom:10px;} 
  127. .system-info-label {width:40%; float:left; font-style:italic;} 
  128. .system-info-data {width:60%; float:left; font-weight:bold;} 
  129. #custom_error_msg_css_at_checkout {width:500px;height:100px;} 
  130. </style> 
  131.  
  132. <script type="text/javascript" language="JavaScript">  
  133. jQuery(document).ready(function($) { 
  134. $("#help-all").click(function() { 
  135. $(".help-text").toggle("slow");  
  136. }); 
  137. $("#help1").click(function() { 
  138. $("#help1-text").toggle("slow");  
  139. }); 
  140. $("#help2").click(function() { 
  141. $("#help2-text").toggle("slow");  
  142. }); 
  143. $("#help3").click(function() { 
  144. $("#help3-text").toggle("slow");  
  145. });  
  146. $("#help4").click(function() { 
  147. $("#help4-text").toggle("slow");  
  148. }); 
  149. $("#help5").click(function() { 
  150. $("#help5-text").toggle("slow");  
  151. }); 
  152. $("#help6").click(function() { 
  153. $("#help6-text").toggle("slow");  
  154. });  
  155. $("#help7").click(function() { 
  156. $("#help7-text").toggle("slow");  
  157. });  
  158. $("#help8").click(function() { 
  159. $("#help8-text").toggle("slow");  
  160. });  
  161. $("#help9").click(function() { 
  162. $("#help9-text").toggle("slow");  
  163. });  
  164. $("#help10").click(function() { 
  165. $("#help10-text").toggle("slow");  
  166. }); 
  167. $("#help11").click(function() { 
  168. $("#help11-text").toggle("slow");  
  169. }); 
  170. $("#help12").click(function() { 
  171. $("#help12-text").toggle("slow");  
  172. }); 
  173. $("#help13").click(function() { 
  174. $("#help13-text").toggle("slow");  
  175. }); 
  176. $("#help14").click(function() { 
  177. $("#help14-text").toggle("slow");  
  178. }); 
  179. $("#help15").click(function() { 
  180. $("#help15-text").toggle("slow");  
  181. }); 
  182. $("#help16").click(function() { 
  183. $("#help16-text").toggle("slow");  
  184. }); 
  185. $("#help17").click(function() { 
  186. $("#help17-text").toggle("slow");  
  187. }); 
  188. $("#help18").click(function() { 
  189. $("#help18-text").toggle("slow");  
  190. }); 
  191. $("#help19").click(function() { 
  192. $("#help19-text").toggle("slow");  
  193. }); 
  194. $("#help20").click(function() { 
  195. $("#help20-text").toggle("slow");  
  196. }); 
  197.  
  198. });  
  199.  
  200. </script> 
  201.  
  202. <?php 
  203. if(!defined('VTMIN_PRO_DIRNAME')) {  
  204. // ********************************************** 
  205. // also disable and grey out options on free version 
  206. // ********************************************** 
  207. ?> 
  208. <style type="text/css"> 
  209. #show_prodcat,  
  210. #show_rulecat 
  211. {color:#aaa;} /*grey out unavailable choices*/ 
  212. </style> 
  213. <script type="text/javascript"> 
  214. jQuery.noConflict(); 
  215. jQuery(document).ready(function($) {  
  216. // To disable  
  217. // $('.someElement').attr('disabled', 'disabled');  
  218. $('#show_prodcat').attr('disabled', 'disabled'); 
  219. $('#show_rulecat').attr('disabled', 'disabled'); 
  220.  
  221. }); //end ready function  
  222. </script> 
  223. <?php } ?> 
  224.  
  225. <div class="wrap"> 
  226. <div id="icon-themes" class="icon32"></div> 
  227.  
  228. <h2> 
  229. <?php  
  230. if(defined('VTMIN_PRO_DIRNAME')) {  
  231. esc_attr_e('Minimum Purchase Pro Options', 'vtmin');  
  232. } else { 
  233. esc_attr_e('Minimum Purchase Options', 'vtmin');  
  234. }  
  235. ?>  
  236. </h2> 
  237.  
  238. <?php settings_errors(); ?> 
  239.  
  240. <?php  
  241. /**if ( isset( $_GET['settings-updated'] ) ) { 
  242. echo "<div class='updated'><p>Theme settings updated successfully.</p></div>"; 
  243. } */ 
  244. ?> 
  245.  
  246. <form method="post" action="options.php"> 
  247. <?php 
  248. //WP functions to execute the registered settings! 
  249. settings_fields( 'vtmin_setup_options_group' ); //activates the field settings setup below 
  250. do_settings_sections( 'vtmin_setup_options_page' ); //activates the section settings setup below  
  251.  
  252. submit_button();  
  253. ?> 
  254.  
  255. <input name="vtmin_setup_options[options-reset]" type="submit" class="button-secondary" value="<?php esc_attr_e('Reset to Defaults', 'vtmin'); ?>" /> 
  256.  
  257. <p id="system-buttons"> 
  258. <h3><?php esc_attr_e('Minimum Purchase Rules Repair and Delete Buttons', 'vtmin'); ?></h3>  
  259. <h4><?php esc_attr_e('Repair reknits the Rules Custom Post Type with the Minimum Purchase rules option array, if out of sync.', 'vtmin'); ?></h4>  
  260. <input id="repair-button" name="vtmin_setup_options[rules-repair]" type="submit" class="button-fourth" value="<?php esc_attr_e('Repair Rules Structures', 'vtmin'); ?>" />  
  261. <h4><?php esc_attr_e('Nuke Rules deletes all Minimum Purchase Rules.', 'vtmin'); ?></h4> 
  262. <input id="nuke-rules-button" name="vtmin_setup_options[rules-nuke]" type="submit" class="button-third" value="<?php esc_attr_e('Nuke all Rules', 'vtmin'); ?>" /> 
  263. <h4><?php esc_attr_e('Nuke Rule Cats deletes all Minimum Purchase Rule Categories', 'vtmin'); ?></h4> 
  264. <input id="nuke-cats-button" name="vtmin_setup_options[cats-nuke]" type="submit" class="button-fifth" value="<?php esc_attr_e('Nuke all Rule Cats', 'vtmin'); ?>" /> 
  265. </p>  
  266. </form> 
  267.  
  268.  
  269. <?php  
  270. global $vtmin_setup_options, $wp_version; 
  271. $vtmin_setup_options = get_option( 'vtmin_setup_options' );  
  272. $vtmin_functions = new VTMIN_Functions; 
  273. $your_system_info = $vtmin_functions->vtmin_getSystemMemInfo(); 
  274. ?> 
  275.  
  276. <h3 id="system-info-title">Plugin Info</h3> 
  277.  
  278. <h4 class="system-info-subtitle">System Info</h4> 
  279. <span class="system-info"> 
  280. <span class="system-info-line"><span class="system-info-label">FREE_VERSION: </span> <span class="system-info-data"><?php echo VTMIN_VERSION; ?></span> </span> 
  281. <span class="system-info-line"><span class="system-info-label">FREE_LAST_UPDATE_DATE: </span> <span class="system-info-data"><?php echo VTMIN_LAST_UPDATE_DATE; ?></span></span> 
  282. <span class="system-info-line"><span class="system-info-label">FREE_DIRNAME: </span> <span class="system-info-data"><?php echo VTMIN_DIRNAME; ?></span></span> 
  283. <span class="system-info-line"><span class="system-info-label">URL: </span> <span class="system-info-data"><?php echo VTMIN_URL; ?></span></span> 
  284. <span class="system-info-line"><span class="system-info-label">EARLIEST_ALLOWED_WP_VERSION: </span> <span class="system-info-data"><?php echo VTMIN_EARLIEST_ALLOWED_WP_VERSION; ?></span></span> 
  285. <span class="system-info-line"><span class="system-info-label">WP VERSION: </span> <span class="system-info-data"><?php echo $wp_version; ?></span> </span> 
  286. <span class="system-info-line"><span class="system-info-label">EARLIEST_ALLOWED_PHP_VERSION: </span> <span class="system-info-data"><?php echo VTMIN_EARLIEST_ALLOWED_PHP_VERSION ;?></span> </span> 
  287. <span class="system-info-line"><span class="system-info-label">FREE_PLUGIN_SLUG: </span> <span class="system-info-data"><?php echo VTMIN_PLUGIN_SLUG; ?></span></span> 
  288. </span>  
  289.  
  290. <h4 class="system-info-subtitle">Parent Plugin Info</h4> 
  291. <span class="system-info"> 
  292. <span class="system-info-line"><span class="system-info-label">PARENT_PLUGIN_NAME: </span> <span class="system-info-data"><?php echo VTMIN_PARENT_PLUGIN_NAME; ?></span> </span> 
  293. <span class="system-info-line"><span class="system-info-label">EARLIEST_ALLOWED_PARENT_VERSION: </span> <span class="system-info-data"><?php echo VTMIN_EARLIEST_ALLOWED_PARENT_VERSION; ?></span></span> 
  294.  
  295. <?php if(defined('WPSC_VERSION') && (VTMIN_PARENT_PLUGIN_NAME == 'WP E-Commerce') ) { ?> 
  296. <span class="system-info-line"><span class="system-info-label">PARENT_VERSION (WPSC): </span> <span class="system-info-data"><?php echo WPSC_VERSION; ?></span></span> 
  297. <?php } ?> 
  298.  
  299. <?php if(defined('WOOCOMMERCE_VERSION') && (VTMIN_PARENT_PLUGIN_NAME == 'WooCommerce')) { ?> 
  300. <span class="system-info-line"><span class="system-info-label">PARENT_VERSION (WOOCOMMERCE): </span> <span class="system-info-data"><?php echo WOOCOMMERCE_VERSION; ?></span></span> 
  301. <?php } ?> 
  302.  
  303. <?php if(defined('JIGOSHOP_VERSION') && (VTMIN_PARENT_PLUGIN_NAME == 'JigoShop')) { ?> 
  304. <span class="system-info-line"><span class="system-info-label">PARENT_VERSION (JIGOSHOP): </span> <span class="system-info-data"><?php echo JIGOSHOP_VERSION; ?></span></span> 
  305. <?php } ?> 
  306.  
  307. <span class="system-info-line"><span class="system-info-label">TESTED_UP_TO_PARENT_VERSION: </span> <span class="system-info-data"><?php echo VTMIN_TESTED_UP_TO_PARENT_VERSION; ?></span></span> 
  308. <span class="system-info-line"><span class="system-info-label">CHECKOUT_PRODUCTS_SELECTOR_BY_PARENT: </span> <span class="system-info-data"><?php echo VTMIN_CHECKOUT_PRODUCTS_SELECTOR_BY_PARENT; ?></span></span> 
  309. <span class="system-info-line"><span class="system-info-label">CHECKOUT_ADDRESS_SELECTOR_BY_PARENT: </span> <span class="system-info-data"><?php echo VTMIN_CHECKOUT_ADDRESS_SELECTOR_BY_PARENT; ?></span></span> 
  310.  
  311. </span>  
  312.  
  313. <?php if (defined('VTMIN_PRO_DIRNAME')) { ?>  
  314. <h4 class="system-info-subtitle">Pro Info</h4> 
  315. <span class="system-info">  
  316. <span class="system-info-line"><span class="system-info-label">PRO_PLUGIN_NAME: </span> <span class="system-info-data"><?php echo VTMIN_PRO_PLUGIN_NAME; ?></span> </span> 
  317. <span class="system-info-line"><span class="system-info-label">PRO_FREE_PLUGIN_NAME: </span> <span class="system-info-data"><?php echo VTMIN_PRO_FREE_PLUGIN_NAME; ?></span> </span> 
  318. <span class="system-info-line"><span class="system-info-label">PRO_VERSION: </span> <span class="system-info-data"><?php echo VTMIN_PRO_VERSION; ?></span> </span> 
  319. <span class="system-info-line"><span class="system-info-label">PRO_LAST_UPDATE_DATE: </span> <span class="system-info-data"><?php echo VTMIN_PRO_LAST_UPDATE_DATE; ?></span></span> 
  320. <span class="system-info-line"><span class="system-info-label">PRO_DIRNAME: </span> <span class="system-info-data"><?php echo VTMIN_PRO_DIRNAME; ?></span></span> 
  321. <span class="system-info-line"><span class="system-info-label">PRO_MINIMUM_REQUIRED_FREE_VERSION: </span> <span class="system-info-data"><?php echo VTMIN_PRO_MINIMUM_REQUIRED_FREE_VERSION; ?></span></span> 
  322. <span class="system-info-line"><span class="system-info-label">PRO_BASE_NAME: </span> <span class="system-info-data"><?php echo VTMIN_PRO_BASE_NAME; ?></span> </span> 
  323. <span class="system-info-line"><span class="system-info-label">PRO_PLUGIN_SLUG: </span> <span class="system-info-data"><?php echo VTMIN_PLUGIN_SLUG; ?></span> </span> 
  324. <span class="system-info-line"><span class="system-info-label">PRO_REMOTE_VERSION_FILE: </span> <span class="system-info-data"><?php echo VTMIN_PRO_REMOTE_VERSION_FILE; ?></span> </span> 
  325. </span>  
  326. <?php } ?>  
  327.  
  328.  
  329. <?php if ( $vtmin_setup_options['debugging_mode_on'] == 'yes' ) { ?>  
  330. <h4 class="system-info-subtitle">Debug Info</h4> 
  331. <span class="system-info">  
  332. <span class="system-info-line"><span class="system-info-label">PHP VERSION: </span> <span class="system-info-data"><?php echo phpversion(); ?></span> </span> 
  333. <span class="system-info-line"><span class="system-info-label">SYSTEM MEMORY: </span> <span class="system-info-data"><?php echo '<pre>'.print_r( $your_system_info , true).'</pre>' ; ?></span> </span>  
  334. <span class="system-info-line"><span class="system-info-label">Setup Options: </span> <span class="system-info-data"><?php echo '<pre>'.print_r( $vtmin_setup_options , true).'</pre>' ; ?></span> </span>  
  335. </span> 
  336. <?php } ?> 
  337. </div><!-- /.wrap --> 
  338.  
  339. <?php 
  340. } // end vtmin_display  
  341.  
  342.  
  343. /** ------------------------------------------------------------------------ * 
  344. * Setting Registration 
  345. * ------------------------------------------------------------------------ */  
  346.  
  347. /** 
  348. * Initializes the theme's display options page by registering the Sections,  
  349. * Fields, and Settings. 
  350. * This function is registered with the 'admin_init' hook. 
  351. */  
  352.  
  353. function vtmin_initialize_options() { 
  354.  
  355. // If the theme options don't exist, create them. 
  356. if( false == get_option( 'vtmin_setup_options' ) ) { 
  357. add_option( 'vtmin_setup_options', $this->vtmin_get_default_options() ); //add the option into the table based on the default values in the function. 
  358. } // end if 
  359.  
  360.  
  361. //**************************** 
  362. // DISPLAY OPTIONS Area 
  363. //**************************** 
  364.  
  365. // First, we register a section. This is necessary since all future options must belong to a  
  366. add_settings_section( 
  367. 'general_settings_section', // ID used to identify this section and with which to register options 
  368. __( 'Display Options', 'vtmin' ), // Title to be displayed on the administration page 
  369. array(&$this, 'vtmin_general_options_callback'), // Callback used to render the description of the section 
  370. 'vtmin_setup_options_page' // Page on which to add this section of options 
  371. ); 
  372.  
  373. // show error msg = yes/no 
  374. add_settings_field( //opt1 
  375. 'show_error_messages_in_table_form', // ID used to identify the field throughout the theme 
  376. __( 'Show Error Messages in Table Format ("no" = text format)', 'vtmin' ), // The label to the left of the option interface element  
  377. array(&$this, 'vtmin_error_in_table_format_callback'), // The name of the function responsible for rendering the option interface 
  378. 'vtmin_setup_options_page', // The page on which this option will be displayed 
  379. 'general_settings_section', // The name of the section to which this field belongs 
  380. array( // The array of arguments to pass to the callback. In this case, just a description. 
  381. __( 'Error messages can be shown in table formats.', 'vtmin' ) 
  382. );  
  383.  
  384. /** //v1.09.5 REMOVED - all messages now use WOO messaging, so these are redundant  
  385. // show error msg = yes/no 
  386. add_settings_field( //opt2 
  387. 'show_error_before_checkout_products', // ID used to identify the field throughout the theme 
  388. __( 'Show Error Messages Just Before Checkout Products List', 'vtmin' ), // The label to the left of the option interface element  
  389. array(&$this, 'vtmin_before_checkout_products_callback'), // The name of the function responsible for rendering the option interface 
  390. 'vtmin_setup_options_page', // The page on which this option will be displayed 
  391. 'general_settings_section', // The name of the section to which this field belongs 
  392. array( // The array of arguments to pass to the callback. In this case, just a description. 
  393. __( 'Error messages are shown in one place at checkout by default.', 'vtmin' ) 
  394. ); 
  395. // customize error selector 1 
  396. add_settings_field( //opt11 
  397. 'show_error_before_checkout_products_selector', // ID used to identify the field throughout the theme 
  398. __( 'Show Error Messages Just Before Checkout Products List - HTML Selector <em>(see => "more info")</em>', 'vtmin' ), // The label to the left of the option interface element 
  399. array(&$this, 'vtmin_before_checkout_products_selector_callback'), // The name of the function responsible for rendering the option interface 
  400. 'vtmin_setup_options_page', // The page on which this option will be displayed 
  401. 'general_settings_section', // The name of the section to which this field belongs 
  402. array( // The array of arguments to pass to the callback. In this case, just a description. 
  403. __( 'For the Product area, Supplies the ID or Class HTML selector this message appears before', 'vtmin' ) 
  404. ); 
  405. // show error msg = yes/no 
  406. add_settings_field( //opt3 
  407. 'show_error_before_checkout_address', // ID used to identify the field throughout the theme 
  408. __( 'Show 2nd Set of Error Messages at Checkout Address Area', 'vtmin' ), // The label to the left of the option interface element 
  409. array(&$this, 'vtmin_before_checkout_address_callback'), // The name of the function responsible for rendering the option interface 
  410. 'vtmin_setup_options_page', // The page on which this option will be displayed 
  411. 'general_settings_section', // The name of the section to which this field belongs 
  412. array( // The array of arguments to pass to the callback. In this case, just a description. 
  413. __( 'Error messages are shown in one place at checkout by default.', 'vtmin' ) 
  414. ); 
  415. // customize error selector 2 
  416. add_settings_field( //opt12 
  417. 'show_error_before_checkout_address_selector', // ID used to identify the field throughout the theme 
  418. __( 'Show Error Messages Just Before Checkout Address List - HTML Selector <em>(see => "more info")</em>', 'vtmin' ), // The label to the left of the option interface element 
  419. array(&$this, 'vtmin_before_checkout_address_selector_callback'), // The name of the function responsible for rendering the option interface 
  420. 'vtmin_setup_options_page', // The page on which this option will be displayed 
  421. 'general_settings_section', // The name of the section to which this field belongs 
  422. array( // The array of arguments to pass to the callback. In this case, just a description. 
  423. __( 'For the Address area, Supplies the ID or Class HTML selector this message appears before', 'vtmin' ) 
  424. ); 
  425.  
  426. */ 
  427.  
  428. // show vtmin ID = yes/no 
  429. add_settings_field( //opt10 
  430. 'show_rule_ID_in_errmsg', // ID used to identify the field throughout the theme 
  431. __( 'Show Rule ID in Error Message', 'vtmin' ), // The label to the left of the option interface element 
  432. array(&$this, 'vtmin_rule_ID_in_errmsg_callback'), // The name of the function responsible for rendering the option interface 
  433. 'vtmin_setup_options_page', // The page on which this option will be displayed 
  434. 'general_settings_section', // The name of the section to which this field belongs 
  435. array( // The array of arguments to pass to the callback. In this case, just a description. 
  436. __( 'Show minimum amount rule id in error message.', 'vtmin' ) 
  437. ); 
  438. // show prod cats = yes/no 
  439. add_settings_field( //opt4 
  440. 'show_prodcat_names_in_errmsg', // ID used to identify the field throughout the theme 
  441. __( 'Show Product Category Names in Minimum Purchase Error Message (Pro Only)', 'vtmin' ), // The label to the left of the option interface element 
  442. array(&$this, 'vtmin_prodcat_names_callback'), // The name of the function responsible for rendering the option interface 
  443. 'vtmin_setup_options_page', // The page on which this option will be displayed 
  444. 'general_settings_section', // The name of the section to which this field belongs 
  445. array( // The array of arguments to pass to the callback. In this case, just a description. 
  446. __( 'If Product Categories are used, show their names in any error messages based on the search criteria.', 'vtmin' ) 
  447. )  
  448. ); 
  449. // show rule cats = yes/no 
  450. add_settings_field( //opt5 
  451. 'show_rulecat_names_in_errmsg', // ID used to identify the field throughout the theme 
  452. __( 'Show Rule Category Names in Minimum Purchase Error Message (Pro Only)', 'vtmin' ), // The label to the left of the option interface element 
  453. array(&$this, 'vtmin_rulecat_names_callback'), // The name of the function responsible for rendering the option interface 
  454. 'vtmin_setup_options_page', // The page on which this option will be displayed 
  455. 'general_settings_section', // The name of the section to which this field belongs 
  456. array( // The array of arguments to pass to the callback. In this case, just a description. 
  457. __( 'If Rule Categories are used, show their names in any error messages based on the search criteria.', 'vtmin' ) 
  458. );  
  459. // custom error msg css at checkout time 
  460. add_settings_field( //opt9 
  461. 'custom_error_msg_css_at_checkout', // ID used to identify the field throughout the theme 
  462. __( 'Custom Minimum Purchase Error Message CSS, used at checkout time', 'vtmin' ), // The label to the left of the option interface element 
  463. array(&$this, 'vtmin_custom_error_msg_css_at_checkout_callback'), // The name of the function responsible for rendering the option interface 
  464. 'vtmin_setup_options_page', // The page on which this option will be displayed 
  465. 'general_settings_section', // The name of the section to which this field belongs 
  466. array( // The array of arguments to pass to the callback. In this case, just a description. 
  467. __( 'Realtime CSS override for minimum amount error messages shown at checkout time. Supply CSS statements only.', 'vtmin' ) 
  468. ); 
  469. //v1.09.5 NEW  
  470. /** 
  471.  
  472. THIS IS COMMENTED because the add-to-cart is not working realtime,  
  473. and confusion reigns if an error box is already displayed and doesn't reflect the new totals 
  474.  
  475.  
  476. // custom error msg css at checkout time 
  477. add_settings_field( //opt13 'show_errors_on_all_pages' 
  478. 'show_errors_on_all_pages', // ID used to identify the field throughout the theme 
  479. __( 'Show Errors on all Pages', 'vtmin' ), // The label to the left of the option interface element 
  480. array(&$this, 'vtmin_show_errors_on_all_pages_callback'), // The name of the function responsible for rendering the option interface 
  481. 'vtmin_setup_options_page', // The page on which this option will be displayed 
  482. 'general_settings_section', // The name of the section to which this field belongs 
  483. array( // The array of arguments to pass to the callback. In this case, just a description. 
  484. __( 'Show errors only at checkout, or on all pages', 'vtmin' ) 
  485. ); 
  486. */ 
  487.  
  488. //**************************** 
  489. // PROCESSING OPTIONS Area 
  490. //**************************** 
  491.  
  492. add_settings_section( 
  493. 'processing_settings_section', // ID used to identify this section and with which to register options 
  494. __( 'Processing Options', 'vtmin' ), // Title to be displayed on the administration page 
  495. array(&$this, 'vtmin_processing_options_callback'), // Callback used to render the description of the section 
  496. 'vtmin_setup_options_page' // Page on which to add this section of options 
  497. ); 
  498.  
  499. /** v1.07  
  500. add_settings_field( //opt6 
  501. 'use_this_currency_sign', // ID used to identify the field throughout the theme 
  502. __( 'Select a Currency Sign', 'vtmin' ), // The label to the left of the option interface element 
  503. array(&$this, 'vtmin_currency_sign_callback'), // The name of the function responsible for rendering the option interface 
  504. 'vtmin_setup_options_page', // The page on which this option will be displayed 
  505. 'processing_settings_section', // The name of the section to which this field belongs 
  506. array( // The array of arguments to pass to the callback. In this case, just a description. 
  507. __( 'Select a Currency Sign.', 'vtmin' ) 
  508. );  
  509. */  
  510. add_settings_field( //opt7 
  511. 'apply_multiple_rules_to_product', // ID used to identify the field throughout the theme 
  512. __( 'Apply More Than 1 Rule to Each Product', 'vtmin' ), // The label to the left of the option interface element 
  513. array(&$this, 'vtmin_mult_rules_processing_callback'), // The name of the function responsible for rendering the option interface 
  514. 'vtmin_setup_options_page', // The page on which this option will be displayed 
  515. 'processing_settings_section', // The name of the section to which this field belongs 
  516. array( // The array of arguments to pass to the callback. In this case, just a description. 
  517. __( 'Do we apply multiple rules to a given product?', 'vtmin' ) 
  518. );  
  519.  
  520.  
  521.  
  522.  
  523. //**************************** 
  524. // SYSTEM AND DEBUG OPTIONS Area 
  525. //**************************** 
  526.  
  527. add_settings_section( 
  528. 'internals_settings_section', // ID used to identify this section and with which to register options 
  529. __( 'System and Debug Options', 'vtmin' ), // Title to be displayed on the administration page 
  530. array(&$this, 'vtmin_internals_options_callback'), // Callback used to render the description of the section 
  531. 'vtmin_setup_options_page' // Page on which to add this section of options 
  532. ); 
  533.  
  534. add_settings_field( //opt8 
  535. 'debugging_mode_on', // ID used to identify the field throughout the theme 
  536. __( 'Test Debugging Mode Turned On <br>(Use Only during testing)', 'vtmin' ), // The label to the left of the option interface element 
  537. array(&$this, 'vtmin_debugging_mode_callback'), // The name of the function responsible for rendering the option interface 
  538. 'vtmin_setup_options_page', // The page on which this option will be displayed 
  539. 'internals_settings_section', // The name of the section to which this field belongs 
  540. array( // The array of arguments to pass to the callback. In this case, just a description. 
  541. __( 'Show any built-in debug info for Rule processing.', 'vtmin' ) 
  542. );  
  543. /**  
  544.  
  545. */ 
  546.  
  547. // Finally, we register the fields with WordPress 
  548. register_setting( 
  549. 'vtmin_setup_options_group',  
  550. 'vtmin_setup_options' ,  
  551. array(&$this, 'vtmin_validate_setup_input') 
  552. ); 
  553.  
  554. } // end vtmin_initialize_options 
  555.  
  556.  
  557. //**************************** 
  558. // DEFAULT OPTIONS INITIALIZATION 
  559. //**************************** 
  560. function vtmin_get_default_options() { 
  561. $options = array( 
  562. 'show_error_messages_in_table_form' => 'yes', //opt1 
  563. 'show_error_before_checkout_products' => 'yes', //opt2 
  564. 'show_error_before_checkout_address' => 'yes', //opt3 
  565. 'show_prodcat_names_in_errmsg' => 'no', //opt4 
  566. 'show_rulecat_names_in_errmsg' => 'no', //opt5 
  567. 'use_this_currency_sign' => 'USD', //opt6 
  568. 'apply_multiple_rules_to_product' => 'no', //opt7 
  569. 'debugging_mode_on' => 'no', //opt8 
  570. 'custom_error_msg_css_at_checkout' => '', //opt9 
  571. 'show_rule_ID_in_errmsg' => 'yes', //opt10 
  572. 'show_error_before_checkout_products_selector' => VTMIN_CHECKOUT_PRODUCTS_SELECTOR_BY_PARENT, //opt11 
  573. 'show_error_before_checkout_address_selector' => VTMIN_CHECKOUT_ADDRESS_SELECTOR_BY_PARENT, //opt12 
  574. 'show_errors_on_all_pages' => 'no' //opt13 //v1.09.5 NEW 
  575. ); 
  576. return $options; 
  577.  
  578. function vtmin_processing_options_callback () { 
  579. ?> 
  580. <h4><?php esc_attr_e('These options control rule error processing during checkout.', 'vtmin'); ?></h4> 
  581. <?php  
  582.  
  583. function vtmin_lifetime_rule_options_callback () { 
  584. ?> 
  585. <h4><?php esc_attr_e('Lifetime rule Options apply to Lifetime Customer Max Purchases. (Lifetime processing rules are available with the Pro version)', 'vtmin'); ?></h4> 
  586. <h4><?php esc_attr_e('These options control how comparisons are made, to see if a customer has purchased products associated with a given rule prior to the current purchase.', 'vtmin'); ?></h4> 
  587.  
  588. <?php  
  589.  
  590. function vtmin_general_options_callback () { 
  591. ?> 
  592. <h4><?php esc_attr_e('These options control rule error message display at checkout time.', 'vtmin'); ?>  
  593. <a id="help-all" class="help-anchor" href="javascript:void(0);" > 
  594. <?php esc_attr_e('Show All:', 'vtmin'); ?>  
  595.   <span> <?php esc_attr_e('More Info', 'vtmin'); ?> </span></a>  
  596. </h4>  
  597. <?php 
  598.  
  599. function vtmin_internals_options_callback () { 
  600. ?> 
  601. <h4><?php esc_attr_e('These options control internal functions within the plugin.', 'vtmin'); ?></h4> 
  602. <?php  
  603.  
  604.  
  605.  
  606.  
  607. function vtmin_before_checkout_products_callback() { //opt2 
  608. $options = get_option( 'vtmin_setup_options' );  
  609. $html = '<select id="before_checkout_products" name="vtmin_setup_options[show_error_before_checkout_products]">'; 
  610. $html .= '<option value="yes"' . selected( $options['show_error_before_checkout_products'], 'yes', false) . '>Yes  </option>'; 
  611. $html .= '<option value="no"' . selected( $options['show_error_before_checkout_products'], 'no', false) . '>No  </option>'; 
  612. $html .= '</select>'; 
  613.  
  614. $more_info = __('More Info', 'vtmin'); 
  615. $html .= '<a id="help2" class="help-anchor" href="javascript:void(0);" >' ; $html .= $more_info; $html .= '</a>'; 
  616.  
  617. $html .= '<p id="help2-text" class = "help-text" >';  
  618. $help = __('"Show Error Messages Just Before Checkout Products List" => This is the standard place to show the error messages, just above the product list area.', 'vtmin');  
  619. $html .= $help; 
  620. $html .= '</p>'; 
  621.  
  622. echo $html; 
  623.  
  624. function vtmin_before_checkout_address_callback() { //opt3 
  625. $options = get_option( 'vtmin_setup_options' );  
  626. $html = '<select id="before_checkout_adress" name="vtmin_setup_options[show_error_before_checkout_address]">'; 
  627. $html .= '<option value="yes"' . selected( $options['show_error_before_checkout_address'], 'yes', false) . '>Yes  </option>'; 
  628. $html .= '<option value="no"' . selected( $options['show_error_before_checkout_address'], 'no', false) . '>No  </option>'; 
  629. $html .= '</select>'; 
  630.  
  631. $more_info = __('More Info', 'vtmin'); 
  632. $html .= '<a id="help3" class="help-anchor" href="javascript:void(0);" >' ; $html .= $more_info; $html .= '</a>'; 
  633.  
  634. $html .= '<p id="help3-text" class = "help-text" >';  
  635. $help = __('"Show Error Messages Just Before Checkout Address Area" => This is the second  
  636. (duplicate) place to show error messages, just above the address area. It is particularly useful  
  637. if your checkout has multiple panes or pages, rather than a single full-display screen', 'vtmin');  
  638. $html .= $help; 
  639. $html .= '</p>'; 
  640.  
  641. echo $html; 
  642.  
  643. function vtmin_rulecat_names_callback () { //opt5 
  644. $options = get_option( 'vtmin_setup_options' );  
  645. $html = '<select id="show_rulecat" name="vtmin_setup_options[show_rulecat_names_in_errmsg]">'; 
  646. $html .= '<option value="yes"' . selected( $options['show_rulecat_names_in_errmsg'], 'yes', false) . '>Yes  </option>'; 
  647. $html .= '<option value="no"' . selected( $options['show_rulecat_names_in_errmsg'], 'no', false) . '>No  </option>'; 
  648. $html .= '</select>'; 
  649.  
  650. $more_info = __('More Info', 'vtmin'); 
  651. $html .= '<a id="help5" class="help-anchor" href="javascript:void(0);" >' ; $html .= $more_info; $html .= '</a>'; 
  652.  
  653. $html .= '<p id="help5-text" class = "help-text" >';  
  654. $help = __('"Show Minimum Purchase Rule Category Names in Error Message (Pro Only)" =>  
  655. If you choose to use the group input search criteria option, and if you employ a Minimum Purchase Category to group the products, you can choose here  
  656. whether to include that Rule category name in any error messages produced.', 'vtmin');  
  657. $html .= $help; 
  658. $html .= '</p>';  
  659.  
  660. echo $html; 
  661.  
  662.  
  663. function vtmin_debugging_mode_callback () { //opt8 
  664. $options = get_option( 'vtmin_setup_options' );  
  665. $html = '<select id="debugging-mode" name="vtmin_setup_options[debugging_mode_on]">'; 
  666. $html .= '<option value="yes"' . selected( $options['debugging_mode_on'], 'yes', false) . '>Yes  </option>'; 
  667. $html .= '<option value="no"' . selected( $options['debugging_mode_on'], 'no', false) . '>No  </option>'; 
  668. $html .= '</select>'; 
  669.  
  670. $more_info = __('More Info', 'vtmin'); 
  671. $html .= '<a id="help8" class="help-anchor" href="javascript:void(0);" >' ; $html .= $more_info; $html .= '</a>'; 
  672.  
  673. $html .= '<p id="help8-text" class = "help-text" >';  
  674. $help = __('"Test Debugging Mode Turned On" =>  
  675. Set this to "yes" if you want to see the full rule structures which produce any error messages. **ONLY** should be used during testing. 
  676. <br><br>NB => IF this switch is SET and the "purchase" button is depressed, the following warning may result: 
  677. <br> "Warning: Cannot modify header information - headers already sent by" ... You will still have debug info available, however. 
  678. ', 'vtmin');  
  679. $html .= $help; 
  680. $html .= '</p>';  
  681.  
  682. echo $html; 
  683.  
  684. function vtmin_prodcat_names_callback () { //opt4 
  685. $options = get_option( 'vtmin_setup_options' );  
  686. $html = '<select id="show_prodcat" name="vtmin_setup_options[show_prodcat_names_in_errmsg]">'; 
  687. $html .= '<option value="yes"' . selected( $options['show_prodcat_names_in_errmsg'], 'yes', false) . '>Yes  </option>'; 
  688. $html .= '<option value="no"' . selected( $options['show_prodcat_names_in_errmsg'], 'no', false) . '>No  </option>'; 
  689. $html .= '</select>'; 
  690.  
  691. $more_info = __('More Info', 'vtmin'); 
  692. $html .= '<a id="help4" class="help-anchor" href="javascript:void(0);" >' ; $html .= $more_info; $html .= '</a>'; 
  693.  
  694. $html .= '<p id="help4-text" class = "help-text" >';  
  695. $help = __('"Show Minimum Purchase Product Category Names in Error Message (Pro Only)" =>  
  696. If you choose to use the group input search criteria option, and if you employ a Minimum Purchase Category to group the products, you can choose here  
  697. whether to include that Product category name in any error messages produced.', 'vtmin');  
  698. $html .= $help; 
  699. $html .= '</p>';  
  700.  
  701. echo $html; 
  702.  
  703. function vtmin_mult_rules_processing_callback() { //opt7 
  704. $options = get_option( 'vtmin_setup_options' );  
  705. $html = '<select id="before_checkout_products" name="vtmin_setup_options[apply_multiple_rules_to_product]">'; 
  706. $html .= '<option value="yes"' . selected( $options['apply_multiple_rules_to_product'], 'yes', false) . '>Yes  </option>'; 
  707. $html .= '<option value="no"' . selected( $options['apply_multiple_rules_to_product'], 'no', false) . '>No  </option>'; 
  708. $html .= '</select>'; 
  709.  
  710. $more_info = __('More Info', 'vtmin'); 
  711. $html .= '<a id="help7" class="help-anchor" href="javascript:void(0);" >' ; $html .= $more_info; $html .= '</a>'; 
  712.  
  713. $html .= '<p id="help7-text" class = "help-text" >';  
  714. $help = __('"Apply More Than 1 Rule to Each Product" => Do we apply multiple minimum purchase rules to EACH product in the cart? If not,  
  715. we apply the FIRST rule we process which applies to a given product. <strong>It is ***Strongly Suggested*** that this option be set to "NO", as otherwise the compounding error messages 
  716. could be quite confusing for the ecommerce customer.</strong>', 'vtmin');  
  717. $html .= $help; 
  718. $html .= '</p>'; 
  719.  
  720. echo $html;  
  721.  
  722. function vtmin_error_in_table_format_callback() { //opt1 
  723. $options = get_option( 'vtmin_setup_options' );  
  724. $html = '<select id="table_format" name="vtmin_setup_options[show_error_messages_in_table_form]">'; 
  725. $html .= '<option value="yes"' . selected( $options['show_error_messages_in_table_form'], 'yes', false) . '>Yes  </option>'; 
  726. $html .= '<option value="no"' . selected( $options['show_error_messages_in_table_form'], 'no', false) . '>No  </option>'; 
  727. $html .= '</select>'; 
  728.  
  729. $more_info = __('More Info', 'vtmin'); 
  730. $html .= '<a id="help1" class="help-anchor" href="javascript:void(0);" >' ; $html .= $more_info; $html .= '</a>'; 
  731.  
  732. $html .= '<p id="help1-text" class = "help-text" >';  
  733. $help = __('"Show Error Messages in Table Format" => Error messages can be shown in text or table format ("yes" = table format, "no" = text format). If table format is desired,  
  734. set this option to "yes". ', 'vtmin');  
  735. $html .= $help; 
  736. $html .= '</p>'; 
  737.  
  738. echo $html; 
  739. /** v1.07 
  740. function vtmin_currency_sign_callback() { //opt6 
  741. $options = get_option( 'vtmin_setup_options' ); 
  742. $html = '<select id="currency_sign" name="vtmin_setup_options[use_this_currency_sign]">'; 
  743. $html .= '<option value="USD"' . selected( $options['use_this_currency_sign'], 'USD', false) . '>$   (Dollar Sign)  </option>'; 
  744. $html .= '<option value="EUR"' . selected( $options['use_this_currency_sign'], 'EUR', false) . '>€   (Euro)  </option>'; 
  745. $html .= '<option value="GBP"' . selected( $options['use_this_currency_sign'], 'GBP', false) . '>£   (Pound Sterling)  </option>'; 
  746. $html .= '<option value="JPY"' . selected( $options['use_this_currency_sign'], 'JPY', false) . '>¥   (Yen)  </option>'; 
  747. $html .= '<option value="CZK"' . selected( $options['use_this_currency_sign'], 'CZK', false) . '>Kč   (Czech Koruna)  </option>'; 
  748. $html .= '<option value="DKK"' . selected( $options['use_this_currency_sign'], 'DKK', false) . '>kr   (Danish Krone)  </option>'; 
  749. $html .= '<option value="HUF"' . selected( $options['use_this_currency_sign'], 'HUF', false) . '>Ft   (Hungarian Forint)  </option>'; 
  750. $html .= '<option value="ILS"' . selected( $options['use_this_currency_sign'], 'ILS', false) . '>₪   (Israeli Shekel)  </option>'; 
  751. $html .= '<option value="MYR"' . selected( $options['use_this_currency_sign'], 'MYR', false) . '>RM   (Malaysian Ringgits)  </option>'; 
  752. $html .= '<option value="NOK"' . selected( $options['use_this_currency_sign'], 'NOK', false) . '>kr   (Norwegian Krone)  </option>'; 
  753. $html .= '<option value="PHP"' . selected( $options['use_this_currency_sign'], 'PHP', false) . '>₱   (Philippine Pesos)  </option>'; 
  754. $html .= '<option value="PLN"' . selected( $options['use_this_currency_sign'], 'PLN', false) . '>zł   (Polish Zloty)  </option>'; 
  755. $html .= '<option value="SEK"' . selected( $options['use_this_currency_sign'], 'SEK', false) . '>kr   (Swedish Krona)  </option>'; 
  756. $html .= '<option value="CHF"' . selected( $options['use_this_currency_sign'], 'CHF', false) . '>CHF   (Swiss Franc)  </option>'; 
  757. $html .= '<option value="TWD"' . selected( $options['use_this_currency_sign'], 'TWD', false) . '>NT$   (Taiwan New Dollars)  </option>'; 
  758. $html .= '<option value="THB"' . selected( $options['use_this_currency_sign'], 'THB', false) . '>฿   (Thai Baht)  </option>'; 
  759. $html .= '<option value="TRY"' . selected( $options['use_this_currency_sign'], 'TRY', false) . '>TL   (Turkish Lira)  </option>'; 
  760. $html .= '<option value="ZAR"' . selected( $options['use_this_currency_sign'], 'ZAR', false) . '>R   (South African Rand)  </option>'; 
  761. $html .= '<option value="RON"' . selected( $options['use_this_currency_sign'], 'RON', false) . '>lei   (Romanian Leu)  </option>'; 
  762. $html .= '</select>'; 
  763.  
  764. $more_info = __('More Info', 'vtmin'); 
  765. $html .= '<a id="help6" class="help-anchor" href="javascript:void(0);" >' ; $html .= $more_info; $html .= '</a>'; 
  766.  
  767. $html .= '<p id="help6-text" class = "help-text" >';  
  768. $help = __('"Select the Currncy Sign for Error Messages" =>  
  769. This currency sign is used whend displaying Minimum Amount rule error messages. If the desired currency symbol is not available, please inform Varktech and  
  770. it will be added.', 'vtmin');  
  771. $html .= $help; 
  772. $html .= '</p>';  
  773.  
  774. echo $html; 
  775. */ 
  776. function vtmin_custom_error_msg_css_at_checkout_callback() { //opt9 
  777. $options = get_option( 'vtmin_setup_options' ); 
  778. $html = '<textarea type="text" id="custom_error_msg_css_at_checkout" rows="200" cols="40" name="vtmin_setup_options[custom_error_msg_css_at_checkout]">' . $options['custom_error_msg_css_at_checkout'] . '</textarea>'; 
  779.  
  780. $more_info = __('More Info', 'vtmin'); 
  781. $html .= '<a id="help9" class="help-anchor" href="javascript:void(0);" >' ; $html .= $more_info; $html .= '</a>'; 
  782.  
  783. $html .= '<p id="help9-text" class = "help-text" >';  
  784. $help = __('"Custom Error Message CSS at Checkout Time" =>  
  785. The CSS used for minimum amount error messages is supplied. If you want to override any of the css, supply just your overrides here. <br>For Example =>  
  786. div.vtmin-error .red-font-italic {color: green;}', 'vtmin');  
  787. $html .= $help; 
  788. $html .= '</p>';  
  789.  
  790. echo $html; 
  791.  
  792.  
  793. function vtmin_rule_ID_in_errmsg_callback() { //opt10 
  794. $options = get_option( 'vtmin_setup_options' );  
  795. $html = '<select id="vtmin-id" name="vtmin_setup_options[show_rule_ID_in_errmsg]">'; 
  796. $html .= '<option value="yes"' . selected( $options['show_rule_ID_in_errmsg'], 'yes', false) . '>Yes  </option>'; 
  797. $html .= '<option value="no"' . selected( $options['show_rule_ID_in_errmsg'], 'no', false) . '>No  </option>'; 
  798. $html .= '</select>'; 
  799.  
  800. $more_info = __('More Info', 'vtmin'); 
  801. $html .= '<a id="help10" class="help-anchor" href="javascript:void(0);" >' ; $html .= $more_info; $html .= '</a>'; 
  802.  
  803. $html .= '<p id="help10-text" class = "help-text" >';  
  804. $help = __('"Show Rule ID in Error Message" => Append the Minimum Amount Rule ID (from the rule entry screen) at the end of 
  805. an error message, to help identify what rule generated the message. ', 'vtmin');  
  806. $html .= $help; 
  807. $html .= '</p>'; 
  808.  
  809. echo $html; 
  810.  
  811.  
  812. function vtmin_before_checkout_products_selector_callback() { //opt11 
  813. $options = get_option( 'vtmin_setup_options' ); 
  814. $html = '<textarea type="text" id="show_error_before_checkout_products_selector" rows="1" cols="20" name="vtmin_setup_options[show_error_before_checkout_products_selector]">' . $options['show_error_before_checkout_products_selector'] . '</textarea>'; 
  815.  
  816. $more_info = __('More Info', 'vtmin'); 
  817. $html .= '<a id="help11" class="help-anchor" href="javascript:void(0);" >' ; $html .= $more_info; $html .= '</a>'; 
  818.  
  819. $html .= '<p id="help11-text" class = "help-text" >';  
  820. $help = __('"Show Error Messages Just Before Checkout Products List - HTML Selector" =>  
  821. <strong>This option controls the location of the message display, ***handle with care***.</strong> For the Product area error message, this option supplies the ID or Class HTML selector this message appears before. This selector would appear in your theme"s checkout area,  
  822. just above the products display area. Be sure to include the "." or "#" selector identifier before the selector name. Default = "' .VTMIN_CHECKOUT_PRODUCTS_SELECTOR_BY_PARENT . '". If you"ve changed this value and can"t get it to work, you can use the "reset to defaults" button (just below the "save changes" button) to get the value back (snapshot your other settings first to help you quickly set the other settings back the way to what you had before.)', 'vtmin');  
  823. $html .= $help; 
  824. $html .= '</p>';  
  825.  
  826. echo $html; 
  827.  
  828. function vtmin_before_checkout_address_selector_callback() { //opt12 
  829. $options = get_option( 'vtmin_setup_options' ); 
  830. $html = '<textarea type="text" id="show_error_before_checkout_address_selector" rows="1" cols="20" name="vtmin_setup_options[show_error_before_checkout_address_selector]">' . $options['show_error_before_checkout_address_selector'] . '</textarea>'; 
  831.  
  832. $more_info = __('More Info', 'vtmin'); 
  833. $html .= '<a id="help12" class="help-anchor" href="javascript:void(0);" >' ; $html .= $more_info; $html .= '</a>'; 
  834.  
  835. $html .= '<p id="help12-text" class = "help-text" >';  
  836. $help = __('"Show Error Messages Just Before Checkout Address List - HTML Selector" =>  
  837. <strong>This option controls the location of the message display, ***handle with care***.</strong> For the Product area error message, this option supplies the ID or Class HTML selector this message appears before. This selector would appear in your theme"s checkout area,  
  838. just above the address display area. Be sure to include the "." or "#" selector identifier before the selector name. Default = "' .VTMIN_CHECKOUT_ADDRESS_SELECTOR_BY_PARENT . '". If you"ve changed this value and can"t get it to work, you can use the "reset to defaults" button (just below the "save changes" button) to get the value back (snapshot your other settings first to help you quickly set the other settings back the way to what you had before.)', 'vtmin');  
  839. $html .= $help; 
  840. $html .= '</p>';  
  841.  
  842. echo $html; 
  843.  
  844. //v1.09.5 NEW 
  845. function vtmin_show_errors_on_all_pages_callback() { //opt13  
  846. $options = get_option( 'vtmin_setup_options' );  
  847. $html = '<select id="vtmin-id" name="vtmin_setup_options[show_errors_on_all_pages]">'; 
  848. $html .= '<option value="yes"' . selected( $options['show_errors_on_all_pages'], 'yes', false) . '>Show Errors on All Pages  </option>'; 
  849. $html .= '<option value="no"' . selected( $options['show_errors_on_all_pages'], 'no', false) . '>Show Errors Only on Cart and Checkout  </option>'; 
  850. $html .= '</select>'; 
  851.  
  852. $more_info = __('More Info', 'vtmin'); 
  853. $html .= '<a id="help13" class="help-anchor" href="javascript:void(0);" >' ; $html .= $more_info; $html .= '</a>'; 
  854.  
  855. $html .= '<p id="help13-text" class = "help-text" >';  
  856. $help = __('Do we show the Rules error messages on all pages, or only on Cart and at Checkout ', 'vtmin');  
  857. $html .= $help; 
  858. $html .= '</p>'; 
  859. $html .= '<p><em>  '; 
  860. $html .= __('NOTE ==>> "Show Errors on All Pages" will NOT react immediately to an Aadd-to-cart. The error message, if warranted, will show up with the NEXT PAGE REFRESH>', 'vtprd'); 
  861. $html .= '</em></p>'; 
  862.  
  863. echo $html; 
  864.  
  865.  
  866. function vtmin_validate_setup_input( $input ) { 
  867.  
  868. //did this come from on of the secondary buttons? 
  869. $reset = ( ! empty($input['options-reset']) ? true : false ); 
  870. $repair = ( ! empty($input['rules-repair']) ? true : false ); 
  871. $nuke_rules = ( ! empty($input['rules-nuke']) ? true : false ); 
  872. $nuke_cats = ( ! empty($input['cats-nuke']) ? true : false ); 
  873.  
  874.  
  875.  
  876. switch( true ) {  
  877. case $reset === true : //reset options 
  878. $output = $this->vtmin_get_default_options(); //load up the defaults 
  879. //as default options are set, no further action, just return 
  880. return apply_filters( 'vtmin_validate_setup_input', $output, $input ); 
  881. break; 
  882. case $repair === true : //repair rules 
  883. $vtmin_nuke = new VTMIN_Rule_delete;  
  884. $vtmin_nuke->vtmin_repair_all_rules(); 
  885. $output = get_option( 'vtmin_setup_options' ); //fix 2-13-2013 - initialize output, otherwise all Options go away... 
  886. break; 
  887. case $nuke_rules === true : 
  888. $vtmin_nuke = new VTMIN_Rule_delete;  
  889. $vtmin_nuke->vtmin_nuke_all_rules(); 
  890. $output = get_option( 'vtmin_setup_options' ); //fix 2-13-2013 - initialize output, otherwise all Options go away... 
  891. break; 
  892. case $nuke_cats === true :  
  893. $vtmin_nuke = new VTMIN_Rule_delete;  
  894. $vtmin_nuke->vtmin_nuke_all_rule_cats(); 
  895. $output = get_option( 'vtmin_setup_options' ); //fix 2-13-2013 - initialize output, otherwise all Options go away... 
  896. break; 
  897. default: //standard update button hit...  
  898. //$output = array(); 
  899. $output = get_option( 'vtmin_setup_options' ); //v1.06 
  900. foreach( $input as $key => $value ) { 
  901. if( isset( $input[$key] ) ) { 
  902. $output[$key] = strip_tags( stripslashes( $input[ $key ] ) );  
  903. } // end if  
  904. } // end foreach  
  905. break; 
  906.  
  907. /** alternative to add_settings_error 
  908. $message = __('<strong>Please Download and/or Activate ' .$free_plugin_name.' (the Free version). </strong><br>It must be installed and active, before the Pro version can be activated. The Free version can be downloaded from ' . $free_plugin_download , 'vtminpro'); 
  909. $admin_notices = '<div id="message" class="error fade" style="background-color: #FFEBE8 !important;"><p>' . $message . ' </p></div>'; 
  910. add_action( 'admin_notices', create_function( '', "echo '$admin_notices';" ) ); 
  911. */ 
  912.  
  913.  
  914. //NO Object-based code on the apply_filters statement needed or wanted!!!!!!!!!!!!! 
  915. return apply_filters( 'vtmin_validate_setup_input', $output, $input );  
  916. }  
  917.  
  918.  
  919. } //end class