Exemplo n.º 1
0
 public static function &get_instance()
 {
     // Create class instance if required
     if (!isset(self::$instance)) {
         self::$instance = new self();
     }
     // Return class instance
     return self::$instance;
 }
Exemplo n.º 2
0
 /**
  * Register widget with WordPress.
  */
 public function __construct()
 {
     parent::__construct('comment_guestbook_widget', 'Comment Guestbook', array('description' => __('This widget displays a list of recent comments.', 'comment-guestbook')));
     add_action('comment_post', array($this, 'flush_widget_cache'));
     add_action('transition_comment_status', array($this, 'flush_widget_cache'));
     $this->options =& CGB_Options::get_instance();
     // define all available items
     $this->items = array('title' => array('std_value' => __('Recent guestbook entries', 'comment-guestbook')), 'num_comments' => array('std_value' => '5'), 'link_to_comment' => array('std_value' => 'false'), 'show_date' => array('std_value' => 'false'), 'date_format' => array('std_value' => get_option('date_format')), 'show_author' => array('std_value' => 'true'), 'author_length' => array('std_value' => '18'), 'show_page_title' => array('std_value' => 'false'), 'page_title_length' => array('std_value' => '18'), 'show_comment_text' => array('std_value' => 'true'), 'comment_text_length' => array('std_value' => '25'), 'url_to_page' => array('std_value' => ''), 'gb_comments_only' => array('std_value' => 'false'), 'hide_gb_page_title' => array('std_value' => 'false'), 'link_to_page' => array('std_value' => 'false'), 'link_to_page_caption' => array('std_value' => __('goto guestbook page', 'comment-guestbook')));
     add_action('admin_init', array(&$this, 'load_widget_items_helptexts'), 2);
 }
 private function __construct()
 {
     // get options instance
     $this->options =& CGB_Options::get_instance();
     // set language domain
     $this->l10n_domain = $this->options->get('cgb_l10n_domain');
     $this->nav_label_prev = __('← Older Comments', $this->l10n_domain);
     $this->nav_label_next = __('Newer Comments →', $this->l10n_domain);
     if ('desc' === $this->options->get('cgb_clist_order')) {
         //switch labels and corred arrow
         $tmp_label = $this->nav_label_prev;
         $this->nav_label_prev = '← ' . substr($this->nav_label_next, 0, -6);
         $this->nav_label_next = substr($tmp_label, 6) . ' →';
     }
 }
 /**
  * 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();
         }
     }
 }
Exemplo n.º 5
0
 /**
  * Constructor
  */
 protected function __construct()
 {
     $this->options =& CGB_Options::get_instance();
 }
<?php

/**
 * The custom template for displaying Comments for comment-guestbook plugin.
 */
if (!defined('ABSPATH')) {
    exit;
}
require_once CGB_PATH . 'includes/options.php';
require_once CGB_PATH . 'includes/comments-functions.php';
$cgb_options = CGB_Options::get_instance();
$cgb_func = CGB_Comments_Functions::get_instance();
global $wp_query;
$in_page = !isset($wp_query->comments);
// Prepare $wp_query when template is displayed in post/page content
if ($in_page) {
    $wp_query->comments = apply_filters('comments_array', $cgb_func->get_comments($wp_query->post->ID));
    $wp_query->comment_count = count($wp_query->comments);
}
// Show comment incl comment forms
if ('' === $cgb_options->get('cgb_clist_in_page_content') && !$in_page || '' !== $cgb_options->get('cgb_clist_in_page_content') && $in_page) {
    echo '
			<div id="comments">';
    // comment form above comments
    $cgb_func->show_comment_form_html('above_comments');
    // is password required?
    if (post_password_required()) {
        echo '
				<p class="nopassword">' . __('This post is password protected. Enter the password to view any comments.', $cgb_func->l10n_domain) . '</p>
			</div><!-- #comments -->';
        return;
Exemplo n.º 7
0
 private function __construct()
 {
     $this->options =& CGB_Options::get_instance();
 }
Exemplo n.º 8
0
 private function __construct()
 {
     $this->options =& CGB_Options::get_instance();
     $this->options->load_options_helptexts();
 }