PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 1.6.4
Kubio AI Page Builder v1.6.4
2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / lib / src / DemoSites / DemoPartsRepository.php
kubio / lib / src / DemoSites Last commit date
DemoPartsRepository.php 3 years ago DemoSites.php 3 years ago DemoSitesHelpers.php 4 years ago DemoSitesImportBlockMap.php 4 years ago DemoSitesImporter.php 3 years ago DemoSitesLogger.php 4 years ago DemoSitesRepository.php 3 years ago WXRExporter.php 4 years ago WXRImporter.php 3 years ago WpCliCommand.php 3 years ago
DemoPartsRepository.php
71 lines
1 <?php
2
3 namespace Kubio\DemoSites;
4
5 class DemoPartsRepository {
6
7 private static $demoParts = null;
8 const DEMO_PARTS_TRANSIENT = 'kubio-demo-parts-repository';
9 private static $instance = null;
10
11 public function __construct() {
12 $this->addRestEndPoints();
13 $this->loadData();
14 }
15
16 public function loadData() {
17 $data = get_transient( self::DEMO_PARTS_TRANSIENT );
18 if ( $data !== false ) {
19 static::$demoParts = $data;
20 }
21 }
22
23 public function getDemoParts() {
24 return static::$demoParts;
25 }
26
27 public function saveDemoParts( \WP_REST_Request $request ) {
28 $demoParts = $request->get_param('demoParts');
29 if(isset($demoParts) && !empty($demoParts)) {
30 set_transient( static::DEMO_PARTS_TRANSIENT, $demoParts );
31 }
32
33 }
34 public function addRestEndPoints() {
35 add_action(
36 'rest_api_init',
37 function () {
38 $namespace = 'kubio/v1';
39
40 register_rest_route(
41 $namespace,
42 '/demo-sites/demo-parts',
43 array(
44 'methods' => 'POST',
45 'callback' => array( $this, 'saveDemoParts' ),
46 'permission_callback' => function () {
47 return current_user_can( 'edit_theme_options' );
48 },
49
50 )
51 );
52 }
53 );
54
55 }
56
57 public static function getInstance() {
58 if ( ! self::$instance ) {
59
60 self::$instance = new self();
61 }
62
63 return self::$instance;
64 }
65
66 public static function load() {
67 return self::getInstance();
68 }
69
70 }
71