| 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 |
$styles = \Depicter::front()->assets()->registerStyles(); |
| 34 |
foreach ( $styles as $handler => $style ) { |
| 35 |
$this->add_css( $handler ); |
| 36 |
} |
| 37 |
|
| 38 |
$scripts = \Depicter::front()->assets()->registerScripts(); |
| 39 |
foreach ( $scripts as $handler => $script ) { |
| 40 |
$this->add_js( $handler ); |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
public static function getDepicterFields() { |
| 45 |
if ( ! isset( $_GET['fl_builder'] ) ) { |
| 46 |
return[]; |
| 47 |
} |
| 48 |
|
| 49 |
$list = [ |
| 50 |
0 => __( 'Select Slider', 'depicter' ) |
| 51 |
]; |
| 52 |
$documents = \Depicter::documentRepository()->getList(); |
| 53 |
foreach( $documents as $document ) { |
| 54 |
$list[ $document['id'] ] = "[#{$document['id']}]: " . $document['name']; |
| 55 |
} |
| 56 |
|
| 57 |
$fields = [ |
| 58 |
'document_id' => [ |
| 59 |
'type' => 'select', |
| 60 |
'label' => __( 'Select Slider', 'depicter' ), |
| 61 |
'default' => '0', |
| 62 |
'options' => $list |
| 63 |
] |
| 64 |
]; |
| 65 |
foreach( $documents as $document ) { |
| 66 |
|
| 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 |
]; |
| 77 |
} |
| 78 |
|
| 79 |
return $fields; |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
\FLBuilder::register_module( '\Depicter\Modules\Beaver\Module', array( |
| 84 |
'general' => array( // Tab |
| 85 |
'title' => __('General', 'depicter'), // Tab title |
| 86 |
'sections' => array( // Tab Sections |
| 87 |
'general' => array( // Section |
| 88 |
'title' => __('Depicter Settings', 'depicter'), // Section Title |
| 89 |
'fields' => Module::getDepicterFields() // Section Fields |
| 90 |
), |
| 91 |
), |
| 92 |
) |
| 93 |
) ); |
| 94 |
|