extensions.php
4.62 KB
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php
namespace HM\BackUpWordPress;
?>
<div class="wrap">
<h1>
<a class="page-title-action" href="<?php echo esc_url( get_settings_url() ); ?>"><?php _e( '← Backups', 'backupwordpress' ); ?></a>
<?php _e( 'BackUpWordPress Extensions', 'backupwordpress' ); ?>
</h1>
<div class="wp-filter">
<p><?php _e( 'Extend BackUpWordPress by installing extensions. Extensions allows you to pick and choose the exact features you need whilst also supporting us, the developers, so we can continue working on BackUpWordPress.', 'backupwordpress' ); ?></p>
</div>
<?php
$extensions_data = Extensions::get_instance()->get_edd_data();
// Sort by title
usort( $extensions_data, function( $a, $b ) {
return strcmp( $b->title->rendered, $a->title->rendered );
});
$installed_plugins = array_reduce( get_plugins(), function( $carry, $item ) {
$carry[ strtolower( $item['Name'] ) ] = $item['Version'];
return $carry;
}, array() );
?>
<h3><?php _e( 'Remote Storage', 'backupwordpress' ); ?></h3>
<p><?php _e( 'It\'s important to store your backups somewhere other than on your site. Using the extensions below you can easily push your backups to one or more Cloud providers.', 'backupwordpress' ); ?></p>
<div class="wp-list-table widefat plugin-install">
<div id="the-list">
<?php $first = true; ?>
<?php foreach ( $extensions_data as $extension ) : ?>
<div class="plugin-card plugin-card-<?php echo esc_attr( $extension->slug ); ?>">
<div class="plugin-card-top">
<div class="name column-name">
<h4>
<a href="<?php echo esc_url( $extension->link ); ?>" class="thickbox">
<?php echo esc_html( $extension->title->rendered ); ?>
<img src="<?php echo esc_url( $extension->featured_image_url ); ?>" class="plugin-icon" alt="">
</a>
</h4>
</div>
<div class="action-links">
<ul class="plugin-action-buttons">
<li>
<?php if ( in_array( strtolower( $extension->title->rendered ), array_keys( $installed_plugins ) ) ) : ?>
<span class="button button-disabled" title="<?php _e( 'This extension is already installed', 'backupwordpress' ); ?>"><?php _e( 'Installed', 'backupwordpress' ); ?></span>
<?php else : ?>
<a class="install-now button-primary" data-slug="<?php echo esc_attr( $extension->slug ); ?>" href="<?php echo esc_url( $extension->link ); ?>" aria-label="Install <?php echo esc_attr( $extension->title->rendered ); ?> now" data-name="<?php echo esc_attr( $extension->title->rendered ); ?>"><?php printf( __( 'Buy Now $%s', 'backupwordpress' ), $extension->edd_price ); ?></a>
<?php endif; ?>
</li>
<li>
<a href="<?php echo esc_url( $extension->link ); ?>" class="thickbox" aria-label="<?php printf( __( 'More information about %s', 'backupwordpress' ), esc_attr( $extension->title->rendered ) ) ; ?>" data-title="<?php echo esc_attr( $extension->title->rendered ); ?>"><?php _e( 'More Details', 'backupwordpress' ); ?></a>
</li>
</ul>
</div>
<div class="desc column-description">
<p><?php echo wp_kses_post( $extension->content->rendered ); ?></p>
</div>
</div>
<?php
$style = $first === true ? 'background-color:aliceblue;' : '';
$first = false;
?>
<div class="plugin-card-bottom" style="<?php echo esc_attr( $style ); ?>">
<div class="vers column-rating">
<div>
<?php esc_html_e( sprintf( __( 'Plugin version %s', 'backupwordpress' ), $extension->_edd_sl_version ) ); ?>
</div>
<div>
<?php
$text = '';
if ( in_array( strtolower( $extension->title->rendered ), array_keys( $installed_plugins ) ) ) {
$current_version = $installed_plugins[ strtolower( $extension->title->rendered ) ];
if ( version_compare( $current_version, $extension->_edd_sl_version, '<' ) ) {
$text = sprintf( __( 'A newer version (%1$s) is available. <a href="%2$s">Update now!</a>', 'backupwordpress' ), esc_html( $extension->_edd_sl_version ), esc_url( admin_url( 'update-core.php' ) ) );
} else {
$text = esc_html__( 'You have the latest version', 'backupwordpress' );
}
}
echo $text;
?>
</div>
</div>
<div class="column-updated">
<strong><?php _e( 'Last Updated:', 'backupwordpress' ); ?></strong> <span title="<?php echo esc_attr( $extension->modified ); ?>"><?php printf( __( '%s ago', 'backupwordpress' ), human_time_diff( strtotime( $extension->modified ) ) ); ?></span>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>