From: Steve Sutton Date: Thu, 20 Nov 2014 15:35:53 +0000 (-0500) Subject: Change to using function call and not widget X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=385b81d4a3ffb65e1f872b8211aab1258a622a33;p=WP-Plugins%2Fglm-preston-locations.git Change to using function call and not widget --- diff --git a/controllers/Front.php b/controllers/Front.php index 5882177..9692f09 100644 --- a/controllers/Front.php +++ b/controllers/Front.php @@ -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(); } } diff --git a/index.php b/index.php index 151b4c9..870f789 100644 --- 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 index 43b3bc8..0000000 --- a/models/PrestonInfoWidget.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @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 - * @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 index 0000000..b6a0a3e --- /dev/null +++ b/models/Preston_Feather_Locations.php @@ -0,0 +1,79 @@ + + * @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 + * @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 index 0000000..52f582d --- /dev/null +++ b/views/locations.php @@ -0,0 +1,29 @@ + +
+
+

show_option('location' . $i);?>

+

show_option('address' . $i);?>

+

show_option('city' . $i);?>, show_option('state' . $i);?> show_option('zip' . $i);?>

+

show_option('phone' . $i);?> + show_option('tfree' . $i)):?>⋅ show_option('tfree' . $i);?>

+ show_option('hours' . $i . 'a', 'days')):?> +

show_option('hours' . $i . 'a', 'days'));?>

+ + show_option('hours' . $i . 'a', 'times')):?> +

show_option('hours' . $i . 'a', 'times'));?>

+ + show_option('hours' . $i . 'b', 'days')):?> +

show_option('hours' . $i . 'b', 'days'));?>

+ + show_option('hours' . $i . 'b', 'times')):?> +

show_option('hours' . $i . 'b', 'times'));?>

+ + show_option('hours' . $i . 'c', 'days')):?> +

show_option('hours' . $i . 'c', 'days'));?>

+ + show_option('hours' . $i . 'c', 'times')):?> +

show_option('hours' . $i . 'c', 'times'));?>

+ +
+
+ diff --git a/views/vCard.php b/views/vCard.php deleted file mode 100644 index 52f582d..0000000 --- a/views/vCard.php +++ /dev/null @@ -1,29 +0,0 @@ - -
-
-

show_option('location' . $i);?>

-

show_option('address' . $i);?>

-

show_option('city' . $i);?>, show_option('state' . $i);?> show_option('zip' . $i);?>

-

show_option('phone' . $i);?> - show_option('tfree' . $i)):?>⋅ show_option('tfree' . $i);?>

- show_option('hours' . $i . 'a', 'days')):?> -

show_option('hours' . $i . 'a', 'days'));?>

- - show_option('hours' . $i . 'a', 'times')):?> -

show_option('hours' . $i . 'a', 'times'));?>

- - show_option('hours' . $i . 'b', 'days')):?> -

show_option('hours' . $i . 'b', 'days'));?>

- - show_option('hours' . $i . 'b', 'times')):?> -

show_option('hours' . $i . 'b', 'times'));?>

- - show_option('hours' . $i . 'c', 'days')):?> -

show_option('hours' . $i . 'c', 'days'));?>

- - show_option('hours' . $i . 'c', 'times')):?> -

show_option('hours' . $i . 'c', 'times'));?>

- -
-
-