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

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/popup-bu.../com/helpers
File: AdminHelper.php
$rolesToBeRestricted = array();
[2000] Fix | Delete
// selected user roles, which have access to the PB
[2001] Fix | Delete
foreach ($allAvailableWpRoles as $allAvailableWpRole) {
[2002] Fix | Delete
if (isset($allAvailableWpRole['name']) && in_array(lcfirst($allAvailableWpRole['name']), $savedUserRoles)) {
[2003] Fix | Delete
$indexToUnset = lcfirst($allAvailableWpRole['name']);
[2004] Fix | Delete
continue;
[2005] Fix | Delete
}
[2006] Fix | Delete
$rolesToBeRestricted[] = lcfirst($allAvailableWpRole['name']);
[2007] Fix | Delete
}
[2008] Fix | Delete
[2009] Fix | Delete
$caps = array(
[2010] Fix | Delete
'read_private_sgpb_popups',
[2011] Fix | Delete
'edit_sgpb_popup',
[2012] Fix | Delete
'edit_sgpb_popups',
[2013] Fix | Delete
'edit_others_sgpb_popups',
[2014] Fix | Delete
'edit_published_sgpb_popups',
[2015] Fix | Delete
'publish_sgpb_popups',
[2016] Fix | Delete
'delete_sgpb_popups',
[2017] Fix | Delete
'delete_published_posts',
[2018] Fix | Delete
'delete_others_sgpb_popups',
[2019] Fix | Delete
'delete_private_sgpb_popups',
[2020] Fix | Delete
'delete_private_sgpb_popup',
[2021] Fix | Delete
'delete_published_sgpb_popups',
[2022] Fix | Delete
'sgpb_manage_options',
[2023] Fix | Delete
'manage_popup_terms',
[2024] Fix | Delete
'manage_popup_categories_terms'
[2025] Fix | Delete
);
[2026] Fix | Delete
[2027] Fix | Delete
if ($hook == 'activate') {
[2028] Fix | Delete
$rolesToBeRestricted = $savedUserRoles;
[2029] Fix | Delete
}
[2030] Fix | Delete
foreach ($rolesToBeRestricted as $roleToBeRestricted) {
[2031] Fix | Delete
if ($roleToBeRestricted == 'administrator' || $roleToBeRestricted == 'admin') {
[2032] Fix | Delete
continue;
[2033] Fix | Delete
}
[2034] Fix | Delete
foreach ($caps as $cap) {
[2035] Fix | Delete
// only for the activation hook we need to add our capabilities back
[2036] Fix | Delete
if ($hook == 'activate') {
[2037] Fix | Delete
$wp_roles->add_cap($roleToBeRestricted, $cap);
[2038] Fix | Delete
}
[2039] Fix | Delete
else {
[2040] Fix | Delete
$wp_roles->remove_cap($roleToBeRestricted, $cap);
[2041] Fix | Delete
}
[2042] Fix | Delete
}
[2043] Fix | Delete
}
[2044] Fix | Delete
}
[2045] Fix | Delete
[2046] Fix | Delete
public static function removeUnnecessaryCodeFromPopups()
[2047] Fix | Delete
{
[2048] Fix | Delete
$alreadyClearded = self::getOption('sgpb-unnecessary-scripts-removed-1');
[2049] Fix | Delete
if ($alreadyClearded) {
[2050] Fix | Delete
return true;
[2051] Fix | Delete
}
[2052] Fix | Delete
[2053] Fix | Delete
global $wpdb;
[2054] Fix | Delete
$postsTableName = $wpdb->prefix.'posts';
[2055] Fix | Delete
$popupsId = $wpdb->get_results( $wpdb->prepare("SELECT id FROM $postsTableName WHERE post_type = %s", SG_POPUP_POST_TYPE), ARRAY_A);
[2056] Fix | Delete
if (empty($popupsId)) {
[2057] Fix | Delete
return true;
[2058] Fix | Delete
}
[2059] Fix | Delete
foreach ($popupsId as $popupId) {
[2060] Fix | Delete
if (empty($popupId['id'])) {
[2061] Fix | Delete
continue;
[2062] Fix | Delete
}
[2063] Fix | Delete
$id = $popupId['id'];
[2064] Fix | Delete
$customScripts = get_post_meta($id, 'sg_popup_scripts', true);
[2065] Fix | Delete
if (empty($customScripts)) {
[2066] Fix | Delete
continue;
[2067] Fix | Delete
}
[2068] Fix | Delete
if (isset($customScripts['js'])) {
[2069] Fix | Delete
unset($customScripts['js']);
[2070] Fix | Delete
update_post_meta($id, 'sg_popup_scripts', $customScripts);
[2071] Fix | Delete
}
[2072] Fix | Delete
}
[2073] Fix | Delete
[2074] Fix | Delete
self::updateOption('sgpb-unnecessary-scripts-removed-1', 1);
[2075] Fix | Delete
}
[2076] Fix | Delete
[2077] Fix | Delete
public static function sendTestNewsletter($newsletterData = array())
[2078] Fix | Delete
{
[2079] Fix | Delete
$mailSubject = $newsletterData['newsletterSubject'];
[2080] Fix | Delete
$fromEmail = $newsletterData['fromEmail'];
[2081] Fix | Delete
$emailMessage = $newsletterData['messageBody'];
[2082] Fix | Delete
$blogInfo = wp_specialchars_decode( get_option( 'blogname' ) );
[2083] Fix | Delete
$headers = array(
[2084] Fix | Delete
'From: "'.$blogInfo.'" <'.$fromEmail.'>' ,
[2085] Fix | Delete
'MIME-Version: 1.0' ,
[2086] Fix | Delete
'Content-type: text/html; charset=UTF-8'
[2087] Fix | Delete
);
[2088] Fix | Delete
[2089] Fix | Delete
$emails = get_option('admin_email');
[2090] Fix | Delete
if (!empty($newsletterData['testSendingEmails'])) {
[2091] Fix | Delete
$emails = $newsletterData['testSendingEmails'];
[2092] Fix | Delete
$emails = str_replace(' ', '', $emails);
[2093] Fix | Delete
[2094] Fix | Delete
$receiverEmailsArray = array();
[2095] Fix | Delete
$emails = explode(',', $emails);
[2096] Fix | Delete
foreach ($emails as $mail) {
[2097] Fix | Delete
if (is_email($mail)) {
[2098] Fix | Delete
$receiverEmailsArray[] = $mail;
[2099] Fix | Delete
}
[2100] Fix | Delete
}
[2101] Fix | Delete
$emails = $receiverEmailsArray;
[2102] Fix | Delete
}
[2103] Fix | Delete
[2104] Fix | Delete
$newsletterOptions = get_option('SGPB_NEWSLETTER_DATA');
[2105] Fix | Delete
$allAvailableShortcodes = array();
[2106] Fix | Delete
$allAvailableShortcodes['patternBlogName'] = '/\[Blog name]/';
[2107] Fix | Delete
$allAvailableShortcodes['patternUserName'] = '/\[User name]/';
[2108] Fix | Delete
$allAvailableShortcodes['patternUnsubscribe'] = '';
[2109] Fix | Delete
[2110] Fix | Delete
$pattern = "/\[(\[?)(Unsubscribe)(?![\w-])([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]\*+(?:\[(?!\/\2\])[^\[]\*+)\*+)\[\/\2\])?)(\]?)/";
[2111] Fix | Delete
preg_match($pattern, $emailMessage, $matches);
[2112] Fix | Delete
$title = __('Unsubscribe', 'popup-builder');
[2113] Fix | Delete
if ($matches) {
[2114] Fix | Delete
$patternUnsubscribe = $matches[0];
[2115] Fix | Delete
// If user didn't change anything inside the [unsubscribe] shortcode $matches[2] will be equal to 'Unsubscribe'
[2116] Fix | Delete
if ($matches[2] == 'Unsubscribe') {
[2117] Fix | Delete
$pattern = '/\s(\w+?)="(.+?)"]/';
[2118] Fix | Delete
preg_match($pattern, $matches[0], $matchesTitle);
[2119] Fix | Delete
if (!empty($matchesTitle[2])) {
[2120] Fix | Delete
$title = AdminHelper::removeAllNonPrintableCharacters($matchesTitle[2], 'Unsubscribe');
[2121] Fix | Delete
}
[2122] Fix | Delete
}
[2123] Fix | Delete
$allAvailableShortcodes['patternUnsubscribe'] = $patternUnsubscribe;
[2124] Fix | Delete
}
[2125] Fix | Delete
[2126] Fix | Delete
$emailMessageCustom = preg_replace($allAvailableShortcodes['patternBlogName'], $newsletterOptions['blogname'], $emailMessage);
[2127] Fix | Delete
$emailMessageCustom = preg_replace($allAvailableShortcodes['patternUserName'], $newsletterOptions['username'], $emailMessageCustom);
[2128] Fix | Delete
$emailMessageCustom = str_replace($allAvailableShortcodes['patternUnsubscribe'], '', $emailMessageCustom);
[2129] Fix | Delete
[2130] Fix | Delete
$mailStatus = wp_mail($emails, $mailSubject, $emailMessageCustom, $headers);
[2131] Fix | Delete
[2132] Fix | Delete
wp_die(esc_html($newsletterData['testSendingStatus']));
[2133] Fix | Delete
}
[2134] Fix | Delete
[2135] Fix | Delete
// wp uploaded images
[2136] Fix | Delete
public static function getImageAltTextByUrl($imageUrl = '')
[2137] Fix | Delete
{
[2138] Fix | Delete
$imageId = attachment_url_to_postid($imageUrl);
[2139] Fix | Delete
$altText = get_post_meta($imageId, '_wp_attachment_image_alt', true);
[2140] Fix | Delete
[2141] Fix | Delete
return $altText;
[2142] Fix | Delete
}
[2143] Fix | Delete
[2144] Fix | Delete
public static function hasBlocks($content)
[2145] Fix | Delete
{
[2146] Fix | Delete
if (function_exists('has_blocks')) {
[2147] Fix | Delete
return has_blocks($content);
[2148] Fix | Delete
}
[2149] Fix | Delete
[2150] Fix | Delete
return false !== strpos( (string) $content, '<!-- wp:' );
[2151] Fix | Delete
}
[2152] Fix | Delete
/**
[2153] Fix | Delete
* Retrieve duplicate post link for post.
[2154] Fix | Delete
*
[2155] Fix | Delete
* @param int $id Optional. Post ID.
[2156] Fix | Delete
* @param string $context Optional, default to display. How to write the '&', defaults to '&amp;'.
[2157] Fix | Delete
* @return string
[2158] Fix | Delete
*/
[2159] Fix | Delete
public static function popupGetClonePostLink($id = 0, $context = 'display')
[2160] Fix | Delete
{
[2161] Fix | Delete
if (!$post = get_post($id)) {
[2162] Fix | Delete
return;
[2163] Fix | Delete
}
[2164] Fix | Delete
$actionName = "popupSaveAsNew";
[2165] Fix | Delete
[2166] Fix | Delete
if ('display' == $context) {
[2167] Fix | Delete
$action = '?action='.$actionName.'&amp;post='.$post->ID;
[2168] Fix | Delete
} else {
[2169] Fix | Delete
$action = '?action='.$actionName.'&post='.$post->ID;
[2170] Fix | Delete
}
[2171] Fix | Delete
[2172] Fix | Delete
$postTypeObject = get_post_type_object($post->post_type);
[2173] Fix | Delete
[2174] Fix | Delete
if (!$postTypeObject) {
[2175] Fix | Delete
return;
[2176] Fix | Delete
}
[2177] Fix | Delete
[2178] Fix | Delete
return wp_nonce_url(apply_filters('popupGetClonePostLink', admin_url("admin.php".$action), $post->ID, $context), 'duplicate-post_' . $post->ID);
[2179] Fix | Delete
}
[2180] Fix | Delete
private static function checkIfLicenseIsActive($license, $itemId, $key) {
[2181] Fix | Delete
$transient = 'sgpb-license-key-'.$key.'-requested';
[2182] Fix | Delete
if ( false !== ( $value = get_transient( $transient ) ) ) {
[2183] Fix | Delete
return;
[2184] Fix | Delete
}
[2185] Fix | Delete
$params = array(
[2186] Fix | Delete
'woo_sl_action' => 'status-check',
[2187] Fix | Delete
'licence_key' => $license,
[2188] Fix | Delete
'product_unique_id' => $itemId,
[2189] Fix | Delete
'domain' => home_url()
[2190] Fix | Delete
);
[2191] Fix | Delete
$requestUri = SGPB_REQUEST_URL.'?'.http_build_query($params);
[2192] Fix | Delete
$response = wp_remote_get($requestUri);
[2193] Fix | Delete
if (!is_wp_error($response) || 200 == wp_remote_retrieve_response_code($response)) {
[2194] Fix | Delete
$licenseData = json_decode(wp_remote_retrieve_body($response));
[2195] Fix | Delete
$status = (isset($licenseData[0]->licence_status) && $licenseData[0]->licence_status === 'active') ? 'valid' : $licenseData[0]->licence_status;
[2196] Fix | Delete
update_option('sgpb-license-status-'.$key, $status);
[2197] Fix | Delete
set_transient($transient, $licenseData[0]->status_code, WEEK_IN_SECONDS);
[2198] Fix | Delete
}
[2199] Fix | Delete
}
[2200] Fix | Delete
[2201] Fix | Delete
public static function updatesInit()
[2202] Fix | Delete
{
[2203] Fix | Delete
if (!class_exists('sgpb\WOOSL_CodeAutoUpdate')) {
[2204] Fix | Delete
// load our custom updater if it doesn't already exist
[2205] Fix | Delete
require_once(SG_POPUP_LIBS_PATH .'WOOSL_CodeAutoUpdate.php');
[2206] Fix | Delete
}
[2207] Fix | Delete
$licenses = (new License())->getLicenses();
[2208] Fix | Delete
[2209] Fix | Delete
foreach ($licenses as $license) {
[2210] Fix | Delete
$key = isset($license['key']) ?$license['key'] : '';
[2211] Fix | Delete
$itemId = isset($license['itemId']) ? $license['itemId'] : '';
[2212] Fix | Delete
$filePath = isset($license['file']) ? $license['file'] : '';
[2213] Fix | Delete
$pluginMainFilePath = strpos($filePath, SG_POPUP_PLUGIN_PATH) !== 0 ? SG_POPUP_PLUGIN_PATH.$filePath : $filePath;
[2214] Fix | Delete
[2215] Fix | Delete
$licenseKey = trim(get_option('sgpb-license-key-'.$key));
[2216] Fix | Delete
$status = get_option('sgpb-license-status-'.$key);
[2217] Fix | Delete
[2218] Fix | Delete
if ($status == false || $status != 'valid') {
[2219] Fix | Delete
continue;
[2220] Fix | Delete
}
[2221] Fix | Delete
self::checkIfLicenseIsActive($licenseKey, $itemId, $key);
[2222] Fix | Delete
switch($key) {
[2223] Fix | Delete
case 'POPUP_SOCIAL':
[2224] Fix | Delete
if (defined('SGPB_SOCIAL_POPUP_VERSION')) {
[2225] Fix | Delete
$version = defined('SGPB_SOCIAL_POPUP_VERSION') ? constant('SGPB_SOCIAL_POPUP_VERSION') : '';
[2226] Fix | Delete
} else {
[2227] Fix | Delete
$version = defined('SG_VERSION_'.$key) ? constant('SG_VERSION_'.$key) : '';
[2228] Fix | Delete
}
[2229] Fix | Delete
break;
[2230] Fix | Delete
case 'POPUP_AGE_VERIFICATION':
[2231] Fix | Delete
if (defined('SGPB_AGE_VERIFICATION_POPUP_VERSION')) {
[2232] Fix | Delete
$version = defined('SGPB_AGE_VERIFICATION_POPUP_VERSION') ? constant('SGPB_AGE_VERIFICATION_POPUP_VERSION') : '';
[2233] Fix | Delete
} else{
[2234] Fix | Delete
$version = defined('SG_VERSION_'.$key) ? constant('SG_VERSION_'.$key) : '';
[2235] Fix | Delete
}
[2236] Fix | Delete
break;
[2237] Fix | Delete
case 'POPUP_GAMIFICATION':
[2238] Fix | Delete
if (defined('POPUP_GAMIFICATION')) {
[2239] Fix | Delete
$version = defined('POPUP_GAMIFICATION') ? constant('POPUP_GAMIFICATION') : '';
[2240] Fix | Delete
} else {
[2241] Fix | Delete
$version = defined('SG_VERSION_'.$key) ? constant('SG_VERSION_'.$key) : '';
[2242] Fix | Delete
}
[2243] Fix | Delete
break;
[2244] Fix | Delete
default :
[2245] Fix | Delete
$version = defined('SG_VERSION_'.$key) ? constant('SG_VERSION_'.$key) : '';
[2246] Fix | Delete
break;
[2247] Fix | Delete
}
[2248] Fix | Delete
// If the version of the extension is not found, update will not possibly be shown
[2249] Fix | Delete
if(empty($version)) {
[2250] Fix | Delete
continue;
[2251] Fix | Delete
}
[2252] Fix | Delete
$sgpbUpdater = new WOOSL_CodeAutoUpdate(
[2253] Fix | Delete
SGPB_REQUEST_URL,
[2254] Fix | Delete
$pluginMainFilePath,
[2255] Fix | Delete
$itemId,
[2256] Fix | Delete
$licenseKey,
[2257] Fix | Delete
$version
[2258] Fix | Delete
);
[2259] Fix | Delete
}
[2260] Fix | Delete
}
[2261] Fix | Delete
[2262] Fix | Delete
public static function allowed_html_tags($allowScript = true)
[2263] Fix | Delete
{
[2264] Fix | Delete
$allowedPostTags = array();
[2265] Fix | Delete
$allowedPostTags = wp_kses_allowed_html('post');
[2266] Fix | Delete
$allowed_atts = array(
[2267] Fix | Delete
'role' => array(),
[2268] Fix | Delete
'checked' => array(),
[2269] Fix | Delete
'align' => array(),
[2270] Fix | Delete
'preload' => array(),
[2271] Fix | Delete
'aria-live' => array(),
[2272] Fix | Delete
'aria-label' => array(),
[2273] Fix | Delete
'aria-disabled' => array(),
[2274] Fix | Delete
'aria-atomic' => array(),
[2275] Fix | Delete
'aria-required' => array(),
[2276] Fix | Delete
'aria-invalid' => array(),
[2277] Fix | Delete
'aria-hidden' => array(),
[2278] Fix | Delete
'aria-valuenow' => array(),
[2279] Fix | Delete
'aria-valuemin' => array(),
[2280] Fix | Delete
'aria-haspopup' => array(),
[2281] Fix | Delete
'aria-expanded' => array(),
[2282] Fix | Delete
'aria-valuemax' => array(),
[2283] Fix | Delete
'aria-labelledby' => array(),
[2284] Fix | Delete
'aria-checked' => array(),
[2285] Fix | Delete
'aria-describedby' => array(),
[2286] Fix | Delete
'aria-valuetext' => array(),
[2287] Fix | Delete
'placeholder' => array(),
[2288] Fix | Delete
'controls' => array(),
[2289] Fix | Delete
'allowfullscreen' => array(),
[2290] Fix | Delete
'class' => array(),
[2291] Fix | Delete
'type' => array(),
[2292] Fix | Delete
'id' => array(),
[2293] Fix | Delete
'dir' => array(),
[2294] Fix | Delete
'size' => array(),
[2295] Fix | Delete
'cols' => array(),
[2296] Fix | Delete
'rows' => array(),
[2297] Fix | Delete
'lang' => array(),
[2298] Fix | Delete
'muted' => array(),
[2299] Fix | Delete
'style' => array(),
[2300] Fix | Delete
'xml:lang' => array(),
[2301] Fix | Delete
'src' => array(),
[2302] Fix | Delete
'autocomplete' => array(),
[2303] Fix | Delete
'maxlength' => array(),
[2304] Fix | Delete
'pattern' => array(),
[2305] Fix | Delete
'alt' => array(),
[2306] Fix | Delete
'href' => array(),
[2307] Fix | Delete
'rel' => array(),
[2308] Fix | Delete
'rev' => array(),
[2309] Fix | Delete
'target' => array(),
[2310] Fix | Delete
'novalidate' => array(),
[2311] Fix | Delete
'value' => array(),
[2312] Fix | Delete
'name' => array(),
[2313] Fix | Delete
'tabindex' => array(),
[2314] Fix | Delete
'action' => array(),
[2315] Fix | Delete
'method' => array(),
[2316] Fix | Delete
'for' => array(),
[2317] Fix | Delete
'width' => array(),
[2318] Fix | Delete
'height' => array(),
[2319] Fix | Delete
'data-*' => true,
[2320] Fix | Delete
'title' => array(),
[2321] Fix | Delete
'enctype' => array(),
[2322] Fix | Delete
'attr' => array(),
[2323] Fix | Delete
'label' => array(),
[2324] Fix | Delete
'selected' => array(),
[2325] Fix | Delete
'multiple' => array()
[2326] Fix | Delete
);
[2327] Fix | Delete
if ($allowScript){
[2328] Fix | Delete
$allowedPostTags['script'] = $allowed_atts;
[2329] Fix | Delete
$allowed_atts['onclick'] = array();
[2330] Fix | Delete
}
[2331] Fix | Delete
$allowedPostTags['select'] = $allowed_atts;
[2332] Fix | Delete
$allowedPostTags['optgroup'] = $allowed_atts;
[2333] Fix | Delete
$allowedPostTags['option'] = $allowed_atts;
[2334] Fix | Delete
$allowedPostTags['form'] = $allowed_atts;
[2335] Fix | Delete
$allowedPostTags['fieldset'] = $allowed_atts;
[2336] Fix | Delete
$allowedPostTags['legend'] = $allowed_atts;
[2337] Fix | Delete
$allowedPostTags['label'] = $allowed_atts;
[2338] Fix | Delete
$allowedPostTags['input'] = $allowed_atts;
[2339] Fix | Delete
$allowedPostTags['video'] = $allowed_atts;
[2340] Fix | Delete
$allowedPostTags['source'] = $allowed_atts;
[2341] Fix | Delete
$allowedPostTags['textarea'] = $allowed_atts;
[2342] Fix | Delete
$allowedPostTags['iframe'] = $allowed_atts;
[2343] Fix | Delete
[2344] Fix | Delete
$allowedPostTags['style'] = $allowed_atts;
[2345] Fix | Delete
$allowedPostTags['strong'] = $allowed_atts;
[2346] Fix | Delete
$allowedPostTags['small'] = $allowed_atts;
[2347] Fix | Delete
$allowedPostTags['table'] = $allowed_atts;
[2348] Fix | Delete
$allowedPostTags['span'] = $allowed_atts;
[2349] Fix | Delete
$allowedPostTags['abbr'] = $allowed_atts;
[2350] Fix | Delete
$allowedPostTags['code'] = $allowed_atts;
[2351] Fix | Delete
$allowedPostTags['pre'] = $allowed_atts;
[2352] Fix | Delete
$allowedPostTags['div'] = $allowed_atts;
[2353] Fix | Delete
$allowedPostTags['img'] = $allowed_atts;
[2354] Fix | Delete
$allowedPostTags['h1'] = $allowed_atts;
[2355] Fix | Delete
$allowedPostTags['h2'] = $allowed_atts;
[2356] Fix | Delete
$allowedPostTags['h3'] = $allowed_atts;
[2357] Fix | Delete
$allowedPostTags['h4'] = $allowed_atts;
[2358] Fix | Delete
$allowedPostTags['h5'] = $allowed_atts;
[2359] Fix | Delete
$allowedPostTags['h6'] = $allowed_atts;
[2360] Fix | Delete
$allowedPostTags['ol'] = $allowed_atts;
[2361] Fix | Delete
$allowedPostTags['ul'] = $allowed_atts;
[2362] Fix | Delete
$allowedPostTags['li'] = $allowed_atts;
[2363] Fix | Delete
$allowedPostTags['em'] = $allowed_atts;
[2364] Fix | Delete
$allowedPostTags['hr'] = $allowed_atts;
[2365] Fix | Delete
$allowedPostTags['br'] = $allowed_atts;
[2366] Fix | Delete
$allowedPostTags['tr'] = $allowed_atts;
[2367] Fix | Delete
$allowedPostTags['td'] = $allowed_atts;
[2368] Fix | Delete
$allowedPostTags['p'] = $allowed_atts;
[2369] Fix | Delete
$allowedPostTags['a'] = $allowed_atts;
[2370] Fix | Delete
$allowedPostTags['b'] = $allowed_atts;
[2371] Fix | Delete
$allowedPostTags['i'] = $allowed_atts;
[2372] Fix | Delete
add_filter('safe_style_css', function($styles){
[2373] Fix | Delete
$styles[] = 'position';
[2374] Fix | Delete
$styles[] = 'opacity';
[2375] Fix | Delete
$styles[] = 'inset';
[2376] Fix | Delete
$styles[] = 'margin';
[2377] Fix | Delete
$styles[] = 'display';
[2378] Fix | Delete
$styles[] = 'z-index';
[2379] Fix | Delete
$styles[] = 'top';
[2380] Fix | Delete
$styles[] = 'left';
[2381] Fix | Delete
$styles[] = 'bottom';
[2382] Fix | Delete
$styles[] = 'right';
[2383] Fix | Delete
[2384] Fix | Delete
return $styles;
[2385] Fix | Delete
}, 10, 1);
[2386] Fix | Delete
[2387] Fix | Delete
return $allowedPostTags;
[2388] Fix | Delete
}
[2389] Fix | Delete
public static function allowed_wrap_html_tags($allowScript = true)
[2390] Fix | Delete
{
[2391] Fix | Delete
$allowedPostTags = array('span','div','h1','h2' ,'h3' ,'h4' ,'h5' ,'h6','ol' ,'ul' ,'li' ,'em' , 'p', 'a','b' ,'i' , 'button');
[2392] Fix | Delete
return $allowedPostTags;
[2393] Fix | Delete
}
[2394] Fix | Delete
public static function sgpbScanCustomJsStr( $quetStrCustomJs)
[2395] Fix | Delete
{
[2396] Fix | Delete
$scamListMethods = array('register', 'createuser', 'forgotPassword', 'user_login', 'password','eval', 'atob' );
[2397] Fix | Delete
foreach( $scamListMethods as $scan_key)
[2398] Fix | Delete
{
[2399] Fix | Delete
$pos_scan = strpos($quetStrCustomJs, $scan_key);
[2400] Fix | Delete
if ($pos_scan !== false) {
[2401] Fix | Delete
return true;
[2402] Fix | Delete
}
[2403] Fix | Delete
}
[2404] Fix | Delete
return false;
[2405] Fix | Delete
}
[2406] Fix | Delete
public static function sgpbScanCustomJsProblem()
[2407] Fix | Delete
{
[2408] Fix | Delete
$sgpbdetect_flag = false;
[2409] Fix | Delete
[2410] Fix | Delete
// Get all custom JS code on Popups
[2411] Fix | Delete
$popupBuilderPosts = new WP_Query(
[2412] Fix | Delete
array(
[2413] Fix | Delete
'post_type' => SG_POPUP_POST_TYPE,
[2414] Fix | Delete
'posts_per_page' => -1
[2415] Fix | Delete
)
[2416] Fix | Delete
);
[2417] Fix | Delete
[2418] Fix | Delete
// We check all the popups one by one to realize whether they might be loaded or not.
[2419] Fix | Delete
while ($popupBuilderPosts->have_posts()) {
[2420] Fix | Delete
$popupBuilderPosts->next_post();
[2421] Fix | Delete
$popupPost = $popupBuilderPosts->post;
[2422] Fix | Delete
$popup = SGPopup::find($popupPost);
[2423] Fix | Delete
if (empty($popup) || !is_object($popup)) {
[2424] Fix | Delete
continue;
[2425] Fix | Delete
}
[2426] Fix | Delete
$alreadySavedCustomData = get_post_meta($popupPost->ID, 'sg_popup_scripts', true);
[2427] Fix | Delete
//Scan each customJS to find insecurity custom JS code
[2428] Fix | Delete
$popup_options = $popup->getOptions();
[2429] Fix | Delete
[2430] Fix | Delete
if ( isset( $popup_options['sgpb-ShouldOpen'] ) && !empty( $popup_options['sgpb-ShouldOpen'] ) ){
[2431] Fix | Delete
//Scan virus code
[2432] Fix | Delete
if( self::sgpbScanCustomJsStr( $popup_options['sgpb-ShouldOpen'] ) == true )
[2433] Fix | Delete
{
[2434] Fix | Delete
$sgpbdetect_flag = true;
[2435] Fix | Delete
return array( 'status' => $sgpbdetect_flag , 'marked_code' => admin_url( 'post.php?post='.$popupPost->ID.'&action=edit#customCssJs' ));
[2436] Fix | Delete
}
[2437] Fix | Delete
}
[2438] Fix | Delete
if ( isset( $popup_options['sgpb-ShouldClose'] ) && !empty( $popup_options['sgpb-ShouldClose'] ) )
[2439] Fix | Delete
{
[2440] Fix | Delete
//Scan virus code
[2441] Fix | Delete
if( self::sgpbScanCustomJsStr( $popup_options['sgpb-ShouldClose'] ) == true )
[2442] Fix | Delete
{
[2443] Fix | Delete
$sgpbdetect_flag = true;
[2444] Fix | Delete
return array( 'status' => $sgpbdetect_flag , 'marked_code' => admin_url( 'post.php?post='.$popupPost->ID.'&action=edit#customCssJs' ));
[2445] Fix | Delete
}
[2446] Fix | Delete
}
[2447] Fix | Delete
if ( isset( $alreadySavedCustomData['js'] ) && !empty( $alreadySavedCustomData['js']['sgpb-ShouldOpen']) )
[2448] Fix | Delete
{
[2449] Fix | Delete
//Scan virus code
[2450] Fix | Delete
if( self::sgpbScanCustomJsStr( $alreadySavedCustomData['js']['sgpb-ShouldOpen'] ) == true )
[2451] Fix | Delete
{
[2452] Fix | Delete
$sgpbdetect_flag = true;
[2453] Fix | Delete
return array( 'status' => $sgpbdetect_flag , 'marked_code' => admin_url( 'post.php?post='.$popupPost->ID.'&action=edit#customCssJs' ));
[2454] Fix | Delete
}
[2455] Fix | Delete
}
[2456] Fix | Delete
if ( isset( $alreadySavedCustomData['js'] ) && !empty( $alreadySavedCustomData['js']['sgpb-WillOpen']) )
[2457] Fix | Delete
{
[2458] Fix | Delete
//Scan virus code
[2459] Fix | Delete
if( self::sgpbScanCustomJsStr( $alreadySavedCustomData['js']['sgpb-WillOpen'] ) == true )
[2460] Fix | Delete
{
[2461] Fix | Delete
$sgpbdetect_flag = true;
[2462] Fix | Delete
return array( 'status' => $sgpbdetect_flag , 'marked_code' => admin_url( 'post.php?post='.$popupPost->ID.'&action=edit#customCssJs' ));
[2463] Fix | Delete
}
[2464] Fix | Delete
}
[2465] Fix | Delete
if ( isset( $alreadySavedCustomData['js'] ) && !empty( $alreadySavedCustomData['js']['sgpb-DidOpen']) )
[2466] Fix | Delete
{
[2467] Fix | Delete
//Scan virus code
[2468] Fix | Delete
if( self::sgpbScanCustomJsStr( $alreadySavedCustomData['js']['sgpb-DidOpen'] ) == true )
[2469] Fix | Delete
{
[2470] Fix | Delete
$sgpbdetect_flag = true;
[2471] Fix | Delete
return array( 'status' => $sgpbdetect_flag , 'marked_code' => admin_url( 'post.php?post='.$popupPost->ID.'&action=edit#customCssJs' ));
[2472] Fix | Delete
}
[2473] Fix | Delete
}
[2474] Fix | Delete
if ( isset( $alreadySavedCustomData['js'] ) && !empty( $alreadySavedCustomData['js']['sgpb-ShouldClose']) )
[2475] Fix | Delete
{
[2476] Fix | Delete
//Scan virus code
[2477] Fix | Delete
if( self::sgpbScanCustomJsStr( $alreadySavedCustomData['js']['sgpb-ShouldClose'] ) == true )
[2478] Fix | Delete
{
[2479] Fix | Delete
$sgpbdetect_flag = true;
[2480] Fix | Delete
return array( 'status' => $sgpbdetect_flag , 'marked_code' => admin_url( 'post.php?post='.$popupPost->ID.'&action=edit#customCssJs' ));
[2481] Fix | Delete
}
[2482] Fix | Delete
}
[2483] Fix | Delete
if ( isset( $alreadySavedCustomData['js'] ) && !empty( $alreadySavedCustomData['js']['sgpb-WillClose']) )
[2484] Fix | Delete
{
[2485] Fix | Delete
//Scan virus code
[2486] Fix | Delete
if( self::sgpbScanCustomJsStr( $alreadySavedCustomData['js']['sgpb-WillClose'] ) == true )
[2487] Fix | Delete
{
[2488] Fix | Delete
$sgpbdetect_flag = true;
[2489] Fix | Delete
return array( 'status' => $sgpbdetect_flag , 'marked_code' => admin_url( 'post.php?post='.$popupPost->ID.'&action=edit#customCssJs' ));
[2490] Fix | Delete
}
[2491] Fix | Delete
}
[2492] Fix | Delete
if ( isset( $alreadySavedCustomData['js'] ) && !empty( $alreadySavedCustomData['js']['sgpb-DidClose']) )
[2493] Fix | Delete
{
[2494] Fix | Delete
//Scan virus code
[2495] Fix | Delete
if( self::sgpbScanCustomJsStr( $alreadySavedCustomData['js']['sgpb-DidClose'] ) == true )
[2496] Fix | Delete
{
[2497] Fix | Delete
$sgpbdetect_flag = true;
[2498] Fix | Delete
return array( 'status' => $sgpbdetect_flag , 'marked_code' => admin_url( 'post.php?post='.$popupPost->ID.'&action=edit#customCssJs' ));
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function