Exemplo n.º 1
0
    /**
     * Create the HTML output for the page (screen) displayed when the menu item is clicked.
     * @link : http://codex.wordpress.org/Adding_Administration_Menus (Step 3)
     */
    public static function wpifw_admin_options()
    {
        if (!current_user_can('edit_others_scenes')) {
            wp_die(__('You do not have sufficient permissions to access this page.'));
        }
        ?>
		<div class="wrap">
            <h2>Story Options</h2>
            
                    <?php 
        settings_errors();
        $display_saved = get_option('opening_scene_updated');
        $icon_color = get_option('icon_color');
        if (wpifw_utils::wpifw_isAdmin()) {
            $allow_fight = get_option('allow_fight');
            $allow_classes = get_option('allow_classes');
            $allow_luck = get_option('allow_luck');
            $allow_passphrase = get_option('allow_passphrase');
            $allow_preface = get_option('allow_preface');
            $wpifw_preface_raw = get_option('wpifw_preface');
            $wpifw_preface = stripslashes($wpifw_preface_raw);
        }
        if ($display_saved == 1) {
            echo '<div class="updated"><p>';
            esc_html_e('Changes', 'wpifw_text');
            echo '<strong>';
            esc_html_e(' saved', 'wpifw_text');
            echo '</strong></p></div>';
            update_option('opening_scene_updated', 0);
        }
        ?>

                <form method="post">
                
                <table class="form-table">
                	<tbody>
                    	<tr>
                        	<th scope="row">
                            	<label for="opening_scene">Opening Scene</label>
                            </th>
                            <td>
                                <select id="opening_scene" name="opening_scene"> 
                                    
                                    <?php 
        $opening_scene = get_option('opening_scene');
        wpifw_utils::wpifw_get_all_scenes($opening_scene);
        ?>
                                    
                                </select>
                            </td>
                        </tr>
                        
                        <?php 
        if (wpifw_utils::wpifw_isAdmin()) {
            $allow_fight = get_option('allow_fight');
            $allow_luck = get_option('allow_luck');
            $allow_passphrase = get_option('allow_passphrase');
            ?>
                        <tr>
                            <th scope="row">
                                <label for="allow_fight">Allow Characters</label>
                            </th>
                            <td>
							<?php 
            echo '<input type="checkbox" id="allow_fight" name="allow_fight"';
            if ($allow_fight == 'on') {
                echo ' checked';
            }
            echo ' ></input>';
            ?>
                            </td>
                        </tr>
                        <tr id="classesRow">
                            <th scope="row">
                                <label for="allow_classes">Allow Classes</label>
                            </th>
                            <td>
							<?php 
            echo '<input type="checkbox" id="allow_classes" name="allow_classes"';
            if ($allow_classes == 'on') {
                echo ' checked';
            }
            echo ' ></input>';
            ?>
                            </td>
                        </tr>
                        <tr>
                            <th scope="row">
                                <label for="allow_luck">Allow luck</label>
                            </th>
                            <td>
							<?php 
            echo '<input type="checkbox" id="allow_luck" name="allow_luck"';
            if ($allow_luck == 'on') {
                echo ' checked';
            }
            echo ' ></input>';
            ?>
                            </td>
                        </tr>
                        <tr>
                            <th scope="row">
                                <label for="allow_passphrase">Allow Passphrases</label>
                            </th>
                            <td>
							<?php 
            echo '<input type="checkbox" id="allow_passphrase" name="allow_passphrase"';
            if ($allow_passphrase == 'on') {
                echo ' checked';
            }
            echo ' ></input>';
            ?>
                            </td>
                        </tr>

                        <?php 
        }
        ?>
                        <tr>
                        	<th scope="row">
                                <label for="image_url">Cover Image</label>
                            </th>
                            <td>    
                               <?php 
        echo '<input type="hidden" name="cover_image_url" id="cover_image_url" class="regular-text" value="';
        $cover_image_url = get_option('cover_image_url');
        echo $cover_image_url;
        echo '">';
        ?>
                                <?php 
        echo '<input type="hidden" name="cover_image_thumbnail_url" id="cover_image_thumbnail_url" class="regular-text" value="';
        $cover_image_thumbnail_url = get_option('cover_image_thumbnail_url');
        echo $cover_image_thumbnail_url;
        echo '">';
        ?>
                                <?php 
        echo '<input type="hidden" name="cover_image_id" id="cover_image_id" class="regular-text" value="';
        $cover_image_id = get_option('cover_image_id');
        echo $cover_image_id;
        echo '">';
        ?>
                                <input type="button" name="upload-btn" id="upload-btn" class="button-secondary" value="Select Image">
                                <input type="button" name="clear-upload-btn" id="clear-upload-btn" class="button-secondary" value="Remove Image">
							</td>
                         </tr>
                         <?php 
        $cover_image_thumbnail_url = get_option('cover_image_thumbnail_url');
        if ($cover_image_thumbnail_url != null) {
            echo '<tr id="cover_image_thumbnail_row"><th scope="row">';
        } else {
            echo '<tr id="cover_image_thumbnail_row" style="display:none"><th scope="row">';
        }
        ?>
                                
                            </th>
                            <td>    
							<?php 
        $cover_image_thumbnail_url = get_option('cover_image_thumbnail_url');
        if ($cover_image_thumbnail_url != null) {
            echo '<img src="';
            echo $cover_image_thumbnail_url;
        } else {
            echo '<img style="display:none" src="';
        }
        echo '" id="cover_image_thumbnail">';
        ?>
							</td>
                    	</tr>
                        <?php 
        if ($cover_image_thumbnail_url != null) {
            echo '<tr id="cover-overlay-row" style="display:table-row">';
        } else {
            echo '<tr id="cover-overlay-row" style="display:none">';
        }
        ?>
                        
                        	<th scope="row">
                                <label for="image_url">Cover Image SVG Overlay</label>
                            </th>
                            <td>    
                               <?php 
        echo '<input type="hidden" name="cover_image_overlay_url" id="cover_image_overlay_url" class="regular-text" value="';
        $cover_image_overlay_url = get_option('cover_image_overlay_url');
        echo $cover_image_overlay_url;
        echo '">';
        ?>
                                <?php 
        echo '<input type="hidden" name="cover_image_overlay_id" id="cover_image_overlay_id" class="regular-text" value="';
        $cover_image_overlay_id = get_option('cover_image_overlay_id');
        echo $cover_image_overlay_id;
        echo '">';
        ?>
                                <?php 
        echo '<input type="text" name="cover_image_overlay_title" id="cover_image_overlay_title" class="regular-text" value="';
        $cover_image_overlay_title = get_option('cover_image_overlay_title');
        echo $cover_image_overlay_title;
        echo '">';
        ?>
                                <input type="button" name="cover-overlay-upload-btn" id="cover-overlay-upload-btn" class="button-secondary" value="Select Image">
                                <input type="button" name="clear-cover-overlay-upload-btn" id="clear-cover-overlay-upload-btn" class="button-secondary" value="Remove Image">
							</td>
                         </tr> 
                         <tr>
                             <th scope="row">
                             	<label for="icon_color">Scroll Icon Colour</label>
                             </th>  
                             <td>
                             	<input type="text" id="icon_color" name="icon_color" value="<?php 
        echo $icon_color;
        ?>
" />
                             </td> 
                         </tr>
                    </tbody>
                </table>
                
                <br />
                <hr />
                
                
                <table class="form-table">
	                <tbody>
    		            <tr>
            			    <th scope="row">
                    			<label for="allow_fight">Use Custom Preface</label>
                			</th>
                			<td>
							<?php 
        echo '<input type="checkbox" id="allow_preface" name="allow_preface"';
        if ($allow_preface == 'on') {
            echo ' checked';
            $content = $wpifw_preface;
        } else {
            $content = '';
        }
        echo ' ></input>';
        ?>
							</td>
						</tr>
					</tbody>
				</table>

				<?php 
        if ($allow_preface == 'on') {
            ?>
				
					<div id="preface-editor" style="display:block">
                
               <?php 
        } else {
            ?>
               
               		<div id="preface-editor" style="display:none">
               
               <?php 
        }
        $editor_id = 'wpifw_preface';
        $settings = array('media_buttons' => false, 'editor_height' => 400, 'wpautop' => true);
        wp_editor($content, $editor_id, $settings);
        ?>
				
				</div>

               <?php 
        submit_button();
        ?>

			</form>  
                  
		<?php 
    }