WordPress.org

Ready to get started?Download WordPress

Forums

YOP Poll
Template choices not being saved (4 posts)

  1. Thor.worx
    Member
    Posted 4 months ago #

    I've chosen both Poll template and Widget templates in my poll.
    After clicking save poll, get message "Poll successfully Edited!"

    However, the widget does not display with my chosen template, and if I return to the poll editing screen, the template choices revert back to "--Select Template--"

    Also, the "Reset Poll Stats Automatically:" choice is reset in options. (I saved it as "No", but it comes back as unchecked)

    I can't override the widget styles because the poll widget keeps inserting (INCORRECT!) inline styles with the poll ID hardcoded into them.

    https://wordpress.org/plugins/yop-poll/

  2. YOP
    Member
    Plugin Author

    Posted 4 months ago #

    Hi Thor.worx,

    Edit inc/plugin-functions.php and at the end add

    function yop_poll_default_options() {
     $sitename = strtolower( $_SERVER['SERVER_NAME'] );
            if ( substr( $sitename, 0, 4 ) == 'www.' ) {
                $sitename = substr( $sitename, 4 );
            }
    
            return array(
                'poll_name_html_tags'      => 'yes',
                'poll_question_html_tags'     => 'yes',
                'poll_answer_html_tags'      => 'yes',
                'poll_custom_field_html_tags'    => 'yes',
                'create_poll_page'       => 'yes',
                'auto_generate_poll_page'                   => 'no',
                'has_auto_generate_poll_page'               => 'no',
                'poll_page_url'        => '',
                'allow_other_answers'      => 'yes',
                'other_answers_label'      => 'Other',
                'display_other_answers_values'    => 'no',
                'allow_multiple_answers'     => 'no',
                'allow_multiple_answers_number'    => 1,
                'allow_multiple_answers_min_number'   => 1,
                'display_answers'       => 'vertical',
                'display_answers_tabulated_cols'   => 1,
                'display_results'       => 'vertical',
                'display_results_tabulated_cols'   => 1,
                'is_default_answer'       => 'no',
                'use_template_bar'       => 'yes',
                'bar_background'       => 'FBD55E',
                'bar_height'        => 10,
                'bar_border_color'       => 'EDB918',
                'bar_border_width'       => 1,
                'bar_border_style'       => 'solid',
                'sorting_answers'       => 'exact',
                'sorting_answers_direction'     => 'asc',
                'sorting_results'       => 'exact',
                'sorting_results_direction'     => 'asc',
                'start_date'        => Yop_Poll_Model::get_mysql_curent_date(),
                'end_date'         => '9999-12-31 23:59:59',
                'never_expire'        => 'yes',
                'view_results'        => 'after',
                'answer_result_label'      => '- %POLL-ANSWER-RESULT-PERCENTAGES% ( %POLL-ANSWER-RESULT-VOTES% )',
                'view_results_type'       => 'votes-number',
                'view_results_start_date'     => '',
                'view_results_link'       => 'yes',
                'view_back_to_vote_link'     => 'yes',
                'singular_answer_result_votes_number_label' => 'vote',
                'plural_answer_result_votes_number_label' => 'votes',
                'vote_button_label'       => 'Vote',
                'view_results_link_label'     => 'View Results',
                'view_back_to_vote_link_label'    => 'Back To Vote',
                'view_total_votes_label'     => 'Total Votes %POLL-TOTAL-VOTES%',
                'view_total_answers_label'     => 'Total Answers %POLL-TOTAL-ANSWERS%',
                'view_total_voters_label'     => 'Total Answers %POLL-TOTAL-VOTERS%',
                'view_total_answers'      => 'yes',
                'view_total_voters'       => 'yes',
                'view_total_votes'       => 'yes',
                'view_poll_archive_link'     => 'yes',
                'view_poll_archive_link_label'    => 'View Poll Archive',
                'poll_archive_url'       => home_url().'/yop-poll-archive',
                'vote_permisions'       => 'guest-registered',
                'vote_permisions_facebook'     => 'no',
                'vote_permisions_facebook_label'   => 'Vote as Facebook User',
                'vote_permisions_wordpress'     => 'no',
                'vote_permisions_wordpress_label'   => 'Vote as WordPress User',
                'vote_permisions_anonymous'     => 'no',
                'vote_permisions_anonymous_label'   => 'Vote as Anonymous User',
                'blocking_voters'       => 'dont-block',
                'blocking_voters_interval_value'   => 30,
                'blocking_voters_interval_unit'    => 'days',
                'template'         => '1',
                'widget_template'       => '1',
                'template_width'       => '200px',
                'widget_template_width'      => '200px',
                'show_in_archive'       => 'yes',
                'archive_order'        => '1',
                'archive_polls_per_page'     => '5',
                'percentages_decimals'      => '0',
                'use_default_loading_image'     => 'yes',
                'loading_image_url'       => '',
                'use_captcha'        => 'no',
                'share_after_vote'       => 'no',
                'share_picture'        => '',
                'share_name'        => '',
                'share_caption'        => '',
                'share_description'       => '',
                'redirect_after_vote'      => 'no',
                'redirect_after_vote_url'     => '',
                'limit_number_of_votes_per_user'   => 'no',
                'number_of_votes_per_user'     => 1,
                'message_after_vote'      => 'Thank you for your vote!',
                'start_scheduler'       => 'no',
                'schedule_reset_poll_stats'     => 'no',
                'schedule_reset_poll_date'     => current_time( 'timestamp' ),
                'schedule_reset_poll_recurring_value'  => 9999,
                'schedule_reset_poll_recurring_unit'  => 'day',
                'view_results_permissions'     => 'guest-registered',
                'date_format'        => 'd/m/Y H:i:s',
                'add_other_answers_to_default_answers'  => 'no',
                'send_email_notifications'     => 'no',
                'email_notifications_from_name'    => 'Yop Poll',
                'email_notifications_from_email'   => 'yop-poll@' . $sitename,
                'email_notifications_recipients'   => '',
                'email_notifications_subject'    => 'New Vote',
                'email_notifications_body'     => '<p>A new vote was registered on [VOTE_DATE] for [POLL_NAME]</p>
       <p>Vote Details:</p>
       <p><b>Question:</b> [QUESTION]</p>
       <p><b>Answers:</b> <br />[ANSWERS]</p>
       <p><b>Custom Fields:</b> <br />[CUSTOM_FIELDS]</p>
       <p><b>Vote ID:</b> <br />[VOTE_ID]</p>',
            );
        }

    Also, in inc/admin.php, at the end of db_update function, add

    $default_options = yop_poll_default_options();
                $general_options = get_option( 'yop_poll_options', array() );
                foreach( $default_options as $option => $value ) {
                    if( !isset($general_options[$option]) ) {
                        $general_options[$option] = $value;
                    }
                }
                update_option('yop_poll_options',$general_options);

    To change the widget style edit the template you used for the widget and make the necessary modifications in the CSS section.

    Regards,

    YOP Team

  3. Thor.worx
    Member
    Posted 4 months ago #

    Thanx for the reply...

    Adding the code provided to inc/plugin-functions.php results in:

    PHP Fatal error: Class 'Yop_Poll_Model' not found in /server/user/public_html/wp/wp-content/plugins/yop-poll/inc/plugin-functions.php on line 238

    Adding the code provided to inc/admin.php results in inability to access admin dashboard (white page).

  4. YOP
    Member
    Plugin Author

    Posted 4 months ago #

    Hi Thor.worx,

    Please replace
    'start_date' => Yop_Poll_Model::get_mysql_curent_date(),
    with
    'start_date' => date('Y-m-d H:i:s'),
    in previous array.

    Please let us know if you need more help.

    Regards,
    YOP Team!

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.