| @@ -82,9 +82,9 @@ | ||
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * The classes responsible for defining all actions that occur in the admin area. |
| 85 | 85 | */ |
| 86 | - require_once AYG_DIR . 'admin/admin.php'; | |
| 86 | + require_once AYG_DIR . 'admin/admin.php'; | |
| 87 | 87 | require_once AYG_DIR . 'admin/settings.php'; |
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | 90 | * The class responsible for defining all actions that occur in the public-facing |
| @@ -90,8 +90,9 @@ | ||
| 90 | 90 | * The class responsible for defining all actions that occur in the public-facing |
| 91 | 91 | * side of the site. |
| 92 | 92 | */ |
| 93 | 93 | require_once AYG_DIR . 'public/public.php'; |
| 94 | + require_once AYG_DIR . 'public/cron.php'; | |
| 94 | 95 | |
| 95 | 96 | /** |
| 96 | 97 | * The class responsible for defining all actions that occur in the gutenberg block. |
| 97 | 98 | */ |
| @@ -132,8 +133,10 @@ | ||
| 132 | 133 | |
| 133 | 134 | $this->loader->add_action( 'admin_init', $admin, 'insert_missing_options', 1 ); |
| 134 | 135 | $this->loader->add_action( 'admin_enqueue_scripts', $admin, 'enqueue_styles' ); |
| 135 | 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' ); | |
| 136 | 139 | $this->loader->add_action( 'admin_menu', $admin, 'admin_menu' ); |
| 137 | 140 | $this->loader->add_action( 'admin_notices', $admin, 'admin_notices' ); |
| 138 | 141 | $this->loader->add_action( 'wp_ajax_ayg_save_api_key', $admin, 'ajax_callback_save_api_key' ); |
| 139 | 142 | |
| @@ -143,9 +146,9 @@ | ||
| 143 | 146 | $settings = new AYG_Admin_Settings(); |
| 144 | 147 | |
| 145 | 148 | $this->loader->add_action( 'admin_menu', $settings, 'admin_menu' ); |
| 146 | 149 | $this->loader->add_action( 'admin_init', $settings, 'admin_init' ); |
| 147 | - $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' ); | |
| 148 | 151 | } |
| 149 | 152 | |
| 150 | 153 | /** |
| 151 | 154 | * Register all of the hooks related to the public-facing functionality |
| @@ -154,19 +157,30 @@ | ||
| 154 | 157 | * @since 1.0.0 |
| 155 | 158 | * @access private |
| 156 | 159 | */ |
| 157 | 160 | private function define_public_hooks() { |
| 161 | + // Hooks common to all public pages | |
| 158 | 162 | $public = new AYG_Public(); |
| 159 | 163 | |
| 160 | 164 | $this->loader->add_action( 'wp_enqueue_scripts', $public, 'register_styles' ); |
| 161 | 165 | $this->loader->add_action( 'wp_enqueue_scripts', $public, 'register_scripts' ); |
| 162 | 166 | $this->loader->add_action( 'enqueue_block_editor_assets', $public, 'enqueue_block_editor_assets' ); |
| 163 | - $this->loader->add_action( 'wp_ajax_ayg_load_more_videos', $public, 'ajax_callback_load_more_videos' ); | |
| 164 | - $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' ); | |
| 165 | 171 | $this->loader->add_action( 'wp_ajax_ayg_set_cookie', $public, 'set_gdpr_cookie' ); |
| 166 | 172 | $this->loader->add_action( 'wp_ajax_nopriv_ayg_set_cookie', $public, 'set_gdpr_cookie' ); |
| 167 | 173 | |
| 168 | 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' ); | |
| 169 | 183 | } |
| 170 | 184 | |
| 171 | 185 | /** |
| 172 | 186 | * Register all of the hooks related to the gutenberg block. |