da11y = $da11y; $this->da11y_options = $da11y_options; $this->version = $version; $this->settings = $settings; } /** * Render the gemerated CSS for the plugin. * * @since 1.0.0 */ public function embedded_styles() { include_once 'partials/divi-accessibility-embedded-css.php'; } /** * Render the gemerated JS for the plugin. * * @since 1.0.0 */ public function embedded_scripts() { include_once 'partials/divi-accessibility-embedded-js.php'; } /** * Remove Divi viewport meta since we want to load our own. * * @since 1.0.2 */ public function remove_divi_viewport_meta() { remove_action( 'wp_head', 'et_add_viewport_meta' ); } /** * Allow users to pinch and zoom divi theme. * * @since 1.0.2 */ public function accessible_viewport_meta() { echo ''; } /** * Register the JavaScript for the public-facing side of the site. * * @since 1.0.0 */ public function enqueue_scripts() { wp_enqueue_script( 'jquery' ); if ( true == $this->can_load_tota11y() ) { wp_enqueue_script( 'divi-accessibility-tota11y', plugin_dir_url( __FILE__ ) . 'js/tota11y.min.js', array(), $this->version, false ); } } /** * Check if we have permission to load tota11y. * * @since 1.0.0 * @return boolean */ public function can_load_tota11y() { $settings = $this->settings; if ( isset( $settings['tota11y'] ) ) { $tota11y = $settings['tota11y']; } if ( current_user_can( 'manage_options' ) && ( true == $tota11y ) ) { return true; } } /** * Check if we have permission to load a checkbox option. * * @since 1.0.0 * @param string $option * @return boolean */ public function can_load( $option ) { $can_load = false; $settings = $this->settings; if ( isset( $settings[ $option ] ) && 1 == $settings[ $option ] ) { $can_load = true; } return apply_filters( 'divi_accessibility_can_load', $can_load, $option ); } /** * Prevent WordPress from adding a unique ID from menu list items. * Because Divi uses js to build the mobile navigation menu from the main navigation links, * unique ID's are cloned, causing issues with accessibility & validation. * * @since 1.2.0 */ public function remove_duplicate_menu_ids() { if ( $this->can_load( 'fix_duplicate_menu_ids' ) ) { add_filter( 'nav_menu_item_id', '__return_null', 1000 ); } } /** * Log plugin info to console for admin users. * * @since 1.0.0 */ public function developer_mode() { if ( ! current_user_can( 'manage_options' ) ) { return; } if ( $this->can_load( 'developer_mode' ) ) { include_once 'partials/divi-accessibility-developer-mode.php'; } } }