WC_Predictive_Search_Admin_UI

The WooCommerce Predictive Search LITE WC Predictive Search Admin UI class.

Defined (1)

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

/admin/admin-ui.php  
  1. class WC_Predictive_Search_Admin_UI 
  2. /** 
  3. * @var string 
  4. * You must change to correct plugin name that you are working 
  5. */ 
  6. public $plugin_name = 'woo_predictive_search'; 
  7.  
  8. public $google_api_key_option = 'woo_predictive_search_google_api_key'; 
  9.  
  10. public $toggle_box_open_option = 'woo_predictive_search_toggle_box_open'; 
  11.  
  12. public $is_free_plugin = true; 
  13.  
  14. public $version_transient = 'woo_predictive_search_licinfo'; 
  15.  
  16. public $plugin_option_key = 'wc_predictive_search_plugin'; 
  17.  
  18. public $support_url = 'https://wordpress.org/support/plugin/woocommerce-predictive-search/'; 
  19.  
  20.  
  21. /** 
  22. * @var string 
  23. * You must change to correct class name that you are working 
  24. */ 
  25. public $class_name = 'WC_Predictive_Search'; 
  26.  
  27. /** 
  28. * @var string 
  29. * You must change to correct pro plugin page url on a3rev site 
  30. */ 
  31. public $pro_plugin_page_url = 'http://a3rev.com/shop/woocommerce-predictive-search/'; 
  32.  
  33. /** 
  34. * @var string 
  35. */ 
  36. public $admin_plugin_url; 
  37.  
  38. /** 
  39. * @var string 
  40. */ 
  41. public $admin_plugin_dir; 
  42.  
  43. /** 
  44. * @var array 
  45. * You must change to correct page you want to include scripts & styles, if you have many pages then use array() : array( 'quotes-orders-mode', 'quotes-orders-rule' ) 
  46. */ 
  47. public $admin_pages = array(); 
  48.  
  49.  
  50. /**-----------------------------------------------------------------------------------*/ 
  51. /** admin_plugin_url() */ 
  52. /**-----------------------------------------------------------------------------------*/ 
  53. public function admin_plugin_url() { 
  54. if ( $this->admin_plugin_url ) return $this->admin_plugin_url; 
  55. return $this->admin_plugin_url = untrailingslashit( plugins_url( '/', __FILE__ ) ); 
  56.  
  57. /**-----------------------------------------------------------------------------------*/ 
  58. /** admin_plugin_dir() */ 
  59. /**-----------------------------------------------------------------------------------*/ 
  60. public function admin_plugin_dir() { 
  61. if ( $this->admin_plugin_dir ) return $this->admin_plugin_dir; 
  62. return $this->admin_plugin_dir = untrailingslashit( plugin_dir_path( __FILE__ ) ); 
  63.  
  64. /**-----------------------------------------------------------------------------------*/ 
  65. /** admin_pages() */ 
  66. /**-----------------------------------------------------------------------------------*/ 
  67. public function admin_pages() { 
  68. $admin_pages = apply_filters( $this->plugin_name . '_admin_pages', $this->admin_pages ); 
  69.  
  70. return (array)$admin_pages; 
  71.  
  72. /** 
  73. * get_premium_video_data() 
  74. * return array 
  75. * Data is used for Premium Video Box 
  76. */ 
  77. public function get_premium_video_data() { 
  78. $premium_video_data = array( 
  79. 'box_title' => __( 'Premium Version Enhanced Features', 'woocommerce-predictive-search' ),  
  80. 'image_url' => WOOPS_IMAGES_URL. '/video.jpg',  
  81. 'video_url' => 'https://www.youtube.com/embed/9dGw-ORfMIk?version=3&autoplay=1',  
  82. 'left_title' => __( 'Premium Version Enhanced Features', 'woocommerce-predictive-search' ),  
  83. 'left_text' => __( 'WooCommerce Predictive Search Premium', 'woocommerce-predictive-search' ) 
  84. . "\n\n" . __( 'Quick Video showing the main (not all) enhanced features that are built into the WooCommerce Predictive Search Premium version', 'woocommerce-predictive-search' ),  
  85. 'right_title' => __( 'Developer Support and Premium Features', 'woocommerce-predictive-search' ),  
  86. 'right_text' => __( 'Limited Time Offer. Purchase the Premium Version Lifetime License. That is a Lifetime of maintenance updates, feature upgrades and developer support for a once only fee. Offer ending soon.', 'woocommerce-predictive-search' ) 
  87. . "\n\n" . '<a target="_blank" href="'.$this->pro_plugin_page_url.'" class="button-primary">' . __( 'Get Premium Features and Support', '' ) . '</a>',  
  88. ); 
  89.  
  90. return $premium_video_data; 
  91.  
  92. public function plugin_premium_video_box( $echo = true ) { 
  93. $premium_video_data = apply_filters( $this->plugin_name . '_plugin_premium_video_data', $this->get_premium_video_data() ); 
  94.  
  95. $output = '<div id="a3_plugin_premium_video_container">'; 
  96. $output .= '<div class="a3rev_panel_container">'; 
  97. $output .= '<div class="a3rev_panel_box">'; 
  98. $output .= '<div class="a3rev_panel_box_handle">'; 
  99. $output .= '<h3 class="a3-plugin-ui-panel-box">'.$premium_video_data['box_title'].'</h3>'; 
  100. $output .= '</div>'; 
  101. $output .= '<div class="a3rev_panel_video_box">'; 
  102. $output .= $this->plugin_premium_video(); 
  103. $output .= $this->plugin_premium_video_text(); 
  104. $output .= '</div>'; 
  105. $output .= '</div>'; 
  106. $output .= '</div>'; 
  107. $output .= '</div>'; 
  108.  
  109. $output = apply_filters( $this->plugin_name . '_plugin_premium_video', $output ); 
  110.  
  111. if ( $echo ) 
  112. echo $output; 
  113. else 
  114. return $output; 
  115.  
  116. public function plugin_premium_video( $echo = false ) { 
  117. $premium_video_data = apply_filters( $this->plugin_name . '_plugin_premium_video_data', $this->get_premium_video_data() ); 
  118.  
  119. wp_enqueue_style('thickbox'); 
  120. wp_enqueue_script('thickbox'); 
  121.  
  122. $output = '<div class="a3rev_panel_box_left_inside">'; 
  123. $output .= '<h2>' . $premium_video_data['left_title'] . '</h2>'; 
  124. $output .= '<a class="a3-plugin-premium-image thickbox" title="'.esc_attr( $premium_video_data['left_title'] ).'" href="'.esc_url( add_query_arg( array( 'TB_iframe' => 'true', 'width' => 640, 'height' => 360 ), $premium_video_data['video_url'] ) ).'">'; 
  125. $output .= '<img src="'.esc_url( $premium_video_data['image_url'] ).'" />'; 
  126. $output .= '<div class="a3-plugin-premium-video-play"></div>'; 
  127. $output .= '</a>'; 
  128. $output .= wpautop( $premium_video_data['left_text'] ); 
  129. $output .= '</div>'; 
  130.  
  131. if ( $echo ) 
  132. echo $output; 
  133. else 
  134. return $output; 
  135.  
  136. public function plugin_premium_video_text( $echo = false ) { 
  137. $premium_video_data = apply_filters( $this->plugin_name . '_plugin_premium_video_data', $this->get_premium_video_data() ); 
  138.  
  139. $output = ''; 
  140. if ( '' != trim( $premium_video_data['right_text'] ) ) { 
  141. $output .= '<div class="a3rev_panel_box_separate"></div>'; 
  142. $output .= '<div class="a3rev_panel_box_right_inside">'; 
  143. $output .= '<h2>' . $premium_video_data['right_title'] . '</h2>'; 
  144. $output .= wpautop( $premium_video_data['right_text'] ); 
  145. $output .= '</div>'; 
  146.  
  147. if ( $echo ) 
  148. echo $output; 
  149. else 
  150. return $output; 
  151.  
  152. public function plugin_extension_boxes( $echo = false ) { 
  153.  
  154. /** 
  155. * extension_boxes 
  156. * ============================================= 
  157. * array ( 
  158. * 'id' => 'box_id' : Enter unique your box id 
  159. * 'content' => 'html_content' : (required) Enter the html content to show inside the box 
  160. * 'css' => 'custom style' : custom style for the box container 
  161. * ) 
  162. */ 
  163. $extension_boxes = apply_filters( $this->plugin_name . '_plugin_extension_boxes', array() ); 
  164.  
  165. $output = ''; 
  166. if ( is_array( $extension_boxes ) && count( $extension_boxes ) > 0 ) { 
  167. foreach ( $extension_boxes as $box ) { 
  168. if ( ! isset( $box['id'] ) ) $box['id'] = ''; 
  169. if ( ! isset( $box['class'] ) ) $box['class'] = ''; 
  170. if ( ! isset( $box['css'] ) ) $box['css'] = ''; 
  171. if ( ! isset( $box['content'] ) ) $box['content'] = ''; 
  172.  
  173. $output .= '<div id="'. esc_attr( $box['id'] ) .'" class="'. esc_attr( $box['class'] ) .' a3_plugin_panel_extension_box" style="'. esc_attr( $box['css'] ) .'">'; 
  174. $output .= $box['content']; 
  175. $output .= '</div>'; 
  176.  
  177. if ( $echo ) 
  178. echo $output; 
  179. else 
  180. return $output; 
  181.  
  182. /**-----------------------------------------------------------------------------------*/ 
  183. /** plugin_extension_start() */ 
  184. /** Start of yellow box on right for pro fields 
  185. /**-----------------------------------------------------------------------------------*/ 
  186. public function plugin_extension_start( $echo = true ) { 
  187. $output = '<div id="a3_plugin_panel_container">'; 
  188. $output .= '<div id="a3_plugin_panel_upgrade_area">'; 
  189. $output .= '<div id="a3_plugin_panel_extensions">'; 
  190. $output .= $this->plugin_extension_boxes( false ); 
  191. $output .= '</div>'; 
  192. $output .= '</div>'; 
  193. $output .= '<div id="a3_plugin_panel_fields">'; 
  194.  
  195. $output = apply_filters( $this->plugin_name . '_plugin_extension_start', $output ); 
  196.  
  197. if ( $echo ) 
  198. echo $output; 
  199. else 
  200. return $output; 
  201.  
  202. /**-----------------------------------------------------------------------------------*/ 
  203. /** plugin_extension_start() */ 
  204. /** End of yellow box on right for pro fields 
  205. /**-----------------------------------------------------------------------------------*/ 
  206. public function plugin_extension_end( $echo = true ) { 
  207. $output = '</div>'; 
  208. $output .= '</div>'; 
  209.  
  210. $output = apply_filters( $this->plugin_name . '_plugin_extension_end', $output ); 
  211.  
  212. if ( $echo ) 
  213. echo $output; 
  214. else 
  215. return $output; 
  216.  
  217.  
  218. /**-----------------------------------------------------------------------------------*/ 
  219. /** upgrade_top_message() */ 
  220. /** Show upgrade top message for pro fields 
  221. /**-----------------------------------------------------------------------------------*/ 
  222. public function upgrade_top_message( $echo = false, $setting_id = '' ) { 
  223. $upgrade_top_message = sprintf( '<div class="pro_feature_top_message">'  
  224. . __( 'Advanced Settings - Upgrade to the <a href="%s" target="_blank">%s License</a> to activate these settings.', 'woocommerce-predictive-search' )  
  225. . '</div>' 
  226. , apply_filters( $this->plugin_name . '_' . $setting_id . '_pro_plugin_page_url', apply_filters( $this->plugin_name . '_pro_plugin_page_url', $this->pro_plugin_page_url ) ) 
  227. , apply_filters( $this->plugin_name . '_' . $setting_id . '_pro_version_name', apply_filters( $this->plugin_name . '_pro_version_name', __( 'Pro Version', 'woocommerce-predictive-search' ) ) ) 
  228. ); 
  229.  
  230. $upgrade_top_message = apply_filters( $this->plugin_name . '_upgrade_top_message', $upgrade_top_message, $setting_id ); 
  231.  
  232. if ( $echo ) echo $upgrade_top_message; 
  233. else return $upgrade_top_message; 
  234.  
  235.  
  236. /**-----------------------------------------------------------------------------------*/ 
  237. /** pro_fields_before() */ 
  238. /** Start of yellow box on right for pro fields 
  239. /**-----------------------------------------------------------------------------------*/ 
  240. public function pro_fields_before( $echo = true ) { 
  241. echo apply_filters( $this->plugin_name . '_pro_fields_before', '<div class="pro_feature_fields">'. $this->upgrade_top_message() ); 
  242.  
  243. /**-----------------------------------------------------------------------------------*/ 
  244. /** pro_fields_after() */ 
  245. /** End of yellow border for pro fields 
  246. /**-----------------------------------------------------------------------------------*/ 
  247. public function pro_fields_after( $echo = true ) { 
  248. echo apply_filters( $this->plugin_name . '_pro_fields_after', '</div>' ); 
  249.  
  250. /**-----------------------------------------------------------------------------------*/ 
  251. /** blue_message_box() */ 
  252. /** Blue Message Box 
  253. /**-----------------------------------------------------------------------------------*/ 
  254. public function blue_message_box( $message = '', $width = '600px' ) { 
  255. $message = '<div class="a3rev_blue_message_box_container" style="width:'.$width.'"><div class="a3rev_blue_message_box">' . $message . '</div></div>'; 
  256. $message = apply_filters( $this->plugin_name . '_blue_message_box', $message ); 
  257.  
  258. return $message; 
  259.  
  260. /**-----------------------------------------------------------------------------------*/ 
  261. /** get_version_message() */ 
  262. /** Get new version message, also include error connect 
  263. /**-----------------------------------------------------------------------------------*/ 
  264. public function get_version_message() { 
  265. $version_message = ''; 
  266.  
  267. //Getting version number 
  268. $version_transient = get_transient( $this->version_transient ); 
  269. if ( false !== $version_transient ) { 
  270. $transient_timeout = '_transient_timeout_' . $this->version_transient; 
  271. $timeout = get_option( $transient_timeout, false ); 
  272. if ( false === $timeout ) { 
  273. $version_message = __( 'You should check now to see if have any new version is available', 'woocommerce-predictive-search' ); 
  274. } elseif ( 'cannot_connect_api' == $version_transient ) { 
  275. $version_message = sprintf( __( 'Connection Failure! Please try again. If this issue persists please create a support request on the plugin <a href="%s" target="_blank">a3rev support forum</a>.', 'woocommerce-predictive-search' ), $this->support_url ); 
  276. } else { 
  277. $version_info = explode( '||', $version_transient ); 
  278. if ( FALSE !== stristr( $version_transient, '||' ) 
  279. && is_array( $version_info ) 
  280. && isset( $version_info[1] ) && $version_info[1] == 'valid' 
  281. && version_compare( get_option('wc_predictive_search_lite_version') , $version_info[0], '<' ) ) { 
  282.  
  283. $version_message = sprintf( __( 'There is a new version <span class="a3rev-ui-new-plugin-version">%s</span> available, <a href="%s" target="_blank">update now</a> or download direct from <a href="%s" target="_blank">My Account</a> on a3rev.com', 'woocommerce-predictive-search' ),  
  284. $version_info[0],  
  285. wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' . WOOPS_NAME ), 'upgrade-plugin_' . WOOPS_NAME ),  
  286. 'https://a3rev.com/my-account/downloads/' 
  287. ); 
  288.  
  289. } else { 
  290. $version_message = __( 'You should check now to see if have any new version is available', 'woocommerce-predictive-search' ); 
  291.  
  292. return $version_message; 
  293.