e_hint ) { $documents = WPO_WCPDF()->documents->get_documents(); foreach ( $documents as $document ) { if ( $document->get_type() == 'invoice' ) { $invoice_email_ids = $document->get_attach_to_email_ids(); if ( empty( $invoice_email_ids ) ) { include_once( WPO_WCPDF()->plugin_path() . '/includes/views/attachment-settings-hint.php' ); } } } } } public function get_installed_templates_list() { $installed_templates = WPO_WCPDF()->settings->get_installed_templates(); $template_list = array(); foreach ( $installed_templates as $path => $template_id ) { $template_name = basename( $template_id ); $group = dirname( $template_id ); switch ( $group ) { case 'default': case 'premium_plugin': // no suffix break; case 'theme': default: $template_name = sprintf( '%s (%s)', $template_name, __( 'Custom', 'woocommerce-pdf-invoices-packing-slips' ) ); break; } $template_list[$template_id] = $template_name; } return $template_list; } /** * List templates in plugin folder, theme folder & child theme folder * @return array template path => template name */ public function find_templates() { $installed_templates = array(); // get base paths $template_base_path = ( function_exists( 'WC' ) && is_callable( array( WC(), 'template_path' ) ) ) ? WC()->template_path() : apply_filters( 'woocommerce_template_path', 'woocommerce/' ); $template_base_path = untrailingslashit( $template_base_path ); $template_paths = array ( // note the 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' ) && ! empty( WP_CONTENT_DIR ) && false !== strpos( WP_CONTENT_DIR, ABSPATH ) ) { $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 ) { if ( empty( $dir ) ) { continue; } // 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