예제 #1
0
 public static function saveSettings()
 {
     $error = '';
     foreach ($_REQUEST as $key => $value) {
         if ($key[0] != '_' && $key != 'action' && $key != 'submit') {
             if (is_array($value)) {
                 $value = implode('~', $value);
             }
             if ($key == 'wpeditor_logging' && $value == '1') {
                 try {
                     WPEditorLog::createLogFile();
                 } catch (WPEditorException $e) {
                     $error = $e->getMessage();
                     WPEditorLog::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Caught WPEditor exception: " . $e->getMessage());
                 }
             }
             WPEditorSetting::setValue($key, trim(stripslashes($value)));
         }
     }
     if (isset($_REQUEST['_tab'])) {
         WPEditorSetting::setValue('settings_tab', $_REQUEST['_tab']);
     }
     if ($error) {
         $result[0] = 'WPEditorAjaxError';
         $result[1] = '<h3>' . __('Warning', 'wpeditor') . "</h3><p>{$error}</p>";
     } else {
         $result[0] = 'WPEditorAjaxSuccess';
         $result[1] = '<h3>' . __('Success', 'wpeditor') . '</h3><p>' . $_REQUEST['_success'] . '</p>';
     }
     $out = json_encode($result);
     echo $out;
     die;
 }
예제 #2
0
 public static function removeDefaultEditorMenus()
 {
     // Remove default plugin editor
     if (WPEditorSetting::getValue('hide_default_plugin_editor') == 1) {
         global $submenu;
         unset($submenu['plugins.php'][15]);
     }
     if (WPEditorSetting::getValue('hide_default_theme_editor') == 1) {
         // Remove default themes editor
         remove_action('admin_menu', '_add_themes_utility_last', 101);
     }
 }
예제 #3
0
 public static function addPostsJquery($editor)
 {
     global $post;
     if (WPEditorSetting::getValue('enable_post_editor')) {
         $theme = WPEditorSetting::getValue('post_editor_theme') ? WPEditorSetting::getValue('post_editor_theme') : 'default';
         $activeLine = WPEditorSetting::getValue('enable_post_active_line') == 1 ? 'activeline-' . $theme : false;
         $post_editor_settings = array('mode' => 'text/html', 'theme' => $theme, 'activeLine' => $activeLine, 'lineNumbers' => WPEditorSetting::getValue('enable_post_line_numbers') == 1 ? true : false, 'lineWrapping' => WPEditorSetting::getValue('enable_post_line_wrapping') == 1 ? true : false, 'enterImgUrl' => __('Enter the URL of the image:', 'wpeditor'), 'enterImgDescription' => __('Enter a description of the image:', 'wpeditor'), 'lookupWord' => __('Enter a word to look up:', 'wpeditor'), 'tabSize' => WPEditorSetting::getValue('enable_post_tab_size') ? WPEditorSetting::getValue('enable_post_tab_size') : 4, 'indentWithTabs' => WPEditorSetting::getValue('enable_post_tab_size') == 'tabs' ? true : false, 'indentUnit' => WPEditorSetting::getValue('post_indent_unit') == '' ? 2 : WPEditorSetting::getValue('post_indent_unit'), 'editorHeight' => WPEditorSetting::getValue('enable_post_editor_height') ? WPEditorSetting::getValue('enable_post_editor_height') : false, 'fontSize' => WPEditorSetting::getValue("change_post_editor_font_size") ? WPEditorSetting::getValue("change_post_editor_font_size") . "px" : "12px", 'save' => isset($post->post_status) && $post->post_status == 'publish' ? __('Update', 'wpeditor') : __('Save', 'wpeditor'));
         WPEditorAdmin::editorStylesheetAndScripts();
         wp_enqueue_script('wp-editor-posts-jquery');
         wp_localize_script('wp-editor-posts-jquery', 'WPEPosts', $post_editor_settings);
     }
     return $editor;
 }
예제 #4
0
          'Esc': toggleFullscreenEditing
        } // set fullscreen options here
      });
      $jq('.CodeMirror').css('font-size', '<?php 
echo WPEditorSetting::getValue("change_theme_editor_font_size") ? WPEditorSetting::getValue("change_theme_editor_font_size") . "px" : "12px";
?>
');
      if(activeLine) {
        var hlLine = editor.setLineClass(0, activeLine);
      }
      <?php 
if (WPEditorSetting::getValue('enable_theme_editor_height')) {
    ?>
        $jq = jQuery.noConflict();
        $jq('.CodeMirror-scroll, .CodeMirror').height('<?php 
    echo WPEditorSetting::getValue("enable_theme_editor_height");
    ?>
px');
        var scrollDivHeight = $jq('.CodeMirror-scroll div:first-child').height();
        var editorDivHeight = $jq('.CodeMirror').height();
        if(scrollDivHeight > editorDivHeight) {
          $jq('.CodeMirror-gutter').height(scrollDivHeight);
        }
      <?php 
}
?>
      if(!$jq('.CodeMirror .quicktags-toolbar').length) {
        $jq('.CodeMirror').prepend('<div class="quicktags-toolbar">' + 
          '<a href="#" class="button-primary editor-button" id="theme_save">save</a>&nbsp;' + 
          '<a href="#" class="button-secondary editor-button" id="theme_undo">undo</a>&nbsp;' + 
          '<a href="#" class="button-secondary editor-button" id="theme_redo">redo</a>&nbsp;' + 
예제 #5
0
          'Esc': toggleFullscreenEditing
        } // set fullscreen options here
      });
      $jq('.CodeMirror').css('font-size', '<?php 
echo WPEditorSetting::getValue("change_plugin_editor_font_size") ? WPEditorSetting::getValue("change_plugin_editor_font_size") . "px" : "12px";
?>
');
      if(activeLine) {
        var hlLine = editor.setLineClass(0, activeLine);
      }
      <?php 
if (WPEditorSetting::getValue('enable_plugin_editor_height')) {
    ?>
        $jq = jQuery.noConflict();
        $jq('.CodeMirror-scroll, .CodeMirror').height('<?php 
    echo WPEditorSetting::getValue("enable_plugin_editor_height");
    ?>
px');
        var scrollDivHeight = $jq('.CodeMirror-scroll div:first-child').height();
        var editorDivHeight = $jq('.CodeMirror').height();
        if(scrollDivHeight > editorDivHeight) {
          $jq('.CodeMirror-gutter').height(scrollDivHeight);
        }
      <?php 
}
?>
      if(!$jq('.CodeMirror .quicktags-toolbar').length) {
        $jq('.CodeMirror').prepend('<div class="quicktags-toolbar">' + 
          '<a href="#" class="button-primary editor-button" id="plugin_save">save</a>&nbsp;' + 
          '<a href="#" class="button-secondary editor-button" id="plugin_undo">undo</a>&nbsp;' + 
          '<a href="#" class="button-secondary editor-button" id="plugin_redo">redo</a>&nbsp;' + 
예제 #6
0
 public static function replacePluginEditLinks($links)
 {
     $data = '';
     if (isset($_REQUEST['plugin_status']) && in_array($_REQUEST['plugin_status'], array('mustuse', 'dropins'))) {
         $data = $links;
     } elseif (WPEditorSetting::getValue('replace_plugin_edit_links') == 1) {
         foreach ($links as $key => $value) {
             if ($key === 'edit') {
                 $value = str_replace('plugin-editor.php?', 'plugins.php?page=wpeditor_plugin&', $value);
             }
             $data[$key] = $value;
         }
     } else {
         $data = $links;
     }
     return $data;
 }
예제 #7
0
                <h3><?php 
_e('Editor Height', 'wp-editor');
?>
</h3>
              </div>
              <div class="section-body">
                <ul>
                  <li>
                    <label for="enable_post_editor_height"><?php 
_e('Editor Height:', 'wp-editor');
?>
</label>
                  </li>
                  <li class="indent">
                    <input class="small-text" name="enable_post_editor_height" value="<?php 
echo WPEditorSetting::getValue('enable_post_editor_height');
?>
" />
                  </li>
                  <li class="indent description">
                    <p><?php 
_e("This will set the height in pixels for the post editor.<br />Default: 450", 'wp-editor');
?>
</p>
                  </li>
                </ul>
              </div>
            </div>
            <div id="save-settings">
              <ul>
                <li>
예제 #8
0
 public static function allowedFiles($dir, $file)
 {
     $slash = '/';
     if (WPWINDOWS) {
         $slash = '\\';
     }
     $output = true;
     if (strstr($dir, 'plugins')) {
         $allowed_extensions = explode('~', WPEditorSetting::getValue('plugin_editor_allowed_extensions'));
     } elseif (strstr($dir, 'themes')) {
         $allowed_extensions = explode('~', WPEditorSetting::getValue('theme_editor_allowed_extensions'));
     }
     if (is_dir($dir . $slash . $file)) {
         $output = true;
     } else {
         $file = pathinfo($file);
         if (isset($file['extension']) && in_array($file['extension'], $allowed_extensions)) {
             $output = true;
         } else {
             $output = false;
         }
     }
     return $output;
 }