Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

first commit

  • Loading branch information...
commit d23f3b641b9f7d70d2f4aba46c5e167d164ed111 0 parents
@welovewordpress authored
10 Context.sublime-menu
@@ -0,0 +1,10 @@
+[
+ {
+ "command": "wordpress_codex_search_selection",
+ "caption": "WordPress Codex Search"
+ },
+ {
+ "command": "wordpress_codex_open_selection",
+ "caption": "WordPress Function Reference"
+ }
+]
14 Default.sublime-commands
@@ -0,0 +1,14 @@
+[
+ {
+ "caption": "WordPress Codex: Search Selection",
+ "command": "wordpress_codex_search_selection"
+ },
+ {
+ "caption": "WordPress Codex: Open Function Reference",
+ "command": "wordpress_codex_open_selection"
+ },
+ {
+ "caption": "WordPress Codex: Search from Input",
+ "command": "wordpress_codex_search_from_input"
+ }
+]
26 Main.sublime-menu
@@ -0,0 +1,26 @@
+[
+ {
+ "caption": "Tools",
+ "mnemonic": "t",
+ "id": "tools",
+ "children":
+ [
+ {
+ "caption": "WordPress Codex",
+ "mnemonic": "f",
+ "id": "wordpress_codex",
+ "children":
+ [
+ {
+ "command": "wordpress_codex_search_selection",
+ "caption": "Search Selection"
+ },
+ {
+ "command": "wordpress_codex_search_from_input",
+ "caption": "Search From Input"
+ }
+ ]
+ }
+ ]
+ }
+]
29 README.md
@@ -0,0 +1,29 @@
+# Search WordPress Codex
+#### [Sublime Text 2](http://www.sublimetext.com/2)
+
+## About
+This is a Sublime Text 2 plugin allowing you to easily search the WordPress Codex.
+
+Most of all it let's you right-click on any WordPress function and select 'WordPress Function Reference' to open the Codex page for *this* function.
+
+The plugin code is based on the [Stackoverflow Plugin](https://github.com/ericmartel/Sublime-Text-2-Stackoverflow-Plugin) script by Eric Martel.
+
+## Usage
+ctrl + shift + P and type `WordPress Codex`, or right click on any function and select 'WordPress Function Reference'.
+
+You can also select 'WordPress Codex Search' to search tje whole codex for the selected text.
+
+## Install
+
+### Package Control
+
+The easiest way to install this is with [Package Control](http://wbond.net/sublime\_packages/package\_control).
+
+ * If you just went and installed Package Control, you probably need to restart Sublime Text 2 before doing this next bit.
+ * Bring up the Command Palette (Command+Shift+p on OS X, Control+Shift+p on Linux/Windows).
+ * Select "Package Control: Install Package" (it'll take a few seconds)
+ * Select WordPress Codex when the list appears.
+
+Package Control will automatically keep Git up to date with the latest version.
+
+If you have some problems or improvements with it, contact me via GitHub.
55 WordPressCodex.py
@@ -0,0 +1,55 @@
+# written by Matthias Krok (www.welovewordpress.de)
+# based on Stackoverflow Search Plugin by Eric Martel (emartel@gmail.com / www.ericmartel.com)
+
+# available commands
+# wordpress_codex_open_selection
+# wordpress_codex_search_selection
+# wordpress_codex_search_from_input
+
+import sublime
+import sublime_plugin
+
+import subprocess
+import webbrowser
+
+def SearchWpCodexFor(text):
+ url = 'http://wordpress.org/search/' + text.replace(' ','%20')
+ webbrowser.open_new_tab(url)
+
+def OpenWpFunctionReference(text):
+ url = 'http://codex.wordpress.org/Function_Reference/' + text.replace(' ','%20')
+ webbrowser.open_new_tab(url)
+
+class WordpressCodexOpenSelectionCommand(sublime_plugin.TextCommand):
+ def run(self, edit):
+ for selection in self.view.sel():
+ # if the user didn't select anything, search the currently highlighted word
+ if selection.empty():
+ selection = self.view.word(selection)
+
+ text = self.view.substr(selection)
+ OpenWpFunctionReference(text)
+
+class WordpressCodexSearchSelectionCommand(sublime_plugin.TextCommand):
+ def run(self, edit):
+ for selection in self.view.sel():
+ # if the user didn't select anything, search the currently highlighted word
+ if selection.empty():
+ selection = self.view.word(selection)
+
+ text = self.view.substr(selection)
+ SearchWpCodexFor(text)
+
+class WordpressCodexSearchFromInputCommand(sublime_plugin.WindowCommand):
+ def run(self):
+ # Get the search item
+ self.window.show_input_panel('Search WordPress Codex for', '',
+ self.on_done, self.on_change, self.on_cancel)
+ def on_done(self, input):
+ SearchWpCodexFor(input)
+
+ def on_change(self, input):
+ pass
+
+ def on_cancel(self):
+ pass
Please sign in to comment.
Something went wrong with that request. Please try again.