PluginProbe ʕ •ᴥ•ʔ
Music Player for WooCommerce / 1.7.9
Music Player for WooCommerce v1.7.9
1.8.3 1.8.2 1.8.1 1.1.10 1.1.11 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.10 1.3.11 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5.0 1.5.1 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 trunk 1.0.173 1.0.174 1.0.175 1.0.176 1.0.177 1.0.178 1.0.179 1.0.180 1.0.181 1.0.182 1.0.183 1.0.184 1.0.185 1.0.186 1.0.187 1.0.188 1.0.189 1.0.190 1.0.191 1.0.192 1.0.193 1.0.194 1.0.195 1.0.196 1.0.197 1.1.0 1.1.1
music-player-for-woocommerce / pagebuilders / builders.php
music-player-for-woocommerce / pagebuilders Last commit date
beaverbuilder 4 months ago divi 4 months ago divi5 4 months ago elementor 4 months ago gutenberg 4 months ago siteorigin 4 months ago visualcomposer 4 months ago builders.php 4 months ago
builders.php
213 lines
1 <?php
2 /**
3 * Main class to interace with the different Content Editors: WCMP_BUILDERS class
4 */
5 if ( ! class_exists( 'WCMP_BUILDERS' ) ) {
6 class WCMP_BUILDERS {
7
8 private static $_instance;
9
10 private function __construct(){}
11
12 private static function instance() {
13 if ( ! isset( self::$_instance ) ) {
14 self::$_instance = new self();
15 }
16 return self::$_instance;
17 } // End instance
18
19 public static function get_preview_url() {
20 $url = WCMP_WEBSITE_URL;
21 $url = wp_nonce_url( $url, 'wcmp_generate_preview', 'wcmp-preview-nonce' );
22 $url .= '&wcmp-preview=';
23
24 return $url;
25 } // End get_preview_url
26
27 public static function run() {
28 $instance = self::instance();
29 add_action( 'init', array( $instance, 'init' ) );
30 add_action( 'after_setup_theme', array( $instance, 'after_setup_theme' ) );
31 }
32
33 public function init() {
34 $instance = self::instance();
35
36 // Gutenberg
37 add_action( 'enqueue_block_editor_assets', array( $instance, 'gutenberg_editor' ) );
38 add_filter( 'pre_render_block', array( $instance, 'gutenberg_pre_render_block' ), 10, 2 );
39
40 // Elementor
41 add_action( 'elementor/widgets/register', array( $instance, 'elementor_editor' ) );
42 add_action( 'elementor/elements/categories_registered', array( $instance, 'elementor_editor_category' ) );
43
44 // Beaver builder
45 if ( class_exists( 'FLBuilder' ) ) {
46 include_once dirname( __FILE__ ) . '/beaverbuilder/wcmp.inc.php';
47 }
48
49 } // End init
50
51 public function after_setup_theme() {
52 $instance = $instance = self::instance();
53
54 // SiteOrigin
55 add_filter( 'siteorigin_widgets_widget_folders', array( $instance, 'siteorigin_widgets_collection' ) );
56 add_filter( 'siteorigin_panels_widget_dialog_tabs', array( $instance, 'siteorigin_panels_widget_dialog_tabs' ) );
57
58 // Visual Composer
59 add_action( 'vcv:api', array( $instance, 'visualcomposer_editor' ) );
60
61 // DIVI
62 if ( function_exists( 'et_get_theme_version' ) ) {
63 if ( version_compare( et_get_theme_version(), '5.0', '>=' ) ) { // DIVI 5
64 add_action( 'et_builder_ready', array($instance, 'divi_editor') );
65 add_action( 'divi_visual_builder_assets_before_enqueue_scripts',
66 function() {
67 if ( et_core_is_fb_enabled() && et_builder_d5_enabled() ) {
68
69 wp_register_script( 'wcmp-divi5-editor-config', '', array(), null, true );
70 wp_enqueue_script( 'wcmp-divi5-editor-config' );
71 $script = 'var wcmp_divi5_player_preview_url = "' . self::get_preview_url() . '";';
72 wp_add_inline_script( 'wcmp-divi5-editor-config', $script );
73
74 \ET\Builder\VisualBuilder\Assets\PackageBuildManager::register_package_build(
75 [
76 'name' => 'wcmp-divi-5-module-visual-builder',
77 'version' => '1.0.0',
78 'script' => [
79 'src' => plugins_url('/pagebuilders/divi5/divi.js', WCMP_PLUGIN_PATH),
80 'deps'=> [
81 'react',
82 'jquery',
83 'divi-module-library',
84 'wp-hooks',
85 'divi-rest',
86 ],
87 'enqueue_top_window' => false,
88 'enqueue_app_window' => true,
89 ],
90 ]
91 );
92 }
93 }
94 );
95
96 // Register module.
97 add_action(
98 'divi_module_library_modules_dependency_tree',
99 function( $dependency_tree ) {
100 // Load Divi 5 modules.
101 require_once dirname(WCMP_PLUGIN_PATH) . '/pagebuilders/divi5/index.php';
102 $dependency_tree->add_dependency( new WCMP_DIVI5() );
103 }
104 );
105
106 add_filter(
107 'divi.moduleLibrary.conversion.moduleConversionOutlineFile',
108 function( $conversion_outline_file, $module_name ) {
109 if ( 'wcmp/wcmp_divi' === $module_name ) {
110 return dirname(WCMP_PLUGIN_PATH) . '/pagebuilders/divi5/conversion-outline.json';
111 }
112 return $conversion_outline_file;
113 }, 10, 2
114 );
115 } else { // DIVI 4
116 add_action( 'et_builder_ready', array($instance, 'divi_editor') );
117 }
118 }
119 } // End after_setup_theme
120
121 /**************************** DIVI ****************************/
122
123 public function divi_editor() {
124 if ( class_exists( 'ET_Builder_Module' ) ) {
125 if ( isset( $_GET['et_fb'] ) ) {
126 wp_enqueue_script( 'wcmp-admin-gutenberg-editor', plugin_dir_url( __FILE__ ) . 'divi/divi.js', array( 'react' ), WCMP_VERSION, true );
127 }
128 require_once dirname( __FILE__ ) . '/divi/divi.pb.php';
129 }
130 } // End divi_editor
131
132 /**************************** GUTENBERG ****************************/
133
134 /**
135 * Loads the javascript resources to integrate the plugin with the Gutenberg editor
136 */
137 public function gutenberg_editor() {
138 wp_enqueue_style( 'wcmp-gutenberg-editor-css', plugin_dir_url( __FILE__ ) . 'gutenberg/gutenberg.css', array(), WCMP_VERSION );
139
140 $url = self::get_preview_url();
141
142 wp_enqueue_script( 'wcmp-admin-gutenberg-editor', plugin_dir_url( __FILE__ ) . 'gutenberg/gutenberg.js', array( 'wp-blocks', 'wp-element' ), WCMP_VERSION, true );
143
144 wp_localize_script(
145 'wcmp-admin-gutenberg-editor',
146 'wcmp_gutenberg_editor_config',
147 array(
148 'url' => $url,
149 'ids_attr_description' => __( 'This feature allows you to select the specific products whose players you want to include in the playlist. You can enter multiple product IDs, separated by commas, or use an asterisk "*" symbol to load all available products effortlessly (e.g. products_ids="*").', 'music-player-for-woocommerce'),
150 'categories_attr_description' => __( 'This feature enables you to load all products belonging to one or multiple categories at once, eliminating the need to enter their IDs individually. To filter by product categories, simply input their slugs, separated by commas (e.g. product_categories="category-1,category-2")', 'music-player-for-woocommerce'),
151 'tags_attr_description' => __( 'Just like filtering by product categories, you can also filter products by tags. To do this, simply enter the tag slugs, separated by commas (e.g. product_tags="tag-1,tag-2")', 'music-player-for-woocommerce'),
152 'more_details' => __( 'The remaining attributes of the playlist are detailed in the following link:', 'music-player-for-woocommerce'),
153 )
154 );
155 } // End gutenberg_editor
156
157 public function gutenberg_pre_render_block( $content, $block ) {
158 if (
159 ! empty( $block['blockName'] ) &&
160 stripos( $block['blockName'], 'woocommerce/' ) !== false &&
161 $GLOBALS['WooCommerceMusicPlayer']->get_on_title()
162 ) {
163 add_filter( 'woocommerce_product_title', array( $GLOBALS['WooCommerceMusicPlayer'], 'woocommerce_product_title' ), 10, 2 );
164 $GLOBALS['WooCommerceMusicPlayer']->enqueue_resources();
165 wp_enqueue_script( 'wcmp-wcblocks-js', plugin_dir_url( __FILE__ ) . 'gutenberg/wcblocks.js', array( 'jquery' ), WCMP_VERSION );
166 wp_enqueue_style( 'wcmp-wcblocks-css', plugin_dir_url( __FILE__ ) . 'gutenberg/wcblocks.css', array(), WCMP_VERSION );
167 }
168 return $content;
169 } // End gutenberg_pre_render_block
170
171 /**************************** ELEMENTOR ****************************/
172
173 public function elementor_editor_category() {
174 require_once dirname( __FILE__ ) . '/elementor/elementor_category.pb.php';
175 } // End elementor_editor
176
177 public function elementor_editor() {
178 require_once dirname( __FILE__ ) . '/elementor/elementor.pb.php';
179 } // End elementor_editor
180
181 /**************************** SITEORIGIN ****************************/
182
183 public function siteorigin_widgets_collection( $folders ) {
184 $folders[] = dirname( __FILE__ ) . '/siteorigin/';
185 return $folders;
186 } // End siteorigin_widgets_collection
187
188 public function siteorigin_panels_widget_dialog_tabs( $tabs ) {
189 $tabs[] = array(
190 'title' => __( 'Music Player for WooCommerce', 'music-player-for-woocommerce' ),
191 'filter' => array(
192 'groups' => array( 'music-player-for-woocommerce' ),
193 ),
194 );
195
196 return $tabs;
197 } // End siteorigin_panels_widget_dialog_tabs
198
199 /**************************** VISUAL COMPOSER ****************************/
200
201 public function visualcomposer_editor( $api ) {
202 $elementsToRegister = array( 'WCMPplaylist' );
203 $pluginBaseUrl = rtrim( plugins_url( 'visualcomposer/', __FILE__ ), '\\/' );
204 $elementsApi = $api->elements;
205 foreach ( $elementsToRegister as $tag ) {
206 $manifestPath = dirname( __FILE__ ) . '/visualcomposer/' . $tag . '/manifest.json';
207 $elementBaseUrl = $pluginBaseUrl . '/' . $tag;
208 $elementsApi->add( $manifestPath, $elementBaseUrl );
209 }
210 } // End visualcomposer_editor
211 } // End WCMP_BUILDERS
212 }
213