WP_Google_Places_Reviews_Free

Class WP_Google_Places_Reviews_Free.

Defined (1)

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

/google-places-reviews.php  
  1. class WP_Google_Places_Reviews_Free { 
  2.  
  3. /** 
  4. * Plugin Instance 
  5. * @var null 
  6. */ 
  7. protected static $_instance = null; 
  8.  
  9. /** 
  10. * GPR_Plugin_Framework 
  11. * @var GPR_Plugin_Framework 
  12. */ 
  13. public $gpr_framework = null; 
  14.  
  15. /** 
  16. * Main Google Places Reviews Instance 
  17. * Ensures only one instance of GPR is loaded or can be loaded. 
  18. * @since 1.4 
  19. */ 
  20. public static function instance() { 
  21. if ( is_null( self::$_instance ) ) { 
  22. self::$_instance = new self(); 
  23.  
  24. return self::$_instance; 
  25.  
  26. /** 
  27. * Class Constructor 
  28. */ 
  29. public function __construct() { 
  30.  
  31. add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); 
  32.  
  33. add_action( 'admin_enqueue_scripts', array( $this, 'options_scripts' ) ); 
  34.  
  35. add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 ); 
  36.  
  37. //Register the Google Places widget 
  38. add_action( 'widgets_init', array( $this, 'setup_widget' ) ); 
  39.  
  40. //Define Constants 
  41. $home_url = home_url(); 
  42. $plugins_url = plugins_url(); 
  43.  
  44. if ( stripos( $home_url, 'https://' ) === false ) { 
  45. $plugins_url = str_ireplace( 'https://', 'http://', $plugins_url ); 
  46.  
  47. define( 'GPR_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); 
  48. define( 'GPR_PLUGIN_URL', $plugins_url . '/' . basename( plugin_dir_path( __FILE__ ) ) ); 
  49.  
  50.  
  51. /** 
  52. * Loads the plugin language files 
  53. * @access public 
  54. * @since 1.0 
  55. * @return void 
  56. */ 
  57. function load_plugin_textdomain() { 
  58.  
  59. // Set filter for plugins's languages directory 
  60. $gpr_lang_dir = dirname( plugin_basename( __FILE__ ) ) . '/languages/'; 
  61. $gpr_lang_dir = apply_filters( 'gpr_languages_directory', $gpr_lang_dir ); 
  62.  
  63. // Traditional WordPress plugin locale filter 
  64. $locale = apply_filters( 'plugin_locale', get_locale(), 'google-places-reviews' ); 
  65. $mofile = sprintf( '%1$s-%2$s.mo', 'give', $locale ); 
  66.  
  67. // Setup paths to current locale file 
  68. $mofile_local = $gpr_lang_dir . $mofile; 
  69. $mofile_global = WP_LANG_DIR . '/google-places-reviews/' . $mofile; 
  70.  
  71. if ( file_exists( $mofile_global ) ) { 
  72. // Look in global /wp-content/languages/google-places-reviews folder 
  73. load_textdomain( 'google-places-reviews', $mofile_global ); 
  74. } elseif ( file_exists( $mofile_local ) ) { 
  75. // Look in local location from filter `gpr_languages_directory` 
  76. load_textdomain( 'google-places-reviews', $mofile_local ); 
  77. } else { 
  78. // Load the default language files packaged up w/ Google Places Reviews 
  79. load_plugin_textdomain( 'google-places-reviews', false, $gpr_lang_dir ); 
  80.  
  81.  
  82. /** 
  83. * Plugin Setup 
  84. */ 
  85. public function setup_widget() { 
  86.  
  87. // Include Core Framework class 
  88. require_once GPR_PLUGIN_PATH . '/classes/core.php'; 
  89.  
  90. // Create plugin instance 
  91. $google_places_reviews = new GPR_Plugin_Framework( __FILE__ ); 
  92.  
  93. // Include options set 
  94. require_once GPR_PLUGIN_PATH . '/inc/options.php'; 
  95.  
  96. // Create options page 
  97. $google_places_reviews->add_options_page( array(), $google_places_reviews_options ); 
  98.  
  99. // Make plugin meta translatable 
  100. __( 'Google Places Reviews', 'google-places-reviews' ); 
  101. __( 'Devin Walker', 'google-places-reviews' ); 
  102. __( 'google-places-reviews', 'google-places-reviews' ); 
  103.  
  104. //Include the widget 
  105. if ( ! class_exists( 'Google_Places_Reviews' ) ) { 
  106. require GPR_PLUGIN_PATH . '/classes/widget.php'; 
  107.  
  108. //Admin only 
  109. if ( is_admin() ) { 
  110. //Deactivating normal activation banner for upgrade to Place ID banner 
  111. require_once GPR_PLUGIN_PATH . '/inc/activation-banner.php'; 
  112.  
  113. //Display our upgrade notice 
  114. require_once GPR_PLUGIN_PATH . '/inc/upgrades/upgrade-functions.php'; 
  115. require_once GPR_PLUGIN_PATH . '/inc/upgrades/upgrades.php'; 
  116.  
  117.  
  118. register_widget( 'Google_Places_Reviews' ); 
  119.  
  120. return $google_places_reviews; 
  121.  
  122.  
  123.  
  124. /** 
  125. * Options Scripts 
  126. * @description: Custom JS/CSS for Options Page 
  127. * @param $hook 
  128. */ 
  129. function options_scripts( $hook ) { 
  130.  
  131. //Only on settings page 
  132. if ( 'settings_page_googleplacesreviews' === $hook ) { 
  133. wp_register_style( 'gpr_custom_options_styles', plugin_dir_url( __FILE__ ) . '/assets/css/options.css' ); 
  134. wp_enqueue_style( 'gpr_custom_options_styles' ); 
  135.  
  136.  
  137. /** 
  138. * Plugin row meta links 
  139. * @since 1.4 
  140. * @param array $input already defined meta links 
  141. * @param string $file plugin file path and name being processed 
  142. * @return array $input 
  143. */ 
  144. function plugin_row_meta( $input, $file ) { 
  145.  
  146. if ( $file != plugin_basename( __FILE__ ) ) { 
  147. return $input; 
  148.  
  149. $addons_link = esc_url( add_query_arg( array( 
  150. 'utm_source' => 'plugins-page',  
  151. 'utm_medium' => 'plugin-row',  
  152. 'utm_campaign' => 'admin',  
  153. ), 'https://wordimpress.com/plugins/google-places-reviews-pro/' ) 
  154. ); 
  155.  
  156. $docs_link = esc_url( add_query_arg( array( 
  157. 'utm_source' => 'plugins-page',  
  158. 'utm_medium' => 'plugin-row',  
  159. 'utm_campaign' => 'admin',  
  160. ), 'https://wordimpress.com/documentation/google-places-reviews/' ) 
  161. ); 
  162.  
  163. $links = array( 
  164. '<a href="' . $docs_link . '" target="_blank">' . esc_html__( 'View Documentation', 'give' ) . '</a>',  
  165. '<a href="' . $addons_link . '" target="_blank">' . esc_html__( 'Upgrade to Pro', 'give' ) . ' »</a>',  
  166. ); 
  167.  
  168. $input = array_merge( $input, $links ); 
  169.  
  170. return $input; 
  171.  
  172.  
  173. }//end WP_Google_Places_Reviews_Free class