/yakadanda-googleplus-hangout-events.php

  1. <?php 
  2. /** 
  3. * Plugin Name: Yakadanda Google+ Hangout Events 
  4. * Plugin URI: http://www.yakadanda.com/plugins/yakadanda-google-hangout-events/ 
  5. * Description: A countdown function to time of the Google+ Hangout Events. 
  6. * Version: 0.3.5 
  7. * Author: Peter Ricci 
  8. * Author URI: http://www.yakadanda.com/ 
  9. * Text Domain: yakadanda-google-hangout-events 
  10. * Domain Path: /languages/ 
  11. * License: GPL2 
  12. */ 
  13.  
  14. /** Put setup procedures to be run when the plugin is activated in the following function */ 
  15. register_activation_hook(__FILE__, 'googleplushangoutevent_activate'); 
  16. function googleplushangoutevent_activate() { 
  17. if (!get_option('yakadanda_googleplus_hangout_event_options')) 
  18. add_option('yakadanda_googleplus_hangout_event_options', null, false, false); 
  19. if (!get_option('yakadanda_googleplus_hangout_event_access_token')) 
  20. add_option('yakadanda_googleplus_hangout_event_access_token', null, false, false); 
  21. googleplushangoutevent_event_init(); 
  22. flush_rewrite_rules(); 
  23.  
  24. // On deacativation, clean up anything your component has added. 
  25. register_deactivation_hook( __FILE__, 'googleplushangoutevent_deactivate'); 
  26. function googleplushangoutevent_deactivate() { 
  27. // You might want to delete any options or tables that your component created. 
  28.  
  29.  
  30. if(!defined('GPLUS_HANGOUT_EVENTS_VER')) define('GPLUS_HANGOUT_EVENTS_VER', '0.3.5'); 
  31. if(!defined('GPLUS_HANGOUT_EVENTS_PLUGIN_DIR')) define('GPLUS_HANGOUT_EVENTS_PLUGIN_DIR', plugin_dir_path(__FILE__)); 
  32. if(!defined('GPLUS_HANGOUT_EVENTS_PLUGIN_URL')) define('GPLUS_HANGOUT_EVENTS_PLUGIN_URL', plugins_url(null, __FILE__)); 
  33. if(!defined('GPLUS_HANGOUT_EVENTS_THEME_DIR')) define('GPLUS_HANGOUT_EVENTS_THEME_DIR', get_stylesheet_directory()); 
  34. if(!defined('GPLUS_HANGOUT_EVENTS_THEME_URL')) define('GPLUS_HANGOUT_EVENTS_THEME_URL', get_stylesheet_directory_uri()); 
  35.  
  36. // Load plugin textdomain 
  37. add_action( 'plugins_loaded', 'googleplushangoutevent_load_textdomain' ); 
  38. function googleplushangoutevent_load_textdomain() { 
  39. load_plugin_textdomain('yakadanda-google-hangout-events', false, dirname( plugin_basename( __FILE__ ) ) . '/languages'); 
  40.  
  41. // Store plugin version 
  42. if (!get_option('yakadanda_googleplus_hangout_event_version')) add_option('yakadanda_googleplus_hangout_event_version', GPLUS_HANGOUT_EVENTS_VER); 
  43.  
  44. // Upgrade 
  45. if (GPLUS_HANGOUT_EVENTS_VER != get_option('yakadanda_googleplus_hangout_event_version')) { 
  46. update_option('yakadanda_googleplus_hangout_event_version', GPLUS_HANGOUT_EVENTS_VER ); 
  47.  
  48.  
  49. add_filter('plugin_action_links', 'googleplushangoutevent_action_links', 10, 2); 
  50. function googleplushangoutevent_action_links($links, $file) { 
  51. static $googleplus_hangout_events; 
  52.  
  53. if (!$googleplus_hangout_events) $googleplus_hangout_events = plugin_basename(__FILE__); 
  54.  
  55. if ($file == $googleplus_hangout_events) { 
  56. $settings_link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/options-general.php?page=googleplus-hangout-events">Settings</a>'; 
  57. array_unshift($links, $settings_link); 
  58.  
  59. return $links; 
  60.  
  61. // Register javascripts & stylesheets 
  62. add_action('init', 'googleplushangoutevent_register'); 
  63. function googleplushangoutevent_register() { 
  64. /** Styles */ 
  65. // Backend 
  66. // Roboto Condensed font 
  67. wp_register_style('roboto-condensed', 'http://fonts.googleapis.com/css?family=Roboto+Condensed:400, 300, 700', false, GPLUS_HANGOUT_EVENTS_VER, 'all'); 
  68. // Yakadanda GooglePlus Hangout Event style 
  69. wp_register_style('googleplushangoutevents-admin-style', GPLUS_HANGOUT_EVENTS_PLUGIN_URL . '/css/admin.css', array('roboto-condensed'), GPLUS_HANGOUT_EVENTS_VER, 'all'); 
  70.  
  71. // Frontend 
  72. // Google web fonts 
  73. $google_fonts = googleplushangoutevent_google_fonts(); 
  74. if ($google_fonts) wp_register_style('googleplushangoutevent-google-fonts', 'http://fonts.googleapis.com/css?family=' . $google_fonts, false, GPLUS_HANGOUT_EVENTS_VER, 'all'); 
  75. if ( file_exists(GPLUS_HANGOUT_EVENTS_THEME_DIR . '/css/google-hangout-events.css' )) { 
  76. wp_register_style('googleplushangoutevents-style', GPLUS_HANGOUT_EVENTS_THEME_URL . '/css/google-hangout-events.css', false, GPLUS_HANGOUT_EVENTS_VER, 'all'); 
  77. } else { 
  78. wp_register_style('googleplushangoutevents-style', GPLUS_HANGOUT_EVENTS_PLUGIN_URL . '/css/google-hangout-events.css', false, GPLUS_HANGOUT_EVENTS_VER, 'all'); 
  79.  
  80. /** Scripts */ 
  81. // Google+ Embedded Posts 
  82. wp_register_script('googleplushangoutevent-embedded-posts', GPLUS_HANGOUT_EVENTS_PLUGIN_URL . '/js/googleplus-embedded-posts.js', array('jquery'), GPLUS_HANGOUT_EVENTS_VER, true ); 
  83. // Countdown timer jQuery Plugin 
  84. wp_register_script('googleplushangoutevent-countdown', GPLUS_HANGOUT_EVENTS_PLUGIN_URL . '/js/jquery.jcountdown.min.js', array('jquery'), '2.0.1', true ); 
  85. // Google+ Hangout Event script 
  86. wp_register_script('googleplushangoutevent-script', GPLUS_HANGOUT_EVENTS_PLUGIN_URL . '/js/script.js', array('jquery'), GPLUS_HANGOUT_EVENTS_VER, true ); 
  87.  
  88. // ajax 
  89. wp_localize_script('googleplushangoutevent-script', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) )); 
  90.  
  91. // backend scripts 
  92. add_action('admin_enqueue_scripts', 'googleplushangoutevent_admin_enqueue_scripts'); 
  93. function googleplushangoutevent_admin_enqueue_scripts() { 
  94. if (googleplushangoutevent_is_page()) { 
  95. // Call stylesheets 
  96. wp_enqueue_style('googleplushangoutevents-admin-style'); 
  97.  
  98. // Call javascripts 
  99. wp_enqueue_script('iris'); 
  100. wp_enqueue_script('jquery-ui-tabs'); 
  101. wp_enqueue_script('jquery-ui-dialog'); 
  102. wp_enqueue_script('media-upload'); 
  103. wp_enqueue_script('googleplushangoutevent-script'); 
  104. } else { 
  105. // load stylesheets 
  106. wp_enqueue_style('googleplushangoutevents-admin-menu', GPLUS_HANGOUT_EVENTS_PLUGIN_URL . '/css/menu.css', array(), GPLUS_HANGOUT_EVENTS_VER , 'all'); 
  107.  
  108. // frontend scripts 
  109. add_action('wp_enqueue_scripts', 'googleplushangoutevent_wp_enqueue_scripts'); 
  110. function googleplushangoutevent_wp_enqueue_scripts() { 
  111. // Call javascripts 
  112. wp_enqueue_script('googleplushangoutevent-embedded-posts'); 
  113. function googleplushangoutevent_wp_enqueue_scripts_load() { 
  114. // Call stylesheets 
  115. $google_fonts = googleplushangoutevent_google_fonts(); 
  116. if ($google_fonts) wp_enqueue_style('googleplushangoutevent-google-fonts'); 
  117. wp_enqueue_style('googleplushangoutevents-style'); 
  118.  
  119. // Call javascripts 
  120. wp_enqueue_script('googleplushangoutevent-countdown'); 
  121. wp_enqueue_script('googleplushangoutevent-script'); 
  122.  
  123. require_once(dirname( __FILE__ ) . '/admin/includes.php'); 
.