PluginProbe
Depicter — Popup & Slider Builder / 1.9.2
Depicter — Popup & Slider Builder v1.9.2
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / Modules / Oxygen / module.php

module.php in Depicter — Popup & Slider Builder 1.9.2, at app/src/Modules/Oxygen/module.php

111 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Depicter\Modules\Oxygen;
4
5 class Module extends \OxyEl
6 {
7
8 public function init() {
9 if ( isset( $_GET['ct_builder'] ) ) {
10 add_action( 'wp_enqueue_scripts', [ $this, 'enqueueDepicterAssets' ] );
11 }
12 }
13
14 public function enqueueDepicterAssets() {
15 \Depicter::front()->assets()->enqueueStyles();
16 \Depicter::front()->assets()->enqueueScripts(['player', 'iframe-resizer']);
17 }
18
19 // Define the element's name.
20 public function name() {
21 return __("Depicter", 'depicter');
22 }
23
24 // Element options
25 public function options(){
26
27 return array(
28 //"wrapper_class" => $classes,
29 "server_side_render" => true
30 );
31
32 }
33
34 public function render( $options, $defaults, $content ){
35
36 if ( !empty( $options['slider_id'] ) ) {
37 $list = $this->getSlidersList();
38 $sliderID = count( $list ) > 2 ? $options['slider_id'] : array_search( $options['slider_id'], $list );
39
40 echo "<style>.oxy-depicter{ width: 100%; }</style>";
41 if ( isset( $_GET['action'] ) && $_GET['action'] == 'oxy_render_oxy-depicter' ) {
42 echo '<iframe id="sliderIframe-' . $sliderID . '" style="width: 1px;min-width: 100%;" src="' . admin_url('admin-ajax.php') . '?action=depicter/document/preview&depicter-csrf=' . \Depicter::csrf()->getToken( \Depicter\Security\CSRF::EDITOR_ACTION ) . '&ID=' . $sliderID . '&status=draft|publish&gutenberg=true"></iframe>';
43 echo "<script>iFrameResize({}, '#sliderIframe-" . $sliderID . "')</script>";
44 } else {
45 echo \Depicter::front()->render()->document( $sliderID, [ 'echo' => false ] );
46 }
47 } else {
48 echo esc_html__('Please select a Depicter slider','depicter' );
49 }
50
51 }
52
53 public function getSlidersList() {
54 $list = [
55 0 => __( 'Select Slider', 'depicter' )
56 ];
57 $documents = \Depicter::documentRepository()->select( ['id', 'name', 'status'] )->orderBy('modified_at', 'DESC')->findAll()->get();
58 $documents = $documents ? $documents->toArray() : [];
59 foreach( $documents as $document ) {
60 $list[ $document['id'] ] = "[#{$document['id']}]: " . $document['name'];
61 }
62 return $list;
63 }
64
65 public function controls(){
66
67 $list = $this->getSlidersList();
68
69 // Select Slider
70 $this->addOptionControl(
71 array(
72 "type" => 'dropdown',
73 "name" => __("Select Slider", 'depicter' ),
74 "slug" => 'slider_id',
75 )
76 )->setValue( $list )->rebuildElementOnChange();
77
78 if ( current_user_can( 'access_depicter' ) ) {
79 $documents = \Depicter::documentRepository()->select( ['id', 'name', 'status'] )->orderBy('modified_at', 'DESC')->findAll()->get();
80 $documents = $documents ? $documents->toArray() : [];
81 foreach( $documents as $document ) {
82
83 $this->addOptionControl( [
84 "type" => 'custom_control',
85 "name" => __('Publish or Edit Slider', 'depicter' ),
86 "slug" => 'slider_btns_' . $document['id'],
87 "condition" => 'slider_id=' . $document['id'],
88 ])->setHTML( $this->slider_buttons_markup([
89 'isPublishedBefore' => \Depicter::documentRepository()->isPublishedBefore( $document['id'] ),
90 'documentStatus' => $document['status'],
91 'documentID' => $document['id']
92 ]) );
93 }
94 }
95 }
96
97 /**
98 * Get slider buttons control field markup
99 *
100 * @param array $settings
101 * @param string $value
102 * @return string
103 */
104 public function slider_buttons_markup( $settings ) {
105 return \Depicter::view('admin/notices/builders-draft-notice')->with('view_args', $settings)->toString();
106 }
107
108 }
109
110 new Module();
111