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/leadin/public/admin
File: class-links.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Leadin\admin;
[2] Fix | Delete
[3] Fix | Delete
use Leadin\data\Filters;
[4] Fix | Delete
use Leadin\data\Portal_Options;
[5] Fix | Delete
use Leadin\admin\MenuConstants;
[6] Fix | Delete
use Leadin\admin\utils\Background;
[7] Fix | Delete
use Leadin\data\User;
[8] Fix | Delete
use Leadin\utils\QueryParameters;
[9] Fix | Delete
use Leadin\utils\Versions;
[10] Fix | Delete
use Leadin\auth\OAuth;
[11] Fix | Delete
use Leadin\admin\Connection;
[12] Fix | Delete
use Leadin\admin\Impact;
[13] Fix | Delete
use Leadin\admin\AdminConstants;
[14] Fix | Delete
use Leadin\includes\utils as utils;
[15] Fix | Delete
use Leadin\auth\OAuthCrypto;
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Class containing all the functions to generate links to HubSpot.
[19] Fix | Delete
*/
[20] Fix | Delete
class Links {
[21] Fix | Delete
/**
[22] Fix | Delete
* Deprecated for OAuth2 routes
[23] Fix | Delete
*
[24] Fix | Delete
* Get a map of <admin_page, url>
[25] Fix | Delete
* Where
[26] Fix | Delete
* - admin_page is a string
[27] Fix | Delete
* - url is either a string or another map <route, string_url>, both strings
[28] Fix | Delete
*/
[29] Fix | Delete
public static function get_routes_mapping() {
[30] Fix | Delete
$portal_id = Portal_Options::get_portal_id();
[31] Fix | Delete
$reporting_page = "/reports-dashboard/$portal_id";
[32] Fix | Delete
$user_guide = "/wordpress-plugin-ui/$portal_id/onboarding/start";
[33] Fix | Delete
[34] Fix | Delete
return array(
[35] Fix | Delete
MenuConstants::ROOT => $user_guide,
[36] Fix | Delete
MenuConstants::USER_GUIDE => $user_guide,
[37] Fix | Delete
MenuConstants::REPORTING => $reporting_page,
[38] Fix | Delete
MenuConstants::CONTACTS => "/contacts/$portal_id",
[39] Fix | Delete
MenuConstants::LISTS => array(
[40] Fix | Delete
'' => "/contacts/$portal_id/objectLists/all",
[41] Fix | Delete
'default' => "/contacts/$portal_id/objectLists",
[42] Fix | Delete
'lists' => "/contacts/$portal_id/lists",
[43] Fix | Delete
),
[44] Fix | Delete
MenuConstants::EMAIL => array(
[45] Fix | Delete
'' => "/email/$portal_id",
[46] Fix | Delete
'cms' => "/content/$portal_id/create/email",
[47] Fix | Delete
),
[48] Fix | Delete
MenuConstants::SETTINGS => array(
[49] Fix | Delete
'' => "/wordpress-plugin-ui/$portal_id/settings",
[50] Fix | Delete
'forms' => "/settings/$portal_id/marketing/form",
[51] Fix | Delete
),
[52] Fix | Delete
MenuConstants::PRICING => "/pricing/$portal_id/marketing",
[53] Fix | Delete
);
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* Get page name from the current page id.
[58] Fix | Delete
* E.g. "hubspot_page_leadin_forms" => "forms"
[59] Fix | Delete
*/
[60] Fix | Delete
private static function get_page_id() {
[61] Fix | Delete
$screen_id = get_current_screen()->id;
[62] Fix | Delete
return preg_replace( '/^(hubspot_page_|toplevel_page_)/', '', $screen_id );
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* Get the parsed `leadin_route` from the query string.
[67] Fix | Delete
*/
[68] Fix | Delete
private static function get_iframe_route() {
[69] Fix | Delete
$iframe_route = QueryParameters::get_param_array( 'leadin_route', 'hubspot-route' );
[70] Fix | Delete
return is_array( $iframe_route ) ? $iframe_route : array();
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
/**
[74] Fix | Delete
* Get the parsed `leadin_search` from the query string.
[75] Fix | Delete
*/
[76] Fix | Delete
private static function get_iframe_search_string() {
[77] Fix | Delete
return QueryParameters::get_param( 'leadin_search', 'hubspot-route' );
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
/**
[81] Fix | Delete
* Return query string from object
[82] Fix | Delete
*
[83] Fix | Delete
* @param array $arr query parameters to stringify.
[84] Fix | Delete
*/
[85] Fix | Delete
private static function http_build_query( $arr ) {
[86] Fix | Delete
if ( ! is_array( $arr ) ) {
[87] Fix | Delete
return '';
[88] Fix | Delete
}
[89] Fix | Delete
return http_build_query( $arr, '', ini_get( 'arg_separator.output' ), PHP_QUERY_RFC3986 );
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
/**
[93] Fix | Delete
* Validate static version.
[94] Fix | Delete
*
[95] Fix | Delete
* @param String $version version of the static bundle.
[96] Fix | Delete
*/
[97] Fix | Delete
private static function is_static_version_valid( $version ) {
[98] Fix | Delete
preg_match( '/static-\d+\.\d+/', $version, $match );
[99] Fix | Delete
return ! empty( $match );
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
/**
[103] Fix | Delete
* Return a string query parameters to add to the iframe src.
[104] Fix | Delete
*/
[105] Fix | Delete
public static function get_query_params() {
[106] Fix | Delete
$config_array = AdminConstants::get_hubspot_query_params_array();
[107] Fix | Delete
\array_merge( $config_array, Impact::get_params() );
[108] Fix | Delete
[109] Fix | Delete
return self::http_build_query( $config_array );
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
/**
[113] Fix | Delete
* This function computes the right iframe src based on query params and current page.
[114] Fix | Delete
*
[115] Fix | Delete
* The `page` query param is used as a key to get the url from the get_routes_mapping
[116] Fix | Delete
* This query param will get ignored if $page_id function param is present
[117] Fix | Delete
* The `leadin_route[]` query params are added to the url
[118] Fix | Delete
*
[119] Fix | Delete
* e.g.:
[120] Fix | Delete
* ?page=leadin_forms&leadin_route[]=foo&leadin_route[]=bar will redirect to /forms/$portal_id/foo/bar
[121] Fix | Delete
*
[122] Fix | Delete
* If the value of get_routes_mapping is an array, the first value of `leadin_route` will be used as key.
[123] Fix | Delete
* If the key isn't found, it will fall back to ''
[124] Fix | Delete
*
[125] Fix | Delete
* e.g.:
[126] Fix | Delete
* ?page=leadin_settings&leadin=route[]=forms&leadin_route[]=bar will redirect to /settings/$portal_id/forms/bar
[127] Fix | Delete
* ?page=leadin_settings&leadin=route[]=foo&leadin_route[]=bar will redirect to /wordpress_plugin_ui/$portal_id/settings/foo/bar
[128] Fix | Delete
*
[129] Fix | Delete
* @param String $page_id is used as a key to get the url from the get_routes_mapping by overriding the query param.
[130] Fix | Delete
*
[131] Fix | Delete
* Returns the right iframe src.
[132] Fix | Delete
*/
[133] Fix | Delete
public static function get_iframe_src( $page_id = '' ) {
[134] Fix | Delete
$leadin_onboarding = 'leadin_onboarding';
[135] Fix | Delete
$leadin_new_portal = 'leadin_new_portal';
[136] Fix | Delete
$browser_search_string = '';
[137] Fix | Delete
[138] Fix | Delete
if ( get_transient( $leadin_onboarding ) ) {
[139] Fix | Delete
delete_transient( $leadin_onboarding );
[140] Fix | Delete
$browser_search_string = '&justConnected=true';
[141] Fix | Delete
if ( get_transient( $leadin_new_portal ) ) {
[142] Fix | Delete
delete_transient( $leadin_new_portal );
[143] Fix | Delete
$browser_search_string = $browser_search_string . '&isNewPortal=true';
[144] Fix | Delete
}
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
$sub_routes_array = self::get_iframe_route();
[148] Fix | Delete
$inframe_search_string = self::get_iframe_search_string();
[149] Fix | Delete
$browser_search_string = $browser_search_string . $inframe_search_string;
[150] Fix | Delete
[151] Fix | Delete
if ( empty( Portal_Options::get_portal_id() ) ) {
[152] Fix | Delete
$wp_user = wp_get_current_user();
[153] Fix | Delete
$wp_user_id = $wp_user->ID;
[154] Fix | Delete
set_transient( $leadin_onboarding, 'true' );
[155] Fix | Delete
} else {
[156] Fix | Delete
if ( '' === $page_id ) {
[157] Fix | Delete
$page_id = self::get_page_id();
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
$routes = self::get_routes_mapping();
[161] Fix | Delete
[162] Fix | Delete
$is_external = MenuConstants::PRICING === $page_id || MenuConstants::REPORTING === $page_id || MenuConstants::LISTS === $page_id || MenuConstants::CONTACTS === $page_id || MenuConstants::EMAIL === $page_id;
[163] Fix | Delete
[164] Fix | Delete
if ( empty( $route ) && isset( $routes[ $page_id ] ) ) {
[165] Fix | Delete
$route = $routes[ $page_id ];
[166] Fix | Delete
[167] Fix | Delete
if ( \is_array( $route ) && isset( $sub_routes_array[0] ) ) {
[168] Fix | Delete
$first_sub_route = $sub_routes_array[0];
[169] Fix | Delete
[170] Fix | Delete
if ( isset( $route[ $first_sub_route ] ) ) {
[171] Fix | Delete
$route = $route[ $first_sub_route ];
[172] Fix | Delete
array_shift( $sub_routes_array );
[173] Fix | Delete
}
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
if ( \is_array( $route ) ) {
[177] Fix | Delete
$route = $route[''];
[178] Fix | Delete
}
[179] Fix | Delete
}
[180] Fix | Delete
}
[181] Fix | Delete
[182] Fix | Delete
$sub_routes = join( '/', $sub_routes_array );
[183] Fix | Delete
$sub_routes = empty( $sub_routes ) ? $sub_routes : "/$sub_routes";
[184] Fix | Delete
// Query string separator "?" may have been added to the URL already.
[185] Fix | Delete
$add_separator = strpos( $sub_routes, '?' ) ? '&' : '?';
[186] Fix | Delete
$additional_query_params = Filters::apply_query_params_filters();
[187] Fix | Delete
[188] Fix | Delete
return Filters::apply_base_url_filters() . "$route$sub_routes" . $add_separator . self::get_query_params() . $browser_search_string . $additional_query_params;
[189] Fix | Delete
}
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function