Plugin Directory

Changeset 1167167


Ignore:
Timestamp:
05/25/2015 02:53:38 PM (11 years ago)
Author:
awesome-ug
Message:

Beta 13

Location:
questions
Files:
99 added
16 edited

Legend:

Unmodified
Added
Removed
  • questions/trunk/README.txt

    r1162710 r1167167  
    6969== Changelog ==
    7070
     71= 1.0.0 beta 13 =
     72* Making Questions Multisite-Ready
     73* Flushing rewrite rules correct
     74* Added WP Editor to settings API
     75* Changed description editor to WP Editor
     76* Moved description text under question, before fields
     77* Fixed bug on double description output
     78* Bettered up Plugin CSS
     79* Enhanced code structure
     80
    7181= 1.0.0 beta 12 =
    7282* Fixed exporting bug on exporting multiple choice fields results
  • questions/trunk/components/charts/charts.php

    r1140359 r1167167  
    5555   
    5656    public function includes(){
    57         include( QUESTIONS_COMPONENTFOLDER . '/charts/data-abstraction.php' );
    5857        include( QUESTIONS_COMPONENTFOLDER . '/charts/chart-creator-dimple.php' );
    5958        include( QUESTIONS_COMPONENTFOLDER . '/charts/shortcodes.php' );
  • questions/trunk/components/core/core.php

    r1127623 r1167167  
    118118        include( QUESTIONS_COMPONENTFOLDER . '/core/tools/post.php' );
    119119        include( QUESTIONS_COMPONENTFOLDER . '/core/tools/survey.php' );
     120        include( QUESTIONS_COMPONENTFOLDER . '/core/data-abstraction.php' );
    120121    }
    121122   
  • questions/trunk/components/core/process-response.php

    r1162557 r1167167  
    3636class Questions_ProcessResponse {
    3737
     38    /**
     39     * Survey id of processed survey
     40     */
    3841    var $survey_id;
    3942
    40     var $response_errors = array();
    41 
     43    /**
     44     * Is survey fineshed?
     45     */
    4246    var $finished = FALSE;
    4347
     
    4852    /**
    4953     * Initializes the Component.
    50      *
    5154     * @since 1.0.0
    5255     */
     
    6467    /**
    6568     * Adding filter for the content to show Survey
     69     * @since 1.0.0
    6670     */
    6771    public function add_post_filter() {
     
    7478     *
    7579     * @param string $content
    76      *
    7780     * @return string $content
     81     * @since 1.0.0
    7882     */
    7983    public function the_content( $content ) {
     
    107111     *
    108112     * @param int $survey_id
    109      *
    110113     * @return string $survey_html
     114     * @since 1.0.0
    111115     */
    112116    public function show_survey( $survey_id ) {
     
    127131     *
    128132     * @param int $survey_id
    129      *
    130133     * @return mixed $participate True
     134     * @since 1.0.0
    131135     */
    132136    private function check_restrictions( $survey_id ) {
     
    229233     *
    230234     * @param int $survey_id
    231      *
    232235     * @return string $html
     236     * @since 1.0.0
    233237     */
    234238    private function survey_form( $survey_id ) {
     
    259263        $step_count = $this->get_step_count( $survey_id );
    260264
    261         $html .= '<div class="questions-description">' . sprintf(
     265        $html .= '<div class="questions-pagination">' . sprintf(
    262266                __(
    263267                    'Step <span class="questions-highlight-number">%d</span> of <span class="questions-highlight-number">%s</span>',
     
    311315     * @param int $survey_id
    312316     * @param int $user_id
    313      *
    314317     * @return boolean $can_participate
     318     * @since 1.0.0
    315319     */
    316320    public function user_can_participate( $survey_id, $user_id = NULL ) {
     
    333337     *
    334338     * @param int $survey_id
    335      *
    336339     * @return int $splitter_count
     340     * @since 1.0.0
    337341     */
    338342    private function get_step_count( $survey_id ) {
     
    348352     * @param int $survey_id
    349353     * @param int $step
    350      *
    351354     * @return array $elements
     355     * @since 1.0.0
    352356     */
    353357    public function get_elements( $survey_id, $step = 0 ) {
     
    374378    /**
    375379     * Processing entered data
     380     * @since 1.0.0
    376381     */
    377382    public function process_response() {
     
    449454    /**
    450455     * Saving response data
     456     * @since 1.0.0
    451457     */
    452458    private function save_response() {
     
    487493     * @param array $response
    488494     * @param int   $step
    489      *
    490495     * @return boolean $validated
     496     * @since 1.0.0
    491497     */
    492498    public function validate_response( $survey_id, $response, $step ) {
     
    569575     * @param int   $survey_id
    570576     * @param array $response
    571      *
    572577     * @return boolean $saved
     578     * @since 1.0.0
    573579     */
    574580    private function save_data( $survey_id, $response ) {
     
    635641     * Has the user participated survey
    636642     *
    637      * @param         $questions_id
    638      * @param     int $user_id
    639      *
    640      * @return bool $has_participated
     643     * @param $questions_id
     644     * @param int $user_id
     645     * @return boolean $has_participated
    641646     * @internal param int $survey_id
     647     * @since 1.0.0
    642648     */
    643649    public function has_participated( $questions_id, $user_id = NULL ) {
     
    673679     *
    674680     * @param $questions_id
    675      *
    676681     * @return bool $has_participated
    677682     * @internal param int $survey_id
     683     * @since 1.0.0
    678684     *
    679685     */
     
    699705    /**
    700706     * Sending out finish email to participator
     707     * @since 1.0.0
    701708     */
    702709    public function email_finished() {
     
    730737     *
    731738     * @param int $survey_id
    732      *
    733739     * @return string $html
     740     * @since 1.0.0
    734741     */
    735742    public function text_thankyou_for_participation( $survey_id ) {
     
    756763     *
    757764     * @param int $survey_id
    758      *
    759765     * @return string $html
     766     * @since 1.0.0
    760767     */
    761768    public function text_already_participated( $survey_id ) {
     
    781788     *
    782789     * @return string $html
     790     * @since 1.0.0
    783791     */
    784792    public function text_not_logged_in() {
     
    795803     *
    796804     * @return string $html
     805     * @since 1.0.0
    797806     */
    798807    public function text_cant_participate() {
     
    809818     *
    810819     * @param int $survey_id
    811      *
    812820     * @return string $html
     821     * @since 1.0.0
    813822     */
    814823    public function show_results( $survey_id ) {
  • questions/trunk/components/element.php

    r1162557 r1167167  
    119119     */
    120120    var $create_answer_params = array();
     121   
     122    var $answer_is_multiple = FALSE;
    121123   
    122124    /**
     
    342344        endif;
    343345       
     346        // Adding description
     347        if ( ! empty( $this->settings[ 'description' ] ) ):
     348            $html .= '<div class="questions-element-description">';
     349            $html .= $this->settings[ 'description' ];
     350            $html .= '</div>';
     351        endif;
     352       
    344353        // Fetching user response data
    345354        $this->get_response();
     
    347356        $html .= '<div class="answer">';
    348357        $html .= $this->input_html();
    349        
    350         // Adding description
    351         if ( ! empty( $this->settings[ 'description' ] ) ):
    352             $html .= '<p class="questions-element-description">';
    353             $html .= $this->settings[ 'description' ];
    354             $html .= '</p>';
    355         endif;
    356 
    357358        $html .= '</div>';
    358359   
     
    709710   
    710711                $input = '<textarea name="' . $name . '">' . $value . '</textarea>';
     712                break;
     713               
     714            case 'wp_editor':
     715                $settings = array(
     716                    'textarea_name' => $name
     717                );
     718                ob_start();
     719                wp_editor( $value, 'qu_wp_editor_' . md5( time() * rand() ), $settings );
     720                $input = ob_get_clean();
    711721                break;
    712722   
  • questions/trunk/components/elements/description.php

    r1162557 r1167167  
    2929
    3030    public function input_html() {
    31 
    32         $html = '<div class="survey-element survey-element-' . $this->id . '">';
    33         $html .= '<div class="survey-description">' . $this->settings[ 'description' ] . '</div>';
    34         $html .= '</div>';
    35 
    36         return $html;
    3731    }
    3832
     
    4236            'description' => array(
    4337                'title'       => esc_attr__( 'Text to show', 'questions-locale' ),
    44                 'type'        => 'textarea',
     38                'type'        => 'wp_editor',
    4539                'description' => esc_attr__( 'The text which will be shown in the form.', 'questions-locale' ),
    4640                'default'     => ''
  • questions/trunk/components/elements/dropdown.php

    r1162557 r1167167  
    6868            'description' => array(
    6969                'title'       => esc_attr__( 'Description', 'questions-locale' ),
    70                 'type'        => 'text',
     70                'type'        => 'wp_editor',
    7171                'description' => esc_attr__( 'The description will be shown after the question.', 'questions-locale' ),
    7272                'default'     => ''
  • questions/trunk/components/elements/multiplechoice.php

    r1162557 r1167167  
    6363            'description' => array(
    6464                'title'       => esc_attr__( 'Description', 'questions-locale' ),
    65                 'type'        => 'text',
     65                'type'        => 'wp_editor',
    6666                'description' => esc_attr__( 'The description will be shown after the question.', 'questions-locale' ),
    6767                'default'     => ''
  • questions/trunk/components/elements/onechoice.php

    r1162557 r1167167  
    6262            'description' => array(
    6363                'title'       => esc_attr__( 'Description', 'questions-locale' ),
    64                 'type'        => 'text',
     64                'type'        => 'wp_editor',
    6565                'description' => esc_attr__( 'The description will be shown after the question.', 'questions-locale' ),
    6666                'default'     => ''
  • questions/trunk/components/elements/separator.php

    r1162557 r1167167  
    4646            'header' => array(
    4747                'title'       => esc_attr__( 'Headline', 'questions-locale' ),
    48                 'type'        => 'text',
     48                'type'        => 'wp_editor',
    4949                'description' => esc_attr__( 'Text which will be shown above the separator', 'questions-locale' ),
    5050                'default'     => ''
  • questions/trunk/components/elements/text.php

    r1162557 r1167167  
    3838            'description' => array(
    3939                'title'       => esc_attr__( 'Description', 'questions-locale' ),
    40                 'type'        => 'text',
     40                'type'        => 'wp_editor',
    4141                'description' => esc_attr__( 'The description will be shown after the question.', 'questions-locale' ),
    4242                'default'     => ''
  • questions/trunk/components/elements/textarea.php

    r1162557 r1167167  
    3939            'description' => array(
    4040                'title'       => esc_attr__( 'Description', 'questions-locale' ),
    41                 'type'        => 'text',
     41                'type'        => 'wp_editor',
    4242                'description' => esc_attr__( 'The description will be shown after the question.', 'questions-locale' ),
    4343                'default'     => ''
  • questions/trunk/components/survey.php

    r1162557 r1167167  
    2727 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    2828 */
     29 
     30if ( ! defined( 'ABSPATH' ) ) {
     31    exit;
     32}
     33
    2934class Questions_Survey {
    3035
    3136    /**
    3237     * @var int $id Survey ID
     38     * @since 1.0.0
    3339     */
    3440    public $id;
     
    3642    /**
    3743     * @var string $title Title of Survey
     44     * @since 1.0.0
    3845     */
    3946    public $title;
     
    4148    /**
    4249     * @var array $elements All elements of the survey
     50     * @since 1.0.0
    4351     */
    4452    public $elements = array();
     
    4654    /**
    4755     * @var int $splitter_count Counter for form splitters
     56     * @since 1.0.0
    4857     */
    4958    public $splitter_count = 0;
     
    5160    /**
    5261     * Constructor
    53      *
    5462     * @param int $id The id of the survey
     63     * @since 1.0.0
    5564     */
    5665    public function __construct( $id = NULL ) {
     
    6372    /**
    6473     * Populating class variables
    65      *
     74     * 
    6675     * @param int $id The id of the survey
     76     * @since 1.0.0
    6777     */
    6878    private function populate( $id ) {
     
    8090    /**
    8191     * Getting all element objects
    82      *
     92     * 
    8393     * @param int $id The id of the survey
    84      *
    8594     * @return array $elements All element objects of the survey
     95     * @since 1.0.0
    8696     */
    8797    public function get_elements( $id = NULL ) {
     
    126136    /**
    127137     * Getting responses of a survey
    128      *
     138     * 
    129139     * @param bool|int $element_id Get responses of a special element
    130140     * @param boolean  $userdata   Adding user specified data to response array
    131      *
    132141     * @return array $responses
     142     * @since 1.0.0
    133143     */
    134144    public function get_responses( $element_id = FALSE, $userdata = TRUE ) {
     
    166176    /**
    167177     * Gettiung all user ids of a survey
    168      *
     178     * 
    169179     * @return array $responses All user ids formatted for response array
     180     * @since 1.0.0
    170181     */
    171182    private function get_response_user_ids() {
     
    196207    /**
    197208     * Gettiung all timestrings of a survey
    198      *
     209     * 
    199210     * @param string $timeformat
    200      *
    201211     * @return array $responses All timestrings formatted for response array
     212     * @since 1.0.0
    202213     */
    203214    private function get_response_timestrings( $timeformat = 'd.m.Y H:i' ) {
     
    225236        return $responses;
    226237    }
    227 
    228     // Need to be here?
    229     public function participated_survey( $user_id = NULL ) {
    230 
    231         global $wpdb, $current_user, $questions_global;
    232 
    233         if ( '' == $user_id ):
    234             get_currentuserinfo();
    235             $user_id = $user_id = $current_user->ID;
    236         endif;
    237 
    238         $sql = $wpdb->prepare( "SELECT id FROM {$questions_global->tables->responds} WHERE  user_id=%s", $user_id );
    239 
    240         return $wpdb->get_col( $sql );
    241     }
    242238}
    243239
     240/**
     241 * Checks if a survey exists
     242 *
     243 * @param int $survey_id Survey id
     244 * @return boolean $exists TRUE if survey exists, FALSE if not
     245 */
    244246function qu_survey_exists( $survey_id ) {
    245247
  • questions/trunk/functions.php

    r1161504 r1167167  
    222222    $data = trim( $data );
    223223    $data = stripslashes( $data );
    224     $data = htmlspecialchars( $data );
    225224    return $data;
    226225}
  • questions/trunk/includes/css/display.css

    r1161504 r1167167  
    11/* This stylesheet is used to style the public view of the plugin. */
     2/**
     3 *  Survey Element
     4 */
    25#questions .survey-element{
    36    margin-bottom:20px;
    47}
    58#questions .survey-element p{
    6     margin:0;
    7     font-size:0.9em;
     9    margin:5px;
    810}
    9 #questions .survey-element h3,
    10 #questions .survey-element h5{
    11     margin: 0 0 10px 0;
     11#questions .survey-element > h3,
     12#questions .survey-element > h5,
     13#questions .survey-element > div
     14{
     15    margin-bottom:10px;
    1216}
    1317#questions .survey-element hr{
     
    1620    border-radius: 3px;
    1721}
    18 #questions .questions-description{
     22/**
     23 *  Pagination
     24 */
     25#questions .questions-pagination{
    1926    margin-bottom: 20px;
    2027}
    21 #questions .questions-description span.questions-highlight-number{
     28#questions .questions-pagination span.questions-highlight-number{
    2229    border-radius: 3px;
    2330    background-color: #CCC;
     
    2532    color:#FFF;
    2633}
     34/**
     35 *  Errors
     36 */
    2737#questions .questions-element-error{
    2838    border: 1px dashed #F00;
     
    4151    margin: 0 0 0 20px;
    4252}
     53/**
     54 *  ?
     55 */
    4356#questions table.questions-range-table{
    4457    width:auto;
  • questions/trunk/init.php

    r1162710 r1167167  
    44 * Plugin URI:   http://www.awesome.ug
    55 * Description:  Drag & drop your survey/poll with the WordPress Questions plugin.
    6  * Version:      1.0.0 beta 12
     6 * Version:      1.0.0 beta 13
    77 * Author:       awesome.ug
    88 * Author URI:   http://www.awesome.ug
     
    3939        register_deactivation_hook( __FILE__, array( __CLASS__, 'deactivate' ) );
    4040        register_uninstall_hook( __FILE__, array( __CLASS__, 'uninstall' ) );
     41       
     42        // If plugin isn't installed, install it now
     43        if( !self::is_installed() )
     44            add_action( 'init', array( __CLASS__, 'install_plugin' ), 100  );
    4145
    4246        // Functions on Frontend
     
    7579     */
    7680    public static function activate( $network_wide ) {
    77 
    7881        global $wpdb;
    79 
     82       
     83        self::install_tables();
     84    } // end activate
     85   
     86    /**
     87     * Is plugin already installed?
     88     */
     89    public static function is_installed(){
     90        global $wpdb;
     91       
     92        $tables = array(       
     93            $wpdb->prefix . 'questions_questions',
     94            $wpdb->prefix . 'questions_answers',
     95            $wpdb->prefix . 'questions_responds',
     96            $wpdb->prefix . 'questions_respond_answers',
     97            $wpdb->prefix . 'questions_settings',
     98            $wpdb->prefix . 'questions_participiants'
     99        );
     100       
     101        // Checking if all tables are existing
     102        $not_found = FALSE;
     103        foreach( $tables AS $table ):
     104            if( $wpdb->get_var( "SHOW TABLES LIKE '$table'" ) != $table ):
     105                $not_found = TRUE;
     106            endif;
     107        endforeach;
     108       
     109        $is_installed_option = (boolean) get_option( 'questions_is_installed', FALSE );
     110       
     111        if( $not_found || FALSE == $is_installed_option )
     112            return FALSE;
     113       
     114        return TRUE;
     115    }
     116   
     117    /**
     118     * Installing plugin
     119     */
     120    public static function install_plugin(){
     121        self::install_tables();
     122        flush_rewrite_rules();
     123        update_option( 'questions_is_installed', TRUE );
     124    }
     125   
     126    /**
     127     * Creating / Updating tables
     128     */
     129    public static function install_tables(){
     130        global $wpdb;
     131       
    80132        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    81133
     
    169221
    170222        update_option( 'questions_db_version', '1.1.0' );
    171 
    172     } // end activate
     223    }
    173224
    174225    /**
     
    179230     */
    180231    public static function deactivate( $network_wide ) {
     232       
     233        delete_option( 'questions_is_installed' );
    181234    } // end deactivate
    182235
Note: See TracChangeset for help on using the changeset viewer.