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/wp-conte.../plugins/content-.../inc/freemius/includes
File: fs-core-functions.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* @package Freemius
[2] Fix | Delete
* @copyright Copyright (c) 2015, Freemius, Inc.
[3] Fix | Delete
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
[4] Fix | Delete
* @since 1.0.3
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[8] Fix | Delete
exit;
[9] Fix | Delete
}
[10] Fix | Delete
[11] Fix | Delete
if ( ! function_exists( 'fs_dummy' ) ) {
[12] Fix | Delete
function fs_dummy() {
[13] Fix | Delete
}
[14] Fix | Delete
}
[15] Fix | Delete
[16] Fix | Delete
/* Url.
[17] Fix | Delete
--------------------------------------------------------------------------------------------*/
[18] Fix | Delete
if ( ! function_exists( 'fs_get_url_daily_cache_killer' ) ) {
[19] Fix | Delete
function fs_get_url_daily_cache_killer() {
[20] Fix | Delete
return date( '\YY\Mm\Dd' );
[21] Fix | Delete
}
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
/* Templates / Views.
[25] Fix | Delete
--------------------------------------------------------------------------------------------*/
[26] Fix | Delete
if ( ! function_exists( 'fs_get_template_path' ) ) {
[27] Fix | Delete
function fs_get_template_path( $path ) {
[28] Fix | Delete
return WP_FS__DIR_TEMPLATES . '/' . trim( $path, '/' );
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
function fs_include_template( $path, &$params = null ) {
[32] Fix | Delete
$VARS = &$params;
[33] Fix | Delete
include fs_get_template_path( $path );
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
function fs_include_once_template( $path, &$params = null ) {
[37] Fix | Delete
$VARS = &$params;
[38] Fix | Delete
include_once fs_get_template_path( $path );
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
function fs_require_template( $path, &$params = null ) {
[42] Fix | Delete
$VARS = &$params;
[43] Fix | Delete
require fs_get_template_path( $path );
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
function fs_require_once_template( $path, &$params = null ) {
[47] Fix | Delete
$VARS = &$params;
[48] Fix | Delete
require_once fs_get_template_path( $path );
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
function fs_get_template( $path, &$params = null ) {
[52] Fix | Delete
ob_start();
[53] Fix | Delete
[54] Fix | Delete
$VARS = &$params;
[55] Fix | Delete
require fs_get_template_path( $path );
[56] Fix | Delete
[57] Fix | Delete
return ob_get_clean();
[58] Fix | Delete
}
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
/* Scripts and styles including.
[62] Fix | Delete
--------------------------------------------------------------------------------------------*/
[63] Fix | Delete
[64] Fix | Delete
if ( ! function_exists( 'fs_asset_url' ) ) {
[65] Fix | Delete
/**
[66] Fix | Delete
* Generates an absolute URL to the given path. This function ensures that the URL will be correct whether the asset
[67] Fix | Delete
* is inside a plugin's folder or a theme's folder.
[68] Fix | Delete
*
[69] Fix | Delete
* Examples:
[70] Fix | Delete
* 1. "themes" folder
[71] Fix | Delete
* Path: C:/xampp/htdocs/fswp/wp-content/themes/twentytwelve/freemius/assets/css/admin/common.css
[72] Fix | Delete
* URL: http://fswp:8080/wp-content/themes/twentytwelve/freemius/assets/css/admin/common.css
[73] Fix | Delete
*
[74] Fix | Delete
* 2. "plugins" folder
[75] Fix | Delete
* Path: C:/xampp/htdocs/fswp/wp-content/plugins/rating-widget-premium/freemius/assets/css/admin/common.css
[76] Fix | Delete
* URL: http://fswp:8080/wp-content/plugins/rating-widget-premium/freemius/assets/css/admin/common.css
[77] Fix | Delete
*
[78] Fix | Delete
* @author Leo Fajardo (@leorw)
[79] Fix | Delete
* @since 1.2.2
[80] Fix | Delete
*
[81] Fix | Delete
* @param string $asset_abs_path Asset's absolute path.
[82] Fix | Delete
*
[83] Fix | Delete
* @return string Asset's URL.
[84] Fix | Delete
*/
[85] Fix | Delete
function fs_asset_url( $asset_abs_path ) {
[86] Fix | Delete
$wp_content_dir = fs_normalize_path( WP_CONTENT_DIR );
[87] Fix | Delete
$asset_abs_path = fs_normalize_path( $asset_abs_path );
[88] Fix | Delete
[89] Fix | Delete
if ( 0 === strpos( $asset_abs_path, $wp_content_dir ) ) {
[90] Fix | Delete
// Handle both theme and plugin assets located in the standard directories.
[91] Fix | Delete
$asset_rel_path = str_replace( $wp_content_dir, '', $asset_abs_path );
[92] Fix | Delete
$asset_url = content_url( fs_normalize_path( $asset_rel_path ) );
[93] Fix | Delete
} else {
[94] Fix | Delete
$wp_plugins_dir = fs_normalize_path( WP_PLUGIN_DIR );
[95] Fix | Delete
if ( 0 === strpos( $asset_abs_path, $wp_plugins_dir ) ) {
[96] Fix | Delete
// Try to handle plugin assets that may be located in a non-standard plugins directory.
[97] Fix | Delete
$asset_rel_path = str_replace( $wp_plugins_dir, '', $asset_abs_path );
[98] Fix | Delete
$asset_url = plugins_url( fs_normalize_path( $asset_rel_path ) );
[99] Fix | Delete
} else {
[100] Fix | Delete
// Try to handle theme assets that may be located in a non-standard themes directory.
[101] Fix | Delete
$active_theme_stylesheet = get_stylesheet();
[102] Fix | Delete
$wp_themes_dir = fs_normalize_path( trailingslashit( get_theme_root( $active_theme_stylesheet ) ) );
[103] Fix | Delete
$asset_rel_path = str_replace( $wp_themes_dir, '', fs_normalize_path( $asset_abs_path ) );
[104] Fix | Delete
$asset_url = trailingslashit( get_theme_root_uri( $active_theme_stylesheet ) ) . fs_normalize_path( $asset_rel_path );
[105] Fix | Delete
}
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
return $asset_url;
[109] Fix | Delete
}
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
if ( ! function_exists( 'fs_enqueue_local_style' ) ) {
[113] Fix | Delete
function fs_enqueue_local_style( $handle, $path, $deps = array(), $ver = false, $media = 'all' ) {
[114] Fix | Delete
wp_enqueue_style( $handle, fs_asset_url( WP_FS__DIR_CSS . '/' . trim( $path, '/' ) ), $deps, $ver, $media );
[115] Fix | Delete
}
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
if ( ! function_exists( 'fs_enqueue_local_script' ) ) {
[119] Fix | Delete
function fs_enqueue_local_script( $handle, $path, $deps = array(), $ver = false, $in_footer = 'all' ) {
[120] Fix | Delete
wp_enqueue_script( $handle, fs_asset_url( WP_FS__DIR_JS . '/' . trim( $path, '/' ) ), $deps, $ver, $in_footer );
[121] Fix | Delete
}
[122] Fix | Delete
}
[123] Fix | Delete
[124] Fix | Delete
if ( ! function_exists( 'fs_img_url' ) ) {
[125] Fix | Delete
function fs_img_url( $path, $img_dir = WP_FS__DIR_IMG ) {
[126] Fix | Delete
return ( fs_asset_url( $img_dir . '/' . trim( $path, '/' ) ) );
[127] Fix | Delete
}
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
#--------------------------------------------------------------------------------
[131] Fix | Delete
#region Request handlers.
[132] Fix | Delete
#--------------------------------------------------------------------------------
[133] Fix | Delete
[134] Fix | Delete
if ( ! function_exists( 'fs_request_get_raw' ) ) {
[135] Fix | Delete
/**
[136] Fix | Delete
* A helper function to fetch GET/POST user input with an optional default value when the input is not set.
[137] Fix | Delete
* This function does not do sanitization. It is up to the caller to properly sanitize and validate the input.
[138] Fix | Delete
*
[139] Fix | Delete
* The return of this function is always unslashed.
[140] Fix | Delete
*
[141] Fix | Delete
* @since 2.5.10
[142] Fix | Delete
*
[143] Fix | Delete
* @param string $key
[144] Fix | Delete
* @param mixed $def
[145] Fix | Delete
* @param string|bool $type When set to 'get', it will look for the value passed via query string. When
[146] Fix | Delete
* set to 'post', it will look for the value passed via the POST request's body. Otherwise,
[147] Fix | Delete
* it will check if the parameter was passed using any of the mentioned two methods.
[148] Fix | Delete
*
[149] Fix | Delete
* @return mixed
[150] Fix | Delete
*/
[151] Fix | Delete
function fs_request_get_raw( $key, $def = false, $type = false ) {
[152] Fix | Delete
if ( is_string( $type ) ) {
[153] Fix | Delete
$type = strtolower( $type );
[154] Fix | Delete
}
[155] Fix | Delete
[156] Fix | Delete
/**
[157] Fix | Delete
* Note to WordPress.org reviewers:
[158] Fix | Delete
* This is a helper function to fetch GET/POST user input with an optional default value when the input is not set. The actual sanitization is done in the scope of the function's usage.
[159] Fix | Delete
*/
[160] Fix | Delete
switch ( $type ) {
[161] Fix | Delete
case 'post':
[162] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Missing
[163] Fix | Delete
$value = isset( $_POST[ $key ] ) ? $_POST[ $key ] : $def;
[164] Fix | Delete
break;
[165] Fix | Delete
case 'get':
[166] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[167] Fix | Delete
$value = isset( $_GET[ $key ] ) ? $_GET[ $key ] : $def;
[168] Fix | Delete
break;
[169] Fix | Delete
default:
[170] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[171] Fix | Delete
$value = isset( $_REQUEST[ $key ] ) ? $_REQUEST[ $key ] : $def;
[172] Fix | Delete
break;
[173] Fix | Delete
}
[174] Fix | Delete
[175] Fix | Delete
// Don't unslash if the value itself is empty (empty string, null, empty array etc).
[176] Fix | Delete
return empty( $value ) ? $value : wp_unslash( $value );
[177] Fix | Delete
}
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
if ( ! function_exists( 'fs_sanitize_input' ) ) {
[181] Fix | Delete
/**
[182] Fix | Delete
* Sanitizes input recursively (if an array).
[183] Fix | Delete
*
[184] Fix | Delete
* @param mixed $input
[185] Fix | Delete
*
[186] Fix | Delete
* @return mixed
[187] Fix | Delete
* @uses sanitize_text_field()
[188] Fix | Delete
* @since 2.5.10
[189] Fix | Delete
*/
[190] Fix | Delete
function fs_sanitize_input( $input ) {
[191] Fix | Delete
if ( is_array( $input ) ) {
[192] Fix | Delete
foreach ( $input as $key => $value ) {
[193] Fix | Delete
$input[ $key ] = fs_sanitize_input( $value );
[194] Fix | Delete
}
[195] Fix | Delete
} else {
[196] Fix | Delete
// Allow empty values to pass through as-is, like `null`, `''`, `0`, `'0'` etc.
[197] Fix | Delete
$input = empty( $input ) ? $input : sanitize_text_field( $input );
[198] Fix | Delete
}
[199] Fix | Delete
[200] Fix | Delete
return $input;
[201] Fix | Delete
}
[202] Fix | Delete
}
[203] Fix | Delete
[204] Fix | Delete
if ( ! function_exists( 'fs_request_get' ) ) {
[205] Fix | Delete
/**
[206] Fix | Delete
* A helper method to fetch GET/POST user input with an optional default value when the input is not set.
[207] Fix | Delete
*
[208] Fix | Delete
* @author Vova Feldman (@svovaf)
[209] Fix | Delete
*
[210] Fix | Delete
* @note The return value is always sanitized with sanitize_text_field().
[211] Fix | Delete
*
[212] Fix | Delete
* @param string $key
[213] Fix | Delete
* @param mixed $def
[214] Fix | Delete
* @param string|bool $type Since 1.2.1.7 - when set to 'get' will look for the value passed via querystring, when
[215] Fix | Delete
* set to 'post' will look for the value passed via the POST request's body, otherwise,
[216] Fix | Delete
* will check if the parameter was passed in any of the two.
[217] Fix | Delete
*
[218] Fix | Delete
*
[219] Fix | Delete
* @return mixed
[220] Fix | Delete
*/
[221] Fix | Delete
function fs_request_get( $key, $def = false, $type = false ) {
[222] Fix | Delete
return fs_sanitize_input( fs_request_get_raw( $key, $def, $type ) );
[223] Fix | Delete
}
[224] Fix | Delete
}
[225] Fix | Delete
[226] Fix | Delete
if ( ! function_exists( 'fs_request_has' ) ) {
[227] Fix | Delete
function fs_request_has( $key ) {
[228] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[229] Fix | Delete
return isset( $_REQUEST[ $key ] );
[230] Fix | Delete
}
[231] Fix | Delete
}
[232] Fix | Delete
[233] Fix | Delete
if ( ! function_exists( 'fs_request_get_bool' ) ) {
[234] Fix | Delete
/**
[235] Fix | Delete
* A helper method to fetch GET/POST user boolean input with an optional default value when the input is not set.
[236] Fix | Delete
*
[237] Fix | Delete
* @author Vova Feldman (@svovaf)
[238] Fix | Delete
*
[239] Fix | Delete
* @param string $key
[240] Fix | Delete
* @param bool $def
[241] Fix | Delete
*
[242] Fix | Delete
* @return bool|mixed
[243] Fix | Delete
*/
[244] Fix | Delete
function fs_request_get_bool( $key, $def = false ) {
[245] Fix | Delete
$val = fs_request_get( $key, null );
[246] Fix | Delete
[247] Fix | Delete
if ( is_null( $val ) ) {
[248] Fix | Delete
return $def;
[249] Fix | Delete
}
[250] Fix | Delete
[251] Fix | Delete
if ( is_bool( $val ) ) {
[252] Fix | Delete
return $val;
[253] Fix | Delete
} else if ( is_numeric( $val ) ) {
[254] Fix | Delete
if ( 1 == $val ) {
[255] Fix | Delete
return true;
[256] Fix | Delete
} else if ( 0 == $val ) {
[257] Fix | Delete
return false;
[258] Fix | Delete
}
[259] Fix | Delete
} else if ( is_string( $val ) ) {
[260] Fix | Delete
$val = strtolower( $val );
[261] Fix | Delete
[262] Fix | Delete
if ( 'true' === $val ) {
[263] Fix | Delete
return true;
[264] Fix | Delete
} else if ( 'false' === $val ) {
[265] Fix | Delete
return false;
[266] Fix | Delete
}
[267] Fix | Delete
}
[268] Fix | Delete
[269] Fix | Delete
return $def;
[270] Fix | Delete
}
[271] Fix | Delete
}
[272] Fix | Delete
[273] Fix | Delete
if ( ! function_exists( 'fs_request_is_post' ) ) {
[274] Fix | Delete
function fs_request_is_post() {
[275] Fix | Delete
return ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) );
[276] Fix | Delete
}
[277] Fix | Delete
}
[278] Fix | Delete
[279] Fix | Delete
if ( ! function_exists( 'fs_request_is_get' ) ) {
[280] Fix | Delete
function fs_request_is_get() {
[281] Fix | Delete
return ( 'get' === strtolower( $_SERVER['REQUEST_METHOD'] ) );
[282] Fix | Delete
}
[283] Fix | Delete
}
[284] Fix | Delete
[285] Fix | Delete
if ( ! function_exists( 'fs_get_action' ) ) {
[286] Fix | Delete
function fs_get_action( $action_key = 'action' ) {
[287] Fix | Delete
// phpcs:disable WordPress.Security.NonceVerification.Recommended
[288] Fix | Delete
if ( ! empty( $_REQUEST[ $action_key ] ) && is_string( $_REQUEST[ $action_key ] ) ) {
[289] Fix | Delete
return strtolower( $_REQUEST[ $action_key ] );
[290] Fix | Delete
}
[291] Fix | Delete
[292] Fix | Delete
if ( 'action' == $action_key ) {
[293] Fix | Delete
$action_key = 'fs_action';
[294] Fix | Delete
[295] Fix | Delete
if ( ! empty( $_REQUEST[ $action_key ] ) && is_string( $_REQUEST[ $action_key ] ) ) {
[296] Fix | Delete
return strtolower( $_REQUEST[ $action_key ] );
[297] Fix | Delete
}
[298] Fix | Delete
}
[299] Fix | Delete
[300] Fix | Delete
return false;
[301] Fix | Delete
// phpcs:enable WordPress.Security.NonceVerification.Recommended
[302] Fix | Delete
}
[303] Fix | Delete
}
[304] Fix | Delete
[305] Fix | Delete
if ( ! function_exists( 'fs_request_is_action' ) ) {
[306] Fix | Delete
function fs_request_is_action( $action, $action_key = 'action' ) {
[307] Fix | Delete
return ( strtolower( $action ) === fs_get_action( $action_key ) );
[308] Fix | Delete
}
[309] Fix | Delete
}
[310] Fix | Delete
[311] Fix | Delete
if ( ! function_exists( 'fs_request_is_action_secure' ) ) {
[312] Fix | Delete
/**
[313] Fix | Delete
* @author Vova Feldman (@svovaf)
[314] Fix | Delete
* @since 1.0.0
[315] Fix | Delete
*
[316] Fix | Delete
* @since 1.2.1.5 Allow nonce verification.
[317] Fix | Delete
*
[318] Fix | Delete
* @param string $action
[319] Fix | Delete
* @param string $action_key
[320] Fix | Delete
* @param string $nonce_key
[321] Fix | Delete
*
[322] Fix | Delete
* @return bool
[323] Fix | Delete
*/
[324] Fix | Delete
function fs_request_is_action_secure(
[325] Fix | Delete
$action,
[326] Fix | Delete
$action_key = 'action',
[327] Fix | Delete
$nonce_key = 'nonce'
[328] Fix | Delete
) {
[329] Fix | Delete
if ( strtolower( $action ) !== fs_get_action( $action_key ) ) {
[330] Fix | Delete
return false;
[331] Fix | Delete
}
[332] Fix | Delete
[333] Fix | Delete
$nonce = ! empty( $_REQUEST[ $nonce_key ] ) ?
[334] Fix | Delete
$_REQUEST[ $nonce_key ] :
[335] Fix | Delete
'';
[336] Fix | Delete
[337] Fix | Delete
if ( empty( $nonce ) ||
[338] Fix | Delete
( false === wp_verify_nonce( $nonce, $action ) )
[339] Fix | Delete
) {
[340] Fix | Delete
return false;
[341] Fix | Delete
}
[342] Fix | Delete
[343] Fix | Delete
return true;
[344] Fix | Delete
}
[345] Fix | Delete
}
[346] Fix | Delete
[347] Fix | Delete
#endregion
[348] Fix | Delete
[349] Fix | Delete
if ( ! function_exists( 'fs_is_plugin_page' ) ) {
[350] Fix | Delete
function fs_is_plugin_page( $page_slug ) {
[351] Fix | Delete
return ( is_admin() && $page_slug === fs_request_get( 'page' ) );
[352] Fix | Delete
}
[353] Fix | Delete
}
[354] Fix | Delete
[355] Fix | Delete
if ( ! function_exists( 'fs_get_raw_referer' ) ) {
[356] Fix | Delete
/**
[357] Fix | Delete
* Retrieves unvalidated referer from '_wp_http_referer' or HTTP referer.
[358] Fix | Delete
*
[359] Fix | Delete
* Do not use for redirects, use {@see wp_get_referer()} instead.
[360] Fix | Delete
*
[361] Fix | Delete
* @since 1.2.3
[362] Fix | Delete
*
[363] Fix | Delete
* @return string|false Referer URL on success, false on failure.
[364] Fix | Delete
*/
[365] Fix | Delete
function fs_get_raw_referer() {
[366] Fix | Delete
if ( function_exists( 'wp_get_raw_referer' ) ) {
[367] Fix | Delete
return wp_get_raw_referer();
[368] Fix | Delete
}
[369] Fix | Delete
if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
[370] Fix | Delete
return wp_unslash( $_REQUEST['_wp_http_referer'] );
[371] Fix | Delete
} else if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
[372] Fix | Delete
return wp_unslash( $_SERVER['HTTP_REFERER'] );
[373] Fix | Delete
}
[374] Fix | Delete
[375] Fix | Delete
return false;
[376] Fix | Delete
}
[377] Fix | Delete
}
[378] Fix | Delete
[379] Fix | Delete
/* Core UI.
[380] Fix | Delete
--------------------------------------------------------------------------------------------*/
[381] Fix | Delete
if ( ! function_exists( 'fs_ui_action_button' ) ) {
[382] Fix | Delete
/**
[383] Fix | Delete
* @param number $module_id
[384] Fix | Delete
* @param string $page
[385] Fix | Delete
* @param string $action
[386] Fix | Delete
* @param string $title
[387] Fix | Delete
* @param string $button_class
[388] Fix | Delete
* @param array $params
[389] Fix | Delete
* @param bool $is_primary
[390] Fix | Delete
* @param bool $is_small
[391] Fix | Delete
* @param string|bool $icon_class Optional class for an icon (since 1.1.7).
[392] Fix | Delete
* @param string|bool $confirmation Optional confirmation message before submit (since 1.1.7).
[393] Fix | Delete
* @param string $method Since 1.1.7
[394] Fix | Delete
*
[395] Fix | Delete
* @uses fs_ui_get_action_button()
[396] Fix | Delete
*/
[397] Fix | Delete
function fs_ui_action_button(
[398] Fix | Delete
$module_id,
[399] Fix | Delete
$page,
[400] Fix | Delete
$action,
[401] Fix | Delete
$title,
[402] Fix | Delete
$button_class = '',
[403] Fix | Delete
$params = array(),
[404] Fix | Delete
$is_primary = true,
[405] Fix | Delete
$is_small = false,
[406] Fix | Delete
$icon_class = false,
[407] Fix | Delete
$confirmation = false,
[408] Fix | Delete
$method = 'GET'
[409] Fix | Delete
) {
[410] Fix | Delete
echo fs_ui_get_action_button(
[411] Fix | Delete
$module_id,
[412] Fix | Delete
$page,
[413] Fix | Delete
$action,
[414] Fix | Delete
$title,
[415] Fix | Delete
$button_class,
[416] Fix | Delete
$params,
[417] Fix | Delete
$is_primary,
[418] Fix | Delete
$is_small,
[419] Fix | Delete
$icon_class,
[420] Fix | Delete
$confirmation,
[421] Fix | Delete
$method
[422] Fix | Delete
);
[423] Fix | Delete
}
[424] Fix | Delete
}
[425] Fix | Delete
[426] Fix | Delete
if ( ! function_exists( 'fs_ui_get_action_button' ) ) {
[427] Fix | Delete
/**
[428] Fix | Delete
* @author Vova Feldman (@svovaf)
[429] Fix | Delete
* @since 1.1.7
[430] Fix | Delete
*
[431] Fix | Delete
* @param number $module_id
[432] Fix | Delete
* @param string $page
[433] Fix | Delete
* @param string $action
[434] Fix | Delete
* @param string $title
[435] Fix | Delete
* @param string $button_class
[436] Fix | Delete
* @param array $params
[437] Fix | Delete
* @param bool $is_primary
[438] Fix | Delete
* @param bool $is_small
[439] Fix | Delete
* @param string|bool $icon_class Optional class for an icon.
[440] Fix | Delete
* @param string|bool $confirmation Optional confirmation message before submit.
[441] Fix | Delete
* @param string $method
[442] Fix | Delete
*
[443] Fix | Delete
* @return string
[444] Fix | Delete
*/
[445] Fix | Delete
function fs_ui_get_action_button(
[446] Fix | Delete
$module_id,
[447] Fix | Delete
$page,
[448] Fix | Delete
$action,
[449] Fix | Delete
$title,
[450] Fix | Delete
$button_class = '',
[451] Fix | Delete
$params = array(),
[452] Fix | Delete
$is_primary = true,
[453] Fix | Delete
$is_small = false,
[454] Fix | Delete
$icon_class = false,
[455] Fix | Delete
$confirmation = false,
[456] Fix | Delete
$method = 'GET'
[457] Fix | Delete
) {
[458] Fix | Delete
// Prepend icon (if set).
[459] Fix | Delete
$title = ( is_string( $icon_class ) ? '<i class="' . $icon_class . '"></i> ' : '' ) . $title;
[460] Fix | Delete
[461] Fix | Delete
if ( is_string( $confirmation ) ) {
[462] Fix | Delete
return sprintf( '<form action="%s" method="%s"><input type="hidden" name="fs_action" value="%s">%s<a href="#" class="%s" onclick="if (confirm(\'%s\')) this.parentNode.submit(); return false;">%s</a></form>',
[463] Fix | Delete
freemius( $module_id )->_get_admin_page_url( $page, $params ),
[464] Fix | Delete
$method,
[465] Fix | Delete
$action,
[466] Fix | Delete
wp_nonce_field( $action, '_wpnonce', true, false ),
[467] Fix | Delete
'button' . ( ! empty( $button_class ) ? ' ' . $button_class : '' ) . ( $is_primary ? ' button-primary' : '' ) . ( $is_small ? ' button-small' : '' ),
[468] Fix | Delete
$confirmation,
[469] Fix | Delete
$title
[470] Fix | Delete
);
[471] Fix | Delete
} else if ( 'GET' !== strtoupper( $method ) ) {
[472] Fix | Delete
return sprintf( '<form action="%s" method="%s"><input type="hidden" name="fs_action" value="%s">%s<a href="#" class="%s" onclick="this.parentNode.submit(); return false;">%s</a></form>',
[473] Fix | Delete
freemius( $module_id )->_get_admin_page_url( $page, $params ),
[474] Fix | Delete
$method,
[475] Fix | Delete
$action,
[476] Fix | Delete
wp_nonce_field( $action, '_wpnonce', true, false ),
[477] Fix | Delete
'button' . ( ! empty( $button_class ) ? ' ' . $button_class : '' ) . ( $is_primary ? ' button-primary' : '' ) . ( $is_small ? ' button-small' : '' ),
[478] Fix | Delete
$title
[479] Fix | Delete
);
[480] Fix | Delete
} else {
[481] Fix | Delete
return sprintf( '<a href="%s" class="%s">%s</a></form>',
[482] Fix | Delete
wp_nonce_url( freemius( $module_id )->_get_admin_page_url( $page, array_merge( $params, array( 'fs_action' => $action ) ) ), $action ),
[483] Fix | Delete
'button' . ( ! empty( $button_class ) ? ' ' . $button_class : '' ) . ( $is_primary ? ' button-primary' : '' ) . ( $is_small ? ' button-small' : '' ),
[484] Fix | Delete
$title
[485] Fix | Delete
);
[486] Fix | Delete
}
[487] Fix | Delete
}
[488] Fix | Delete
[489] Fix | Delete
function fs_ui_action_link( $module_id, $page, $action, $title, $params = array() ) {
[490] Fix | Delete
?><a class=""
[491] Fix | Delete
href="<?php echo wp_nonce_url( freemius( $module_id )->_get_admin_page_url( $page, array_merge( $params, array( 'fs_action' => $action ) ) ), $action ) ?>"><?php echo $title ?></a><?php
[492] Fix | Delete
}
[493] Fix | Delete
}
[494] Fix | Delete
[495] Fix | Delete
if ( ! function_exists( 'fs_get_entity' ) ) {
[496] Fix | Delete
/**
[497] Fix | Delete
* @author Leo Fajardo (@leorw)
[498] Fix | Delete
* @since 2.3.1
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function