order: child-theme before theme, so that array_unique filters out parent doubles 'default' => WPO_WCPDF()->plugin_path() . '/templates/', 'child-theme' => get_stylesheet_directory() . "/{$template_base_path}/pdf/", 'theme' => get_template_directory() . "/{$template_base_path}/pdf/", ); $template_paths = apply_filters( 'wpo_wcpdf_template_paths', $template_paths ); if ( defined( 'WP_CONTENT_DIR' ) && strpos( WP_CONTENT_DIR, ABSPATH ) !== false ) { $forwardslash_basepath = str_replace( '\\', '/', ABSPATH ); } else { $forwardslash_basepath = str_replace( '\\', '/', WP_CONTENT_DIR ); } foreach ( $template_paths as $template_source => $template_path ) { $dirs = (array) glob( $template_path . '*' , GLOB_ONLYDIR ); foreach ( $dirs as $dir ) { // we're stripping abspath to make the plugin settings more portable $forwardslash_dir = str_replace( '\\', '/', $dir ); $installed_templates[ str_replace( $forwardslash_basepath, '', $forwardslash_dir ) ] = basename($dir); } } // remove parent doubles $installed_templates = array_unique($installed_templates); if ( empty( $installed_templates ) ) { // fallback to Simple template for servers with glob() disabled $simple_template_path = str_replace( ABSPATH, '', $template_paths['default'] . 'Simple' ); $installed_templates[$simple_template_path] = 'Simple'; } return apply_filters( 'wpo_wcpdf_templates', $installed_templates ); } } endif; // class_exists