コード例 #1
0
ファイル: tabx.php プロジェクト: laiello/suitex
 function adminPage()
 {
     if (current_user_can('publish_pages')) {
         if ($_POST['submit']) {
             $omit = array('submit', 'wp_nonce');
             if (!wp_verify_nonce($_POST['wp_nonce'], 'tabx')) {
                 die('Invalid Token');
             }
             foreach ($_POST as $k => $v) {
                 if (!in_array($k, $omit)) {
                     $this->options[$k] = $v;
                 }
             }
             if ($_FILES['image']['name'] != '') {
                 $file = wp_handle_upload($_FILES['image'], array('test_form' => false));
                 $this->options['image'] = $file['url'];
             }
             update_option('tabx_options', $this->options);
             $message = '<p>Options Saved</p>';
         }
         $envArray = array('Development', 'Production');
         require_once PHPX_DIR . 'phpx_form.php';
         $form = new phpx_form();
         $text = '<div class="wrap" id="phpxContainer"><h2>Slide Out Tab</h2>';
         if ($message || $_GET['message']) {
             $text .= $message;
         }
         $text .= $form->startForm('tools.php?page=tabx/tabx.php', 'tabxForm', 'post', true);
         $text .= $form->hidden('wp_nonce', wp_create_nonce('tabx'));
         $text .= $form->textField('Link Text', 'link_text', $this->options['link_text']);
         ob_start();
         wp_editor(stripslashes($this->options['content']), 'tabxcontent', array('textarea_name' => 'content'));
         $text .= $form->freeText(ob_get_contents());
         ob_end_clean();
         $locationArray = array('top' => 'top', 'bottom' => 'bottom', 'left' => 'left', 'right' => 'right');
         $actionArray = array('click' => 'click', 'hover' => 'hover');
         $fixedArray = array('true' => 'True', 'false' => 'False');
         $text .= $form->fileField('Image', 'image');
         $text .= $form->freeText('<strong>Current Image: </strong><br /><img src="' . $this->options['image'] . '" />');
         $text .= $form->textField('Image Height', 'height', $this->options['height']);
         $text .= $form->textField('Image Width', 'width', $this->options['width']);
         $text .= $form->dropDown('Location', 'location', $this->options['location'], $locationArray);
         $text .= $form->textField('Speed', 'speed', $this->options['speed']);
         $text .= $form->dropDown('Action', 'action', $this->options['action'], $actionArray);
         $text .= $form->textField('Top Position', 'top', $this->options['top']);
         $text .= $form->textField('Left Position', 'left', $this->options['left']);
         $text .= $form->dropDown('Fixed Position', 'fixed', $this->options['fixed'], $fixedArray);
         $text .= $form->endForm();
         $text .= '</div>';
         print $text;
     }
 }