public static function &get_instance() { // singleton setup if (!isset(self::$instance)) { self::$instance = new self(); } return self::$instance; }
/** * Constructor: * Initializes the plugin. */ public function __construct() { $this->shortcode = null; $this->options = null; // ALWAYS: // Register translation add_action('plugins_loaded', array(&$this, 'load_textdomain')); // Register shortcodes add_shortcode('comment-guestbook', array(&$this, 'shortcode_comment_guestbook')); // Register widgets add_action('widgets_init', array(&$this, 'widget_init')); // ADMIN PAGE: if (is_admin()) { // Include required php-files and initialize required objects require_once CGB_PATH . 'admin/admin.php'; CGB_Admin::get_instance()->init_admin_page(); } else { require_once 'includes/options.php'; $this->options = CGB_Options::get_instance(); // Filters required after new guestbook comment if (isset($_POST['is_cgb_comment']) && $_POST['is_cgb_comment'] == $_POST['comment_post_ID']) { // Set filter to overwrite comments_open status if (isset($_POST['cgb_comments_status']) && 'open' === $_POST['cgb_comments_status']) { add_filter('comments_open', array(&$this, 'filter_ignore_comments_open'), 50); } // Set filter to overwrite registration requirements for comments on guestbook page if (get_option('comment_registration') && $this->options->get('cgb_ignore_comment_registration')) { add_filter('option_comment_registration', array(&$this, 'filter_ignore_comment_registration')); } // Set filter to overwrite name and email requirement (actual requirement is set via guestbook options) add_filter('option_require_name_email', array(&$this, 'filter_require_name_email')); } // Fix link after adding a comment (required if clist_order = desc) and added query for message after comment add_filter('comment_post_redirect', array(&$this, 'filter_comment_post_redirect')); // Filters for comments on other pages/posts add_action('comment_form_before_fields', array(&$this, 'page_comment_filters')); // Add message after comment if (isset($_GET['cmessage']) && 1 == $_GET['cmessage']) { require_once CGB_PATH . 'includes/cmessage.php'; $cmessage = CGB_CMessage::get_instance(); $cmessage->init(); } } }