function compatibility_check() { global $wpdb; global $wp_version; $data = array(); // PHP if (version_compare(PHP_VERSION, '5.3', '<')) { $data['php'] = array('status' => 'warning', 'message' => sprintf(__('Your PHP version (%s) is lower than recommended (%s).', OP_SN), PHP_VERSION, '5.3')); } else { $data['php'] = array('status' => 'ok', 'message' => sprintf(__('Your PHP version (%s) meets requirements (%s).', OP_SN), PHP_VERSION, '5.3')); } // MySQL if (version_compare($wpdb->db_version(), '5.0', '<')) { $data['mysql'] = array('status' => 'error', 'message' => sprintf(__('Your MySQL version (%s) is lower than required (%s).', OP_SN), $wpdb->db_version(), '5.0')); } else { $data['mysql'] = array('status' => 'ok', 'message' => sprintf(__('Your MySQL version (%s) meets requirements (%s).', OP_SN), $wpdb->db_version(), '5.0')); } // WP if (version_compare($wp_version, '3.5', '<')) { $data['wordpress'] = array('status' => 'warning', 'message' => sprintf(__('Your WordPress version (%s) is lower than recommended (%s).', OP_SN), $wp_version, '3.5')); } else { $data['wordpress'] = array('status' => 'ok', 'message' => sprintf(__('Your WordPress version (%s) meets requirements (%s).', OP_SN), $wp_version, '3.5')); } // Transfer protocols (curl, streams) $http = new Wp_Http(); if (false === $http->_get_first_available_transport(array())) { $data['transfer'] = array('status' => 'error', 'message' => __('There are no transport protocols (curl, streams) that are capable of handling the requests.', OP_SN)); } else { $data['transfer'] = array('status' => 'ok', 'message' => __('Transfer protocols (curl, streams) are in order.', OP_SN)); } // OP SL if (true !== op_sl_ping()) { $data['op_sl'] = array('status' => 'error', 'message' => __('Unable to connect to OptimizePress Security & Licensing service.', OP_SN)); } else { $data['op_sl'] = array('status' => 'ok', 'message' => __('Connection with OptimizePress Security & Licensing service is in order.', OP_SN)); } // OP Eligibility if (true !== op_sl_eligible()) { $data['op_sl'] = array('status' => 'warning', 'message' => sprintf(__('You are not eligible for new updates. You can prolong your subscription <a href="%s" target="_blank">here</a>.', OP_SN), 'http://optimizepress.com')); } // Permalink structure if ('' === ($permalink_structure = get_option('permalink_structure', ''))) { $data['permalink'] = array('status' => 'error', 'message' => sprintf(__('Permalink structure must not be set to "default" for OptimizePress to work correctly. Please change the <a href="%s">setting</a>.', OP_SN), admin_url('options-permalink.php'))); } else { $data['permalink'] = array('status' => 'ok', 'message' => sprintf(__('Permalink structure is in order (%s).', OP_SN), trim($permalink_structure, '/'))); } // Memory limit $memory_limit = wp_convert_hr_to_bytes(ini_get('memory_limit')) / 1024 / 1024; if ($memory_limit < 64) { $data['memory'] = array('status' => 'warning', 'message' => sprintf(__('Your memory limit (%sMB) is lower than recommended (%sMB)', OP_SN), $memory_limit, 64)); } else { $data['memory'] = array('status' => 'ok', 'message' => sprintf(__('Your memory limit (%sMB) meets recommendation (%sMB)', OP_SN), $memory_limit, 64)); } // Upload limit $upload_limit = wp_max_upload_size() / 1024 / 1024; if ($upload_limit < 32) { $data['upload'] = array('status' => 'warning', 'message' => sprintf(__('Your upload limit (%sMB) is lower than recommended (%sMB).', OP_SN), $upload_limit, 32)); } else { $data['upload'] = array('status' => 'ok', 'message' => sprintf(__('Your upload limit (%sMB) meets recommendation (%sMB).', OP_SN), $upload_limit, 32)); } // Max input vars $input_vars_limit = ini_get('max_input_vars'); if ($input_vars_limit < 3000) { $data['input_vars'] = array('status' => 'info', 'message' => sprintf(__('Your "max_input_vars" setting is set to %s. If you plan to have pages with a large number of elements on it, you should raise this setting to at least %s.', OP_SN), $input_vars_limit ? $input_vars_limit : 1000, 3000)); } else { $data['input_vars'] = array('status' => 'ok', 'message' => sprintf(__('Your "max_input_vars" (%s) meets recommendation (%s).', OP_SN), $input_vars_limit, 3000)); } // Max execution time $execution_time = ini_get('max_execution_time'); if ($execution_time < 60) { $data['execution_time'] = array('status' => 'info', 'message' => sprintf(__('Your "max_execution_time" setting (%s) is lower than recommended (%s).', OP_SN), $execution_time ? $execution_time : 30, 60)); } else { $data['execution_time'] = array('status' => 'ok', 'message' => sprintf(__('Your "max_execution_time" (%s) meets recommendation (%s).', OP_SN), $execution_time, 60)); } echo op_load_section('compatibility_check', array('compat' => $data), 'global_settings'); }
/** * Checks if user is eligible for updates and show him nag message * @since 2.2.2 * @return void */ function checkEligibility() { /* * User can disable eligibility notice, in that case nag won't be shown */ if ('disabled' === get_transient(OptimizePress_Sl_Api::OPTION_ELIGIBILITY_STATUS . '_disabled')) { return; } /* * We need to skip if user hasn't added API key yet */ $apiKey = op_sl_get_key(); if (empty($apiKey)) { return; } /* * Lets check transients */ if (false === ($eligibility = get_transient(OptimizePress_Sl_Api::OPTION_ELIGIBILITY_STATUS))) { $eligibility = array('installation_url' => op_sl_get_url(), 'status' => op_sl_eligible() === true ? 1 : 0); } set_transient(OptimizePress_Sl_Api::OPTION_ELIGIBILITY_STATUS, $eligibility, MINUTE_IN_SECONDS * 15); /* * If API key and URL combo is valid we are done */ if ((int) $eligibility['status'] === 1 && $eligibility['installation_url'] === op_sl_get_url()) { return; } /* * We are nagging the user with our message */ echo '<div class="update-nag">' . sprintf(__('You are not eligible for new updates. You can <a href="%s" target="_blank">prolong your subscription</a> or <a href="%s">disable this notification</a>.', OP_SN), 'http://www.optimizepress.com/updates-renewal/', admin_url('admin.php?action=optimizepress-disable-eligibility')) . '</div>'; }
/** * Return environment data * @return array */ protected function getEnvironmentRows() { if (!isset($this->environment)) { global $wpdb, $wp_version; $items['home_url'] = array('status' => 'ok', 'label' => __('Home URL', 'optimizepress'), 'message' => home_url()); $items['site_url'] = array('status' => 'ok', 'label' => __('Site URL', 'optimizepress'), 'message' => site_url()); if (version_compare($wp_version, '3.5', '<')) { $items['wp_version'] = array('status' => 'warning', 'label' => __('WP Version', 'optimizepress'), 'message' => sprintf(__('Your WordPress version (%s) is lower than recommended (%s).', 'optimizepress'), $wp_version, '3.5')); } else { $items['wp_version'] = array('status' => 'ok', 'label' => __('WP Version', 'optimizepress'), 'message' => $wp_version); } $items['wp_multisite'] = array('status' => 'ok', 'label' => __('WP Multisite Enabled', 'optimizepress'), 'message' => is_multisite() ? __('Yes', 'optimizepress') : __('No', 'optimizepress')); // Server settings $items['web_server'] = array('status' => 'ok', 'label' => __('Web Server', 'optimizepress'), 'message' => esc_html($_SERVER['SERVER_SOFTWARE'])); if (version_compare(PHP_VERSION, '5.3', '<')) { $items['php_version'] = array('label' => __('PHP Version', 'optimizepress'), 'status' => 'warning', 'message' => sprintf(__('Your PHP version (%s) is lower than recommended (%s).', 'optimizepress'), PHP_VERSION, '5.3')); } else { $items['php_version'] = array('label' => __('PHP Version', 'optimizepress'), 'status' => 'ok', 'message' => PHP_VERSION); } if (version_compare($wpdb->db_version(), '5.0', '<')) { $items['mysql_version'] = array('label' => __('MySQL Version', 'optimizepress'), 'status' => 'error', 'message' => sprintf(__('Your MySQL version (%s) is lower than required (%s).', 'optimizepress'), $wpdb->db_version(), '5.0')); } else { $items['mysql_version'] = array('label' => __('MySQL Version', 'optimizepress'), 'status' => 'ok', 'message' => $wpdb->db_version()); } $items['suhosin_installed'] = array('label' => __('Suhosin Installed', 'optimizepress'), 'status' => 'ok', 'message' => extension_loaded('suhosin') ? __('Yes', 'optimizepress') : __('No', 'optimizepress')); $inputVars = ini_get('max_input_vars'); if ($inputVars < 3000) { $items['input_vars'] = array('label' => __('Max Input Vars', 'optimizepress'), 'status' => 'info', 'message' => sprintf(__('Your "max_input_vars" setting is set to %s. If you plan to have pages with a large number of elements on it, you should raise this setting to at least %s.', 'optimizepress'), $inputVars ?: 1000, 3000)); } else { $items['input_vars'] = array('label' => __('Max Input Vars', 'optimizepress'), 'status' => 'ok', 'message' => $inputVars); } $executionTime = ini_get('max_execution_time'); if ($executionTime < 60) { $items['execution_time'] = array('label' => __('Max Execution Time', 'optimizepress'), 'status' => 'info', 'message' => sprintf(__('Your "max_execution_time" setting (%s) is lower than recommended (%s).', 'optimizepress'), $executionTime ?: 30, 60)); } else { $items['execution_time'] = array('label' => __('Max. Execution Time', 'optimizepress'), 'status' => 'ok', 'message' => $executionTime); } // $postMaxSize = wp_convert_hr_to_bytes(ini_get('post_max_size')) / 1024 / 1024; // if ($postMaxSize < 32) { // $items['post_size'] = array( // 'label' => __('PHP POST Max Size', 'optimizepress'), // 'status' => 'ok', // 'message' => sprintf(__('Your PHP POST max size (%sMB) is lower than recommended (%sMB).', 'optimizepress'), $postMaxSize, 32), // ); // } else { // $items['post_size'] = array( // 'label' => __('PHP POST Max Size', 'optimizepress'), // 'status' => 'ok', // 'message' => $postMaxSize . 'MB', // ); // } $memoryLimit = wp_convert_hr_to_bytes(ini_get('memory_limit')) / 1024 / 1024; if ($memoryLimit < 64) { $items['memory'] = array('label' => __('PHP Memory Limit', 'optimizepress'), 'status' => 'warning', 'message' => sprintf(__('Your PHP memory limit (%sMB) is lower than recommended (%sMB)', 'optimizepress'), $memoryLimit, 64)); } else { $items['memory'] = array('label' => __('PHP Memory Limit', 'optimizepress'), 'status' => 'ok', 'message' => $memoryLimit . 'MB'); } // WordPress settings $wpMemoryLimit = wp_convert_hr_to_bytes(WP_MEMORY_LIMIT) / 1024 / 1024; if ($wpMemoryLimit < 64) { $items['wp_memory'] = array('label' => __('WP Memory Limit', 'optimizepress'), 'status' => 'warning', 'message' => sprintf(__('Your WP memory limit (%sMB) is lower than recommended (%sMB)', 'optimizepress'), $wpMemoryLimit, 64)); } else { $items['wp_memory'] = array('label' => __('WP Memory Limit', 'optimizepress'), 'status' => 'ok', 'message' => $wpMemoryLimit . 'MB'); } $uploadLimit = wp_max_upload_size() / 1024 / 1024; if ($uploadLimit < 32) { $items['upload_limit'] = array('label' => __('WP Max Upload Size', 'optimizepress'), 'status' => 'warning', 'message' => sprintf(__('Your WP upload limit (%sMB) is lower than recommended (%sMB).', 'optimizepress'), $uploadLimit, 32)); } else { $items['upload_limit'] = array('label' => __('WP Max Upload Size', 'optimizepress'), 'status' => 'ok', 'message' => $uploadLimit . 'MB'); } // Transfer protocols (curl, streams) $availableProtocols = $disabledProtocols = array(); foreach (array('exthttp' => 'PHP HTTP Extension', 'curl' => 'cURL', 'streams' => 'PHP Streams', 'fopen' => 'PHP fopen()', 'fsockopen' => 'PHP fsockopen()') as $transport => $label) { $class = "WP_Http_{$transport}"; if (!class_exists($class)) { continue; } $class = new $class(); $useable = $class->test(); if ($useable) { $availableProtocols[] = $label; } else { $disabledProtocols[] = $label; } } if (count($availableProtocols) === 0) { $availableProtocols[] = 'none'; } if (count($disabledProtocols) === 0) { $disabledProtocols[] = 'none'; } $items['transfer'] = array('label' => __('WP Transport Protocols', 'optimizepress'), 'status' => 'info', 'message' => sprintf(__('Available transport protocols: %s.<br /> Disabled transfer protocols: %s.', 'optimizepress'), implode(', ', $availableProtocols), implode(', ', $disabledProtocols))); if ('' === ($permalinkStructure = get_option('permalink_structure', ''))) { $items['permalink'] = array('label' => __('Permalink Structure', 'optimizepress'), 'status' => 'error', 'message' => sprintf(__('Permalink structure must not be set to "default" for OptimizePress to work correctly. Please change the <a href="%s">setting</a>.', 'optimizepress'), admin_url('options-permalink.php'))); } else { $items['permalink'] = array('label' => __('Permalink Structure', 'optimizepress'), 'status' => 'ok', 'message' => __('Permalink structure is in order.', 'optimizepress')); } // OptimizePress special params $items['op_type'] = array('label' => __('OptimizePress Type', 'optimizepress'), 'status' => 'ok', 'message' => OP_TYPE); $items['op_version'] = array('label' => __('OptimizePress Version', 'optimizepress'), 'status' => 'ok', 'message' => OP_VERSION); if (false === ($opCheck = get_transient('op_system_status_check'))) { $opCheck = array('ping' => op_sl_ping(), 'eligibility' => op_sl_eligible()); set_transient('op_system_status_check', $opCheck, MINUTE_IN_SECONDS * 5); } if (true !== $opCheck['ping']) { $items['op_sl'] = array('label' => __('OptimizePress Outgoing Connection', 'optimizepress'), 'status' => 'error', 'message' => __('Unable to connect to OptimizePress Security & Licensing service.', 'optimizepress')); } else { $items['op_sl'] = array('label' => __('OptimizePress Outgoing Connection', 'optimizepress'), 'status' => 'ok', 'message' => __('Connection OK.', 'optimizepress')); } if (true !== $opCheck['eligibility']) { $items['op_eligibility'] = array('label' => __('OptimizePress Updates', 'optimizepress'), 'status' => 'warning', 'message' => sprintf(__('You are not eligible for new updates. You can prolong your subscription <a href="%s" target="_blank">here</a>.', 'optimizepress'), 'http://optimizepress.com/updates-renewal/')); } else { $items['op_eligibility'] = array('label' => __('OptimizePress Updates', 'optimizepress'), 'status' => 'ok', 'message' => __('Eligible for new updates.', 'optimizepress')); } $this->environment = $items; } return $this->environment; }