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

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