From c47a2bcf2913168f3afa7a6852efe27f723ecb83 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Mon, 28 Dec 2015 15:34:50 -0500 Subject: [PATCH] Update for the files When pulling files really need to know which url for the files. Creating a new option for file URL. Which will be used for the file uploads. --- controllers/Admin.php | 5 +++++ controllers/ToolboxImport.php | 11 +++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/controllers/Admin.php b/controllers/Admin.php index db0824d..194b4fc 100644 --- a/controllers/Admin.php +++ b/controllers/Admin.php @@ -137,6 +137,11 @@ class GlmWPImporter_Admin_Controller 'label' => 'Toolbox Files Table', 'type' => 'text' ), + array( + 'name' => 'toolbox_files_url', + 'label' => 'Toolbox Files URL', + 'type' => 'text' + ), array( 'name' => 'ckeditor_schema', 'label' => 'CKEditor Schema', diff --git a/controllers/ToolboxImport.php b/controllers/ToolboxImport.php index 2d5581f..10a4df9 100644 --- a/controllers/ToolboxImport.php +++ b/controllers/ToolboxImport.php @@ -129,6 +129,9 @@ if (!$this->_options['toolbox_files_table']) { $errors[] = 'Toolbox Files Table'; } + if (!$this->_options['toolbox_files_url']) { + $errors[] = 'Toolbox Files URL'; + } return $errors; } @@ -206,7 +209,7 @@ //return false; //} //$fileUrl = wp_get_attachment_url($file_id); - $fileUrl =$this->_options['toolbox_image_url'] . '/original/' . $data['filename']; + $fileUrl =$this->_options['toolbox_files_url'] . '/' . $data['filename']; $fileName = ($data['urltext']) ? $data['urltext'] : $data['filename']; return "\n".''.$fileName.''; } @@ -935,7 +938,7 @@ $sql = " SELECT * FROM {$wpdb->prefix}posts - WHERE post_content LIKE '%http://is0.gaslightmedia.com%' + WHERE post_content LIKE '%{$this->_options['toolbox_files_url']}%' AND post_type = 'page'"; $sql .= " AND ID IN (" . implode(',', $currentPostArray) . ")"; $results = $wpdb->get_results($sql, OBJECT); @@ -943,7 +946,7 @@ foreach ($results as $post) { $content = $post->post_content; echo '
'; - $urlPattern = '%]*)" ?[^>]*>([^>]+)%s'; + $urlPattern = '%]*)" ?[^>]*>([^>]+)%s'; if (preg_match_all($urlPattern, $content, $isMatch)) { $isMatchCount = count($isMatch[0]); echo '

Matches is0 ' . $isMatchCount . '

'; @@ -966,7 +969,7 @@ $fileTitle, '', $post->ID, - $this->_options['site_url'] . '/uploads/' + $this->_options['toolbox_files_url'] . '/' ); } if ($key !== false) { -- 2.17.1