| @@ -1,8 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Depicter\Modules; |
| 4 | -; | |
| 4 | + | |
| 5 | + | |
| 5 | 6 | use Depicter\Modules\Elementor\SliderWidget; |
| 6 | 7 | use WPEmerge\ServiceProviders\ServiceProviderInterface; |
| 7 | 8 | |
| 8 | 9 | /** |
| @@ -14,8 +15,15 @@ | ||
| 14 | 15 | */ |
| 15 | 16 | public function register( $container ) { |
| 16 | 17 | add_action( 'plugins_loaded', [ $this, 'elementorModulesLoaded' ] ); |
| 17 | 18 | $this->modulesLoaded(); |
| 19 | + | |
| 20 | + $app = $container[ WPEMERGE_APPLICATION_KEY ]; | |
| 21 | + | |
| 22 | + $container[ 'depicter.modules.manager' ] = function () { | |
| 23 | + return new Modules(); | |
| 24 | + }; | |
| 25 | + $app->alias( 'modules', 'depicter.modules.manager' ); | |
| 18 | 26 | } |
| 19 | 27 | |
| 20 | 28 | public function elementorModulesLoaded() { |
| 21 | 29 | if( defined( 'ELEMENTOR_VERSION' ) ){ |
| @@ -32,8 +40,10 @@ | ||
| 32 | 40 | add_action( 'wp_enqueue_scripts', [ $this, 'load_beaver_builder_widget_script'] ); |
| 33 | 41 | |
| 34 | 42 | add_action( 'vc_before_init', [ $this, 'initWPBakeryModule' ] ); |
| 35 | 43 | add_action( 'init', [ $this, 'initDiviModule' ] ); |
| 44 | + | |
| 45 | + add_action( 'init', [ $this, 'loadOxygenModule' ] ); | |
| 36 | 46 | } |
| 37 | 47 | |
| 38 | 48 | /** |
| 39 | 49 | * {@inheritDoc} |
| @@ -82,9 +92,10 @@ | ||
| 82 | 92 | 'id' => "0", |
| 83 | 93 | 'name' => __( 'Select Slider', 'depicter' ) |
| 84 | 94 | ] |
| 85 | 95 | ]; |
| 86 | - $list = array_merge( $list, \Depicter::app()->documentRepository()->getList(['name','id']) ); | |
| 96 | + $documents = \Depicter::documentRepository()->select( ['id', 'name'] )->orderBy('modified_at', 'DESC')->findAll()->get(); | |
| 97 | + $list = $documents ? array_merge( $list, $documents->toArray() ) : $list; | |
| 87 | 98 | if ( !empty( $list ) ) { |
| 88 | 99 | foreach ( $list as $key => $item ) { |
| 89 | 100 | $list[ $key ]['label'] = $item['name']; |
| 90 | 101 | unset( $list[ $key ]['name'] ); |
| @@ -92,10 +103,20 @@ | ||
| 92 | 103 | $list[ $key ]['value'] = $item['id']; |
| 93 | 104 | unset( $list[ $key ]['id'] ); |
| 94 | 105 | } |
| 95 | 106 | } |
| 107 | + | |
| 108 | + // load common assets | |
| 109 | + \Depicter::front()->assets()->enqueueStyles(); | |
| 110 | + \Depicter::front()->assets()->enqueueScripts(['player', 'iframe-resizer']); | |
| 111 | + | |
| 96 | 112 | wp_localize_script( 'wp-block-editor', 'depicterSliders',[ |
| 97 | - 'list' => $list | |
| 113 | + 'list' => $list, | |
| 114 | + 'ajax_url' => admin_url('admin-ajax.php'), | |
| 115 | + 'editor_url' => \Depicter::editor()->getEditUrl('1'), | |
| 116 | + 'token' => \Depicter::csrf()->getToken( \Depicter\Security\CSRF::EDITOR_ACTION ), | |
| 117 | + 'publish_text' => esc_html__( 'Publish Slider', 'depicter' ), | |
| 118 | + 'edit_text' => esc_html__( 'Edit Slider', 'depicter' ) | |
| 98 | 119 | ]); |
| 99 | 120 | |
| 100 | 121 | } |
| 101 | 122 | |
| @@ -134,8 +155,12 @@ | ||
| 134 | 155 | * @return void |
| 135 | 156 | */ |
| 136 | 157 | public function initWPBakeryModule() { |
| 137 | 158 | require_once 'WPBakery/module.php'; |
| 159 | + | |
| 160 | + if ( !empty( $_GET['vc_action'] ) && $_GET['vc_action'] == 'vc_inline' ) { | |
| 161 | + $this->enqueueEditorScripts(); | |
| 162 | + } | |
| 138 | 163 | } |
| 139 | 164 | |
| 140 | 165 | /** |
| 141 | 166 | * Load divi module |
| @@ -144,7 +169,21 @@ | ||
| 144 | 169 | */ |
| 145 | 170 | public function initDiviModule() { |
| 146 | 171 | if ( class_exists( 'ET_Builder_Plugin' ) ) { |
| 147 | 172 | require_once 'Divi/depicter-divi.php'; |
| 173 | + | |
| 174 | + if ( !empty( $_GET['et_fb'] ) ) { | |
| 175 | + add_action( 'wp_enqueue_scripts', [ $this, 'enqueueEditorScripts' ] ); | |
| 176 | + } | |
| 177 | + } | |
| 178 | + } | |
| 179 | + | |
| 180 | + public function loadOxygenModule() { | |
| 181 | + if ( class_exists('\OxyEl') ) { | |
| 182 | + require_once 'Oxygen/module.php'; | |
| 183 | + } | |
| 184 | + | |
| 185 | + if ( isset( $_GET['ct_builder'] ) ) { | |
| 186 | + add_action( 'wp_enqueue_scripts', [ $this, 'enqueueEditorScripts' ] ); | |
| 148 | 187 | } |
| 149 | 188 | } |
| 150 | 189 | } |