PluginProbe
Depicter — Popup & Slider Builder / 1.5.2
Depicter — Popup & Slider Builder v1.5.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 / Beaver / module.php

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

121 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Depicter\Modules\Beaver;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 class Module extends \FLBuilderModule {
9
10 public function __construct() {
11 parent::__construct( array(
12
13 'name' => __( 'Depicter', 'depicter' ),
14
15 'description' => __( 'Make animated and interactive image slider, video slider, post slider and carousel which work smoothly across devices.', 'depicter' ),
16
17 'category' => __( 'Depicter', 'depicter' ),
18
19 'dir' => DEPICTER_PLUGIN_PATH . '/app/src/Modules/Beaver/',
20
21 'url' => DEPICTER_PLUGIN_URL . '/app/src/Modules/Beaver/',
22
23 // 'icon' => 'button.svg',
24
25 'editor_export' => true, // Defaults to true and can be omitted.
26
27 'enabled' => true, // Defaults to true and can be omitted.
28
29 'partial_refresh' => false, // Defaults to false and can be omitted.
30
31 ) );
32
33 add_action( 'wp_enqueue_scripts', [ $this, 'loadModuletScripts' ] );
34 }
35
36 /**
37 * Load module scripts when required
38 *
39 * @return void
40 */
41 public function loadModuletScripts() {
42 global $post;
43 if ( !\FLBuilderModel::is_builder_enabled( $post->ID ) ) {
44 return;
45 }
46
47 if ( strpos( $post->post_content, 'depicter-') || \FLBuilderModel::is_builder_active() ) {
48 $styles = \Depicter::front()->assets()->enqueueStyles();
49 foreach ( $styles as $handler => $style ) {
50 $this->add_css( $handler );
51 }
52
53 $flbuilder_data = get_post_meta( $post->ID, '_fl_builder_data', true);
54 $flbuilder_data = is_array( $flbuilder_data ) ? maybe_serialize( $flbuilder_data ) : $flbuilder_data;
55 preg_match_all( '/document_id";s:\d+:"(\d+)"/', $flbuilder_data, $sliderIDs, PREG_SET_ORDER );
56 foreach( $sliderIDs as $key => $sliderID ) {
57 if ( !empty( $sliderID[1] ) ) {
58 \Depicter::front()->assets()->enqueueCustomAssets( $sliderID[1] );
59 \Depicter::front()->assets()->enqueuePreloadTags( $sliderID[1] );
60 }
61 }
62
63 $scripts = \Depicter::front()->assets()->enqueueScripts();
64 foreach ( $scripts as $handler => $script ) {
65 $this->add_js( $handler );
66 }
67 }
68 }
69
70 public static function getDepicterFields() {
71 if ( ! isset( $_GET['fl_builder'] ) ) {
72 return[];
73 }
74
75 $list = [
76 '0' => __( 'Select Slider', 'depicter' )
77 ];
78 $documents = \Depicter::documentRepository()->select( ['id', 'name', 'status'] )->orderBy('modified_at', 'DESC')->findAll()->get();
79 $documents = $documents ? $documents->toArray() : [];
80 foreach( $documents as $document ) {
81 $list[ '#' . $document['id'] ] = "[#{$document['id']}]: " . $document['name'];
82 }
83
84 $fields = [
85 'document_id' => [
86 'type' => 'select',
87 'label' => __( 'Select Slider', 'depicter' ),
88 'default' => '0',
89 'options' => $list
90 ]
91 ];
92 foreach( $documents as $document ) {
93
94 $args = [
95 'isPublishedBefore' => \Depicter::documentRepository()->isPublishedBefore( $document['id'] ),
96 'documentStatus' => $document['status']
97 ];
98
99 $markup = \Depicter::view('admin/notices/builders-draft-notice')->with('view_args', $args)->toString();
100 $fields[ 'slider_control_buttons_' . $document['id'] ] = [
101 'type' => 'raw',
102 'content' => $markup,
103 ];
104 }
105
106 return $fields;
107 }
108 }
109
110 \FLBuilder::register_module( '\Depicter\Modules\Beaver\Module', array(
111 'general' => array( // Tab
112 'title' => __('General', 'depicter'), // Tab title
113 'sections' => array( // Tab Sections
114 'general' => array( // Section
115 'title' => __('Depicter Settings', 'depicter'), // Section Title
116 'fields' => Module::getDepicterFields() // Section Fields
117 ),
118 ),
119 )
120 ) );
121