esc_html__('Add new link', 'affieasy'), 'editLink' => esc_html__('Edit link', 'affieasy'), 'copyToClipboard' => esc_html__('Copy to clipboard', 'affieasy'), 'tagCopied' => esc_html__('Tag copied!', 'affieasy'), 'shortUrlCopied' => esc_html__('Short url copied!', 'affieasy'), 'add' => esc_html__('Add', 'affieasy'), 'edit' => esc_html__('Edit', 'affieasy'), 'cancel' => esc_html__('Cancel', 'affieasy'), 'yes' => esc_html__('Yes', 'affieasy'), 'no' => esc_html__('No', 'affieasy'), )); $postId = isset($_GET['post_id']) ? absint($_GET['post_id']) : 0; $postSlug = ''; if ($postId > 0) { $slug = get_post_field('post_name', $postId); if (!is_wp_error($slug) && !empty($slug)) { $postSlug = $slug; } } wp_localize_script('edit-links-script', 'afesEditLinks', array( 'ajaxUrl' => admin_url('admin-ajax.php'), 'detectWebshopNonce' => wp_create_nonce('afes_detect_webshop_nonce'), 'postSlug' => $postSlug, )); $dbManager = new AFES_DbManager(); $actionType = isset($_REQUEST['actionType']) ? sanitize_key($_REQUEST['actionType']) : null; $id = isset($_REQUEST['idParam']) && is_numeric($_REQUEST['idParam']) ? intval(sanitize_key($_REQUEST['idParam'])) : null; $nonce = isset($_REQUEST['_wpnonce']) ? $_REQUEST['_wpnonce'] : null; if (isset($actionType)) { if ($actionType === 'deletion' && isset($id) && is_numeric($id) && wp_verify_nonce( $nonce, 'my-nonce') ) { $dbManager->delete_link($id); } else if ($actionType === 'edition' && wp_verify_nonce( $nonce, 'edit-link-nonce') ) { $dbManager->edit_link(new AFES_Link( $id, isset($_POST['webshopIdParam']) ? sanitize_key($_POST['webshopIdParam']) : null, isset($_POST['labelParam']) ? sanitize_text_field($_POST['labelParam']) : null, isset($_POST['categoryParam']) ? sanitize_text_field($_POST['categoryParam']) : null, isset($_POST['parametersParam']) ? AFES_Utils::sanitize_parameters($_POST['parametersParam']) : null, isset($_POST['urlParam']) ? esc_url_raw(str_replace('[', '', str_replace(']', '', preg_replace('/\[[\s\S]+?]/', '', $_POST['urlParam'])))) : null, isset($_POST['noFollowParam']) ? sanitize_key($_POST['noFollowParam']) === 'on' : false, isset($_POST['openInNewTabParam']) ? sanitize_key($_POST['openInNewTabParam']) === 'on' : false )); } } $canUsePremiumCode = true; $currentLinkCount = 0; if (!$canUsePremiumCode) { $currentLinkCount = $dbManager->get_table_count(TABLE_LINK); } $webshops = $dbManager->get_webshop_list(); $hasNoWebshop = empty($webshops); ?>