Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/themify-.../classes
File: class-themify-builder.php
<?php
[0] Fix | Delete
defined('ABSPATH') || exit;
[1] Fix | Delete
[2] Fix | Delete
if (!class_exists('Themify_Builder',false)) :
[3] Fix | Delete
[4] Fix | Delete
/**
[5] Fix | Delete
* Main Themify Builder class
[6] Fix | Delete
*
[7] Fix | Delete
* @package default
[8] Fix | Delete
*/
[9] Fix | Delete
class Themify_Builder {
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* @var array
[13] Fix | Delete
*/
[14] Fix | Delete
public static $registered_post_types = array('post', 'page');
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* Define builder grid active or not
[18] Fix | Delete
* @var bool
[19] Fix | Delete
*/
[20] Fix | Delete
public static $frontedit_active = false;
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* Define builder grid active id
[24] Fix | Delete
* @var int
[25] Fix | Delete
*/
[26] Fix | Delete
public static $builder_active_id = null;
[27] Fix | Delete
[28] Fix | Delete
/**
[29] Fix | Delete
* Get status of builder content whether inside builder content or not
[30] Fix | Delete
*/
[31] Fix | Delete
public static $is_loop = false;
[32] Fix | Delete
[33] Fix | Delete
/**
[34] Fix | Delete
* A list of posts which have been rendered by Builder
[35] Fix | Delete
*/
[36] Fix | Delete
private static $post_ids = array();
[37] Fix | Delete
public static $builder_is_saving = false;
[38] Fix | Delete
private static $tooltips = [];
[39] Fix | Delete
[40] Fix | Delete
/* flag to indicate when Builder is rendering the output */
[41] Fix | Delete
private static $is_rendering = false;
[42] Fix | Delete
[43] Fix | Delete
public $in_the_loop = false;//deprecated use $is_loop
[44] Fix | Delete
[45] Fix | Delete
/**
[46] Fix | Delete
* Themify Builder Constructor
[47] Fix | Delete
*/
[48] Fix | Delete
public function __construct() {
[49] Fix | Delete
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
/**
[53] Fix | Delete
* Class Init
[54] Fix | Delete
*/
[55] Fix | Delete
public static function init():void {
[56] Fix | Delete
add_action('init', array(__CLASS__, 'register_deprecated_cpt'));
[57] Fix | Delete
// Include required files
[58] Fix | Delete
self::includes_always();
[59] Fix | Delete
Themify_Builder_Layouts::init();
[60] Fix | Delete
Themify_Global_Styles::init();
[61] Fix | Delete
[62] Fix | Delete
// Plugin compatibility
[63] Fix | Delete
self::plugins_compatibility();
[64] Fix | Delete
[65] Fix | Delete
if (is_admin() || themify_is_rest()) {
[66] Fix | Delete
add_action('wp_loaded', array(__CLASS__, 'wp_loaded'));
[67] Fix | Delete
} else {
[68] Fix | Delete
add_action('wp', array(__CLASS__, 'wp_loaded'), 100);
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
// Login module action for failed login
[72] Fix | Delete
add_action('wp_login_failed', array(__CLASS__, 'wp_login_failed'));
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
public static function register_deprecated_cpt():void {
[76] Fix | Delete
Themify_Builder_Model::builder_cpt_check();
[77] Fix | Delete
$post_types = array(
[78] Fix | Delete
'portfolio' => array(
[79] Fix | Delete
'plural' => __('Portfolios', 'themify'),
[80] Fix | Delete
'singular' => __('Portfolio', 'themify'),
[81] Fix | Delete
'rewrite' => apply_filters('themify_portfolio_rewrite', 'project'),
[82] Fix | Delete
'menu_icon' => 'dashicons-portfolio'
[83] Fix | Delete
),
[84] Fix | Delete
'highlight' => array(
[85] Fix | Delete
'plural' => __('Highlights', 'themify'),
[86] Fix | Delete
'singular' => __('Highlight', 'themify'),
[87] Fix | Delete
'menu_icon' => 'dashicons-welcome-write-blog'
[88] Fix | Delete
),
[89] Fix | Delete
'slider' => array(
[90] Fix | Delete
'plural' => __('Slides', 'themify'),
[91] Fix | Delete
'singular' => __('Slide', 'themify'),
[92] Fix | Delete
'supports' => array('title', 'editor', 'author', 'thumbnail', 'custom-fields'),
[93] Fix | Delete
'menu_icon' => 'dashicons-slides'
[94] Fix | Delete
),
[95] Fix | Delete
'testimonial' => array(
[96] Fix | Delete
'plural' => __('Testimonials', 'themify'),
[97] Fix | Delete
'singular' => __('Testimonial', 'themify'),
[98] Fix | Delete
'menu_icon' => 'dashicons-testimonial'
[99] Fix | Delete
)
[100] Fix | Delete
);
[101] Fix | Delete
[102] Fix | Delete
foreach ($post_types as $key => $args) {
[103] Fix | Delete
if (Themify_Builder_Model::is_cpt_active($key) && Themify_Builder_Model::is_module_active($key)) {
[104] Fix | Delete
[105] Fix | Delete
if (!post_type_exists($key)) {
[106] Fix | Delete
$options = array(
[107] Fix | Delete
'labels' => array(
[108] Fix | Delete
'name' => $args['plural'],
[109] Fix | Delete
'singular_name' => $args['singular'],
[110] Fix | Delete
'add_new' => __('Add New', 'themify'),
[111] Fix | Delete
'add_new_item' => sprintf(__('Add New %s', 'themify'), $args['singular']),
[112] Fix | Delete
'edit_item' => sprintf(__('Edit %s', 'themify'), $args['singular']),
[113] Fix | Delete
'new_item' => sprintf(__('New %s', 'themify'), $args['singular']),
[114] Fix | Delete
'view_item' => sprintf(__('View %s', 'themify'), $args['singular']),
[115] Fix | Delete
'search_items' => sprintf(__('Search %s', 'themify'), $args['plural']),
[116] Fix | Delete
'not_found' => sprintf(__('No %s found', 'themify'), $args['plural']),
[117] Fix | Delete
'not_found_in_trash' => sprintf(__('No %s found in Trash', 'themify'), $args['plural']),
[118] Fix | Delete
'menu_name' => $args['plural']
[119] Fix | Delete
),
[120] Fix | Delete
'supports' => isset($args['supports']) ? $args['supports'] : array('title', 'editor', 'thumbnail', 'custom-fields', 'excerpt'),
[121] Fix | Delete
'hierarchical' => false,
[122] Fix | Delete
'public' => true,
[123] Fix | Delete
'show_ui' => true,
[124] Fix | Delete
'show_in_menu' => true,
[125] Fix | Delete
'show_in_nav_menus' => false,
[126] Fix | Delete
'publicly_queryable' => true,
[127] Fix | Delete
'rewrite' => array('slug' => isset($args['rewrite']) ? $args['rewrite'] : strtolower($args['singular'])),
[128] Fix | Delete
'query_var' => true,
[129] Fix | Delete
'can_export' => true,
[130] Fix | Delete
'capability_type' => 'post',
[131] Fix | Delete
'menu_icon' => isset($args['menu_icon']) ? $args['menu_icon'] : ''
[132] Fix | Delete
);
[133] Fix | Delete
[134] Fix | Delete
register_post_type($key, $options);
[135] Fix | Delete
self::$registered_post_types[]=$key;
[136] Fix | Delete
}
[137] Fix | Delete
if (!taxonomy_exists($key . '-category')) {
[138] Fix | Delete
$options = array(
[139] Fix | Delete
'labels' => array(
[140] Fix | Delete
'name' => sprintf(__('%s Categories', 'themify'), $args['singular']),
[141] Fix | Delete
'singular_name' => sprintf(__('%s Category', 'themify'), $args['singular']),
[142] Fix | Delete
'search_items' => sprintf(__('Search %s Categories', 'themify'), $args['singular']),
[143] Fix | Delete
'popular_items' => sprintf(__('Popular %s Categories', 'themify'), $args['singular']),
[144] Fix | Delete
'all_items' => sprintf(__('All Categories', 'themify'), $args['singular']),
[145] Fix | Delete
'parent_item' => sprintf(__('Parent %s Category', 'themify'), $args['singular']),
[146] Fix | Delete
'parent_item_colon' => sprintf(__('Parent %s Category:', 'themify'), $args['singular']),
[147] Fix | Delete
'edit_item' => sprintf(__('Edit %s Category', 'themify'), $args['singular']),
[148] Fix | Delete
'update_item' => sprintf(__('Update %s Category', 'themify'), $args['singular']),
[149] Fix | Delete
'add_new_item' => sprintf(__('Add New %s Category', 'themify'), $args['singular']),
[150] Fix | Delete
'new_item_name' => sprintf(__('New %s Category', 'themify'), $args['singular']),
[151] Fix | Delete
'separate_items_with_commas' => sprintf(__('Separate %s Category with commas', 'themify'), $args['singular']),
[152] Fix | Delete
'add_or_remove_items' => sprintf(__('Add or remove %s Category', 'themify'), $args['singular']),
[153] Fix | Delete
'choose_from_most_used' => sprintf(__('Choose from the most used %s Category', 'themify'), $args['singular']),
[154] Fix | Delete
'menu_name' => sprintf(__('%s Category', 'themify'), $args['singular']),
[155] Fix | Delete
),
[156] Fix | Delete
'public' => true,
[157] Fix | Delete
'show_in_nav_menus' => false,
[158] Fix | Delete
'show_ui' => true,
[159] Fix | Delete
'show_admin_column' => true,
[160] Fix | Delete
'show_tagcloud' => true,
[161] Fix | Delete
'hierarchical' => true,
[162] Fix | Delete
'rewrite' => true,
[163] Fix | Delete
'query_var' => true
[164] Fix | Delete
);
[165] Fix | Delete
[166] Fix | Delete
register_taxonomy($key . '-category', $key, $options);
[167] Fix | Delete
}
[168] Fix | Delete
}
[169] Fix | Delete
}
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
public static function wp_loaded() {
[173] Fix | Delete
add_filter('themify_builder_module_content', array('Themify_Builder_Model', 'format_text'));
[174] Fix | Delete
if (Themify_Builder_Model::is_front_builder_activate() === false) {
[175] Fix | Delete
$func = function_exists('wp_filter_content_tags') ? 'wp_filter_content_tags' : 'wp_make_content_images_responsive';
[176] Fix | Delete
add_filter('themify_builder_module_content', $func);
[177] Fix | Delete
add_filter('themify_image_make_responsive_image', $func);
[178] Fix | Delete
add_action('themify_builder_background_styling', array(__CLASS__, 'display_tooltip'), 10, 3);
[179] Fix | Delete
add_action( 'template_include', [ __CLASS__, 'template_include' ], 1000 );
[180] Fix | Delete
}
[181] Fix | Delete
elseif (isset($_GET['tb-id']) || isset($_COOKIE['tb_active'])) {
[182] Fix | Delete
self::$builder_active_id = isset($_GET['tb-id']) ? (int) $_GET['tb-id'] : (int) $_COOKIE['tb_active'];
[183] Fix | Delete
themify_disable_other_lazy();
[184] Fix | Delete
}
[185] Fix | Delete
// Actions
[186] Fix | Delete
self::setup();
[187] Fix | Delete
if (did_action('wp') > 0) {
[188] Fix | Delete
self::wp_hook();
[189] Fix | Delete
} else {
[190] Fix | Delete
add_action('wp', array(__CLASS__, 'wp_hook'));
[191] Fix | Delete
}
[192] Fix | Delete
$is_ajax=themify_is_ajax();
[193] Fix | Delete
$is_admin=is_admin();
[194] Fix | Delete
$has_access=($is_admin===true && $is_ajax===false) || ($is_ajax===true && isset($_POST['admin']))?Themify_Access_Role::check_access_backend():Themify_Builder_Model::is_frontend_editor_page();
[195] Fix | Delete
if ($has_access===true) {
[196] Fix | Delete
self::includes_active();
[197] Fix | Delete
if($is_admin===true){
[198] Fix | Delete
self::includes_admin();
[199] Fix | Delete
}
[200] Fix | Delete
}
[201] Fix | Delete
[202] Fix | Delete
// Script Loader
[203] Fix | Delete
add_action('wp_enqueue_scripts', array(__CLASS__, 'register_js_css'), 9);
[204] Fix | Delete
[205] Fix | Delete
// Hook to frontend
[206] Fix | Delete
add_action('wp_head', array(__CLASS__, 'inline_css'), -1001);
[207] Fix | Delete
add_filter('the_content', array(__CLASS__, 'clear_static_content'), 1);
[208] Fix | Delete
add_filter('the_content', array(__CLASS__, 'builder_show_on_front'), 11);
[209] Fix | Delete
add_filter('body_class', array(__CLASS__, 'body_class'), 10);
[210] Fix | Delete
// Add extra protocols like skype: to WordPress allowed protocols.
[211] Fix | Delete
if (!has_filter('kses_allowed_protocols', 'themify_allow_extra_protocols') && function_exists('themify_allow_extra_protocols')) {
[212] Fix | Delete
add_filter('kses_allowed_protocols', 'themify_allow_extra_protocols');
[213] Fix | Delete
}
[214] Fix | Delete
[215] Fix | Delete
Themify_Builder_Stylesheet::init();
[216] Fix | Delete
// Visibility controls
[217] Fix | Delete
Themify_Builder_Visibility_Controls::init();
[218] Fix | Delete
[219] Fix | Delete
//convert old data to new grid data,can be removed after updates
[220] Fix | Delete
[221] Fix | Delete
add_action('wp_ajax_nopriv_tb_update_old_data', array(__CLASS__, 'convert_data'), 10);
[222] Fix | Delete
add_action('wp_ajax_tb_update_old_data', array(__CLASS__, 'convert_data'), 10);
[223] Fix | Delete
}
[224] Fix | Delete
[225] Fix | Delete
public static function template_include( $template ) {
[226] Fix | Delete
if ( is_singular() && isset( $_GET['post_in_lightbox'] ) ) {
[227] Fix | Delete
show_admin_bar(false);
[228] Fix | Delete
wp_enqueue_style( 'tb_post_lightbox', THEMIFY_BUILDER_CSS_MODULES . 'post-lightbox.css', null, THEMIFY_VERSION);
[229] Fix | Delete
add_filter( 'body_class', [ __CLASS__, 'post_in_lightbox_body_class' ] );
[230] Fix | Delete
if ( current_theme_supports( 'themify-builder-lightbox-template' ) ) {
[231] Fix | Delete
global $themify;
[232] Fix | Delete
$themify->header_enabled = false;
[233] Fix | Delete
$themify->footer_enabled = false;
[234] Fix | Delete
$themify->layout = 'sidebar-none';
[235] Fix | Delete
} else {
[236] Fix | Delete
$template = Themify_Builder_Component_Module::locate_template( 'post_in_lightbox.php' );
[237] Fix | Delete
}
[238] Fix | Delete
}
[239] Fix | Delete
[240] Fix | Delete
return $template;
[241] Fix | Delete
}
[242] Fix | Delete
[243] Fix | Delete
public static function post_in_lightbox_body_class( $classes ) {
[244] Fix | Delete
$classes[] = 'tb_post_lightbox';
[245] Fix | Delete
return $classes;
[246] Fix | Delete
}
[247] Fix | Delete
[248] Fix | Delete
/**
[249] Fix | Delete
* Return all modules for a post as a two-dimensional array
[250] Fix | Delete
* @since 7.5
[251] Fix | Delete
* @return bool|array
[252] Fix | Delete
*/
[253] Fix | Delete
public static function get_builder_modules_list(?int $post_id = null,?array $builder_data = null,bool $only_check = false) {
[254] Fix | Delete
if ($builder_data === null) {
[255] Fix | Delete
$builder_data = ThemifyBuilder_Data_Manager::get_data($post_id);
[256] Fix | Delete
}
[257] Fix | Delete
if ($only_check !== false) {
[258] Fix | Delete
return strpos(json_encode($builder_data), 'mod_settings') !== false;
[259] Fix | Delete
}
[260] Fix | Delete
$_modules = array();
[261] Fix | Delete
// loop through modules in Builder
[262] Fix | Delete
if (is_array($builder_data)) {
[263] Fix | Delete
foreach ($builder_data as $row) {
[264] Fix | Delete
$_modules = array_merge( $_modules, self::_get_modules_recursive( $row ) );
[265] Fix | Delete
}
[266] Fix | Delete
}
[267] Fix | Delete
[268] Fix | Delete
return $_modules;
[269] Fix | Delete
}
[270] Fix | Delete
[271] Fix | Delete
/**
[272] Fix | Delete
* Find modules within the $row, recursively search for submodules
[273] Fix | Delete
*
[274] Fix | Delete
* @return array
[275] Fix | Delete
*/
[276] Fix | Delete
private static function _get_modules_recursive( $row ) : array {
[277] Fix | Delete
$modules = [];
[278] Fix | Delete
if ( ! empty( $row['cols'] ) ) {
[279] Fix | Delete
foreach ( $row['cols'] as $col ) {
[280] Fix | Delete
if ( ! empty( $col['modules'] ) ) {
[281] Fix | Delete
foreach ( $col['modules'] as $module ) {
[282] Fix | Delete
if ( isset( $module['mod_name'] ) ) {
[283] Fix | Delete
$modules[] = $module;
[284] Fix | Delete
}
[285] Fix | Delete
$modules = array_merge( $modules, self::_get_modules_recursive( $module ) );
[286] Fix | Delete
}
[287] Fix | Delete
}
[288] Fix | Delete
}
[289] Fix | Delete
}
[290] Fix | Delete
[291] Fix | Delete
return $modules;
[292] Fix | Delete
}
[293] Fix | Delete
[294] Fix | Delete
/**
[295] Fix | Delete
* Return first not empty text module
[296] Fix | Delete
*/
[297] Fix | Delete
public static function get_first_text(?int $post_id = null,?array $builder_data = null):string {
[298] Fix | Delete
if ($builder_data === null) {
[299] Fix | Delete
$builder_data = ThemifyBuilder_Data_Manager::get_data($post_id);
[300] Fix | Delete
}
[301] Fix | Delete
// loop through modules in Builder
[302] Fix | Delete
if (is_array($builder_data)) {
[303] Fix | Delete
foreach ($builder_data as $row) {
[304] Fix | Delete
if (!empty($row['cols'])) {
[305] Fix | Delete
foreach ($row['cols'] as $col) {
[306] Fix | Delete
if (!empty($col['modules'])) {
[307] Fix | Delete
foreach ($col['modules'] as $mod) {
[308] Fix | Delete
if (isset($mod['mod_name']) && $mod['mod_name'] === 'text' && !empty($mod['mod_settings']['content_text'])) {
[309] Fix | Delete
return $mod['mod_settings']['content_text'];
[310] Fix | Delete
}
[311] Fix | Delete
// Check for Sub-rows
[312] Fix | Delete
if (!empty($mod['cols'])) {
[313] Fix | Delete
foreach ($mod['cols'] as $sub_col) {
[314] Fix | Delete
if (!empty($sub_col['modules'])) {
[315] Fix | Delete
foreach ($sub_col['modules'] as $sub_module) {
[316] Fix | Delete
if (isset($sub_module['mod_name']) && $sub_module['mod_name'] === 'text' && !empty($sub_module['mod_settings']['content_text'])) {
[317] Fix | Delete
return $sub_module['mod_settings']['content_text'];
[318] Fix | Delete
}
[319] Fix | Delete
}
[320] Fix | Delete
}
[321] Fix | Delete
}
[322] Fix | Delete
}
[323] Fix | Delete
}
[324] Fix | Delete
}
[325] Fix | Delete
}
[326] Fix | Delete
}
[327] Fix | Delete
}
[328] Fix | Delete
}
[329] Fix | Delete
[330] Fix | Delete
return '';
[331] Fix | Delete
}
[332] Fix | Delete
[333] Fix | Delete
[334] Fix | Delete
/**
[335] Fix | Delete
* Init function
[336] Fix | Delete
*/
[337] Fix | Delete
private static function setup():void {
[338] Fix | Delete
do_action('themify_builder_setup_modules');
[339] Fix | Delete
if ((!empty($_REQUEST['action']) && !in_array($_REQUEST['action'], array('tb_update_tick', 'tb_load_module_partial', 'tb_render_element', 'tb_module_favorite', 'themify_regenerate_css_files_ajax', 'render_element_shortcode_ajaxify', 'get_ajax_post_types', 'tb_help'), true) && themify_is_ajax()) || Themify_Builder_Model::is_front_builder_activate()) {
[340] Fix | Delete
Themify_Builder_Component_Module::load_modules();
[341] Fix | Delete
}
[342] Fix | Delete
}
[343] Fix | Delete
[344] Fix | Delete
public static function wp_hook():void {
[345] Fix | Delete
do_action('themify_builder_run');
[346] Fix | Delete
}
[347] Fix | Delete
[348] Fix | Delete
private static function includes_always():void {
[349] Fix | Delete
if (Themify_Builder_Model::is_gutenberg_active()) {
[350] Fix | Delete
include THEMIFY_BUILDER_CLASSES_DIR . '/class-themify-builder-gutenberg.php';
[351] Fix | Delete
}
[352] Fix | Delete
include THEMIFY_BUILDER_CLASSES_DIR . '/class-builder-data-manager.php';
[353] Fix | Delete
include THEMIFY_BUILDER_CLASSES_DIR . '/class-themify-builder-stylesheet.php';
[354] Fix | Delete
include THEMIFY_BUILDER_CLASSES_DIR . '/class-themify-builder-widgets.php';
[355] Fix | Delete
include THEMIFY_BUILDER_CLASSES_DIR . '/class-themify-builder-visibility-controls.php';
[356] Fix | Delete
if (current_user_can('publish_pages')) {
[357] Fix | Delete
include THEMIFY_BUILDER_CLASSES_DIR . '/class-themify-builder-page.php';
[358] Fix | Delete
}
[359] Fix | Delete
[360] Fix | Delete
include THEMIFY_BUILDER_INCLUDES_DIR . '/components/base.php';
[361] Fix | Delete
include THEMIFY_BUILDER_INCLUDES_DIR . '/components/row.php';
[362] Fix | Delete
include THEMIFY_BUILDER_INCLUDES_DIR . '/components/subrow.php';
[363] Fix | Delete
include THEMIFY_BUILDER_INCLUDES_DIR . '/components/column.php';
[364] Fix | Delete
include THEMIFY_BUILDER_INCLUDES_DIR . '/components/module.php';
[365] Fix | Delete
}
[366] Fix | Delete
[367] Fix | Delete
private static function includes_active():void {
[368] Fix | Delete
include THEMIFY_BUILDER_CLASSES_DIR . '/class-themify-builder-active.php';
[369] Fix | Delete
}
[370] Fix | Delete
[371] Fix | Delete
private static function includes_admin():void {
[372] Fix | Delete
include THEMIFY_BUILDER_CLASSES_DIR . '/class-themify-builder-admin.php';
[373] Fix | Delete
}
[374] Fix | Delete
[375] Fix | Delete
/**
[376] Fix | Delete
* List of post types that support the editor
[377] Fix | Delete
*
[378] Fix | Delete
* @since 2.4.8
[379] Fix | Delete
*/
[380] Fix | Delete
public static function builder_post_types_support():array {
[381] Fix | Delete
$public_post_types = get_post_types(array(
[382] Fix | Delete
'public' => true,
[383] Fix | Delete
'_builtin' => false,
[384] Fix | Delete
'show_ui' => true,
[385] Fix | Delete
));
[386] Fix | Delete
$post_types = array_merge($public_post_types, array('post', 'page'));
[387] Fix | Delete
foreach ($post_types as $key => $type) {
[388] Fix | Delete
if (!post_type_supports($type, 'editor')) {
[389] Fix | Delete
unset($post_types[$key]);
[390] Fix | Delete
}
[391] Fix | Delete
}
[392] Fix | Delete
[393] Fix | Delete
return apply_filters('themify_builder_post_types_support', $post_types);
[394] Fix | Delete
}
[395] Fix | Delete
[396] Fix | Delete
[397] Fix | Delete
[398] Fix | Delete
[399] Fix | Delete
[400] Fix | Delete
[401] Fix | Delete
/**
[402] Fix | Delete
* Register styles and scripts necessary for Builder template output.
[403] Fix | Delete
* These are enqueued when a user initializes Builder or from a template output.
[404] Fix | Delete
*
[405] Fix | Delete
* Registered style handlers:
[406] Fix | Delete
*
[407] Fix | Delete
* Registered script handlers:
[408] Fix | Delete
* themify-builder-module-plugins-js
[409] Fix | Delete
* themify-builder-script-js
[410] Fix | Delete
*
[411] Fix | Delete
* @since 2.1.9
[412] Fix | Delete
*/
[413] Fix | Delete
public static function register_js_css():void {
[414] Fix | Delete
add_action('wp_footer', array(__CLASS__, 'footer_js'));
[415] Fix | Delete
}
[416] Fix | Delete
[417] Fix | Delete
public static function footer_js():void {
[418] Fix | Delete
$args = array(
[419] Fix | Delete
'fullwidth_support' => Themify_Builder_Model::is_fullwidth_layout_supported(),
[420] Fix | Delete
'is_sticky' => Themify_Builder_Model::is_sticky_scroll_active(),
[421] Fix | Delete
'is_animation' => Themify_Builder_Model::is_animation_active(),
[422] Fix | Delete
'is_parallax' => Themify_Builder_Model::is_parallax_active(),
[423] Fix | Delete
'scrollHighlight' => apply_filters('themify_builder_scroll_highlight_vars', array()) //Inject variable values in Scroll-Highlight script
[424] Fix | Delete
);
[425] Fix | Delete
if (Themify_Builder_Model::is_front_builder_activate()) {
[426] Fix | Delete
$modules=Themify_Builder_Component_Module::load_modules();
[427] Fix | Delete
foreach ($modules as $id=>$m) {
[428] Fix | Delete
$assets = $m::get_js_css();
[429] Fix | Delete
if (!empty($assets)) {
[430] Fix | Delete
Themify_Builder_Component_Module::add_modules_assets($id, $assets);
[431] Fix | Delete
}
[432] Fix | Delete
}
[433] Fix | Delete
}
[434] Fix | Delete
elseif (!empty(self::$tooltips)) {
[435] Fix | Delete
Themify_Enqueue_Assets::addLocalization('builder_tooltips', self::$tooltips);
[436] Fix | Delete
self::$tooltips = null;
[437] Fix | Delete
}
[438] Fix | Delete
$offset = themify_builder_get('setting-scrollto_offset', 'builder_scrollTo');
[439] Fix | Delete
if (!empty($offset)) {
[440] Fix | Delete
$args['scrollHighlight']['offset'] = (int) $offset;
[441] Fix | Delete
}
[442] Fix | Delete
$speed = themify_builder_get('scrollto_speed', 'builder_scrollTo_speed');
[443] Fix | Delete
if ($speed === null) {
[444] Fix | Delete
$speed = .9;
[445] Fix | Delete
}
[446] Fix | Delete
$args['scrollHighlight']['speed'] = ( (float) $speed * 1000 ) + .01; /* .01 second is added in case user enters 0 to disable the animation */
[447] Fix | Delete
$args['addons'] = Themify_Builder_Component_Module::get_modules_assets();
[448] Fix | Delete
[449] Fix | Delete
$args = apply_filters('themify_builder_script_vars', $args);
[450] Fix | Delete
if (true === $args['is_animation']) {
[451] Fix | Delete
unset($args['is_animation']);
[452] Fix | Delete
}
[453] Fix | Delete
if (true === $args['is_parallax']) {
[454] Fix | Delete
unset($args['is_parallax']);
[455] Fix | Delete
}
[456] Fix | Delete
if (true === $args['is_sticky']) {
[457] Fix | Delete
unset($args['is_sticky']);
[458] Fix | Delete
}
[459] Fix | Delete
if ($args['fullwidth_support'] === true) {
[460] Fix | Delete
unset($args['fullwidth_support']);
[461] Fix | Delete
} else {
[462] Fix | Delete
$args['fullwidth_support'] = 1;
[463] Fix | Delete
}
[464] Fix | Delete
Themify_Enqueue_Assets::localize_script('themify-main-script', 'tbLocalScript', $args);
[465] Fix | Delete
$args = null;
[466] Fix | Delete
}
[467] Fix | Delete
[468] Fix | Delete
[469] Fix | Delete
[470] Fix | Delete
[471] Fix | Delete
/**
[472] Fix | Delete
* Only need to save converted old css col padding to new grid css padding
[473] Fix | Delete
*/
[474] Fix | Delete
public static function convert_data() {
[475] Fix | Delete
check_ajax_referer('tf_nonce', 'nonce');
[476] Fix | Delete
if (!empty($_POST['data']) && !empty($_POST['bid'])) {
[477] Fix | Delete
$id = (int) $_POST['bid'];
[478] Fix | Delete
$builder_data = ThemifyBuilder_Data_Manager::get_data($id);
[479] Fix | Delete
if (is_array($builder_data)) {
[480] Fix | Delete
$convert = json_decode(stripslashes_deep($_POST['data']), true);
[481] Fix | Delete
$update = false;
[482] Fix | Delete
$breakpints = array_reverse(array_keys(themify_get_breakpoints()));
[483] Fix | Delete
$breakpints[] = 'desktop';
[484] Fix | Delete
$bpLength = count($breakpints);
[485] Fix | Delete
$allowed = array('padding', 'padding_top', 'padding_bottom', 'padding_left', 'padding_right', 'padding_left_unit', 'padding_right_unit', 'padding_top_unit', 'padding_bottom_unit', 'margin-bottom', 'margin-top', 'margin-bottom_unit', 'margin-top_unit');
[486] Fix | Delete
foreach ($builder_data as &$row) {
[487] Fix | Delete
if (!empty($row['cols'])) {
[488] Fix | Delete
foreach ($row['cols'] as &$col) {
[489] Fix | Delete
if (isset($convert[$col['element_id']])) {
[490] Fix | Delete
$hasChange = false;
[491] Fix | Delete
foreach ($convert[$col['element_id']] as $bp => $props) {
[492] Fix | Delete
if (in_array($bp, $breakpints, true)) {
[493] Fix | Delete
foreach ($props as $prop => $v) {
[494] Fix | Delete
if (in_array($prop, $allowed, true)) {
[495] Fix | Delete
if ($bp === 'desktop') {
[496] Fix | Delete
if ($v === '%') {//unit proop
[497] Fix | Delete
$col['styling'][$prop] = $v;
[498] Fix | Delete
} else {
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function