PluginProbe
YayMail – WooCommerce Email Customizer / trunk
YayMail – WooCommerce Email Customizer vtrunk
4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 3.4.2 3.4.3 All 55 releases
yaymail / src / Utils / Localize.php

Localize.php in YayMail – WooCommerce Email Customizer trunk, at src/Utils/Localize.php

144 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace YayMail\Utils;
4
5 defined( 'ABSPATH' ) || exit;
6
7 use YayMail\Integrations\TranslationModule;
8 use YayMail\Models\TemplateModel;
9
10 /**
11 * Localize Classes
12 */
13 class Localize {
14
15 public static function get_translate_integrations() {
16 $current_integration = TranslationModule::get_instance()->current_integration;
17 return [
18 'available' => [],
19 'current_translation' => is_null( $current_integration ) ? null : $current_integration->get_data(),
20 ];
21 }
22
23 public static function get_list_orders() {
24 if ( yaymail_is_wc_installed() ) {
25 $data_orders [] = [
26 'id' => 'sample_order',
27 'order_number' => 'sample_order',
28 'email' => '',
29 'first_name' => '',
30 'last_name' => '',
31 'title' => esc_html__( 'Sample order', 'yaymail' ),
32 ];
33
34 $wc_list_orders = wc_get_orders(
35 [
36 'limit' => 50,
37 ]
38 );
39
40 foreach ( $wc_list_orders as $order ) {
41 if ( method_exists( $order, 'get_id' ) && method_exists( $order, 'get_order_number' ) ) {
42 $order_id = strval( $order->get_id() );
43 $order_number = $order->get_order_number();
44 $email = method_exists( $order, 'get_billing_email' ) ? $order->get_billing_email() : '';
45 $first_name = method_exists( $order, 'get_billing_first_name' ) ? $order->get_billing_first_name() : '';
46 $last_name = method_exists( $order, 'get_billing_last_name' ) ? $order->get_billing_last_name() : '';
47 $title = $order_number . ' - ' . $first_name . $last_name . ' (' . ( $email ? $email : __( 'Unknown', 'yaymail' ) ) . ')';
48
49 $data_orders[] = [
50 'id' => $order_id,
51 'order_number' => $order_number,
52 'email' => $email,
53 'first_name' => $first_name,
54 'last_name' => $last_name,
55 'title' => $title,
56 ];
57 }
58 }
59 return $data_orders;
60 }//end if
61 return [];
62 }
63
64 public static function get_social_icons_data() {
65
66 $socials = [
67 'behance',
68 'discord',
69 'dribble',
70 'facebook',
71 'github',
72 'google',
73 'instagram',
74 'linkedin',
75 'medium',
76 'messenger',
77 'pinterest',
78 'reddit',
79 'skype',
80 'snapchat',
81 'spotify',
82 'telegram',
83 'tiktok',
84 'twitch',
85 'twitter',
86 'viber',
87 'vimeo',
88 'website',
89 'wechat',
90 'whatsapp',
91 'youtube',
92 'zillow',
93 ];
94 $resource_prefix_url = YAYMAIL_PLUGIN_URL . 'assets/images/social-icons/';
95 $themes = [ 'colorful', 'line-dark', 'line-light', 'solid-dark', 'solid-light', 'custom' ];
96 $themes_pascal = array_map( [ self::class, 'kebab_to_pascal' ], $themes );
97 $images = [];
98 foreach ( $socials as $social ) {
99 $pngs = [];
100 foreach ( $themes as $theme ) {
101 $theme_pascal = self::kebab_to_pascal( $theme );
102 $file_name = $theme . '.png';
103 $file_url = $resource_prefix_url . $social . '/' . $file_name;
104 $pngs[] = [
105 'theme' => $theme_pascal,
106 'src' => $file_url,
107 ];
108 }
109 $images[] = [
110 'name' => $social,
111 'data' => $pngs,
112 ];
113 }
114
115 return [
116 'themes' => $themes_pascal,
117 'images' => $images,
118 ];
119 }
120
121 public static function get_global_headers_footers( $template_name = 'yaymail_global_header_footer' ) {
122 $template_model = TemplateModel::get_instance();
123 $global_headers_footers = $template_model->get_global_headers_and_footers_for_all_available_languages( $template_name );
124 return $global_headers_footers;
125 }
126
127 public static function get_activated_addons() {
128 $result = apply_filters( 'yaymail_activated_addons', [] );
129
130 return $result;
131 }
132
133 private static function kebab_to_pascal( $input ) {
134 // Remove hyphens and split the string into words
135 $words = explode( '-', $input );
136 // Capitalize the first letter of each word
137 $pascal_words = array_map( 'ucfirst', $words );
138 // Join the words back together
139 $pascal_case = implode( '', $pascal_words );
140
141 return $pascal_case;
142 }
143 }
144