get_table_count(TABLE_WEBSHOP) >= 2; $webshop = $isActionForbidden ? new AFES_Webshop() : new AFES_Webshop( $id, isset($_POST['name']) ? sanitize_text_field($_POST['name']) : null, isset($_POST['url']) ? sanitize_text_field($_POST['url']) : null, isset($_POST['link-text-preference']) ? sanitize_text_field($_POST['link-text-preference']) : null, isset($_POST['background-color-preference']) ? sanitize_hex_color($_POST['background-color-preference']) : null, isset($_POST['text-color-preference']) ? sanitize_hex_color($_POST['text-color-preference']) : null, isset($_POST['encoder-url']) ? sanitize_key($_POST['encoder-url']) === 'on' : false, isset($_POST['product-domains']) ? sanitize_text_field($_POST['product-domains']) : '' ); $errors = array(); $submit = isset($_POST['submit']) ? sanitize_key($_POST['submit']) : null; $isFromSaveAction = $submit === 'save-action'; if(!$isActionForbidden) { if ($isFromSaveAction) { $nonce = isset($_REQUEST['_wpnonce']) ? $_REQUEST['_wpnonce'] : null; if (wp_verify_nonce( $nonce, 'edit-webshop-nonce')){ if (empty($webshop->getName())) { array_push($errors, esc_html__('Name must not be empty', 'affieasy')); } $webshopUrl = $webshop->geturl(); if (empty($webshopUrl)) { array_push($errors, esc_html__('Url must not be empty', 'affieasy')); } else { if (!in_array(AFES_Constants::MANDATORY_URL_PARAM, $webshop->getParameters())) { array_push($errors, sprintf( esc_html__('Url must contains at least [[%1$s]] parameter', 'affieasy'), AFES_Constants::MANDATORY_URL_PARAM)); } } if (empty($errors)) { $webshop = $dbManager->edit_webshop($webshop); } } // Fin check nonce } else if (!empty($id)) { $webshop = $dbManager->get_webshop_by_id($id); } } $webshopId = $webshop->getId(); $webshopName = $webshop->getName(); ?>