-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs_composer.php
executable file
·910 lines (838 loc) · 21.9 KB
/
js_composer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
<?php
/*
Plugin Name: WPBakery Visual Composer
Plugin URI: http://vc.wpbakery.com
Description: Drag and drop page builder for WordPress. Take full control over your WordPress site, build any layout you can imagine – no programming knowledge required.
Version: 4.12.1
Author: Michael M - WPBakery.com
Author URI: http://wpbakery.com
*/
// don't load directly
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Current visual composer version
*/
if ( ! defined( 'WPB_VC_VERSION' ) ) {
/**
*
*/
define( 'WPB_VC_VERSION', '4.12.1' );
}
/**
* Vc starts here. Manager sets mode, adds required wp hooks and loads required object of structure
*
* Manager controls and access to all modules and classes of VC.
*
* @package WPBakeryVisualComposer
* @since 4.2
*/
class Vc_Manager {
/**
* Set status/mode for VC.
*
* It depends on what functionality is required from vc to work with current page/part of WP.
*
* Possible values:
* none - current status is unknown, default mode;
* page - simple wp page;
* admin_page - wp dashboard;
* admin_frontend_editor - visual composer front end editor version;
* admin_settings_page - settings page
* page_editable - inline version for iframe in front end editor;
*
* @since 4.2
* @var string
*/
private $mode = 'none';
/**
* Enables Visual Composer to act as the theme plugin.
*
* @since 4.2
* @var bool
*/
private $is_as_theme = false;
/**
* Vc is network plugin or not.
* @since 4.2
* @var bool
*/
private $is_network_plugin = null;
/**
* List of paths.
*
* @since 4.2
* @var array
*/
private $paths = array();
/**
* Default post types where to activate visual composer meta box settings
* @since 4.2
* @var array
*/
private $editor_default_post_types = array( 'page' ); // TODO: move to Vc settings
/**
* Directory name in theme folder where composer should search for alternative templates of the shortcode.
* @since 4.2
* @var string
*/
private $custom_user_templates_dir = false;
/**
* Set updater mode
* @since 4.2
* @var bool
*/
private $disable_updater = false;
/**
* Modules and objects instances list
* @since 4.2
* @var array
*/
private $factory = array();
/**
* File name for components manifest file.
*
* @since 4.4
* @var string
*/
private $components_manifest = 'components.json';
/**
* @var string
*/
private $plugin_name = 'js_composer/js_composer.php';
/**
* Core singleton class
* @var self - pattern realization
*/
private static $_instance;
/**
* @var Vc_Current_User_Access|false
* @since 4.8
*/
private $current_user_access = false;
/**
* @var Vc_Role_Access|false
* @since 4.8
*/
private $role_access = false;
public $editor_post_types;
/**
* Constructor loads API functions, defines paths and adds required wp actions
*
* @since 4.2
*/
private function __construct() {
$dir = dirname( __FILE__ );
/**
* Define path settings for visual composer.
*
* APP_ROOT - plugin directory.
* WP_ROOT - WP application root directory.
* APP_DIR - plugin directory name.
* CONFIG_DIR - configuration directory.
* ASSETS_DIR - asset directory full path.
* ASSETS_DIR_NAME - directory name for assets. Used from urls creating.
* CORE_DIR - classes directory for core vc files.
* HELPERS_DIR - directory with helpers functions files.
* SHORTCODES_DIR - shortcodes classes.
* SETTINGS_DIR - main dashboard settings classes.
* TEMPLATES_DIR - directory where all html templates are hold.
* EDITORS_DIR - editors for the post contents
* PARAMS_DIR - complex params for shortcodes editor form.
* UPDATERS_DIR - automatic notifications and updating classes.
*/
$this->setPaths( array(
'APP_ROOT' => $dir,
'WP_ROOT' => preg_replace( '/$\//', '', ABSPATH ),
'APP_DIR' => basename( $dir ),
'CONFIG_DIR' => $dir . '/config',
'ASSETS_DIR' => $dir . '/assets',
'ASSETS_DIR_NAME' => 'assets',
'AUTOLOAD_DIR' => $dir . '/include/autoload',
'CORE_DIR' => $dir . '/include/classes/core',
'HELPERS_DIR' => $dir . '/include/helpers',
'SHORTCODES_DIR' => $dir . '/include/classes/shortcodes',
'SETTINGS_DIR' => $dir . '/include/classes/settings',
'TEMPLATES_DIR' => $dir . '/include/templates',
'EDITORS_DIR' => $dir . '/include/classes/editors',
'PARAMS_DIR' => $dir . '/include/params',
'UPDATERS_DIR' => $dir . '/include/classes/updaters',
'VENDORS_DIR' => $dir . '/include/classes/vendors',
) );
// Load API
require_once $this->path( 'HELPERS_DIR', 'helpers_factory.php' );
require_once $this->path( 'HELPERS_DIR', 'helpers.php' );
require_once $this->path( 'CORE_DIR', 'interfaces.php' );
require_once $this->path( 'CORE_DIR', 'class-vc-sort.php' ); // used by wpb-map
require_once $this->path( 'CORE_DIR', 'class-wpb-map.php' );
require_once $this->path( 'CORE_DIR', 'class-vc-shared-library.php' );
require_once $this->path( 'HELPERS_DIR', 'helpers_api.php' );
require_once $this->path( 'HELPERS_DIR', 'filters.php' );
require_once $this->path( 'PARAMS_DIR', 'params.php' );
require_once $this->path( 'AUTOLOAD_DIR', 'vc-shortcode-autoloader.php' );
require_once $this->path( 'SHORTCODES_DIR', 'shortcodes.php' );
// Add hooks
add_action( 'plugins_loaded', array( &$this, 'pluginsLoaded' ), 9 );
add_action( 'init', array( &$this, 'init' ), 9 );
$this->setPluginName( $this->path( 'APP_DIR', 'js_composer.php' ) );
register_activation_hook( __FILE__, array( $this, 'activationHook' ) );
}
/**
* Get the instane of VC_Manager
*
* @return self
*/
public static function getInstance() {
if ( ! ( self::$_instance instanceof self ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Cloning disabled
*/
private function __clone() {
}
/**
* Serialization disabled
*/
private function __sleep() {
}
/**
* De-serialization disabled
*/
private function __wakeup() {
}
/**
* Callback function WP plugin_loaded action hook. Loads locale
*
* @since 4.2
* @access public
*/
public function pluginsLoaded() {
// Setup locale
do_action( 'vc_plugins_loaded' );
load_plugin_textdomain( 'js_composer', false, $this->path( 'APP_DIR', 'locale' ) );
}
/**
* Callback function for WP init action hook. Sets Vc mode and loads required objects.
*
* @since 4.2
* @access public
*
* @return void
*/
public function init() {
do_action( 'vc_before_init' );
$this->setMode();
do_action( 'vc_after_set_mode' );
/**
* Set version of VC if required.
*/
$this->setVersion();
// Load required
! vc_is_updater_disabled() && vc_updater()->init();
/**
* Init default hooks and options to load.
*/
$this->vc()->init();
/**
* if is admin and not front end editor.
*/
is_admin() && ! vc_is_frontend_editor() && $this->asAdmin();
/**
* if frontend editor is enabled init editor.
*/
vc_enabled_frontend() && vc_frontend_editor()->init();
do_action( 'vc_before_mapping' ); // VC ACTION
// Include default shortcodes.
$this->mapper()->init(); //execute all required
do_action( 'vc_after_mapping' ); // VC ACTION
// Load && Map shortcodes from Automapper.
vc_automapper()->map();
if ( vc_user_access()
->wpAny( 'manage_options' )
->part( 'settings' )
->can( 'vc-updater-tab' )
->get()
) {
vc_license()->setupReminder();
}
do_action( 'vc_after_init' );
}
/**
* @return Vc_Current_User_Access
* @since 4.8
*/
public function getCurrentUserAccess() {
if ( ! $this->current_user_access ) {
require_once vc_path_dir( 'CORE_DIR', 'access/class-vc-current-user-access.php' );
$this->current_user_access = new Vc_Current_User_Access();
}
return $this->current_user_access;
}
/**
* @param false|Vc_Current_User_Access $current_user_access
*/
public function setCurrentUserAccess( $current_user_access ) {
$this->current_user_access = $current_user_access;
}
/**
* @return Vc_Role_Access
* @since 4.8
*/
public function getRoleAccess() {
if ( ! $this->role_access ) {
require_once vc_path_dir( 'CORE_DIR', 'access/class-vc-role-access.php' );
$this->role_access = new Vc_Role_Access();
}
return $this->role_access;
}
/**
* @param false|Vc_Role_Access $role_access
*/
public function setRoleAccess( $role_access ) {
$this->role_access = $role_access;
}
/**
* Enables to add hooks in activation process.
* @since 4.5
*/
public function activationHook() {
do_action( 'vc_activation_hook' );
}
/**
* Load required components to enable useful functionality.
*
* @access public
* @since 4.4
*/
public function loadComponents() {
$manifest_file = apply_filters( 'vc_autoload_components_manifest_file', vc_path_dir( 'AUTOLOAD_DIR', $this->components_manifest ) );
if ( is_file( $manifest_file ) ) {
ob_start();
require_once $manifest_file;
$data = ob_get_clean();
if ( $data ) {
$components = (array) json_decode( $data );
$components = apply_filters( 'vc_autoload_components_list', $components );
$dir = vc_path_dir( 'AUTOLOAD_DIR' );
foreach ( $components as $component => $description ) {
$component_path = $dir . '/' . $component;
if ( false === strpos( $component_path, '*' ) ) {
require_once $component_path;
} else {
$components_paths = glob( $component_path );
if ( is_array( $components_paths ) ) {
foreach ( $components_paths as $path ) {
if ( false === strpos( $path, '*' ) ) {
require_once $path;
}
}
}
}
}
}
}
}
/**
* Load required logic for operating in Wp Admin dashboard.
*
* @since 4.2
* @access protected
*
* @return void
*/
protected function asAdmin() {
vc_license()->init();
vc_backend_editor()->addHooksSettings();
}
/**
* Set VC mode.
*
* Mode depends on which page is requested by client from server and request parameters like vc_action.
*
* @since 4.2
* @access protected
*
* @return void
*/
protected function setMode() {
/**
* TODO: Create another system (When ajax rebuild).
* Use vc_action param to define mode.
* 1. admin_frontend_editor - set by editor or request param
* 2. admin_backend_editor - set by editor or request param
* 3. admin_frontend_editor_ajax - set by request param
* 4. admin_backend_editor_ajax - set by request param
* 5. admin_updater - by vc_action
* 6. page_editable - by vc_action
*/
if ( is_admin() ) {
if ( 'vc_inline' === vc_action() ) {
vc_user_access()
->wpAny( array(
'edit_post',
(int) vc_request_param( 'post_id' ),
) )
->validateDie()
->part( 'frontend_editor' )
->can()
->validateDie();
$this->mode = 'admin_frontend_editor';
} elseif ( ( vc_user_access()
->wpAny( 'edit_posts', 'edit_pages' )
->get() ) && ( 'vc_upgrade' === vc_action() || ( 'update-selected' === vc_get_param( 'action' ) && $this->pluginName() === vc_get_param( 'plugins' ) ) )
) {
$this->mode = 'admin_updater';
} elseif ( vc_user_access()
->wpAny( 'manage_options' )
->get() && isset( $_GET['page'] ) && $_GET['page'] === $this->settings()
->page()
) {
$this->mode = 'admin_settings_page';
} else {
$this->mode = 'admin_page';
}
} else {
if ( isset( $_GET['vc_editable'] ) && 'true' === $_GET['vc_editable'] ) {
vc_user_access()
->checkAdminNonce()
->validateDie()
->wpAny( array(
'edit_post',
(int) vc_request_param( 'vc_post_id' ),
) )
->validateDie()
->part( 'frontend_editor' )
->can()
->validateDie();
$this->mode = 'page_editable';
} else {
$this->mode = 'page';
}
}
}
/**
* Sets version of the VC in DB as option `vc_version`
*
* @since 4.3.2
* @access protected
*
* @return void
*/
protected function setVersion() {
$version = get_option( 'vc_version' );
if ( ! is_string( $version ) || version_compare( $version, WPB_VC_VERSION ) !== 0 ) {
add_action( 'vc_after_init', array(
vc_settings(),
'rebuild',
) );
update_option( 'vc_version', WPB_VC_VERSION );
}
}
/**
* Get current mode for VC.
*
* @since 4.2
* @access public
*
* @return string
*/
public function mode() {
return $this->mode;
}
/**
* Setter for paths
*
* @since 4.2
* @access protected
*
* @param $paths
*/
protected function setPaths( $paths ) {
$this->paths = $paths;
}
/**
* Gets absolute path for file/directory in filesystem.
*
* @since 4.2
* @access public
*
* @param $name - name of path dir
* @param string $file - file name or directory inside path
*
* @return string
*/
public function path( $name, $file = '' ) {
$path = $this->paths[ $name ] . ( strlen( $file ) > 0 ? '/' . preg_replace( '/^\//', '', $file ) : '' );
return apply_filters( 'vc_path_filter', $path );
}
/**
* Set default post types. Vc editors are enabled for such kind of posts.
*
* @param array $type - list of default post types.
*/
public function setEditorDefaultPostTypes( array $type ) {
$this->editor_default_post_types = $type;
}
/**
* Returns list of default post types where user can use visual composer editors.
*
* @since 4.2
* @access public
*
* @return array
*/
public function editorDefaultPostTypes() {
return $this->editor_default_post_types;
}
/**
* Get post types where VC editors are enabled.
*
* @since 4.2
* @access public
*
* @return array
*/
public function editorPostTypes() {
if ( is_null( $this->editor_post_types ) ) {
$post_types = array_keys( vc_user_access()
->part( 'post_types' )
->getAllCaps() );
$this->editor_post_types = $post_types ? $post_types : $this->editorDefaultPostTypes();
}
return $this->editor_post_types;
}
/**
* Set post types where VC editors are enabled.
*
* @since 4.4
* @access public
*
* @param array $post_types
*/
public function setEditorPostTypes( array $post_types ) {
$this->editor_post_types = ! empty( $post_types ) ? $post_types : $this->editorDefaultPostTypes();
require_once ABSPATH . 'wp-admin/includes/user.php';
$editable_roles = get_editable_roles();
foreach ( $editable_roles as $role => $settings ) {
$part = vc_role_access()->who( $role )->part( 'post_types' );
$all_post_types = $part->getAllCaps();
foreach ( $all_post_types as $post_type => $value ) {
$part->getRole()
->remove_cap( $part->getStateKey() . '/' . $post_type );
}
$part->setState( 'custom' );
foreach ( $this->editor_post_types as $post_type ) {
$part->setCapRule( $post_type );
}
}
}
/**
* Setter for as-theme-plugin status for VC.
*
* @since 4.2
* @access public
*
* @param bool $value
*/
public function setIsAsTheme( $value = true ) {
$this->is_as_theme = (boolean) $value;
}
/**
* Get as-theme-plugin status
*
* As theme plugin status used by theme developers. It disables settings
*
* @since 4.2
* @access public
*
* @return bool
*/
public function isAsTheme() {
return (boolean) $this->is_as_theme;
}
/**
* Setter for as network plugin for MultiWP.
*
* @since 4.2
* @access public
*
* @param bool $value
*/
public function setAsNetworkPlugin( $value = true ) {
$this->is_network_plugin = $value;
}
/**
* Gets VC is activated as network plugin.
*
* @since 4.2
* @access public
*
* @return bool
*/
public function isNetworkPlugin() {
if ( is_null( $this->is_network_plugin ) ) {
// Check is VC as network plugin
if ( is_multisite() && ( is_plugin_active_for_network( $this->pluginName() )
|| is_network_only_plugin( $this->pluginName() ) )
) {
$this->setAsNetworkPlugin( true );
}
}
return $this->is_network_plugin ? true : false;
}
/**
* Setter for disable updater variable.
* @since 4.2
* @see
*
* @param bool $value
*/
public function disableUpdater( $value = true ) {
$this->disable_updater = $value;
}
/**
* Get is vc updater is disabled;
*
* @since 4.2
* @see to where updater will be
*
* @return bool
*/
public function isUpdaterDisabled() {
return is_admin() && $this->disable_updater;
}
/**
* Set user directory name.
*
* Directory name is the directory name vc should scan for custom shortcodes template.
*
* @since 4.2
* @access public
*
* @param $dir - path to shortcodes templates inside developers theme
*/
public function setCustomUserShortcodesTemplateDir( $dir ) {
preg_replace( '/\/$/', '', $dir );
$this->custom_user_templates_dir = $dir;
}
/**
* Get default directory where shortcodes templates area placed.
*
* @since 4.2
* @access public
*
* @return string - path to default shortcodes
*/
public function getDefaultShortcodesTemplatesDir() {
return vc_path_dir( 'TEMPLATES_DIR', 'shortcodes' );
}
/**
*
* Get shortcodes template dir.
*
* @since 4.2
* @access public
*
* @param $template
*
* @return string
*/
public function getShortcodesTemplateDir( $template ) {
return false !== $this->custom_user_templates_dir ? $this->custom_user_templates_dir . '/' . $template : locate_template( 'vc_templates' . '/' . $template );
}
/**
* Directory name where template files will be stored.
*
* @since 4.2
* @access public
*
* @return string
*/
public function uploadDir() {
return 'js_composer';
}
/**
* Getter for VC_Mapper instance
*
* @since 4.2
* @access public
*
* @return Vc_Mapper
*/
public function mapper() {
if ( ! isset( $this->factory['mapper'] ) ) {
require_once $this->path( 'CORE_DIR', 'class-vc-mapper.php' );
$this->factory['mapper'] = new Vc_Mapper();
}
return $this->factory['mapper'];
}
/**
* Visual Composer.
*
* @since 4.2
* @access public
*
* @return Vc_Base
*/
public function vc() {
if ( ! isset( $this->factory['vc'] ) ) {
do_action( 'vc_before_init_vc' );
require_once $this->path( 'CORE_DIR', 'class-vc-base.php' );
$vc = new Vc_Base();
// DI Set template new modal editor.
require_once $this->path( 'EDITORS_DIR', 'popups/class-vc-templates-panel-editor.php' );
$vc->setTemplatesPanelEditor( new Vc_Templates_Panel_Editor() );
// DI Set edit form
require_once $this->path( 'EDITORS_DIR', 'popups/class-vc-shortcode-edit-form.php' );
$vc->setEditForm( new Vc_Shortcode_Edit_Form() );
$this->factory['vc'] = $vc;
do_action( 'vc_after_init_vc' );
}
return $this->factory['vc'];
}
/**
* Vc options.
*
* @since 4.2
* @access public
*
* @return Vc_Settings
*/
public function settings() {
if ( ! isset( $this->factory['settings'] ) ) {
do_action( 'vc_before_init_settings' );
require_once $this->path( 'SETTINGS_DIR', 'class-vc-settings.php' );
$this->factory['settings'] = new Vc_Settings();
do_action( 'vc_after_init_settings' );
}
return $this->factory['settings'];
}
/**
* Vc license settings.
*
* @since 4.2
* @access public
*
* @return Vc_License
*/
public function license() {
if ( ! isset( $this->factory['license'] ) ) {
do_action( 'vc_before_init_license' );
require_once $this->path( 'SETTINGS_DIR', 'class-vc-license.php' );
$this->factory['license'] = new Vc_License();
do_action( 'vc_after_init_license' );
}
return $this->factory['license'];
}
/**
* Get frontend VC editor.
*
* @since 4.2
* @access public
*
* @return Vc_Frontend_Editor
*/
public function frontendEditor() {
if ( ! isset( $this->factory['frontend_editor'] ) ) {
do_action( 'vc_before_init_frontend_editor' );
require_once $this->path( 'EDITORS_DIR', 'class-vc-frontend-editor.php' );
$this->factory['frontend_editor'] = new Vc_Frontend_Editor();
}
return $this->factory['frontend_editor'];
}
/**
* Get backend VC editor. Edit page version.
*
* @since 4.2
*
* @return Vc_Backend_Editor
*/
public function backendEditor() {
if ( ! isset( $this->factory['backend_editor'] ) ) {
do_action( 'vc_before_init_backend_editor' );
require_once $this->path( 'EDITORS_DIR', 'class-vc-backend-editor.php' );
$this->factory['backend_editor'] = new Vc_Backend_Editor();
}
return $this->factory['backend_editor'];
}
/**
* Gets automapper instance.
*
* @since 4.2
* @access public
*
* @return Vc_Automapper
*/
public function automapper() {
if ( ! isset( $this->factory['automapper'] ) ) {
do_action( 'vc_before_init_automapper' );
require_once $this->path( 'SETTINGS_DIR', 'class-vc-automapper.php' );
$this->factory['automapper'] = new Vc_Automapper();
do_action( 'vc_after_init_automapper' );
}
return $this->factory['automapper'];
}
/**
* Gets updater instance.
* @since 4.2
*
* @return Vc_Updater
*/
public function updater() {
if ( ! isset( $this->factory['updater'] ) ) {
do_action( 'vc_before_init_updater' );
require_once $this->path( 'UPDATERS_DIR', 'class-vc-updater.php' );
$updater = new Vc_Updater();
require_once vc_path_dir( 'UPDATERS_DIR', 'class-vc-updating-manager.php' );
$updater->setUpdateManager( new Vc_Updating_Manager( WPB_VC_VERSION, $updater->versionUrl(), $this->pluginName() ) );
$this->factory['updater'] = $updater;
do_action( 'vc_after_init_updater' );
}
return $this->factory['updater'];
}
/**
* Getter for plugin name variable.
* @since 4.2
*
* @return string
*/
public function pluginName() {
return $this->plugin_name;
}
/**
* @since 4.8.1
*
*/
public function setPluginName( $name ) {
$this->plugin_name = $name;
}
/**
* Get absolute url for VC asset file.
*
* Assets are css, javascript, less files and images.
*
* @since 4.2
*
* @param $file
*
* @return string
*/
public function assetUrl( $file ) {
return preg_replace( '/\s/', '%20', plugins_url( $this->path( 'ASSETS_DIR_NAME', $file ), __FILE__ ) );
}
}
/**
* Main Visual composer manager.
* @var Vc_Manager $vc_manager - instance of composer management.
* @since 4.2
*/
global $vc_manager;
if ( ! $vc_manager ) {
$vc_manager = Vc_Manager::getInstance();
// Load components
$vc_manager->loadComponents();
}