/** * create_wpml_xml_file. * * @version 2.2.8 */ function create_wpml_xml_file() { if (!isset($_GET['create_wpml_xml_file']) || !is_super_admin()) { return; } if (!isset($_GET['section']) || 'wpml' != $_GET['section']) { return; } $file_path = wcj_plugin_path() . '/wpml-config.xml'; if (false !== ($handle = fopen($file_path, 'w'))) { fwrite($handle, '<wpml-config>' . PHP_EOL); fwrite($handle, "\t"); fwrite($handle, '<admin-texts>' . PHP_EOL); // $sections = $this->get_sections(); $sections = apply_filters('wcj_settings_sections', array()); foreach ($sections as $section => $section_title) { // $settings = $this->get_settings( $section ); $settings = apply_filters('wcj_settings_' . $section, array()); foreach ($settings as $value) { if ($this->is_wpml_value($section, $value)) { fwrite($handle, "\t\t"); fwrite($handle, '<key name="' . $value['id'] . '" />' . PHP_EOL); } } } fwrite($handle, "\t"); fwrite($handle, '</admin-texts>' . PHP_EOL); fwrite($handle, '</wpml-config>' . PHP_EOL); fclose($handle); $this->notice = __('File wpml-config.xml successfully regenerated!', 'woocommerce-jetpack'); } }
/** * Constructor. * * @version 2.5.0 * @since 2.5.0 */ function __construct() { $this->id = 'product_price_by_formula'; $this->short_desc = __('Product Price by Formula', 'woocommerce-jetpack'); $this->desc = __('Set formula for automatic WooCommerce product price calculation.', 'woocommerce-jetpack'); $this->link = 'http://booster.io/features/woocommerce-product-price-formula/'; parent::__construct(); if ($this->is_enabled()) { require_once wcj_plugin_path() . '/includes/lib/PHPMathParser/Math.php'; add_action('add_meta_boxes', array($this, 'add_meta_box')); add_action('save_post_product', array($this, 'save_meta_box'), PHP_INT_MAX, 2); if (!is_admin() || defined('DOING_AJAX') && DOING_AJAX) { // Prices add_filter('woocommerce_get_price', array($this, 'change_price_by_formula'), PHP_INT_MAX - 100, 2); add_filter('woocommerce_get_sale_price', array($this, 'change_price_by_formula'), PHP_INT_MAX - 100, 2); add_filter('woocommerce_get_regular_price', array($this, 'change_price_by_formula'), PHP_INT_MAX - 100, 2); // Variations add_filter('woocommerce_variation_prices_price', array($this, 'change_price_by_formula'), PHP_INT_MAX - 100, 2); add_filter('woocommerce_variation_prices_regular_price', array($this, 'change_price_by_formula'), PHP_INT_MAX - 100, 2); add_filter('woocommerce_variation_prices_sale_price', array($this, 'change_price_by_formula'), PHP_INT_MAX - 100, 2); add_filter('woocommerce_get_variation_prices_hash', array($this, 'get_variation_prices_hash'), PHP_INT_MAX - 100, 3); // Grouped products add_filter('woocommerce_get_price_including_tax', array($this, 'change_price_by_formula_grouped'), PHP_INT_MAX - 100, 3); add_filter('woocommerce_get_price_excluding_tax', array($this, 'change_price_by_formula_grouped'), PHP_INT_MAX - 100, 3); } add_filter('wcj_save_meta_box_value', array($this, 'save_meta_box_value'), PHP_INT_MAX, 3); add_action('admin_notices', array($this, 'admin_notices')); } }
/** * create_wpml_xml_file. * * @version 2.4.4 */ function create_wpml_xml_file() { $file_path = wcj_plugin_path() . '/wpml-config.xml'; if (false !== ($handle = fopen($file_path, 'w'))) { fwrite($handle, '<wpml-config>' . PHP_EOL); fwrite($handle, "\t"); fwrite($handle, '<admin-texts>' . PHP_EOL); $sections = apply_filters('wcj_settings_sections', array()); foreach ($sections as $section => $section_title) { if ($this->is_wpml_section($section)) { $settings = apply_filters('wcj_settings_' . $section, array()); foreach ($settings as $value) { if ($this->is_wpml_value($value)) { fwrite($handle, "\t\t"); fwrite($handle, '<key name="' . $value['id'] . '" />' . PHP_EOL); } } } } fwrite($handle, "\t"); fwrite($handle, '</admin-texts>' . PHP_EOL); fwrite($handle, '</wpml-config>' . PHP_EOL); fclose($handle); } }
/** * get_cat_by_section * * @version 2.2.3 * @since 2.2.3 */ function get_cat_by_section($section) { $cats = (include wcj_plugin_path() . '/includes/admin/' . 'wcj-modules-cats.php'); foreach ($cats as $id => $label_info) { if (!empty($label_info['all_cat_ids']) && is_array($label_info['all_cat_ids']) && in_array($section, $label_info['all_cat_ids'])) { return $id; } } return ''; }
/** * prepare_pdf. * * @version 2.5.2 */ function prepare_pdf() { $invoice_type = $this->invoice_type; // Create new PDF document require_once wcj_plugin_path() . '/includes/classes/class-wcj-tcpdf.php'; $pdf = new WCJ_TCPDF(get_option('wcj_invoicing_' . $invoice_type . '_page_orientation', 'P'), PDF_UNIT, get_option('wcj_invoicing_' . $invoice_type . '_page_format', 'A4'), true, 'UTF-8', false); $pdf->set_invoice_type($invoice_type); // Set document information $pdf->SetCreator(PDF_CREATOR); // $pdf->SetAuthor( 'Algoritmika Ltd.' ); $invoice_title = $invoice_type; $invoice_types = wcj_get_invoice_types(); foreach ($invoice_types as $invoice_type_data) { if ($invoice_type === $invoice_type_data['id']) { $invoice_title = $invoice_type_data['title']; break; } } $pdf->SetTitle($invoice_title); $pdf->SetSubject('Invoice PDF'); $pdf->SetKeywords('invoice, PDF'); // Header - set default header data if ('yes' === get_option('wcj_invoicing_' . $invoice_type . '_header_enabled')) { $the_logo = ''; $the_logo_width_mm = 0; if ('' != get_option('wcj_invoicing_' . $invoice_type . '_header_image')) { $the_logo = parse_url(get_option('wcj_invoicing_' . $invoice_type . '_header_image'), PHP_URL_PATH); $the_logo_width_mm = get_option('wcj_invoicing_' . $invoice_type . '_header_image_width_mm'); } $pdf->SetHeaderData($the_logo, $the_logo_width_mm, do_shortcode(get_option('wcj_invoicing_' . $invoice_type . '_header_title_text')), do_shortcode(get_option('wcj_invoicing_' . $invoice_type . '_header_text')), wcj_hex2rgb(get_option('wcj_invoicing_' . $invoice_type . '_header_text_color')), wcj_hex2rgb(get_option('wcj_invoicing_' . $invoice_type . '_header_line_color'))); } else { $pdf->SetPrintHeader(false); } // Footer if ('yes' === get_option('wcj_invoicing_' . $invoice_type . '_footer_enabled')) { $pdf->setFooterData(wcj_hex2rgb(get_option('wcj_invoicing_' . $invoice_type . '_footer_text_color')), wcj_hex2rgb(get_option('wcj_invoicing_' . $invoice_type . '_footer_line_color'))); } else { $pdf->SetPrintFooter(false); } // Set Header and Footer fonts $pdf->setHeaderFont(array(get_option('wcj_invoicing_' . $invoice_type . '_general_font_family', 'dejavusans'), '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(get_option('wcj_invoicing_' . $invoice_type . '_general_font_family', 'dejavusans'), '', PDF_FONT_SIZE_DATA)); // Set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // Set margins $pdf->SetMargins(get_option('wcj_invoicing_' . $invoice_type . '_margin_left'), get_option('wcj_invoicing_' . $invoice_type . '_margin_top'), get_option('wcj_invoicing_' . $invoice_type . '_margin_right')); $pdf->SetHeaderMargin(get_option('wcj_invoicing_' . $invoice_type . '_margin_header')); $pdf->SetFooterMargin(get_option('wcj_invoicing_' . $invoice_type . '_margin_footer')); // Set auto page breaks $pdf->SetAutoPageBreak(TRUE, get_option('wcj_invoicing_' . $invoice_type . '_margin_bottom')); // Set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); /*// Set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { require_once(dirname(__FILE__).'/lang/eng.php'); $pdf->setLanguageArray($l); }*/ // Set default font subsetting mode $pdf->setFontSubsetting(true); // Set font /* if ( 'DroidSansFallback' === apply_filters( 'booster_get_option', 'dejavusans', get_option( 'wcj_invoicing_' . $invoice_type . '_general_font_family', 'dejavusans' ) ) ) { $pdf->addTTFfont( wcj_plugin_path() . '/includes/lib/tcpdf_min/fonts/' . 'DroidSansFallback.ttf' ); } */ // dejavusans is a UTF-8 Unicode font, if you only need to print standard ASCII chars, you can use core fonts like helvetica or times to reduce file size. $pdf->SetFont(apply_filters('booster_get_option', 'dejavusans', get_option('wcj_invoicing_' . $invoice_type . '_general_font_family', 'dejavusans')), '', apply_filters('booster_get_option', 8, get_option('wcj_invoicing_' . $invoice_type . '_general_font_size', 8)), '', true); // Add a page $pdf->AddPage(); // Set text shadow effect if ('yes' === get_option('wcj_invoicing_' . $invoice_type . '_general_font_shadowed', 'yes')) { $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal')); } return $pdf; }
<?php /** * WooCommerce Jetpack TCPDF * * The WooCommerce Jetpack TCPDF class. * * @version 2.3.0 * @author Algoritmika Ltd. */ if (!defined('ABSPATH')) { exit; } if (!class_exists('WCJ_TCPDF')) { // Include the main TCPDF library require_once wcj_plugin_path() . '/includes/lib/tcpdf_min/tcpdf.php'; class WCJ_TCPDF extends TCPDF { /** * set_invoice_type. */ public function set_invoice_type($invoice_type) { $this->invoice_type = $invoice_type; } /** * Page header. * public function Header() { // Logo $image_file = K_PATH_IMAGES.'logo_example.jpg';
function wcj_get_currency_symbol($currency_code) { $return = ''; $currencies = (include wcj_plugin_path() . '/includes/currencies/wcj-currencies.php'); foreach ($currencies as $data) { if ($currency_code == $data['code']) { $return = $data['symbol']; break; } } $return = apply_filters('wcj_get_option_filter', $return, get_option('wcj_currency_' . $currency_code, $return)); return '' != $return ? $return : false; }
function wcj_get_currency_symbol($currency_code) { $currencies = (include wcj_plugin_path() . '/includes/currencies/wcj-currencies.php'); foreach ($currencies as $data) { if ($currency_code == $data['code']) { return $data['symbol']; } } return false; }