elvismdev / wordpress-firebase-chat

Live Chat powered by Firebase
0 stars 0 forks source link

Show chat room in another post or page #3

Closed elvismdev closed 9 years ago

elvismdev commented 9 years ago

Following up this question I made to the author of the plugin https://wordpress.org/support/topic/embed-chat-room-into-another-page-or-post

I would like to have a shortcode which can be used to embed/output the chat room created into another page or post. Or a function which could be called from the page/post template file and invokes an specified chat room.

elvismdev commented 9 years ago

I was able to put this static code in the a page template file to render a chat room created:

<div ng-app="chat_app" ng-controller="chat_controller" ng-init="startChat(36)" class="ng-scope">
            <div id="fire_chat_container">
                <div id="fire_chat_messages">
                    <article ng-repeat="msg in fireChat.chat">
                        <strong>{{msg.name}}</strong>: <span>{{msg.msg}}</span>
                    </article>
                </div>
                <form id="fire_chat_form" ng-submit="newChat()">
                    <input ng-model="msg.name" placeholder="Name" />
                    <textarea ng-model="msg.msg" placeholder="Message"></textarea>
                    <input type="submit" value="chat" />
                </form>
            </div>
        </div>

All needed to do is create a shortcode that could be passed the id of the chat room to load (the custom post_type id), so we can run something like:

echo do_shortcode( '[chatroom id="36"]' );
elvismdev commented 9 years ago

Merged a shortcode to master in pull request https://github.com/elvismdev/wordpress-firebase-chat/pull/4

Needs fixing to make it working properly on pages and posts content body.

By now it works good invoking from the template files with do_shortcode()

elvismdev commented 9 years ago

Bug fixed thanks to the improvement made on AngularJS for WP plugin at this commit https://github.com/royboy789/angularjs-for-wordpress/commit/7b3dee9b8e97ac1389eaa032eac2ee0a585d0b34