trailingslashit( $dir ), 1 ); } /** * Plugin fallback templates - LOWER PRIORITY * (runs if theme doesn't override) * @return void */ bbp_register_template_stack( fn() => trailingslashit( FORUMAX_PATH . 'templates' ), 5 ); } /** * Get template directories from themes, child themes, and plugins * using /forumax or /bbpress folders (when supported). * * @return array */ function forumax_get_external_template_dirs() { $dirs = []; $slugs = [ 'forumax', 'bbpress' ]; $themes = [ get_template_directory(), get_stylesheet_directory() ]; // === Themes === foreach ( array_unique( $themes ) as $theme ) { foreach ( $slugs as $slug ) { $path = trailingslashit( $theme ) . $slug . '/'; if ( is_dir( $path ) ) { $dirs[] = $path; } } } // === Plugins === foreach ( glob( WP_PLUGIN_DIR . '/*', GLOB_ONLYDIR ) as $plugin ) { if ( basename( $plugin ) === 'forumax' ) { continue; } foreach ( $slugs as $slug ) { $path = trailingslashit( $plugin ) . $slug . '/'; if ( is_dir( $path ) ) { $dirs[] = $path; } } } return $dirs; } /** * Extend bbPress template locations */ add_filter( 'bbp_get_template_locations', 'forumax_extend_template_locations', 10, 2 ); function forumax_extend_template_locations( $locations ) { foreach ( [ 'forumax', 'bbpress' ] as $slug ) { if ( ! in_array( $slug, $locations, true ) ) { array_unshift( $locations, $slug ); } } return $locations; } /** * Banner preset background styles * * @return array[]|string[] */ function forumax_banner_bg_style() { return array( 'color' => FORUMAX_IMG . '/options/color.png', 'faded-sun' => FORUMAX_IMG . '/options/faded-sun.jpg', 'happy-journey' => FORUMAX_IMG . '/options/happy-journey.jpg', 'apparent-circle' => FORUMAX_IMG . '/options/apparent-circle.jpg', 'soft-weather' => FORUMAX_IMG . '/options/soft-weather.jpg', 'romantic-sun' => FORUMAX_IMG . '/options/romantic-sun.jpg', 'teal-eclipse' => FORUMAX_IMG . '/options/teal-eclipse.jpg', ); } /** * Image from Settings * * @param string $option_id * @param string $class * @param string $alt */ function get_image_from_settings( string $option_id = '', string $class = '', string $alt = '' ):void { $image = forumax_get_opt($option_id) ?? ''; // Check if the image has an 'id' or a 'url' and display accordingly if ( ! empty($image['id']) ) { echo wp_get_attachment_image($image['id'], 'full', '' ); } elseif ( !empty($image['url']) ) { echo ""; } }