Plugin Directory

Changeset 1131247


Ignore:
Timestamp:
04/09/2015 02:54:07 PM (11 years ago)
Author:
awesome-ug
Message:

Added survey shortcode

Location:
questions
Files:
66 added
9 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • questions/trunk/README.txt

    r1130499 r1131247  
    6666== Changelog ==
    6767
     68= 1.0.0 beta 5 =
     69* Added Questions Shortcode for embedding surveys
     70* Fixed some translation fails
     71
    6872= 1.0.0 beta 4 =
    6973* Min length of 0 is possible too now
  • questions/trunk/components/admin/admin.php

    r1128186 r1131247  
    288288            $checked_yes = ' checked="checked"';
    289289       
    290         $html = '<div class="questions-resultsettings-value">';
     290        $html = '<div class="questions-options">';
    291291            $html.= '<p><label for="show_results">' . __( 'Show results after finishing survey', 'questions-locale' ) . '</label></p>';
    292292            $html.= '<input type="radio" name="show_results" value="yes"' . $checked_yes .'>' . __( 'Yes') . ' ';
     
    295295       
    296296        ob_start();
    297         do_action( 'questions_survey_result_settings', $survey_id );
     297        do_action( 'questions_survey_options', $survey_id );
    298298        $html.= ob_get_clean();
    299299       
     
    341341            add_meta_box(
    342342                'survey-options',
    343                 __( 'Result Settings', 'questions-locale' ),
     343                __( 'Options', 'questions-locale' ),
    344344                array( $this, 'meta_box_survey_options' ),
    345345                'questions',
  • questions/trunk/components/charts/shortcodes.php

    r1128186 r1131247  
    3939        add_shortcode( 'question_results', array( __CLASS__ , 'sc_question_results' ) );
    4040       
    41         add_action( 'questions_survey_result_settings', array( __CLASS__ , 'show_survey_result_shortcode' ) );
     41        add_action( 'questions_survey_options', array( __CLASS__ , 'show_survey_result_shortcode' ) );
    4242        add_action( 'questions_element_admin_tabs_content', array( __CLASS__ , 'show_question_result_shortcode' ) );
    4343    }
     
    9191   
    9292    public static function show_survey_result_shortcode( $survey_id ){
    93         $html = '<div class="questions-resultsettings-value shortcode">';
    94         $html.= '<label for="survey_results_shortcode">' . __( 'Shortcode:', 'questions-locale' ) . '</label>';
    95         $html.= '<input type="text" id="survey_results_shortcode" value="[survey_results id=' . $survey_id . ']" />';
     93        $html = '<div class="questions-options shortcode">';
     94        $html.= '<label for="survey_results_shortcode">' . __( 'Results Shortcode:', 'questions-locale' ) . '</label><br />';
     95        $html.= '<input type="text" id="survey_questions_shortcode" value="[survey_results id=' . $survey_id . ']" />';
    9696        $html.= '</div>';
    9797       
  • questions/trunk/components/core/process-response.php

    r1128186 r1131247  
    6767    }
    6868   
    69     private function show_survey( $survey_id ){
     69    public function show_survey( $survey_id ){
    7070        if( TRUE === $this->check_restrictions( $survey_id ) ):
    7171            return $this->survey_form( $survey_id );
     
    233233            return;
    234234       
     235        $questions_survey_id = $_POST[ 'questions_id' ];
     236       
    235237        // Post Type is questions or die
    236         if( 'questions' != $wp_object->query_vars[ 'post_type' ] )
    237             return;
    238        
    239         // Getting Survey id from post or die
    240         if( array_key_exists( 'name', $wp_object->query_vars) ):
    241             $sql = $wpdb->prepare( "SELECT ID FROM {$wpdb->prefix}posts WHERE post_name = %s AND post_type='questions'", $wp_object->query_vars[ 'name' ] );
    242             $questions_survey_id = $wpdb->get_var( $sql );
    243         elseif( array_key_exists( 'p', $wp_object->query_vars) ):
    244             $questions_survey_id = $wp_object->query_vars[ 'p' ];
    245         else:
    246             return;
    247         endif;
     238        if( !qu_survey_exists( $questions_survey_id ) )
     239            return;
    248240       
    249241        if( TRUE !== $this->check_restrictions( $questions_survey_id ) )
  • questions/trunk/components/core/shortcodes.php

    r1127623 r1131247  
    3535    var $question_types = array();
    3636   
    37     public function __construct(){
    38         add_shortcode( 'questions', array( $this, 'questions' ) );
     37    public static function init(){
     38        add_shortcode( 'survey', array( __CLASS__, 'survey' ) );
     39        add_action( 'questions_survey_options', array( __CLASS__ , 'show_survey_shortcode' ), 5 );
    3940    }
    4041   
    41     public function questions( $atts ){
     42    public static function survey( $atts ){
    4243        global $Questions_ProcessResponse;
    43         extract( shortcode_atts( array(
     44       
     45        $atts = shortcode_atts( array(
    4446                'id' => '',
    4547                'title' => __( 'Survey', 'questions-locale' )
    4648            ),
    47             $atts ) );
     49            $atts );
    4850       
    49         if( '' === $id ):
     51        if( '' == $atts[ 'id' ] ):
    5052            _e( 'Please enter an id in the survey shortcode!', 'questions-locale' );
    5153            return;
    5254        endif;
    5355       
    54         echo $Questions_ProcessResponse->get_survey( $id );
     56        if( !qu_survey_exists( $atts[ 'id' ] ) ):
     57            _e( 'Survey not found. Please enter another ID in your shortcode.', 'questions-locale' );
     58            return;
     59        endif;
     60       
     61        echo $Questions_ProcessResponse->show_survey( $atts[ 'id' ] );
     62    }
     63   
     64    public static function show_survey_shortcode( $survey_id ){
     65        $html = '<div class="questions-options shortcode">';
     66        $html.= '<label for="survey_results_shortcode">' . __( 'Survey Shortcode:', 'questions-locale' ) . '</label><br />';
     67        $html.= '<input type="text" id="survey_results_shortcode" value="[survey id=' . $survey_id . ']" />';
     68        $html.= '</div>';
     69       
     70        echo $html;
    5571    }
    5672}
    57 $QuestionsShortCodes = new QuestionsShortCodes();
     73QuestionsShortCodes::init();
  • questions/trunk/components/element.php

    r1130499 r1131247  
    520520    private function admin_widget_settings_tab_field( $name, $field ){
    521521        $widget_id = $this->admin_get_widget_id();
     522        $value = '';
    522523       
    523524        if( array_key_exists( $name, $this->settings ) )
  • questions/trunk/components/survey.php

    r1128186 r1131247  
    224224    }
    225225}
     226function qu_survey_exists( $survey_id ){
     227    global $wpdb;
     228   
     229    $sql = $wpdb->prepare( "SELECT COUNT( ID ) FROM {$wpdb->prefix}posts WHERE ID = %d and post_type = 'questions'", $survey_id );
     230    $var = $wpdb->get_var( $sql );
     231   
     232    if( $var > 0 )
     233        return TRUE;
     234   
     235    return FALSE;
     236}
  • questions/trunk/includes/css/admin.css

    r1128186 r1131247  
    9797}
    9898.survey_element_tabs .shortcode,
    99 .questions-resultsettings-value.shortcode{
     99.questions-options.shortcode{
    100100    background-color: #f7f7f7;
    101101    margin-top:20px;
     
    103103    border: 1px solid #e5e5e5;
    104104}
    105 #questions-content .survey_element_tabs .shortcode .shortcode_input,
    106 .questions-resultsettings-value #survey_results_shortcode{
     105.questions-options input[type="text"]{
     106    background-color: #f7f7f7;
     107    font-size: 11px;
     108    height: 25px;
     109    width:100%;
     110}
     111#questions-content .survey_element_tabs .shortcode .shortcode_input{
    107112    background-color: #f7f7f7;
    108113    font-size: 11px;
  • questions/trunk/init.php

    r1130499 r1131247  
    44Plugin URI: http://www.awesome.ug
    55Description: Drag & drop your survey/poll with the WordPress Questions plugin.
    6 Version: 1.0.0 beta 4
     6Version: 1.0.0 beta 5
    77Author: awesome.ug
    88Author URI: http://www.awesome.ug
  • questions/trunk/languages/questions-locale-de_DE.po

    r1128186 r1131247  
    33"Project-Id-Version: SurveyVal v1.0\n"
    44"Report-Msgid-Bugs-To: \n"
    5 "POT-Creation-Date: 2015-04-05 14:50+0100\n"
    6 "PO-Revision-Date: 2015-04-05 15:02+0100\n"
     5"POT-Creation-Date: 2015-04-09 15:39+0100\n"
     6"PO-Revision-Date: 2015-04-09 15:41+0100\n"
    77"Last-Translator: Sven Wagener <sven.wagener@rheinschmiede.de>\n"
    88"Language-Team: \n"
     
    4545
    4646# @ surveyval-locale
    47 #: ../components/admin/admin.php:72 ../components/element.php:322
     47#: ../components/admin/admin.php:72 ../components/element.php:323
    4848msgid "Settings"
    4949msgstr "Einstellungen"
     
    6666#: ../components/admin/admin.php:163
    6767msgid "All visitors of the site can participate the poll"
    68 msgstr "Alle Besucher der Seite k&ouml;nenn an der Umfrage teilnehmen"
     68msgstr "Alle Besucher der Seite k&ouml;nnen an der Umfrage teilnehmen"
    6969
    7070#: ../components/admin/admin.php:164
    7171msgid "All members of the site can participate the poll"
    72 msgstr "Alle Mitglieder der Seite k&ouml;nenn an der Umfrage teilnehmen"
     72msgstr "Alle Mitglieder der Seite k&ouml;nnen an der Umfrage teilnehmen"
    7373
    7474#: ../components/admin/admin.php:165
     
    130130# @ surveyval-locale
    131131#: ../components/admin/admin.php:251 ../components/admin/admin.php:850
    132 #: ../components/element.php:447 ../components/element.php:490
     132#: ../components/element.php:448 ../components/element.php:491
    133133msgid "Delete"
    134134msgstr "L&ouml;schen"
     
    141141# @ surveyval-locale
    142142#: ../components/admin/admin.php:292 ../components/admin/admin.php:851
    143 #: ../components/element.php:648
     143#: ../components/element.php:650
    144144msgid "Yes"
    145145msgstr "Ja"
     
    147147# @ surveyval-locale
    148148#: ../components/admin/admin.php:293 ../components/admin/admin.php:852
    149 #: ../components/element.php:650
     149#: ../components/element.php:652
    150150msgid "No"
    151151msgstr "Nein"
     
    176176"Sie k&ouml;nenn Teilnehmer einladen, sobald die Umfrage gespeichert ist."
    177177
    178 # @ surveyval-locale
    179178#: ../components/admin/admin.php:343
    180 msgid "Result Settings"
    181 msgstr "Ergebnis-Einstellungen"
     179msgid "Options"
     180msgstr "Optionen"
    182181
    183182#: ../components/admin/admin.php:350
     
    347346
    348347#: ../components/charts/shortcodes.php:94
     348msgid "Results Shortcode:"
     349msgstr "Ergebnis-Shortcode:"
     350
    349351#: ../components/charts/shortcodes.php:103
     352msgid "(CTRL+C and paste into post to embed question results in post)"
     353msgstr ""
     354"(STRG +C  und anschließend in Post einfügen um die Ergebnisse der Frage "
     355"anzuzeigen)"
     356
     357#: ../components/charts/shortcodes.php:104
    350358msgid "Shortcode:"
    351359msgstr "Shortcode:"
    352 
    353 #: ../components/charts/shortcodes.php:102
    354 msgid "(CTRL+C and paste into post to embed question results in post)"
    355 msgstr ""
    356 "(STRG +C  und anschließend in Post einfügen um die Ergebnisse der Frage "
    357 "anzuzeigen)"
    358360
    359361# @ surveyval-locale
     
    425427
    426428# @ surveyval-locale
    427 #: ../components/core/core.php:88 ../components/core/shortcodes.php:45
     429#: ../components/core/core.php:88 ../components/core/shortcodes.php:47
    428430msgid "Survey"
    429431msgstr "Umfrage"
     
    508510
    509511# @ surveyval-locale
    510 #: ../components/core/shortcodes.php:50
     512#: ../components/core/shortcodes.php:52
    511513msgid "Please enter an id in the survey shortcode!"
    512514msgstr "Bitte geb eine id im Umfragen-Shortcode an!"
    513515
    514516# @ surveyval-locale
    515 #: ../components/element.php:59
     517#: ../components/core/shortcodes.php:57
     518msgid "Survey not found. Please enter another ID in your shortcode."
     519msgstr ""
     520"Umfrage nicht gefunden. Bitte geben Sie eine andere ID im Sportcode an."
     521
     522#: ../components/core/shortcodes.php:66
     523msgid "Survey Shortcode:"
     524msgstr "Umfrage-Shortcode:"
     525
     526# @ surveyval-locale
     527#: ../components/element.php:60
    516528msgid "This is a Questions Survey Element."
    517529msgstr "Dies ist ein Questions Umfrage-Element."
    518530
    519 #: ../components/element.php:245
     531#: ../components/element.php:246
    520532msgid "No HTML for Element given. Please check element sourcecode."
    521533msgstr ""
     
    524536
    525537# @ surveyval-locale
    526 #: ../components/element.php:318
     538#: ../components/element.php:319
    527539msgid "Question"
    528540msgstr "Frage"
    529541
    530542# @ surveyval-locale
    531 #: ../components/element.php:354 ../components/element.php:579
     543#: ../components/element.php:355 ../components/element.php:581
    532544msgid "Delete element"
    533545msgstr "Element l&ouml;schen"
    534546
    535547# @ surveyval-locale
    536 #: ../components/element.php:394
     548#: ../components/element.php:395
    537549msgid "Answer/s:"
    538550msgstr "Antwort/en:"
    539551
    540552# @ surveyval-locale
    541 #: ../components/element.php:504
     553#: ../components/element.php:505
    542554msgid "Add Answer"
    543555msgstr "Antwort hinzuf&uuml;gen"
     
    545557# @ surveyval-locale
    546558#: ../components/elements/description.php:18
    547 #: ../components/elements/dropdown.php:61
    548 #: ../components/elements/multiplechoice.php:52
    549 #: ../components/elements/onechoice.php:51 ../components/elements/text.php:32
     559#: ../components/elements/dropdown.php:62
     560#: ../components/elements/multiplechoice.php:53
     561#: ../components/elements/onechoice.php:52 ../components/elements/text.php:32
    550562#: ../components/elements/textarea.php:32
    551563msgid "Description"
     
    574586"Eine Frage hinzufügen, die mittels eines Dropdown Feldes beantwortet wird."
    575587
    576 #: ../components/elements/dropdown.php:38
    577 #: ../components/elements/multiplechoice.php:34
    578 #: ../components/elements/onechoice.php:34
     588#: ../components/elements/dropdown.php:39
     589#: ../components/elements/multiplechoice.php:35
     590#: ../components/elements/onechoice.php:35
    579591msgid "You don´t entered any answers. Please add some to display answers here."
    580592msgstr "Es wird keine Antwort vorgegeben."
    581593
    582 #: ../components/elements/dropdown.php:42
     594#: ../components/elements/dropdown.php:43
    583595msgid "Please select"
    584596msgstr "Bitte w&auml;hlen"
    585597
    586 #: ../components/elements/dropdown.php:63
    587 #: ../components/elements/multiplechoice.php:54
    588 #: ../components/elements/onechoice.php:53 ../components/elements/text.php:34
     598#: ../components/elements/dropdown.php:64
     599#: ../components/elements/multiplechoice.php:55
     600#: ../components/elements/onechoice.php:54 ../components/elements/text.php:34
    589601#: ../components/elements/textarea.php:34
    590602msgid "The description will be shown after the question."
    591603msgstr "Die Beschreibung wird unter der Frage angezeigt."
    592604
    593 #: ../components/elements/dropdown.php:73
    594 #: ../components/elements/onechoice.php:63
     605#: ../components/elements/dropdown.php:74
     606#: ../components/elements/onechoice.php:64
    595607msgid "Please select a value."
    596608msgstr "Bitte w&auml;hlen Sie einen Wert"
     
    614626
    615627# @ surveyval-locale
    616 #: ../components/elements/multiplechoice.php:58
     628#: ../components/elements/multiplechoice.php:59
    617629msgid "Minimum Answers"
    618630msgstr "Minimale Anzahl an Antworten"
    619631
    620632# @ surveyval-locale
    621 #: ../components/elements/multiplechoice.php:60
     633#: ../components/elements/multiplechoice.php:61
    622634msgid "The minimum number of answers which have to be choosed."
    623635msgstr "Die minimale Anzahl an Antworten, welche gew&auml;hlt werden kann."
    624636
    625637# @ surveyval-locale
    626 #: ../components/elements/multiplechoice.php:64
     638#: ../components/elements/multiplechoice.php:65
    627639msgid "Maximum Answers"
    628640msgstr "Maximale Anzahl an Antworten"
    629641
    630642# @ surveyval-locale
    631 #: ../components/elements/multiplechoice.php:66
     643#: ../components/elements/multiplechoice.php:67
    632644msgid "The maximum number of answers which can be choosed."
    633645msgstr "Die maximale Anzahl an Antworten, welche eingegeben werden kann."
    634646
    635 #: ../components/elements/multiplechoice.php:80
     647#: ../components/elements/multiplechoice.php:81
    636648msgid "Too less choices."
    637649msgstr "Zu wenig Angaben."
    638650
    639651# @ surveyval-locale
    640 #: ../components/elements/multiplechoice.php:80
    641 #: ../components/elements/multiplechoice.php:86
     652#: ../components/elements/multiplechoice.php:81
     653#: ../components/elements/multiplechoice.php:87
    642654#, php-format
    643655msgid "You have to choose between %d and %d answers."
    644656msgstr "Sie m&uuml;ssen zwischen %d und %d Antworten ausw&auml;hlen."
    645657
    646 #: ../components/elements/multiplechoice.php:86
     658#: ../components/elements/multiplechoice.php:87
    647659msgid "Too many choices."
    648660msgstr "Zu viele Angaben."
     
    776788#: ../components/elements/textarea.php:18
    777789msgid "Textarea"
    778 msgstr "Textara"
     790msgstr "Textfeld"
    779791
    780792# @ surveyval-locale
     
    892904msgstr "Vergessen Sie nicht, die Umfrage zu beantworten"
    893905
     906# @ surveyval-locale
     907#~ msgid "Result Settings"
     908#~ msgstr "Ergebnis-Einstellungen"
     909
    894910#~ msgid "Show Results"
    895911#~ msgstr "Ergebnisse anzeigen"
    896 
    897 #~ msgid "Survey Options"
    898 #~ msgstr "Umfrage-Optionen"
    899912
    900913#~ msgid "Size"
Note: See TracChangeset for help on using the changeset viewer.