PluginProbe
Depicter — Popup & Slider Builder / 1.3.3
Depicter — Popup & Slider Builder v1.3.3
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.3.3, at app/src/Modules/Beaver/module.php

119 lines 3.9 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 }
60 }
61
62 $scripts = \Depicter::front()->assets()->enqueueScripts();
63 foreach ( $scripts as $handler => $script ) {
64 $this->add_js( $handler );
65 }
66 }
67 }
68
69 public static function getDepicterFields() {
70 if ( ! isset( $_GET['fl_builder'] ) ) {
71 return[];
72 }
73
74 $list = [
75 0 => __( 'Select Slider', 'depicter' )
76 ];
77 $documents = \Depicter::documentRepository()->getList();
78 foreach( $documents as $document ) {
79 $list[ $document['id'] ] = "[#{$document['id']}]: " . $document['name'];
80 }
81
82 $fields = [
83 'document_id' => [
84 'type' => 'select',
85 'label' => __( 'Select Slider', 'depicter' ),
86 'default' => '0',
87 'options' => $list
88 ]
89 ];
90 foreach( $documents as $document ) {
91
92 $args = [
93 'isNotPublished' => \Depicter::documentRepository()->isNotPublished( $document['id'], [ 'status' => 'publish' ] ),
94 'documentStatus' => $document['status']
95 ];
96
97 $markup = \Depicter::view('admin/notices/builders-draft-notice')->with('view_args', $args)->toString();
98 $fields[ 'slider_control_buttons_' . $document['id'] ] = [
99 'type' => 'raw',
100 'content' => $markup,
101 ];
102 }
103
104 return $fields;
105 }
106 }
107
108 \FLBuilder::register_module( '\Depicter\Modules\Beaver\Module', array(
109 'general' => array( // Tab
110 'title' => __('General', 'depicter'), // Tab title
111 'sections' => array( // Tab Sections
112 'general' => array( // Section
113 'title' => __('Depicter Settings', 'depicter'), // Section Title
114 'fields' => Module::getDepicterFields() // Section Fields
115 ),
116 ),
117 )
118 ) );
119