public function render_content()
 {
     echo '<label><span class="customize-control-title">' . esc_html($this->label) . '</span></label>';
     ob_start();
     icit_fields::field_textarea(array('name' => (string) $this->setting->id, 'description' => '', 'default' => $this->setting->default, 'tiny_mce' => false, 'edit_args' => array('media_buttons' => false, 'teeny' => true, 'textarea_rows' => $this->textarea_rows)));
     $textarea = ob_get_clean();
     echo str_replace('<textarea', '<textarea ' . $this->get_link(), $textarea);
 }
예제 #2
0
        public function meta_box_results(WP_Post $post, $meta_box)
        {
            $quiz_type = get_post_meta($post->ID, 'type', true);
            echo '
			<table class="form-table">
				<tbody>';
            // results if not a poll type
            //if ( $quiz_type !== 'poll' ) {
            $result_title = get_post_meta($post->ID, 'result_title', true);
            echo '
						<tr>
							<th><label>' . __('Results title') . '</label><br/><span class="description">' . __('This is the text shown at the very top of the results panel') . '</span></th>
							<td>';
            icit_fields::field_text(array('name' => "result_title", 'value' => $result_title ? $result_title : 'Results', 'class' => 'widefat', 'default' => 'Results'));
            echo '
							</td>
						</tr>';
            // result text or intro result text
            echo '
						<tr class="quiz-result-default">
							<th><label>' . __('Results introduction (default)') . '</label><br/><span class="description">' . __('This is shown below the title and can be overridden by any Introduction text set in graduated results (below)') . '</span></th>
							<td>';
            $result_introduction = get_post_meta($post->ID, 'result_introduction', true);
            icit_fields::field_text(array('name' => 'result_introduction', 'value' => $result_introduction ? $result_introduction : '<p>' . __('Here are your results') . '</p>', 'class' => 'widefat', 'default' => 'Here are your results'));
            echo '
							</td>
						</tr>';
            if ($quiz_type !== 'which') {
                // You scored text
                $result_heading = get_post_meta($post->ID, 'result_heading', true);
                echo '
							<tr>
								<th><label>' . __('Score heading') . '</label><br/><span class="description">' . __('This is the text displayed directly above the quiz score') . '</span></th>
								<td>';
                icit_fields::field_text(array('name' => "result_heading", 'value' => $result_heading ? $result_heading : 'You scored ...', 'class' => 'widefat', 'default' => 'You scored ...'));
                echo '
								</td>
							</tr>';
            }
            // Default base text
            echo '
						<tr class="quiz-result-default">
							<th><label>' . __('Results text (default)') . '</label><br/><span class="description">' . __('This is displayed underneath the score and can be overridden by any results text set in graduated results (below)') . '</span></th>
							<td>';
            $result = get_post_meta($post->ID, 'result', true);
            icit_fields::field_textarea(array('name' => 'result', 'value' => $result ? $result : '<p>' . __('Congratulations on your score of <strong>{{state.points}}</strong> out of <strong>{{state.maxpoints}}</strong>!') . '</p>', 'tiny_mce' => true, 'edit_args' => array('media_buttons' => true, 'teeny' => true, 'textarea_rows' => 2, 'wpautop' => true), 'default' => '<p>Congratulations on your score of <strong>{{state.points}}</strong> out of <strong>{{state.maxpoints}}</strong>!</p>'));
            echo '
							</td>
						</tr>';
            $results = get_post_meta($post->ID, 'results', true);
            // default results array
            if (!$results) {
                $results = array();
                if ($quiz_type === 'which') {
                    $results = array(array('points' => 0, 'image' => false, 'result' => '<p>You scored <strong>{{state.points}}</strong> out of <strong>{{state.maxpoints}}</strong>!</p>', 'short' => ''), array('points' => 1, 'image' => false, 'result' => '<p>You scored <strong>{{state.points}}</strong> out of <strong>{{state.maxpoints}}</strong>!</p>', 'short' => ''));
                }
            }
            // placeholder for js
            $results['__i__'] = array();
            echo '
						<tr>
							<th>
								<h2>' . __('Graduated Results') . '</h2>
								<div class="description">
									<p class="description">' . __('You can show custom results based on the number of points reached.') . '</p>
								</div>
							</th>
							<td>';
            $prev_points = 0;
            foreach ($results as $i => $result) {
                $min = $i > 0 ? $prev_points + 1 : $prev_points;
                $result = wp_parse_args($result, array('points' => $min, 'image' => false, 'result' => '<p>Congratulations on your score of <strong>{{state.points}}</strong> out of <strong>{{state.maxpoints}}</strong>!</p>', 'short' => ''));
                // make sure the points make sense
                $result['points'] = max($min, $result['points']);
                echo '
								<div class="multiple-results result-field postbox"' . ($i === '__i__' ? ' style="display:none" id="result-template"' : '') . '>
									<table class="form-table">
										<tbody>';
                echo '
											<tr class="quiz-result quiz-result-points">
												<th>' . __('Points') . '</th>
												<td>From <strong>' . $min . '</strong> to ';
                icit_fields::field_numeric(array('name' => "results[{$i}][points]", 'value' => $result['points'], 'min' => $min));
                echo '
												</td>
											</tr>';
                echo '
											<tr>
												<th><label>' . __('Results title') . '</label><br/><span class="description">' . __('The result title (overrides default text)') . '</span></th>
												<td>';
                icit_fields::field_text(array('name' => "results[{$i}][short]", 'value' => $result['short'], 'class' => 'widefat'));
                echo '
												</td>
											</tr>';
                echo '
											<tr class="quiz-result">
												<th>' . __('Image') . '</th>
												<td>';
                icit_fields::field_image(array('name' => "results[{$i}][image]", 'value' => $result['image'], 'size' => 'large'));
                echo '
												</td>
											</tr>';
                echo '
											<tr>
												<th><label>' . __('Results text') . '</label><br/><span class="description">' . __('Overrides default text') . '</span></th>
												<td>';
                icit_fields::field_textarea(array('name' => "results_{$i}_result", 'value' => $result['result'], 'tiny_mce' => $i !== '__i__' ? true : false, 'edit_args' => array('media_buttons' => false, 'teeny' => true, 'textarea_rows' => 4, 'wpautop' => true)));
                echo '
												</td>
											</tr>';
                echo '
										</tbody>
									</table>';
                if ($i !== 0 && $quiz_type === 'which' || $i === '__i__' || $quiz_type !== 'which') {
                    echo '<p><input type="submit" name="deleteresult[' . $i . ']" class="button deletion" value="' . __('Delete Result') . '" /></p>';
                }
                echo '
								</div>';
                $prev_points = $result['points'];
            }
            echo '
								<p><input type="submit" class="button" name="addresult" value="' . __('Add new result') . '" /></p>';
            echo '
							</td>
						</tr>';
            // poll results
            //} else {
            //
            //	$result_title = get_post_meta( $post->ID, 'result_title', true );
            //	echo '
            //			<tr>
            //				<th><label>' . __( 'Results title' ) . '</label><br/><span class="description">' . __( 'This is the text shown at the very top of the results panel' ) . '</span></th>
            //				<td>';
            //				icit_fields::field_text( array(
            //					'name' => "result_title",
            //					'value' => $result_title ? $result_title : 'Thank you',
            //					'class' => 'widefat',
            //					'default' => 'Thank you'
            //				) );
            //	echo '
            //				</td>
            //			</tr>';
            //
            //	// result text or intro result text
            //	echo '
            //			<tr class="quiz-result-default">
            //				<th><label>' . __( 'Results introduction (default)' ) . '</label><br/><span class="description">' . __( 'This is shown below the title' ) . '</span></th>
            //				<td>';
            //				$result_introduction = get_post_meta( $post->ID, 'result_introduction', true );
            //				icit_fields::field_textarea( array(
            //					'name' => 'result_introduction',
            //					'value' => $result_introduction ? $result_introduction : '<p>' . __( 'Here are the current results' ) . '</p>',
            //					'tiny_mce' => false,
            //					'edit_args' => array(
            //						'media_buttons' => false,
            //						'teeny' => false,
            //						'textarea_rows' => 2,
            //						'wpautop' => true
            //					),
            //					'default' => 'Here are the current results'
            //				) );
            //	echo '
            //				</td>
            //			</tr>';
            //
            //	// Default base text
            //	echo '
            //			<tr class="quiz-result-default">
            //				<th><label>' . __( 'Results text (default)' ) . '</label><br/><span class="description">' . __( 'This is displayed underneath the results panel' ) . '</span></th>
            //				<td>';
            //				$result = get_post_meta( $post->ID, 'result', true );
            //				icit_fields::field_textarea( array(
            //					'name' => 'result',
            //					'value' => $result ? $result : '<p>' . __( 'Please come back and be a part of our polls in the future.' ) . '</p>',
            //					'tiny_mce' => true,
            //					'edit_args' => array(
            //						'media_buttons' => true,
            //						'teeny' => true,
            //						'textarea_rows' => 2,
            //						'wpautop' => true
            //					),
            //					'default' => '<p>Please come back and be a part of our polls in the future.</p>'
            //				) );
            //
            //}
            echo '
				</tbody>
			</table>';
        }