'args' => array(
'option_name' => $option_name,
'id' => 'coc_number',
'translatable' => true,
'description' => __( 'Required for UBL output format.
You can display this number on the invoice from the document settings.', 'woocommerce-pdf-invoices-packing-slips' ) . ' ' . $requires_pro ,
)
),
array(
'type' => 'setting',
'id' => 'shop_address',
'title' => __( 'Shop Address', 'woocommerce-pdf-invoices-packing-slips' ),
'callback' => 'textarea',
'section' => 'general_settings',
'args' => array(
'option_name' => $option_name,
'id' => 'shop_address',
'width' => '72',
'height' => '8',
'translatable' => true,
//'description' => __( '...', 'woocommerce-pdf-invoices-packing-slips' ),
)
),
array(
'type' => 'setting',
'id' => 'footer',
'title' => __( 'Footer: terms & conditions, policies, etc.', 'woocommerce-pdf-invoices-packing-slips' ),
'callback' => 'textarea',
'section' => 'general_settings',
'args' => array(
'option_name' => $option_name,
'id' => 'footer',
'width' => '72',
'height' => '4',
'translatable' => true,
//'description' => __( '...', 'woocommerce-pdf-invoices-packing-slips' ),
)
),
array(
'type' => 'section',
'id' => 'extra_template_fields',
'title' => __( 'Extra template fields', 'woocommerce-pdf-invoices-packing-slips' ),
'callback' => 'custom_fields_section',
),
array(
'type' => 'setting',
'id' => 'extra_1',
'title' => __( 'Extra field 1', 'woocommerce-pdf-invoices-packing-slips' ),
'callback' => 'textarea',
'section' => 'extra_template_fields',
'args' => array(
'option_name' => $option_name,
'id' => 'extra_1',
'width' => '72',
'height' => '8',
'description' => __( 'This is footer column 1 in the Modern (Premium) template', 'woocommerce-pdf-invoices-packing-slips' ),
'translatable' => true,
)
),
array(
'type' => 'setting',
'id' => 'extra_2',
'title' => __( 'Extra field 2', 'woocommerce-pdf-invoices-packing-slips' ),
'callback' => 'textarea',
'section' => 'extra_template_fields',
'args' => array(
'option_name' => $option_name,
'id' => 'extra_2',
'width' => '72',
'height' => '8',
'description' => __( 'This is footer column 2 in the Modern (Premium) template', 'woocommerce-pdf-invoices-packing-slips' ),
'translatable' => true,
)
),
array(
'type' => 'setting',
'id' => 'extra_3',
'title' => __( 'Extra field 3', 'woocommerce-pdf-invoices-packing-slips' ),
'callback' => 'textarea',
'section' => 'extra_template_fields',
'args' => array(
'option_name' => $option_name,
'id' => 'extra_3',
'width' => '72',
'height' => '8',
'description' => __( 'This is footer column 3 in the Modern (Premium) template', 'woocommerce-pdf-invoices-packing-slips' ),
'translatable' => true,
)
),
);
// allow plugins to alter settings fields
$settings_fields = apply_filters( 'wpo_wcpdf_settings_fields_general', $settings_fields, $page, $option_group, $option_name );
WPO_WCPDF()->settings->add_settings_fields( $settings_fields, $page, $option_group, $option_name );
return;
}
public function attachment_settings_hint( $active_tab, $active_section ) {
// save or check option to hide attachments settings hint
if ( isset( $_REQUEST['wpo_wcpdf_hide_attachments_hint'] ) && isset( $_REQUEST['_wpnonce'] ) ) {
// validate nonce
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'hide_attachments_hint_nonce' ) ) {
wcpdf_log_error( 'You do not have sufficient permissions to perform this action: wpo_wcpdf_hide_attachments_hint' );
$hide_hint = false;
} else {
update_option( 'wpo_wcpdf_hide_attachments_hint', true );
$hide_hint = true;
}
} else {
$hide_hint = get_option( 'wpo_wcpdf_hide_attachments_hint' );
}
if ( $active_tab == 'general' && ! $hide_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