PluginProbe
Bold Timeline Lite / trunk
Bold Timeline Lite vtrunk
trunk 1.1.7 1.2.4 1.2.6 1.2.7 1.2.8 1.3.0
bold-timeline-lite / bold-timeline-lite.php

bold-timeline-lite.php in Bold Timeline Lite trunk, at bold-timeline-lite.php

324 lines 13.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plugin Name: Bold Timeline Lite
5 * Description: Bold Timeline Lite by BoldThemes.
6 * Version: 1.3.0
7 * Author: BoldThemes
8 * Author URI: https://bold-themes.com/
9 * License: GPL v2 or later
10 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
11 * Text Domain: bold-timeline-lite
12 */
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 if( !in_array( 'bold-timeline/bold-timeline.php', apply_filters('active_plugins', get_option('active_plugins')))){
19
20 if ( ! class_exists( 'Bold_Timeline' ) ) {
21
22 require_once( 'bold-builder-light/bold-builder-light.php' );
23 require_once( 'bold-timeline-lite-notice.php' );
24
25 if (class_exists('BoldTimelineLiteNotice')) {
26 add_action( 'wp_ajax_bold_timeline_lite_dismiss_notice_callto_action_snooze', array( 'BoldTimelineLiteNotice' , 'bold_timeline_lite_dismiss_notice_callto_action_snooze_callback' ) );
27 }
28
29 // Helpers
30
31 require_once( 'assets-general/php/bold_timeline_helpers.php' );
32
33 // Page builder elements
34
35 add_action( 'init', function() {
36 define( 'BOLD_TIMELINE_ELEMENT_NAME', esc_html__( 'BoldThemes Bold Timeline', 'bold-timeline' ) );
37 define( 'BOLD_TIMELINE_ELEMENT_DESCRIPTION', esc_html__( 'Shortcode outputs BoldThemes Bold Timeline.', 'bold-timeline' ) );
38 define( 'BOLD_TIMELINE_ELEMENT_CLASS', 'bold-timeline' );
39
40 define( 'BOLD_TIMELINE_FIELD_TITLE', esc_html__( 'Bold Timelines', 'bold-timeline' ) );
41 define( 'BOLD_TIMELINE_FIELD_DESCRIPTION', esc_html__( 'This is bold timeline to show in the shortcode', 'bold-timeline' ) );
42
43 define( 'BOLD_TIMELINE_ELEMENTOR_CATEGORY', esc_html__( 'BoldThemes Widgets', 'bold-timeline' ) );
44 } );
45 require_once( 'assets-general/php/page-builder-elements/elementor.php' );
46 require_once( 'assets-general/php/page-builder-elements/bt_bb_bold_timeline.php' );
47
48 // CSS crush
49 if ( ! file_exists( get_parent_theme_file_path( 'css-crush/CssCrush.php' ) ) ) {
50 if ( file_exists( plugin_dir_path( __FILE__ ) . 'css-crush/CssCrush.php' ) ) {
51 require_once( 'css-crush/CssCrush.php' );
52 } else {
53 if ( ! class_exists( 'CssCrush\Functions' ) ) {
54 require_once( 'BTCrushFunctions.php' );
55 require_once( 'BTCrushUtil.php' );
56 require_once( 'BTCrushColor.php' );
57 require_once( 'BTCrushRegex.php' );
58 }
59 }
60 }
61
62 /**
63 * Main class.
64 *
65 * @since 1.0.0
66 */
67
68 class Bold_Timeline {
69 static $builder;
70 static $fonts_added = array();
71 static $font_subsets_added = array();
72 static $crush_vars_def = array();
73 static $crush_vars = array();
74 static $separator = " ";
75 static $timeline_style = '';
76 }
77
78 // BB Light
79 add_action( 'init', function() {
80 Bold_Timeline::$builder = new BTBB_Light(
81 array(
82 'slug' => 'bold-timeline',
83 'single_name' => esc_html__( 'Bold Timeline', 'bold-timeline' ),
84 'plural_name' => esc_html__( 'Bold Timelines', 'bold-timeline' ),
85 'icon' => 'dashicons-clock',
86 'home_url' => '//bold-themes.com',
87 'doc_url' => '//documentation.bold-themes.com/bold-timeline-lite',
88 'support_url' => '',
89 'changelog_url' => '',
90 'shortcode' => 'bold_timeline',
91 'product_id' => '',
92 'plugin_file_path' => __FILE__
93 )
94 );
95 } );
96 /**
97 * Enqueue scripts and styles.
98 *
99 * @since 1.0.0
100 */
101 function bold_timeline_enqueue() {
102
103 Bold_Timeline::$crush_vars_def = array(
104 'defaultLineColor',
105 'defaultItemBackgroundColor',
106 'defaultGroupColor',
107 'defaultFrameColor',
108 'defaultButtonColor',
109 'defaultIconColor',
110 'defaultConnectionColor',
111 'defaultStickerColor',
112 'defaultSliderNavigationColor',
113 'defaultMarkerColor'
114 );
115
116 wp_enqueue_script( 'bold-timeline', plugins_url( 'assets/js/bold-timeline.js', __FILE__ ), array( 'jquery' ) );
117 wp_enqueue_style( 'bold-timeline', plugins_url( 'style.css', __FILE__ ) );
118
119 if ( function_exists( 'boldthemes_plugin_csscrush_file' ) ) {
120 boldthemes_plugin_csscrush_file( plugin_dir_path( __FILE__ ) . 'style.crush.css', array( 'source_map' => true, 'minify' => false, 'output_file' => 'style', 'formatter' => 'block', 'boilerplate' => false, 'plugins' => array( 'loop', 'ease' ) ), plugin_dir_path( __FILE__ ) . 'css-override.php', 'Bold_Timeline' );
121
122 boldthemes_plugin_csscrush_file( plugin_dir_path( __FILE__ ) . 'assets/scss/container.crush.scss', array( 'source_map' => true, 'minify' => false, 'output_dir' => '__no_dir_do_not_change', 'output_file' => '', 'formatter' => 'block', 'boilerplate' => false, 'plugins' => array( 'loop', 'ease' ) ), plugin_dir_path( __FILE__ ) . 'css-override-container.php', 'Bold_Timeline' );
123
124 boldthemes_plugin_csscrush_file( plugin_dir_path( __FILE__ ) . 'assets/scss/group.crush.scss', array( 'source_map' => true, 'minify' => false, 'output_dir' => '__no_dir_do_not_change', 'output_file' => '', 'formatter' => 'block', 'boilerplate' => false, 'plugins' => array( 'loop', 'ease' ) ), plugin_dir_path( __FILE__ ) . 'css-override-group.php', 'Bold_Timeline' );
125
126 boldthemes_plugin_csscrush_file( plugin_dir_path( __FILE__ ) . 'assets/scss/item.crush.scss', array( 'source_map' => true, 'minify' => false, 'output_dir' => '__no_dir_do_not_change', 'output_file' => '', 'formatter' => 'block', 'boilerplate' => false, 'plugins' => array( 'loop', 'ease' ) ), plugin_dir_path( __FILE__ ) . 'css-override-item.php', 'Bold_Timeline' );
127
128 boldthemes_plugin_csscrush_file( plugin_dir_path( __FILE__ ) . 'assets/scss/button.crush.scss', array( 'source_map' => true, 'minify' => false, 'output_dir' => '__no_dir_do_not_change', 'output_file' => '', 'formatter' => 'block', 'boilerplate' => false, 'plugins' => array( 'loop', 'ease' ) ), plugin_dir_path( __FILE__ ) . 'css-override-button.php', 'Bold_Timeline' );
129
130 boldthemes_plugin_csscrush_file( plugin_dir_path( __FILE__ ) . 'assets/scss/slider.crush.scss', array( 'source_map' => true, 'minify' => false, 'output_dir' => '__no_dir_do_not_change', 'output_file' => '', 'formatter' => 'block', 'boilerplate' => false, 'plugins' => array( 'loop', 'ease' ) ), plugin_dir_path( __FILE__ ) . 'css-override-slider.php', 'Bold_Timeline' );
131 }
132
133 }
134 add_action( 'wp_enqueue_scripts', 'bold_timeline_enqueue' );
135
136 // Update CSS within in Admin
137
138 function bold_timeline_admin_style() {
139 wp_enqueue_style( 'bold_timeline_admin_style', plugin_dir_url( __FILE__ ) . 'style-admin.css' );
140 wp_enqueue_style( 'bt-bb-light-override', plugins_url( 'bt_bbl_override.css', __FILE__ ) );
141 }
142
143 if ( isset( $_GET['page'] ) && 'bold-timeline-edit' === sanitize_text_field( wp_unslash( $_GET['page'] ) ) ) {
144 add_action( 'admin_enqueue_scripts', 'bold_timeline_admin_style' );
145 }
146
147 /**
148 * Load plugin textdomain.
149 *
150 * @since 1.0.0
151 */
152 function bold_timeline_load_textdomain() {
153 load_plugin_textdomain( 'bold-timeline', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
154 }
155 add_action( 'init', 'bold_timeline_load_textdomain' );
156
157 $glob_match = glob( plugin_dir_path( __FILE__ ) . 'content_elements/*/*.php' );
158 $elements = array();
159 if ( $glob_match ) {
160 foreach( $glob_match as $file ) {
161 if ( preg_match( '/(\w+)\/\1.php$/', $file, $match ) ) {
162 $elements[ $match[1] ] = $file;
163 }
164 }
165 }
166 add_action( 'init', function() use ( $elements ) {
167 foreach( $elements as $key => $value ) {
168 require( $value );
169 }
170 } );
171 /**
172 * Map shortcodes.
173 *
174 * @since 1.0.0
175 */
176
177 if ( ! function_exists( 'bold_timeline_enqueue_google_font' ) ) {
178 function bold_timeline_enqueue_google_font( $font, $subset ) {
179
180 if ( ! in_array( $font, Bold_Timeline::$fonts_added ) ) {
181
182 Bold_Timeline::$fonts_added[] = $font;
183
184 $subset = preg_replace( '/\s+/', '', $subset );
185 $subset_arr = explode( ',', $subset );
186
187 Bold_Timeline::$font_subsets_added = Bold_Timeline::$font_subsets_added + $subset_arr;
188
189 add_action( 'wp_footer', 'bold_timeline_enqueue_google_fonts' );
190
191 }
192 }
193 }
194
195 if ( ! function_exists( 'bold_timeline_enqueue_google_fonts' ) ) {
196 function bold_timeline_enqueue_google_fonts() {
197
198 if ( count( Bold_Timeline::$fonts_added ) > 0 ) {
199
200 $font_families = array();
201
202 foreach( Bold_Timeline::$fonts_added as $item ) {
203 $font_families[] = urldecode( $item ) . ':100,200,300,400,500,600,700,800,900,100italic,200italic,300italic,400italic,500italic,600italic,700italic,800italic,900italic';
204 }
205
206 $query_args = array(
207 'family' => urlencode( implode( '|', $font_families ) ),
208 'subset' => urlencode( implode( ',', Bold_Timeline::$font_subsets_added ) ),
209 );
210
211 $font_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
212 wp_enqueue_style( 'bold-timeline-footer' );
213 wp_enqueue_style( 'bold-timeline-google-fonts', $font_url, array(), '1.0.0' );
214
215 }
216 }
217 }
218
219 if ( ! function_exists( 'bold_timeline_js_head' ) ) {
220 function bold_timeline_js_head() { ?>
221 <script>
222 // Select the node that will be observed for mutations
223 const targetNode = document.documentElement;
224
225 // Options for the observer (which mutations to observe)
226 const config = { attributes: false, childList: true, subtree: false };
227
228 var bold_timeline_item_button_done = false;
229 var css_override_item_done = false;
230 var css_override_group_done = false;
231 var css_override_container_done = false;
232
233 // Callback function to execute when mutations are observed
234 const callback = function( mutationsList, observer ) {
235 var i;
236 for ( i = 0; i < mutationsList.length; i++ ) {
237 if ( mutationsList[ i ].type === 'childList' ) {
238 if ( typeof jQuery !== 'undefined' && jQuery( '.bold_timeline_item_button' ).length > 0 && ! bold_timeline_item_button_done ) {
239 bold_timeline_item_button_done = true;
240 jQuery( '.bold_timeline_item_button' ).each( function() {
241 var css_override = jQuery( this ).data( 'css-override' );
242 if ( css_override != '' ) {
243 var id = jQuery( this ).attr( 'id' );
244 css_override = css_override.replace( /(\.bold_timeline_item_button)([\.\{\s])/g, '.bold_timeline_item_button#' + id + '$2' );
245 var head = document.getElementsByTagName( 'head' )[0];
246 var style = document.createElement( 'style' );
247 style.appendChild( document.createTextNode( css_override ) );
248 head.appendChild( style );
249 }
250 });
251 }
252 if ( typeof jQuery !== 'undefined' && jQuery( '.bold_timeline_item' ).length > 0 && ! css_override_item_done ) {
253 css_override_item_done = true;
254 jQuery( '.bold_timeline_item' ).each( function() {
255 var css_override = jQuery( this ).data( 'css-override' );
256 if ( css_override != '' ) {
257 var id = jQuery( this ).attr( 'id' );
258 css_override = css_override.replace( /(\.bold_timeline_item)([\.\{\s])/g, '.bold_timeline_item#' + id + '$2' );
259 var head = document.getElementsByTagName( 'head' )[0];
260 var style = document.createElement( 'style' );
261 style.appendChild( document.createTextNode( css_override ) );
262 head.appendChild( style );
263 }
264 });
265 }
266 if ( typeof jQuery !== 'undefined' && jQuery( '.bold_timeline_group' ).length > 0 && ! css_override_group_done ) {
267 css_override_group_done = true;
268 jQuery( '.bold_timeline_group' ).each( function() {
269 var css_override = jQuery( this ).data( 'css-override' );
270 if ( css_override != '' ) {
271 var id = jQuery( this ).attr( 'id' );
272 css_override = css_override.replace( /(\.bold_timeline_group)([\.\{\s])/g, '.bold_timeline_group#' + id + '$2' );
273 var head = document.getElementsByTagName( 'head' )[0];
274 var style = document.createElement( 'style' );
275 style.appendChild( document.createTextNode( css_override ) );
276 head.appendChild( style );
277 }
278 });
279 }
280 if ( typeof jQuery !== 'undefined' && jQuery( '.bold_timeline_container' ).length > 0 && ! css_override_container_done ) {
281 css_override_container_done = true;
282 jQuery( '.bold_timeline_container' ).each( function() {
283 var css_override = jQuery( this ).data( 'css-override' );
284 if ( css_override != '' ) {
285 var id = jQuery( this ).attr( 'id' );
286 css_override = css_override.replace( /(\.bold_timeline_container)([\.\{\s])/g, '#' + id + '$2' );
287 var head = document.getElementsByTagName( 'head' )[0];
288 var style = document.createElement( 'style' );
289 style.appendChild( document.createTextNode( css_override ) );
290 head.appendChild( style );
291 }
292 });
293 }
294 }
295 }
296 };
297
298 // Create an observer instance linked to the callback function
299 const observer = new MutationObserver(callback);
300
301 // Start observing the target node for configured mutations
302 observer.observe(targetNode, config);
303
304 // Later, you can stop observing
305 document.addEventListener( 'DOMContentLoaded', function() { observer.disconnect(); }, false );
306
307 </script>
308 <?php }
309 }
310 add_action( 'wp_head', 'bold_timeline_js_head' );
311 }
312
313 // Admin
314 if ( !function_exists( 'bold_timeline_admin_enqueue' ) ) {
315 function bold_timeline_admin_enqueue() {
316 wp_enqueue_style( 'bold-timeline-admin-style', plugins_url( 'assets-general/css//bold-timeline-style.css', __FILE__ ) );
317 //wp_enqueue_script( 'bold-timeline-admin-js', plugins_url( 'assets-general/js/bold-timeline-admin.js', __FILE__ ) );
318 }
319 }
320
321 if ( isset( $_GET['page'] ) && 'bold-timeline-edit' === sanitize_text_field( wp_unslash( $_GET['page'] ) ) ) {
322 add_action( 'admin_enqueue_scripts', 'bold_timeline_admin_enqueue', 100 );
323 }
324 }