VTMIN_Rules_UI

Rule CPT rows are stored.

Defined (1)

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

/admin/vtmin-rules-ui.php  
  1. class VTMIN_Rules_UI {  
  2.  
  3. public function __construct() {  
  4. global $post, $vtmin_info; 
  5. add_action( 'add_meta_boxes_vtmin-rule', array(&$this, 'vtmin_remove_meta_boxes') );  
  6. add_action( 'add_meta_boxes_vtmin-rule', array(&$this, 'vtmin_add_metaboxes') ); 
  7. add_action( "admin_enqueue_scripts", array($this, 'vtmin_enqueue_script') ); 
  8.  
  9. //all in one seo fix 
  10. add_action( 'add_meta_boxes_vtmin-rule', array($this, 'vtmin_remove_all_in_one_seo_aiosp') );  
  11.  
  12. //AJAX actions 
  13. add_action( 'wp_ajax_vtmin_ajax_load_variations', array($this, 'vtmin_ajax_load_variations') );  
  14. add_action( 'wp_ajax_noprov_vtmin_ajax_load_variations', array($this, 'vtmin_ajax_load_variations') );  
  15.  
  16.  
  17. public function vtmin_enqueue_script() { 
  18. global $post_type; 
  19. if( 'vtmin-rule' == $post_type ) {  
  20. wp_register_style( 'vtmin-admin-style', VTMIN_URL.'/admin/css/vtmin-admin-style-v002.css' ); //v1.09.6 ==> new version for new metabox 
  21. wp_enqueue_style('vtmin-admin-style'); 
  22. wp_register_script( 'vtmin-admin-script', VTMIN_URL.'/admin/js/vtmin-admin-script.js' );  
  23. wp_enqueue_script('vtmin-admin-script'); 
  24.  
  25. //AJAX resources 
  26. // see http://wp.smashingmagazine.com/2011/10/18/how-to-use-ajax-in-wordpress/ 
  27. // http://wpmu.org/how-to-use-ajax-with-php-on-your-wp-site-without-a-plugin/ 
  28. wp_register_script( "vtmin_variations_script", plugin_dir_url( __FILE__ ).'/admin/js/vtmin-variations-script.js', array('jquery') ); 
  29. // "variationsInAjax" used in URL jquery statement: "url : variationsInAjax.ajaxurl" 
  30. wp_localize_script( 'vtmin_variations_script', 'variationsInAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'location' => 'post', 'manual' => 'false' ));  
  31. wp_enqueue_script( 'vtmin_variations_script' ); 
  32.  
  33. }  
  34.  
  35. public function vtmin_remove_meta_boxes() { 
  36. if(!current_user_can('administrator')) {  
  37. remove_meta_box( 'revisionsdiv', 'post', 'normal' ); // Revisions meta box 
  38. remove_meta_box( 'commentsdiv', 'vtmin-rule', 'normal' ); // Comments meta box 
  39. remove_meta_box( 'authordiv', 'vtmin-rule', 'normal' ); // Author meta box 
  40. remove_meta_box( 'slugdiv', 'vtmin-rule', 'normal' ); // Slug meta box  
  41. remove_meta_box( 'postexcerpt', 'vtmin-rule', 'normal' ); // Excerpt meta box 
  42. remove_meta_box( 'formatdiv', 'vtmin-rule', 'normal' ); // Post format meta box 
  43. remove_meta_box( 'trackbacksdiv', 'vtmin-rule', 'normal' ); // Trackbacks meta box 
  44. remove_meta_box( 'postcustom', 'vtmin-rule', 'normal' ); // Custom fields meta box 
  45. remove_meta_box( 'commentstatusdiv', 'vtmin-rule', 'normal' ); // Comment status meta box 
  46. remove_meta_box( 'postimagediv', 'vtmin-rule', 'side' ); // Featured image meta box 
  47. remove_meta_box( 'pageparentdiv', 'vtmin-rule', 'side' ); // Page attributes meta box 
  48. remove_meta_box( 'categorydiv', 'vtmin-rule', 'side' ); // Category meta box 
  49. remove_meta_box( 'tagsdiv-post_tag', 'vtmin-rule', 'side' ); // Post tags meta box 
  50. remove_meta_box( 'tagsdiv-vtmin_rule_category', 'vtmin-rule', 'side' ); // vtmin_rule_category tags  
  51. remove_meta_box('relateddiv', 'vtmin-rule', 'side');  
  52. }  
  53.  
  54.  
  55.  
  56. public function vtmin_add_metaboxes() { 
  57. global $post, $vtmin_info, $vtmin_rule, $vtmin_rules_set;  
  58.  
  59. $found_rule = false;  
  60.  
  61. if ($post->ID > ' ' ) { 
  62. $post_id = $post->ID; 
  63. $vtmin_rules_set = get_option( 'vtmin_rules_set' ) ; 
  64. $sizeof_rules_set = sizeof($vtmin_rules_set); 
  65. if ($sizeof_rules_set > 0) { //1.09.3  
  66. for($i=0; $i < $sizeof_rules_set; $i++) {  
  67. if ($vtmin_rules_set[$i]->post_id == $post_id) { 
  68. $vtmin_rule = $vtmin_rules_set[$i]; //load vtmin-rule  
  69. $found_rule = true; 
  70. $found_rule_index = $i;  
  71. $i = $sizeof_rules_set; 
  72. } //1.09.3  
  73. }  
  74.  
  75. if (!$found_rule) { 
  76. //initialize rule 
  77. $vtmin_rule = new VTMIN_Rule;  
  78. //fill in standard default values not already supplied 
  79. $selected = 's'; 
  80. $vtmin_rule->inpop[1]['user_input'] = $selected; //use selection groups by default 
  81. $vtmin_rule->specChoice_in[0]['user_input'] = $selected; 
  82. $vtmin_rule->amtSelected[0]['user_input'] = $selected;  
  83. $vtmin_rule->role_and_or_in[1]['user_input'] = $selected; // 'or' 
  84.  
  85. if ( sizeof($vtmin_rule->rule_error_message ) > 0 ) { //these error messages are from the last upd action attempt, coming from vtmin-rules-update.php 
  86. add_meta_box('vtmin-errmsg', __('Update Error Messages :: The rule is not active until these are resolved ::', 'vtmin'), array(&$this, 'vtmin_error_messages'), 'vtmin-rule', 'normal', 'high'); 
  87. }  
  88.  
  89. add_meta_box('vtmin-pop-in-select', __('Cart Search Criteria', 'vtmin'), array(&$this, 'vtmin_pop_in_select'), 'vtmin-rule', 'normal', 'high');  
  90. add_meta_box('vtmin-pop-in-specifics', __('Rule Application Method', 'vtmin'), array(&$this, 'vtmin_pop_in_specifics'), 'vtmin-rule', 'normal', 'high'); 
  91. add_meta_box('vtmin-rule-amount', __('Quantity or Price Minimum Amount', 'vtmin'), array(&$this, 'vtmin_rule_amount'), 'vtmin-rule', 'normal', 'high'); 
  92. add_meta_box('vtmin-rule-repeating-groups', __('Repeating Groups', 'vtmin'), array(&$this, 'vtmin_rule_repeating_groups'), 'vtmin-rule', 'normal', 'default'); //v1.09.6 
  93. add_meta_box('vtmin-rule-custom-message', __('Custom Message', 'vtmin'), array(&$this, 'vtmin_rule_custom_message'), 'vtmin-rule', 'normal', 'default'); //v1.08 
  94. add_meta_box('vtmin-rule-id', __('Minimum Purchase Rule ID', 'vtmin'), array(&$this, 'vtmin_rule_id'), 'vtmin-rule', 'side', 'low'); //low = below Publish box 
  95. add_meta_box('vtmin-rule-resources', __('Resources', 'vtmin'), array(&$this, 'vtmin_rule_resources'), 'vtmin-rule', 'side', 'low'); //low = below Publish box  
  96.  
  97. //add help tab to this screen...  
  98. $content = '<br><a href="' . VTMIN_DOCUMENTATION_PATH_PRO_BY_PARENT . '" title="Access Plugin Documentation">Access Plugin Documentation</a>'; 
  99. $screen = get_current_screen(); 
  100. $screen->add_help_tab( array(  
  101. 'id' => 'vtmin-help', //unique id for the tab 
  102. 'title' => 'Minimum Purchase Help', //unique visible title for the tab 
  103. 'content' => $content //actual help text 
  104. ) );  
  105. }  
  106.  
  107.  
  108. public function vtmin_error_messages() {  
  109. global $post, $vtmin_rule; 
  110. echo "<div class='alert-message alert-danger'>" ;  
  111. for($i=0; $i < sizeof($vtmin_rule->rule_error_message); $i++) {  
  112. echo '<div class="vtmin-error"><p>';  
  113. echo $vtmin_rule->rule_error_message[$i]; 
  114. echo '</p></div>';  
  115. } //end for loop 
  116.  
  117. echo "</div>";  
  118. if( $post->post_status == 'publish') { //if post status not = pending, make it so  
  119. $post_id = $post->ID; 
  120. global $wpdb; 
  121. $wpdb->update( $wpdb->posts, array( 'post_status' => 'pending' ), array( 'ID' => $post_id ) ); 
  122. }  
  123.  
  124. }  
  125.  
  126.  
  127. public function vtmin_pop_in_select( ) { 
  128. global $post, $vtmin_info, $vtmin_rule; $vtmin_rules_set; 
  129. $checked = 'checked="checked"';  
  130. $vtminNonce = wp_create_nonce("vtmin-rule-nonce"); //nonce verified in vt-minimum-purchase.php 
  131.  
  132. $disabled = 'disabled="disabled"' ;  
  133. ?> 
  134.  
  135. <style type="text/css"> 
  136. /*Free version*/ 
  137. #cartChoice,  
  138. #cartChoice-label,  
  139. #varChoice,  
  140. #varChoice-label,  
  141. #singleChoice,  
  142. #singleChoice-label,  
  143. #prodcat-in,  
  144. #prodcat-in h3,  
  145. .and-or,  
  146. #rulecat-in,  
  147. #rulecat-in h3,  
  148. #andChoice-label  
  149. {color:#aaa;} /*grey out unavailable choices*/ 
  150. #wpsc_product_category-adder,  
  151. #vtmin_rule_category-adder { 
  152. display:none; 
  153. #vtmin-pop-in-cntl {margin-bottom:15px;} 
  154. /*v1.06 begin*/ 
  155. .pro-anchor { 
  156. border: 1px solid #CCCCCC; 
  157. clear: both; 
  158. color: #000000; 
  159. float: left; 
  160. font-size: 14px; 
  161. margin-bottom: 10px; 
  162. margin-left: 2%; 
  163. margin-top: 20px; 
  164. padding: 5px 10px; 
  165. text-decoration: none; 
  166. width: auto;  
  167. #inpopDescrip-more-help {color: #0074A2 !important;font-size: 15px;} 
  168. /*v1.06 end*/ 
  169. </style> 
  170.  
  171. <input type="hidden" id="vtmin_nonce" name="vtmin_nonce" value="<?php echo $vtminNonce; ?>" /> 
  172.  
  173. <input type="hidden" id="fullMsg" name="fullMsg" value="<?php echo $vtmin_info['default_full_msg'];?>" /> <?php //v1.08 ?> 
  174.  
  175. <div class="column1" id="inpopDescrip"> 
  176. <h4> <?php _e('Choose how to look at the Candidate Population', 'vtmin') ?></h4> 
  177. <p> <?php _e('Minimum Amount rules will only look at the contents of the cart at checkout. 
  178. Minimum Amount rules define a candidate group within the cart. The Free version of the plugin 
  179. applies only to logged-in user membership status.', 'vtmin') ?>  
  180. </p> 
  181. <?php //v1.06 msg moved below ?> 
  182. </div> 
  183.  
  184.  
  185. <div class="column2" id="inpopChoice">  
  186. <h3><?php _e('Select Search Type', 'vtmin')?></h3> 
  187. <div id="inpopRadio"> 
  188. <?php 
  189. $sizeof_rule_inpop = sizeof($vtmin_rule->inpop); 
  190. for($i=0; $i < $sizeof_rule_inpop; $i++) {  
  191. ?>  
  192.  
  193. <input id="<?php echo $vtmin_rule->inpop[$i]['id']; ?>" class="<?php echo $vtmin_rule->inpop[$i]['class']; ?>" type="<?php echo $vtmin_rule->inpop[$i]['type']; ?>" name="<?php echo $vtmin_rule->inpop[$i]['name']; ?>" value="<?php echo $vtmin_rule->inpop[$i]['value']; ?>" <?php if ( $vtmin_rule->inpop[$i]['user_input'] > ' ' ) { echo $checked; } else { echo $disabled; } ?> /><span id="<?php echo $vtmin_rule->inpop[$i]['id'] . '-label'; ?>"> <?php echo $vtmin_rule->inpop[$i]['label']; ?></span><br /> 
  194.  
  195. <?php } ?>  
  196. </div> 
  197.  
  198. <span class="" id="singleChoice-span">  
  199. <span id="inpop-singleProdID-label"><?php _e('  Enter Product ID Number', 'vtmin')?></span><br />  
  200. <input id="<?php echo $vtmin_rule->inpop_singleProdID['id']; ?>" class="<?php echo $vtmin_rule->inpop_singleProdID['class']; ?>" type="<?php echo $vtmin_rule->inpop_singleProdID['type']; ?>" name="<?php echo $vtmin_rule->inpop_singleProdID['name']; ?>" value="<?php echo $vtmin_rule->inpop_singleProdID['value']; ?>"> 
  201. <br />  
  202. <?php if ($vtmin_rule->inpop_singleProdID['value'] > ' ' ) { ?>  
  203. <span id="inpop-singleProdID-name-label"><?php _e('  Product Name', 'vtmin')?></span><br />  
  204. <span id="inpop-singleProdID-name" ><?php echo $vtmin_rule->inpop_singleProdID_name; ?></span><br /> 
  205. <?php } ?>  
  206. </span> 
  207.  
  208. </div> 
  209.  
  210. <div class="column3 inpopExplanation" id="cartChoice-chosen"> 
  211. <h4><?php _e('Apply to all products in the cart', 'vtmin')?><span> - <?php _e('explained', 'vtmin')?></span></h4> 
  212. <p><?php _e('No threshhold group is chosen, and the initial rule logic applies to all products 
  213. to be found in the cart.', 'vtmin')?>  
  214. </p> 
  215. </div> 
  216. <div class="column3 inpopExplanation" id="groupChoice-chosen"> 
  217. <h4><?php _e('Use Selection Groups', 'vtmin')?><span> - <?php _e('explained', 'vtmin')?></span></h4>  
  218. <p><?php _e('Using selection groups, you can specify the initial focus of the rule, focusing on some products found in the cart.  
  219. A selection group can be considered a threshhold, which when reached the other 
  220. aspects of the rule is applied. For example, if you specify category Auto Parts, then 
  221. if products in categories other than Auto Parts are in the cart, the rule would not apply to them.', 'vtmin')?>  
  222. </p> 
  223. </div> 
  224. <div class="column3 inpopExplanation" id="varChoice-chosen"> 
  225. <h4><?php _e('Single Product with Variations', 'vtmin')?><span> - <?php _e('explained', 'vtmin')?></span></h4> 
  226. <p><?php _e('Apply rule to the variations for a single product found in the cart, whose ID is supplied in the "Product ID" box. Enter the Product ID and hit the "Product and Variations" button (The product ID can be found in the URL 
  227. of the product during a product edit session). Select any/all of the variations belonging to the product.', 'vtmin')?>  
  228. </p> 
  229. </div>  
  230. <div class="column3 inpopExplanation" id="singleChoice-chosen"> 
  231. <h4><?php _e('Single Product Only', 'vtmin')?><span> - <?php _e('explained', 'vtmin')?></span></h4> 
  232. <p><?php _e('Only apply rule to a single product found in the cart, whose ID is supplied in the "Product ID" box. The product ID can be found in the URL 
  233. of the product during a product edit session.', 'vtmin')?>  
  234. <br /> <br />  
  235. <?php _e('For example, in the product edit session url:', 'vtmin')?>  
  236. <br /><br />       
  237. <?php _e('http://www.xxxx.com/wp-admin/post.php?post=872&action=edit', 'vtmin')?>  
  238. <br /><br /> 
  239. <?php _e('The product id is in the "post=872" portion of the address, and hence the number is 872. You would enter  
  240. that number in the box to the left labeled "Enter Product ID Number".', 'vtmin')?> 
  241. <br /><br /> 
  242. <?php _e('NB: If **single** is chosen, the value of "All" is applied to the Rule Application Method, regardless of what is chosen below.', 'vtmin')?>  
  243. </p> 
  244. </div>  
  245.  
  246. <div id="inpop-varProdID-cntl">  
  247. <a id="inpop-varProdID-more" class="help-anchor" href="javascript:void(0);">Single Product with Variations - <span id="pop-in-more-help">More Info</span></a> 
  248. <p id="inpop-varProdID-descrip" class="help-text"><?php _e('When "Single Product with Variations" is chosen, at least one variation must be selected. 
  249. <br><br> NB - PLEASE NOTE: If the product variation structure is changed in any way, you MUST return to the matching rule and reselect your variation choices. 
  250. <br><br>Multiple rules may be created to apply to individual variations, or groups of variations within a product.  
  251. <br><br>Please be sure to prevent any rule overlap when applied to a given 
  252. product-variation combination. An overlap example: if there is a category-level rule covering an entire product, and an individual rule applying to any of the product variations. 
  253. <br><br>Rule overlap in variation rules is Not removed by the rule processing engine, it must be prevented here.' , 'vtmin')?>  
  254. </p>  
  255. <div id="inpopVarBox"> 
  256. <h3>Single Product with Variations</h3> 
  257. <div id="inpopVarProduct"> 
  258. <span id="inpop-varProdID-label"><?php _e('  Enter Product ID Number', 'vtmin')?></span><br />  
  259. <input id="<?php echo $vtmin_rule->inpop_varProdID['id']; ?>" class="<?php echo $vtmin_rule->inpop_varProdID['class']; ?>" type="<?php echo $vtmin_rule->inpop_varProdID['type']; ?>" name="<?php echo $vtmin_rule->inpop_varProdID['name']; ?>" value="<?php echo $vtmin_rule->inpop_varProdID['value']; ?>"> 
  260. <br />  
  261. </div> 
  262. <div id="inpopVarButton"> 
  263. <?php 
  264. $product_ID = $vtmin_rule->inpop_varProdID['value']; 
  265. $product_variation_IDs = vtmin_get_variations_list($product_ID); 
  266. /** ************************************************ 
  267. ** Get Variations Button for Rule screen 
  268. * ==>>> get the product id from $_REQUEST['varProdID']; in the receiving ajax routine.  
  269. ************************************************ */  
  270. ?> 
  271.  
  272. <div class="inpopVar-loading-animation"> 
  273. <img title="Loading" alt="Loading" src="<?php echo VTMIN_URL;?>/admin/images/indicator.gif" /> 
  274. <?php _e('Getting Variations ...', 'vtmin'); ?> 
  275. </div> 
  276.  
  277.  
  278. <a id="ajaxVariationIn" href="javascript:void(0);"> 
  279. <?php if ($product_ID > ' ') { ?> 
  280. <?php _e('Refresh Variations', 'vtmin')?>  
  281. <?php } else { ?> 
  282. <?php _e('Get Variations', 'vtmin')?>  
  283. <?php } ?> 
  284. </a> 
  285.  
  286. </div> 
  287. </div> 
  288. <div id="variations-in"> 
  289. <?php  
  290. if ($product_variation_IDs) { //if product still has variations, expose them here 
  291. ?> 
  292. <h3><?php _e('Product Variations', 'vtmin')?></h3>  
  293. <?php 
  294. //******************************** 
  295. $this->vtmin_post_category_meta_box($post, array( 'args' => array( 'taxonomy' => 'variations', 'tax_class' => 'var-in', 'checked_list' => $vtmin_rule->var_in_checked, 'product_ID' => $product_ID, 'product_variation_IDs' => $product_variation_IDs ))); 
  296. // ******************************** 
  297. }  
  298. ?> 
  299. </div> <?php//end variations-in ?> 
  300. </div> <?php //end inpopVarProdID ?>  
  301.  
  302.  
  303. <?php //v1.06 moved here, changed msg?> 
  304. <a id="" class="pro-anchor" target="_blank" href="<?php echo VTMIN_PURCHASE_PRO_VERSION_BY_PARENT ; ?>">( Greyed-out Options are available in the <span id="inpopDescrip-more-help">Pro Version</span>  )</a> 
  305.  
  306.  
  307. <div class="<?php //echo $groupPop_vis ?> " id="vtmin-pop-in-cntl">  
  308. <a id="pop-in-more" class="help-anchor" href="javascript:void(0);">Selection Groups - <span id="pop-in-more-help">More Info</span></a> 
  309. <p id="pop-in-descrip" class="help-text"><?php _e("Role/Membership is used within Wordpress to control access and capabilities, when a role is given to a user.  
  310. Wordpress assigns certain roles by default such as Subscriber for new users or Administrator for the site's owner. Roles can also be used to associate a user  
  311. with a pricing level. Use a role management plugin like http://wordpress.org/extend/plugins/user-role-editor/ to establish custom roles, which you can give  
  312. to a user or class of users. Then you can associate that role with a Minimum Purchase Rule. So when the user logs into your site, their Role interacts with the appropriate Rule. 
  313. <br><br> 
  314. In the Pro version, you may use an existing category to identify the group of products to which you wish to apply the rule.  
  315. If you'd rather, use a Minimum Purchase Category to identify products - this avoids disturbing the store categories. Just add a Minimum Purchase Category, go to the product screen,  
  316. and add the product to the correct minimum purchase category. (On your product add/update screen, the Mininimum purchase  
  317. category metabox is just below the default product category box.) You can also apply the rule using User Membership or Roles  
  318. as a solo selection, or you can use any combination of all three.  
  319. <br><br> 
  320. Please take note of the relationship choice 'and/or' 
  321. when using roles. The default is 'or', while choosing 'and' requires that both a role and a category be selected, before a rule 
  322. can be published.", 'vtmin')?> 
  323. </p>  
  324.  
  325. <div id="prodcat-in"> 
  326. <h3><?php _e('Product Categories', 'vtmin')?></h3> 
  327.  
  328. <?php 
  329. // ******************************** 
  330. $this->vtmin_post_category_meta_box($post, array( 'args' => array( 'taxonomy' => $vtmin_info['parent_plugin_taxonomy'], 'tax_class' => 'prodcat-in', 'checked_list' => $vtmin_rule->prodcat_in_checked))); 
  331. // ******************************** 
  332. ?> 
  333.  
  334. </div> <?php//end prodcat-in ?> 
  335. <h4 class="and-or"><?php _e('Or', 'vtmin') //('And / Or', 'vtmin')?></h4> 
  336. <div id="rulecat-in"> 
  337. <h3><?php _e('Minimum Purchase Categories', 'vtmin')?></h3> 
  338.  
  339. <?php 
  340. // ******************************** 
  341. $this->vtmin_post_category_meta_box($post, array( 'args' => array( 'taxonomy' => $vtmin_info['rulecat_taxonomy'], 'tax_class' => 'rulecat-in', 'checked_list' => $vtmin_rule->rulecat_in_checked ))); 
  342. // ******************************** 
  343. ?>  
  344.  
  345. </div> <?php//end rulecat-in ?> 
  346.  
  347.  
  348. <div id="and-or-role-div"> 
  349. <?php 
  350. $checked = 'checked="checked"';  
  351. for($i=0; $i < sizeof($vtmin_rule->role_and_or_in); $i++) {  
  352. ?>  
  353. <input id="<?php echo $vtmin_rule->role_and_or_in[$i]['id']; ?>" class="<?php echo $vtmin_rule->role_and_or_in[$i]['class']; ?>" type="<?php echo $vtmin_rule->role_and_or_in[$i]['type']; ?>" name="<?php echo $vtmin_rule->role_and_or_in[$i]['name']; ?>" value="<?php echo $vtmin_rule->role_and_or_in[$i]['value']; ?>" <?php if ( $vtmin_rule->role_and_or_in[$i]['user_input'] > ' ' ) { echo $checked; } else { echo $disabled; }?> /><span id="<?php echo $vtmin_rule->role_and_or_in[$i]['id'] . '-label'; ?>"> <?php echo $vtmin_rule->role_and_or_in[$i]['label']; ?></span><br />  
  354. <?php }  
  355. //if neither 'and' nor 'or' selected, select 'or' 
  356. /** if ( (!$vtmin_rule->role_and_or_in[0]['user_input'] == 's') && (!$vtmin_rule->role_and_or_in[1]['user_input'] == 's') ) { 
  357. $vtmin_rule->role_and_or_in[1]['user_input'] = 's'; 
  358. } */ 
  359.  
  360. ?>  
  361. </div> 
  362.  
  363.  
  364. <div id="role-in"> 
  365. <h3><?php _e('Membership List by Role', 'vtmin')?></h3> 
  366.  
  367. <?php 
  368. // ******************************** 
  369. $this->vtmin_post_category_meta_box($post, array( 'args' => array( 'taxonomy' => 'roles', 'tax_class' => 'role-in', 'checked_list' => $vtmin_rule->role_in_checked ))); 
  370. // ******************************** 
  371. ?> 
  372. </div> 
  373. <div class="back-to-top"> 
  374. <a title="Back to Top" href="#wpbody"><?php _e('Back to Top', 'vtmin')?><span class="back-to-top-arrow"> ↑</span></a> 
  375. </div> 
  376. </div> <?php //end vtmin-pop-in-cntl ?> 
  377.  
  378. <?php  
  379.  
  380.  
  381. public function vtmin_pop_in_specifics( ) {  
  382. global $post, $vtmin_info, $vtmin_rule; $vtmin_rules_set; 
  383. $checked = 'checked="checked"';  
  384. ?> 
  385.  
  386. <div class="column1" id="specDescrip"> 
  387. <h4><?php _e('How is the Rule applied to the search results?', 'vtmin')?></h4> 
  388. <p><?php _e("Once we've figured out the population we're working on (cart only or specified groups),  
  389. how do we apply the rule? Do we look at each product individually and apply the rule to 
  390. each product we find? Or do we look at the population as a group, and apply the rule to the 
  391. group as a tabulated whole? Or do we apply the rule to any we find, and limit the application  
  392. of the rule to a certain number of products?", 'vtmin')?>  
  393. </p> 
  394. </div> 
  395. <div class="column2" id="specChoice"> 
  396. <h3><?php _e('Select Rule Application Method', 'vtmin')?></h3> 
  397. <div id="specRadio"> 
  398. <span id="Choice-input-span"> 
  399. <?php 
  400. for($i=0; $i < sizeof($vtmin_rule->specChoice_in); $i++) {  
  401. ?>  
  402.  
  403. <input id="<?php echo $vtmin_rule->specChoice_in[$i]['id']; ?>" class="<?php echo $vtmin_rule->specChoice_in[$i]['class']; ?>" type="<?php echo $vtmin_rule->specChoice_in[$i]['type']; ?>" name="<?php echo $vtmin_rule->specChoice_in[$i]['name']; ?>" value="<?php echo $vtmin_rule->specChoice_in[$i]['value']; ?>" <?php if ( $vtmin_rule->specChoice_in[$i]['user_input'] > ' ' ) { echo $checked; } ?> /><?php echo $vtmin_rule->specChoice_in[$i]['label']; ?><br /> 
  404.  
  405. <?php 
  406. ?>  
  407. </span> 
  408. <span class="" id="anyChoice-span"> 
  409. <span><?php _e('*Any* applies to a *required*', 'vtmin')?></span><br /> 
  410. <?php _e('Maximum of:', 'vtmin')?>  
  411. <input id="<?php echo $vtmin_rule->anyChoice_max['id']; ?>" class="<?php echo $vtmin_rule->anyChoice_max['class']; ?>" type="<?php echo $vtmin_rule->anyChoice_max['type']; ?>" name="<?php echo $vtmin_rule->anyChoice_max['name']; ?>" value="<?php echo $vtmin_rule->anyChoice_max['value']; ?>"> 
  412. <?php _e('Products', 'vtmin')?> 
  413. </span>  
  414. </div>  
  415. </div>  
  416. <div class="column3 specExplanation" id="allChoice-chosen"> 
  417. <h4><?php _e('Treat the Selected Group as a Single Entity', 'vtmin')?><span> - <?php _e('explained', 'vtmin')?></span></h4> 
  418. <p><?php _e("Using *All* as your method, you choose to look at all the products from your cart search results. That means we add 
  419. all the quantities and/or price across all relevant products in the cart, to test against the rule's requirements.", 'vtmin')?>  
  420. </p> 
  421. </div> 
  422. <div class="column3 specExplanation" id="eachChoice-chosen"> 
  423. <h4><?php _e('Each in the Selected Group', 'vtmin')?><span> - <?php _e('explained', 'vtmin')?></span></h4> 
  424. <p><?php _e("Using *Each* as your method, we apply the rule to each product from your cart search results. 
  425. So if any of these products fail to meet the rule's requirements, the cart as a whole receives an error message.", 'vtmin')?>  
  426. </p> 
  427. </div> 
  428. <div class="column3 specExplanation" id="anyChoice-chosen"> 
  429. <h4><?php _e('Apply the rule to any Individual Product in the Cart', 'vtmin')?><span> - <?php _e('explained', 'vtmin')?></span></h4> 
  430. <p><?php _e("Using *Any*, we can apply the rule to any product in the cart from your cart search results, similar to *Each*. However, there is a 
  431. maximum number of products to which the rule is applied. The product group is checked to see if any of the group fail to reach the minimum amount 
  432. threshhold. If so, the error will be applied to products in the cart based on cart order, up to the maximum limit supplied.", 'vtmin')?> 
  433. <br /> <br />  
  434. <?php _e('For example, the rule might be something like:', 'vtmin')?> 
  435. <br /> <br /> 
  436. <?php _e('  "You must buy a minimum of $10 for each of any of 2 products from this group."', 'vtmin')?>  
  437. </p>  
  438. </div>  
  439. <div class="back-to-top"> 
  440. <a title="Back to Top" href="#wpbody"><?php _e('Back to Top', 'vtmin')?><span class="back-to-top-arrow"> ↑</span></a> 
  441. </div> 
  442. <?php 
  443. }  
  444.  
  445.  
  446. public function vtmin_rule_amount( ) { 
  447. global $post, $vtmin_info, $vtmin_rule, $vtmin_rules_set; 
  448. $checked = 'checked="checked"';  
  449. ?> 
  450. <div class="column1" id="amtDescrip"> 
  451. <h4><?php _e('What are the Rule Amount Options?', 'vtmin')?></h4> 
  452. <p><?php _e('Minimum Purchase Rules can be applied to the quantity or the price of the products from  
  453. your cart search results.', 'vtmin')?>  
  454. </p> 
  455. </div> 
  456. <div class="column2" id="amtChoice"> 
  457. <h3><?php _e('Select Rule Amount Option', 'vtmin')?></h3> 
  458. <div id="amtRadio"> 
  459. <span id="amt-selected"> 
  460. <?php 
  461. for($i=0; $i < sizeof($vtmin_rule->amtSelected); $i++) {  
  462. ?>  
  463.  
  464. <input id="<?php echo $vtmin_rule->amtSelected[$i]['id']; ?>" class="<?php echo $vtmin_rule->amtSelected[$i]['class']; ?>" type="<?php echo $vtmin_rule->amtSelected[$i]['type']; ?>" name="<?php echo $vtmin_rule->amtSelected[$i]['name']; ?>" value="<?php echo $vtmin_rule->amtSelected[$i]['value']; ?>" <?php if ( $vtmin_rule->amtSelected[$i]['user_input'] > ' ' ) { echo $checked; } ?> /><?php echo $vtmin_rule->amtSelected[$i]['label']; ?><br /> 
  465.  
  466. <?php 
  467. ?> 
  468. </span> 
  469. <span id="amtChoice-span"> 
  470. <?php _e('Minimum Amount:', 'vtmin')?> 
  471. <input id="<?php echo $vtmin_rule->minimum_amt['id']; ?>" class="<?php echo $vtmin_rule->minimum_amt['class']; ?>" type="<?php echo $vtmin_rule->minimum_amt['type']; ?>" name="<?php echo $vtmin_rule->minimum_amt['name']; ?>" value="<?php echo $vtmin_rule->minimum_amt['value']; ?>"> 
  472. </span> 
  473. </div>  
  474. </div> 
  475. <div class="column3 amtExplanation" id="qtyChoice-chosen"> 
  476. <h4><?php _e('Apply to Quantity', 'vtmin')?><span> - <?php _e('explained', 'vtmin')?></span></h4> 
  477. <p><?php _e('With Quantity chosen, we total up the units amount across indivual products, candidate groups in the cart, or the cart 
  478. in total. Then we compare that total against the minimum amount for the rule.', 'vtmin')?>  
  479. </p> 
  480. </div> 
  481. <div class="column3 amtExplanation" id="amtChoice-chosen"> 
  482. <h4><?php _e('Apply to Price', 'vtmin')?><span> - <?php _e('explained', 'vtmin')?></span></h4> 
  483. <p><?php _e('With Price chosen, we total up the price across indivual products, candidate groups in the cart, or the cart 
  484. in total. Then we compare that total against the minimum amount for the rule.', 'vtmin')?>  
  485. </p> 
  486. </div> 
  487. <div class="back-to-top"> 
  488. <a title="Back to Top" href="#wpbody"><?php _e('Back to Top', 'vtmin')?><span class="back-to-top-arrow"> ↑</span></a> 
  489. </div> 
  490. <?php 
  491. }  
  492.  
  493. //v1.09.6 NEW FUNCTION  
  494. //repeating groups by count or $ value  
  495. public function vtmin_rule_repeating_groups() { 
  496. global $post, $vtmin_info, $vtmin_rule, $vtmin_rules_set;  
  497. ?> 
  498. <div class="rule_message clear-left" id="repeating-groups-area"> 
  499. <span class="newColumn1" id=repeating-groups-label-area> 
  500. <h3><?php _e('Repeating Groups Quantity', 'vtmin')?></h3> 
  501. <span id='repeating-groups-optional'>(optional)</span> 
  502. <span class="clear-left" id='repeating-groups-comment'>(rule purchases must be in groups of X count)</span> 
  503. </span>  
  504. <textarea name="repeating-groups" type="text" class="msg-text" id="repeating-groups"><?php echo $vtmin_rule->repeatingGroups; ?></textarea>  
  505. </div> 
  506.  
  507. <?php 
  508. }  
  509. //v1.09.6 end 
  510.  
  511. //V1.08 NEW FUNCTION  
  512. //Custom Message overriding default messaging  
  513. public function vtmin_rule_custom_message() { 
  514. global $post, $vtmin_info, $vtmin_rule, $vtmin_rules_set;  
  515. ?> 
  516. <div class="rule_message clear-left" id="cust-msg-text-area"> 
  517. <span class="newColumn1" id=cust-msg-text-label-area> 
  518. <h3><?php _e('Custom Message Text', 'vtmin')?></h3> 
  519. <span id='cust-msg-optional'>(optional)</span> 
  520. <span class="clear-left" id='cust-msg-comment'>(overrides default message)</span> 
  521. </span>  
  522. <textarea name="cust-msg-text" type="text" class="msg-text newColumn2" id="cust-msg-text" cols="50" rows="2"><?php echo stripslashes($vtmin_rule->custMsg_text); ?></textarea>  
  523. </div> 
  524.  
  525. <?php 
  526. }  
  527. //v1.08 end 
  528.  
  529. public function vtmin_rule_id( ) { 
  530. global $post;  
  531. echo '<span id="vtmin-rule-postid">' . $post->ID . '</span>'; 
  532. }  
  533.  
  534. public function vtmin_rule_resources ( ) {  
  535. echo '<span id="vtmin-rr-text">Read documentation, learn the functions and find some tips & tricks.</span><br>'; 
  536. echo '<a id="vtmin-rr-doc" href="' . VTMIN_DOCUMENTATION_PATH_PRO_BY_PARENT . '" title="Access Plugin Documentation">Plugin Documentation</a>'; 
  537. echo '<span id="vtmin-rr-box">'; 
  538. echo '<span id="vtmin-rr-created">by VarkTech.com</span>'; 
  539. echo '<a id="vtmin-rr-vote" href="' . VTMIN_DOWNLOAD_FREE_VERSION_BY_PARENT . '" title="Vote for the Plugin">Vote</a>'; 
  540. echo '</span>'; //end rr-box 
  541. }  
  542.  
  543. /** 
  544. source: http://www.ilovecolors.com.ar/avoid-hierarchical-taxonomies-to-loose-hierarchy/  
  545. ==> pasted from wp-admin/includes/meta-boxes.php -> post_categories_meta_box() 
  546. ** plugin with same code in http://scribu.net/wordpress/category-checklist-tree  
  547. */ 
  548.  
  549. public function vtmin_post_category_meta_box( $post, $box ) { 
  550. $defaults = array('taxonomy' => 'category'); 
  551. if ( !isset($box['args']) || !is_array($box['args']) ) 
  552. $args = array(); 
  553. else 
  554. $args = $box['args']; 
  555. extract( wp_parse_args($args, $defaults), EXTR_SKIP ); 
  556. $tax = get_taxonomy($taxonomy); 
  557.  
  558. //vark => removed the divs with the tabs for 'all' and 'most popular' 
  559. ?> 
  560. <div id="taxonomy-<?php echo $taxonomy; ?>" class="categorydiv"> 
  561.  
  562. <div id="<?php echo $taxonomy; ?>-pop" class="tabs-panel" style="display: none;"> 
  563. <ul id="<?php echo $taxonomy; ?>checklist-pop" class="categorychecklist form-no-clear" > 
  564. <?php $popular_ids = wp_popular_terms_checklist($taxonomy); ?> 
  565. </ul> 
  566. </div> 
  567.  
  568. <div id="<?php echo $taxonomy; ?>-all" class="tabs-panel"> 
  569. <?php 
  570. $name = ( $taxonomy == 'category' ) ? 'post_category' : 'tax_input[' . $tax_class . ']'; //vark replaced $taxonomy with $tax_class 
  571. echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. 
  572. ?> 
  573. <ul id="<?php echo $taxonomy; ?>checklist" class="list:<?php echo $taxonomy?> categorychecklist form-no-clear"> 
  574. <?php  
  575.  
  576. switch( $taxonomy ) { 
  577. case 'roles':  
  578. $vtmin_checkbox_classes = new VTMIN_Checkbox_classes;  
  579. $vtmin_checkbox_classes->vtmin_fill_roles_checklist($tax_class, $checked_list); 
  580. break; 
  581. case 'variations':  
  582. vtmin_fill_variations_checklist($tax_class, $checked_list, $product_ID, $product_variation_IDs);  
  583. break; 
  584. default: //product category or vtmin category... 
  585. $this->vtmin_build_checkbox_contents ($taxonomy, $tax_class, $checked_list);  
  586. break; 
  587.  
  588. ?>  
  589. </ul> 
  590. </div> 
  591.  
  592. <?php //wp-hidden-children div removed, no longer functions as/of WP3.5 ?> 
  593.  
  594. </div> 
  595. <?php 
  596.  
  597. //remove conflict with all-in-one seo pack!!  
  598. // from http://wordpress.stackexchange.com/questions/55088/disable-all-in-one-seo-pack-for-some-custom-post-types 
  599. function vtmin_remove_all_in_one_seo_aiosp() { 
  600. $cpts = array( 'vtmin-rule' ); 
  601. foreach( $cpts as $cpt ) { 
  602. remove_meta_box( 'aiosp', $cpt, 'advanced' ); 
  603.  
  604.  
  605.  
  606. /** 
  607. * taxonomy (r) - registered name of taxonomy 
  608. * tax_class (r) - name options => 'prodcat-in' 'prodcat-out' 'rulecat-in' 'rulecat-out' 
  609. * refers to product taxonomy on the candidate or action categories,  
  610. * rulecat taxonomy on the candidate or action categories 
  611. * :: as there are only these 4, they are unique  
  612. * checked_list (o) - selection list from previous iteration of rule selection  
  613. *  
  614. */ 
  615.  
  616. public function vtmin_build_checkbox_contents ($taxonomy, $tax_class, $checked_list = NULL) { 
  617. global $wpdb, $vtmin_info;  
  618. $sql = "SELECT terms.`term_id`, terms.`name` FROM `" . $wpdb->prefix . "terms` as terms, `" . $wpdb->prefix . "term_taxonomy` as term_taxonomy WHERE terms.`term_id` = term_taxonomy.`term_id` AND term_taxonomy.`taxonomy` = '" . $taxonomy . "' ORDER BY terms.`term_id` ASC";  
  619. $categories = $wpdb->get_results($sql, ARRAY_A) ; 
  620.  
  621. foreach ($categories as $category) { 
  622. $output = '<li id='.$taxonomy.'-'.$category['term_id'].'>' ; 
  623. $output .= '<label class="selectit">' ; 
  624. $output .= '<input id="'.$tax_class.'_'.$taxonomy.'-'.$category['term_id'].' " '; 
  625. $output .= 'type="checkbox" name="tax-input-' . $tax_class . '[]" '; 
  626. $output .= 'value="'.$category['term_id'].'" '; 
  627. if ($checked_list) { 
  628. if (in_array($category['term_id'], $checked_list)) { //if cat_id is in previously checked_list  
  629. $output .= 'checked="checked"'; 
  630. if ( ($taxonomy == $vtmin_info['parent_plugin_taxonomy']) || ($taxonomy == $vtmin_info['rulecat_taxonomy']) ) {  
  631. $output .= ' disabled="disabled"'; 
  632. $output .= '>'; //end input statement 
  633. $output .= ' ' . $category['name']; 
  634. $output .= '</label>';  
  635. $output .= '</li>'; 
  636. echo $output ; 
  637. return; 
  638.  
  639.  
  640.  
  641.  
  642. } //end class