function w3tc_errors($errors) { $c = Dispatcher::config(); $state = Dispatcher::config_state(); $cdn_engine = $c->get_string('cdn.engine'); if (Cdn_Util::is_engine_push($cdn_engine)) { /** * Show notification if upload queue is not empty */ try { if (!($error = get_transient('w3tc_cdn_error')) && !$this->_is_queue_empty()) { $errors['cdn_unsuccessful_queue'] = sprintf(__('The %s has unresolved errors. Empty the queue to restore normal operation.', 'w3-total-cache'), Util_Ui::button_popup(__('unsuccessful transfer queue', 'w3-total-cache'), 'cdn_queue')); } elseif ($error) { $errors['cdn_generic'] = $error; } } catch (\Exception $ex) { $errors[] = $ex->getMessage(); set_transient('w3tc_cdn_error', $ex->getMessage(), 30); } /** * Check upload settings */ $upload_info = Util_Http::upload_info(); if (!$upload_info) { $upload_path = get_option('upload_path'); $upload_path = trim($upload_path); if (empty($upload_path)) { $upload_path = WP_CONTENT_DIR . '/uploads'; $errors['cdn_uploads_folder_empty'] = sprintf(__('The uploads directory is not available. Default WordPress directories will be created: <strong>%s</strong>.', 'w3-total-cache'), $upload_path); } if (!Util_Environment::is_wpmu()) { $errors['cdn_uploads_folder_not_found'] = sprintf(__('The uploads path found in the database (%s) is inconsistent with the actual path. Please manually adjust the upload path either in miscellaneous settings or if not using a custom path %s automatically to resolve the issue.', 'w3-total-cache'), $upload_path, Util_Ui::button_link(__('update the path', 'w3-total-cache'), Util_Ui::url(array('w3tc_config_update_upload_path' => 'y')))); } } } /** * Check CDN settings */ $error = ''; switch (true) { case $cdn_engine == 'ftp' && !count($c->get_array('cdn.ftp.domain')): $errors['cdn_ftp_empty'] = __('A configuration issue prevents <acronym title="Content Delivery Network">CDN</acronym> from working: The <strong>"Replace default hostname with"</strong> field cannot be empty. Enter <acronym title="Content Delivery Network">CDN</acronym> provider hostname <a href="?page=w3tc_cdn#configuration">here</a>. <em>(This is the hostname used in order to view objects in a browser.)</em>', 'w3-total-cache'); break; case $cdn_engine == 's3' && ($c->get_string('cdn.s3.key') == '' || $c->get_string('cdn.s3.secret') == '' || $c->get_string('cdn.s3.bucket') == ''): $error = __('The <strong>"Access key", "Secret key" and "Bucket"</strong> fields cannot be empty.', 'w3-total-cache'); break; case $cdn_engine == 'cf' && ($c->get_string('cdn.cf.key') == '' || $c->get_string('cdn.cf.secret') == '' || $c->get_string('cdn.cf.bucket') == '' || $c->get_string('cdn.cf.id') == '' && !count($c->get_array('cdn.cf.cname'))): $error = __('The <strong>"Access key", "Secret key", "Bucket" and "Replace default hostname with"</strong> fields cannot be empty.', 'w3-total-cache'); break; case $cdn_engine == 'cf2' && ($c->get_string('cdn.cf2.key') == '' || $c->get_string('cdn.cf2.secret') == '' || $c->get_string('cdn.cf2.id') == '' && !count($c->get_array('cdn.cf2.cname'))): $error = __('The <strong>"Access key", "Secret key" and "Replace default hostname with"</strong> fields cannot be empty.', 'w3-total-cache'); break; case $cdn_engine == 'rscf' && ($c->get_string('cdn.rscf.user') == '' || $c->get_string('cdn.rscf.key') == '' || $c->get_string('cdn.rscf.container') == ''): $error = __('The <strong>"Username", "API key", "Container" and "Replace default hostname with"</strong> fields cannot be empty.', 'w3-total-cache'); break; case $cdn_engine == 'azure' && ($c->get_string('cdn.azure.user') == '' || $c->get_string('cdn.azure.key') == '' || $c->get_string('cdn.azure.container') == ''): $error = __('The <strong>"Account name", "Account key" and "Container"</strong> fields cannot be empty.', 'w3-total-cache'); break; case $cdn_engine == 'mirror' && !count($c->get_array('cdn.mirror.domain')): $error = __('The <strong>"Replace default hostname with"</strong> field cannot be empty.', 'w3-total-cache'); break; case $cdn_engine == 'netdna': $fields = array(); if ($c->get_string('cdn.netdna.authorization_key') == '') { $fields[] = '"' . __('Authorization key', 'w3-total-cache') . '"'; } if (!count($c->get_array('cdn.netdna.domain'))) { $fields[] = '"' . __('Replace default hostname with', 'w3-total-cache') . '"'; } if ($fields) { $error = sprintf(__('The <strong>%s</strong> field(s) cannot be empty.', 'w3-total-cache'), implode(__(' and ', 'w3-total-cache'), $fields)); } if ($c->get_string('cdn.netdna.authorization_key') != '' && sizeof(explode('+', $c->get_string('cdn.netdna.authorization_key'))) != 3) { $error .= __('The <strong>"Authorization key"</strong> is not correct.', 'w3-total-cache'); } elseif ($c->get_integer('cdn.netdna.zone_id', 0) <= 0) { $error .= __('You need to select / create a pull zone.', 'w3-total-cache'); } break; case $cdn_engine == 'maxcdn': $fields = array(); if ($c->get_string('cdn.maxcdn.authorization_key') == '') { $fields[] = '"' . __('Authorization key', 'w3-total-cache') . '"'; } if (!count($c->get_array('cdn.maxcdn.domain'))) { $fields[] = '"' . __('Replace default hostname with', 'w3-total-cache') . '"'; } if ($fields) { $error = sprintf(__('The <strong>%s</strong> field(s) cannot be empty.', 'w3-total-cache'), implode(__(' and ', 'w3-total-cache'), $fields)); } if ($c->get_string('cdn.maxcdn.authorization_key') != '' && sizeof(explode('+', $c->get_string('cdn.maxcdn.authorization_key'))) != 3) { $error .= __('The <strong>"Authorization key"</strong> is not correct.', 'w3-total-cache'); } elseif ($c->get_integer('cdn.maxcdn.zone_id', 0) <= 0) { $error .= __('You need to select / create a pull zone.', 'w3-total-cache'); } break; case $cdn_engine == 'cotendo' && !count($c->get_array('cdn.cotendo.domain')): $error = __('The <strong>"Replace default hostname with"</strong> field cannot be empty.', 'w3-total-cache'); break; case $cdn_engine == 'edgecast' && !count($c->get_array('cdn.edgecast.domain')): $error = __('The <strong>"Replace default hostname with"</strong> field cannot be empty.', 'w3-total-cache'); break; case $cdn_engine == 'att' && !count($c->get_array('cdn.att.domain')): $error = __('The <strong>"Replace default hostname with"</strong> field cannot be empty.', 'w3-total-cache'); break; case $cdn_engine == 'akamai' && !count($c->get_array('cdn.akamai.domain')): $error = 'The <strong>"Replace default hostname with"</strong> field cannot be empty.'; break; } if ($error) { $errors['cdn_not_configured'] = __('A configuration issue prevents <acronym title="Content Delivery Network">CDN</acronym> from working: ', 'w3-total-cache') . $error . __(' <a href="?page=w3tc_cdn#configuration">Specify it here</a>.', 'w3-total-cache'); } return $errors; }