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
← All changes | app/src/Modules/Beaver/module.php +53 -23 1.2.01.9.2 View file →
@@ -29,32 +29,59 @@
29 29 'partial_refresh' => false, // Defaults to false and can be omitted.
30 30
31 31 ) );
32 32
33 - $styles = \Depicter::front()->assets()->registerStyles();
34 - foreach ( $styles as $handler => $style ) {
35 - $this->add_css( $handler );
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;
36 45 }
37 46
38 - $scripts = \Depicter::front()->assets()->registerScripts();
39 - foreach ( $scripts as $handler => $script ) {
40 - $this->add_js( $handler );
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 + }
41 67 }
42 68 }
43 69
44 70 public static function getDepicterFields() {
45 - if ( ! isset( $_GET['fl_builder'] ) ) {
71 + if ( ! isset( $_GET['fl_builder'] ) ) {
46 72 return[];
47 73 }
48 -
74 +
49 75 $list = [
50 - 0 => __( 'Select Slider', 'depicter' )
76 + '0' => __( 'Select Slider', 'depicter' )
51 77 ];
52 - $documents = \Depicter::documentRepository()->getList();
78 + $documents = \Depicter::documentRepository()->select( ['id', 'name', 'status'] )->orderBy('modified_at', 'DESC')->findAll()->get();
79 + $documents = $documents ? $documents->toArray() : [];
53 80 foreach( $documents as $document ) {
54 - $list[ $document['id'] ] = "[#{$document['id']}]: " . $document['name'];
81 + $list[ '#' . $document['id'] ] = "[#{$document['id']}]: " . $document['name'];
55 82 }
56 -
83 +
57 84 $fields = [
58 85 'document_id' => [
59 86 'type' => 'select',
60 87 'label' => __( 'Select Slider', 'depicter' ),
@@ -61,20 +88,23 @@
61 88 'default' => '0',
62 89 'options' => $list
63 90 ]
64 91 ];
65 - foreach( $documents as $document ) {
92 + if ( current_user_can( 'access_depicter' ) ) {
93 + foreach( $documents as $document ) {
66 94
67 - $args = [
68 - 'isNotPublished' => \Depicter::documentRepository()->isNotPublished( $document['id'], [ 'status' => 'publish' ] ),
69 - 'documentStatus' => $document['status']
70 - ];
71 -
72 - $markup = \Depicter::view('admin/notices/builders-draft-notice')->with('view_args', $args)->toString();
73 - $fields[ 'slider_control_buttons_' . $document['id'] ] = [
74 - 'type' => 'raw',
75 - 'content' => $markup,
76 - ];
95 + $args = [
96 + 'isPublishedBefore' => \Depicter::documentRepository()->isPublishedBefore( $document['id'] ),
97 + 'documentStatus' => $document['status'],
98 + 'documentID' => $document['id']
99 + ];
100 +
101 + $markup = \Depicter::view('admin/notices/builders-draft-notice')->with('view_args', $args)->toString();
102 + $fields[ 'slider_control_buttons_' . $document['id'] ] = [
103 + 'type' => 'raw',
104 + 'content' => $markup,
105 + ];
106 + }
77 107 }
78 108
79 109 return $fields;
80 110 }