require_files(); /** * Add the necessary action hooks. */ $this->add_actions(); } /** * Require the necessary files. * * @since 0.1.0 * * @return void */ private function require_files() { /** * The helper functions. */ require( plugin_dir_path( __FILE__ ) . 'functions.php' ); } /** * Add the necessary action hooks. * * @since 0.1.0 * * @return void */ private function add_actions() { // Load the text domain for i18n. add_action( 'init', array( $this, 'load_textdomain' ) ); // If checked in the settings, load the default and custom styles. if ( get_option( '_av_styling', 1 ) == 1 ) { add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); add_action( 'wp_head', array( $this, 'custom_styles' ) ); } // Maybe display the overlay. add_action( 'wp_footer', array( $this, 'verify_overlay' ) ); // Maybe hide the content of a restricted content type. add_action( 'the_content', array( $this, 'restrict_content' ) ); // Verify the visitor's input. add_action( 'template_redirect', array( $this, 'verify' ) ); // If checked in the settings, add to the registration form. if ( av_confirmation_required() ) { add_action( 'register_form', 'av_register_form' ); add_action( 'register_post', 'av_register_check', 10, 3 ); } } /** * Load the text domain. * * Based on the bbPress implementation. * * @since 0.1.0 * * @return The textdomain or false on failure. */ public function load_textdomain() { $locale = get_locale(); $locale = apply_filters( 'plugin_locale', $locale, 'age_verify' ); $mofile = sprintf( 'age_verify-%s.mo', $locale ); $mofile_local = plugin_dir_path( __FILE__ ) . 'languages/' . $mofile; $mofile_global = WP_LANG_DIR . '/age-verify/' . $mofile; if ( file_exists( $mofile_local ) ) return load_textdomain( 'age_verify', $mofile_local ); if ( file_exists( $mofile_global ) ) return load_textdomain( 'age_verify', $mofile_global ); load_plugin_textdomain( 'age_verify' ); return false; } /** * Enqueue the styles. * * @since 0.1.0 * * @return void */ public function enqueue_styles() { wp_enqueue_style( 'av-styles', plugin_dir_url( __FILE__ ) . 'assets/styles.css' ); } /** * Print the custom colors, as defined in the admin. * * @since 0.1.0 * * @return void */ public function custom_styles() { ?>