Change to using function call and not widget
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 20 Nov 2014 15:35:53 +0000 (10:35 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 20 Nov 2014 15:35:53 +0000 (10:35 -0500)
controllers/Front.php
index.php
models/PrestonInfoWidget.php [deleted file]
models/Preston_Feather_Locations.php [new file with mode: 0644]
views/locations.php [new file with mode: 0644]
views/vCard.php [deleted file]

index 5882177..9692f09 100644 (file)
@@ -45,16 +45,18 @@ class Preston_Info_Front_controller
     function __construct($path)
     {
         $this->path = $path;
-        add_action('widgets_init', array($this, 'prestonclientinfo_register_widget'));
+
     }
 
     /**
      * Register the Client Info Widget with WordPress
      */
-    function prestonclientinfo_register_widget()
+    function locations()
     {
-        include $this->path . 'models/PrestonInfoWidget.php';
-        register_widget('PrestonInfoWidget');
+        echo 'done';
+        include $this->path . 'models/Preston_Feather_Locations.php';
+        $locations = new Preston_Feather_Locations($this->path);
+        $locations->toHtml();
     }
 
 }
index 151b4c9..870f789 100644 (file)
--- a/index.php
+++ b/index.php
@@ -22,10 +22,11 @@ if (is_admin()) {
     $adminController = new Preston_Info_Admin_Controller(
         plugin_dir_path(__FILE__)
     );
+} else {
+    function preston_feather_get_locations()
+    {
+        include 'models/Preston_Feather_Locations.php';
+        $locations = new Preston_Feather_Locations(plugin_dir_path(__FILE__));
+        $locations->toHtml();
+    }
 }
-
-// call the Front Controller to setup the widget
-require_once 'controllers/Front.php';
-$frontController = new Preston_Info_Front_controller(
-    plugin_dir_path(__FILE__)
-);
diff --git a/models/PrestonInfoWidget.php b/models/PrestonInfoWidget.php
deleted file mode 100644 (file)
index 43b3bc8..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-
-/**
- * Glmclientinfo_Widget.php
- *
- * PHP version 5.3
- *
- * @category  Toolkit
- * @package   Package
- * @author    Steve Sutton <steve@gaslightmedia.com>
- * @copyright 2013 Gaslight Media
- * @license   Gaslight Media
- * @version   SVN: (0.1)
- * @link      <>
- */
-
-/**
- * Toolkit_Package_QuickSite_Widget
- *
- * Description of QuickSite_Widget
- *
- * @category  Toolkit
- * @package   Package
- * @author    Steve Sutton <steve@gaslightmedia.com>
- * @copyright 2013 Gaslight Media
- * @license   Gaslight Media
- * @release   Release: (0.1)
- * @link      <>
- */
-class PrestonInfoWidget
-    extends WP_widget
-{
-
-    private $pluginDirPath;
-
-    /**
-     * Class Initializer
-     */
-    public function __construct()
-    {
-        parent::__construct(
-            'PrestonInfoWidget',
-            __('Locations Info Widget', 'text_domain'),
-            array('description' => __('Locations Widget', 'text_domain'))
-        );
-    }
-
-    /**
-     * Output widget
-     *
-     * Includes the template file for the widget.
-     * Template file is plain old php for your fastest template engine yet!
-     *
-     * @param type $args     Widget Args
-     * @param type $instance Widget Instance
-     *
-     * @return string
-     */
-    public function widget($args, $instance)
-    {
-        $path = plugin_dir_path(__FILE__);
-        include $path . '../views/vCard.php';
-    }
-
-    /**
-     * Return the quicksite option for the given key
-     *
-     * @param type $name Name of the quicksite option to return
-     *
-     * @return string Option
-     */
-    function show_option($name, $key)
-    {
-        $settings = get_option('prestonclientinfo_settings');
-        $states   = get_option('prestonclientinfo_states');
-        if ($key) {
-            return ($settings[$name][$key])
-                ? $settings[$name][$key]
-                : null;
-        } else {
-            return ($settings && $settings[$name])
-                ? $settings[$name]
-                : null;
-        }
-
-    }
-
-}
diff --git a/models/Preston_Feather_Locations.php b/models/Preston_Feather_Locations.php
new file mode 100644 (file)
index 0000000..b6a0a3e
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+
+/**
+ * Preston_Feather_Locations.php
+ *
+ * PHP version 5.3
+ *
+ * @category  Toolkit
+ * @package   Package
+ * @author    Steve Sutton <steve@gaslightmedia.com>
+ * @copyright 2013 Gaslight Media
+ * @license   Gaslight Media
+ * @version   SVN: (0.1)
+ * @link      <>
+ */
+
+/**
+ * Preston_Feather_Locations
+ *
+ * Output the Locations.
+ *
+ * @category  Toolkit
+ * @package   Package
+ * @author    Steve Sutton <steve@gaslightmedia.com>
+ * @copyright 2013 Gaslight Media
+ * @license   Gaslight Media
+ * @release   Release: (0.1)
+ * @link      <>
+ */
+class Preston_Feather_Locations
+{
+
+    private $pluginDirPath;
+
+    /**
+     * Class Initializer
+     */
+    public function __construct($path)
+    {
+        $this->pluginDirPath = $path;
+    }
+
+    /**
+     * Output Locations
+     *
+     * Includes the template file for the widget.
+     * Template file is plain old php for your fastest template engine yet!
+     *
+     * @return string
+     */
+    public function toHtml()
+    {
+        include $this->pluginDirPath . 'views/locations.php';
+    }
+
+    /**
+     * Return the locations option for the given key
+     *
+     * @param string $name Name of the quicksite option to return
+     * @param string $key  Sub key for the value
+     *
+     * @return string Option
+     */
+    function show_option($name, $key = null)
+    {
+        $settings = get_option('prestonclientinfo_settings');
+        if ($key) {
+            return ($settings[$name][$key])
+                ? $settings[$name][$key]
+                : null;
+        } else {
+            return ($settings && $settings[$name])
+                ? $settings[$name]
+                : null;
+        }
+
+    }
+
+}
diff --git a/views/locations.php b/views/locations.php
new file mode 100644 (file)
index 0000000..52f582d
--- /dev/null
@@ -0,0 +1,29 @@
+<?php for ($i = 1; $i <= 4; ++$i):?>
+<div class="small-12 medium-3 columns">
+    <div class="center">
+        <h3><?php echo $this->show_option('location' . $i);?></h3>
+        <p><?php echo $this->show_option('address' . $i);?></p>
+        <p><?php echo $this->show_option('city' . $i);?>, <?php echo $this->show_option('state' . $i);?> <?php echo $this->show_option('zip' . $i);?></p>
+        <p><?php echo $this->show_option('phone' . $i);?>
+            <?php if($this->show_option('tfree' . $i)):?>&sdot; <?php echo $this->show_option('tfree' . $i);?><?php endif;?></p>
+        <?php if ($this->show_option('hours' . $i . 'a', 'days')):?>
+            <p class="day"><?php echo nl2br($this->show_option('hours' . $i . 'a', 'days'));?></p>
+        <?php endif;?>
+        <?php if ($this->show_option('hours' . $i . 'a', 'times')):?>
+            <p class="time"><?php echo nl2br($this->show_option('hours' . $i . 'a', 'times'));?></p>
+        <?php endif;?>
+        <?php if ($this->show_option('hours' . $i . 'b', 'days')):?>
+            <p class="day"><?php echo nl2br($this->show_option('hours' . $i . 'b', 'days'));?></p>
+        <?php endif;?>
+        <?php if ($this->show_option('hours' . $i . 'b', 'times')):?>
+            <p class="time"><?php echo nl2br($this->show_option('hours' . $i . 'b', 'times'));?></p>
+        <?php endif;?>
+        <?php if ($this->show_option('hours' . $i . 'c', 'days')):?>
+            <p class="day"><?php echo nl2br($this->show_option('hours' . $i . 'c', 'days'));?></p>
+        <?php endif;?>
+        <?php if ($this->show_option('hours' . $i . 'c', 'times')):?>
+            <p class="time"><?php echo nl2br($this->show_option('hours' . $i . 'c', 'times'));?></p>
+        <?php endif;?>
+    </div>
+</div>
+<?php endfor;?>
diff --git a/views/vCard.php b/views/vCard.php
deleted file mode 100644 (file)
index 52f582d..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php for ($i = 1; $i <= 4; ++$i):?>
-<div class="small-12 medium-3 columns">
-    <div class="center">
-        <h3><?php echo $this->show_option('location' . $i);?></h3>
-        <p><?php echo $this->show_option('address' . $i);?></p>
-        <p><?php echo $this->show_option('city' . $i);?>, <?php echo $this->show_option('state' . $i);?> <?php echo $this->show_option('zip' . $i);?></p>
-        <p><?php echo $this->show_option('phone' . $i);?>
-            <?php if($this->show_option('tfree' . $i)):?>&sdot; <?php echo $this->show_option('tfree' . $i);?><?php endif;?></p>
-        <?php if ($this->show_option('hours' . $i . 'a', 'days')):?>
-            <p class="day"><?php echo nl2br($this->show_option('hours' . $i . 'a', 'days'));?></p>
-        <?php endif;?>
-        <?php if ($this->show_option('hours' . $i . 'a', 'times')):?>
-            <p class="time"><?php echo nl2br($this->show_option('hours' . $i . 'a', 'times'));?></p>
-        <?php endif;?>
-        <?php if ($this->show_option('hours' . $i . 'b', 'days')):?>
-            <p class="day"><?php echo nl2br($this->show_option('hours' . $i . 'b', 'days'));?></p>
-        <?php endif;?>
-        <?php if ($this->show_option('hours' . $i . 'b', 'times')):?>
-            <p class="time"><?php echo nl2br($this->show_option('hours' . $i . 'b', 'times'));?></p>
-        <?php endif;?>
-        <?php if ($this->show_option('hours' . $i . 'c', 'days')):?>
-            <p class="day"><?php echo nl2br($this->show_option('hours' . $i . 'c', 'days'));?></p>
-        <?php endif;?>
-        <?php if ($this->show_option('hours' . $i . 'c', 'times')):?>
-            <p class="time"><?php echo nl2br($this->show_option('hours' . $i . 'c', 'times'));?></p>
-        <?php endif;?>
-    </div>
-</div>
-<?php endfor;?>