/var/www/html_fr/wp-content/plugins/yaymail/src/Utils/Localize.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php

namespace YayMail\Utils;

defined'ABSPATH' ) || exit;

use 
YayMail\Models\TemplateModel;

/**
 * Localize Classes
 */
class Localize {

    public static function 
get_list_orders() {
        if ( 
yaymail_is_wc_installed() ) {
            
$data_orders   [] = [
                
'id'           => 'sample_order',
                
'order_number' => 'sample_order',
                
'email'        => '',
                
'first_name'   => '',
                
'last_name'    => '',
                
'title'        => esc_html__'Sample order''yaymail' ),
            ];

            
$wc_list_orders wc_get_orders(
                [
                    
'limit' => 50,
                ]
            );

            foreach ( 
$wc_list_orders as $order ) {
                if ( 
method_exists$order'get_id' ) && method_exists$order'get_order_number' ) ) {
                    
$order_id     strval$order->get_id() );
                    
$order_number $order->get_order_number();
                    
$email        method_exists$order'get_billing_email' ) ? $order->get_billing_email() : '';
                    
$first_name   method_exists$order'get_billing_first_name' ) ? $order->get_billing_first_name() : '';
                    
$last_name    method_exists$order'get_billing_last_name' ) ? $order->get_billing_last_name() : '';
                    
$title        $order_number ' - ' $first_name $last_name ' (' . ( $email $email __'Unknown''yaymail' ) ) . ')';

                    
$data_orders[] = [
                        
'id'           => $order_id,
                        
'order_number' => $order_number,
                        
'email'        => $email,
                        
'first_name'   => $first_name,
                        
'last_name'    => $last_name,
                        
'title'        => $title,
                    ];
                }
            }
        }
//end if
        
return $data_orders;
    }

    public static function 
get_social_icons_data() {

        
$socials             = [
            
'behance',
            
'discord',
            
'dribble',
            
'facebook',
            
'github',
            
'google',
            
'instagram',
            
'linkedin',
            
'medium',
            
'messenger',
            
'pinterest',
            
'reddit',
            
'skype',
            
'snapchat',
            
'spotify',
            
'telegram',
            
'tiktok',
            
'twitch',
            
'twitter',
            
'viber',
            
'vimeo',
            
'website',
            
'wechat',
            
'whatsapp',
            
'youtube',
            
'zillow',
        ];
        
$resource_prefix_url YAYMAIL_PLUGIN_URL 'assets/images/social-icons/';
        
$themes              = [ 'colorful''line-dark''line-light''solid-dark''solid-light' ];
        
$themes_pascal       array_map( [ self::class, 'kebab_to_pascal' ], $themes );
        
$images              = [];
        foreach ( 
$socials as $social ) {
            
$pngs = [];
            foreach ( 
$themes as $theme ) {
                
$theme_pascal self::kebab_to_pascal$theme );
                
$file_name    $theme '.png';
                
$file_url     $resource_prefix_url $social '/' $file_name;
                
$pngs[]       = [
                    
'theme' => $theme_pascal,
                    
'src'   => $file_url,
                ];
            }
            
$images[] = [
                
'name' => $social,
                
'data' => $pngs,
            ];
        }

        return [
            
'themes' => $themes_pascal,
            
'images' => $images,
        ];
    }

    public static function 
get_global_headers_footers() {
        
$template_model         TemplateModel::get_instance();
        
$global_headers_footers $template_model->get_global_header_and_footer();
        return 
$global_headers_footers;
    }

    public static function 
get_activated_addons() {
        
$result apply_filters'yaymail_activated_addons', [] );

        return 
$result;
    }

    private static function 
kebab_to_pascal$input ) {
        
// Remove hyphens and split the string into words
        
$words explode'-'$input );
        
// Capitalize the first letter of each word
        
$pascal_words array_map'ucfirst'$words );
        
// Join the words back together
        
$pascal_case implode''$pascal_words );

        return 
$pascal_case;
    }
}