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/clone/wp-conte.../plugins/themify-.../classes
File: class-themify-builder-admin.php
<?php
[0] Fix | Delete
defined('ABSPATH') || exit;
[1] Fix | Delete
[2] Fix | Delete
class Themify_Builder_Admin{
[3] Fix | Delete
[4] Fix | Delete
public static function init():void{
[5] Fix | Delete
global $pagenow;
[6] Fix | Delete
if ($pagenow === 'edit.php' || $pagenow === 'post-new.php') {
[7] Fix | Delete
$post_type = isset($_GET['post_type']) ? $_GET['post_type'] : 'post';
[8] Fix | Delete
} elseif ('post.php' === $pagenow && isset($_GET['post'])) {
[9] Fix | Delete
$post_type = get_post_type($_GET['post']);
[10] Fix | Delete
}
[11] Fix | Delete
if((empty($post_type) || !Themify_Builder_Model::is_builder_disabled_for_post_type($post_type))){
[12] Fix | Delete
self::run();
[13] Fix | Delete
}
[14] Fix | Delete
}
[15] Fix | Delete
[16] Fix | Delete
private static function run():void{
[17] Fix | Delete
// Filtered post types
[18] Fix | Delete
add_filter('themify_post_types', array(__CLASS__, 'extend_post_types'));
[19] Fix | Delete
add_action('admin_enqueue_scripts', array(__CLASS__, 'check_admin_interface'), 10);
[20] Fix | Delete
add_action('wp_ajax_tb_save_ajax_builder_mutiple_posts', array(__CLASS__, 'save_ajax_builder_mutiple_posts'));
[21] Fix | Delete
// Switch to frontend
[22] Fix | Delete
add_action('save_post', array(__CLASS__, 'switch_frontend'), 999, 1);
[23] Fix | Delete
// Disable WP Editor
[24] Fix | Delete
add_filter('is_protected_meta', array(__CLASS__, 'is_protected_meta'), 10, 3);
[25] Fix | Delete
add_filter( 'hidden_meta_boxes', [ __CLASS__, 'hidden_meta_boxes' ], 10, 3 );
[26] Fix | Delete
}
[27] Fix | Delete
[28] Fix | Delete
[29] Fix | Delete
/**
[30] Fix | Delete
* Includes this custom post to array of cpts managed by Themify
[31] Fix | Delete
* @param Array
[32] Fix | Delete
* @return Array
[33] Fix | Delete
*/
[34] Fix | Delete
public static function extend_post_types(array $types):array {
[35] Fix | Delete
static $post_types = null;
[36] Fix | Delete
if ($post_types === null) {
[37] Fix | Delete
$post_types = array_keys(array_flip(array_merge(
[38] Fix | Delete
Themify_Builder::$registered_post_types, array_values(get_post_types(array(
[39] Fix | Delete
'public' => true,
[40] Fix | Delete
'_builtin' => false,
[41] Fix | Delete
'show_ui' => true
[42] Fix | Delete
)))
[43] Fix | Delete
)));
[44] Fix | Delete
}
[45] Fix | Delete
return array_keys(array_flip(array_merge($types, $post_types)));
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
/**
[49] Fix | Delete
* Builder write panels
[50] Fix | Delete
*
[51] Fix | Delete
* @param $meta_boxes
[52] Fix | Delete
*
[53] Fix | Delete
* @return array
[54] Fix | Delete
*/
[55] Fix | Delete
public static function builder_write_panels(array $meta_boxes):array {
[56] Fix | Delete
if (Themify_Builder_Model::is_gutenberg_editor()) {
[57] Fix | Delete
return $meta_boxes;
[58] Fix | Delete
}
[59] Fix | Delete
// Page builder Options
[60] Fix | Delete
$page_builder_options = apply_filters('themify_builder_write_panels_options', array(
[61] Fix | Delete
array(
[62] Fix | Delete
'name' => 'page_builder',
[63] Fix | Delete
'title' => __('Themify Builder', 'themify'),
[64] Fix | Delete
'description' => '',
[65] Fix | Delete
'type' => 'page_builder'
[66] Fix | Delete
)
[67] Fix | Delete
));
[68] Fix | Delete
[69] Fix | Delete
$types = Themify_Builder::builder_post_types_support();
[70] Fix | Delete
$all_meta_boxes = array();
[71] Fix | Delete
foreach ($types as $type) {
[72] Fix | Delete
$all_meta_boxes[] = apply_filters('themify_builder_write_panels_meta_boxes', array(
[73] Fix | Delete
'name' => __('Themify Builder', 'themify'),
[74] Fix | Delete
'id' => 'page-builder',
[75] Fix | Delete
'options' => $page_builder_options,
[76] Fix | Delete
'pages' => $type
[77] Fix | Delete
));
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
return array_merge($meta_boxes, $all_meta_boxes);
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
/**
[84] Fix | Delete
* Add builder metabox
[85] Fix | Delete
*/
[86] Fix | Delete
public static function add_builder_metabox():void {
[87] Fix | Delete
include THEMIFY_BUILDER_INCLUDES_DIR . '/themify-builder-meta.php';
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
[91] Fix | Delete
[92] Fix | Delete
[93] Fix | Delete
/**
[94] Fix | Delete
* Load admin js and css
[95] Fix | Delete
*/
[96] Fix | Delete
public static function check_admin_interface(string $hook):void {
[97] Fix | Delete
if (in_array($hook, array('post-new.php', 'post.php'), true) && in_array(get_post_type(), themify_post_types(), true) && Themify_Access_Role::check_access_backend( get_the_ID() ) ) {
[98] Fix | Delete
add_action('admin_footer', array('Themify_Builder_Active', 'load_javascript_template_admin'), 10);
[99] Fix | Delete
add_filter('admin_body_class', array(__CLASS__, 'admin_body_class'), 10, 1);
[100] Fix | Delete
add_filter('mce_css', array(__CLASS__, 'static_badge_css'));
[101] Fix | Delete
add_filter('themify_do_metaboxes', array(__CLASS__, 'builder_write_panels'), 11);
[102] Fix | Delete
add_action('themify_builder_metabox', array(__CLASS__, 'add_builder_metabox'), 10);
[103] Fix | Delete
add_action('edit_form_after_title', array(__CLASS__, 'disable_wp_editor'), 99);
[104] Fix | Delete
}
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
[108] Fix | Delete
[109] Fix | Delete
/**
[110] Fix | Delete
* Switch to frontend
[111] Fix | Delete
*/
[112] Fix | Delete
public static function switch_frontend(?int $post_id) {
[113] Fix | Delete
//verify post is not a revision
[114] Fix | Delete
if (isset($_POST['tb_switch_frontend']) && $_POST['tb_switch_frontend'] === 'yes' && Themify_Builder::$builder_is_saving !== true && !wp_is_post_revision($post_id)) {
[115] Fix | Delete
$post_url = get_permalink($post_id);
[116] Fix | Delete
wp_redirect(themify_https_esc($post_url) . '#builder_active');
[117] Fix | Delete
exit;
[118] Fix | Delete
}
[119] Fix | Delete
}
[120] Fix | Delete
[121] Fix | Delete
[122] Fix | Delete
/**
[123] Fix | Delete
* Disable WP Editor
[124] Fix | Delete
*/
[125] Fix | Delete
public static function disable_wp_editor():void {
[126] Fix | Delete
if (themify_builder_get('setting-page_builder_disable_wp_editor', 'builder_disable_wp_editor') && themify_builder_get('setting-page_builder_is_active') !== 'disable') {
[127] Fix | Delete
echo '<div class="tb_wp_editor_holder">
[128] Fix | Delete
<a href="' . get_permalink() . '#builder_active">' . esc_html__('Edit With Themify Builder', 'themify') . '</a>
[129] Fix | Delete
</div>';
[130] Fix | Delete
}
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
/**
[134] Fix | Delete
* Hide Builder meta fields from Custom Fields admin panel
[135] Fix | Delete
*
[136] Fix | Delete
* @hooked to "is_protected_meta"
[137] Fix | Delete
*/
[138] Fix | Delete
public static function is_protected_meta(bool $protected, $meta_key, $meta_type):bool {
[139] Fix | Delete
if ($meta_key === 'tbp_custom_css') {
[140] Fix | Delete
$protected = true;
[141] Fix | Delete
}
[142] Fix | Delete
return $protected;
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
[146] Fix | Delete
/**
[147] Fix | Delete
* Register css in tinymce editor.
[148] Fix | Delete
*/
[149] Fix | Delete
public static function static_badge_css(string $mce_css):string {
[150] Fix | Delete
$mce_css .= ', ' . THEMIFY_BUILDER_URI . '/css/editor/backend/themify-builder-static-badge.css';
[151] Fix | Delete
return $mce_css;
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
public static function admin_body_class(?string $classes): string {
[155] Fix | Delete
return $classes . ' builder-breakpoint-desktop tb_panel_closed';
[156] Fix | Delete
}
[157] Fix | Delete
[158] Fix | Delete
public static function save_ajax_builder_mutiple_posts() {
[159] Fix | Delete
check_ajax_referer('tf_nonce', 'nonce');
[160] Fix | Delete
if (current_user_can('edit_pages')) {
[161] Fix | Delete
if (isset($_POST['data'])) {
[162] Fix | Delete
$data = stripslashes_deep($_POST['data']);
[163] Fix | Delete
} elseif (isset($_FILES['data'])) {
[164] Fix | Delete
$data = file_get_contents($_FILES['data']['tmp_name']);
[165] Fix | Delete
}
[166] Fix | Delete
if (!empty($data)) {
[167] Fix | Delete
$data = json_decode($data, true);
[168] Fix | Delete
$results = array();
[169] Fix | Delete
foreach ($data as $post_id => $builder) {
[170] Fix | Delete
if (current_user_can('edit_post', $post_id)) {
[171] Fix | Delete
$res = ThemifyBuilder_Data_Manager::save_data($builder, $post_id);
[172] Fix | Delete
$results[$post_id] = !empty($res['mid']) ? 1 : sprintf(__('Can`t save builder data of post "%s"', 'themify'), get_the_title($post_id));
[173] Fix | Delete
} else {
[174] Fix | Delete
$results[$post_id] = sprintf(__('You don`t have permission to edit post "%s"', 'themify'), get_the_title($post_id));
[175] Fix | Delete
}
[176] Fix | Delete
}
[177] Fix | Delete
wp_send_json_success($results);
[178] Fix | Delete
}
[179] Fix | Delete
} else {
[180] Fix | Delete
wp_send_json_error(__('You don`t have permission to edit pages', 'themify'));
[181] Fix | Delete
}
[182] Fix | Delete
wp_send_json_error();
[183] Fix | Delete
}
[184] Fix | Delete
[185] Fix | Delete
/**
[186] Fix | Delete
* prevent hiding the Themify Custom Panel on Builder's templating post types
[187] Fix | Delete
*/
[188] Fix | Delete
public static function hidden_meta_boxes( $hidden, $screen, $use_defaults ) : array {
[189] Fix | Delete
if ( $screen->base === 'post' && in_array( $screen->post_type, [ Themify_Builder_Layouts::LAYOUT_PART_SLUG, Themify_Builder_Layouts::LAYOUT_SLUG, 'tbp_template' ], true ) ) {
[190] Fix | Delete
$themify_metabox = array_search( 'themify-meta-boxes', $hidden, true );
[191] Fix | Delete
if ( $themify_metabox !== false ) {
[192] Fix | Delete
unset( $hidden[ $themify_metabox ] );
[193] Fix | Delete
}
[194] Fix | Delete
}
[195] Fix | Delete
[196] Fix | Delete
return $hidden;
[197] Fix | Delete
}
[198] Fix | Delete
}
[199] Fix | Delete
Themify_Builder_Admin::init();
[200] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function