From a05488e0cec3d251a5c9f5663707a2a8f402c188 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 8 Jul 2015 17:58:54 -0400 Subject: [PATCH] Looking at the import part --- NOTES.md | 4 ++++ controllers/Admin.php | 14 ++++++++++++-- index.php | 7 +------ views/optionsPage.php | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/NOTES.md b/NOTES.md index a3e1c6b..06ca5a9 100644 --- a/NOTES.md +++ b/NOTES.md @@ -10,3 +10,7 @@ I'm planning on using the same thing here. 2. Fetch all pages from the database and add pages. 3. Fetch list of all images, files and import them into Media Library 4. Update all pages with new references of the images. + +REFERENCES: +For Wordpress Plugin Development +https://developer.wordpress.org/plugins/the-basics/header-requirements/ diff --git a/controllers/Admin.php b/controllers/Admin.php index 4071142..5fa27f2 100644 --- a/controllers/Admin.php +++ b/controllers/Admin.php @@ -35,7 +35,12 @@ class GlmWPImporter_Admin_Controller { $this->path = $path; add_action('admin_menu', array($this, 'glmwpimporter_add_admin_menu')); - add_action('admin_init', array($this, 'glmwpimporter_settings_init')); + + if (isset($action) && $action = filter_var($_REQUEST['glm_action'], FILTER_SANITIZE_STRING)) { + add_action('admin_init', array($this, 'glmimporter_import_pages')); + } else { + add_action('admin_init', array($this, 'glmwpimporter_settings_init')); + } } @@ -47,7 +52,6 @@ class GlmWPImporter_Admin_Controller { } - static public function glmwpimporter_uninstall() { delete_option(GLM_WP_IMPORT_SETTINGS); @@ -197,4 +201,10 @@ class GlmWPImporter_Admin_Controller } } + public function glmimporter_import_pages() + { + echo '
'; + echo '
'.print_r($_REQUEST, true).'
'; + echo '
'; + } } diff --git a/index.php b/index.php index 690c9d3..db6b44d 100644 --- a/index.php +++ b/index.php @@ -18,10 +18,5 @@ if (is_admin()) { register_deactivation_hook(__FILE__, array('GlmWPImporter_Admin_Controller', 'deactivate_plugin')); register_uninstall_hook(__FILE__, array('GlmWPImporter_Admin_Controller', 'uninstall')); - - if ($action = filter_var($_REQUEST['glm_action'], FILTER_SANITIZE_STRING)) { - $importController = new GlmWPImporter_Import_Controller(plugin_dir_path(__FILE__)); - } else { - $adminController = new GlmWPImporter_Admin_Controller(plugin_dir_path(__FILE__)); - } + $adminController = new GlmWPImporter_Admin_Controller(plugin_dir_path(__FILE__)); } diff --git a/views/optionsPage.php b/views/optionsPage.php index f3bfda6..92cd437 100644 --- a/views/optionsPage.php +++ b/views/optionsPage.php @@ -7,7 +7,7 @@ submit_button(); ?> -
+
-- 2.17.1