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-global-styles.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* This file defines Global Styles
[2] Fix | Delete
*
[3] Fix | Delete
* Themify_Global_Styles class register post type for Global Styles and load them
[4] Fix | Delete
*
[5] Fix | Delete
*
[6] Fix | Delete
* @package Themify_Builder
[7] Fix | Delete
* @subpackage Themify_Builder/classes
[8] Fix | Delete
*/
[9] Fix | Delete
if (!class_exists('Themify_Global_Styles',false)) :
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* The Global Styles class.
[13] Fix | Delete
*
[14] Fix | Delete
* This class register post type for Global Styles and load them.
[15] Fix | Delete
*
[16] Fix | Delete
*
[17] Fix | Delete
* @package Themify_Builder
[18] Fix | Delete
* @subpackage Themify_Builder/classes
[19] Fix | Delete
* @author Themify
[20] Fix | Delete
*/
[21] Fix | Delete
final class Themify_Global_Styles {
[22] Fix | Delete
[23] Fix | Delete
const SLUG = 'tglobal_style';
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* Post Type Global Styles Object.
[27] Fix | Delete
*
[28] Fix | Delete
* @access private
[29] Fix | Delete
* @var object $used_styles .
[30] Fix | Delete
*/
[31] Fix | Delete
public static $used_styles = array();
[32] Fix | Delete
[33] Fix | Delete
/**
[34] Fix | Delete
* Constructor
[35] Fix | Delete
*
[36] Fix | Delete
* @access public
[37] Fix | Delete
*/
[38] Fix | Delete
public static $isGlobalEditPage = false;
[39] Fix | Delete
[40] Fix | Delete
public static function init() {
[41] Fix | Delete
self::register_global_style();
[42] Fix | Delete
if (is_admin()) {
[43] Fix | Delete
add_filter('themify_post_types', array(__CLASS__, 'extend_post_types'));
[44] Fix | Delete
add_filter('themify_exclude_CPT_for_sidebar', array(__CLASS__, 'extend_post_types'));
[45] Fix | Delete
add_action('wp_ajax_tb_save_custom_global_style', array(__CLASS__, 'save_custom_global_style_ajaxify'), 10);
[46] Fix | Delete
add_action('wp_ajax_tb_delete_global_style', array(__CLASS__, 'delete_global_style_ajaxify'), 10);
[47] Fix | Delete
add_action('wp_ajax_tb_restore_global_style', array(__CLASS__, 'restore_global_style_ajaxify'), 10);
[48] Fix | Delete
add_filter('themify_builder_post_types_support', array(__CLASS__, 'add_builder_support'));
[49] Fix | Delete
add_action('admin_enqueue_scripts', array(__CLASS__, 'enqueue_admin_scripts'), 25);
[50] Fix | Delete
add_action('wp_ajax_tb_save_as_new_global_style', array(__CLASS__, 'save_as_new_ajax'), 10);
[51] Fix | Delete
add_action('wp_ajax_tb_update_global_style', array(__CLASS__, 'update_live'), 10);
[52] Fix | Delete
add_action('wp_ajax_tb_get_gs_posts', array(__CLASS__, 'get_posts_ajax'), 10);
[53] Fix | Delete
add_action('wp_ajax_tb_import_gs_posts_ajax', array(__CLASS__, 'import_posts_ajax'), 10);
[54] Fix | Delete
add_action('wp_ajax_tb_get_gs_post', array(__CLASS__, 'wp_ajax_tb_get_gs_post'));
[55] Fix | Delete
} else {
[56] Fix | Delete
add_filter('template_include', array(__CLASS__, 'template_singular_global_style'));
[57] Fix | Delete
}
[58] Fix | Delete
add_filter('themify_builder_active_vars', array(__CLASS__, 'localize_data'));
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* Register Global Style Custom Post Type
[63] Fix | Delete
*
[64] Fix | Delete
* @access static
[65] Fix | Delete
*/
[66] Fix | Delete
private static function register_global_style() {
[67] Fix | Delete
if (!class_exists('CPT',false)) {
[68] Fix | Delete
include_once THEMIFY_DIR . '/CPT.php';
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
// create a template custom post type
[72] Fix | Delete
$cpt = new CPT(array(
[73] Fix | Delete
'post_type_name' => self::SLUG,
[74] Fix | Delete
'singular' => __('Global Style', 'themify'),
[75] Fix | Delete
'plural' => __('Global Styles', 'themify')
[76] Fix | Delete
), array(
[77] Fix | Delete
'supports' => array('title'),
[78] Fix | Delete
'exclude_from_search' => true,
[79] Fix | Delete
'show_in_nav_menus' => false,
[80] Fix | Delete
'show_in_menu' => false,
[81] Fix | Delete
'public' => true,
[82] Fix | Delete
'has_archive' => false
[83] Fix | Delete
));
[84] Fix | Delete
[85] Fix | Delete
// define the columns to appear on the admin edit screen
[86] Fix | Delete
$cpt->columns(array(
[87] Fix | Delete
'title' => __('Title', 'themify')
[88] Fix | Delete
));
[89] Fix | Delete
[90] Fix | Delete
// use "pages" icon for post type
[91] Fix | Delete
$cpt->menu_icon('dashicons-admin-page');
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
/**
[95] Fix | Delete
* Includes this custom post to array of cpts managed by Themify
[96] Fix | Delete
*/
[97] Fix | Delete
static function extend_post_types(array $types):array {
[98] Fix | Delete
unset($types[self::SLUG]);
[99] Fix | Delete
$types[] = self::SLUG;
[100] Fix | Delete
return $types;
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
/**
[104] Fix | Delete
* Global Style for Template (Editor).
[105] Fix | Delete
*/
[106] Fix | Delete
static function template_singular_global_style(?string $original_template):?string {
[107] Fix | Delete
if (is_singular(self::SLUG)) {
[108] Fix | Delete
self::$isGlobalEditPage = true;
[109] Fix | Delete
$original_template = THEMIFY_BUILDER_TEMPLATES_DIR . '/template-builder-editor.php';
[110] Fix | Delete
}
[111] Fix | Delete
return $original_template;
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
/**
[115] Fix | Delete
* Handle Ajax request for add new Global Style
[116] Fix | Delete
*
[117] Fix | Delete
* @access static
[118] Fix | Delete
*/
[119] Fix | Delete
static function save_custom_global_style_ajaxify() {
[120] Fix | Delete
check_ajax_referer('tf_nonce', 'nonce');
[121] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[122] Fix | Delete
die;
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
$data = $response = array();
[126] Fix | Delete
if (isset($_POST['form_data'])) {
[127] Fix | Delete
parse_str($_POST['form_data'], $data);
[128] Fix | Delete
$insert_post = self::add_new($data);
[129] Fix | Delete
if (false === $insert_post) {
[130] Fix | Delete
$response['status'] = 'failed';
[131] Fix | Delete
$response['msg'] = __('Something went wrong', 'themify');
[132] Fix | Delete
} else {
[133] Fix | Delete
$response['status'] = 'success';
[134] Fix | Delete
$response['url'] = $insert_post['url'] . '#builder_active';
[135] Fix | Delete
}
[136] Fix | Delete
}
[137] Fix | Delete
wp_send_json($response);
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
/**
[141] Fix | Delete
* Handle Ajax request for save as new global style from a module
[142] Fix | Delete
*
[143] Fix | Delete
* @access static
[144] Fix | Delete
*/
[145] Fix | Delete
static function save_as_new_ajax() {
[146] Fix | Delete
check_ajax_referer('tf_nonce', 'nonce');
[147] Fix | Delete
if (empty($_POST['title']) || empty($_POST['type']) || empty($_POST['styles'])) {
[148] Fix | Delete
return false;
[149] Fix | Delete
}
[150] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[151] Fix | Delete
die;
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
$args = array(
[155] Fix | Delete
'style-name' => $_POST['title'],
[156] Fix | Delete
'style-type' => $_POST['type'],
[157] Fix | Delete
'styles' => json_decode(stripslashes_deep($_POST['styles']), true)
[158] Fix | Delete
);
[159] Fix | Delete
$insert_post = self::add_new($args);
[160] Fix | Delete
if (false === $insert_post) {
[161] Fix | Delete
$response['status'] = 'failed';
[162] Fix | Delete
$response['msg'] = __('Something went wrong', 'themify');
[163] Fix | Delete
} else {
[164] Fix | Delete
$response['status'] = 'success';
[165] Fix | Delete
$response['post_data'] = $insert_post;
[166] Fix | Delete
$response['msg'] = __('Global Style has been saved!', 'themify');
[167] Fix | Delete
}
[168] Fix | Delete
wp_send_json($response);
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
/**
[172] Fix | Delete
* Handle Ajax request for updating a global style
[173] Fix | Delete
*
[174] Fix | Delete
* @access static
[175] Fix | Delete
*/
[176] Fix | Delete
static function update_live() {
[177] Fix | Delete
check_ajax_referer('tf_nonce', 'nonce');
[178] Fix | Delete
if (empty($_POST['bid']) || empty($_POST['data'])) {
[179] Fix | Delete
return false;
[180] Fix | Delete
}
[181] Fix | Delete
if ( ! current_user_can( 'edit_post', $_POST['bid'] ) ) {
[182] Fix | Delete
die;
[183] Fix | Delete
}
[184] Fix | Delete
[185] Fix | Delete
ThemifyBuilder_Data_Manager::save_data(stripslashes_deep($_POST['data']), $_POST['bid']);
[186] Fix | Delete
$response['status'] = 'success';
[187] Fix | Delete
wp_send_json($response);
[188] Fix | Delete
}
[189] Fix | Delete
[190] Fix | Delete
/**
[191] Fix | Delete
* Handle Ajax request for get global style posts
[192] Fix | Delete
*
[193] Fix | Delete
* @access static
[194] Fix | Delete
*/
[195] Fix | Delete
static function get_posts_ajax() {
[196] Fix | Delete
check_ajax_referer('tf_nonce', 'nonce');
[197] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[198] Fix | Delete
die;
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
$loaded = !empty($_POST['loaded']) ? $_POST['loaded'] : array();
[202] Fix | Delete
$args = array(
[203] Fix | Delete
'limit' => 10,
[204] Fix | Delete
'data' => true,
[205] Fix | Delete
'order' => 'ASC',
[206] Fix | Delete
'orderby' => 'title',
[207] Fix | Delete
'loaded' => $loaded
[208] Fix | Delete
);
[209] Fix | Delete
if (!empty($_POST['s'])) {
[210] Fix | Delete
$args['limit'] = 50;
[211] Fix | Delete
$args['search'] = sanitize_text_field($_POST['s']);
[212] Fix | Delete
}
[213] Fix | Delete
$globalStyles = self::get_global_styles($args);
[214] Fix | Delete
wp_send_json($globalStyles);
[215] Fix | Delete
}
[216] Fix | Delete
[217] Fix | Delete
/**
[218] Fix | Delete
* Insert new Global Style
[219] Fix | Delete
*
[220] Fix | Delete
* @access static
[221] Fix | Delete
* @param array $args
[222] Fix | Delete
* @return Mixed return false if fails or array of info about inserted post if success
[223] Fix | Delete
*/
[224] Fix | Delete
public static function add_new($args, $action = 'new') {
[225] Fix | Delete
[226] Fix | Delete
if (empty($args['style-name'])) {
[227] Fix | Delete
return false;
[228] Fix | Delete
}
[229] Fix | Delete
$name = sanitize_text_field($args['style-name']);
[230] Fix | Delete
$type = sanitize_text_field($args['style-type']);
[231] Fix | Delete
if ($type === 'subcolumn') {
[232] Fix | Delete
$type = 'column';
[233] Fix | Delete
} elseif ($type === 'subrow') {
[234] Fix | Delete
$type = 'row';
[235] Fix | Delete
}
[236] Fix | Delete
$module_type = 'row' === $type || 'column' === $type ? 'text' : $type;
[237] Fix | Delete
$rowStyling = $colStyling = $moduleStyling = '{}';
[238] Fix | Delete
$default = array();
[239] Fix | Delete
if ('text' === $module_type) {
[240] Fix | Delete
$default['content_text'] = '<h1>Heading 1</h1><h2>Heading 2</h2><h3>Heading 3</h3><h4>Heading 4</h4><p>This is a sample Text module.</p>';
[241] Fix | Delete
}
[242] Fix | Delete
if (!empty($args['styles'])) {
[243] Fix | Delete
[244] Fix | Delete
if (is_array($args['styles']) && !empty($args['styles'][0])) {
[245] Fix | Delete
$args['styles'] = $args['styles'][0];
[246] Fix | Delete
if ($type !== 'row') {
[247] Fix | Delete
$args['styles'] = !empty($args['styles']['cols']) ? $args['styles']['cols'][0] : array();
[248] Fix | Delete
}
[249] Fix | Delete
if ($type === 'column' || $type === 'row') {
[250] Fix | Delete
$args['styles'] = isset($args['styling']) ? $args['styling'] : array();
[251] Fix | Delete
} else {
[252] Fix | Delete
$args['styles'] = !empty($args['styles']['modules']) ? $args['styles']['modules'][0]['mod_settings'] : array();
[253] Fix | Delete
}
[254] Fix | Delete
if (empty($args['styles'])) {
[255] Fix | Delete
return false;
[256] Fix | Delete
}
[257] Fix | Delete
}
[258] Fix | Delete
switch ($type) {
[259] Fix | Delete
case 'row':
[260] Fix | Delete
$rowStyling = json_encode($args['styles']);
[261] Fix | Delete
break;
[262] Fix | Delete
case 'column':
[263] Fix | Delete
$colStyling = json_encode($args['styles']);
[264] Fix | Delete
break;
[265] Fix | Delete
default:
[266] Fix | Delete
$args['styles'] = array_merge($default, $args['styles']);
[267] Fix | Delete
$moduleStyling = json_encode($args['styles']);
[268] Fix | Delete
}
[269] Fix | Delete
} else {
[270] Fix | Delete
$moduleStyling = json_encode($default);
[271] Fix | Delete
}
[272] Fix | Delete
if ('row' === $type || 'column' === $type) {
[273] Fix | Delete
$moduleStyling = json_encode($default);
[274] Fix | Delete
}
[275] Fix | Delete
$id = uniqid();
[276] Fix | Delete
$builder_content = '[{"element_id":"row' . $id . '","styling":' . $rowStyling . ',"cols":[{"element_id":"col' . $id . '","grid_class":"col-full","styling":' . $colStyling . ',"modules":[{"element_id":"mod' . $id . '","mod_name":"' . $module_type . '","mod_settings":' . $moduleStyling . '}]}]}]';
[277] Fix | Delete
if ('import' === $action) {
[278] Fix | Delete
$new_id = $args['id'];
[279] Fix | Delete
update_post_meta($new_id, 'themify_global_style_type', $type);
[280] Fix | Delete
}
[281] Fix | Delete
else {
[282] Fix | Delete
$new_id = wp_insert_post(array(
[283] Fix | Delete
'post_status' => 'publish',
[284] Fix | Delete
'post_type' => self::SLUG,
[285] Fix | Delete
'post_title' => $name,
[286] Fix | Delete
'post_name' => !empty($args['slug']) ? $args['slug'] : '',
[287] Fix | Delete
'meta_input' => array(
[288] Fix | Delete
'themify_global_style_type' => $type,
[289] Fix | Delete
'hide_page_title' => 'yes'
[290] Fix | Delete
),
[291] Fix | Delete
));
[292] Fix | Delete
}
[293] Fix | Delete
if (!is_wp_error($new_id)) {
[294] Fix | Delete
ThemifyBuilder_Data_Manager::save_data($builder_content, $new_id);
[295] Fix | Delete
if (empty($args['slug'])) {
[296] Fix | Delete
$post_slug = 'tb_gs' . $new_id . substr(uniqid(), 0, 3);
[297] Fix | Delete
wp_update_post(array(
[298] Fix | Delete
'ID' => $new_id,
[299] Fix | Delete
'post_name' => $post_slug
[300] Fix | Delete
));
[301] Fix | Delete
}
[302] Fix | Delete
else {
[303] Fix | Delete
$post_slug = $args['slug'];
[304] Fix | Delete
}
[305] Fix | Delete
if ('import' === $action) {
[306] Fix | Delete
$result = array(
[307] Fix | Delete
'builder_data' => ThemifyBuilder_Data_Manager::get_data($new_id),
[308] Fix | Delete
'gsType' => $type
[309] Fix | Delete
);
[310] Fix | Delete
} else {
[311] Fix | Delete
$result = array(
[312] Fix | Delete
'id' => $new_id,
[313] Fix | Delete
'class' => $post_slug,
[314] Fix | Delete
'title' => $name,
[315] Fix | Delete
'type' => $type,
[316] Fix | Delete
'url' => get_post_permalink($new_id),
[317] Fix | Delete
'data' => ThemifyBuilder_Data_Manager::get_data($new_id),
[318] Fix | Delete
);
[319] Fix | Delete
}
[320] Fix | Delete
} else {
[321] Fix | Delete
//there was an error in the post insertion,
[322] Fix | Delete
$result = false;
[323] Fix | Delete
}
[324] Fix | Delete
return $result;
[325] Fix | Delete
}
[326] Fix | Delete
[327] Fix | Delete
/**
[328] Fix | Delete
* Add Builder support to Global Style post type.
[329] Fix | Delete
* @param array $post_types
[330] Fix | Delete
* @access static
[331] Fix | Delete
* @return array
[332] Fix | Delete
*/
[333] Fix | Delete
static function add_builder_support(array $post_types):array {
[334] Fix | Delete
$post_types[self::SLUG] = self::SLUG;
[335] Fix | Delete
return $post_types;
[336] Fix | Delete
}
[337] Fix | Delete
[338] Fix | Delete
/**
[339] Fix | Delete
* Return Global Styles page content
[340] Fix | Delete
*
[341] Fix | Delete
* @access static
[342] Fix | Delete
* @return String
[343] Fix | Delete
*/
[344] Fix | Delete
public static function page_content() {
[345] Fix | Delete
$page_status = empty($_GET['status']) ? 'publish' : sanitize_text_field($_GET['status']);
[346] Fix | Delete
$args = array(
[347] Fix | Delete
'preview' => true,
[348] Fix | Delete
'status' => $page_status,
[349] Fix | Delete
'limit' => 20,
[350] Fix | Delete
'paged' => isset($_GET['pagenum']) ? absint($_GET['pagenum']) : 1
[351] Fix | Delete
);
[352] Fix | Delete
$search = !empty($_GET['s']) ? sanitize_text_field($_GET['s']) : '';
[353] Fix | Delete
if (!empty($search)) {
[354] Fix | Delete
$args['search'] = $search;
[355] Fix | Delete
}
[356] Fix | Delete
$globalStyles = self::get_global_styles($args);
[357] Fix | Delete
if (!empty($globalStyles)) {
[358] Fix | Delete
themify_enque_style('themify-builder-style', THEMIFY_BUILDER_URI . '/css/themify-builder-style.css', null, THEMIFY_VERSION, '', true);
[359] Fix | Delete
if (is_rtl()) {
[360] Fix | Delete
themify_enque_style('themify-builder-style-rtl', THEMIFY_BUILDER_URI . '/css/themify-builder-style-rtl.css', null, THEMIFY_VERSION, '', true);
[361] Fix | Delete
}
[362] Fix | Delete
Themify_Enqueue_Assets::loadMainScript();
[363] Fix | Delete
Themify_Builder::footer_js();
[364] Fix | Delete
themify_enque_script('themify-builder-js', THEMIFY_BUILDER_URI . '/js/themify-builder-script.js');
[365] Fix | Delete
}
[366] Fix | Delete
// Enqueue media scripts
[367] Fix | Delete
wp_enqueue_media();
[368] Fix | Delete
?>
[369] Fix | Delete
<div id="tb_admin_gs_container" class="wrap">
[370] Fix | Delete
<!-- Just used for admin notice placement-->
[371] Fix | Delete
<h2 style="display: none;"></h2>
[372] Fix | Delete
<h3 class="page-title"><?php _e('Global Styles', 'themify'); ?></h3>
[373] Fix | Delete
<a href="#tb_new_gs_form"
[374] Fix | Delete
class="page-title-action tb_add_new_gs"><?php _e('Add new', 'themify') ?></a>
[375] Fix | Delete
<a href="#" class="page-title-action tb_import_gs"><?php _e('Import from file', 'themify') ?></a>
[376] Fix | Delete
<div class="tb_gs_admin_page_header">
[377] Fix | Delete
<div class="tb_gs_post_status">
[378] Fix | Delete
<a <?php echo 'publish' === $page_status ? 'class="tb_gs_active_page"' : ''; ?>
[379] Fix | Delete
href="<?php echo admin_url('admin.php?page=themify-global-styles&status=publish'); ?>"><?php _e('Published', 'themify'); ?></a>
[380] Fix | Delete
<a <?php echo 'trash' === $page_status ? 'class="tb_gs_active_page"' : ''; ?>
[381] Fix | Delete
href="<?php echo admin_url('admin.php?page=themify-global-styles&status=trash'); ?>"><?php _e('Trash', 'themify'); ?></a>
[382] Fix | Delete
</div>
[383] Fix | Delete
<div class="tb_gs_admin_search">
[384] Fix | Delete
<form>
[385] Fix | Delete
<input type="text" name="s" value="<?php echo!empty($search) ? esc_attr($search) : ''; ?>">
[386] Fix | Delete
<input type="hidden" name="page" value="themify-global-styles">
[387] Fix | Delete
<input type="hidden" name="status" value="<?php echo esc_attr($page_status); ?>">
[388] Fix | Delete
<button type="submit"><?php _e('Search', 'themify'); ?></button>
[389] Fix | Delete
</form>
[390] Fix | Delete
</div>
[391] Fix | Delete
</div>
[392] Fix | Delete
<?php if (!empty($search)): ?>
[393] Fix | Delete
<h3><?php echo sprintf(__('Search Results for %s', 'themify'), $search); ?></h3>
[394] Fix | Delete
<?php endif; ?>
[395] Fix | Delete
<div class="tb_admin_gs_list" data-list="<?php echo esc_attr($page_status); ?>">
[396] Fix | Delete
<?php if (!empty($globalStyles)): ?>
[397] Fix | Delete
<?php
[398] Fix | Delete
foreach ($globalStyles as $style) :
[399] Fix | Delete
Themify_Builder_Stylesheet::enqueue_stylesheet(false, $style['id']);
[400] Fix | Delete
?>
[401] Fix | Delete
<div class="tb_gs_element">
[402] Fix | Delete
<div class="tb_gs_thumbnail_container">
[403] Fix | Delete
<span class="tb_admin_gs_type"><?php echo $style['type']; ?></span>
[404] Fix | Delete
[405] Fix | Delete
<?php if ( current_user_can( 'delete_post', $style['id'] ) ) : ?>
[406] Fix | Delete
<a href="#" class="tb_remove_gs tf_close" data-id="<?php echo $style['id']; ?>"></a>
[407] Fix | Delete
<?php endif; ?>
[408] Fix | Delete
[409] Fix | Delete
<?php if ('publish' === $page_status): ?>
[410] Fix | Delete
<a href="#" target="_blank" class="tb_gs_export tb_export" data-title="<?php echo esc_attr($style['title']); ?>" data-id="<?php echo $style['id']; ?>"><?php echo themify_get_icon('export', 'ti'); ?></a>
[411] Fix | Delete
<?php else: ?>
[412] Fix | Delete
<?php if ( current_user_can( 'delete_post', $style['id'] ) ) : ?>
[413] Fix | Delete
<a href="#" class="tb_gs_restore" data-id="<?php echo $style['id']; ?>"><?php echo themify_get_icon('back-left', 'ti'); ?></a>
[414] Fix | Delete
<?php endif; ?>
[415] Fix | Delete
<?php endif; ?>
[416] Fix | Delete
<div data-builder="<?php echo esc_url($style['url']); ?>#builder_active"
[417] Fix | Delete
class="tb_gs_preview_container">
[418] Fix | Delete
<a href="<?php echo 'publish' === $page_status ? esc_url($style['url']) . '#builder_active' : '#'; ?>"
[419] Fix | Delete
class="tb_gs_preview_overlay"></a>
[420] Fix | Delete
<?php echo $style['preview']; ?>
[421] Fix | Delete
</div>
[422] Fix | Delete
</div>
[423] Fix | Delete
<span class="tb_admin_gs_title"><?php echo $style['title']; ?></span>
[424] Fix | Delete
</div>
[425] Fix | Delete
<?php endforeach; ?>
[426] Fix | Delete
<?php else: ?>
[427] Fix | Delete
<p class="wp-heading-inline"><?php _e('No Global Styles found.', 'themify'); ?></p>
[428] Fix | Delete
<?php endif; ?>
[429] Fix | Delete
</div>
[430] Fix | Delete
<?php self::add_new_form(); ?>
[431] Fix | Delete
<?php self::pagination(); ?>
[432] Fix | Delete
</div>
[433] Fix | Delete
<?php
[434] Fix | Delete
Themify_Builder_Stylesheet::load_styles();
[435] Fix | Delete
}
[436] Fix | Delete
[437] Fix | Delete
/**
[438] Fix | Delete
* Admin page pagination
[439] Fix | Delete
*
[440] Fix | Delete
* @return String
[441] Fix | Delete
*/
[442] Fix | Delete
private static function pagination():void {
[443] Fix | Delete
$count_posts = wp_count_posts(self::SLUG);
[444] Fix | Delete
if (isset($count_posts->publish)){
[445] Fix | Delete
$limit = 20;
[446] Fix | Delete
$total = $count_posts->publish;
[447] Fix | Delete
$num_of_pages = ceil($total / $limit);
[448] Fix | Delete
$page_links = paginate_links(array(
[449] Fix | Delete
'base' => add_query_arg('pagenum', '%#%'),
[450] Fix | Delete
'format' => '',
[451] Fix | Delete
'prev_text' => __('«', 'text-domain'),
[452] Fix | Delete
'next_text' => __('»', 'text-domain'),
[453] Fix | Delete
'total' => $num_of_pages,
[454] Fix | Delete
'current' => isset($_GET['pagenum']) ? absint($_GET['pagenum']) : 1
[455] Fix | Delete
));
[456] Fix | Delete
[457] Fix | Delete
if ($page_links) {
[458] Fix | Delete
echo '<div class="tablenav"><div class="tablenav-pages">' , $page_links , '</div></div>';
[459] Fix | Delete
}
[460] Fix | Delete
}
[461] Fix | Delete
}
[462] Fix | Delete
[463] Fix | Delete
/**
[464] Fix | Delete
* Create add new Global Style form
[465] Fix | Delete
*
[466] Fix | Delete
* @return String
[467] Fix | Delete
*/
[468] Fix | Delete
private static function add_new_form():void {
[469] Fix | Delete
$excludes = array('page-break', 'divider', 'widget', 'widgetized', 'layout-part', 'plain-text');
[470] Fix | Delete
$modules=Themify_Builder_Component_Module::load_modules();
[471] Fix | Delete
?>
[472] Fix | Delete
<div id="tb_new_gs_form">
[473] Fix | Delete
<div class="tb_gs_form_header">
[474] Fix | Delete
<span class="tb_gs_form_title"><?php _e('New Style', 'themify'); ?></span>
[475] Fix | Delete
</div>
[476] Fix | Delete
<div class="tb_gs_form_body">
[477] Fix | Delete
<form id="tb_admin_new_gs">
[478] Fix | Delete
<div class="tb_gs_input_container">
[479] Fix | Delete
<label for="style-name"><?php _e('Style Name', 'themify'); ?></label>
[480] Fix | Delete
<input type="text" id="style-name" name="style-name">
[481] Fix | Delete
</div>
[482] Fix | Delete
<div class="tb_gs_input_container">
[483] Fix | Delete
<label for="style-type"><?php _e('Type', 'themify'); ?></label>
[484] Fix | Delete
<div class="tb_gs_type_container">
[485] Fix | Delete
<select id="style-type" name="style-type">
[486] Fix | Delete
<option value="row"><?php _e('Row', 'themify'); ?></option>
[487] Fix | Delete
<option value="column"><?php _e('Column', 'themify'); ?></option>
[488] Fix | Delete
<?php foreach ($modules as $slug => $module): ?>
[489] Fix | Delete
<?php if (!in_array($slug, $excludes, true)): ?>
[490] Fix | Delete
<option value="<?php echo $slug; ?>"><?php echo $module::get_module_name($slug); ?></option>
[491] Fix | Delete
<?php endif; ?>
[492] Fix | Delete
<?php endforeach; ?>
[493] Fix | Delete
</select>
[494] Fix | Delete
</div>
[495] Fix | Delete
</div>
[496] Fix | Delete
</form>
[497] Fix | Delete
</div>
[498] Fix | Delete
<div class="tb_gs_form_footer">
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function