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

134 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 }//end if
51 return $data_orders;
52 }
53
54 public static function get_social_icons_data() {
55
56 $socials = [
57 'behance',
58 'discord',
59 'dribble',
60 'facebook',
61 'github',
62 'google',
63 'instagram',
64 'linkedin',
65 'medium',
66 'messenger',
67 'pinterest',
68 'reddit',
69 'skype',
70 'snapchat',
71 'spotify',
72 'telegram',
73 'tiktok',
74 'twitch',
75 'twitter',
76 'viber',
77 'vimeo',
78 'website',
79 'wechat',
80 'whatsapp',
81 'youtube',
82 'zillow',
83 ];
84 $resource_prefix_url = YAYMAIL_PLUGIN_URL . 'assets/images/social-icons/';
85 $themes = [ 'colorful', 'line-dark', 'line-light', 'solid-dark', 'solid-light' ];
86 $themes_pascal = array_map( [ self::class, 'kebab_to_pascal' ], $themes );
87 $images = [];
88 foreach ( $socials as $social ) {
89 $pngs = [];
90 foreach ( $themes as $theme ) {
91 $theme_pascal = self::kebab_to_pascal( $theme );
92 $file_name = $theme . '.png';
93 $file_url = $resource_prefix_url . $social . '/' . $file_name;
94 $pngs[] = [
95 'theme' => $theme_pascal,
96 'src' => $file_url,
97 ];
98 }
99 $images[] = [
100 'name' => $social,
101 'data' => $pngs,
102 ];
103 }
104
105 return [
106 'themes' => $themes_pascal,
107 'images' => $images,
108 ];
109 }
110
111 public static function get_global_headers_footers() {
112 $template_model = TemplateModel::get_instance();
113 $global_headers_footers = $template_model->get_global_header_and_footer();
114 return $global_headers_footers;
115 }
116
117 public static function get_activated_addons() {
118 $result = apply_filters( 'yaymail_activated_addons', [] );
119
120 return $result;
121 }
122
123 private static function kebab_to_pascal( $input ) {
124 // Remove hyphens and split the string into words
125 $words = explode( '-', $input );
126 // Capitalize the first letter of each word
127 $pascal_words = array_map( 'ucfirst', $words );
128 // Join the words back together
129 $pascal_case = implode( '', $pascal_words );
130
131 return $pascal_case;
132 }
133 }
134