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.../public_h.../wp-conte.../plugins/themify-.../classes
File: class-themify-builder-active.php
<?php
[0] Fix | Delete
defined('ABSPATH') || exit;
[1] Fix | Delete
[2] Fix | Delete
class Themify_Builder_Active{
[3] Fix | Delete
[4] Fix | Delete
public static function init():void{
[5] Fix | Delete
self::includes();
[6] Fix | Delete
self::run();
[7] Fix | Delete
}
[8] Fix | Delete
[9] Fix | Delete
private static function run():void{
[10] Fix | Delete
if (Themify_Builder_Model::is_front_builder_activate()) {
[11] Fix | Delete
// load module panel frontend
[12] Fix | Delete
add_action('wp_footer', array(__CLASS__, 'load_javascript_template_front'), 1);
[13] Fix | Delete
add_filter('show_admin_bar', '__return_false'); // Custom CSS
[14] Fix | Delete
add_filter('themify_dev_mode', '__return_false');
[15] Fix | Delete
global $wp_actions;
[16] Fix | Delete
$wp_actions['wp_enqueue_media'] = true;
[17] Fix | Delete
themify_set_headers(array(
[18] Fix | Delete
'X-FRAME-OPTIONS' => 'SAMEORIGIN',
[19] Fix | Delete
'CONTENT-SECURITY-POLICY' => array(
[20] Fix | Delete
'img-src' => "https://themify.org https://placehold.co 'unsafe-inline' blob:",
[21] Fix | Delete
'default-src' => "https://placehold.co 'unsafe-inline' blob:"
[22] Fix | Delete
)
[23] Fix | Delete
));
[24] Fix | Delete
}
[25] Fix | Delete
else {
[26] Fix | Delete
$is_admin = is_admin();
[27] Fix | Delete
$is_ajax=themify_is_ajax();
[28] Fix | Delete
// Ajax Actions
[29] Fix | Delete
if ($is_ajax===true) {
[30] Fix | Delete
add_action('wp_ajax_tb_load_editor', array(__CLASS__, 'load_editor'), 10);
[31] Fix | Delete
[32] Fix | Delete
add_action('wp_ajax_tb_load_module_partial', array(__CLASS__, 'load_module_partial_ajaxify'), 10);
[33] Fix | Delete
add_action('wp_ajax_tb_render_element', array(__CLASS__, 'render_element_ajaxify'), 10);
[34] Fix | Delete
add_action('wp_ajax_tb_get_post_types', array(__CLASS__, 'get_ajax_post_types'), 10);
[35] Fix | Delete
add_action('wp_ajax_tb_render_element_shortcode', array(__CLASS__, 'render_element_shortcode_ajaxify'), 10);
[36] Fix | Delete
// Builder Save Data
[37] Fix | Delete
add_action('wp_ajax_tb_save_data', array(__CLASS__, 'save_data_builder'), 10);
[38] Fix | Delete
add_action('wp_ajax_tb_save_css', array(__CLASS__, 'save_builder_css'), 10);
[39] Fix | Delete
// AJAX Action Save Module Favorite Data
[40] Fix | Delete
add_action('wp_ajax_tb_module_favorite', array(__CLASS__, 'save_module_favorite_data'));
[41] Fix | Delete
//AJAX Action update ticks and TakeOver
[42] Fix | Delete
add_action('wp_ajax_tb_update_tick', array(__CLASS__, 'update_tick'));
[43] Fix | Delete
add_action('wp_ajax_tb_help', array(__CLASS__, 'help'));
[44] Fix | Delete
// Replace URL
[45] Fix | Delete
add_action('wp_ajax_tb_get_ajax_builder_posts', array(__CLASS__, 'get_ajax_builder_posts'));
[46] Fix | Delete
add_action('wp_ajax_tb_get_ajax_data', array(__CLASS__, 'get_ajax_data'));
[47] Fix | Delete
add_action('wp_ajax_tb_validate_captcha', array(__CLASS__, 'ajax_validate_captcha'));
[48] Fix | Delete
add_action('wp_ajax_tb_get_pages', array(__CLASS__, 'tb_get_pages'));
[49] Fix | Delete
}
[50] Fix | Delete
if ($is_admin === false || $is_ajax===true) {
[51] Fix | Delete
add_action('admin_bar_menu', array(__CLASS__, 'builder_admin_bar_menu'), 100);
[52] Fix | Delete
if ($is_admin === false) {
[53] Fix | Delete
add_action('wp_footer', array(__CLASS__, 'async_footer'));
[54] Fix | Delete
}
[55] Fix | Delete
}
[56] Fix | Delete
// Import Export
[57] Fix | Delete
Themify_Builder_Import_Export::init();
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
// Library Module, Rows and Layout Parts
[61] Fix | Delete
Themify_Builder_Library_Items::init();
[62] Fix | Delete
[63] Fix | Delete
// Themify Builder Revisions
[64] Fix | Delete
Themify_Builder_Revisions::init();
[65] Fix | Delete
[66] Fix | Delete
// Fix security restrictions
[67] Fix | Delete
add_filter('user_can_richedit', '__return_true');
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
/**
[71] Fix | Delete
* Load interface js and css
[72] Fix | Delete
*/
[73] Fix | Delete
private static function load_frontend_interface():void {
[74] Fix | Delete
[75] Fix | Delete
// load only when builder is turn on
[76] Fix | Delete
$editorUrl = THEMIFY_BUILDER_URI . '/css/editor/';
[77] Fix | Delete
themify_enque_style('themify-builder-admin-ui', $editorUrl . 'themify-builder-admin-ui.css', array(), THEMIFY_VERSION, '', true);
[78] Fix | Delete
$grids = array_diff(scandir(THEMIFY_DIR . '/css/grids/', SCANDIR_SORT_NONE), array('..', '.'));
[79] Fix | Delete
foreach ($grids as $g) {
[80] Fix | Delete
Themify_Enqueue_Assets::loadGridCss(str_replace('.css', '', $g), true);
[81] Fix | Delete
}
[82] Fix | Delete
unset($grids);
[83] Fix | Delete
[84] Fix | Delete
$editorUrl = THEMIFY_BUILDER_URI . '/js/editor/';
[85] Fix | Delete
Themify_Icon_Font::enqueue();
[86] Fix | Delete
[87] Fix | Delete
themify_enque_script('themify-colorpicker', THEMIFY_METABOX_URI . 'js/themify.minicolors.js');
[88] Fix | Delete
themify_enque_script('themify-combobox', $editorUrl . 'themify-combobox.min.js');
[89] Fix | Delete
[90] Fix | Delete
themify_enque_script('themify-builder-js', THEMIFY_BUILDER_URI . '/js/themify-builder-script.js');
[91] Fix | Delete
themify_enque_script('tb_builder_js_style', THEMIFY_URI . '/js/generate-style.js');
[92] Fix | Delete
themify_enque_script('themify-builder-app-js', $editorUrl . 'build/components.min.js', THEMIFY_VERSION, array('tb_builder_js_style'));
[93] Fix | Delete
themify_enque_script('themify-builder-modules-js', $editorUrl . 'build/modules.min.js', THEMIFY_VERSION, array('themify-builder-app-js'));
[94] Fix | Delete
[95] Fix | Delete
themify_enque_script('themify-builder-front-ui-js', $editorUrl . 'frontend/themify-builder-visual.js', THEMIFY_VERSION, array('themify-builder-app-js'));
[96] Fix | Delete
[97] Fix | Delete
global $shortcode_tags;
[98] Fix | Delete
$builderData = self::get_active_builder_vars();
[99] Fix | Delete
$builderData['upload_url'] = themify_upload_dir('baseurl');
[100] Fix | Delete
$builderData['available_shortcodes'] = array_keys($shortcode_tags);
[101] Fix | Delete
[102] Fix | Delete
do_action('themify_builder_active_enqueue', 'visual');
[103] Fix | Delete
wp_localize_script('themify-colorpicker', 'themifyCM', Themify_Metabox::themify_localize_cm_data());
[104] Fix | Delete
wp_localize_script('themify-builder-app-js', 'themifyBuilder', $builderData);
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
private static function load_admin_interface():void {
[108] Fix | Delete
$editorUrl = THEMIFY_BUILDER_URI . '/css/editor/';
[109] Fix | Delete
themify_enque_style('tf_base', THEMIFY_URI . '/css/base.min.css', null, THEMIFY_VERSION, '', true);
[110] Fix | Delete
themify_enque_style('themify-builder-loader', $editorUrl . 'themify-builder-loader.css', null, THEMIFY_VERSION, '', true);
[111] Fix | Delete
themify_enque_style('themify-builder-style', THEMIFY_BUILDER_URI . '/css/themify-builder-style.css', null, THEMIFY_VERSION, '', true);
[112] Fix | Delete
themify_enque_style('themify-builder-lightbox', $editorUrl . 'components/lightbox.css', null, THEMIFY_VERSION, '', true);
[113] Fix | Delete
themify_enque_style('themify-builder-admin-ui', $editorUrl . 'themify-builder-admin-ui.css', null, THEMIFY_VERSION, '', true);
[114] Fix | Delete
themify_enque_style('themify-backend-mode', $editorUrl . 'backend-mode.css', null, THEMIFY_VERSION, '', true);
[115] Fix | Delete
themify_enque_style('themify-backend-ui', $editorUrl . 'backend/backend-ui.css', null, THEMIFY_VERSION, '', true);
[116] Fix | Delete
$editorUrl = THEMIFY_BUILDER_URI . '/js/editor/';
[117] Fix | Delete
[118] Fix | Delete
Themify_Enqueue_Assets::loadMainScript();
[119] Fix | Delete
[120] Fix | Delete
themify_enque_script('themify-combobox', $editorUrl . 'themify-combobox.min.js');
[121] Fix | Delete
[122] Fix | Delete
themify_enque_script('tb_builder_js_style', THEMIFY_URI . '/js/generate-style.js');
[123] Fix | Delete
[124] Fix | Delete
themify_enque_script('themify-builder-app-js', $editorUrl . 'build/components.min.js', THEMIFY_VERSION, array('tb_builder_js_style'));
[125] Fix | Delete
themify_enque_script('themify-builder-modules-js', $editorUrl . 'build/modules.min.js', THEMIFY_VERSION, array('themify-builder-app-js'));
[126] Fix | Delete
[127] Fix | Delete
themify_enque_script('themify-builder-backend-js', $editorUrl . 'backend/themify-builder-backend.js', THEMIFY_VERSION, array('themify-builder-app-js'));
[128] Fix | Delete
[129] Fix | Delete
themify_enque_script('themify-static-badge', THEMIFY_BUILDER_URI . '/js/editor/backend/themify-builder-static-badge.js', THEMIFY_VERSION, array('mce-view', 'themify-builder-backend-js'));
[130] Fix | Delete
[131] Fix | Delete
[132] Fix | Delete
[133] Fix | Delete
$builderData = self::get_active_builder_vars();
[134] Fix | Delete
$builderData['post_ID'] = get_the_ID();
[135] Fix | Delete
$builderData['is_gutenberg_editor'] = Themify_Builder_Model::is_gutenberg_editor();
[136] Fix | Delete
do_action('themify_builder_active_enqueue', 'admin');
[137] Fix | Delete
[138] Fix | Delete
wp_localize_script('themify-builder-app-js', 'themifyBuilder', $builderData);
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
[142] Fix | Delete
private static function get_active_builder_vars():array {
[143] Fix | Delete
Themify_Builder_Component_Module::load_modules();
[144] Fix | Delete
$video=$audio=$image=[];
[145] Fix | Delete
if(current_user_can('upload_files')){
[146] Fix | Delete
$tmp_extensions = get_allowed_mime_types();
[147] Fix | Delete
$allowed_extensions=[];
[148] Fix | Delete
foreach($tmp_extensions as $ext=>$v){
[149] Fix | Delete
if(strpos($ext,'|')!==false){
[150] Fix | Delete
$ext=explode('|',$ext);
[151] Fix | Delete
foreach($ext as $ex){
[152] Fix | Delete
$allowed_extensions[$ex]=$v;
[153] Fix | Delete
}
[154] Fix | Delete
}else{
[155] Fix | Delete
$allowed_extensions[$ext]=$v;
[156] Fix | Delete
}
[157] Fix | Delete
}
[158] Fix | Delete
$extensions=wp_get_ext_types();
[159] Fix | Delete
$_video= $extensions['video'];
[160] Fix | Delete
$_audio=$extensions['audio'];
[161] Fix | Delete
$_image= $extensions['image'];
[162] Fix | Delete
$tmp_extensions=$extensions=null;
[163] Fix | Delete
foreach($_video as $v){
[164] Fix | Delete
if ( isset($allowed_extensions[$v]) ) {
[165] Fix | Delete
$mime=explode('/',$allowed_extensions[$v])[1];
[166] Fix | Delete
if(!isset($video[$mime])){
[167] Fix | Delete
$video[$mime]='';
[168] Fix | Delete
}
[169] Fix | Delete
$video[$mime].=$v.'|';
[170] Fix | Delete
}
[171] Fix | Delete
}
[172] Fix | Delete
foreach($_audio as $v){
[173] Fix | Delete
if ( isset($allowed_extensions[$v]) ) {
[174] Fix | Delete
$mime=explode('/',$allowed_extensions[$v])[1];
[175] Fix | Delete
if(!isset($audio[$mime])){
[176] Fix | Delete
$audio[$mime]='';
[177] Fix | Delete
}
[178] Fix | Delete
$audio[$mime].=$v.'|';
[179] Fix | Delete
}
[180] Fix | Delete
}
[181] Fix | Delete
foreach($_image as $v){
[182] Fix | Delete
if ( isset($allowed_extensions[$v]) ) {
[183] Fix | Delete
$mime=explode('/',$allowed_extensions[$v])[1];
[184] Fix | Delete
if(!isset($image[$mime])){
[185] Fix | Delete
$image[$mime]='';
[186] Fix | Delete
}
[187] Fix | Delete
$image[$mime].=$v.'|';
[188] Fix | Delete
}
[189] Fix | Delete
}
[190] Fix | Delete
$allowed_extensions=$_video=$_audio=$_image=null;
[191] Fix | Delete
}
[192] Fix | Delete
global $wp_styles;
[193] Fix | Delete
$id = is_admin() ? get_the_ID() : Themify_Builder::$builder_active_id;
[194] Fix | Delete
$i18n=include THEMIFY_BUILDER_INCLUDES_DIR . '/i18n.php';
[195] Fix | Delete
$vars=apply_filters('themify_builder_active_vars',[
[196] Fix | Delete
'builder_data' => ThemifyBuilder_Data_Manager::get_data($id),
[197] Fix | Delete
'addons'=>[],
[198] Fix | Delete
'site_url' => get_site_url(),
[199] Fix | Delete
'nonce' => wp_create_nonce('tf_nonce'),
[200] Fix | Delete
'disableShortcuts' => themify_builder_get('setting-page_builder_disable_shortcuts', 'builder_disable_shortcuts'),
[201] Fix | Delete
'widget_css' => array(home_url($wp_styles->registered['widgets']->src), home_url($wp_styles->registered['customize-widgets']->src)),
[202] Fix | Delete
'modules' => Themify_Builder_Model::get_modules_localize_settings(),
[203] Fix | Delete
'favorite' => Themify_Builder_Model::get_favorite_modules(),
[204] Fix | Delete
'gutters' => Themify_Builder_Model::get_gutters(),
[205] Fix | Delete
'i18n' => $i18n,
[206] Fix | Delete
'layouts' => Themify_Builder_Model::get_layouts(),
[207] Fix | Delete
'blocks' => 'https://themify.org/public-api/predesigned-rows/',
[208] Fix | Delete
'custom_css' => get_post_meta($id, 'tbp_custom_css', true),
[209] Fix | Delete
'post_title' => get_the_title($id),
[210] Fix | Delete
'cf_api_url' => Themify_Custom_Fonts::$api_url,
[211] Fix | Delete
'safe' => themify_get_web_safe_font_list(),
[212] Fix | Delete
'google' => themify_get_google_web_fonts_list(),
[213] Fix | Delete
'cf' => Themify_Custom_Fonts::get_list(),
[214] Fix | Delete
'ticks' => Themify_Builder_Model::get_transient_time(),
[215] Fix | Delete
'memory' => (int) (wp_convert_hr_to_bytes(WP_MEMORY_LIMIT) * MB_IN_BYTES),
[216] Fix | Delete
'imgphp'=>Themify_Builder_Model::is_img_php_disabled(),
[217] Fix | Delete
'admin_url'=>rtrim( get_admin_url(), '/' ),
[218] Fix | Delete
'ext'=>['video'=>$video,'audio'=>$audio,'image'=>$image]
[219] Fix | Delete
], is_admin() ? 'admin' : 'visual' );
[220] Fix | Delete
unset($image,$video,$audio);
[221] Fix | Delete
$jsonFiles=Themify_Builder_Component_Module::get_styles_json();
[222] Fix | Delete
$vars['style_json']=$jsonFiles;
[223] Fix | Delete
if(!is_admin()){
[224] Fix | Delete
foreach($jsonFiles as $f){
[225] Fix | Delete
Themify_Enqueue_Assets::addPreLoadMedia($f,'prefetch','json');
[226] Fix | Delete
}
[227] Fix | Delete
}
[228] Fix | Delete
if(!current_user_can('upload_files')){
[229] Fix | Delete
$vars['upload_disable']=1;
[230] Fix | Delete
}
[231] Fix | Delete
if(!function_exists('gzdecode')){
[232] Fix | Delete
$vars['gzip_disabled']=1;
[233] Fix | Delete
}
[234] Fix | Delete
if(empty($vars['custom_css'])){
[235] Fix | Delete
unset($vars['custom_css']);
[236] Fix | Delete
}
[237] Fix | Delete
if(empty($vars['imgphp'])){
[238] Fix | Delete
unset($vars['imgphp']);
[239] Fix | Delete
}
[240] Fix | Delete
if(empty($vars['favorite'])){
[241] Fix | Delete
unset($vars['favorite']);
[242] Fix | Delete
}
[243] Fix | Delete
if(empty($vars['addons'])){
[244] Fix | Delete
unset($vars['addons']);
[245] Fix | Delete
}
[246] Fix | Delete
if(empty($vars['disableShortcuts'])){
[247] Fix | Delete
unset($vars['disableShortcuts']);
[248] Fix | Delete
}
[249] Fix | Delete
if(empty($vars['style_json'])){
[250] Fix | Delete
unset($vars['style_json']);
[251] Fix | Delete
}
[252] Fix | Delete
return $vars;
[253] Fix | Delete
}
[254] Fix | Delete
[255] Fix | Delete
private static function includes():void {
[256] Fix | Delete
include THEMIFY_BUILDER_CLASSES_DIR . '/class-themify-builder-revisions.php';
[257] Fix | Delete
include THEMIFY_BUILDER_CLASSES_DIR . '/class-themify-builder-library-item.php';
[258] Fix | Delete
include THEMIFY_BUILDER_CLASSES_DIR . '/class-builder-duplicate-page.php';
[259] Fix | Delete
include THEMIFY_BUILDER_CLASSES_DIR . '/class-themify-builder-import-export.php';
[260] Fix | Delete
}
[261] Fix | Delete
[262] Fix | Delete
[263] Fix | Delete
/**
[264] Fix | Delete
* Loads JS templates for front-end editor.
[265] Fix | Delete
*/
[266] Fix | Delete
public static function load_javascript_template_front():void {
[267] Fix | Delete
add_filter( 'wp_inline_script_attributes', array(__CLASS__, 'exclude_cloudfare_js'), 11,1);
[268] Fix | Delete
[269] Fix | Delete
self::load_frontend_interface();
[270] Fix | Delete
include THEMIFY_BUILDER_INCLUDES_DIR . '/tpl/tmpl-common.php';
[271] Fix | Delete
include THEMIFY_BUILDER_INCLUDES_DIR . '/tpl/tmpl-front.php';
[272] Fix | Delete
}
[273] Fix | Delete
[274] Fix | Delete
/**
[275] Fix | Delete
* Loads JS templates for WordPress admin dashboard editor.
[276] Fix | Delete
*/
[277] Fix | Delete
public static function load_javascript_template_admin():void {
[278] Fix | Delete
self::load_admin_interface();
[279] Fix | Delete
self::print_static_content_badge_templates();
[280] Fix | Delete
include THEMIFY_BUILDER_INCLUDES_DIR . '/tpl/tmpl-common.php';
[281] Fix | Delete
include THEMIFY_BUILDER_INCLUDES_DIR . '/tpl/tmpl-admin.php';
[282] Fix | Delete
}
[283] Fix | Delete
[284] Fix | Delete
[285] Fix | Delete
[286] Fix | Delete
public static function exclude_cloudfare_js(array $attr=array()):array {
[287] Fix | Delete
if(isset($attr['id']) && ($attr['id']==='themify-builder-app-js-js-extra' || $attr['id']==='themify-colorpicker-js-extra' || $attr['id']==='tf-icon-picker-js-extra')){
[288] Fix | Delete
$attr['data-cfasync']='false';
[289] Fix | Delete
$attr['data-no-optimize']=$attr['data-noptimize']=1;
[290] Fix | Delete
}
[291] Fix | Delete
return $attr;
[292] Fix | Delete
}
[293] Fix | Delete
[294] Fix | Delete
public static function load_editor() {
[295] Fix | Delete
global $wp_scripts, $wp_styles, $concatenate_scripts, $wp_actions;
[296] Fix | Delete
if (!defined('CONCATENATE_SCRIPTS')) {
[297] Fix | Delete
define('CONCATENATE_SCRIPTS', false);
[298] Fix | Delete
}
[299] Fix | Delete
$concatenate_scripts = false;
[300] Fix | Delete
[301] Fix | Delete
/* ensure $wp_scripts and $wp_styles globals have been initialized */
[302] Fix | Delete
wp_styles();
[303] Fix | Delete
wp_scripts();
[304] Fix | Delete
[305] Fix | Delete
wp_enqueue_script( 'jquery-ui-sortable' );
[306] Fix | Delete
wp_enqueue_script( 'shortcode' );
[307] Fix | Delete
[308] Fix | Delete
/* force a load uncompressed TinyMCE script, fix script issues on frontend editor */
[309] Fix | Delete
$wp_scripts->remove('wp-tinymce');
[310] Fix | Delete
wp_register_tinymce_scripts($wp_scripts, true); // true: $force_uncompressed
[311] Fix | Delete
//store original
[312] Fix | Delete
if (is_object($wp_styles)) {
[313] Fix | Delete
$tmp_styles = clone $wp_styles;
[314] Fix | Delete
}
[315] Fix | Delete
$tmp_scripts = clone $wp_scripts;
[316] Fix | Delete
$new = array();
[317] Fix | Delete
[318] Fix | Delete
foreach ($tmp_scripts->registered as $k => $v) {
[319] Fix | Delete
$new[$k] = clone $v;
[320] Fix | Delete
}
[321] Fix | Delete
[322] Fix | Delete
$scripts_registered = $new;
[323] Fix | Delete
if (isset($tmp_styles)) {
[324] Fix | Delete
$new = array();
[325] Fix | Delete
foreach ($tmp_styles->registered as $k => $v) {
[326] Fix | Delete
$new[$k] = clone $v;
[327] Fix | Delete
}
[328] Fix | Delete
$styles_registered = $new;
[329] Fix | Delete
}
[330] Fix | Delete
$new = null;
[331] Fix | Delete
//don't allow loading wp_enqueue_media thirdy party plugins
[332] Fix | Delete
$wp_actions['wp_enqueue_media'] = true;
[333] Fix | Delete
[334] Fix | Delete
//for thirdy party plugins, maybe they use wp_enqueue_scripts hook to add localize data in tinymce, the js files we don't need to check by wp standart they should use mce_external_plugins
[335] Fix | Delete
do_action('wp_enqueue_scripts');
[336] Fix | Delete
$data = !empty($wp_scripts->registered['editor']->extra['data']) ? $wp_scripts->registered['editor']->extra['data'] : null;
[337] Fix | Delete
[338] Fix | Delete
//restore original because we only need the js/css related with wp editor only,otherwise they will be loaded in wp_footer
[339] Fix | Delete
if (isset($tmp_styles)) {
[340] Fix | Delete
$tmp_styles->registered = $styles_registered;
[341] Fix | Delete
$wp_styles = clone $tmp_styles;
[342] Fix | Delete
$tmp_styles = $styles_registered = null;
[343] Fix | Delete
}
[344] Fix | Delete
$tmp_scripts->registered = $scripts_registered;
[345] Fix | Delete
[346] Fix | Delete
$wp_scripts = clone $tmp_scripts;
[347] Fix | Delete
$tmp_scripts = $scripts_registered = null;
[348] Fix | Delete
[349] Fix | Delete
$wp_scripts->done[] = 'jquery';
[350] Fix | Delete
$wp_scripts->done[] = 'jquery-core';
[351] Fix | Delete
unset($wp_actions['wp_enqueue_media']);
[352] Fix | Delete
echo '<div id="tb_tinymce_wrap">';
[353] Fix | Delete
if (current_user_can('upload_files')) {
[354] Fix | Delete
wp_enqueue_media();
[355] Fix | Delete
}
[356] Fix | Delete
echo '<div style="display:none;">';
[357] Fix | Delete
wp_editor(' ', 'tb_lb_hidden_editor');
[358] Fix | Delete
echo '</div>';
[359] Fix | Delete
if (!empty($wp_scripts->registered['editor']->deps)) {
[360] Fix | Delete
$wp_scripts->registered['editor']->deps[] = 'wp-tinymce-root';
[361] Fix | Delete
} else {
[362] Fix | Delete
$wp_scripts->registered['editor']->deps = array('wp-tinymce-root');
[363] Fix | Delete
}
[364] Fix | Delete
//wp is returing is_admin() true on the ajax call,that is why we have to add these hooks manually
[365] Fix | Delete
add_action('wp_print_footer_scripts', array('_WP_Editors', 'editor_js'), 50);
[366] Fix | Delete
add_action('wp_print_footer_scripts', array('_WP_Editors', 'force_uncompressed_tinymce'), 1);
[367] Fix | Delete
add_action('wp_print_footer_scripts', array('_WP_Editors', 'enqueue_scripts'), 1);
[368] Fix | Delete
wp_footer();
[369] Fix | Delete
[370] Fix | Delete
if ($data !== null) {
[371] Fix | Delete
echo '<script>', $data, '</script>';
[372] Fix | Delete
}
[373] Fix | Delete
echo '</div>';
[374] Fix | Delete
die;
[375] Fix | Delete
}
[376] Fix | Delete
[377] Fix | Delete
/**
[378] Fix | Delete
* Load module partial when update live content
[379] Fix | Delete
*/
[380] Fix | Delete
public static function load_module_partial_ajaxify() {
[381] Fix | Delete
check_ajax_referer('tf_nonce', 'nonce');
[382] Fix | Delete
themify_disable_other_lazy();
[383] Fix | Delete
Themify_Builder::$frontedit_active = true;
[384] Fix | Delete
Themify_Builder::$builder_active_id = $_POST['bid'];
[385] Fix | Delete
$new_modules = apply_filters('themify_builder_load_module_partial', array(
[386] Fix | Delete
'mod_name' => $_POST['tb_module_slug'],
[387] Fix | Delete
'mod_settings' => json_decode(stripslashes($_POST['tb_module_data']), true),
[388] Fix | Delete
'element_id' => $_POST['element_id']
[389] Fix | Delete
));
[390] Fix | Delete
[391] Fix | Delete
Themify_Builder_Component_Module::template($new_modules, Themify_Builder::$builder_active_id);
[392] Fix | Delete
$css = Themify_Enqueue_Assets::get_css();
[393] Fix | Delete
if (!empty($css)) {
[394] Fix | Delete
echo '<script type="text/template" id="tb_module_styles">', json_encode($css), '</script>';
[395] Fix | Delete
}
[396] Fix | Delete
wp_die();
[397] Fix | Delete
}
[398] Fix | Delete
[399] Fix | Delete
public static function render_element_ajaxify() {
[400] Fix | Delete
check_ajax_referer('tf_nonce', 'nonce');
[401] Fix | Delete
themify_disable_other_lazy();
[402] Fix | Delete
$response = array();
[403] Fix | Delete
$batch = json_decode(stripslashes($_POST['batch']), true);
[404] Fix | Delete
Themify_Builder::$frontedit_active = true;
[405] Fix | Delete
$batch = apply_filters('themify_builder_load_module_partial', $batch);
[406] Fix | Delete
Themify_Builder::$builder_active_id =$activeId= $_POST['bid'];
[407] Fix | Delete
if (!empty($_POST['tmpGS'])) {
[408] Fix | Delete
Themify_Global_Styles::$used_styles[$activeId] = Themify_Global_Styles::addGS($activeId, json_decode(stripslashes($_POST['tmpGS']), true));
[409] Fix | Delete
}
[410] Fix | Delete
if (!empty($batch)) {
[411] Fix | Delete
$used_gs = array();
[412] Fix | Delete
foreach ($batch as $b) {
[413] Fix | Delete
$type = $b['elType'];
[414] Fix | Delete
$element_id = $b['element_id'];
[415] Fix | Delete
switch ($type) {
[416] Fix | Delete
case 'module':
[417] Fix | Delete
if (isset($_POST['element_id'])) {
[418] Fix | Delete
$element_id = $b['element_id'] = $_POST['element_id'];
[419] Fix | Delete
}
[420] Fix | Delete
$markup = Themify_Builder_Component_Module::template($b, $activeId, false);
[421] Fix | Delete
break;
[422] Fix | Delete
[423] Fix | Delete
case 'subrow':
[424] Fix | Delete
unset($b['cols']);
[425] Fix | Delete
$markup = Themify_Builder_Component_SubRow::template($b, $activeId, false);
[426] Fix | Delete
break;
[427] Fix | Delete
[428] Fix | Delete
case 'column':
[429] Fix | Delete
unset($b['modules']);
[430] Fix | Delete
$markup = Themify_Builder_Component_Column::template($b, $activeId, false);
[431] Fix | Delete
break;
[432] Fix | Delete
[433] Fix | Delete
case 'row':
[434] Fix | Delete
unset($b['cols']);
[435] Fix | Delete
$markup = Themify_Builder_Component_Row::template($b, $activeId, false);
[436] Fix | Delete
break;
[437] Fix | Delete
}
[438] Fix | Delete
$response[$element_id] = $markup;
[439] Fix | Delete
if (!empty($b['attached_gs'])) {
[440] Fix | Delete
$used_gs = array_merge($used_gs, $b['attached_gs']);
[441] Fix | Delete
}
[442] Fix | Delete
}
[443] Fix | Delete
}
[444] Fix | Delete
$batch = null;
[445] Fix | Delete
if (!empty($used_gs)) {
[446] Fix | Delete
$used_gs = array_keys(array_flip($used_gs));
[447] Fix | Delete
// Return used gs
[448] Fix | Delete
$args = array(
[449] Fix | Delete
'exclude' => empty($_POST['loadedGS']) ? array() : $_POST['loadedGS'],
[450] Fix | Delete
'include' => $used_gs,
[451] Fix | Delete
'limit' => -1,
[452] Fix | Delete
'data' => true
[453] Fix | Delete
);
[454] Fix | Delete
[455] Fix | Delete
$used_gs = Themify_Global_Styles::get_global_styles($args);
[456] Fix | Delete
if (!empty($used_gs)) {
[457] Fix | Delete
$response['gs'] = $used_gs;
[458] Fix | Delete
}
[459] Fix | Delete
}
[460] Fix | Delete
$css = Themify_Enqueue_Assets::get_css();
[461] Fix | Delete
if (!empty($css)) {
[462] Fix | Delete
$response['tb_module_styles'] = $css;
[463] Fix | Delete
}
[464] Fix | Delete
//don't use wp_send_json it's very heavy,this array can be very large
[465] Fix | Delete
header('Content-Type: application/json; charset=' . get_option('blog_charset'));
[466] Fix | Delete
die(json_encode($response));
[467] Fix | Delete
}
[468] Fix | Delete
[469] Fix | Delete
public static function render_element_shortcode_ajaxify() {
[470] Fix | Delete
check_ajax_referer('tf_nonce', 'nonce');
[471] Fix | Delete
$shortcodes = $styles = array();
[472] Fix | Delete
$shortcode_data = json_decode(stripslashes_deep($_POST['shortcode_data']), true);
[473] Fix | Delete
[474] Fix | Delete
if (is_array($shortcode_data)) {
[475] Fix | Delete
if(!empty($_POST['bid'])){
[476] Fix | Delete
$p=get_post((int)$_POST['bid']);
[477] Fix | Delete
if(!empty($p)){
[478] Fix | Delete
$arr=array(
[479] Fix | Delete
'no_found_rows'=>false,
[480] Fix | Delete
'ignore_sticky_posts'=>true,
[481] Fix | Delete
'orderby'=>'none',
[482] Fix | Delete
'post_status'=>$p->post_status,
[483] Fix | Delete
'post_type'=>$p->post_type
[484] Fix | Delete
);
[485] Fix | Delete
if($p->post_type==='page'){
[486] Fix | Delete
$arr['page_id']=$p->ID;
[487] Fix | Delete
}else{
[488] Fix | Delete
$arr['p']=$p->ID;
[489] Fix | Delete
}
[490] Fix | Delete
query_posts($arr);
[491] Fix | Delete
unset($arr);
[492] Fix | Delete
global $post;
[493] Fix | Delete
$post=$p;
[494] Fix | Delete
setup_postdata( $post );
[495] Fix | Delete
}
[496] Fix | Delete
}
[497] Fix | Delete
foreach ($shortcode_data as $shortcode) {
[498] Fix | Delete
$shortcodes[] = array('key' => $shortcode, 'html' => Themify_Builder_Model::format_text($shortcode));
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function