facebook_likebox_slider

The Facebook Likebox Slider facebook likebox slider class.

Defined (1)

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

/facebook_likebox_slider.php  
  1. class facebook_likebox_slider 
  2. public static $inserted = 0; 
  3. protected static $instance = null; 
  4. /** 
  5. * Construct the plugin object 
  6. */ 
  7. public function __construct() 
  8. // installation and uninstallation hooks 
  9. register_activation_hook(__FILE__, array('facebook_likebox_slider', 'activate')); 
  10. register_deactivation_hook(__FILE__, array('facebook_likebox_slider', 'deactivate')); 
  11. register_uninstall_hook(__FILE__, array('facebook_likebox_slider', 'uninstall')); 
  12. add_filter( 'wp_footer', array(&$this, 'check_404') ); 
  13. if (is_admin()) 
  14. require_once(sprintf("%s/settings.php", dirname(__FILE__))); 
  15. $facebook_likebox_slider_settings = new facebook_likebox_slider_settings(); 
  16. $plugin = plugin_basename(__FILE__); 
  17. add_filter("plugin_action_links_$plugin", array(&$this, 'plugin_settings_link')); 
  18. else 
  19. if (isset($_SERVER['HTTP_HOST']) AND isset($_SERVER['REQUEST_URI'])) $domain = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; 
  20. else $domain = get_permalink(); 
  21. if ('http://'.$_SERVER['HTTP_HOST'].'/'==$domain||'http://'.$_SERVER['HTTP_HOST']==$domain||'http://www.'.$_SERVER['HTTP_HOST']==$domain||'http://www.'.$_SERVER['HTTP_HOST'].'/'==$domain) 
  22. add_action('init', array(&$this, 'enqueue_custom_scripts_and_styles')); 
  23. if (get_option('setting_appid')) add_action('wp_head', array(&$this, 'add_meta_appid')); 
  24. function check_404( $title ) { 
  25. if (is_404()) print('<div style="display:none">[disable_facebook_likebox_slider]</div>'); 
  26. public static function getInstance() 
  27. if (!isset($instance))  
  28. $instance = new facebook_likebox_slider; 
  29. return $instance; 
  30. /** 
  31. * Activate the plugin 
  32. **/ 
  33. public static function activate() 
  34. if ( ! get_option('setting_hide_icon')) 
  35. add_option('setting_hide_icon' , 'off'); 
  36. if ( ! get_option('setting_icon_size2')) 
  37. add_option('setting_icon_size2' , 'medium'); 
  38. if ( ! get_option('setting_auto_open2')) 
  39. add_option('setting_auto_open2' , 'on'); 
  40. if ( ! get_option('setting_lock_screen')) 
  41. add_option('setting_lock_screen' , 'on'); 
  42. if ( ! get_option('setting_closeable')) 
  43. add_option('setting_closeable' , 'on'); 
  44. if ( ! get_option('setting_timer')) 
  45. add_option('setting_timer' , '300'); 
  46. if ( ! get_option('setting_transparency')) 
  47. add_option('setting_transparency' , '90'); 
  48. if ( ! get_option('setting_likebox_message')) 
  49. add_option('setting_likebox_message' , 'Like Our Facebook Page'); 
  50. if ( ! get_option('setting_display_once_for_same_user')) 
  51. add_option('setting_display_once_for_same_user' , 'off'); 
  52. if ( ! get_option('setting_disable_on_mobile')) 
  53. add_option('setting_disable_on_mobile' , 'off'); 
  54. if ( ! get_option('setting_display_only_allowed_pages')) 
  55. add_option('setting_display_only_allowed_pages' , 'off'); 
  56. if ( ! get_option('setting_localization')) 
  57. add_option('setting_localization' , 'en_US'); 
  58. if ( ! get_option('setting_direction2')) 
  59. add_option('setting_direction2' , 'right'); 
  60. if ( ! get_option('setting_no_post_to_show')) 
  61. add_option('setting_no_post_to_show' , '5'); 
  62. if ( ! get_option('setting_vertical_distance2')) 
  63. add_option('setting_vertical_distance2' , '20'); 
  64. if ( ! get_option('setting_home_page_style')) 
  65. add_option('setting_home_page_style' , 'likebox'); 
  66. /** 
  67. * Deactivate the plugin 
  68. **/ 
  69. public static function deactivate() 
  70. if (get_option('setting_keep_settings')!='on') 
  71. unregister_setting('facebook_comment_slider-group', 'setting_appid'); 
  72. unregister_setting('facebook_comment_slider-group', 'setting_adminid'); 
  73. unregister_setting('facebook_comment_slider-group', 'setting_fbsitename'); 
  74. unregister_setting('facebook_comment_slider-group', 'setting_home_page_style'); 
  75. unregister_setting('facebook_comment_slider-group', 'setting_hide_icon'); 
  76. unregister_setting('facebook_comment_slider-group', 'setting_lock_screen'); 
  77. unregister_setting('facebook_comment_slider-group', 'setting_closeable'); 
  78. unregister_setting('facebook_comment_slider-group', 'setting_timer'); 
  79. unregister_setting('facebook_comment_slider-group', 'setting_transparency'); 
  80. unregister_setting('facebook_comment_slider-group', 'setting_display_once_for_same_user'); 
  81. unregister_setting('facebook_comment_slider-group', 'setting_disable_on_mobile'); 
  82. unregister_setting('facebook_comment_slider-group', 'setting_display_only_allowed_pages'); 
  83. unregister_setting('facebook_comment_slider-group', 'setting_localization'); 
  84. unregister_setting('facebook_comment_slider-group', 'setting_scheme'); 
  85. unregister_setting('facebook_comment_slider-group', 'setting_skin'); 
  86. unregister_setting('facebook_comment_slider-group', 'setting_hide_alreadyliked'); 
  87. unregister_setting('facebook_comment_slider-group', 'setting_keep_settings'); 
  88. unregister_setting('facebook_comment_slider_comment_box-group', 'setting_vertical_distance1'); 
  89. unregister_setting('facebook_comment_slider_comment_box-group', 'setting_icon_size1'); 
  90. unregister_setting('facebook_comment_slider_comment_box-group', 'setting_auto_open1'); 
  91. unregister_setting('facebook_comment_slider_comment_box-group', 'setting_message'); 
  92. unregister_setting('facebook_comment_slider_comment_box-group', 'setting_specified_page1'); 
  93. unregister_setting('facebook_comment_slider_comment_box-group', 'setting_direction1'); 
  94. unregister_setting('facebook_comment_slider_comment_box-group', 'setting_no_post_to_show'); 
  95. unregister_setting('facebook_comment_slider_comment_box-group', 'setting_icon_url1'); 
  96. unregister_setting('facebook_comment_slider_comment_box-group', 'setting_shake1'); 
  97. unregister_setting('facebook_comment_slider_like_box-group', 'setting_vertical_distance2'); 
  98. unregister_setting('facebook_comment_slider_like_box-group', 'setting_icon_size2'); 
  99. unregister_setting('facebook_comment_slider_like_box-group', 'setting_auto_open2'); 
  100. unregister_setting('facebook_comment_slider_like_box-group', 'setting_likebox_message'); 
  101. unregister_setting('facebook_comment_slider_like_box-group', 'setting_direction2'); 
  102. unregister_setting('facebook_comment_slider_like_box-group', 'setting_icon_url2'); 
  103. unregister_setting('facebook_comment_slider_like_box-group', 'setting_shake2'); 
  104. unregister_setting('facebook_comment_slider_post_box-group', 'setting_vertical_distance3'); 
  105. unregister_setting('facebook_comment_slider_post_box-group', 'setting_icon_size3'); 
  106. unregister_setting('facebook_comment_slider_post_box-group', 'setting_auto_open3'); 
  107. unregister_setting('facebook_comment_slider_post_box-group', 'setting_postbox_message'); 
  108. unregister_setting('facebook_comment_slider_post_box-group', 'setting_direction3'); 
  109. unregister_setting('facebook_comment_slider_post_box-group', 'setting_icon_url3'); 
  110. unregister_setting('facebook_comment_slider_post_box-group', 'setting_shake3'); 
  111.  
  112. /** 
  113. * Uninstall the plugin 
  114. **/ 
  115. public static function uninstall() 
  116. if (get_option('setting_keep_settings')!='on') 
  117. delete_option('setting_appid'); 
  118. delete_option('setting_adminid'); 
  119. delete_option('setting_fbsitename'); 
  120. delete_option('setting_home_page_style'); 
  121. delete_option('setting_hide_icon'); 
  122. delete_option('setting_lock_screen'); 
  123. delete_option('setting_closeable'); 
  124. delete_option('setting_timer'); 
  125. delete_option('setting_transparency'); 
  126. delete_option('setting_display_once_for_same_user'); 
  127. delete_option('setting_disable_on_mobile'); 
  128. delete_option('setting_display_only_allowed_pages'); 
  129. delete_option('setting_localization'); 
  130. delete_option('setting_scheme'); 
  131. delete_option('setting_skin'); 
  132. delete_option('setting_hide_alreadyliked'); 
  133. delete_option('setting_keep_settings'); 
  134. delete_option('setting_vertical_distance1'); 
  135. delete_option('setting_icon_size1'); 
  136. delete_option('setting_auto_open1'); 
  137. delete_option('setting_message'); 
  138. delete_option('setting_specified_page1'); 
  139. delete_option('setting_direction1'); 
  140. delete_option('setting_no_post_to_show'); 
  141. delete_option('setting_icon_url1'); 
  142. delete_option('setting_shake1'); 
  143. delete_option('setting_vertical_distance2'); 
  144. delete_option('setting_icon_size2'); 
  145. delete_option('setting_auto_open2'); 
  146. delete_option('setting_likebox_message'); 
  147. delete_option('setting_direction2'); 
  148. delete_option('setting_icon_url2'); 
  149. delete_option('setting_shake2'); 
  150. delete_option('setting_vertical_distance3'); 
  151. delete_option('setting_icon_size3'); 
  152. delete_option('setting_auto_open3'); 
  153. delete_option('setting_postbox_message'); 
  154. delete_option('setting_direction3'); 
  155. delete_option('setting_icon_url3'); 
  156. delete_option('setting_shake3'); 
  157.  
  158. function add_meta_appid() 
  159. return print('<meta property="fb:app_id" content="'.get_option('setting_appid').'">'); 
  160.  
  161. function enqueue_custom_scripts_and_styles()  
  162. $direction = '';$domain = ''; 
  163. if (get_option('setting_direction2')=='right') $direction2 = 'right'; 
  164. else $direction2 = 'left'; 
  165. if (get_option('setting_closeable')=='on') $closeable = 'true'; 
  166. else $closeable = 'false'; 
  167. if (get_option('setting_hide_icon')=='off') $hide_icon = 'false'; 
  168. else $hide_icon = 'true'; 
  169. if (get_option('setting_icon_size2')) $icon_size2 = get_option('setting_icon_size2'); 
  170. else $icon_size2 = 'medium'; 
  171. if (get_option('setting_auto_open2')=='off') $auto_open2 = 'false'; 
  172. else $auto_open2 = 'true'; 
  173. if (get_option('setting_lock_screen')=='on') $lock_screen = 'true'; 
  174. else $lock_screen = 'false'; 
  175. if (get_option('setting_timer')>0) $timer = get_option('setting_timer'); 
  176. if (get_option('setting_transparency')>=0) $transparency = get_option('setting_transparency'); 
  177. else $transparency = '90'; 
  178. if (get_option('setting_likebox_message')) $likebox_message = get_option('setting_likebox_message'); 
  179. else $likebox_message = 'Follow Us on Facebook'; 
  180. if (get_option('setting_display_once_for_same_user')=='on') $dofsu = 'true'; 
  181. else $dofsu = 'false'; 
  182. if (get_option('setting_disable_on_mobile')=='on') $dom = 'true'; 
  183. else $dom = 'false'; 
  184. if (get_option('setting_display_only_allowed_pages')=='on') $doap = 'true'; 
  185. else $doap = 'false'; 
  186. if (get_option('setting_no_post_to_show')>0) $no_post_to_show = get_option('setting_no_post_to_show'); 
  187. else $no_post_to_show = 5; 
  188. if (get_option('setting_localization')) $local = get_option('setting_localization'); 
  189. else $local = 'en_US'; 
  190. if (get_option('setting_appid')) $appid = get_option('setting_appid'); 
  191. else $appid = 'false'; 
  192. if (get_option('setting_scheme')) $scheme = get_option('setting_scheme'); 
  193. else $scheme = 'light'; 
  194. if (get_option('setting_skin')) $skin = get_option('setting_skin'); 
  195. else $skin = 'default'; 
  196. if (get_option('setting_hide_alreadyliked')=='on') $hal = true; 
  197. else $hal = false; 
  198. if (get_option('setting_shake2')) $shake2 = get_option('setting_shake2'); 
  199. else $shake2 = '0'; 
  200. if (get_option('setting_icon_url2')) $icon_url2 = get_option('setting_icon_url2'); 
  201. else $icon_url2 = ''; 
  202. if (get_option('setting_vertical_distance2')) $vertical_distance2 = get_option('setting_vertical_distance2'); 
  203. else $vertical_distance2 = '30'; 
  204. if (get_option('setting_home_page_style')) $home_page_style = get_option('setting_home_page_style'); 
  205. else $home_page_style = 'likebox'; 
  206. if (get_option('setting_fbsitename')) $fbsitename = get_option('setting_fbsitename'); 
  207. else $fbsitename = ''; 
  208. if (isset($_SERVER['HTTP_HOST']) AND isset($_SERVER['REQUEST_URI'])) $domain = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; 
  209. else $domain = get_permalink(); 
  210. $channel_url = plugins_url( '/templates/channel.html' , __FILE__ ); 
  211. $xid = md5($domain); 
  212.  
  213. /** params for demo start */ 
  214. if (isset($_REQUEST['s_direction'])) $direction1 = $_REQUEST['s_direction']; 
  215. if (isset($_REQUEST['s_closeable'])) $closeable = $_REQUEST['s_closeable']; 
  216. if (isset($_REQUEST['s_hide_icon'])) $hide_icon = $_REQUEST['s_hide_icon']; 
  217. if (isset($_REQUEST['s_icon_size'])) $icon_size1 = $_REQUEST['s_icon_size']; 
  218. if (isset($_REQUEST['s_auto_open'])) $auto_open1 = $_REQUEST['s_auto_open']; 
  219. if (isset($_REQUEST['s_lock_screen'])) $lock_screen = $_REQUEST['s_lock_screen']; 
  220. if (isset($_REQUEST['s_timer'])) $timer = $_REQUEST['s_timer']; 
  221. if (isset($_REQUEST['s_transparency'])) $transparency = $_REQUEST['s_transparency']; 
  222. if (isset($_REQUEST['s_message'])) $message = $_REQUEST['s_message']; 
  223. if (isset($_REQUEST['s_localization'])) $local = $_REQUEST['s_localization']; 
  224. if (isset($_REQUEST['s_scheme'])) $scheme = $_REQUEST['s_scheme']; 
  225. if (isset($_REQUEST['s_shake'])) $shake1 = $_REQUEST['s_shake']; 
  226. if (isset($_REQUEST['s_vertical'])) $vertical_distance1 = $_REQUEST['s_vertical']; 
  227. if (isset($_REQUEST['s_icon_url'])) $icon_url1 = $_REQUEST['s_icon_url']; 
  228. if (isset($_REQUEST['s_skin'])) $skin = $_REQUEST['s_skin']; 
  229.  
  230. /** params for demo end */ 
  231. $currentstyle = "home"; 
  232. wp_enqueue_style('facebook_likebox_slider_style', plugins_url( '/templates/assets/css/facebook_likebox_slider.css' , __FILE__ )); 
  233. wp_enqueue_style('jquery_ui_style', plugins_url( '/templates/assets/css/jquery-ui.css' , __FILE__ )); 
  234. wp_enqueue_script('jquery'); 
  235. wp_enqueue_script('jquery-ui-core', array('jquery')); 
  236. wp_enqueue_script('jquery-effects-core', array('jquery')); 
  237. wp_enqueue_script('jquery-effects-fade', array('jquery-effects-core')); 
  238. wp_enqueue_script('jquery-effects-slide', array('jquery-effects-core')); 
  239. wp_enqueue_script('jquery-effects-shake', array('jquery-effects-core')); 
  240. wp_enqueue_script('jquerymousewheel', plugins_url('/templates/assets/js/jquery.mousewheel.js' , __FILE__ ), array('jquery'), '1.0.0.1', true ); 
  241. wp_enqueue_script('jscrollpane', plugins_url('/templates/assets/js/jquery.jscrollpane.min.js' , __FILE__ ), array('jquery'), '1.0.0.1', true); 
  242. wp_register_script( "facebook_likebox_slider_script", plugins_url('/templates/assets/js/facebook_likebox_slider.min.js' , __FILE__ ), array('jquery', 'jquery-ui-core', 'jquery-effects-core', 'jquery-effects-fade', 'jquery-effects-slide', 'jquery-effects-shake'), '1.0.1.0', false ); 
  243. wp_localize_script( 'facebook_likebox_slider_script', 'flb_params', array( 'direction2'=>$direction2, 'closeable'=>$closeable, 'timer'=>$timer, 'transparency'=>$transparency, 'hide_icon'=>$hide_icon, 'icon_size2'=>$icon_size2, 'auto_open2'=>$auto_open2, 'lock_screen'=>$lock_screen, 'likebox_message'=>$likebox_message, 'dofsu'=>$dofsu, 'dom'=>$dom, 'doap'=>$doap, 'no_post_to_show'=>$no_post_to_show, 'appid'=>$appid, 'vertical_distance2'=>$vertical_distance2, 'home_page_style'=>'likebox', 'fbsitename'=>$fbsitename, 'currentstyle'=>$currentstyle, 'channel_url'=>$channel_url, 'local'=>$local, 'xid'=>$xid, 'scheme' => $scheme, 'skin' => $skin, 'hide_alreadyliked' => $hal, 'shake2' => $shake2, 'icon_url2' => $icon_url2)); 
  244. wp_enqueue_script( 'facebook_likebox_slider_script' ); 
  245.  
  246. /** 
  247. * Add the settings link to the plugins page 
  248. **/ 
  249. function plugin_settings_link($links) 
  250. {  
  251. $settings_link = '<a href="options-general.php?page=facebook_likebox_slider">Settings</a>'; 
  252. array_unshift($links, $settings_link);  
  253. return $links;