PageRenderTime 26ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/shop quần áo starloveshop.com/wp-content/plugins/woocommerce-predictive-search/classes/class-wc-predictive-search-metabox.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien
PHP | 79 lines | 56 code | 10 blank | 13 comment | 19 complexity | b1b36ecc5002566936f5577b5cef2e10 MD5 | raw file
  1. <?php
  2. /**
  3. * Predictive Search Meta
  4. *
  5. * Class Function into WP e-Commerce plugin
  6. *
  7. * Table Of Contents
  8. *
  9. *
  10. * create_custombox()
  11. * a3_people_metabox()
  12. */
  13. class WC_Predictive_Search_Meta
  14. {
  15. public static function create_custombox() {
  16. global $post;
  17. $exclude_items = array();
  18. if (get_post_type($post->ID) == 'product') {
  19. $exclude_items = (array) get_option('woocommerce_search_exclude_products');
  20. }
  21. $check = '';
  22. if (is_array($exclude_items) && in_array($post->ID, $exclude_items)) {
  23. $check = 'checked="checked"';
  24. }
  25. if (get_post_type($post->ID) == 'product') {
  26. $hide_item_from_result_text = ' <span style="float:right;" class="a3_woocommerce_search_exclude_item"><label><input style="position: relative; top: 2px;" type="checkbox" '.$check.' value="1" name="_woocommerce_search_exclude_item" /> '.__('Hide from Predictive Search results.', 'woops').'</label></span>';
  27. } else {
  28. $hide_item_from_result_text = ' <span style="float:right;" class="a3_woocommerce_search_exclude_item"><label><input disabled="disabled" style="position: relative; top: 2px;" type="checkbox" checked="checked" value="1" name="_woocommerce_search_exclude_item" /> '.__('Hide from Predictive Search results.', 'woops').'</label></span>';
  29. }
  30. add_meta_box( 'wc_predictive_search_metabox', __('Predictive Search Meta', 'woops').$hide_item_from_result_text , array('WC_Predictive_Search_Meta','data_metabox'), 'post', 'normal', 'high' );
  31. add_meta_box( 'wc_predictive_search_metabox', __('Predictive Search Meta', 'woops').$hide_item_from_result_text , array('WC_Predictive_Search_Meta','data_metabox'), 'page', 'normal', 'high' );
  32. add_meta_box( 'wc_predictive_search_metabox', __('Predictive Search Meta', 'woops').$hide_item_from_result_text , array('WC_Predictive_Search_Meta','data_metabox'), 'product', 'normal', 'high' );
  33. }
  34. public static function data_metabox() {
  35. global $post;
  36. $postid = $post->ID;
  37. ?>
  38. <style>
  39. #woo_predictive_upgrade_area_box { border:2px solid #E6DB55;-webkit-border-radius:10px;-moz-border-radius:10px;-o-border-radius:10px; border-radius: 10px; padding:10px; position:relative}
  40. #woo_predictive_upgrade_area_box legend {margin-left:4px; font-weight:bold;}
  41. </style>
  42. <fieldset id="woo_predictive_upgrade_area_box"><legend><?php _e('Upgrade to','woops'); ?> <a href="<?php echo WOOPS_AUTHOR_URI; ?>" target="_blank"><?php _e('Pro Version', 'woops'); ?></a> <?php _e('to activate', 'woops'); ?></legend>
  43. <table class="form-table" cellspacing="0">
  44. <tr valign="top">
  45. <th scope="rpw" class="titledesc"><label for="_predictive_search_focuskw"><?php _e('Focus Keywords', 'woops'); ?></label></th>
  46. <td class="forminp"><div class="wide_div"><input type="text" value="" id="_predictive_search_focuskw" name="_predictive_search_focuskw" style="width:98%;" /></div></td>
  47. </tr>
  48. </table>
  49. </fieldset>
  50. <?php
  51. }
  52. public static function save_custombox($post_id) {
  53. $post_status = get_post_status($post_id);
  54. $post_type = get_post_type($post_id);
  55. if(in_array($post_type, array('product') ) && isset($_REQUEST['_predictive_search_focuskw']) && $post_status != false && $post_status != 'inherit') {
  56. extract($_REQUEST);
  57. $exclude_option = 'woocommerce_search_exclude_products';
  58. $exclude_items = (array) get_option($exclude_option);
  59. if (!is_array($exclude_items)) $exclude_items = array();
  60. if (isset($_REQUEST['_woocommerce_search_exclude_item']) && $_REQUEST['_woocommerce_search_exclude_item'] == 1) {
  61. if (!in_array($post_id, $exclude_items)) $exclude_items[] = $post_id;
  62. } else {
  63. $exclude_items = array_diff($exclude_items, array($post_id));
  64. }
  65. update_option($exclude_option, $exclude_items);
  66. }
  67. }
  68. }
  69. ?>