diff options
author | Zach van Rijn <me@zv.io> | 2021-07-21 14:54:07 -0500 |
---|---|---|
committer | Zach van Rijn <me@zv.io> | 2021-07-21 14:54:07 -0500 |
commit | 9d4123cee1867ee7199b06bdc92d40611f547ecc (patch) | |
tree | 6d864e2725242863afed1f8ba12d9c7a9bc63a69 /inc/compatibility/class-astra-visual-composer.php | |
download | blog-ng-9d4123cee1867ee7199b06bdc92d40611f547ecc.tar.gz blog-ng-9d4123cee1867ee7199b06bdc92d40611f547ecc.tar.bz2 blog-ng-9d4123cee1867ee7199b06bdc92d40611f547ecc.tar.xz blog-ng-9d4123cee1867ee7199b06bdc92d40611f547ecc.zip |
Initial unmodified import from Astra (Version: 3.6.5) @ /wp-content/themes/astra/.
Diffstat (limited to 'inc/compatibility/class-astra-visual-composer.php')
-rw-r--r-- | inc/compatibility/class-astra-visual-composer.php | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/inc/compatibility/class-astra-visual-composer.php b/inc/compatibility/class-astra-visual-composer.php new file mode 100644 index 0000000..8d863cb --- /dev/null +++ b/inc/compatibility/class-astra-visual-composer.php @@ -0,0 +1,141 @@ +<?php
+/**
+ * Visual Composer Compatibility File.
+ *
+ * @package Astra
+ */
+
+// If plugin - 'Visual Composer' not exist then return.
+if ( ! class_exists( 'Vc_Manager' ) ) {
+ return;
+}
+
+/**
+ * Astra Visual Composer Compatibility
+ */
+if ( ! class_exists( 'Astra_Visual_Composer' ) ) :
+
+ /**
+ * Astra Visual Composer Compatibility
+ *
+ * @since 1.0.0
+ */
+ class Astra_Visual_Composer {
+
+ /**
+ * Member Variable
+ *
+ * @var object instance
+ */
+ private static $instance;
+
+ /**
+ * Initiator
+ */
+ public static function get_instance() {
+ if ( ! isset( self::$instance ) ) {
+ self::$instance = new self();
+ }
+ return self::$instance;
+ }
+
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ add_action( 'wp', array( $this, 'vc_default_setting' ), 20 );
+ add_action( 'do_meta_boxes', array( $this, 'vc_default_setting' ), 20 );
+ add_action( 'vc_frontend_editor_render', array( $this, 'vc_frontend_default_setting' ) );
+ add_filter( 'astra_theme_assets', array( $this, 'add_styles' ) );
+ }
+
+ /**
+ * VC Updated meta settings
+ *
+ * @since 1.0.13
+ * @param int $id Post id.
+ * @return void
+ */
+ public function vc_update_meta_setting( $id ) {
+
+ if ( false === astra_enable_page_builder_compatibility() || 'post' == get_post_type() ) {
+ return;
+ }
+
+ update_post_meta( $id, '_astra_content_layout_flag', 'disabled' );
+ update_post_meta( $id, 'site-post-title', 'disabled' );
+ update_post_meta( $id, 'ast-title-bar-display', 'disabled' );
+ update_post_meta( $id, 'ast-featured-img', 'disabled' );
+
+ $content_layout = get_post_meta( $id, 'site-content-layout', true );
+ if ( empty( $content_layout ) || 'default' == $content_layout ) {
+ update_post_meta( $id, 'site-content-layout', 'plain-container' );
+ }
+
+ $sidebar_layout = get_post_meta( $id, 'site-sidebar-layout', true );
+ if ( empty( $sidebar_layout ) || 'default' == $sidebar_layout ) {
+ update_post_meta( $id, 'site-sidebar-layout', 'no-sidebar' );
+ }
+ }
+
+ /**
+ * Set frontend default setting.
+ *
+ * @since 1.0.13
+ * @return void
+ */
+ public function vc_frontend_default_setting() {
+
+ global $post;
+ $id = astra_get_post_id();
+ $page_builder_flag = get_post_meta( $id, '_astra_content_layout_flag', true );
+
+ if ( empty( $page_builder_flag ) ) {
+ if ( $id > 0 && empty( $post->post_content ) ) {
+ $this->vc_update_meta_setting( $id );
+ }
+ }
+ }
+
+ /**
+ * Set default setting.
+ *
+ * @since 1.0.13
+ * @return void
+ */
+ public function vc_default_setting() {
+
+ global $post;
+ $id = astra_get_post_id();
+
+ $page_builder_flag = get_post_meta( $id, '_astra_content_layout_flag', true );
+
+ if ( isset( $post ) && empty( $page_builder_flag ) && ( is_admin() || is_singular() ) ) {
+ $vc_active = get_post_meta( $id, '_wpb_vc_js_status', true );
+ if ( 'true' == $vc_active || has_shortcode( $post->post_content, 'vc_row' ) ) {
+ $this->vc_update_meta_setting( $id );
+ }
+ }
+ }
+
+ /**
+ * Add assets in theme
+ *
+ * @param array $assets list of theme assets (JS & CSS).
+ * @return array List of updated assets.
+ * @since 3.5.0
+ */
+ public function add_styles( $assets ) {
+ if ( ! empty( $assets['css'] ) ) {
+ $assets['css'] = array( 'astra-vc-builder' => 'compatibility/page-builder/vc-plugin' ) + $assets['css'];
+ }
+ return $assets;
+ }
+ }
+
+endif;
+
+/**
+ * Kicking this off by calling 'get_instance()' method
+ */
+Astra_Visual_Composer::get_instance();
|