public static function get_instance() { if (!isset(self::$instance)) { $c = __CLASS__; self::$instance = new $c(); } return self::$instance; }
function __construct() { $this->options = CardSettings::get_instance()->getOptions(); //form if (isset($_POST['update_' . CardSettings::$options_namespace])) { foreach ($this->options as $key => $value) { if ($_POST[$key] && $_POST[$key] != $this->options[$key]['description']) { $this->options[$key]['value'] = $_POST[$key]; } } if (update_option(CardSettings::$options_namespace, $this->options)) { echo '<div><p>Your settings were successfully updated.</p></div>'; } } }
function __construct() { $this->options = CardSettings::get_instance()->getOptions(); }
(at your option) any later version. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/> */ //note: played around with autoloading, obvs would be better here - still working on it. //path const is defined in wp-settings include BCARD_PATH . '/CardSettings.php'; include BCARD_PATH . '/CardAdmin.php'; include BCARD_PATH . '/Card.php'; $business_card_settings = CardSettings::get_instance(); $business_card_admin = new CardAdmin(); $business_card = new Card(); function businessCardAdmin() { global $business_card_admin; add_options_page('Business Card', 'Business Card', 9, basename(__FILE__), array(&$business_card_admin, 'printForm')); } add_action('admin_menu', 'businessCardAdmin'); add_action('wp_head', array(&$business_card, 'showCard'), 1); add_action('activate_businesscard/businesscard.php', array(&$business_card_settings, 'setUp'));