Moving files around.
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 9 Jul 2015 20:30:37 +0000 (16:30 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 9 Jul 2015 20:30:37 +0000 (16:30 -0400)
put the Import class into controllers folder

controllers/Admin.php
controllers/Import.php
glm-wp-importer.php [deleted file]
index.php

index 22fe5cc..b2597e3 100644 (file)
@@ -36,7 +36,7 @@ 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'));
-        
+
     }
 
     static public function activate_plugin()
@@ -54,7 +54,7 @@ class GlmWPImporter_Admin_Controller
 
     public function glmwpimporter_add_admin_menu()
     {
-        add_menu_page(
+        add_options_page(
             'Gaslight WP Importer Setup',
             'GLM WP Importer',
             GLM_WP_IMPORT_CAPABILITY,
index c771250..d740719 100644 (file)
  * @release   Release: (0.0.1)
  * @link      <>
  */
-class GlmWPImporter_Import_Controller
-{
-    public $path;
-
-    public function __construct($path)
-    {
-        $this->path = $path;
-    }
-}
+ if (!defined('WP_LOAD_IMPORTERS')) {
+   return;
+ }
+ require_once ABSPATH . 'wp-admin/includes/import.php';
+
+ if ( !class_exists( 'WP_Importer' ) ) {
+       $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
+       if ( file_exists( $class_wp_importer ) ) {
+               require_once $class_wp_importer;
+     }
+ }
+
+ if (class_exists('WP_Importer')) {
+     class Toolbox_Import extends WP_Importer
+     {
+         private $_dbh;
+         function __construct(){}
+
+         function header()
+         {
+             echo '<div class="wrap">';
+             echo '<h2>'.__('Toolbox Importer').'</h2>';
+         }
+
+         function footer()
+         {
+             echo '</div>';
+         }
+
+         function greet()
+         {
+             echo '<h2>Hello there person!</h2>';
+             // read optios for the import and if they aren't set then give a warning.
+             $options = get_option(GLM_WP_IMPORT_SETTINGS);
+             echo '<pre>'.print_r($options, true).'</pre>';
+             // try making a postgres connection to the database
+             $connectionString  = 'dbname=' . $options['db_name'];
+             $connectionString .= ' host=' . $options['db_host'];
+             $connectionString .= ' user=' . $options['db_user'];
+             $driverOptions = array(
+                 PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
+             );
+             $this->_dbh = new PDO('pgsql:'.$connectionString, null, null, $driverOptions);
+             $this->_dbh->setAttribute(
+                 PDO::ATTR_ERRMODE,
+                 PDO::ERRMODE_EXCEPTION
+             );
+             echo '<pre>'.print_r($this->_dbh, true).'</pre>';
+             $sql = "SELECT * FROM toolbox.pages";
+             $data = $this->_dbh->query($sql)->fetchAll();
+             echo '<pre>'.print_r($data, true).'</pre>';
+         }
+
+         function dispatch()
+         {
+             if (empty($_GET['step'])) {
+                 $step = 0;
+             } else {
+                 $step = filter_var($_GET['step'], FILTER_VALIDATE_INT);
+             }
+             switch($step) {
+             case 0:
+                 $this->greet();
+                 break;
+             case 1:
+                 $this->import();
+                 break;
+             }
+         }
+     }
+ }
+
+ $toolbox_import = new Toolbox_Import();
+
+ register_importer(
+     'toolbox',
+     __('Toolbox', 'import-toolbox-pages'),
+     sprintf(
+         __('Import the contents of Gaslight Toolbox Pages as pages. Visit <a href="%s">setup</a> first to setup the database options.',
+         'import-toolbox-pages'),
+         'options-general.php?page=glmwpimporter'
+     ),
+     array($toolbox_import, 'dispatch')
+ );
diff --git a/glm-wp-importer.php b/glm-wp-importer.php
deleted file mode 100644 (file)
index 23a5cff..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-<?php
-if (!defined('WP_LOAD_IMPORTERS')) {
-  return;
-}
-require_once ABSPATH . 'wp-admin/includes/import.php';
-
-if ( !class_exists( 'WP_Importer' ) ) {
-       $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
-       if ( file_exists( $class_wp_importer ) ) {
-               require_once $class_wp_importer;
-    }
-}
-
-if (class_exists('WP_Importer')) {
-    class Toolbox_Import extends WP_Importer
-    {
-        private $_dbh;
-        function __construct(){}
-
-        function header()
-        {
-            echo '<div class="wrap">';
-            echo '<h2>'.__('Toolbox Importer').'</h2>';
-        }
-
-        function footer()
-        {
-            echo '</div>';
-        }
-
-        function greet()
-        {
-            echo '<h2>Hello there person!</h2>';
-            // read optios for the import and if they aren't set then give a warning.
-            $options = get_option(GLM_WP_IMPORT_SETTINGS);
-            echo '<pre>'.print_r($options, true).'</pre>';
-            // try making a postgres connection to the database
-            $connectionString  = 'dbname=' . $options['db_name'];
-            $connectionString .= ' host=' . $options['db_host'];
-            $connectionString .= ' user=' . $options['db_user'];
-            $driverOptions = array(
-                PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
-            );
-            $this->_dbh = new PDO('pgsql:'.$connectionString, null, null, $driverOptions);
-            $this->_dbh->setAttribute(
-                PDO::ATTR_ERRMODE,
-                PDO::ERRMODE_EXCEPTION
-            );
-            echo '<pre>'.print_r($this->_dbh, true).'</pre>';
-            $sql = "SELECT * FROM toolbox.pages";
-            $data = $this->_dbh->query($sql)->fetchAll();
-            echo '<pre>'.print_r($data, true).'</pre>';
-        }
-
-        function dispatch()
-        {
-            if (empty($_GET['step'])) {
-                $step = 0;
-            } else {
-                $step = filter_var($_GET['step'], FILTER_VALIDATE_INT);
-            }
-            switch($step) {
-            case 0:
-                $this->greet();
-                break;
-            case 1:
-                $this->import();
-                break;
-            }
-        }
-    }
-}
-
-$toolbox_import = new Toolbox_Import();
-
-register_importer(
-    'toolbox',
-    __('Toolbox', 'import-toolbox-pages'),
-    sprintf(
-        __('Import the contents of Gaslight Toolbox Pages as pages. Visit <a href="%s">setup</a> first to setup the database options.',
-        'import-toolbox-pages'),
-        'options-general.php?page=toolbox-html.php'
-    ),
-    array($toolbox_import, 'dispatch')
-);
index 72d5272..db6b44d 100644 (file)
--- a/index.php
+++ b/index.php
@@ -14,7 +14,6 @@ define('GLM_WP_IMPORT_OPTION_GROUP', 'glmwp_import_group');
 if (is_admin()) {
     require_once 'controllers/Admin.php';
     require_once 'controllers/Import.php';
-    require_once 'glm-wp-importer.php';
     register_activation_hook(__FILE__, array('GlmWPImporter_Admin_Controller', 'activate_plugin'));
     register_deactivation_hook(__FILE__, array('GlmWPImporter_Admin_Controller', 'deactivate_plugin'));
     register_uninstall_hook(__FILE__, array('GlmWPImporter_Admin_Controller', 'uninstall'));