| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/wp-content/plugins/nav-menu-collapse/includes/static/ |
Upload File : |
<?php
/*!
* Plugin setup functionality.
*
* @since 2.0.0
*
* @package Nav Menu Collapse
* @subpackage Setup
*/
if (!defined('ABSPATH'))
{
exit;
}
/**
* Class used to implement the setup functionality.
*
* @since 2.0.0
*/
final class Nav_Menu_Collapse_Setup
{
/**
* Check and update the plugin version.
*
* @since 2.0.2 Improved version sanitization.
* @since 2.0.1 Improved condition and changed force previous version definition.
* @since 2.0.0
*
* @access public static
* @return void
*/
public static function check_version()
{
$current_version =
(
!defined('NDT_FORCE_PREVIOUS_VERSION')
||
!NDT_FORCE_PREVIOUS_VERSION
)
? wp_unslash(get_option(Nav_Menu_Collapse_Constants::OPTION_VERSION))
: '2.0.1';
if (empty($current_version))
{
add_option(Nav_Menu_Collapse_Constants::OPTION_VERSION, sanitize_text_field(Nav_Menu_Collapse_Constants::VERSION));
}
else if ($current_version !== Nav_Menu_Collapse_Constants::VERSION)
{
update_option(Nav_Menu_Collapse_Constants::OPTION_VERSION, sanitize_text_field(Nav_Menu_Collapse_Constants::VERSION));
if (version_compare($current_version, '2.0.0', '<'))
{
self::_pre_two_zero_zero($current_version);
}
}
}
/**
* Clean up plugin settings for plugin versions earlier than 2.0.0.
*
* @since 2.0.3 Minor MySQL query cleanup.
* @since 2.0.2 Added option unslashing.
* @since 2.0.0
*
* @access private static
* @param string $current_version Current version of the plugin.
* @return void
*/
private static function _pre_two_zero_zero($current_version)
{
global $wpdb;
$wpdb->query($wpdb->prepare
(
"UPDATE
$wpdb->usermeta
SET
meta_key = %s
WHERE
meta_key = 'nmc_collapsed';\n",
Nav_Menu_Collapse_Constants::USER_META_COLLAPSED
));
$plugin_settings = wp_unslash(get_option(Nav_Menu_Collapse_Constants::OPTION_SETTINGS));
if (is_array($plugin_settings))
{
if (version_compare($current_version, '1.1.0', '<'))
{
$plugin_settings = self::_pre_one_one_zero($plugin_settings);
}
unset($plugin_settings['disable_help_buttons']);
unset($plugin_settings['disable_help_tabs']);
update_option(Nav_Menu_Collapse_Constants::OPTION_SETTINGS, $plugin_settings);
Nav_Menu_Collapse()->settings->load_option($plugin_settings);
}
}
/**
* Clean up plugin settings for plugin versions earlier than 1.1.0.
*
* @since 2.0.0
*
* @access private static
* @param array $plugin_settings Loaded plugin settings.
* @return array Modified plugin settings.
*/
private static function _pre_one_one_zero($plugin_settings)
{
$plugin_settings['store_collapsed_states'] = '1';
return $plugin_settings;
}
}