Introducing objects answers as well as other new features and fixes #156
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a big PR originally meant to come with a way to generate a poll from existing posts type items (films, songs, places, etc.), as evoked in #155. It has been implemented here, but It eventually also comes with fixes, and other features.
Sorry for the fact that there has been no progressive commits to make it easier to follow the changes, but you will find summarized below the main changes & directions taken.
Also note that this PR has been tested successfully both on a fresh install and on an existing install with the limitations mentioned in the To-do section below.
Main changes
New features
get_poll
has a new optional parametertemplates_set_id
which says whether settings should be retrieved from:templates_set_id = 0
templates_set_id > 0
templates_set_id = -1
get_pollvotes_by_templates_set_id($templates_set_id)
(sum of all polls' totalvotes associated to a given templates_set ID).$templates_set_id
to display only archive of polls associated to a given templates set.polls_archive($templates_set_id)
[page_polls tpl_id=2]
to retrieve for instance polls associated to templates set n°2 .Partial UI reorganization
wp-options
table) to allow templates set-specific settings.Improvements
wp-polls-ans
with attributedata-ansmax
set with value%POLL_MULTIPLE_ANS_MAX%
. It is included in the vote template header of the updated default templates sets (both for text and object type).Fixes
$poll_questions_ids = substr($poll_questions_ids, 0, -2);
. It is now using array-based logic instead of a string-based one.sprintf()
command in polls-add.php responsible for disclosing the shortcode after poll creation.Tested for backward compatibility as well as for fresh install.
Development's directions:
pollsaof
to save answers object fields associated to each poll with object answers, andpollstpl
to save templates sets)text
orobject
) coming together with a proper migration mechanism from previous plugin's version.get_option()
) to tablepollstpl
. The array retrieved withget_option('poll_options')
has been internally modified but kept as the place to store the 'General Options' settings. Its subkeys (i.e. former options key retrieved withget_option()
) are now to be retrieved using the helperwp_polls_get_child_option($subkey)
.poll_scripts()
has been split in 2 functions ( and ):poll_scripts()
with the key static content which is fine being loaded atwp_enqueue_scripts
.poll_templates_scripts()
with dynamic content which must be loaded atwp_footer
so that$templates_sets_loaded
global variable has time to be correctly populated.wp_footer
but as it is a template-dependant hook (although "fairly widely supported"), the rationale behind the split is that it may be more resilient to have the mandatory content for the plugin to work fired atwp_enqueue_scripts
(theme-independant hook). That way, even if a theme wasn't supporting thewp_footer
hook, the plugin would still work (even if slightly degraded in terms of style).To-do
wp-polls.php
was set to 3.00.0 (you might want to change this).polls_activate()
. New code base with old DB structures will result in errors displayed. Also if the admin tries to uninstall the plugin, he/she will get a message saying it is impossible to remove (due touninstall.php
trying to remove new DB tables that were never created so far). Should plugin desactivation at upgrade be forced (say atplugins_loaded
hook for instance), calling for manual reactivation by admin ?