PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.2
YayMail – WooCommerce Email Customizer v4.4.2
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 4.4.2, at src/Utils/Localize.php

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