Initial commit

This commit is contained in:
2020-04-07 13:03:04 +00:00
committed by Gitium
commit 00f842d9bf
1673 changed files with 471161 additions and 0 deletions

View File

@ -0,0 +1,66 @@
<?php
/**
* The abstract class for module definition.
*
* @package ThemeIsleSDK
* @subpackage Loader
* @copyright Copyright (c) 2017, Marius Cristea
* @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
* @since 3.0.0
*/
namespace ThemeisleSDK\Common;
use ThemeisleSDK\Product;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class Abstract_Module.
*
* @package ThemeisleSDK\Common
*/
abstract class Abstract_Module {
/**
* Product which use the module.
*
* @var Product $product Product object.
*/
protected $product = null;
/**
* Can load the module for the selected product.
*
* @param Product $product Product data.
*
* @return bool Should load module?
*/
public abstract function can_load( $product );
/**
* Bootstrap the module.
*
* @param Product $product Product object.
*/
public abstract function load( $product );
/**
* Check if the product is from partner.
*
* @param Product $product Product data.
*
* @return bool Is product from partner.
*/
public function is_from_partner( $product ) {
foreach ( Module_Factory::$domains as $partner_domain ) {
if ( strpos( $product->get_store_url(), $partner_domain ) !== false ) {
return true;
}
}
return array_key_exists( $product->get_slug(), Module_Factory::$slugs );
}
}

View File

@ -0,0 +1,108 @@
<?php
/**
* The module factory class.
*
* @package ThemeIsleSDK
* @subpackage Loader
* @copyright Copyright (c) 2017, Marius Cristea
* @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
* @since 3.0.0
*/
namespace ThemeisleSDK\Common;
use ThemeisleSDK\Product;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class Job_Factory
*
* @package ThemeisleSDK\Common
*/
class Module_Factory {
/**
* Partners slugs.
*
* @var array $SLUGS Partners product slugs.
*/
public static $slugs = [
'zermatt' => true,
'neto' => true,
'olsen' => true,
'benson' => true,
'romero' => true,
'carmack' => true,
'puzzle' => true,
'broadsheet' => true,
'girlywp' => true,
'veggie' => true,
'zeko' => true,
'maishawp' => true,
'didi' => true,
'liber' => true,
'medicpress-pt' => true,
'adrenaline-pt' => true,
'consultpress-pt' => true,
'legalpress-pt' => true,
'gympress-pt' => true,
'readable-pt' => true,
'bolts-pt' => true,
];
/**
* Partners domains.
*
* @var array $DOMAINS Partners domains.
*/
public static $domains = [
'proteusthemes.com',
'anarieldesign.com',
'prothemedesign.com',
'cssigniter.com',
];
/**
* Map which contains all the modules loaded for each product.
*
* @var array Mapping array.
*/
private static $modules_attached = [];
/**
* Load availabe modules for the selected product.
*
* @param Product $product Loaded product.
* @param array $modules List of modules.
*/
public static function attach( $product, $modules ) {
if ( ! isset( self::$modules_attached[ $product->get_slug() ] ) ) {
self::$modules_attached[ $product->get_slug() ] = [];
}
foreach ( $modules as $module ) {
$class = 'ThemeisleSDK\\Modules\\' . ucwords( $module, '_' );
/**
* Module object.
*
* @var Abstract_Module $module_object Module instance.
*/
$module_object = new $class( $product );
if ( ! $module_object->can_load( $product ) ) {
continue;
}
self::$modules_attached[ $product->get_slug() ][ $module ] = $module_object->load( $product );
}
}
/**
* Products/Modules loaded map.
*
* @return array Modules map.
*/
public static function get_modules_map() {
return self::$modules_attached;
}
}