%s', wp_kses_post( wpautop( $message ) ) ); } /** * The Baltic class autoloader. * Finds the path to a class that we're requiring and includes the file. * * @access protected * @param string $class_name The name of the class we're trying to load. */ protected function autoload( $class_name ) { // Not a Baltic file, early exit. if ( 0 !== stripos( $class_name, 'Baltic' ) ) { return; } // Check if we've got it cached and ready. if ( isset( $this->cached_paths[ $class_name ] ) && file_exists( $this->cached_paths[ $class_name ] ) ) { require_once $this->cached_paths[ $class_name ]; return; } $paths = $this->get_paths( $class_name ); foreach ( $paths as $path ) { $path = wp_normalize_path( $path ); if ( file_exists( $path ) ) { $this->cached_paths[ $class_name ] = $path; require_once $path; return; } } } /** * Get an array of possible paths for the file. * * @access protected * @param string $class_name The name of the class we're trying to load. * @return array */ protected function get_paths( $class_name ) { $paths = array(); // Build the filename. $filename = 'class-' . strtolower( str_replace( '_', '-', $class_name ) ) . '.php'; // Break class-name into parts. $name_parts = explode( '_', str_replace( 'Baltic_', '', $class_name ) ); if ( isset( $name_parts[0] ) && 'Connect' === $name_parts[0] ) { $path = BALTIC_INC . '/connect/'; $path .= strtolower( str_replace( '_', '-', str_replace( 'Baltic_Connect_', '', $class_name ) ) ) . '/'; $paths[] = $path . $filename; } if ( isset( $name_parts[0] ) && 'WooCommerce' === $name_parts[0] ) { $path = BALTIC_INC . '/connect/woocommerce/'; $paths[] = $path . $filename; } if ( isset( $name_parts[0] ) && 'Control' === $name_parts[0] ) { $path = BALTIC_INC . '/customizer/controls/'; $paths[] = $path . $filename; } if ( isset( $name_parts[0] ) && 'Settings' === $name_parts[0] ) { $path = BALTIC_INC . '/customizer/settings/'; $paths[] = $path . $filename; } $paths[] = BALTIC_INC . '/customizer/' . $filename; $paths[] = BALTIC_INC . '/extras/' . $filename; $paths[] = BALTIC_INC . '/structure/' . $filename; $paths[] = BALTIC_INC . '/theme/' . $filename; $paths[] = BALTIC_INC . '/widgets/' . $filename; $substr = str_replace( 'Baltic_', '', $class_name ); $exploded = explode( '_', $substr ); $levels = count( $exploded ); $previous_path = ''; for ( $i = 0; $i < $levels; $i++ ) { $paths[] = BALTIC_INC . '/' . $previous_path . strtolower( $exploded[ $i ] ) . '/' . $filename; $previous_path .= strtolower( $exploded[ $i ] ) . '/'; } return $paths; } } Baltic_Init::instance();