admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('net360qr_title'), 'i18n' => array( 'loading' => 'Detecting title…', 'found' => 'Title detected', 'notFound' => 'Page title not found.', 'error' => 'Could not fetch the page. Check the URL and try again.' ) )); } } public function logo_preload($hook) { if ($hook !== 'toplevel_page_360-qr') return; echo ''; } private function url($args=array()) { $url = add_query_arg($args, admin_url('admin.php?page=360-qr')); return wp_nonce_url($url, 'net360qr_admin_view'); } private function code() { $chars='ABCDEFGHJKLMNPQRSTUVWXYZ23456789'; do{$c='';for($i=0;$i<8;$i++)$c.=$chars[wp_rand(0,strlen($chars)-1)];}while(NET360QR_DB::code_exists($c)); return $c; } public function save() { if(!current_user_can('manage_options')) wp_die('Permission denied.'); check_admin_referer('net360qr_save'); $id = isset($_POST['id']) ? absint(wp_unslash($_POST['id'])) : 0; $name = isset($_POST['name']) ? sanitize_text_field(wp_unslash($_POST['name'])) : ''; $dest = isset($_POST['destination_url']) ? esc_url_raw(wp_unslash($_POST['destination_url'])) : ''; $code = isset($_POST['code']) ? strtoupper(sanitize_key(wp_unslash($_POST['code']))) : ''; if(!$name||!$dest||!preg_match('#^https?://#i',$dest)) wp_safe_redirect($this->url(array('error'=>'Enter a name and a valid URL (http/https).'))) && exit; if(!$code) $code=$this->code(); $public=home_url('/q/'.$code); $check=NET360QR_LOCAL::validate_text($public); if(is_wp_error($check)) wp_safe_redirect($this->url(array('error'=>$check->get_error_message()))) && exit; if(NET360QR_DB::code_exists($code,$id)) wp_safe_redirect($this->url(array('error'=>'Duplicate code.'))) && exit; $existing = $id ? NET360QR_DB::get($id) : null; $logo_id = $existing ? absint($existing->logo_attachment_id ?? 0) : 0; if (!empty($_POST['remove_logo'])) $logo_id = 0; if (!empty($_FILES['net360qr_logo']['name'])) { require_once ABSPATH . 'wp-admin/includes/file.php'; require_once ABSPATH . 'wp-admin/includes/media.php'; require_once ABSPATH . 'wp-admin/includes/image.php'; $new_logo = media_handle_upload('net360qr_logo', 0); if (is_wp_error($new_logo)) wp_safe_redirect($this->url(array('error'=>'Could not upload the logo: '.$new_logo->get_error_message()))) && exit; $mime = get_post_mime_type($new_logo); if (!in_array($mime, array('image/png','image/jpeg','image/webp'), true)) { wp_delete_attachment($new_logo, true); wp_safe_redirect($this->url(array('error'=>'The logo must be a PNG, JPG, or WebP image.'))) && exit; } $logo_id = (int) $new_logo; } $shape_input = isset($_POST['qr_shape']) ? sanitize_key(wp_unslash($_POST['qr_shape'])) : ($existing->qr_shape ?? 'classic'); $shape = NET360QR_LOCAL::shape($shape_input); $data = array('name'=>$name,'code'=>$code,'destination_url'=>$dest,'logo_attachment_id'=>$logo_id,'qr_shape'=>$shape); if($id) NET360QR_DB::update($id,$data); else NET360QR_DB::insert(array_merge($data,array('user_id'=>get_current_user_id(),'status'=>'active'))); wp_safe_redirect($this->url(array('saved'=>1))); exit; } public function delete() { if(!current_user_can('manage_options')) wp_die('Permission denied.'); $id = isset($_GET['id']) ? absint(wp_unslash($_GET['id'])) : 0; check_admin_referer('net360qr_delete_'.$id); if($id) NET360QR_DB::delete($id); wp_safe_redirect($this->url()); exit; } public function toggle() { if(!current_user_can('manage_options')) wp_die('Permission denied.'); $id = isset($_GET['id']) ? absint(wp_unslash($_GET['id'])) : 0; check_admin_referer('net360qr_toggle_'.$id); $qr=NET360QR_DB::get($id); if($qr) NET360QR_DB::update($id,array('status'=>$qr->status==='active'?'inactive':'active')); wp_safe_redirect($this->url()); exit; } public function svg() { if(!current_user_can('manage_options')) wp_die('Permission denied.'); $id = isset($_GET['id']) ? absint(wp_unslash($_GET['id'])) : 0; check_admin_referer('net360qr_svg_'.$id); $qr=NET360QR_DB::get($id); if(!$qr) wp_die('QR code not found.'); $public=home_url('/q/'.rawurlencode($qr->code)); nocache_headers(); header('Content-Type: image/svg+xml; charset=utf-8'); header('Content-Disposition: attachment; filename="net360-'.sanitize_file_name($qr->code).'.svg"'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- SVG is generated internally by the plugin and must remain valid XML. echo NET360QR_LOCAL::svg($public, 1000, '#111827', '#FFFFFF', absint($qr->logo_attachment_id ?? 0), NET360QR_LOCAL::shape($qr->qr_shape ?? 'classic')); exit; } public function png() { if(!current_user_can('manage_options')) wp_die('Permission denied.'); $id = isset($_GET['id']) ? absint(wp_unslash($_GET['id'])) : 0; check_admin_referer('net360qr_png_'.$id); $qr=NET360QR_DB::get($id); if(!$qr) wp_die('QR code not found.'); $public=home_url('/q/'.rawurlencode($qr->code)); $size = isset($_GET['size']) ? absint(wp_unslash($_GET['size'])) : 1200; if (!in_array($size, array(512, 1024, 2048), true)) { $size = 1200; } $png=NET360QR_LOCAL::png($public,$size,absint($qr->logo_attachment_id ?? 0), NET360QR_LOCAL::shape($qr->qr_shape ?? 'classic')); if(is_wp_error($png)) wp_die(esc_html($png->get_error_message())); nocache_headers(); header('Content-Type: image/png'); header('Content-Disposition: attachment; filename="net360-'.sanitize_file_name($qr->code).'-'.$size.'px.png"'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- PNG is binary data and must not be escaped. echo $png; exit; } public function fetch_title() { if (!current_user_can('manage_options')) wp_send_json_error(array('message'=>'Permission denied.'), 403); check_ajax_referer('net360qr_title', 'nonce'); $url = isset($_POST['url']) ? esc_url_raw(wp_unslash($_POST['url'])) : ''; if (!$url || !preg_match('#^https?://#i', $url)) wp_send_json_error(array('message'=>'Invalid URL.'), 400); if (function_exists('wp_http_validate_url') && !wp_http_validate_url($url)) wp_send_json_error(array('message'=>'URL is not allowed.'), 400); $response = wp_safe_remote_get($url, array( 'timeout' => 12, 'redirection' => 5, 'limit_response_size' => 2000000, 'user-agent' => 'Mozilla/5.0 (compatible; 360 QR/'.NET360QR_VERSION.'; +'.home_url('/').')', 'headers' => array('Accept' => 'text/html,application/xhtml+xml;q=0.9,*/*;q=0.8') )); if (is_wp_error($response)) { wp_send_json_error(array('message'=>'Could not fetch the URL: '.$response->get_error_message()), 502); } $code = (int) wp_remote_retrieve_response_code($response); if ($code < 200 || $code >= 400) wp_send_json_error(array('message'=>'The website returned HTTP '.$code.'.'), 502); $body = wp_remote_retrieve_body($response); if (!$body) wp_send_json_error(array('message'=>'The page returned no content.'), 502); $title = ''; // First, try the
Manage your dynamic QR codes directly in WordPress.
QR code saved successfully.
The QR code uses your system URL, so you can change its destination later without reprinting it.
Manage, pause, and download your dynamic QR codes.
| QR | Name | Code | Destination | Status | Scans | Last Scan | Actions |
|---|---|---|---|---|---|---|---|
| No QR codes yet. | |||||||
| name);?> Created created_at));?> | code);?> | destination_url);?> | status==='active'?'● Active':'● Inactive';?> | scans));?> | last_scan_at?esc_html(mysql2date('d/m/Y H:i',$qr->last_scan_at)):'—';?> | ||