/admin/admin-ui.php

  1. <?php 
  2. /** "Copyright 2012 a3 Revolution Web Design" This software is distributed under the terms of GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 */ 
  3. // File Security Check 
  4. if ( ! defined( 'ABSPATH' ) ) exit; 
  5. ?> 
  6. <?php 
  7. /**----------------------------------------------------------------------------------- 
  8. A3rev Plugin Admin UI 
  9.   
  10. TABLE OF CONTENTS 
  11.   
  12. - var plugin_name 
  13. - var admin_plugin_url 
  14. - var admin_plugin_dir 
  15. - var admin_pages 
  16. - admin_plugin_url() 
  17. - admin_plugin_dir() 
  18. - admin_pages() 
  19. - plugin_extension_start() 
  20. - plugin_extension_end() 
  21. - pro_fields_before() 
  22. - pro_fields_after() 
  23. - blue_message_box() 
  24.   
  25. -----------------------------------------------------------------------------------*/ 
  26.  
  27. class WC_Dynamic_Gallery_Admin_UI 
  28. /** 
  29. * @var string 
  30. * You must change to correct plugin name that you are working 
  31. */ 
  32. public $plugin_name = 'woo_dynamic_gallery'; 
  33.  
  34. public $google_api_key_option = 'woo_dynamic_gallery_google_api_key'; 
  35.  
  36. public $toggle_box_open_option = 'woo_dynamic_gallery_toggle_box_open'; 
  37.  
  38. public $is_free_plugin = true; 
  39.  
  40. public $version_transient = 'a3rev_woo_dgallery_update_info'; 
  41.  
  42. public $plugin_option_key = 'a3rev_woo_dgallery_plugin'; 
  43.  
  44. public $support_url = 'https://wordpress.org/support/plugin/woocommerce-dynamic-gallery/'; 
  45.  
  46.  
  47. /** 
  48. * @var string 
  49. * You must change to correct class name that you are working 
  50. */ 
  51. public $class_name = 'WC_Dynamic_Gallery'; 
  52.  
  53. /** 
  54. * @var string 
  55. * You must change to correct pro plugin page url on a3rev site 
  56. */ 
  57. public $pro_plugin_page_url = 'http://a3rev.com/shop/woocommerce-dynamic-gallery/'; 
  58.  
  59. /** 
  60. * @var string 
  61. */ 
  62. public $admin_plugin_url; 
  63.  
  64. /** 
  65. * @var string 
  66. */ 
  67. public $admin_plugin_dir; 
  68.  
  69. /** 
  70. * @var array 
  71. * 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' ) 
  72. */ 
  73. public $admin_pages = array(); 
  74.  
  75.  
  76. /**-----------------------------------------------------------------------------------*/ 
  77. /** admin_plugin_url() */ 
  78. /**-----------------------------------------------------------------------------------*/ 
  79. public function admin_plugin_url() { 
  80. if ( $this->admin_plugin_url ) return $this->admin_plugin_url; 
  81. return $this->admin_plugin_url = untrailingslashit( plugins_url( '/', __FILE__ ) ); 
  82.  
  83. /**-----------------------------------------------------------------------------------*/ 
  84. /** admin_plugin_dir() */ 
  85. /**-----------------------------------------------------------------------------------*/ 
  86. public function admin_plugin_dir() { 
  87. if ( $this->admin_plugin_dir ) return $this->admin_plugin_dir; 
  88. return $this->admin_plugin_dir = untrailingslashit( plugin_dir_path( __FILE__ ) ); 
  89.  
  90. /**-----------------------------------------------------------------------------------*/ 
  91. /** admin_pages() */ 
  92. /**-----------------------------------------------------------------------------------*/ 
  93. public function admin_pages() { 
  94. $admin_pages = apply_filters( $this->plugin_name . '_admin_pages', $this->admin_pages ); 
  95.  
  96. return (array)$admin_pages; 
  97.  
  98. /** 
  99. * get_premium_video_data() 
  100. * return array 
  101. * Data is used for Premium Video Box 
  102. */ 
  103. public function get_premium_video_data() { 
  104. $premium_video_data = array( 
  105. 'box_title' => __( 'Premium Version Enhanced Features', 'woo_dgallery' ),  
  106. 'image_url' => WOO_DYNAMIC_GALLERY_IMAGES_URL. '/video.jpg',  
  107. 'video_url' => 'https://www.youtube.com/embed/9dGw-ORfMIk?version=3&autoplay=1',  
  108. 'left_title' => __( 'Premium Version Enhanced Features', 'woo_dgallery' ),  
  109. 'left_text' => __( 'WooCommerce Dynamic Gallery Premium', 'woo_dgallery' ) 
  110. . "\n\n" . __( 'Quick Video showing the main (not all) enhanced features that are built into the WooCommerce Dynamic Gallery Premium version', 'woo_dgallery' ),  
  111. 'right_title' => __( 'Developer Support and Premium Features', 'woo_dgallery' ),  
  112. '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.', 'woo_dgallery' ) 
  113. . "\n\n" . '<a target="_blank" href="'.$this->pro_plugin_page_url.'" class="button-primary">' . __( 'Get Premium Features and Support', '' ) . '</a>',  
  114. ); 
  115.  
  116. return $premium_video_data; 
  117.  
  118. public function plugin_premium_video_box( $echo = true ) { 
  119. $premium_video_data = apply_filters( $this->plugin_name . '_plugin_premium_video_data', $this->get_premium_video_data() ); 
  120.  
  121. $output = '<div id="a3_plugin_premium_video_container">'; 
  122. $output .= '<div class="a3rev_panel_container">'; 
  123. $output .= '<div class="a3rev_panel_box">'; 
  124. $output .= '<div class="a3rev_panel_box_handle">'; 
  125. $output .= '<h3 class="a3-plugin-ui-panel-box">'.$premium_video_data['box_title'].'</h3>'; 
  126. $output .= '</div>'; 
  127. $output .= '<div class="a3rev_panel_video_box">'; 
  128. $output .= $this->plugin_premium_video(); 
  129. $output .= $this->plugin_premium_video_text(); 
  130. $output .= '</div>'; 
  131. $output .= '</div>'; 
  132. $output .= '</div>'; 
  133. $output .= '</div>'; 
  134.  
  135. $output = apply_filters( $this->plugin_name . '_plugin_premium_video', $output ); 
  136.  
  137. if ( $echo ) 
  138. echo $output; 
  139. else 
  140. return $output; 
  141.  
  142. public function plugin_premium_video( $echo = false ) { 
  143. $premium_video_data = apply_filters( $this->plugin_name . '_plugin_premium_video_data', $this->get_premium_video_data() ); 
  144.  
  145. wp_enqueue_style('thickbox'); 
  146. wp_enqueue_script('thickbox'); 
  147.  
  148. $output = '<div class="a3rev_panel_box_left_inside">'; 
  149. $output .= '<h2>' . $premium_video_data['left_title'] . '</h2>'; 
  150. $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'] ) ).'">'; 
  151. $output .= '<img src="'.esc_url( $premium_video_data['image_url'] ).'" />'; 
  152. $output .= '<div class="a3-plugin-premium-video-play"></div>'; 
  153. $output .= '</a>'; 
  154. $output .= wpautop( $premium_video_data['left_text'] ); 
  155. $output .= '</div>'; 
  156.  
  157. if ( $echo ) 
  158. echo $output; 
  159. else 
  160. return $output; 
  161.  
  162. public function plugin_premium_video_text( $echo = false ) { 
  163. $premium_video_data = apply_filters( $this->plugin_name . '_plugin_premium_video_data', $this->get_premium_video_data() ); 
  164.  
  165. $output = ''; 
  166. if ( '' != trim( $premium_video_data['right_text'] ) ) { 
  167. $output .= '<div class="a3rev_panel_box_separate"></div>'; 
  168. $output .= '<div class="a3rev_panel_box_right_inside">'; 
  169. $output .= '<h2>' . $premium_video_data['right_title'] . '</h2>'; 
  170. $output .= wpautop( $premium_video_data['right_text'] ); 
  171. $output .= '</div>'; 
  172.  
  173. if ( $echo ) 
  174. echo $output; 
  175. else 
  176. return $output; 
  177.  
  178. public function plugin_extension_boxes( $echo = false ) { 
  179.  
  180. /** 
  181. * extension_boxes 
  182. * ============================================= 
  183. * array ( 
  184. * 'id' => 'box_id' : Enter unique your box id 
  185. * 'content' => 'html_content' : (required) Enter the html content to show inside the box 
  186. * 'css' => 'custom style' : custom style for the box container 
  187. * ) 
  188. * 
  189. */ 
  190. $extension_boxes = apply_filters( $this->plugin_name . '_plugin_extension_boxes', array() ); 
  191.  
  192. $output = ''; 
  193. if ( is_array( $extension_boxes ) && count( $extension_boxes ) > 0 ) { 
  194. foreach ( $extension_boxes as $box ) { 
  195. if ( ! isset( $box['id'] ) ) $box['id'] = ''; 
  196. if ( ! isset( $box['class'] ) ) $box['class'] = ''; 
  197. if ( ! isset( $box['css'] ) ) $box['css'] = ''; 
  198. if ( ! isset( $box['content'] ) ) $box['content'] = ''; 
  199.  
  200. $output .= '<div id="'. esc_attr( $box['id'] ) .'" class="'. esc_attr( $box['class'] ) .' a3_plugin_panel_extension_box" style="'. esc_attr( $box['css'] ) .'">'; 
  201. $output .= $box['content']; 
  202. $output .= '</div>'; 
  203.  
  204. if ( $echo ) 
  205. echo $output; 
  206. else 
  207. return $output; 
  208.  
  209. /**-----------------------------------------------------------------------------------*/ 
  210. /** plugin_extension_start() */ 
  211. /* Start of yellow box on right for pro fields 
  212. /**-----------------------------------------------------------------------------------*/ 
  213. public function plugin_extension_start( $echo = true ) { 
  214. $output = '<div id="a3_plugin_panel_container">'; 
  215. $output .= '<div id="a3_plugin_panel_upgrade_area">'; 
  216. $output .= '<div id="a3_plugin_panel_extensions">'; 
  217. $output .= $this->plugin_extension_boxes( false ); 
  218. $output .= '</div>'; 
  219. $output .= '</div>'; 
  220. $output .= '<div id="a3_plugin_panel_fields">'; 
  221.  
  222. $output = apply_filters( $this->plugin_name . '_plugin_extension_start', $output ); 
  223.  
  224. if ( $echo ) 
  225. echo $output; 
  226. else 
  227. return $output; 
  228.  
  229. /**-----------------------------------------------------------------------------------*/ 
  230. /** plugin_extension_start() */ 
  231. /* End of yellow box on right for pro fields 
  232. /**-----------------------------------------------------------------------------------*/ 
  233. public function plugin_extension_end( $echo = true ) { 
  234. $output = '</div>'; 
  235. $output .= '</div>'; 
  236.  
  237. $output = apply_filters( $this->plugin_name . '_plugin_extension_end', $output ); 
  238.  
  239. if ( $echo ) 
  240. echo $output; 
  241. else 
  242. return $output; 
  243.  
  244.  
  245. /**-----------------------------------------------------------------------------------*/ 
  246. /** upgrade_top_message() */ 
  247. /* Show upgrade top message for pro fields 
  248. /**-----------------------------------------------------------------------------------*/ 
  249. public function upgrade_top_message( $echo = false, $setting_id = '' ) { 
  250. $upgrade_top_message = sprintf( '<div class="pro_feature_top_message">'  
  251. . __( 'Advanced Settings - Upgrade to the <a href="%s" target="_blank">%s License</a> to activate these settings.', 'woo_dgallery' )  
  252. . '</div>' 
  253. , 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 ) ) 
  254. , apply_filters( $this->plugin_name . '_' . $setting_id . '_pro_version_name', apply_filters( $this->plugin_name . '_pro_version_name', __( 'Pro Version', 'woo_dgallery' ) ) ) 
  255. ); 
  256.  
  257. $upgrade_top_message = apply_filters( $this->plugin_name . '_upgrade_top_message', $upgrade_top_message, $setting_id ); 
  258.  
  259. if ( $echo ) echo $upgrade_top_message; 
  260. else return $upgrade_top_message; 
  261.  
  262.  
  263. /**-----------------------------------------------------------------------------------*/ 
  264. /** pro_fields_before() */ 
  265. /* Start of yellow box on right for pro fields 
  266. /**-----------------------------------------------------------------------------------*/ 
  267. public function pro_fields_before( $echo = true ) { 
  268. echo apply_filters( $this->plugin_name . '_pro_fields_before', '<div class="pro_feature_fields">'. $this->upgrade_top_message() ); 
  269.  
  270. /**-----------------------------------------------------------------------------------*/ 
  271. /** pro_fields_after() */ 
  272. /* End of yellow border for pro fields 
  273. /**-----------------------------------------------------------------------------------*/ 
  274. public function pro_fields_after( $echo = true ) { 
  275. echo apply_filters( $this->plugin_name . '_pro_fields_after', '</div>' ); 
  276.  
  277. /**-----------------------------------------------------------------------------------*/ 
  278. /** blue_message_box() */ 
  279. /* Blue Message Box 
  280. /**-----------------------------------------------------------------------------------*/ 
  281. public function blue_message_box( $message = '', $width = '600px' ) { 
  282. $message = '<div class="a3rev_blue_message_box_container" style="width:'.$width.'"><div class="a3rev_blue_message_box">' . $message . '</div></div>'; 
  283. $message = apply_filters( $this->plugin_name . '_blue_message_box', $message ); 
  284.  
  285. return $message; 
  286.  
  287. /**-----------------------------------------------------------------------------------*/ 
  288. /** get_version_message() */ 
  289. /* Get new version message, also include error connect 
  290. /**-----------------------------------------------------------------------------------*/ 
  291. public function get_version_message() { 
  292. $version_message = ''; 
  293.  
  294. //Getting version number 
  295. $version_transient = get_transient( $this->version_transient ); 
  296. if ( false !== $version_transient ) { 
  297. $transient_timeout = '_transient_timeout_' . $this->version_transient; 
  298. $timeout = get_option( $transient_timeout, false ); 
  299. if ( false === $timeout ) { 
  300. $version_message = __( 'You should check now to see if have any new version is available', 'woo_dgallery' ); 
  301. } elseif ( 'cannot_connect_api' == $version_transient ) { 
  302. $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>.', 'woo_dgallery' ), $this->support_url ); 
  303. } else { 
  304. $version_info = explode( '||', $version_transient ); 
  305. if ( FALSE !== stristr( $version_transient, '||' ) 
  306. && is_array( $version_info ) 
  307. && isset( $version_info[1] ) && $version_info[1] == 'valid' 
  308. && version_compare( get_option('a3rev_woo_dgallery_lite_version') , $version_info[0], '<' ) ) { 
  309.  
  310. $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', 'woo_dgallery' ),  
  311. $version_info[0],  
  312. wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' . WOO_DYNAMIC_GALLERY_NAME ), 'upgrade-plugin_' . WOO_DYNAMIC_GALLERY_NAME ),  
  313. 'https://a3rev.com/my-account/downloads/' 
  314. ); 
  315.  
  316. } else { 
  317. $version_message = __( 'You should check now to see if have any new version is available', 'woo_dgallery' ); 
  318.  
  319. return $version_message; 
  320.  
  321.  
  322. ?> 
.