Poll, Survey, Quiz, Slideshow, Form, Story & Landing Page - Version 1.0

Version Description

N/A

Download this release

Release Info

Developer yoffegil
Plugin Icon 128x128 Poll, Survey, Quiz, Slideshow, Form, Story & Landing Page
Version 1.0
Comparing to
See all releases

Version 1.0

images/os-small.png ADDED
Binary file
images/os.png ADDED
Binary file
opinionstage-functions.php ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* --- Wordpress Hooks Implementations --- */
3
+
4
+ /**
5
+ * Main function for creating the widget html representation.
6
+ * Transforms the shorcode parameters to the desired iframe call.
7
+ *
8
+ * Syntax as follows:
9
+ * shortcode name - OPINIONSTAGE_WIDGET_SHORTCODE
10
+ *
11
+ * Arguments:
12
+ * @param id - Id of the poll
13
+ *
14
+ */
15
+ function opinionstage_add_poll($atts) {
16
+ extract(shortcode_atts(array('id' => 0), $atts));
17
+ if(!is_feed()) {
18
+ $id = intval($id);
19
+ return opinionstage_create_embed_code($id);
20
+ } else {
21
+ return __('Note: There is a poll embedded within this post, please visit the site to participate in this post\'s poll.', OPINIONSTAGE_WIDGET_UNIQUE_ID);
22
+ }
23
+ }
24
+
25
+ /**
26
+ * Create the The iframe HTML Tag according to the given paramters.
27
+ * Either get the embed code or embeds it directly in case
28
+ *
29
+ * Arguments:
30
+ * @param id - Id of the poll
31
+ */
32
+ function opinionstage_create_embed_code($id) {
33
+
34
+ // Only present if id is available
35
+ if (isset($id) && !empty($id)) {
36
+ // Load embed code from the cache if possible
37
+ if ( false === ( $code = get_transient( 'embed_code' . $id) ) ) {
38
+ extract(opinionstage_get_contents("http://".OPINIONSTAGE_SERVER_BASE."/api/debates/" . $id . "/embed_code.json"));
39
+ $data = json_decode($raw_data);
40
+ if ($success) {
41
+ $code = $data->{'code'};
42
+ // Set the embed code to be cached for an hour
43
+ set_transient( 'embed_code' . $id, $code, 3600);
44
+ }
45
+ }
46
+ }
47
+ return $code;
48
+ }
49
+
50
+ /**
51
+ * Perform an HTTP GET Call to retrieve the data for the required content.
52
+ *
53
+ * Arguments:
54
+ * @param $url
55
+ * @return array - raw_data and a success flag
56
+ */
57
+ function opinionstage_get_contents($url) {
58
+ $response = wp_remote_get($url, array('header' => array('Accept' => 'application/json; charset=utf-8'),
59
+ 'timeout' => 10));
60
+
61
+ return opinionstage_parse_response($response);
62
+ }
63
+
64
+ /**
65
+ * Parse the HTTP response and return the data and if was successful or not.
66
+ */
67
+ function opinionstage_parse_response($response) {
68
+ $success = false;
69
+ $raw_data = "Unknown error";
70
+
71
+ if (is_wp_error($response)) {
72
+ $raw_data = $response->get_error_message();
73
+
74
+ } elseif (!empty($response['response'])) {
75
+ if ($response['response']['code'] != 200) {
76
+ $raw_data = $response['response']['message'];
77
+ } else {
78
+ $success = true;
79
+ $raw_data = $response['body'];
80
+ }
81
+ }
82
+
83
+ return compact('raw_data', 'success');
84
+ }
85
+
86
+ /**
87
+ * Adds the poll button to the edit bar for new/edited post/page
88
+ */
89
+ function opinionstage_poll_footer_admin() {
90
+ // Javascript Code Courtesy Of WP-AddQuicktag (http://bueltge.de/wp-addquicktags-de-plugin/120/)
91
+ echo '<script type="text/javascript">'."\n";
92
+ echo '/* <![CDATA[ */'."\n";
93
+ echo "\t".'var opsPollBtn = {'."\n";
94
+ echo "\t\t".'enter_poll_id: "'.esc_js(__('Enter Poll ID', OPINIONSTAGE_WIDGET_UNIQUE_ID)).'",'."\n";
95
+ echo "\t\t".'enter_poll_id_again: "'.esc_js(__('Error: Poll ID must be numeric', OPINIONSTAGE_WIDGET_UNIQUE_ID)).'\n\n'.esc_js(__('Please enter Poll ID again', OPINIONSTAGE_WIDGET_UNIQUE_ID)).'",'."\n";
96
+ echo "\t\t".'poll: "'.esc_js(__('social poll', OPINIONSTAGE_WIDGET_UNIQUE_ID)).'",'."\n";
97
+ echo "\t\t".'insert_poll: "'.esc_js(__('Insert social poll', OPINIONSTAGE_WIDGET_UNIQUE_ID)).'"'."\n";
98
+ echo "\t".'};'."\n";
99
+ echo "\t".'function insertOSPoll(where, myField) {'."\n";
100
+ echo "\t\t".'var poll_id = jQuery.trim(prompt(opsPollBtn.enter_poll_id));'."\n";
101
+ echo "\t\t".'while(isNaN(poll_id)) {'."\n";
102
+ echo "\t\t\t".'poll_id = jQuery.trim(prompt(opsPollBtn.enter_poll_id_again));'."\n";
103
+ echo "\t\t".'}'."\n";
104
+ echo "\t\t".'if (poll_id >= -1 && poll_id != null && poll_id != "") {'."\n";
105
+ echo "\t\t\t".'if(where == \'code\') {'."\n";
106
+ echo "\t\t\t\t".'edInsertContent(myField, \'['.OPINIONSTAGE_WIDGET_SHORTCODE.' id="\' + poll_id + \'"]\');'."\n";
107
+ echo "\t\t\t".'} else {'."\n";
108
+ echo "\t\t\t\t".'return \'['.OPINIONSTAGE_WIDGET_SHORTCODE.' id="\' + poll_id + \'"]\';'."\n";
109
+ echo "\t\t\t".'}'."\n";
110
+ echo "\t\t".'}'."\n";
111
+ echo "\t".'}'."\n";
112
+ echo "\t".'if(document.getElementById("ed_toolbar")){'."\n";
113
+ echo "\t\t".'edButtons[edButtons.length] = new edButton("ed_o_poll",opsPollBtn.poll, "", "","");'."\n";
114
+ echo "\t\t".'jQuery(document).ready(function($){'."\n";
115
+ echo "\t\t\t".'$(\'#qt_content_ed_o_poll\').replaceWith(\'<input type="button" id="qt_content_ed_o_poll" accesskey="" class="ed_button" onclick="insertOSPoll(\\\'code\\\', edCanvas);" value="\' + opsPollBtn.poll + \'" title="\' + opsPollBtn.insert_poll + \'" />\');'."\n";
116
+ echo "\t\t".'});'."\n";
117
+ echo "\t".'}'."\n";
118
+ echo '/* ]]> */'."\n";
119
+ echo '</script>'."\n";
120
+ }
121
+
122
+ /**
123
+ * Adds the poll button to the edit bar for new/edited post/page
124
+ */
125
+ function opinionstage_poll_menu() {
126
+ if (function_exists('add_menu_page')) {
127
+ add_menu_page(__('Add Polls', OPINIONSTAGE_WIDGET_UNIQUE_ID), __('Social Polls', OPINIONSTAGE_WIDGET_UNIQUE_ID), 'edit_posts', OPINIONSTAGE_WIDGET_UNIQUE_LOCATION, 'opinionstage_add_poll_page',
128
+ plugins_url(OPINIONSTAGE_WIDGET_UNIQUE_ID.'/images/os-small.png'));
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Instructions for adding a poll
134
+ */
135
+ function opinionstage_add_poll_page() {
136
+ ?>
137
+ <h1><strong>Opinion Stage Social Polls</strong></h1>
138
+ <BR>
139
+ <h3><strong>To add a social poll to your post/page:</strong></h3>
140
+ <p>1) &nbsp; Start a new poll using the <?php echo opinionstage_create_link('start a poll / debate', 'new_debate', ''); ?> form on OpinionStage.com</p>
141
+ <p>2) &nbsp; Copy the embed ID (located near the Embed button on the poll / debate page)</p>
142
+ <p>3) &nbsp; From the WordPress post/page text editor, click on the social poll icon to open the embed dialog</p>
143
+ <p>4) &nbsp; Paste the ID into the embed dialog</p>
144
+ <BR>
145
+ Need more information? <?php echo opinionstage_create_link('click here', 'publishers/wordpress', ''); ?>. For support or feedback, please email us at:&nbsp;<a href="mailto:info@opinionstage.com">info@opinionstage.com</a>
146
+ <?php
147
+ }
148
+
149
+ /**
150
+ * Adds the poll button to the edit bar for new/edited post/page In TinyMCE >= WordPress 2.5
151
+ */
152
+ function opinionstage_poll_tinymce_addbuttons() {
153
+ if(!current_user_can('edit_posts') && ! current_user_can('edit_pages')) {
154
+ return;
155
+ }
156
+ if(get_user_option('rich_editing') == 'true') {
157
+ add_filter("mce_external_plugins", "opinionstage_poll_tinymce_addplugin");
158
+ add_filter('mce_buttons', 'opinionstage_poll_tinymce_registerbutton');
159
+ }
160
+ }
161
+ function opinionstage_poll_tinymce_registerbutton($buttons) {
162
+ array_push($buttons, 'separator', 'ospolls');
163
+ return $buttons;
164
+ }
165
+ function opinionstage_poll_tinymce_addplugin($plugin_array) {
166
+ $plugin_array['ospolls'] = plugins_url(OPINIONSTAGE_WIDGET_UNIQUE_ID.'/tinymce/plugins/polls/editor_plugin.js');
167
+ return $plugin_array;
168
+ }
169
+
170
+ /**
171
+ * Utility function to create a link with the correct host and all the required information.
172
+ */
173
+ function opinionstage_create_link($caption, $page, $params = "", $options = array()) {
174
+ $style = empty($options['style']) ? '' : $options['style'];
175
+ $new_page = empty($options['new_page']) ? true : $options['new_page'];
176
+
177
+ $params_prefix = empty($params) ? "" : "&";
178
+
179
+ $link = "http://".OPINIONSTAGE_SERVER_BASE."/".$page."?ref=".OPINIONSTAGE_WIDGET_API_KEY.$params_prefix.$params;
180
+
181
+ return "<a href=\"".$link."\"".($new_page ? " target='_blank'" : "")." style=".$style.">".$caption."</a>";
182
+ }
183
+
184
+ ?>
opinionstage-polls.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Social Polls by OpinionStage
4
+ Plugin URI: http://www.opinionstage.com
5
+ Description: Adds a highly engaging social polling system to your blog. You can easily add a social poll to your blog post/page by clicking the social poll icon in the WordPress post/page text editor.
6
+ Version: 1.0.0
7
+ Author: OpinionStage.com
8
+ Author URI: http://www.opinionstage.com
9
+ */
10
+
11
+ /* --- Static initializer for Wordpress hooks --- */
12
+
13
+ define('OPINIONSTAGE_SERVER_BASE', "www.opinionstage.com"); /* Don't include the protocol, added dynamically */
14
+ define('OPINIONSTAGE_WIDGET_VERSION', '1.0.0');
15
+ define('OPINIONSTAGE_WIDGET_PLUGIN_NAME', 'Social Polls by OpinionStage');
16
+ define('OPINIONSTAGE_WIDGET_API_KEY', 'wp-v-poll');
17
+ define('OPINIONSTAGE_WIDGET_SHORTCODE', 'socialpoll');
18
+ define('OPINIONSTAGE_WIDGET_UNIQUE_ID', 'social-polls-by-opinionstage');
19
+ define('OPINIONSTAGE_WIDGET_UNIQUE_LOCATION', __FILE__);
20
+
21
+ require_once(WP_PLUGIN_DIR."/".OPINIONSTAGE_WIDGET_UNIQUE_ID."/opinionstage-functions.php");
22
+
23
+
24
+ /* --- Static initializer for Wordpress hooks --- */
25
+
26
+
27
+ add_shortcode(OPINIONSTAGE_WIDGET_SHORTCODE, 'opinionstage_add_poll');
28
+
29
+ // Post creation/edit hooks
30
+ add_action('admin_footer-post-new.php', 'opinionstage_poll_footer_admin');
31
+ add_action('admin_footer-post.php', 'opinionstage_poll_footer_admin');
32
+ add_action('admin_footer-page-new.php', 'opinionstage_poll_footer_admin');
33
+ add_action('admin_footer-page.php', 'opinionstage_poll_footer_admin');
34
+
35
+ // Post creation/edit hook for visual editing
36
+ add_action('init', 'opinionstage_poll_tinymce_addbuttons');
37
+
38
+ // Side menu
39
+ add_action('admin_menu', 'opinionstage_poll_menu');
40
+
41
+ ?>
readme.txt ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Social Polls by OpinionStage ===
2
+ Contributors: OpinionStage.com
3
+ Donate link:
4
+ Tags: poll, polls, polling, vote, voting, debate, survey, social, opinionstage, opinion stage
5
+
6
+ Requires at least: 2.8
7
+ Tested up to: 3.3.2
8
+ Stable tag: trunk
9
+
10
+ Add a social polling system to your blog. To add a social poll click on the social poll icon in the post/page text editor.
11
+
12
+ == Description ==
13
+
14
+ The Opinion Stage social poll plug-in allows you to easily integrate a social poll in any blog post/page.
15
+ <BR>
16
+ The social polls are designed to both improve user engagement and to drive additional traffic from social networks to the page in which the poll is embedded.
17
+ <BR>
18
+ The social poll plug-in is completely free and is easy to install and use.
19
+
20
+ = Main Poll Features: =
21
+
22
+ * Survey site visitors using their social network identities
23
+ * View the full poll participant list
24
+ * Filter the poll participant list according to vote
25
+ * Follow users that participated in the poll
26
+ * Get notified about poll votes of users you follow (optionally)
27
+ * Filter the poll results by users you follow
28
+ * Discover what poll participants voted in other polls by visiting their profile
29
+ * Get the poll question & poll votes shared in social networks, driving additional traffic to the site
30
+ * ... And many more features to come!
31
+
32
+ = About Opinion Stage: =
33
+
34
+ Opinion Stage polls / debates bring together social network users with common interests and a desire to express, debate and follow opinions. For more details on Opinion Stage's polls & debates, visit <a href="http://www.opinionstage.com?ref=wp-v-poll" target="_blank">the Opinion Stage site.</a>
35
+
36
+ == Installation ==
37
+
38
+ 1. Upload the social polls plug-in to your blog (or search for it) and install it on your plug-ins page
39
+ 2. Activate it
40
+
41
+ == Frequently Asked Questions ==
42
+
43
+
44
+ = What sets Opinion Stage polls apart from other polling solutions? =
45
+
46
+ Opinion Stage polls are social polls which means that social network identities are used for polling the participants. This makes the poll more engaging than the typical poll, letting users discover who supports what and how each user voted in other polls. You can also follow users and then filter the poll results by the people you follow. Using social polls, also improves the distribution of the poll in social networks.
47
+
48
+ = Do you require users to identify by logging-in before voting? =
49
+
50
+ Yes, we currently support Facebook login, but are working to add additional poll login options such as Twitter.
51
+
52
+ = Do you support anonymous voting? =
53
+
54
+ Yes, while you do need to login to participate in the poll, you can vote anonymously so that nobody besides yourself knows what you voted in the poll.
55
+
56
+ = How do users share the poll & their vote in social networks? =
57
+
58
+ Users can either share the poll question from the sharing menu, or share their votes from the Facebook & Twitter sharing buttons that are displayed after voting. We never share anything on the users' behalf.
59
+
60
+ = What are the benifits of using social polls? =
61
+
62
+ Using social polls improves user engagement and adds additional traffic from social networks.
63
+
64
+ = What types of polls do you support? =
65
+
66
+ We currently support two-sided polls. However we will soon be supporting additional types of polls.
67
+
68
+ = Do you plan to add debating capabilities to the poll? =
69
+
70
+ Yes, we plan to add the option to allow debating the poll. Users will be able to add a text explanation to their votes so the vote can be debated.
71
+
72
+ = How do I add a poll to my post/page? =
73
+
74
+ Follow these steps:
75
+
76
+ 1. Create a new poll / debate from <a href="http://www.opinionstage.com?ref=wp-v-poll" target="_blank">here</a>
77
+ 2. Copy the embed ID displayed on the poll
78
+ 3. Click on the poll icon in the WordPress text editor to open the embed dialog
79
+ 4. Paste the ID you copied in the embed dialog
80
+
81
+ = What is the embed ID and where can I find it? =
82
+
83
+ Each poll has a unique ID which identifies it. The poll ID can be found in the poll embed button on the poll / debate page.
84
+
85
+ = Can I embed a poll manually? =
86
+
87
+ Yes, just post the following syntax into any post/page: [socialpoll ID="xyz"], where the xyz represents the poll ID.
88
+
89
+ == Screenshots ==
90
+
91
+ 1. **Two sided poll: before vote** - Example of a poll with 2 videos, you can filter the poll results by the people you follow
92
+ 2. **Two sided poll: after vote** - After voting in the poll, users are encouraged to share their poll vote in Facebook or Twitter driving additional traffic to the site
93
+ 3. **Full list of poll voters** - Click 'view all', to view the full list of poll voters and discover who supports what. You can also follow users from this screen
94
+ 4. **Profile of poll participant** - click on one of the poll participants to view his/her opinion profile. The profile includes votes in other polls, list of following users and more
95
+ 5. **Start a poll / debate form** - Just add a question, add sides & select a topic and you're ready to go. Click the 'show details' for advanced poll options
96
+ 6. **Insert social poll icon** - From the WordPress editor, click on the social poll icon to add a poll to the post/page
97
+
98
+ == Upgrade Notice ==
99
+
100
+ N/A
101
+
102
+ == Changelog ==
103
+ = Version 1.0.0 (15 Aug 2012) =
104
+ * First social poll version
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file
screenshot-4.png ADDED
Binary file
screenshot-5.png ADDED
Binary file
screenshot-6.png ADDED
Binary file
tinymce/plugins/polls/editor_plugin.js ADDED
@@ -0,0 +1 @@
 
1
+ (function(){tinymce.PluginManager.requireLangPack('ospolls');tinymce.create("tinymce.plugins.OSPolls",{init:function(a,b){a.addCommand("mceOSPollInsert",function(){a.execCommand("mceInsertContent",0,insertOSPoll("visual",""))});a.addButton("ospolls",{title:"ospolls.insert_poll",cmd:"mceOSPollInsert",image:b+"/img/os.png"});a.onNodeChange.add(function(d,c,e){c.setActive("ospolls",e.nodeName=="IMG")})},createControl:function(b,a){return null},getInfo:function(){return{longname:"Social-Polls-by-OpinionStage",author:"Opinion Stage",authorurl:"http://www.opinionstage.com",infourl:"http://www.opinionstage.com/about",version:"1.0"}}});tinymce.PluginManager.add("ospolls",tinymce.plugins.OSPolls)})();
tinymce/plugins/polls/img/os.png ADDED
Binary file
tinymce/plugins/polls/langs/en.js ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ tinyMCE.addI18n("en.ospolls", {
2
+ insert_poll : 'Insert Social Poll'
3
+ });