PluginProbe
BetterLinks – Link Shortener, Link Cloaking, Redirects, Affiliate Link Manager & MCP / trunk
BetterLinks – Link Shortener, Link Cloaking, Redirects, Affiliate Link Manager & MCP vtrunk
3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 3.0.0 2.4.13 2.4.12 2.4.11 2.4.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 All 110 releases
betterlinks / includes / Tools / Migration / TAOneClick.php

TAOneClick.php in BetterLinks – Link Shortener, Link Cloaking, Redirects, Affiliate Link Manager & MCP trunk, at includes/Tools/Migration/TAOneClick.php

39 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace BetterLinks\Tools\Migration;
3 if ( ! defined( 'ABSPATH' ) ) { exit; }
4
5 use BetterLinks\Interfaces\ImportOneClickInterface;
6
7 class TAOneClick extends BaseCSV implements ImportOneClickInterface
8 {
9 public function run_importer($data)
10 {
11 $message = [];
12 if (is_array($data) && count($data) > 0) {
13 foreach ($data as $item) {
14 if (!empty($item['link_title']) && !empty($item['short_url'])) {
15 $link_id = \BetterLinks\Helper::insert_link($item);
16 if ($link_id) {
17 if (!empty($item['keywords'])) {
18 $this->insert_keywords($link_id, $item['keywords'], ['limit' => $item['limit']]);
19 }
20 $terms = empty($item['terms']) ? ['uncategorized'] : $item['terms'];
21 $terms_ids = \BetterLinks\Helper::insert_category_terms($terms);
22 if (count($terms_ids) > 0) {
23 foreach ($terms_ids as $term_id) {
24 \BetterLinks\Helper::insert_terms_relationships($term_id, $link_id);
25 }
26 }
27 $message[] = 'Imported Successfully "' . $item['short_url'] . '"';
28 } else {
29 $message[] = 'Imported Failed "' . $item['short_url'] . '" already exists.';
30 }
31 }
32 }
33 }
34 return [
35 'links' => $message
36 ];
37 }
38 }
39