options = get_option( 'aiwp_settings', array() ); // if admin area, get instance of admin class if ( is_admin() ) { Appear_In_WP_Admin::get_instance(); } // else, check for shortcode presence and respond accordingly else { add_action( 'template_redirect', array( $this, 'respond_to_shortcode' ) ); } // add the shortcode add_shortcode( 'appear_in', array( $this, 'display_shortcode' ) ); } // end __construct /*---------------------------------------------------------------------------------* * Public Functions *---------------------------------------------------------------------------------*/ /** * Return an instance of this class. * * @since 1.0 * * @return object A single instance of this class. */ public static function get_instance() { // if the single instance hasn't been set, set it now. if ( null == self::$instance ) { self::$instance = new self; } // end if return self::$instance; } // end get_instance /** * Check for shortcode and enqueue scripts if shortcode is present. * * @since 1.0 */ public function respond_to_shortcode() { // get post object global $post; // get post object $post_obj = get_post( $post->ID ); // check if shortcode is present in post content if ( stripos( $post_obj->post_content, '[appear_in' ) !== FALSE ) { // call to enqueue scripts and styles needed for shortcode add_action( 'wp_enqueue_scripts', array( $this, 'add_stylesheets_and_javascript' ) ); } // end if } // end respond_to_shortcode /** * Registers the front-end stylesheets and scripts * * @since 1.0 */ public function add_stylesheets_and_javascript() { // enqueue stylesheet wp_enqueue_style( 'aiwp-style', AIWP_DIR_URL . 'aiwp.css', array(), AIWP_VERSION, 'screen' ); // enqueue jquery on front-end wp_enqueue_script( 'jquery' ); // enqueue appear-in API library wp_enqueue_script( 'appearin-library', 'http://iswebrtcready.appear.in/apiv2.js', array(), AIWP_VERSION ); // enqueue script for handling local interaction wp_enqueue_script( 'aiwp', AIWP_DIR_URL . 'aiwp.js', array(), AIWP_VERSION ); } // end add_stylesheets_and_javascript /** * Returns the shortcode content * * @since 1.0 * * @return string HTML content displayed by shortcode. */ public function display_shortcode( $atts, $content = '' ) { // extract the shortcode parameters extract( shortcode_atts( array( 'room' => '', 'type' => 'public', ), $atts ) ); // push the shortcode defined rooom types to an array $aiwp_room_types = explode( ',', str_replace( ' ', '', $type ) ); // get public room name from shortcode, otherwise from custom options, otherwise from plugins randomly assigned & daily dynamic name if ( '' != $room ) { $custom_room_name = $room; } elseif ( isset( $this->options['room'] ) && '' != $this->options['room'] ) { $custom_room_name = $this->options['room']; } else { $custom_room_name = get_option( 'aiwp_public_room' ); } // build room selection wrapper // Add styling for iconset $html = ''; $html .= '