admin
3 years ago
core
3 years ago
class-activator.php
3 years ago
class-assets.php
3 years ago
class-builder-page.php
3 years ago
class-deactivator.php
3 years ago
class-debug-info.php
3 years ago
class-feed-deserializer.php
3 years ago
class-feed-old.php
4 years ago
class-feed-page.php
4 years ago
class-feed-serializer-ajax.php
3 years ago
class-feed-serializer.php
3 years ago
class-feed-shortcode.php
4 years ago
class-feed-widget.php
4 years ago
class-plugin-overview-ajax.php
3 years ago
class-plugin-overview.php
3 years ago
class-plugin-settings.php
3 years ago
class-plugin-support.php
4 years ago
class-plugin.php
3 years ago
class-post-types.php
3 years ago
class-reviews-cron.php
3 years ago
class-settings-save.php
3 years ago
class-view.php
3 years ago
index.php
4 years ago
page-setting-fig.php
3 years ago
page-setting-support.php
4 years ago
class-plugin.php
147 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WP_Rplg_Google_Reviews\Includes; |
| 4 | |
| 5 | use WP_Rplg_Google_Reviews\Includes\Admin\Admin_Menu; |
| 6 | use WP_Rplg_Google_Reviews\Includes\Admin\Admin_Tophead; |
| 7 | use WP_Rplg_Google_Reviews\Includes\Admin\Admin_Notice; |
| 8 | use WP_Rplg_Google_Reviews\Includes\Admin\Admin_Feed_Columns; |
| 9 | use WP_Rplg_Google_Reviews\Includes\Admin\Admin_Rev; |
| 10 | use WP_Rplg_Google_Reviews\Includes\Admin\Admin_Rateus_Ajax; |
| 11 | |
| 12 | use WP_Rplg_Google_Reviews\Includes\Core\Core; |
| 13 | use WP_Rplg_Google_Reviews\Includes\Core\Connect_Google; |
| 14 | use WP_Rplg_Google_Reviews\Includes\Core\Database; |
| 15 | |
| 16 | final class Plugin { |
| 17 | |
| 18 | protected $name; |
| 19 | protected $version; |
| 20 | protected $activator; |
| 21 | protected $deactivator; |
| 22 | |
| 23 | public function __construct() { |
| 24 | $this->name = 'widget-google-reviews'; |
| 25 | $this->version = GRW_VERSION; |
| 26 | } |
| 27 | |
| 28 | public function register() { |
| 29 | register_activation_hook(GRW_PLUGIN_FILE, array($this, 'activate')); |
| 30 | register_deactivation_hook(GRW_PLUGIN_FILE, array($this, 'deactivate')); |
| 31 | |
| 32 | add_action('admin_init', array($this, 'admin_init')); |
| 33 | add_action('plugins_loaded', array($this, 'register_services')); |
| 34 | } |
| 35 | |
| 36 | public function admin_init() { |
| 37 | if (get_option('grw_do_activation', false)) { |
| 38 | delete_option('grw_do_activation'); |
| 39 | wp_safe_redirect(admin_url('admin.php?page=grw')); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | public function register_services() { |
| 44 | $this->init_language(); |
| 45 | |
| 46 | $database = new Database(); |
| 47 | |
| 48 | $activator = new Activator($database); |
| 49 | $activator->register(); |
| 50 | |
| 51 | $assets = new Assets(GRW_ASSETS_URL, $this->version, get_option('grw_debug_mode') == '1'); |
| 52 | $assets->register(); |
| 53 | |
| 54 | $post_types = new Post_Types(); |
| 55 | $post_types->register(); |
| 56 | |
| 57 | $feed_deserializer = new Feed_Deserializer(new \WP_Query()); |
| 58 | |
| 59 | $debug_info = new Debug_Info($activator, $feed_deserializer); |
| 60 | |
| 61 | $feed_page = new Feed_Page($feed_deserializer); |
| 62 | $feed_page->register(); |
| 63 | |
| 64 | $core = new Core(); |
| 65 | |
| 66 | $view = new View(); |
| 67 | |
| 68 | $builder_page = new Builder_Page($feed_deserializer, $core, $view); |
| 69 | $builder_page->register(); |
| 70 | |
| 71 | $feed_old = new Feed_Old(); |
| 72 | |
| 73 | $feed_shortcode = new Feed_Shortcode($feed_deserializer, $assets, $core, $view, $feed_old); |
| 74 | $feed_shortcode->register(); |
| 75 | |
| 76 | Feed_Widget::$static_feed_deserializer = $feed_deserializer; |
| 77 | Feed_Widget::$static_core = $core; |
| 78 | Feed_Widget::$static_view = $view; |
| 79 | Feed_Widget::$static_assets = $assets; |
| 80 | Feed_Widget::$static_feed_old = $feed_old; |
| 81 | add_action('widgets_init', function() { |
| 82 | register_widget('WP_Rplg_Google_Reviews\Includes\Feed_Widget'); |
| 83 | }); |
| 84 | |
| 85 | $connect_google = new Connect_Google(); |
| 86 | |
| 87 | $reviews_cron = new Reviews_Cron($connect_google, $feed_deserializer); |
| 88 | $reviews_cron->register(); |
| 89 | |
| 90 | $this->deactivator = new Deactivator($reviews_cron); |
| 91 | |
| 92 | if (is_admin()) { |
| 93 | $feed_serializer = new Feed_Serializer(); |
| 94 | $feed_serializer_ajax = new Feed_Serializer_Ajax($feed_serializer, $feed_deserializer, $core, $view); |
| 95 | |
| 96 | $admin_notice = new Admin_Notice(); |
| 97 | $admin_notice->register(); |
| 98 | |
| 99 | $admin_menu = new Admin_Menu(); |
| 100 | $admin_menu->register(); |
| 101 | |
| 102 | $admin_tophead = new Admin_Tophead(); |
| 103 | $admin_tophead->register(); |
| 104 | |
| 105 | $admin_feed_columns = new Admin_Feed_Columns($feed_deserializer); |
| 106 | $admin_feed_columns->register(); |
| 107 | |
| 108 | $plugin_overview_ajax = new Plugin_Overview_Ajax($core); |
| 109 | $plugin_overview = new Plugin_Overview(); |
| 110 | $plugin_overview->register(); |
| 111 | |
| 112 | $settings_save = new Settings_Save($activator, $reviews_cron); |
| 113 | $settings_save->register(); |
| 114 | |
| 115 | $plugin_settings = new Plugin_Settings($debug_info); |
| 116 | $plugin_settings->register(); |
| 117 | |
| 118 | $plugin_support = new Plugin_Support(); |
| 119 | $plugin_support->register(); |
| 120 | |
| 121 | $admin_rev = new Admin_Rev(); |
| 122 | $admin_rev->register(); |
| 123 | |
| 124 | $rateus_ajax = new Admin_Rateus_Ajax(); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | public function init_language() { |
| 129 | load_plugin_textdomain('widget-google-reviews', false, basename(dirname(GRW_PLUGIN_FILE)) . '/languages'); |
| 130 | } |
| 131 | |
| 132 | public function activate($network_wide = false) { |
| 133 | $now = time(); |
| 134 | update_option('grw_activation_time', $now); |
| 135 | |
| 136 | add_option('grw_is_multisite', $network_wide); |
| 137 | |
| 138 | add_option('grw_do_activation', true); |
| 139 | |
| 140 | $activator = new Activator(new Database()); |
| 141 | $activator->activate(); |
| 142 | } |
| 143 | |
| 144 | public function deactivate() { |
| 145 | $this->deactivator->deactivate(); |
| 146 | } |
| 147 | } |