base, 'accessibility-magic' ) ) { return true; } return false; } /** * Get the supported units * * @return string[] */ function get_supported_units() { return [ 'px', '%', 'vh', 'vw', 'em', 'rem', ]; } /** * Process the icon position * * @param string $position Position of the icon eg: bottom-right * @param int $offset_x Offset in x direction * @param int $offset_y Offset in y direction * @param string $unit Unit of the offset * * @return string[] */ function process_icon_position( $position, $offset_x, $offset_y, $unit ) { // Initialize the icon position array as empty $icon = [ 'type' => 'fixed' ]; // Split the position input into components $position_parts = explode( '-', $position ); // Adjust the array based on the position input and offset values foreach ( $position_parts as $part ) { switch ( $part ) { case 'top': $icon[ $part ] = [ 'size' => intval( $offset_y ), 'units' => $unit, ]; break; case 'bottom': $icon[ $part ] = [ 'size' => intval( $offset_y ), 'units' => $unit, ]; break; case 'left': $icon[ $part ] = [ 'size' => intval( $offset_x ), 'units' => $unit, ]; break; case 'right': $icon[ $part ] = [ 'size' => intval( $offset_x ), 'units' => $unit, ]; break; } } return $icon; } /** * Mask given string * * @param string $input_string String * @param int $unmask_length The length of unmask * * @return string * @since 1.0 */ function mask_string( $input_string, $unmask_length ) { $output_string = substr( $input_string, 0, $unmask_length ); if ( strlen( $input_string ) > $unmask_length ) { $output_string .= str_repeat( '*', strlen( $input_string ) - $unmask_length ); } return $output_string; } /** * Get the excluded pages * * @return array */ function get_excluded_pages() { $settings = get_settings(); // phpcs:ignore $excluded_pages = []; if ( ! empty( $settings['excluded_pages'] ) ) { $excluded_pages = preg_split( '#(\r\n|\r|\n)#', $settings['excluded_pages'], - 1, PREG_SPLIT_NO_EMPTY ); } return apply_filters( 'accessibility_toolkit_excluded_pages', $excluded_pages ); } /** * Check if the current page is excluded * * @return bool */ function is_excluded_page() { $excluded_pages = get_excluded_pages(); $request_uri = isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '/'; if ( ! empty( $excluded_pages ) ) { foreach ( $excluded_pages as $exception ) { if ( preg_match( '#^[\s]*$#', $exception ) ) { continue; } // full url exception if ( preg_match( '#^https?://#', $exception ) ) { $exception = wp_parse_url( $exception, PHP_URL_PATH ); } if ( empty( $exception ) ) { continue; } if ( preg_match( '#^(' . preg_quote( $exception, '#' ) . ')#', $request_uri ) ) { return true; } } } return false; }