| @@ -44,8 +44,9 @@ | ||
| 44 | 44 | $this->set_locale(); |
| 45 | 45 | $this->define_admin_hooks(); |
| 46 | 46 | $this->define_public_hooks(); |
| 47 | 47 | $this->define_block_hooks(); |
| 48 | + $this->define_widget_hooks(); | |
| 48 | 49 | } |
| 49 | 50 | |
| 50 | 51 | /** |
| 51 | 52 | * Load the required dependencies for this plugin. |
| @@ -81,9 +82,9 @@ | ||
| 81 | 82 | |
| 82 | 83 | /** |
| 83 | 84 | * The classes responsible for defining all actions that occur in the admin area. |
| 84 | 85 | */ |
| 85 | - require_once AYG_DIR . 'admin/admin.php'; | |
| 86 | + require_once AYG_DIR . 'admin/admin.php'; | |
| 86 | 87 | require_once AYG_DIR . 'admin/settings.php'; |
| 87 | 88 | |
| 88 | 89 | /** |
| 89 | 90 | * The class responsible for defining all actions that occur in the public-facing |
| @@ -89,13 +90,19 @@ | ||
| 89 | 90 | * The class responsible for defining all actions that occur in the public-facing |
| 90 | 91 | * side of the site. |
| 91 | 92 | */ |
| 92 | 93 | require_once AYG_DIR . 'public/public.php'; |
| 94 | + require_once AYG_DIR . 'public/cron.php'; | |
| 93 | 95 | |
| 94 | 96 | /** |
| 95 | 97 | * The class responsible for defining all actions that occur in the gutenberg block. |
| 96 | 98 | */ |
| 97 | - require_once AYG_DIR. 'block/block.php'; | |
| 99 | + require_once AYG_DIR. 'block/block.php'; | |
| 100 | + | |
| 101 | + /** | |
| 102 | + * The class responsible for defining all actions that occur in the widget. | |
| 103 | + */ | |
| 104 | + require_once AYG_DIR . 'widget/widget.php'; | |
| 98 | 105 | |
| 99 | 106 | /** |
| 100 | 107 | * Create an instance of the loader. |
| 101 | 108 | */ |
| @@ -126,8 +133,10 @@ | ||
| 126 | 133 | |
| 127 | 134 | $this->loader->add_action( 'admin_init', $admin, 'insert_missing_options', 1 ); |
| 128 | 135 | $this->loader->add_action( 'admin_enqueue_scripts', $admin, 'enqueue_styles' ); |
| 129 | 136 | $this->loader->add_action( 'admin_enqueue_scripts', $admin, 'enqueue_scripts' ); |
| 137 | + $this->loader->add_action( 'elementor/editor/after_enqueue_styles', $admin, 'enqueue_styles' ); | |
| 138 | + $this->loader->add_action( 'elementor/editor/after_enqueue_scripts', $admin, 'enqueue_scripts' ); | |
| 130 | 139 | $this->loader->add_action( 'admin_menu', $admin, 'admin_menu' ); |
| 131 | 140 | $this->loader->add_action( 'admin_notices', $admin, 'admin_notices' ); |
| 132 | 141 | $this->loader->add_action( 'wp_ajax_ayg_save_api_key', $admin, 'ajax_callback_save_api_key' ); |
| 133 | 142 | |
| @@ -137,9 +146,9 @@ | ||
| 137 | 146 | $settings = new AYG_Admin_Settings(); |
| 138 | 147 | |
| 139 | 148 | $this->loader->add_action( 'admin_menu', $settings, 'admin_menu' ); |
| 140 | 149 | $this->loader->add_action( 'admin_init', $settings, 'admin_init' ); |
| 141 | - $this->loader->add_action( 'wp_ajax_ayg_delete_cache', $settings, 'ajax_callback_delete_cache' ); | |
| 150 | + $this->loader->add_action( 'wp_ajax_ayg_delete_cache', $settings, 'ajax_callback_delete_cache' ); | |
| 142 | 151 | } |
| 143 | 152 | |
| 144 | 153 | /** |
| 145 | 154 | * Register all of the hooks related to the public-facing functionality |
| @@ -148,19 +157,30 @@ | ||
| 148 | 157 | * @since 1.0.0 |
| 149 | 158 | * @access private |
| 150 | 159 | */ |
| 151 | 160 | private function define_public_hooks() { |
| 161 | + // Hooks common to all public pages | |
| 152 | 162 | $public = new AYG_Public(); |
| 153 | - | |
| 163 | + | |
| 154 | 164 | $this->loader->add_action( 'wp_enqueue_scripts', $public, 'register_styles' ); |
| 155 | 165 | $this->loader->add_action( 'wp_enqueue_scripts', $public, 'register_scripts' ); |
| 156 | 166 | $this->loader->add_action( 'enqueue_block_editor_assets', $public, 'enqueue_block_editor_assets' ); |
| 157 | - $this->loader->add_action( 'wp_ajax_ayg_load_more_videos', $public, 'ajax_callback_load_more_videos' ); | |
| 158 | - $this->loader->add_action( 'wp_ajax_nopriv_ayg_load_more_videos', $public, 'ajax_callback_load_more_videos' ); | |
| 167 | + $this->loader->add_action( 'elementor/editor/after_enqueue_scripts', $public, 'enqueue_block_editor_assets' ); | |
| 168 | + $this->loader->add_action( 'elementor/preview/enqueue_scripts', $public, 'enqueue_block_editor_assets' ); | |
| 169 | + $this->loader->add_action( 'wp_ajax_ayg_load_videos', $public, 'ajax_callback_load_videos' ); | |
| 170 | + $this->loader->add_action( 'wp_ajax_nopriv_ayg_load_videos', $public, 'ajax_callback_load_videos' ); | |
| 159 | 171 | $this->loader->add_action( 'wp_ajax_ayg_set_cookie', $public, 'set_gdpr_cookie' ); |
| 160 | 172 | $this->loader->add_action( 'wp_ajax_nopriv_ayg_set_cookie', $public, 'set_gdpr_cookie' ); |
| 161 | 173 | |
| 162 | 174 | $this->loader->add_filter( 'smush_skip_iframe_from_lazy_load', $public, 'smush', 999, 2 ); |
| 175 | + | |
| 176 | + // Hooks specific to the cron jobs | |
| 177 | + $cron = new AYG_Public_Cron(); | |
| 178 | + | |
| 179 | + $this->loader->add_action( 'wp', $cron, 'schedule_events' ); | |
| 180 | + $this->loader->add_action( 'ayg_schedule_weekly', $cron, 'cron_event' ); | |
| 181 | + | |
| 182 | + $this->loader->add_filter( 'cron_schedules', $cron, 'cron_schedules' ); | |
| 163 | 183 | } |
| 164 | 184 | |
| 165 | 185 | /** |
| 166 | 186 | * Register all of the hooks related to the gutenberg block. |
| @@ -185,9 +205,28 @@ | ||
| 185 | 205 | $this->loader->add_filter( 'block_categories_all', $block, 'block_categories' ); |
| 186 | 206 | } else { |
| 187 | 207 | $this->loader->add_filter( 'block_categories', $block, 'block_categories' ); |
| 188 | 208 | } |
| 189 | - } | |
| 209 | + } | |
| 210 | + | |
| 211 | + /** | |
| 212 | + * Register all of the hooks related to the widget. | |
| 213 | + * | |
| 214 | + * @since 2.1.0 | |
| 215 | + * @access private | |
| 216 | + */ | |
| 217 | + private function define_widget_hooks() { | |
| 218 | + $this->loader->add_action( 'widgets_init', $this, 'register_widget' ); | |
| 219 | + } | |
| 220 | + | |
| 221 | + /** | |
| 222 | + * Register the widget. | |
| 223 | + * | |
| 224 | + * @since 2.1.0 | |
| 225 | + */ | |
| 226 | + public function register_widget() { | |
| 227 | + register_widget( 'AYG_Widget' ); | |
| 228 | + } | |
| 190 | 229 | |
| 191 | 230 | /** |
| 192 | 231 | * Run the loader to execute all of the hooks with WordPress. |
| 193 | 232 | * |