class-extension.php
7 months ago
class-extensions-api.php
7 months ago
class-extensions-loader.php
7 months ago
class-extension.php
58 lines
| 1 | <?php |
| 2 | /** |
| 3 | * FooGallery Extension Class that holds all information about an extension |
| 4 | * |
| 5 | * Date: 19/03/2017 |
| 6 | */ |
| 7 | if ( ! class_exists( 'FooGallery_Extension' ) ) { |
| 8 | |
| 9 | class FooGallery_Extension extends stdClass { |
| 10 | |
| 11 | /** |
| 12 | * private constructor |
| 13 | * |
| 14 | * @param array $array |
| 15 | */ |
| 16 | private function __construct( $array = null ) { |
| 17 | if ( $array !== null ) { |
| 18 | $this->load( $array ); |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | private function convertToObject( $array, $parent = null ) { |
| 23 | $object = ( null === $parent ) ? $this : new stdClass(); |
| 24 | foreach ( $array as $key => $value ) { |
| 25 | if ( is_array( $value ) ) { |
| 26 | $value = convertToObject( $value, $object ); |
| 27 | } |
| 28 | $object->$key = $value; |
| 29 | } |
| 30 | return $object; |
| 31 | } |
| 32 | |
| 33 | function load( $array ) { |
| 34 | $this->convertToObject( $array ); |
| 35 | // 'slug' => 'foobox', |
| 36 | // 'class' => 'FooGallery_FooBox_Extension', |
| 37 | // 'categories' => array( 'Featured', 'Premium' ), |
| 38 | // 'file' => 'foobox.php', |
| 39 | // 'title' => 'FooBox PRO', |
| 40 | // 'description' => 'The best lightbox for WordPress just got even better!', |
| 41 | // 'price' => '$27', |
| 42 | // 'author' => 'FooPlugins', |
| 43 | // 'author_url' => 'https://fooplugins.com', |
| 44 | // 'thumbnail' => '/assets/extension_bg.png', |
| 45 | // 'tags' => array( 'premium', 'lightbox', ), |
| 46 | // 'source' => 'fooplugins', |
| 47 | // 'download_button' => |
| 48 | // array( |
| 49 | // 'text' => 'Buy - $27', |
| 50 | // 'target' => '_blank', |
| 51 | // 'href' => 'https://fooplugins.com/plugins/foobox', |
| 52 | // 'confirm' => false, |
| 53 | // ), |
| 54 | // 'activated_by_default' => true, |
| 55 | // 'minimum_version' => '2.3.2', |
| 56 | } |
| 57 | } |
| 58 | } |