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: class-fs-admin-notices.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 2.0.0
[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
/**
[12] Fix | Delete
* WP Admin notices manager both for site level and network level.
[13] Fix | Delete
*
[14] Fix | Delete
* Class FS_Admin_Notices
[15] Fix | Delete
*/
[16] Fix | Delete
class FS_Admin_Notices {
[17] Fix | Delete
/**
[18] Fix | Delete
* @since 1.2.2
[19] Fix | Delete
*
[20] Fix | Delete
* @var string
[21] Fix | Delete
*/
[22] Fix | Delete
protected $_module_unique_affix;
[23] Fix | Delete
/**
[24] Fix | Delete
* @var string
[25] Fix | Delete
*/
[26] Fix | Delete
protected $_id;
[27] Fix | Delete
/**
[28] Fix | Delete
* @var string
[29] Fix | Delete
*/
[30] Fix | Delete
protected $_title;
[31] Fix | Delete
/**
[32] Fix | Delete
* @var FS_Admin_Notice_Manager
[33] Fix | Delete
*/
[34] Fix | Delete
protected $_notices;
[35] Fix | Delete
/**
[36] Fix | Delete
* @var FS_Admin_Notice_Manager
[37] Fix | Delete
*/
[38] Fix | Delete
protected $_network_notices;
[39] Fix | Delete
/**
[40] Fix | Delete
* @var int The ID of the blog that is associated with the current site level options.
[41] Fix | Delete
*/
[42] Fix | Delete
private $_blog_id = 0;
[43] Fix | Delete
/**
[44] Fix | Delete
* @var bool
[45] Fix | Delete
*/
[46] Fix | Delete
private $_is_multisite;
[47] Fix | Delete
/**
[48] Fix | Delete
* @var FS_Admin_Notices[]
[49] Fix | Delete
*/
[50] Fix | Delete
private static $_instances = array();
[51] Fix | Delete
[52] Fix | Delete
/**
[53] Fix | Delete
* @param string $id
[54] Fix | Delete
* @param string $title
[55] Fix | Delete
* @param string $module_unique_affix
[56] Fix | Delete
* @param bool $is_network_and_blog_admins Whether or not the message should be shown both on network and
[57] Fix | Delete
* blog admin pages.
[58] Fix | Delete
*
[59] Fix | Delete
* @return FS_Admin_Notices
[60] Fix | Delete
*/
[61] Fix | Delete
static function instance( $id, $title = '', $module_unique_affix = '', $is_network_and_blog_admins = false ) {
[62] Fix | Delete
if ( ! isset( self::$_instances[ $id ] ) ) {
[63] Fix | Delete
self::$_instances[ $id ] = new FS_Admin_Notices( $id, $title, $module_unique_affix, $is_network_and_blog_admins );
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
return self::$_instances[ $id ];
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
/**
[70] Fix | Delete
* @param string $id
[71] Fix | Delete
* @param string $title
[72] Fix | Delete
* @param string $module_unique_affix
[73] Fix | Delete
* @param bool $is_network_and_blog_admins Whether or not the message should be shown both on network and
[74] Fix | Delete
* blog admin pages.
[75] Fix | Delete
*/
[76] Fix | Delete
protected function __construct( $id, $title = '', $module_unique_affix = '', $is_network_and_blog_admins = false ) {
[77] Fix | Delete
$this->_id = $id;
[78] Fix | Delete
$this->_title = $title;
[79] Fix | Delete
$this->_module_unique_affix = $module_unique_affix;
[80] Fix | Delete
$this->_is_multisite = is_multisite();
[81] Fix | Delete
[82] Fix | Delete
if ( $this->_is_multisite ) {
[83] Fix | Delete
$this->_blog_id = get_current_blog_id();
[84] Fix | Delete
[85] Fix | Delete
$this->_network_notices = FS_Admin_Notice_Manager::instance(
[86] Fix | Delete
$id,
[87] Fix | Delete
$title,
[88] Fix | Delete
$module_unique_affix,
[89] Fix | Delete
$is_network_and_blog_admins,
[90] Fix | Delete
true
[91] Fix | Delete
);
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
$this->_notices = FS_Admin_Notice_Manager::instance(
[95] Fix | Delete
$id,
[96] Fix | Delete
$title,
[97] Fix | Delete
$module_unique_affix,
[98] Fix | Delete
false,
[99] Fix | Delete
$this->_blog_id
[100] Fix | Delete
);
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
/**
[104] Fix | Delete
* Add admin message to admin messages queue, and hook to admin_notices / all_admin_notices if not yet hooked.
[105] Fix | Delete
*
[106] Fix | Delete
* @author Vova Feldman (@svovaf)
[107] Fix | Delete
* @since 1.0.4
[108] Fix | Delete
*
[109] Fix | Delete
* @param string $message
[110] Fix | Delete
* @param string $title
[111] Fix | Delete
* @param string $type
[112] Fix | Delete
* @param bool $is_sticky
[113] Fix | Delete
* @param string $id Message ID
[114] Fix | Delete
* @param bool $store_if_sticky
[115] Fix | Delete
* @param int|null $network_level_or_blog_id
[116] Fix | Delete
*
[117] Fix | Delete
* @uses add_action()
[118] Fix | Delete
*/
[119] Fix | Delete
function add(
[120] Fix | Delete
$message,
[121] Fix | Delete
$title = '',
[122] Fix | Delete
$type = 'success',
[123] Fix | Delete
$is_sticky = false,
[124] Fix | Delete
$id = '',
[125] Fix | Delete
$store_if_sticky = true,
[126] Fix | Delete
$network_level_or_blog_id = null,
[127] Fix | Delete
$is_dimissible = null
[128] Fix | Delete
) {
[129] Fix | Delete
$notices = $this->get_site_or_network_notices( $id, $network_level_or_blog_id );
[130] Fix | Delete
[131] Fix | Delete
$notices->add(
[132] Fix | Delete
$message,
[133] Fix | Delete
$title,
[134] Fix | Delete
$type,
[135] Fix | Delete
$is_sticky,
[136] Fix | Delete
$id,
[137] Fix | Delete
$store_if_sticky,
[138] Fix | Delete
null,
[139] Fix | Delete
null,
[140] Fix | Delete
false,
[141] Fix | Delete
$is_dimissible
[142] Fix | Delete
);
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
/**
[146] Fix | Delete
* @author Vova Feldman (@svovaf)
[147] Fix | Delete
* @since 1.0.7
[148] Fix | Delete
*
[149] Fix | Delete
* @param string|string[] $ids
[150] Fix | Delete
* @param int|null $network_level_or_blog_id
[151] Fix | Delete
* @param bool $store
[152] Fix | Delete
*/
[153] Fix | Delete
function remove_sticky( $ids, $network_level_or_blog_id = null, $store = true ) {
[154] Fix | Delete
if ( ! is_array( $ids ) ) {
[155] Fix | Delete
$ids = array( $ids );
[156] Fix | Delete
}
[157] Fix | Delete
[158] Fix | Delete
if ( $this->should_use_network_notices( $ids[0], $network_level_or_blog_id ) ) {
[159] Fix | Delete
$notices = $this->_network_notices;
[160] Fix | Delete
} else {
[161] Fix | Delete
$notices = $this->get_site_notices( $network_level_or_blog_id );
[162] Fix | Delete
}
[163] Fix | Delete
[164] Fix | Delete
return $notices->remove_sticky( $ids, $store );
[165] Fix | Delete
}
[166] Fix | Delete
[167] Fix | Delete
/**
[168] Fix | Delete
* Check if sticky message exists by id.
[169] Fix | Delete
*
[170] Fix | Delete
* @author Vova Feldman (@svovaf)
[171] Fix | Delete
* @since 1.0.9
[172] Fix | Delete
*
[173] Fix | Delete
* @param string $id
[174] Fix | Delete
* @param int|null $network_level_or_blog_id
[175] Fix | Delete
*
[176] Fix | Delete
* @return bool
[177] Fix | Delete
*/
[178] Fix | Delete
function has_sticky( $id, $network_level_or_blog_id = null ) {
[179] Fix | Delete
$notices = $this->get_site_or_network_notices( $id, $network_level_or_blog_id );
[180] Fix | Delete
[181] Fix | Delete
return $notices->has_sticky( $id );
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
/**
[185] Fix | Delete
* Adds sticky admin notification.
[186] Fix | Delete
*
[187] Fix | Delete
* @author Vova Feldman (@svovaf)
[188] Fix | Delete
* @since 1.0.7
[189] Fix | Delete
*
[190] Fix | Delete
* @param string $message
[191] Fix | Delete
* @param string $id Message ID
[192] Fix | Delete
* @param string $title
[193] Fix | Delete
* @param string $type
[194] Fix | Delete
* @param int|null $network_level_or_blog_id
[195] Fix | Delete
* @param number|null $wp_user_id
[196] Fix | Delete
* @param string|null $plugin_title
[197] Fix | Delete
* @param bool $is_network_and_blog_admins Whether or not the message should be shown both on network and
[198] Fix | Delete
* blog admin pages.
[199] Fix | Delete
* @param bool $is_dismissible
[200] Fix | Delete
*/
[201] Fix | Delete
function add_sticky(
[202] Fix | Delete
$message,
[203] Fix | Delete
$id,
[204] Fix | Delete
$title = '',
[205] Fix | Delete
$type = 'success',
[206] Fix | Delete
$network_level_or_blog_id = null,
[207] Fix | Delete
$wp_user_id = null,
[208] Fix | Delete
$plugin_title = null,
[209] Fix | Delete
$is_network_and_blog_admins = false,
[210] Fix | Delete
$is_dismissible = true,
[211] Fix | Delete
$data = array()
[212] Fix | Delete
) {
[213] Fix | Delete
$notices = $this->get_site_or_network_notices( $id, $network_level_or_blog_id );
[214] Fix | Delete
[215] Fix | Delete
$notices->add_sticky( $message, $id, $title, $type, $wp_user_id, $plugin_title, $is_network_and_blog_admins, $is_dismissible, $data );
[216] Fix | Delete
}
[217] Fix | Delete
[218] Fix | Delete
/**
[219] Fix | Delete
* Retrieves the data of a sticky notice.
[220] Fix | Delete
*
[221] Fix | Delete
* @author Leo Fajardo (@leorw)
[222] Fix | Delete
* @since 2.4.3
[223] Fix | Delete
*
[224] Fix | Delete
* @param string $id
[225] Fix | Delete
* @param int|null $network_level_or_blog_id
[226] Fix | Delete
*
[227] Fix | Delete
* @return array|null
[228] Fix | Delete
*/
[229] Fix | Delete
function get_sticky( $id, $network_level_or_blog_id ) {
[230] Fix | Delete
$notices = $this->get_site_or_network_notices( $id, $network_level_or_blog_id );
[231] Fix | Delete
[232] Fix | Delete
return $notices->get_sticky( $id );
[233] Fix | Delete
}
[234] Fix | Delete
[235] Fix | Delete
/**
[236] Fix | Delete
* Clear all sticky messages.
[237] Fix | Delete
*
[238] Fix | Delete
* @author Vova Feldman (@svovaf)
[239] Fix | Delete
* @since 2.0.0
[240] Fix | Delete
*
[241] Fix | Delete
* @param int|null $network_level_or_blog_id
[242] Fix | Delete
* @param bool $is_temporary
[243] Fix | Delete
*/
[244] Fix | Delete
function clear_all_sticky( $network_level_or_blog_id = null, $is_temporary = false ) {
[245] Fix | Delete
if ( ! $this->_is_multisite ||
[246] Fix | Delete
false === $network_level_or_blog_id ||
[247] Fix | Delete
0 == $network_level_or_blog_id ||
[248] Fix | Delete
is_null( $network_level_or_blog_id )
[249] Fix | Delete
) {
[250] Fix | Delete
$notices = $this->get_site_notices( $network_level_or_blog_id );
[251] Fix | Delete
$notices->clear_all_sticky( $is_temporary );
[252] Fix | Delete
}
[253] Fix | Delete
[254] Fix | Delete
if ( $this->_is_multisite &&
[255] Fix | Delete
( true === $network_level_or_blog_id || is_null( $network_level_or_blog_id ) )
[256] Fix | Delete
) {
[257] Fix | Delete
$this->_network_notices->clear_all_sticky( $is_temporary );
[258] Fix | Delete
}
[259] Fix | Delete
}
[260] Fix | Delete
[261] Fix | Delete
/**
[262] Fix | Delete
* Add admin message to all admin messages queue, and hook to all_admin_notices if not yet hooked.
[263] Fix | Delete
*
[264] Fix | Delete
* @author Vova Feldman (@svovaf)
[265] Fix | Delete
* @since 1.0.4
[266] Fix | Delete
*
[267] Fix | Delete
* @param string $message
[268] Fix | Delete
* @param string $title
[269] Fix | Delete
* @param string $type
[270] Fix | Delete
* @param bool $is_sticky
[271] Fix | Delete
* @param string $id Message ID
[272] Fix | Delete
*/
[273] Fix | Delete
function add_all( $message, $title = '', $type = 'success', $is_sticky = false, $id = '' ) {
[274] Fix | Delete
$this->add( $message, $title, $type, $is_sticky, true, $id );
[275] Fix | Delete
}
[276] Fix | Delete
[277] Fix | Delete
#--------------------------------------------------------------------------------
[278] Fix | Delete
#region Helper Methods
[279] Fix | Delete
#--------------------------------------------------------------------------------
[280] Fix | Delete
[281] Fix | Delete
/**
[282] Fix | Delete
* @author Vova Feldman (@svovaf)
[283] Fix | Delete
* @since 2.0.0
[284] Fix | Delete
*
[285] Fix | Delete
* @param int $blog_id
[286] Fix | Delete
*
[287] Fix | Delete
* @return FS_Admin_Notice_Manager
[288] Fix | Delete
*/
[289] Fix | Delete
private function get_site_notices( $blog_id = 0 ) {
[290] Fix | Delete
if ( 0 == $blog_id || $blog_id == $this->_blog_id ) {
[291] Fix | Delete
return $this->_notices;
[292] Fix | Delete
}
[293] Fix | Delete
[294] Fix | Delete
return FS_Admin_Notice_Manager::instance(
[295] Fix | Delete
$this->_id,
[296] Fix | Delete
$this->_title,
[297] Fix | Delete
$this->_module_unique_affix,
[298] Fix | Delete
false,
[299] Fix | Delete
$blog_id
[300] Fix | Delete
);
[301] Fix | Delete
}
[302] Fix | Delete
[303] Fix | Delete
/**
[304] Fix | Delete
* Check if the network notices should be used.
[305] Fix | Delete
*
[306] Fix | Delete
* @author Vova Feldman (@svovaf)
[307] Fix | Delete
* @since 2.0.0
[308] Fix | Delete
*
[309] Fix | Delete
* @param string $id
[310] Fix | Delete
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite notices (if there's a network). When `false`, use the current context blog notices. When `null`, the decision which notices manager to use (MS vs. Current S) will be handled internally and determined based on the $id and the context admin (blog admin vs. network level admin).
[311] Fix | Delete
*
[312] Fix | Delete
* @return bool
[313] Fix | Delete
*/
[314] Fix | Delete
private function should_use_network_notices( $id = '', $network_level_or_blog_id = null ) {
[315] Fix | Delete
if ( ! $this->_is_multisite ) {
[316] Fix | Delete
// Not a multisite environment.
[317] Fix | Delete
return false;
[318] Fix | Delete
}
[319] Fix | Delete
[320] Fix | Delete
if ( is_numeric( $network_level_or_blog_id ) ) {
[321] Fix | Delete
// Explicitly asked to use a specified blog storage.
[322] Fix | Delete
return false;
[323] Fix | Delete
}
[324] Fix | Delete
[325] Fix | Delete
if ( is_bool( $network_level_or_blog_id ) ) {
[326] Fix | Delete
// Explicitly specified whether should use the network or blog level storage.
[327] Fix | Delete
return $network_level_or_blog_id;
[328] Fix | Delete
}
[329] Fix | Delete
[330] Fix | Delete
return fs_is_network_admin();
[331] Fix | Delete
}
[332] Fix | Delete
[333] Fix | Delete
/**
[334] Fix | Delete
* Retrieves an instance of FS_Admin_Notice_Manager.
[335] Fix | Delete
*
[336] Fix | Delete
* @author Leo Fajardo (@leorw)
[337] Fix | Delete
* @since 2.5.0
[338] Fix | Delete
*
[339] Fix | Delete
* @param string $id
[340] Fix | Delete
* @param int|null $network_level_or_blog_id
[341] Fix | Delete
*
[342] Fix | Delete
* @return FS_Admin_Notice_Manager
[343] Fix | Delete
*/
[344] Fix | Delete
private function get_site_or_network_notices( $id, $network_level_or_blog_id ) {
[345] Fix | Delete
return $this->should_use_network_notices( $id, $network_level_or_blog_id ) ?
[346] Fix | Delete
$this->_network_notices :
[347] Fix | Delete
$this->get_site_notices( $network_level_or_blog_id );
[348] Fix | Delete
}
[349] Fix | Delete
[350] Fix | Delete
#endregion
[351] Fix | Delete
}
[352] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function