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
|
<?php /** * FooGallery Extension Class that holds all information about an extension * * Date: 19/03/2017 */ if ( ! class_exists( 'FooGallery_Extension' ) ) {
class FooGallery_Extension extends stdClass {
/** * private constructor * * @param array $array */ private function __construct( $array = null ) { if ( $array !== null ) { $this->load( $array ); } }
private function convertToObject( $array, $parent = null ) { $object = ( null === $parent ) ? $this : new stdClass(); foreach ( $array as $key => $value ) { if ( is_array( $value ) ) { $value = convertToObject( $value, $object ); } $object->$key = $value; } return $object; }
function load( $array ) { $this->convertToObject( $array ); // 'slug' => 'foobox', // 'class' => 'FooGallery_FooBox_Extension', // 'categories' => array( 'Featured', 'Premium' ), // 'file' => 'foobox.php', // 'title' => 'FooBox PRO', // 'description' => 'The best lightbox for WordPress just got even better!', // 'price' => '$27', // 'author' => 'FooPlugins', // 'author_url' => 'http://fooplugins.com', // 'thumbnail' => '/assets/extension_bg.png', // 'tags' => array( 'premium', 'lightbox', ), // 'source' => 'fooplugins', // 'download_button' => // array( // 'text' => 'Buy - $27', // 'target' => '_blank', // 'href' => 'http://fooplugins.com/plugins/foobox', // 'confirm' => false, // ), // 'activated_by_default' => true, // 'minimum_version' => '2.3.2', } } }
|