/** * Get instance. * * @static * * @return LivePress_Config|null */ public static function get_instance() { if (!isset(self::$singleton_instance)) { self::$singleton_instance = new self(); } return self::$singleton_instance; }
/** * Constructor. */ function __construct() { add_action('admin_init', array($this, 'admin_init')); add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); add_action('admin_menu', array($this, 'admin_menu')); $this->settings = $this->get_settings(); $this->livepress_config = LivePress_Config::get_instance(); }
function __construct() { add_action('admin_bar_menu', array($this, 'admin_bar_menu'), 100, 1); // priority influences position add_action('admin_enqueue_scripts', array($this, 'enqueue')); add_action('wp_enqueue_scripts', array($this, 'enqueue')); $this->livepress_config = LivePress_Config::get_instance(); $this->options = get_option(LivePress_Administration::$options_name); }
/** * Constructor * * @param string $api_key The api key to be used in the validations inside * the livepress service. */ public function __construct($api_key = '') { if ('' == $api_key) { } $this->livepress_config = LivePress_Config::get_instance(); $this->api_key = $api_key; // Note: site_url is the admin url on VIP $this->address = site_url(); // WP API $this->last_error = ''; $this->last_response = null; }
/** * Add comments needed by JS on frontend * * @param LivePress_JavaScript_Config $ljsc * @param Post $post current post * @param integer $page_active the page of the pagination * @param integer $comments_per_page */ public function js_config($ljsc, $post, $page_active, $comments_per_page) { $config = LivePress_Config::get_instance(); if (isset($post->comment_count)) { $ljsc->new_value('comment_count', $post->comment_count, Livepress_Configuration_Item::$LITERAL); } else { $ljsc->new_value('comment_count', 0, Livepress_Configuration_Item::$LITERAL); } $pagination_on = $config->get_host_option("page_comments") == "1"; $ljsc->new_value('comment_pagination_is_on', $pagination_on, Livepress_Configuration_Item::$BOOLEAN); $ljsc->new_value('comment_page_number', $page_active, Livepress_Configuration_Item::$LITERAL); $ljsc->new_value('comment_pages_count', $comments_per_page, Livepress_Configuration_Item::$LITERAL); $comment_order = $config->get_host_option('comment_order'); $ljsc->new_value('comment_order', $comment_order, Livepress_Configuration_Item::$STRING); $ljsc->new_value('disable_comments', $this->options['disable_comments'], Livepress_Configuration_Item::$BOOLEAN); $ljsc->new_value('comment_live_updates_default', $this->options['comment_live_updates_default'], Livepress_Configuration_Item::$BOOLEAN); if (isset($post->ID) && $post->ID) { $comment_msg_id = LivePress_WP_Utils::get_from_post($post->ID, "comment_update", true); $ljsc->new_value('comment_msg_id', $comment_msg_id); $ljsc->new_value('can_edit_comments', current_user_can('edit_post', $post->ID), Livepress_Configuration_Item::$BOOLEAN); } }
/** * The author template. * * @static * * @return string Author template. */ public static function author_template() { $config = LivePress_Config::get_instance(); return $config->get_option('author_template'); }
/** * Contructor that assigns the wordpress hooks, initialize the * configurable options and gets the wordpress options set. */ function __construct() { global $current_user; $this->custom_timestamp = null; $this->blogging_tools = new LivePress_Blogging_Tools(); $this->options = get_option(LivePress_Administration::$options_name); $this->options['ajax_nonce'] = wp_create_nonce(self::LIVEPRESS_ONCE); $this->options['ajax_comment_nonce'] = wp_create_nonce('post_comment'); $this->options['ajax_status_nonce'] = wp_create_nonce('lp_status'); $this->options['lp_add_live_update_tags_nonce'] = wp_create_nonce('lp_add_live_update_tags_nonce'); $this->options['ajax_twitter_search_nonce'] = wp_create_nonce('twitter_search_term'); $this->options['ajax_twitter_follow_nonce'] = wp_create_nonce('twitter_follow'); $this->options['ajax_lp_post_to_twitter'] = wp_create_nonce('lp_post_to_twitter_nonce'); $this->options['ajax_api_validate_nonce'] = wp_create_nonce('livepress_api_validate_nonce'); $this->options['lp_update_shortlink_nonce'] = wp_create_nonce('lp_update_shortlink'); $this->options['ajax_check_oauth'] = wp_create_nonce('lp_check_oauth_nonce'); $this->options['ajax_lp_collaboration_comments'] = wp_create_nonce('lp_collaboration_comments_nonce'); $this->options['ajax_get_live_edition_data'] = wp_create_nonce('get_live_edition_data_nonce'); $this->options['ajax_lp_im_integration'] = wp_create_nonce('lp_im_integration_nonce'); $this->options['ajax_render_tabs'] = wp_create_nonce('render_tabs_nonce'); $this->options['ajax_update_live_comments'] = wp_create_nonce('update_live_comments_nonce'); $this->options['ajax_new_im_follower'] = wp_create_nonce('new_im_follower_nonce'); $this->options['ajax_start_editor'] = wp_create_nonce('start_editor_nonce'); $this->user_options = get_user_option(LivePress_Administration::$options_name, $current_user->ID, false); $this->lp_comment = new LivePress_Comment($this->options); add_action('before_delete_post', array($this, 'remove_related_post_data')); add_action('transition_post_status', array($this, 'send_to_livepress_new_post'), 10, 3); add_action('private_to_publish', array($this, 'livepress_publish_post')); add_action('wp_ajax_lp_twitter_search_term', array($this, 'twitter_search_callback')); add_action('wp_ajax_lp_twitter_follow', array($this, 'twitter_follow_callback')); add_action('wp_ajax_lp_status', array($this, 'lp_status')); add_action('wp_ajax_lp_add_live_update_tags', array($this, 'lp_add_live_update_tags')); add_filter('update_post_metadata', array($this, 'livepress_filter_post_locks'), 10, 5); add_filter('add_post_metadata', array($this, 'livepress_filter_post_locks'), 10, 5); $this->lp_comment->do_wp_binds(isset($_POST['livepress_update'])); if (!isset($_POST['livepress_update'])) { $livepress_enabled = $this->has_livepress_enabled(); if ($livepress_enabled) { add_action('admin_head', array($this, 'embed_constants')); add_action('admin_enqueue_scripts', array($this, 'add_js_config'), 11); add_action('admin_enqueue_scripts', array($this, 'add_css_and_js_on_header'), 10); add_action('admin_head', array($this, 'remove_auto_save'), 10); // Adds the modified tinyMCE if (get_user_option('rich_editing') == 'true') { add_filter('mce_external_plugins', array($this, 'add_modified_tinymce')); } } // Ensuring that the post is divided into micro-post livepress chunks $live_update = $this->init_live_update(); add_action('wp_enqueue_scripts', array($this, 'add_js_config'), 11); add_action('wp_enqueue_scripts', array($this, 'add_css_and_js_on_header'), 10); add_filter('edit_post', array($this, 'maybe_merge_post'), 10); add_action('pre_post_update', array($this, 'save_old_post'), 999); add_filter('pre_post_update', array($this, 'save_lp_post_options'), 10); add_filter('content_save_pre', array($live_update, 'fill_livepress_shortcodes'), 5); } $api_key = isset($this->options['api_key']) ? $this->options['api_key'] : false; $this->livepress_config = LivePress_Config::get_instance(); $this->livepress_communication = new LivePress_Communication($api_key); // Moved these values from config file for increased VIP compatibility $this->title_css_selectors = array('Pixel' => 'h2.topTitle, .sidebarbox ul', 'Monochrome' => '.post_content_wrapper h2 span'); $this->background_colors = array('wordpress default' => '#FFFFFF'); // Add the Livepress Tags custom taxonomy register_taxonomy('livetags', apply_filters('livepress_post_types', array('post')), array('label' => __('Live Update Tags'), 'public' => false, 'show_ui' => true)); // We only want the taxonomy to show in the menu, not on the post edit page add_action('admin_menu', array($this, 'remove_livetag_metabox')); }
/** * Enqueue scripts and styles. */ function add_css_and_js() { if (LivePress_Config::get_instance()->script_debug()) { wp_enqueue_script('livepress_admin_ui_js', LP_PLUGIN_URL . 'js/admin_ui.full.js', array('jquery')); } else { wp_enqueue_script('livepress_admin_ui_js', LP_PLUGIN_URL . 'js/admin_ui.min.js', array('jquery')); } wp_register_style('livepress_facebox', LP_PLUGIN_URL . 'css/facebox.css'); wp_register_style('livepress_admin', LP_PLUGIN_URL . 'css/admin.css'); wp_print_styles('livepress_facebox'); wp_print_styles('livepress_admin'); }
/** * Make a feature pointer available so that users can find * the Blogging Tools Palette. */ public function feature_pointer() { $dismissed = explode(',', (string) get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true)); if (!in_array('livepress_pointer', $dismissed)) { $enqueue = true; // Enqueue pointers wp_enqueue_script('wp-pointer'); wp_enqueue_style('wp-pointer'); if (LivePress_Config::get_instance()->debug()) { wp_enqueue_script('livepress-pointer', LP_PLUGIN_URL . 'js/admin/livepress-pointer.full.js', array('wp-pointer'), LP_PLUGIN_VERSION, true); } else { wp_enqueue_script('livepress-pointer', LP_PLUGIN_URL . 'js/admin/livepress-pointer.min.js', array('wp-pointer'), LP_PLUGIN_VERSION, true); } // Initialize JS Options $pointer = array(); $pointer['ajaxurl'] = admin_url('admin-ajax.php'); $html = array(); $html[] = '<h3>' . esc_html__('New Real-Time Writing Tools!', 'livepress') . '</h3>'; $html[] = '<p>' . esc_html__('Click the above link to expand a set of tools for managing comments, searching Twitter, adding remote authors, and saving notes. — All in real-time!', 'livepress') . '</p>'; $pointer['content'] = implode('', $html); wp_localize_script('livepress-pointer', 'livepress_pointer', $pointer); } }